forked from wangziqi/gongxue-base
feat: establish production SaaS foundation
This commit is contained in:
@@ -64,6 +64,12 @@ def utc_now_iso() -> str:
|
||||
return datetime.now(timezone.utc).isoformat().replace("+00:00", "Z")
|
||||
|
||||
|
||||
def write_json_file(file_path: pathlib.Path, payload: Any) -> None:
|
||||
with file_path.open("w", encoding="utf-8", newline="\n") as handle:
|
||||
json.dump(payload, handle, ensure_ascii=False, indent=2)
|
||||
handle.write("\n")
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(description="Export PocketBase SQLite collections to JSON.")
|
||||
parser.add_argument("--data-db", required=True, help="Path to PocketBase data.db")
|
||||
@@ -371,19 +377,11 @@ def main() -> int:
|
||||
"generatedAt": utc_now_iso(),
|
||||
"collections": collections,
|
||||
}
|
||||
(export_dir / "pb_schema.sqlite.json").write_text(
|
||||
json.dumps(schema_payload, ensure_ascii=False, indent=2),
|
||||
encoding="utf-8",
|
||||
newline="\n",
|
||||
)
|
||||
write_json_file(export_dir / "pb_schema.sqlite.json", schema_payload)
|
||||
|
||||
storage_manifest = build_storage_manifest(storage_dir, collections) if storage_dir else None
|
||||
if storage_manifest:
|
||||
(export_dir / "storage-manifest.json").write_text(
|
||||
json.dumps(storage_manifest, ensure_ascii=False, indent=2),
|
||||
encoding="utf-8",
|
||||
newline="\n",
|
||||
)
|
||||
write_json_file(export_dir / "storage-manifest.json", storage_manifest)
|
||||
|
||||
aux = auxiliary_summary(aux_db, args.include_aux_logs) if aux_db else None
|
||||
|
||||
@@ -416,11 +414,7 @@ def main() -> int:
|
||||
"auxiliary": aux,
|
||||
}
|
||||
|
||||
(export_dir / "sqlite-export-manifest.json").write_text(
|
||||
json.dumps(manifest, ensure_ascii=False, indent=2),
|
||||
encoding="utf-8",
|
||||
newline="\n",
|
||||
)
|
||||
write_json_file(export_dir / "sqlite-export-manifest.json", manifest)
|
||||
|
||||
print(json.dumps(manifest, ensure_ascii=False))
|
||||
return 0
|
||||
|
||||
Reference in New Issue
Block a user