@supacloud/cli 0.13.0 → 0.14.1
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/dist/index.js +14 -46
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6087,6 +6087,11 @@ function schemaProperties(schema) {
|
|
|
6087
6087
|
}
|
|
6088
6088
|
|
|
6089
6089
|
// src/shared/cli.ts
|
|
6090
|
+
function cliToolResultIsError(toolResult) {
|
|
6091
|
+
if (toolResult.isError === true)
|
|
6092
|
+
return true;
|
|
6093
|
+
return toolResult.content?.some((chunk) => chunk.type === "text" && chunk.text?.trimStart().startsWith("❌") === true) ?? false;
|
|
6094
|
+
}
|
|
6090
6095
|
function coerceCliValue(value) {
|
|
6091
6096
|
if (value === "true")
|
|
6092
6097
|
return true;
|
|
@@ -6193,7 +6198,7 @@ async function runCli(cliTools, args, options = {}) {
|
|
|
6193
6198
|
} else {
|
|
6194
6199
|
console.log(JSON.stringify(result, null, 2));
|
|
6195
6200
|
}
|
|
6196
|
-
process.exit(result
|
|
6201
|
+
process.exit(cliToolResultIsError(result) ? 1 : 0);
|
|
6197
6202
|
} catch (error) {
|
|
6198
6203
|
const message = error instanceof Error ? error.message : String(error);
|
|
6199
6204
|
console.error(`❌ Error: ${message}`);
|
|
@@ -6889,8 +6894,7 @@ Actions: ${allActions.join(", ")}${readOnly ? " (read-only mode)" : ""}`, {
|
|
|
6889
6894
|
`);
|
|
6890
6895
|
break;
|
|
6891
6896
|
}
|
|
6892
|
-
const
|
|
6893
|
-
const baselineResult = await execSql(baselineSql, "migration");
|
|
6897
|
+
const baselineResult = await http.post(`/v1/projects/${ref}/database/migrations/baseline`, { migrations: missing.map(({ name, version }) => ({ name, version })) });
|
|
6894
6898
|
text = baselineResult.ok ? [
|
|
6895
6899
|
`✅ Migration baseline completed for ${dir}`,
|
|
6896
6900
|
`Marked applied: ${missing.length}`,
|
|
@@ -6958,48 +6962,6 @@ function buildRlsPolicySql(qualifiedTable, policyMode, ownerColumnValue) {
|
|
|
6958
6962
|
CREATE POLICY "SupaCloud owner update" ON ${qualifiedTable} FOR UPDATE TO authenticated USING (${predicate}) WITH CHECK (${predicate});
|
|
6959
6963
|
CREATE POLICY "SupaCloud owner delete" ON ${qualifiedTable} FOR DELETE TO authenticated USING (${predicate});`;
|
|
6960
6964
|
}
|
|
6961
|
-
function sqlString(value) {
|
|
6962
|
-
return `'${value.replace(/'/g, "''")}'`;
|
|
6963
|
-
}
|
|
6964
|
-
function buildMigrationBaselineSql(migrations) {
|
|
6965
|
-
const values = migrations.map(({ name, version }) => `(${version}, ${sqlString(name)}, ARRAY[${sqlString(`baseline:${name}`)}]::text[])`).join(`,
|
|
6966
|
-
`);
|
|
6967
|
-
return `
|
|
6968
|
-
CREATE SCHEMA IF NOT EXISTS supabase_migrations;
|
|
6969
|
-
|
|
6970
|
-
CREATE TABLE IF NOT EXISTS supabase_migrations.schema_migrations (
|
|
6971
|
-
version BIGINT PRIMARY KEY,
|
|
6972
|
-
statements TEXT[],
|
|
6973
|
-
name TEXT
|
|
6974
|
-
);
|
|
6975
|
-
|
|
6976
|
-
CREATE TABLE IF NOT EXISTS public.schema_migrations (
|
|
6977
|
-
version VARCHAR(255) PRIMARY KEY,
|
|
6978
|
-
statements TEXT[],
|
|
6979
|
-
name TEXT
|
|
6980
|
-
);
|
|
6981
|
-
|
|
6982
|
-
WITH baseline(version, name, statements) AS (
|
|
6983
|
-
VALUES
|
|
6984
|
-
${values}
|
|
6985
|
-
)
|
|
6986
|
-
INSERT INTO supabase_migrations.schema_migrations (version, statements, name)
|
|
6987
|
-
SELECT version, statements, name FROM baseline
|
|
6988
|
-
ON CONFLICT (version) DO UPDATE
|
|
6989
|
-
SET statements = EXCLUDED.statements,
|
|
6990
|
-
name = EXCLUDED.name;
|
|
6991
|
-
|
|
6992
|
-
WITH baseline(version, name, statements) AS (
|
|
6993
|
-
VALUES
|
|
6994
|
-
${values}
|
|
6995
|
-
)
|
|
6996
|
-
INSERT INTO public.schema_migrations (version, statements, name)
|
|
6997
|
-
SELECT version::text, statements, name FROM baseline
|
|
6998
|
-
ON CONFLICT (version) DO UPDATE
|
|
6999
|
-
SET statements = EXCLUDED.statements,
|
|
7000
|
-
name = EXCLUDED.name;
|
|
7001
|
-
`.trim();
|
|
7002
|
-
}
|
|
7003
6965
|
function formatSqlResult(data) {
|
|
7004
6966
|
if (!data || typeof data !== "object")
|
|
7005
6967
|
return JSON.stringify(data, null, 2);
|
|
@@ -8585,6 +8547,7 @@ Actions: routes, upsert_route, update_route, delete_route, config, get_certifica
|
|
|
8585
8547
|
hosts: withDescription(stringArray, "[upsert_route/update_route] 主机名列表,逗号分隔或 JSON 数组(1-20)"),
|
|
8586
8548
|
paths: withDescription(stringArray, "[upsert_route/update_route] 路径列表,逗号分隔或 JSON 数组(1-32)"),
|
|
8587
8549
|
upstream: optional(Type.String(), "[upsert_route/update_route] 反代上游 host:port 或 http(s)://host[:port]"),
|
|
8550
|
+
managed_upstream: optional(stringEnum(["edge-functions"]), "[upsert_route/update_route] 托管上游(同步 Edge Function)"),
|
|
8588
8551
|
upstream_tls_insecure_skip_verify: optional(Type.Boolean(), "[upsert_route/update_route] 上游 TLS 跳过校验"),
|
|
8589
8552
|
static_root: optional(Type.String(), "[upsert_route/update_route] 静态站点根目录"),
|
|
8590
8553
|
protocol: optional(stringEnum(["http", "https"]), "[upsert_route/update_route] 可选请求协议匹配"),
|
|
@@ -8630,6 +8593,7 @@ Actions: routes, upsert_route, update_route, delete_route, config, get_certifica
|
|
|
8630
8593
|
hosts,
|
|
8631
8594
|
paths,
|
|
8632
8595
|
upstream,
|
|
8596
|
+
managed_upstream,
|
|
8633
8597
|
upstream_tls_insecure_skip_verify,
|
|
8634
8598
|
static_root,
|
|
8635
8599
|
protocol,
|
|
@@ -8675,6 +8639,8 @@ Actions: routes, upsert_route, update_route, delete_route, config, get_certifica
|
|
|
8675
8639
|
};
|
|
8676
8640
|
if (upstream !== undefined)
|
|
8677
8641
|
body.upstream = upstream;
|
|
8642
|
+
if (managed_upstream !== undefined)
|
|
8643
|
+
body.managed_upstream = managed_upstream;
|
|
8678
8644
|
if (upstream_tls_insecure_skip_verify !== undefined)
|
|
8679
8645
|
body.upstream_tls_insecure_skip_verify = upstream_tls_insecure_skip_verify;
|
|
8680
8646
|
if (static_root !== undefined)
|
|
@@ -8710,6 +8676,8 @@ Actions: routes, upsert_route, update_route, delete_route, config, get_certifica
|
|
|
8710
8676
|
};
|
|
8711
8677
|
if (upstream !== undefined)
|
|
8712
8678
|
body.upstream = upstream;
|
|
8679
|
+
if (managed_upstream !== undefined)
|
|
8680
|
+
body.managed_upstream = managed_upstream;
|
|
8713
8681
|
if (upstream_tls_insecure_skip_verify !== undefined)
|
|
8714
8682
|
body.upstream_tls_insecure_skip_verify = upstream_tls_insecure_skip_verify;
|
|
8715
8683
|
if (static_root !== undefined)
|
|
@@ -9866,7 +9834,7 @@ async function main() {
|
|
|
9866
9834
|
console.log(chunk.text);
|
|
9867
9835
|
}
|
|
9868
9836
|
}
|
|
9869
|
-
if (result
|
|
9837
|
+
if (cliToolResultIsError(result))
|
|
9870
9838
|
process.exitCode = 1;
|
|
9871
9839
|
return;
|
|
9872
9840
|
}
|