@supacloud/cli 0.39.0 → 0.40.0

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.
Files changed (2) hide show
  1. package/dist/index.js +35 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -248357,10 +248357,35 @@ async function runExplain2(args, root) {
248357
248357
  const text = explainObject(manifest, target);
248358
248358
  return textResult2(text, text.startsWith("未找到对象"));
248359
248359
  }
248360
- async function runModuleCheckAction(args, root, environment) {
248360
+ var defaultLiteSpawn = async (command, cwd) => {
248361
+ const proc = Bun.spawn({ cmd: command, cwd, stdout: "pipe", stderr: "pipe" });
248362
+ const [exitCode, stdout, stderr] = await Promise.all([
248363
+ proc.exited,
248364
+ new Response(proc.stdout).text(),
248365
+ new Response(proc.stderr).text()
248366
+ ]);
248367
+ return { exitCode, stdout, stderr };
248368
+ };
248369
+ async function runModuleCheckLite(args, root, spawn3, liteBinary) {
248370
+ const projectDir = resolve8(args.project_dir?.trim() || root);
248371
+ const binary = liteBinary === undefined ? Bun.which("supacloud-lite") : liteBinary;
248372
+ if (!binary) {
248373
+ throw new Error("db module_check --lite 需要本机可用的 supacloud-lite(npm i -g @supacloud/lite,或加入 PATH)");
248374
+ }
248375
+ const command = [binary, "db", "check", "--project-dir", projectDir];
248376
+ if (args.module_file?.trim())
248377
+ command.push("--module-file", resolve8(root, args.module_file.trim()));
248378
+ const result = await spawn3(command, projectDir);
248379
+ const output = [result.stdout.trim(), result.stderr.trim()].filter(Boolean).join(`
248380
+ `);
248381
+ return textResult2(output || "lite db check 无输出", result.exitCode !== 0);
248382
+ }
248383
+ async function runModuleCheckAction(args, root, environment, spawn3, liteBinary) {
248384
+ if (args.lite)
248385
+ return runModuleCheckLite(args, root, spawn3, liteBinary);
248361
248386
  const databaseUrl = args.database_url?.trim() || environment.DATABASE_URL?.trim();
248362
248387
  if (!databaseUrl) {
248363
- throw new Error("db module_check requires --database_url 或环境变量 DATABASE_URL");
248388
+ throw new Error("db module_check requires --database_url、环境变量 DATABASE_URL 或 --lite");
248364
248389
  }
248365
248390
  const modules = await loadDatabaseModules(root, args.module_file);
248366
248391
  const schemas = parseSchemas(args.schema);
@@ -248388,14 +248413,17 @@ async function runModuleCheckAction(args, root, environment) {
248388
248413
  function registerDbGovernanceTools(server2, options = {}) {
248389
248414
  const environment = options.environment || process.env;
248390
248415
  const fallbackRoot = options.currentWorkingDirectory || process.cwd();
248391
- server2.tool("db", "Local database governance (@supacloud/db): lint declared modules, explain objects, reconcile against a live catalog. Actions: lint, explain, module_check", {
248416
+ const liteSpawn = options.liteSpawn || defaultLiteSpawn;
248417
+ server2.tool("db", "Local database governance (@supacloud/db): lint declared modules, explain objects, reconcile against a live catalog or a local SupaCloud Lite project. Actions: lint, explain, module_check", {
248392
248418
  action: withDescription(stringEnum(["lint", "explain", "module_check"]), "Database governance action"),
248393
248419
  module: optional(Type.String(), "[lint] Only lint this manifest module (default: all)"),
248394
248420
  root: optional(Type.String(), "[*] Project root (default: current directory)"),
248395
248421
  module_file: optional(Type.String(), "[*] File exporting defineDatabaseModule(...) (default: <root>/db/modules.ts)"),
248396
248422
  target: optional(Type.String(), "[explain] Policy / function / table name to explain"),
248397
248423
  database_url: optional(Type.String(), "[module_check] Postgres connection URL (default: DATABASE_URL)"),
248398
- schema: optional(Type.String(), "[module_check] Comma-separated schemas to inspect (default: public)")
248424
+ schema: optional(Type.String(), "[module_check] Comma-separated schemas to inspect (default: public)"),
248425
+ lite: optional(Type.Boolean(), "[module_check] Reconcile against a local SupaCloud Lite project (runs supacloud-lite db check)"),
248426
+ project_dir: optional(Type.String(), "[module_check] Lite project directory (with --lite; default: --root)")
248399
248427
  }, async (request) => {
248400
248428
  const root = resolve8(request.root || fallbackRoot);
248401
248429
  switch (request.action) {
@@ -248404,7 +248432,7 @@ function registerDbGovernanceTools(server2, options = {}) {
248404
248432
  case "explain":
248405
248433
  return runExplain2(request, root);
248406
248434
  case "module_check":
248407
- return runModuleCheckAction(request, root, environment);
248435
+ return runModuleCheckAction(request, root, environment, liteSpawn, options.liteBinary);
248408
248436
  default:
248409
248437
  return textResult2(`Unknown db action: ${String(request.action)}`, true);
248410
248438
  }
@@ -250613,7 +250641,7 @@ function registerDeployTools(server2, http, options = {}) {
250613
250641
  // package.json
250614
250642
  var package_default = {
250615
250643
  name: "@supacloud/cli",
250616
- version: "0.39.0",
250644
+ version: "0.40.0",
250617
250645
  description: "Project-scoped CLI for SupaCloud users",
250618
250646
  type: "module",
250619
250647
  main: "./dist/index.js",
@@ -250902,6 +250930,7 @@ EXAMPLES
250902
250930
  ${preferredCommand} db lint --root . --module_file db/modules.ts
250903
250931
  ${preferredCommand} db explain --target public.cases --module_file db/modules.ts
250904
250932
  ${preferredCommand} db module_check --module_file db/modules.ts --database_url "postgresql://..."
250933
+ ${preferredCommand} db module_check --lite --project_dir .
250905
250934
  ${preferredCommand} edge_functions get_config --ref abc123 --slug hello
250906
250935
  ${preferredCommand} edge_functions deploy --ref abc123 --slug hello --path ./supabase/functions/hello --expected-active-version absent --expected-activation-id legacy
250907
250936
  ${preferredCommand} edge_functions deploy --ref abc123 --slug hello --prebundled-path ./dist/hello.js --expected-sha256 <sha256> --expected-active-version 4 --expected-activation-id <uuid>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supacloud/cli",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "description": "Project-scoped CLI for SupaCloud users",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",