@runa-ai/runa-cli 0.7.1 → 0.7.3
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/{build-HUDIP6KU.js → build-HQMSVN6N.js} +3 -3
- package/dist/{check-LOMVIRHX.js → check-PCSQPYDM.js} +2 -2
- package/dist/{chunk-QM53IQHM.js → chunk-2QX7T24B.js} +1 -1
- package/dist/{chunk-CCW3PLQY.js → chunk-3JO6YP3T.js} +1 -1
- package/dist/{chunk-XDCHRVE3.js → chunk-4XHZQRRK.js} +2 -2
- package/dist/{chunk-7B5C6U2K.js → chunk-A6A7JIRD.js} +35 -2
- package/dist/{chunk-AFY3TX4I.js → chunk-AO554K3G.js} +1 -1
- package/dist/{chunk-Z4Z5DNW4.js → chunk-B3POLMII.js} +12 -0
- package/dist/chunk-CKRLVEIO.js +119 -0
- package/dist/{chunk-HD74F6W2.js → chunk-FWMGC5FP.js} +1 -0
- package/dist/{chunk-FHG3ILE4.js → chunk-OBYZDT2E.js} +38 -8
- package/dist/{chunk-H2AHNI75.js → chunk-PAWNJA3N.js} +1 -1
- package/dist/{chunk-VM3IWOT5.js → chunk-QSEF4T3Y.js} +13 -5
- package/dist/{chunk-NPSRD26F.js → chunk-UHDAYPHH.js} +1 -1
- package/dist/{chunk-2APB25TT.js → chunk-VSH3IXDQ.js} +7 -3
- package/dist/{chunk-644FVGIQ.js → chunk-WPMR7RQ4.js} +9 -2
- package/dist/{chunk-EMB6IZFT.js → chunk-XVNDDHAF.js} +20 -1
- package/dist/{risk-detector-plpgsql-HWKS4OLR.js → chunk-Y5ANTCKE.js} +3 -412
- package/dist/{ci-XY6IKEDC.js → ci-Z4525QW6.js} +2150 -488
- package/dist/{cli-UZA4RBNQ.js → cli-SVXOSMW6.js} +72 -54
- package/dist/commands/ci/commands/ci-prod-db-operations.d.ts +6 -4
- package/dist/commands/ci/commands/ci-prod-types.d.ts +3 -0
- package/dist/commands/ci/commands/ci-prod-workflow.d.ts +1 -1
- package/dist/commands/ci/commands/ci-resolvers.d.ts +1 -1
- package/dist/commands/ci/commands/ci-supabase-local.d.ts +4 -0
- package/dist/commands/ci/machine/actors/build/build-and-playwright.d.ts +1 -1
- package/dist/commands/ci/machine/actors/db/collect-schema-stats.d.ts +11 -1
- package/dist/commands/ci/machine/actors/db/production-preview.d.ts +22 -4
- package/dist/commands/ci/machine/actors/db/schema-canonical-diff.d.ts +8 -1
- package/dist/commands/ci/machine/actors/db/sync-schema.d.ts +1 -0
- package/dist/commands/ci/machine/actors/finalize/index.d.ts +0 -1
- package/dist/commands/ci/machine/actors/index.d.ts +1 -1
- package/dist/commands/ci/machine/actors/setup/local.d.ts +2 -0
- package/dist/commands/ci/machine/actors/setup/pr-common.d.ts +3 -0
- package/dist/commands/ci/machine/actors/setup/pr-local.d.ts +2 -0
- package/dist/commands/ci/machine/commands/machine-runner.d.ts +5 -1
- package/dist/commands/ci/machine/commands/step-telemetry.d.ts +16 -0
- package/dist/commands/ci/machine/contract.d.ts +40 -0
- package/dist/commands/ci/machine/formatters/github-comment-types.d.ts +7 -2
- package/dist/commands/ci/machine/formatters/github-comment.d.ts +2 -1
- package/dist/commands/ci/machine/formatters/sections/final-comment.d.ts +2 -1
- package/dist/commands/ci/machine/formatters/sections/index.d.ts +1 -1
- package/dist/commands/ci/machine/formatters/summary.d.ts +4 -4
- package/dist/commands/ci/machine/guards.d.ts +4 -0
- package/dist/commands/ci/machine/helpers.d.ts +25 -0
- package/dist/commands/ci/machine/machine-state-helpers.d.ts +1 -1
- package/dist/commands/ci/machine/machine.d.ts +15 -8
- package/dist/commands/ci/machine/types.d.ts +9 -0
- package/dist/commands/ci/utils/ci-diagnostics.d.ts +67 -0
- package/dist/commands/ci/utils/ci-summary.d.ts +118 -0
- package/dist/commands/ci/utils/db-url-utils.d.ts +4 -77
- package/dist/commands/ci/utils/github-api.d.ts +14 -0
- package/dist/commands/db/apply/contract.d.ts +73 -0
- package/dist/commands/db/apply/helpers/alter-statement-parsers.d.ts +95 -0
- package/dist/commands/db/apply/helpers/data-compatibility-checker.d.ts +0 -61
- package/dist/commands/db/apply/helpers/function-plan-false-positive-filter.d.ts +36 -0
- package/dist/commands/db/apply/helpers/hazard-handler.d.ts +4 -4
- package/dist/commands/db/apply/helpers/index.d.ts +14 -5
- package/dist/commands/db/apply/helpers/partition-acl-cleaner.d.ts +3 -1
- package/dist/commands/db/apply/helpers/pg-schema-diff-helpers.d.ts +69 -6
- package/dist/commands/db/apply/helpers/plan-ast.d.ts +56 -0
- package/dist/commands/db/apply/helpers/plan-check-filter.d.ts +26 -0
- package/dist/commands/db/apply/helpers/plan-drop-protection.d.ts +43 -0
- package/dist/commands/db/apply/helpers/plan-ordering.d.ts +6 -0
- package/dist/commands/db/apply/helpers/plan-statement-parser.d.ts +39 -0
- package/dist/commands/db/apply/helpers/plan-validator.d.ts +8 -40
- package/dist/commands/db/apply/helpers/retry-logic.d.ts +1 -10
- package/dist/commands/db/apply/helpers/temp-db-bootstrap.d.ts +18 -0
- package/dist/commands/db/apply/helpers/temp-db-dsn.d.ts +14 -0
- package/dist/commands/db/apply/machine.d.ts +56 -32
- package/dist/commands/db/commands/db-apply-error.d.ts +5 -0
- package/dist/commands/db/commands/db-apply.d.ts +2 -0
- package/dist/commands/db/commands/db-sync/directory-placement-check.d.ts +4 -0
- package/dist/commands/db/commands/db-sync/error-classifier.d.ts +1 -1
- package/dist/commands/db/commands/db-sync/plan-boundary-reconciliation.d.ts +3 -0
- package/dist/commands/db/commands/db-sync/precheck-helpers.d.ts +18 -0
- package/dist/commands/db/commands/db-sync/production-precheck.d.ts +15 -0
- package/dist/commands/db/commands/db-sync/risk-scan-collectors.d.ts +11 -0
- package/dist/commands/db/commands/db-sync.d.ts +11 -5
- package/dist/commands/db/sync/contract.d.ts +80 -0
- package/dist/commands/db/sync/machine.d.ts +60 -1
- package/dist/commands/db/types.d.ts +5 -0
- package/dist/commands/db/utils/boundary-policy/rule-compiler.d.ts +2 -1
- package/dist/commands/db/utils/boundary-policy/types.d.ts +23 -0
- package/dist/commands/db/utils/boundary-policy-runtime.d.ts +12 -3
- package/dist/commands/db/utils/boundary-policy.d.ts +1 -1
- package/dist/commands/db/utils/db-target.d.ts +5 -3
- package/dist/commands/db/utils/declarative-dependency-collectors.d.ts +6 -0
- package/dist/commands/db/utils/declarative-dependency-contract.d.ts +78 -0
- package/dist/commands/db/utils/declarative-dependency-sql-utils.d.ts +49 -0
- package/dist/commands/db/utils/declarative-dependency-warning-governance.d.ts +24 -0
- package/dist/commands/db/utils/preflight-check.d.ts +1 -1
- package/dist/commands/db/utils/preflight-checks/declarative-dependency-checks.d.ts +4 -0
- package/dist/commands/db/utils/preflight-checks/idempotent-risk-checks.d.ts +4 -0
- package/dist/commands/db/utils/preflight-checks/schema-boundary-checks.d.ts +4 -0
- package/dist/commands/db/utils/preflight-checks/schema-risk-policy.d.ts +4 -0
- package/dist/commands/db/utils/preflight-checks/supabase-checks.d.ts +12 -0
- package/dist/commands/db/utils/psql.d.ts +23 -0
- package/dist/commands/db/utils/sql-table-extractor.d.ts +42 -1
- package/dist/commands/env/commands/setup/types.d.ts +1 -0
- package/dist/commands/env/constants/local-supabase.d.ts +4 -1
- package/dist/commands/observability.d.ts +72 -0
- package/dist/commands/observability.helpers.d.ts +25 -0
- package/dist/commands/template-check/contract.d.ts +3 -3
- package/dist/commands/template-check/machine.d.ts +1 -1
- package/dist/commands/workflow/commands/deploy-production.d.ts +0 -1
- package/dist/constants/versions.d.ts +1 -1
- package/dist/{db-Q3GF7JWP.js → db-S4V4ETDR.js} +14629 -11270
- package/dist/{dev-5YXNPTCJ.js → dev-MLRKIP7F.js} +5 -5
- package/dist/{doctor-MZLOA53G.js → doctor-ROSWSMLH.js} +2 -2
- package/dist/{env-GMB3THRG.js → env-WNHJVLOT.js} +37 -20
- package/dist/{env-HMMRSYCI.js → env-XPPACZM4.js} +2 -2
- package/dist/{env-files-2UIUYLLR.js → env-files-HRNUGZ5O.js} +1 -1
- package/dist/{error-handler-HEXBRNVV.js → error-handler-YRQWRDEF.js} +17 -0
- package/dist/{hotfix-NDTPY2T4.js → hotfix-Z5EGVSMH.js} +4 -4
- package/dist/index.js +4 -4
- package/dist/{init-U4VCRHTD.js → init-35JLDFHI.js} +1 -1
- package/dist/{inject-test-attrs-P44BVTQS.js → inject-test-attrs-XN4I2AOR.js} +2 -2
- package/dist/internal/machines/index.d.ts +1 -1
- package/dist/internal/machines/snapshot-helpers.d.ts +6 -0
- package/dist/{manifest-TMFLESHW.js → manifest-EGCAZ4TK.js} +1 -1
- package/dist/observability-CJA5UFIC.js +721 -0
- package/dist/{risk-detector-4U6ZJ2G5.js → risk-detector-S7XQF4I2.js} +1 -1
- package/dist/{risk-detector-core-TK4OAI3N.js → risk-detector-core-TGFKWHRS.js} +61 -3
- package/dist/risk-detector-plpgsql-O32TUR34.js +736 -0
- package/dist/{template-check-FFJVDLBF.js → template-check-BDFMT6ZO.js} +1 -1
- package/dist/{upgrade-7TWORWBV.js → upgrade-7L4JIE4K.js} +1 -1
- package/dist/utils/db-url-utils.d.ts +81 -0
- package/dist/validators/risk-detector-plpgsql.d.ts +3 -1
- package/dist/{vuln-check-6CMNPSBR.js → vuln-check-D575VXIQ.js} +1 -1
- package/dist/{vuln-checker-EJJTNDNE.js → vuln-checker-QV6XODTJ.js} +1 -1
- package/dist/{watch-PNTKZYFB.js → watch-AL4LCBRM.js} +1 -1
- package/dist/{workflow-H75N4BXX.js → workflow-UZIZ2JUS.js} +2 -3
- package/package.json +3 -3
- package/dist/chunk-AKZAN4BC.js +0 -90
- package/dist/commands/ci/machine/actors/finalize/summary.d.ts +0 -32
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import './chunk-QDF7QXBL.js';
|
|
4
|
-
import { getSnapshotStateName, isSnapshotComplete } from './chunk-
|
|
5
|
-
import { guards, manifestActor, supabaseStartActor, envCheckActor, depsInstallActor, detectTurbo, detectManifestTask, detectDatabase, checkSupabaseStatus } from './chunk-
|
|
4
|
+
import { getSnapshotStateName, isSnapshotComplete } from './chunk-XVNDDHAF.js';
|
|
5
|
+
import { guards, manifestActor, supabaseStartActor, envCheckActor, depsInstallActor, detectTurbo, detectManifestTask, detectDatabase, checkSupabaseStatus } from './chunk-VSH3IXDQ.js';
|
|
6
6
|
import { findRepoRoot } from './chunk-3WDV32GA.js';
|
|
7
7
|
import { runLogged } from './chunk-6FAU4IGR.js';
|
|
8
8
|
import { createMachineStateChangeLogger } from './chunk-5FT3F36G.js';
|
|
9
9
|
import './chunk-II7VYQEM.js';
|
|
10
|
-
import './chunk-
|
|
10
|
+
import './chunk-QSEF4T3Y.js';
|
|
11
11
|
import { securePnpm } from './chunk-RZLYEO4U.js';
|
|
12
12
|
import { emitJsonSuccess } from './chunk-KE6QJBZG.js';
|
|
13
13
|
import './chunk-WJXC4MVY.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
-
export { checkCommand, runCheckCommand } from './chunk-
|
|
4
|
-
import './chunk-
|
|
3
|
+
export { checkCommand, runCheckCommand } from './chunk-2QX7T24B.js';
|
|
4
|
+
import './chunk-WPMR7RQ4.js';
|
|
5
5
|
import './chunk-DRSUEMAK.js';
|
|
6
6
|
import './chunk-KE6QJBZG.js';
|
|
7
7
|
import './chunk-WJXC4MVY.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
-
import { loadEnvFiles } from './chunk-
|
|
3
|
+
import { loadEnvFiles } from './chunk-WPMR7RQ4.js';
|
|
4
4
|
import { emitJsonSuccess } from './chunk-KE6QJBZG.js';
|
|
5
5
|
import { getOutputFormatFromEnv } from './chunk-HKUWEGUX.js';
|
|
6
6
|
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
@@ -16,7 +16,7 @@ init_esm_shims();
|
|
|
16
16
|
|
|
17
17
|
// src/constants/versions.ts
|
|
18
18
|
init_esm_shims();
|
|
19
|
-
var COMPATIBLE_TEMPLATES_VERSION = "0.7.
|
|
19
|
+
var COMPATIBLE_TEMPLATES_VERSION = "0.7.3";
|
|
20
20
|
var TEMPLATES_PACKAGE_NAME = "@r06-dev/runa-templates";
|
|
21
21
|
var GITHUB_PACKAGES_REGISTRY = "https://npm.pkg.github.com";
|
|
22
22
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
-
import { stripSqlComments } from './chunk-
|
|
3
|
+
import { stripSqlComments } from './chunk-A6A7JIRD.js';
|
|
4
4
|
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
5
5
|
import { existsSync, readFileSync, readdirSync } from 'fs';
|
|
6
6
|
import { join } from 'path';
|
|
@@ -98,7 +98,7 @@ function formatSchemasForSql(schemas) {
|
|
|
98
98
|
}).join(", ");
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
// src/
|
|
101
|
+
// src/utils/db-url-utils.ts
|
|
102
102
|
init_esm_shims();
|
|
103
103
|
function resolveHostToIPv4(hostname) {
|
|
104
104
|
const ipVersion = isIP(hostname);
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
4
4
|
import { spawnSync } from 'child_process';
|
|
5
|
+
import { randomUUID } from 'crypto';
|
|
6
|
+
import { writeFileSync, unlinkSync } from 'fs';
|
|
7
|
+
import { tmpdir } from 'os';
|
|
8
|
+
import { join } from 'path';
|
|
5
9
|
import { execa } from 'execa';
|
|
6
10
|
|
|
7
11
|
createRequire(import.meta.url);
|
|
@@ -49,7 +53,8 @@ function psqlSyncFile(params) {
|
|
|
49
53
|
const result = spawnSync("psql", [...args, "-f", params.filePath], {
|
|
50
54
|
encoding: "utf-8",
|
|
51
55
|
stdio: ["pipe", "pipe", "pipe"],
|
|
52
|
-
env: buildPsqlEnv(conn)
|
|
56
|
+
env: buildPsqlEnv(conn),
|
|
57
|
+
timeout: params.timeout ?? 3e5
|
|
53
58
|
});
|
|
54
59
|
return {
|
|
55
60
|
status: result.status,
|
|
@@ -81,6 +86,34 @@ async function psqlExec(params) {
|
|
|
81
86
|
stdio: "inherit"
|
|
82
87
|
});
|
|
83
88
|
}
|
|
89
|
+
function psqlSyncBatch(params) {
|
|
90
|
+
if (params.statements.length === 0) {
|
|
91
|
+
return { status: 0, stdout: "", stderr: "" };
|
|
92
|
+
}
|
|
93
|
+
if (params.statements.length === 1) {
|
|
94
|
+
return psqlSyncQuery({
|
|
95
|
+
databaseUrl: params.databaseUrl,
|
|
96
|
+
sql: params.statements[0],
|
|
97
|
+
timeout: params.timeout
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const tmpFile = join(tmpdir(), `runa-batch-${randomUUID()}.sql`);
|
|
101
|
+
writeFileSync(tmpFile, `${params.statements.join(";\n")};
|
|
102
|
+
`, "utf-8");
|
|
103
|
+
try {
|
|
104
|
+
return psqlSyncFile({
|
|
105
|
+
databaseUrl: params.databaseUrl,
|
|
106
|
+
filePath: tmpFile,
|
|
107
|
+
onErrorStop: params.onErrorStop ?? false,
|
|
108
|
+
timeout: params.timeout ?? 6e4
|
|
109
|
+
});
|
|
110
|
+
} finally {
|
|
111
|
+
try {
|
|
112
|
+
unlinkSync(tmpFile);
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
84
117
|
|
|
85
118
|
// src/lib/sql-comment-utils.ts
|
|
86
119
|
init_esm_shims();
|
|
@@ -271,4 +304,4 @@ function consumeDollarQuotedBody(content, index) {
|
|
|
271
304
|
};
|
|
272
305
|
}
|
|
273
306
|
|
|
274
|
-
export { blankDollarQuotedBodies, buildPsqlArgs, buildPsqlEnv, parsePostgresUrl, psqlExec, psqlQuery, psqlSyncFile, psqlSyncQuery, stripSqlComments };
|
|
307
|
+
export { blankDollarQuotedBodies, buildPsqlArgs, buildPsqlEnv, parsePostgresUrl, psqlExec, psqlQuery, psqlSyncBatch, psqlSyncFile, psqlSyncQuery, stripSqlComments };
|
|
@@ -874,6 +874,18 @@ async function processFiles(options) {
|
|
|
874
874
|
state.resolutionDetails.push(...result.resolutionDetails);
|
|
875
875
|
await handleChangedFile(result, check, repoRoot, verbose, state);
|
|
876
876
|
}
|
|
877
|
+
const processedFiles = /* @__PURE__ */ new Set([...withMachineDefinitions, ...withMachineHooks, ...withJsxOnly]);
|
|
878
|
+
for (const filePath of files) {
|
|
879
|
+
if (processedFiles.has(filePath)) {
|
|
880
|
+
continue;
|
|
881
|
+
}
|
|
882
|
+
try {
|
|
883
|
+
const code = await fs2.promises.readFile(filePath, "utf-8");
|
|
884
|
+
const relativePath = path3.relative(repoRoot, filePath);
|
|
885
|
+
collectRouteInfo(relativePath, code, verbose);
|
|
886
|
+
} catch {
|
|
887
|
+
}
|
|
888
|
+
}
|
|
877
889
|
if (!check) {
|
|
878
890
|
await formatChangedFiles(state.filesToFormat, repoRoot, verbose);
|
|
879
891
|
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { env } from './chunk-UHDAYPHH.js';
|
|
4
|
+
import { redactSecrets } from './chunk-II7VYQEM.js';
|
|
5
|
+
import { init_local_supabase, buildLocalDatabaseUrl } from './chunk-QSEF4T3Y.js';
|
|
6
|
+
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
7
|
+
import { CLIError } from '@runa-ai/runa';
|
|
8
|
+
|
|
9
|
+
createRequire(import.meta.url);
|
|
10
|
+
|
|
11
|
+
// src/commands/db/utils/db-target.ts
|
|
12
|
+
init_esm_shims();
|
|
13
|
+
init_local_supabase();
|
|
14
|
+
function getLocalDatabaseUrl() {
|
|
15
|
+
return buildLocalDatabaseUrl(process.cwd());
|
|
16
|
+
}
|
|
17
|
+
function isLocalHostname(hostname) {
|
|
18
|
+
return hostname === "localhost" || hostname === "127.0.0.1" || hostname === "::1" || hostname === "host.docker.internal";
|
|
19
|
+
}
|
|
20
|
+
function isLocalDatabaseUrl(url) {
|
|
21
|
+
try {
|
|
22
|
+
const parsed = new URL(url);
|
|
23
|
+
return isLocalHostname(parsed.hostname);
|
|
24
|
+
} catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function getExplicitLocalAdminUrl() {
|
|
29
|
+
const explicitAdminUrl = process.env.DATABASE_URL_ADMIN?.trim();
|
|
30
|
+
if (!explicitAdminUrl) return void 0;
|
|
31
|
+
return isLocalDatabaseUrl(explicitAdminUrl) ? explicitAdminUrl : void 0;
|
|
32
|
+
}
|
|
33
|
+
function resolveDatabaseTarget(environment) {
|
|
34
|
+
switch (environment) {
|
|
35
|
+
case "local": {
|
|
36
|
+
const explicitAdminUrl = getExplicitLocalAdminUrl();
|
|
37
|
+
const url = explicitAdminUrl || getLocalDatabaseUrl();
|
|
38
|
+
if (!isLocalDatabaseUrl(url)) {
|
|
39
|
+
throw new CLIError("Local database URL appears to be a remote URL", "LOCAL_DB_URL_REMOTE", [
|
|
40
|
+
"Local operations should use the local Supabase instance",
|
|
41
|
+
// SECURITY (Issue #513): Redact credentials from database URL in error message
|
|
42
|
+
`Current URL: ${redactSecrets(url)}`,
|
|
43
|
+
"If you need to connect to a remote DB, use --env preview or --env production"
|
|
44
|
+
]);
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
url,
|
|
48
|
+
source: explicitAdminUrl ? "DATABASE_URL_ADMIN" : "LOCAL_SUPABASE"
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
case "preview": {
|
|
52
|
+
const explicitAdminUrl = process.env.DATABASE_URL_ADMIN;
|
|
53
|
+
if (explicitAdminUrl) {
|
|
54
|
+
return { url: explicitAdminUrl, source: "DATABASE_URL_ADMIN" };
|
|
55
|
+
}
|
|
56
|
+
if (env.DATABASE_URL) {
|
|
57
|
+
return { url: env.DATABASE_URL, source: "DATABASE_URL" };
|
|
58
|
+
}
|
|
59
|
+
const fallbackUrl = process.env.DATABASE_URL;
|
|
60
|
+
if (!fallbackUrl) {
|
|
61
|
+
throw new CLIError("Preview database URL not found", "PREVIEW_DB_URL_NOT_FOUND", [
|
|
62
|
+
"Set DATABASE_URL_ADMIN environment variable (for DDL/migrations)",
|
|
63
|
+
"Or set DATABASE_URL as fallback"
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
66
|
+
return { url: fallbackUrl, source: "DATABASE_URL" };
|
|
67
|
+
}
|
|
68
|
+
case "main":
|
|
69
|
+
case "production": {
|
|
70
|
+
const ghAdminUrl = process.env.GH_DATABASE_URL_ADMIN;
|
|
71
|
+
if (ghAdminUrl) {
|
|
72
|
+
if (isLocalDatabaseUrl(ghAdminUrl)) {
|
|
73
|
+
throw new CLIError(
|
|
74
|
+
"Production database URL points to localhost",
|
|
75
|
+
"PRODUCTION_DB_URL_IS_LOCAL",
|
|
76
|
+
[
|
|
77
|
+
"Use --env local for local Supabase operations",
|
|
78
|
+
"Production operations require a remote database URL",
|
|
79
|
+
"Set DATABASE_URL_ADMIN or GH_DATABASE_URL_ADMIN to the production database URL"
|
|
80
|
+
]
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return { url: ghAdminUrl, source: "GH_DATABASE_URL_ADMIN" };
|
|
84
|
+
}
|
|
85
|
+
const explicitAdminUrl = process.env.DATABASE_URL_ADMIN;
|
|
86
|
+
if (explicitAdminUrl) {
|
|
87
|
+
if (isLocalDatabaseUrl(explicitAdminUrl)) {
|
|
88
|
+
throw new CLIError(
|
|
89
|
+
"Production database URL points to localhost",
|
|
90
|
+
"PRODUCTION_DB_URL_IS_LOCAL",
|
|
91
|
+
[
|
|
92
|
+
"Use --env local for local Supabase operations",
|
|
93
|
+
"Production operations require a remote database URL",
|
|
94
|
+
"Set DATABASE_URL_ADMIN or GH_DATABASE_URL_ADMIN to the production database URL"
|
|
95
|
+
]
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
return { url: explicitAdminUrl, source: "DATABASE_URL_ADMIN" };
|
|
99
|
+
}
|
|
100
|
+
throw new CLIError("Production database URL not found", "PRODUCTION_DB_URL_NOT_FOUND", [
|
|
101
|
+
"Set GH_DATABASE_URL_ADMIN (CI) or DATABASE_URL_ADMIN (local) to a direct postgres URL",
|
|
102
|
+
"Do not use GH_DATABASE_URL or DATABASE_URL for DDL operations"
|
|
103
|
+
]);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function resolveDatabaseUrl(environment) {
|
|
108
|
+
return resolveDatabaseTarget(environment).url;
|
|
109
|
+
}
|
|
110
|
+
function tryResolveDatabaseUrl(environment) {
|
|
111
|
+
try {
|
|
112
|
+
return resolveDatabaseUrl(environment);
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (error instanceof CLIError) return void 0;
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export { resolveDatabaseTarget, resolveDatabaseUrl, tryResolveDatabaseUrl };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
-
import { psqlQuery, stripSqlComments } from './chunk-
|
|
3
|
+
import { psqlQuery, stripSqlComments } from './chunk-A6A7JIRD.js';
|
|
4
4
|
import { loadRunaConfig } from './chunk-5NKWR4FF.js';
|
|
5
5
|
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
6
6
|
import { existsSync, writeFileSync, unlinkSync, readdirSync, readFileSync, mkdirSync, realpathSync } from 'fs';
|
|
@@ -33,6 +33,7 @@ function buildEnvLocalContent(config) {
|
|
|
33
33
|
"# This file overrides .env.development so that `pnpm dev` uses correct ports.",
|
|
34
34
|
"# Removed automatically by `runa db stop`. Safe to delete manually.",
|
|
35
35
|
`DATABASE_URL=${dbUrl}`,
|
|
36
|
+
`DATABASE_URL_LISTENER=${dbUrl}`,
|
|
36
37
|
`DATABASE_URL_ADMIN=${dbUrl}`,
|
|
37
38
|
`DATABASE_URL_SERVICE=${dbUrl}`,
|
|
38
39
|
`NEXT_PUBLIC_SUPABASE_URL=http://${config.host}:${config.api}`,
|
|
@@ -931,17 +932,32 @@ function convertAstIndexes(indexes, include) {
|
|
|
931
932
|
isUnique: idx.isUnique
|
|
932
933
|
}));
|
|
933
934
|
}
|
|
935
|
+
async function buildPolicyMap(policies, include) {
|
|
936
|
+
if (!include) return /* @__PURE__ */ new Map();
|
|
937
|
+
const map = /* @__PURE__ */ new Map();
|
|
938
|
+
for (const policy of policies) {
|
|
939
|
+
const key = `${policy.schema}.${policy.table}`.toLowerCase();
|
|
940
|
+
const existing = map.get(key) ?? [];
|
|
941
|
+
existing.push({
|
|
942
|
+
name: policy.name,
|
|
943
|
+
command: policy.for.toUpperCase(),
|
|
944
|
+
using: policy.using,
|
|
945
|
+
withCheck: policy.withCheck
|
|
946
|
+
});
|
|
947
|
+
map.set(key, existing);
|
|
948
|
+
}
|
|
949
|
+
return map;
|
|
950
|
+
}
|
|
934
951
|
async function extractTablesWithAst(content, filePath, opts) {
|
|
935
952
|
const parser = await getSqlParserUtils();
|
|
936
953
|
if (!parser) return [];
|
|
937
|
-
const
|
|
954
|
+
const schemaDocument = await parser.parseSchemaDocument(content);
|
|
955
|
+
const astTables = schemaDocument.tables;
|
|
956
|
+
const policyMap = await buildPolicyMap(schemaDocument.policies, opts.includeRlsPolicies);
|
|
938
957
|
const tables = [];
|
|
939
958
|
for (const astTable of astTables) {
|
|
940
|
-
if (opts.includeIndexes) {
|
|
941
|
-
await parser.parseIndexesForTables(content, [astTable]);
|
|
942
|
-
}
|
|
943
959
|
const hasRls = hasRlsEnabledRegex(content, astTable.schema, astTable.name);
|
|
944
|
-
const rlsPolicies = opts.includeRlsPolicies && hasRls ?
|
|
960
|
+
const rlsPolicies = opts.includeRlsPolicies && hasRls ? policyMap.get(astTable.qualifiedName.toLowerCase()) : void 0;
|
|
945
961
|
tables.push({
|
|
946
962
|
schema: astTable.schema,
|
|
947
963
|
name: astTable.name,
|
|
@@ -963,11 +979,25 @@ async function extractTablesWithAst(content, filePath, opts) {
|
|
|
963
979
|
// src/commands/db/utils/sql-table-extractor.ts
|
|
964
980
|
var sqlParserUtils = null;
|
|
965
981
|
var astAvailable = null;
|
|
982
|
+
function hasRequiredSqlParserSurface(parser) {
|
|
983
|
+
return Boolean(
|
|
984
|
+
parser && typeof parser.isSqlParserAvailable === "function" && typeof parser.parseSchemaDocument === "function" && typeof parser.parseCreateTables === "function" && typeof parser.parseIndexesForTables === "function" && typeof parser.parseCreatePolicies === "function"
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
async function loadSqlParserUtilsWithFallback() {
|
|
988
|
+
const { loadSqlParserUtils } = await import('@runa-ai/runa/ast');
|
|
989
|
+
const loaded = await loadSqlParserUtils();
|
|
990
|
+
if (!hasRequiredSqlParserSurface(loaded)) {
|
|
991
|
+
throw new Error(
|
|
992
|
+
"SQL parser utilities are unavailable or missing required schema document helpers"
|
|
993
|
+
);
|
|
994
|
+
}
|
|
995
|
+
return loaded;
|
|
996
|
+
}
|
|
966
997
|
async function isAstParserAvailable() {
|
|
967
998
|
if (astAvailable !== null) return astAvailable;
|
|
968
999
|
try {
|
|
969
|
-
|
|
970
|
-
sqlParserUtils = await loadSqlParserUtils();
|
|
1000
|
+
sqlParserUtils = await loadSqlParserUtilsWithFallback();
|
|
971
1001
|
const isAvailable = await sqlParserUtils.isSqlParserAvailable();
|
|
972
1002
|
astAvailable = isAvailable;
|
|
973
1003
|
return isAvailable;
|
|
@@ -9,7 +9,7 @@ init_esm_shims();
|
|
|
9
9
|
var riskDetectorModulePromise = null;
|
|
10
10
|
async function loadRiskDetectorModule() {
|
|
11
11
|
if (!riskDetectorModulePromise) {
|
|
12
|
-
riskDetectorModulePromise = import('./risk-detector-core-
|
|
12
|
+
riskDetectorModulePromise = import('./risk-detector-core-TGFKWHRS.js').catch((error) => {
|
|
13
13
|
riskDetectorModulePromise = null;
|
|
14
14
|
throw error;
|
|
15
15
|
});
|
|
@@ -110,9 +110,10 @@ function resolveSupabaseRoot(projectRoot) {
|
|
|
110
110
|
function isAllowedLocalhostHost(host) {
|
|
111
111
|
return host === "127.0.0.1" || host === "localhost" || host === "host.docker.internal";
|
|
112
112
|
}
|
|
113
|
-
function buildDetectionCacheKey(projectRoot) {
|
|
113
|
+
function buildDetectionCacheKey(projectRoot, options) {
|
|
114
114
|
return [
|
|
115
115
|
projectRoot,
|
|
116
|
+
options.skipStatusDetection === true ? "skip-status" : "with-status",
|
|
116
117
|
process.env.LOCAL_SUPABASE_HOST ?? "",
|
|
117
118
|
process.env.LOCAL_SUPABASE_API_PORT ?? "",
|
|
118
119
|
process.env.LOCAL_SUPABASE_DB_PORT ?? "",
|
|
@@ -127,9 +128,9 @@ function readSupabaseOverrides() {
|
|
|
127
128
|
studio: asPort(process.env.LOCAL_SUPABASE_STUDIO_PORT, DEFAULT_STUDIO_PORT)
|
|
128
129
|
};
|
|
129
130
|
}
|
|
130
|
-
function detectLocalSupabasePorts(projectRoot = process.cwd()) {
|
|
131
|
+
function detectLocalSupabasePorts(projectRoot = process.cwd(), options = {}) {
|
|
131
132
|
const resolvedRoot = resolveSupabaseRoot(projectRoot);
|
|
132
|
-
const cacheKey = buildDetectionCacheKey(resolvedRoot);
|
|
133
|
+
const cacheKey = buildDetectionCacheKey(resolvedRoot, options);
|
|
133
134
|
if (detectionCache?.key === cacheKey) {
|
|
134
135
|
return detectionCache.config;
|
|
135
136
|
}
|
|
@@ -151,7 +152,7 @@ function detectLocalSupabasePorts(projectRoot = process.cwd()) {
|
|
|
151
152
|
};
|
|
152
153
|
return explicitConfig;
|
|
153
154
|
}
|
|
154
|
-
const status = detectStatus(resolvedRoot);
|
|
155
|
+
const status = options.skipStatusDetection === true ? null : detectStatus(resolvedRoot);
|
|
155
156
|
const tomlPorts = parseTomlPorts(resolvedRoot);
|
|
156
157
|
const statusApiUrl = status ? getStatusValue(status, ["API_URL", "API URL", "api_url"]) : null;
|
|
157
158
|
const statusDbUrl = status ? getStatusValue(status, ["DB_URL", "DB URL", "db_url"]) : null;
|
|
@@ -200,6 +201,7 @@ function getLocalSupabaseEnvValues(projectRoot = process.cwd()) {
|
|
|
200
201
|
LOCAL_SUPABASE_API_PORT: String(config.api),
|
|
201
202
|
LOCAL_SUPABASE_DB_PORT: String(config.db),
|
|
202
203
|
DATABASE_URL: databaseUrl,
|
|
204
|
+
DATABASE_URL_LISTENER: databaseUrl,
|
|
203
205
|
DATABASE_URL_ADMIN: databaseUrl,
|
|
204
206
|
DATABASE_URL_SERVICE: databaseUrl,
|
|
205
207
|
NEXT_PUBLIC_SUPABASE_URL: supabaseUrl,
|
|
@@ -214,6 +216,7 @@ function getLocalValueDescriptions(projectRoot = process.cwd()) {
|
|
|
214
216
|
LOCAL_SUPABASE_API_PORT: `supabase local api port ${config.api}`,
|
|
215
217
|
LOCAL_SUPABASE_DB_PORT: `supabase local db port ${config.db}`,
|
|
216
218
|
DATABASE_URL: `supabase local DB ${config.host}:${config.db}`,
|
|
219
|
+
DATABASE_URL_LISTENER: `supabase local DB ${config.host}:${config.db}`,
|
|
217
220
|
DATABASE_URL_ADMIN: `supabase local DB ${config.host}:${config.db}`,
|
|
218
221
|
DATABASE_URL_SERVICE: `supabase local DB ${config.host}:${config.db}`,
|
|
219
222
|
NEXT_PUBLIC_SUPABASE_URL: `supabase local API ${config.host}:${config.api}`,
|
|
@@ -224,6 +227,7 @@ function getLocalValueDescriptions(projectRoot = process.cwd()) {
|
|
|
224
227
|
function validateLocalhostValues(envValues) {
|
|
225
228
|
const urlKeys = [
|
|
226
229
|
"DATABASE_URL",
|
|
230
|
+
"DATABASE_URL_LISTENER",
|
|
227
231
|
"DATABASE_URL_ADMIN",
|
|
228
232
|
"DATABASE_URL_SERVICE",
|
|
229
233
|
"NEXT_PUBLIC_SUPABASE_URL"
|
|
@@ -290,7 +294,11 @@ function detectSupabasePorts(projectRoot) {
|
|
|
290
294
|
}
|
|
291
295
|
let status;
|
|
292
296
|
try {
|
|
293
|
-
|
|
297
|
+
const jsonMatch = result.stdout.match(/\{[\s\S]*\}/);
|
|
298
|
+
if (!jsonMatch) {
|
|
299
|
+
throw new Error("No JSON object found in output");
|
|
300
|
+
}
|
|
301
|
+
status = JSON.parse(jsonMatch[0]);
|
|
294
302
|
} catch {
|
|
295
303
|
throw new Error(
|
|
296
304
|
"Failed to parse Supabase status output.\n\nTry restarting Supabase: supabase stop && supabase start"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
-
import { init_constants, constants_exports } from './chunk-
|
|
3
|
+
import { init_constants, constants_exports } from './chunk-QSEF4T3Y.js';
|
|
4
4
|
import { init_esm_shims, __toCommonJS } from './chunk-VRXHCR5K.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import { runLogged } from './chunk-6FAU4IGR.js';
|
|
4
|
-
import { init_constants, detectSupabasePorts } from './chunk-
|
|
4
|
+
import { init_constants, detectSupabasePorts } from './chunk-QSEF4T3Y.js';
|
|
5
5
|
import { init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
6
6
|
import { execSync, spawnSync } from 'child_process';
|
|
7
7
|
import { existsSync, statSync, readFileSync } from 'fs';
|
|
@@ -301,14 +301,18 @@ var manifestActor = fromPromise(
|
|
|
301
301
|
const { repoRoot, tmpDir, env = process.env } = input;
|
|
302
302
|
const startTime = Date.now();
|
|
303
303
|
try {
|
|
304
|
+
const cliEntry = process.argv[1];
|
|
305
|
+
if (!cliEntry) {
|
|
306
|
+
throw new Error("Unable to resolve current CLI entry for manifest generation");
|
|
307
|
+
}
|
|
304
308
|
const fullTmpDir = path2.join(repoRoot, tmpDir);
|
|
305
309
|
await mkdir(fullTmpDir, { recursive: true });
|
|
306
310
|
await runLogged({
|
|
307
311
|
cwd: repoRoot,
|
|
308
312
|
env,
|
|
309
313
|
label: "manifest",
|
|
310
|
-
command:
|
|
311
|
-
args: [
|
|
314
|
+
command: process.execPath,
|
|
315
|
+
args: [cliEntry, "manifest"],
|
|
312
316
|
logFile: path2.join(fullTmpDir, "manifest.log")
|
|
313
317
|
});
|
|
314
318
|
return {
|
|
@@ -114,7 +114,12 @@ function loadEnvFiles(options = {}) {
|
|
|
114
114
|
applyTargetEnvToProcessEnv({ targetEnv, protectedKeys });
|
|
115
115
|
}
|
|
116
116
|
if (options.runaEnv === "local") {
|
|
117
|
-
const localExcludedKeys = [
|
|
117
|
+
const localExcludedKeys = [
|
|
118
|
+
"DATABASE_URL",
|
|
119
|
+
"DATABASE_URL_LISTENER",
|
|
120
|
+
"DATABASE_URL_ADMIN",
|
|
121
|
+
"DATABASE_URL_SERVICE"
|
|
122
|
+
];
|
|
118
123
|
for (const key of localExcludedKeys) {
|
|
119
124
|
delete process.env[key];
|
|
120
125
|
}
|
|
@@ -132,7 +137,9 @@ function loadEnvFiles(options = {}) {
|
|
|
132
137
|
process.stderr.write(" \u{1F513} Auto-decrypted with .env.keys\n");
|
|
133
138
|
}
|
|
134
139
|
if (options.runaEnv === "local") {
|
|
135
|
-
process.stderr.write(
|
|
140
|
+
process.stderr.write(
|
|
141
|
+
" \u{1F3E0} Local mode: runtime DATABASE_URL* vars excluded (using local Supabase)\n"
|
|
142
|
+
);
|
|
136
143
|
}
|
|
137
144
|
}
|
|
138
145
|
return { projectRoot, loadedFiles };
|
|
@@ -36,6 +36,25 @@ function getSnapshotStateName(snapshot) {
|
|
|
36
36
|
const nested = flattenState(child);
|
|
37
37
|
return nested ? `${parent}.${nested}` : parent;
|
|
38
38
|
}
|
|
39
|
+
function getSnapshotStatePaths(snapshot) {
|
|
40
|
+
function collect(value, prefix = "") {
|
|
41
|
+
if (typeof value === "string") {
|
|
42
|
+
return [prefix ? `${prefix}.${value}` : value];
|
|
43
|
+
}
|
|
44
|
+
if (!value || typeof value !== "object") {
|
|
45
|
+
return prefix ? [prefix] : [];
|
|
46
|
+
}
|
|
47
|
+
const entries = Object.entries(value);
|
|
48
|
+
if (entries.length === 0) {
|
|
49
|
+
return prefix ? [prefix] : [];
|
|
50
|
+
}
|
|
51
|
+
return entries.flatMap(([key, childValue]) => {
|
|
52
|
+
const nextPrefix = prefix ? `${prefix}.${key}` : key;
|
|
53
|
+
return collect(childValue, nextPrefix);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return collect(snapshot.value);
|
|
57
|
+
}
|
|
39
58
|
function isSnapshotComplete(snapshot) {
|
|
40
59
|
return snapshot.status === "done";
|
|
41
60
|
}
|
|
@@ -43,4 +62,4 @@ function getErrorMessage(error) {
|
|
|
43
62
|
return error instanceof Error ? error.message : String(error);
|
|
44
63
|
}
|
|
45
64
|
|
|
46
|
-
export { getErrorMessage, getSnapshotStateName, isSnapshotComplete };
|
|
65
|
+
export { getErrorMessage, getSnapshotStateName, getSnapshotStatePaths, isSnapshotComplete };
|