Public Access
Initial clean VYTA import
This commit is contained in:
commit
3ea1c3f889
92 files changed
+25789
No files matched your search
@@ -0,0 +1,166 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# CONFIG
|
||||
# ------------------------------------------------------------
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
|
||||
VYTA_PROJECT = Path(
|
||||
r"C:\Users\Silicon Solder\Documents\Codex\vyta"
|
||||
)
|
||||
|
||||
DATA_FILE = (
|
||||
VYTA_PROJECT
|
||||
/ "private-data"
|
||||
/ "vyta-data.json"
|
||||
)
|
||||
|
||||
BLOB_PATH = "vyta/vyta-data.json"
|
||||
|
||||
|
||||
# Läs vyta-sync\.env
|
||||
load_dotenv(SCRIPT_DIR / ".env")
|
||||
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# HELPERS
|
||||
# ------------------------------------------------------------
|
||||
|
||||
def find_vercel_cli() -> str:
|
||||
"""
|
||||
Hitta Vercel CLI.
|
||||
|
||||
På Windows ligger global npm CLI normalt som vercel.cmd.
|
||||
"""
|
||||
|
||||
candidates = [
|
||||
"vercel.cmd",
|
||||
"vercel",
|
||||
]
|
||||
|
||||
for candidate in candidates:
|
||||
executable = shutil.which(candidate)
|
||||
|
||||
if executable:
|
||||
return executable
|
||||
|
||||
# Vanlig npm global-bin på Windows
|
||||
appdata = os.environ.get("APPDATA")
|
||||
|
||||
if appdata:
|
||||
fallback = Path(appdata) / "npm" / "vercel.cmd"
|
||||
|
||||
if fallback.exists():
|
||||
return str(fallback)
|
||||
|
||||
raise FileNotFoundError(
|
||||
"Kunde inte hitta Vercel CLI. "
|
||||
"Kontrollera att 'vercel --version' fungerar i PowerShell."
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
print("=" * 60)
|
||||
print("VYTA → VERCEL PRIVATE BLOB")
|
||||
print("=" * 60)
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Kontrollera datafil
|
||||
# --------------------------------------------------------
|
||||
|
||||
if not DATA_FILE.exists():
|
||||
print()
|
||||
print("ERROR: Vyta-datafilen saknas:")
|
||||
print(DATA_FILE)
|
||||
sys.exit(1)
|
||||
|
||||
print()
|
||||
print(f"Datafil: {DATA_FILE}")
|
||||
print(f"Storlek: {DATA_FILE.stat().st_size:,} bytes")
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Blob-token
|
||||
# --------------------------------------------------------
|
||||
|
||||
token = os.environ.get(
|
||||
"BLOB_READ_WRITE_TOKEN"
|
||||
)
|
||||
|
||||
if not token:
|
||||
print()
|
||||
print(
|
||||
"ERROR: BLOB_READ_WRITE_TOKEN saknas i vyta-sync\\.env"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
print("Blob-token: OK")
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Vercel CLI
|
||||
# --------------------------------------------------------
|
||||
|
||||
try:
|
||||
vercel_cli = find_vercel_cli()
|
||||
except FileNotFoundError as exc:
|
||||
print()
|
||||
print(f"ERROR: {exc}")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"Vercel CLI: {vercel_cli}")
|
||||
|
||||
# --------------------------------------------------------
|
||||
# Upload
|
||||
# --------------------------------------------------------
|
||||
|
||||
command = [
|
||||
vercel_cli,
|
||||
"blob",
|
||||
"put",
|
||||
str(DATA_FILE),
|
||||
"--pathname",
|
||||
BLOB_PATH,
|
||||
"--access",
|
||||
"private",
|
||||
"--allow-overwrite",
|
||||
"--content-type",
|
||||
"application/json",
|
||||
"--rw-token",
|
||||
token,
|
||||
]
|
||||
|
||||
print()
|
||||
print(
|
||||
f"Laddar upp till Private Blob: {BLOB_PATH}"
|
||||
)
|
||||
print()
|
||||
|
||||
result = subprocess.run(
|
||||
command,
|
||||
cwd=str(VYTA_PROJECT),
|
||||
text=True,
|
||||
)
|
||||
|
||||
if result.returncode != 0:
|
||||
print()
|
||||
print(
|
||||
f"ERROR: Blob-upload misslyckades "
|
||||
f"(exit code {result.returncode})"
|
||||
)
|
||||
sys.exit(result.returncode)
|
||||
|
||||
print()
|
||||
print("=" * 60)
|
||||
print("VYTA BLOB-UPLOAD KLAR")
|
||||
print("=" * 60)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user