@supacloud/lite 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/cli.js +81 -47
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.5.5](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.5.4...supacloud-lite-v0.5.5) (2026-08-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **lite:** exit Windows CLI after cleanup ([579a714](https://github.com/zuohuadong/supacloud/commit/579a7147a2007885ddcaaabc0123ba10866187a5))
|
|
9
|
+
* **lite:** exit Windows CLI after cleanup ([17fe71e](https://github.com/zuohuadong/supacloud/commit/17fe71e23bdd2b1c79de3fbc7ec54fe3432981d1))
|
|
10
|
+
* **lite:** keep Windows CLI alive through cleanup ([2032834](https://github.com/zuohuadong/supacloud/commit/20328342240321c1f9267b307d9e546849fed85a))
|
|
11
|
+
|
|
3
12
|
## [0.5.4](https://github.com/zuohuadong/supacloud/compare/supacloud-lite-v0.5.3...supacloud-lite-v0.5.4) (2026-08-02)
|
|
4
13
|
|
|
5
14
|
|
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { dirname as dirname5, join as join9, resolve as resolve4 } from "path";
|
|
|
8
8
|
// package.json
|
|
9
9
|
var package_default = {
|
|
10
10
|
name: "@supacloud/lite",
|
|
11
|
-
version: "0.5.
|
|
11
|
+
version: "0.5.5",
|
|
12
12
|
description: "Bun-native, single-project Supabase-compatible backend powered by PGlite",
|
|
13
13
|
type: "module",
|
|
14
14
|
license: "Apache-2.0",
|
|
@@ -9754,21 +9754,21 @@ async function main() {
|
|
|
9754
9754
|
const options = parseArgs(process.argv.slice(2));
|
|
9755
9755
|
const paths = resolveProjectPaths(options);
|
|
9756
9756
|
if (options.command === "version" || options.command === "--version") {
|
|
9757
|
-
|
|
9757
|
+
await writeStandardOutput(`${package_default.version}
|
|
9758
|
+
`);
|
|
9758
9759
|
return;
|
|
9759
9760
|
}
|
|
9760
9761
|
if (options.command === "keys") {
|
|
9761
9762
|
const secrets = await ensureProjectSecrets(paths);
|
|
9762
9763
|
const keys = await mintProjectKeys(secrets.jwtSecret);
|
|
9763
|
-
|
|
9764
|
-
${keys.anonKey}`);
|
|
9765
|
-
if (options.serviceRole)
|
|
9766
|
-
console.log(`
|
|
9764
|
+
const privilegedKey = options.serviceRole ? `
|
|
9767
9765
|
service_role key:
|
|
9768
|
-
${keys.serviceRoleKey}`
|
|
9769
|
-
|
|
9770
|
-
|
|
9771
|
-
|
|
9766
|
+
${keys.serviceRoleKey}` : `
|
|
9767
|
+
Use --service-role to print the privileged key.`;
|
|
9768
|
+
await writeStandardOutput(`anon key:
|
|
9769
|
+
${keys.anonKey}
|
|
9770
|
+
${privilegedKey}
|
|
9771
|
+
`);
|
|
9772
9772
|
return;
|
|
9773
9773
|
}
|
|
9774
9774
|
if (options.command === "db") {
|
|
@@ -9799,9 +9799,10 @@ Use --service-role to print the privileged key.`);
|
|
|
9799
9799
|
if (options.output) {
|
|
9800
9800
|
await mkdir7(dirname5(options.output), { recursive: true });
|
|
9801
9801
|
await writeFile6(options.output, source);
|
|
9802
|
-
|
|
9802
|
+
await writeStandardOutput(`Wrote ${options.output}
|
|
9803
|
+
`);
|
|
9803
9804
|
} else
|
|
9804
|
-
|
|
9805
|
+
await writeStandardOutput(source);
|
|
9805
9806
|
} finally {
|
|
9806
9807
|
await project2.backend.close();
|
|
9807
9808
|
}
|
|
@@ -9816,7 +9817,7 @@ Use --service-role to print the privileged key.`);
|
|
|
9816
9817
|
log: quietLog
|
|
9817
9818
|
});
|
|
9818
9819
|
try {
|
|
9819
|
-
printInspection(await inspectDb(project2.backend.db, "public"));
|
|
9820
|
+
await printInspection(await inspectDb(project2.backend.db, "public"));
|
|
9820
9821
|
} finally {
|
|
9821
9822
|
await project2.backend.close();
|
|
9822
9823
|
}
|
|
@@ -9834,13 +9835,10 @@ Use --service-role to print the privileged key.`);
|
|
|
9834
9835
|
});
|
|
9835
9836
|
try {
|
|
9836
9837
|
const applied = await project2.backend.db.listAppliedMigrations();
|
|
9837
|
-
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
else
|
|
9842
|
-
for (const migration of applied)
|
|
9843
|
-
console.log(`${migration.version} ${migration.name ?? ""}`);
|
|
9838
|
+
const output = options.command === "migrate" ? `${applied.length} migration(s) applied.` : applied.length === 0 ? "no migrations applied" : applied.map((migration) => `${migration.version} ${migration.name ?? ""}`).join(`
|
|
9839
|
+
`);
|
|
9840
|
+
await writeStandardOutput(`${output}
|
|
9841
|
+
`);
|
|
9844
9842
|
} finally {
|
|
9845
9843
|
await project2.backend.close();
|
|
9846
9844
|
}
|
|
@@ -9849,7 +9847,8 @@ Use --service-role to print the privileged key.`);
|
|
|
9849
9847
|
if (options.command !== "start")
|
|
9850
9848
|
throw new Error(`unknown command: ${options.command}`);
|
|
9851
9849
|
const project = await startProjectServer({ ...options, log: (message) => console.log(` ${message}`) });
|
|
9852
|
-
|
|
9850
|
+
const shutdown = waitForShutdown(() => project.close());
|
|
9851
|
+
await writeStandardOutput(`
|
|
9853
9852
|
SupaCloud Lite running
|
|
9854
9853
|
|
|
9855
9854
|
API URL: ${project.url}
|
|
@@ -9862,8 +9861,9 @@ Use --service-role to print the privileged key.`);
|
|
|
9862
9861
|
|
|
9863
9862
|
Run "supacloud-lite keys" for the anon key.
|
|
9864
9863
|
Run "supacloud-lite keys --service-role" only when privileged access is required.
|
|
9864
|
+
|
|
9865
9865
|
`);
|
|
9866
|
-
await
|
|
9866
|
+
await shutdown;
|
|
9867
9867
|
process.exitCode = 0;
|
|
9868
9868
|
}
|
|
9869
9869
|
async function runDbCommand(options) {
|
|
@@ -9886,7 +9886,8 @@ async function runDbCommand(options) {
|
|
|
9886
9886
|
});
|
|
9887
9887
|
try {
|
|
9888
9888
|
const applied = await project2.backend.db.listAppliedMigrations();
|
|
9889
|
-
|
|
9889
|
+
await writeStandardOutput(`reset complete: ${applied.length} migration(s) applied
|
|
9890
|
+
`);
|
|
9890
9891
|
} finally {
|
|
9891
9892
|
await project2.backend.close();
|
|
9892
9893
|
}
|
|
@@ -9896,7 +9897,8 @@ async function runDbCommand(options) {
|
|
|
9896
9897
|
if (subcommand === "diff") {
|
|
9897
9898
|
const ddl = await computeDbDiff({ liveDataDir: paths.dataDir, migrations: project.migrations });
|
|
9898
9899
|
if (ddl.length === 0) {
|
|
9899
|
-
|
|
9900
|
+
await writeStandardError(`No schema changes found.
|
|
9901
|
+
`);
|
|
9900
9902
|
return;
|
|
9901
9903
|
}
|
|
9902
9904
|
const source = `${ddl.join(`
|
|
@@ -9908,9 +9910,10 @@ async function runDbCommand(options) {
|
|
|
9908
9910
|
const output = join9(paths.projectDir, "supabase", "migrations", `${stamp}_${options.diffFile}.sql`);
|
|
9909
9911
|
await mkdir7(join9(paths.projectDir, "supabase", "migrations"), { recursive: true });
|
|
9910
9912
|
await writeFile6(output, source);
|
|
9911
|
-
|
|
9913
|
+
await writeStandardOutput(`Wrote ${output}
|
|
9914
|
+
`);
|
|
9912
9915
|
} else
|
|
9913
|
-
|
|
9916
|
+
await writeStandardOutput(source);
|
|
9914
9917
|
return;
|
|
9915
9918
|
}
|
|
9916
9919
|
if (subcommand === "pull") {
|
|
@@ -9921,9 +9924,11 @@ async function runDbCommand(options) {
|
|
|
9921
9924
|
name: options.positionals[1] ?? "remote_schema"
|
|
9922
9925
|
});
|
|
9923
9926
|
if (!result.path)
|
|
9924
|
-
|
|
9927
|
+
await writeStandardError(`No schema changes to pull.
|
|
9928
|
+
`);
|
|
9925
9929
|
else
|
|
9926
|
-
|
|
9930
|
+
await writeStandardOutput(`Wrote ${result.path} and recorded version ${result.version} as applied.
|
|
9931
|
+
`);
|
|
9927
9932
|
return;
|
|
9928
9933
|
}
|
|
9929
9934
|
throw new Error(`unknown db subcommand: ${subcommand ?? "(none)"}`);
|
|
@@ -9938,9 +9943,12 @@ async function runSnapshotCommand(options) {
|
|
|
9938
9943
|
await ensureProjectSecrets(paths);
|
|
9939
9944
|
const output = options.output ?? join9(paths.stateDir, "backups", `snapshot-${timestamp()}.tar.gz`);
|
|
9940
9945
|
const manifest = await createSnapshot({ paths, packageVersion: package_default.version, storageBackend, output });
|
|
9941
|
-
|
|
9942
|
-
|
|
9943
|
-
|
|
9946
|
+
await writeStandardOutput(`Snapshot created: ${output}
|
|
9947
|
+
`);
|
|
9948
|
+
if (manifest.storageBackend === "s3") {
|
|
9949
|
+
await writeStandardOutput(`S3 objects were not copied; the snapshot contains database metadata and secrets only.
|
|
9950
|
+
`);
|
|
9951
|
+
}
|
|
9944
9952
|
return;
|
|
9945
9953
|
}
|
|
9946
9954
|
if (subcommand === "restore") {
|
|
@@ -9948,11 +9956,15 @@ async function runSnapshotCommand(options) {
|
|
|
9948
9956
|
if (!input)
|
|
9949
9957
|
throw new Error("snapshot restore requires a snapshot file");
|
|
9950
9958
|
const result = await restoreSnapshot({ paths, storageBackend, input, force: options.force });
|
|
9951
|
-
|
|
9952
|
-
|
|
9953
|
-
|
|
9954
|
-
|
|
9955
|
-
|
|
9959
|
+
const rollbackLines = result.rollbackPaths.map((rollbackPath) => `Previous state retained at ${rollbackPath}`);
|
|
9960
|
+
const reconnectLine = result.manifest.storageBackend === "s3" ? ["Reconnect the original S3 bucket/prefix before starting Lite."] : [];
|
|
9961
|
+
await writeStandardOutput([
|
|
9962
|
+
`Snapshot restored from ${resolve4(input)}`,
|
|
9963
|
+
...rollbackLines,
|
|
9964
|
+
...reconnectLine
|
|
9965
|
+
].join(`
|
|
9966
|
+
`) + `
|
|
9967
|
+
`);
|
|
9956
9968
|
return;
|
|
9957
9969
|
}
|
|
9958
9970
|
throw new Error(`unknown snapshot subcommand: ${subcommand ?? "(none)"}`);
|
|
@@ -9965,7 +9977,8 @@ async function runUpgradeCommand(options) {
|
|
|
9965
9977
|
await ensureProjectSecrets(paths);
|
|
9966
9978
|
const output = options.output ?? join9(paths.stateDir, "backups", `pre-upgrade-${timestamp()}.tar.gz`);
|
|
9967
9979
|
await createSnapshot({ paths, packageVersion: package_default.version, storageBackend, output });
|
|
9968
|
-
|
|
9980
|
+
await writeStandardOutput(`Pre-upgrade snapshot: ${output}
|
|
9981
|
+
`);
|
|
9969
9982
|
try {
|
|
9970
9983
|
const project = await createProjectBackend({
|
|
9971
9984
|
...options,
|
|
@@ -9978,7 +9991,8 @@ async function runUpgradeCommand(options) {
|
|
|
9978
9991
|
});
|
|
9979
9992
|
try {
|
|
9980
9993
|
const applied = await project.backend.db.listAppliedMigrations();
|
|
9981
|
-
|
|
9994
|
+
await writeStandardOutput(`Upgrade complete on @supacloud/lite ${package_default.version}: ${applied.length} migration(s) recorded.
|
|
9995
|
+
`);
|
|
9982
9996
|
} finally {
|
|
9983
9997
|
await project.backend.close();
|
|
9984
9998
|
}
|
|
@@ -9986,15 +10000,26 @@ async function runUpgradeCommand(options) {
|
|
|
9986
10000
|
throw new Error(`upgrade failed; snapshot retained at ${output}. Restore it with ` + `"supacloud-lite snapshot restore ${output} --force". ${error instanceof Error ? error.message : String(error)}`);
|
|
9987
10001
|
}
|
|
9988
10002
|
}
|
|
9989
|
-
function printInspection(rows) {
|
|
10003
|
+
async function printInspection(rows) {
|
|
9990
10004
|
if (rows.length === 0) {
|
|
9991
|
-
|
|
10005
|
+
await writeStandardOutput(`No tables in schema "public".
|
|
10006
|
+
`);
|
|
9992
10007
|
return;
|
|
9993
10008
|
}
|
|
9994
10009
|
const width = Math.max(5, ...rows.map((row) => row.table.length));
|
|
9995
|
-
|
|
9996
|
-
|
|
9997
|
-
|
|
10010
|
+
const output = [
|
|
10011
|
+
`${"table".padEnd(width)} ${"rows".padStart(10)} size`,
|
|
10012
|
+
...rows.map((row) => `${row.table.padEnd(width)} ${String(row.rows).padStart(10)} ${row.size}`)
|
|
10013
|
+
];
|
|
10014
|
+
await writeStandardOutput(`${output.join(`
|
|
10015
|
+
`)}
|
|
10016
|
+
`);
|
|
10017
|
+
}
|
|
10018
|
+
async function writeStandardOutput(output) {
|
|
10019
|
+
await Bun.write(Bun.stdout, output);
|
|
10020
|
+
}
|
|
10021
|
+
async function writeStandardError(output) {
|
|
10022
|
+
await Bun.write(Bun.stderr, output);
|
|
9998
10023
|
}
|
|
9999
10024
|
function timestamp() {
|
|
10000
10025
|
return new Date().toISOString().replace(/[-:T]/g, "").slice(0, 14);
|
|
@@ -10047,7 +10072,16 @@ function formatStorage(backend, storageDir) {
|
|
|
10047
10072
|
return "custom driver";
|
|
10048
10073
|
return storageDir;
|
|
10049
10074
|
}
|
|
10050
|
-
|
|
10051
|
-
|
|
10052
|
-
|
|
10053
|
-
|
|
10075
|
+
var windowsLifecycleRef = process.platform === "win32" ? setInterval(() => {}, 1000) : null;
|
|
10076
|
+
var exitCode = 0;
|
|
10077
|
+
try {
|
|
10078
|
+
await main();
|
|
10079
|
+
} catch (error) {
|
|
10080
|
+
await writeStandardError(`${error instanceof Error ? error.message : String(error)}
|
|
10081
|
+
`);
|
|
10082
|
+
exitCode = 1;
|
|
10083
|
+
} finally {
|
|
10084
|
+
if (windowsLifecycleRef !== null)
|
|
10085
|
+
clearInterval(windowsLifecycleRef);
|
|
10086
|
+
}
|
|
10087
|
+
process.exit(exitCode);
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ function randomToken(bytes = 32) {
|
|
|
71
71
|
// package.json
|
|
72
72
|
var package_default = {
|
|
73
73
|
name: "@supacloud/lite",
|
|
74
|
-
version: "0.5.
|
|
74
|
+
version: "0.5.5",
|
|
75
75
|
description: "Bun-native, single-project Supabase-compatible backend powered by PGlite",
|
|
76
76
|
type: "module",
|
|
77
77
|
license: "Apache-2.0",
|