@runa-ai/runa-cli 0.10.3 → 0.10.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/dist/{build-P2A6345N.js → build-C65G2QQE.js} +3 -2
- package/dist/{chunk-UHDAYPHH.js → chunk-47BG6DRP.js} +1 -1
- package/dist/{chunk-MAFJAA2P.js → chunk-C3SRIUWX.js} +1 -1
- package/dist/{chunk-QSEF4T3Y.js → chunk-F2AQ3EYJ.js} +10 -199
- package/dist/{chunk-SS7RIWW3.js → chunk-FZONYKNR.js} +1 -1
- package/dist/chunk-NOXYPVMZ.js +204 -0
- package/dist/chunk-TXXGDJYB.js +3636 -0
- package/dist/{chunk-S7VGVFYF.js → chunk-WHVJ4JMQ.js} +274 -3863
- package/dist/{chunk-XFXGFUAM.js → chunk-XVGMGFKF.js} +1 -1
- package/dist/{chunk-WGRVAGSR.js → chunk-ZDETCPCE.js} +2 -2
- package/dist/{ci-6P7VK6WB.js → ci-WOP7K7MS.js} +11 -9
- package/dist/{cli-Q665YRVT.js → cli-4HI3D2II.js} +12 -12
- package/dist/{db-BQOVOQXU.js → db-DO6L72RR.js} +91 -53
- package/dist/{dev-QR55VDNZ.js → dev-N3BFJZ7F.js} +3 -2
- package/dist/{env-KYR6Q7WO.js → env-2XM45E7O.js} +4 -3
- package/dist/{env-XPPACZM4.js → env-KIMSQSPS.js} +3 -2
- package/dist/helpers-RHAZLOLQ.js +15 -0
- package/dist/{hotfix-JYHDY2M6.js → hotfix-QP5J6FCD.js} +4 -3
- package/dist/index.js +3 -3
- package/dist/local-supabase-KTTC3O2L.js +8 -0
- package/dist/{risk-detector-GDDLISVE.js → risk-detector-4D5HRUMY.js} +1 -1
- package/dist/{risk-detector-core-YI3M6INI.js → risk-detector-core-CHUY6M5N.js} +1 -1
- package/dist/{vuln-check-WW43E7PS.js → vuln-check-OE4KSASO.js} +1 -1
- package/dist/{vuln-checker-BC3ZAXJ3.js → vuln-checker-LMHRSMYY.js} +1 -1
- package/dist/{watch-4RHXVCQ3.js → watch-VQQHKDNQ.js} +1 -1
- package/package.json +3 -3
- package/dist/{risk-detector-plpgsql-4GWEQXUG.js → risk-detector-plpgsql-NNUZU3OQ.js} +1 -1
|
@@ -2,16 +2,17 @@
|
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import './chunk-QDF7QXBL.js';
|
|
4
4
|
import { getSnapshotStateName, isSnapshotComplete } from './chunk-XVNDDHAF.js';
|
|
5
|
-
import { guards, manifestActor, supabaseStartActor, envCheckActor, depsInstallActor, detectTurbo, detectManifestTask, detectDatabase, checkSupabaseStatus } from './chunk-
|
|
5
|
+
import { guards, manifestActor, supabaseStartActor, envCheckActor, depsInstallActor, detectTurbo, detectManifestTask, detectDatabase, checkSupabaseStatus } from './chunk-C3SRIUWX.js';
|
|
6
6
|
import { findRepoRoot } from './chunk-3WDV32GA.js';
|
|
7
7
|
import { runLogged } from './chunk-ELXXQIGW.js';
|
|
8
8
|
import { createMachineStateChangeLogger } from './chunk-5FT3F36G.js';
|
|
9
9
|
import './chunk-II7VYQEM.js';
|
|
10
|
-
import './chunk-
|
|
10
|
+
import './chunk-NOXYPVMZ.js';
|
|
11
11
|
import { securePnpm } from './chunk-RZLYEO4U.js';
|
|
12
12
|
import { emitJsonSuccess } from './chunk-KE6QJBZG.js';
|
|
13
13
|
import './chunk-WJXC4MVY.js';
|
|
14
14
|
import './chunk-HKUWEGUX.js';
|
|
15
|
+
import './chunk-F2AQ3EYJ.js';
|
|
15
16
|
import { init_esm_shims, __require } from './chunk-VRXHCR5K.js';
|
|
16
17
|
import { CLIError, createCLILogger } from '@runa-ai/runa';
|
|
17
18
|
import { Command } from 'commander';
|
|
@@ -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-NOXYPVMZ.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-ELXXQIGW.js';
|
|
4
|
-
import { init_constants, detectSupabasePorts } from './chunk-
|
|
4
|
+
import { init_constants, detectSupabasePorts } from './chunk-NOXYPVMZ.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';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
|
-
import { __esm, init_esm_shims
|
|
3
|
+
import { __esm, init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
4
4
|
import { existsSync, readFileSync } from 'fs';
|
|
5
5
|
import { spawnSync } from 'child_process';
|
|
6
6
|
import path from 'path';
|
|
@@ -184,6 +184,9 @@ function detectLocalSupabasePorts(projectRoot = process.cwd(), options = {}) {
|
|
|
184
184
|
};
|
|
185
185
|
return detectedConfig;
|
|
186
186
|
}
|
|
187
|
+
function clearLocalSupabaseDetectionCache() {
|
|
188
|
+
detectionCache = null;
|
|
189
|
+
}
|
|
187
190
|
function buildLocalSupabaseUrl(projectRoot = process.cwd()) {
|
|
188
191
|
const config = detectLocalSupabasePorts(projectRoot);
|
|
189
192
|
return `http://${config.host}:${config.api}`;
|
|
@@ -251,7 +254,7 @@ function validateLocalhostValues(envValues) {
|
|
|
251
254
|
);
|
|
252
255
|
}
|
|
253
256
|
}
|
|
254
|
-
var DEFAULT_HOST, DEFAULT_API_PORT, DEFAULT_DB_PORT, DEFAULT_STUDIO_PORT, detectionCache, LOCAL_SUPABASE_ANON_KEY, LOCAL_SUPABASE_SERVICE_ROLE_KEY, LOCAL_SUPABASE_ENV_VALUES;
|
|
257
|
+
var DEFAULT_HOST, DEFAULT_API_PORT, DEFAULT_DB_PORT, DEFAULT_STUDIO_PORT, detectionCache, LOCAL_SUPABASE_ANON_KEY, LOCAL_SUPABASE_SERVICE_ROLE_KEY, LOCAL_SUPABASE_ENV_VALUES, LOCAL_REPLACEMENT_KEYS, LOCAL_VALUE_DESCRIPTIONS, LOCAL_SUPABASE_URL, LOCAL_DATABASE_URL;
|
|
255
258
|
var init_local_supabase = __esm({
|
|
256
259
|
"src/commands/env/constants/local-supabase.ts"() {
|
|
257
260
|
init_esm_shims();
|
|
@@ -263,204 +266,12 @@ var init_local_supabase = __esm({
|
|
|
263
266
|
LOCAL_SUPABASE_ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0";
|
|
264
267
|
LOCAL_SUPABASE_SERVICE_ROLE_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU";
|
|
265
268
|
LOCAL_SUPABASE_ENV_VALUES = getLocalSupabaseEnvValues();
|
|
266
|
-
|
|
269
|
+
LOCAL_REPLACEMENT_KEYS = Object.keys(LOCAL_SUPABASE_ENV_VALUES);
|
|
270
|
+
LOCAL_VALUE_DESCRIPTIONS = getLocalValueDescriptions();
|
|
271
|
+
LOCAL_SUPABASE_URL = `http://${DEFAULT_HOST}:${DEFAULT_API_PORT}`;
|
|
272
|
+
LOCAL_DATABASE_URL = `postgresql://postgres:postgres@${DEFAULT_HOST}:${DEFAULT_DB_PORT}/postgres`;
|
|
267
273
|
validateLocalhostValues(LOCAL_SUPABASE_ENV_VALUES);
|
|
268
274
|
}
|
|
269
275
|
});
|
|
270
276
|
|
|
271
|
-
|
|
272
|
-
var constants_exports = {};
|
|
273
|
-
__export(constants_exports, {
|
|
274
|
-
DATABASE_DEFAULTS: () => DATABASE_DEFAULTS,
|
|
275
|
-
ERROR_MESSAGES: () => ERROR_MESSAGES,
|
|
276
|
-
SCRIPT_LOCATIONS: () => SCRIPT_LOCATIONS,
|
|
277
|
-
SEED_DEFAULTS: () => SEED_DEFAULTS,
|
|
278
|
-
detectSupabasePorts: () => detectSupabasePorts,
|
|
279
|
-
getSupabaseAccessPoints: () => getSupabaseAccessPoints
|
|
280
|
-
});
|
|
281
|
-
function detectSupabasePorts(projectRoot) {
|
|
282
|
-
const cwd = projectRoot || process.cwd();
|
|
283
|
-
const result = spawnSync("supabase", ["status", "--output", "json"], {
|
|
284
|
-
encoding: "utf-8",
|
|
285
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
286
|
-
timeout: 5e3,
|
|
287
|
-
// 5 second timeout
|
|
288
|
-
cwd
|
|
289
|
-
});
|
|
290
|
-
if (result.status !== 0 || !result.stdout) {
|
|
291
|
-
throw new Error(
|
|
292
|
-
"Supabase is not running.\n\nStart Supabase with: supabase start\nOr run: runa check --fix"
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
let status;
|
|
296
|
-
try {
|
|
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]);
|
|
302
|
-
} catch {
|
|
303
|
-
throw new Error(
|
|
304
|
-
"Failed to parse Supabase status output.\n\nTry restarting Supabase: supabase stop && supabase start"
|
|
305
|
-
);
|
|
306
|
-
}
|
|
307
|
-
const apiUrl = status.API_URL || status["API URL"] || status.api_url;
|
|
308
|
-
const dbUrl = status.DB_URL || status["DB URL"] || status.db_url;
|
|
309
|
-
const studioUrl = status.STUDIO_URL || status["Studio URL"] || status.studio_url;
|
|
310
|
-
const extractPort2 = (url) => {
|
|
311
|
-
try {
|
|
312
|
-
const parsed = new URL(url);
|
|
313
|
-
return parsed.port ? Number.parseInt(parsed.port, 10) : null;
|
|
314
|
-
} catch {
|
|
315
|
-
const match = url.match(/:(\d+)\//);
|
|
316
|
-
return match ? Number.parseInt(match[1], 10) : null;
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
const apiPort = apiUrl ? extractPort2(apiUrl) : null;
|
|
320
|
-
const dbPort = dbUrl ? extractPort2(dbUrl) : null;
|
|
321
|
-
const studioPort = studioUrl ? extractPort2(studioUrl) : null;
|
|
322
|
-
if (!apiPort || !dbPort) {
|
|
323
|
-
throw new Error(
|
|
324
|
-
"Could not detect Supabase ports from status output.\n\nTry restarting Supabase: supabase stop && supabase start"
|
|
325
|
-
);
|
|
326
|
-
}
|
|
327
|
-
return {
|
|
328
|
-
api: apiPort,
|
|
329
|
-
db: dbPort,
|
|
330
|
-
studio: studioPort ?? apiPort + 2
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
function getSupabaseAccessPoints(projectRoot) {
|
|
334
|
-
const ports = detectLocalSupabasePorts(projectRoot);
|
|
335
|
-
const buildSupabaseUrl = (port) => {
|
|
336
|
-
const url = new URL(buildLocalSupabaseUrl(projectRoot));
|
|
337
|
-
url.port = String(port);
|
|
338
|
-
return url.toString().replace(/\/$/, "");
|
|
339
|
-
};
|
|
340
|
-
return {
|
|
341
|
-
studio: buildSupabaseUrl(ports.studio),
|
|
342
|
-
api: buildLocalSupabaseUrl(projectRoot),
|
|
343
|
-
db: buildLocalDatabaseUrl(projectRoot)
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
var DATABASE_DEFAULTS, SEED_DEFAULTS, SCRIPT_LOCATIONS, ERROR_MESSAGES;
|
|
347
|
-
var init_constants = __esm({
|
|
348
|
-
"src/commands/db/constants.ts"() {
|
|
349
|
-
init_esm_shims();
|
|
350
|
-
init_local_supabase();
|
|
351
|
-
DATABASE_DEFAULTS = {
|
|
352
|
-
// Supabase Local defaults (for development)
|
|
353
|
-
// Note: PORT is detected from running Supabase instance
|
|
354
|
-
// AI HINT: Local Supabase Default Credentials (Non-Production)
|
|
355
|
-
// postgres:postgres is the standard default for `supabase start`.
|
|
356
|
-
// This is a documented public value, not a secret.
|
|
357
|
-
// Production uses environment variables via .env.production.
|
|
358
|
-
SUPABASE_LOCAL: {
|
|
359
|
-
get HOST() {
|
|
360
|
-
return detectLocalSupabasePorts().host;
|
|
361
|
-
},
|
|
362
|
-
get PORT() {
|
|
363
|
-
return detectSupabasePorts().db;
|
|
364
|
-
},
|
|
365
|
-
USER: "postgres",
|
|
366
|
-
PASSWORD: "postgres",
|
|
367
|
-
DATABASE: "postgres"
|
|
368
|
-
},
|
|
369
|
-
// Standard PostgreSQL defaults (more generic)
|
|
370
|
-
POSTGRES: {
|
|
371
|
-
HOST: "127.0.0.1",
|
|
372
|
-
PORT: 5432,
|
|
373
|
-
USER: "postgres",
|
|
374
|
-
PASSWORD: "",
|
|
375
|
-
DATABASE: "postgres"
|
|
376
|
-
},
|
|
377
|
-
// Timeouts
|
|
378
|
-
CONNECTION_TIMEOUT_MS: 5e3,
|
|
379
|
-
SCRIPT_TIMEOUT_MS: 3e5,
|
|
380
|
-
// 5 minutes for schema/seed operations
|
|
381
|
-
// Get actual connection URL from environment or default
|
|
382
|
-
get defaultUrl() {
|
|
383
|
-
if (process.env.NODE_ENV === "production") {
|
|
384
|
-
if (!process.env.DATABASE_URL) {
|
|
385
|
-
throw new Error(
|
|
386
|
-
"DATABASE_URL is required in production environment.\nSet DATABASE_URL environment variable or configure in .env file."
|
|
387
|
-
);
|
|
388
|
-
}
|
|
389
|
-
return process.env.DATABASE_URL;
|
|
390
|
-
}
|
|
391
|
-
const databaseUrl = process.env.DATABASE_URL;
|
|
392
|
-
if (databaseUrl) {
|
|
393
|
-
try {
|
|
394
|
-
const url2 = new URL(databaseUrl);
|
|
395
|
-
const isLocalhost = url2.hostname === "127.0.0.1" || url2.hostname === "localhost" || url2.hostname === "host.docker.internal";
|
|
396
|
-
if (isLocalhost) {
|
|
397
|
-
return databaseUrl;
|
|
398
|
-
}
|
|
399
|
-
} catch {
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
const host = process.env.LOCAL_DB_HOST || process.env.DB_HOST || process.env.LOCAL_SUPABASE_HOST || this.SUPABASE_LOCAL.HOST;
|
|
403
|
-
const port = process.env.LOCAL_DB_PORT || process.env.DB_PORT || process.env.LOCAL_SUPABASE_DB_PORT || String(this.SUPABASE_LOCAL.PORT);
|
|
404
|
-
const user = process.env.LOCAL_DB_USER || process.env.DB_USER || this.SUPABASE_LOCAL.USER;
|
|
405
|
-
const password = process.env.LOCAL_DB_PASSWORD || process.env.DB_PASSWORD || this.SUPABASE_LOCAL.PASSWORD;
|
|
406
|
-
const database = process.env.LOCAL_DB_NAME || process.env.DB_NAME || this.SUPABASE_LOCAL.DATABASE;
|
|
407
|
-
const url = `postgresql://${user}:${password}@${host}:${port}/${database}`;
|
|
408
|
-
if (!process.env.DATABASE_URL && !process.env.LOCAL_DB_HOST && !process.env.DB_HOST) ;
|
|
409
|
-
return url;
|
|
410
|
-
}
|
|
411
|
-
};
|
|
412
|
-
SEED_DEFAULTS = {
|
|
413
|
-
// Unified 'ci.sql' for local and CI/preview (production does not use seeds)
|
|
414
|
-
REQUIRED_FILES: ["ci.sql"],
|
|
415
|
-
// Generic default paths (used only if config.toml parse fails)
|
|
416
|
-
// Projects should define their own sql_paths in config.toml
|
|
417
|
-
DEFAULT_PATHS: [
|
|
418
|
-
"./seeds/[0-9]*.sql",
|
|
419
|
-
// Prerequisite seeds (e.g., 00_auth_users.sql)
|
|
420
|
-
"./seeds/ci.sql"
|
|
421
|
-
// Unified seed for local and CI/preview
|
|
422
|
-
],
|
|
423
|
-
CONFIG_SECTION: "[db.seed]"
|
|
424
|
-
};
|
|
425
|
-
SCRIPT_LOCATIONS = {
|
|
426
|
-
VALIDATE_SCHEMAS: {
|
|
427
|
-
relativePath: "supabase/validate-schemas.sh",
|
|
428
|
-
description: "Schema validation script",
|
|
429
|
-
required: true
|
|
430
|
-
},
|
|
431
|
-
DETECT_RISKS: {
|
|
432
|
-
relativePath: "supabase/detect-risks.sh",
|
|
433
|
-
description: "Risk detection script",
|
|
434
|
-
required: true
|
|
435
|
-
},
|
|
436
|
-
APPLY_SCHEMAS: {
|
|
437
|
-
relativePath: "supabase/apply-schemas.sh",
|
|
438
|
-
description: "Schema application script",
|
|
439
|
-
required: true
|
|
440
|
-
},
|
|
441
|
-
APPLY_SEEDS: {
|
|
442
|
-
relativePath: "packages/sdk/scripts/apply-seeds.sh",
|
|
443
|
-
description: "Seed application script (SDK)",
|
|
444
|
-
required: false
|
|
445
|
-
},
|
|
446
|
-
GENERATE_TYPES: {
|
|
447
|
-
relativePath: "packages/sdk/scripts/generate-types.sh",
|
|
448
|
-
description: "Type generation script (SDK)",
|
|
449
|
-
required: false
|
|
450
|
-
}
|
|
451
|
-
};
|
|
452
|
-
ERROR_MESSAGES = {
|
|
453
|
-
SCRIPT_NOT_FOUND: (scriptName, expectedPath) => `${scriptName} not found
|
|
454
|
-
|
|
455
|
-
Expected location: ${expectedPath}`,
|
|
456
|
-
SEED_DIR_NOT_FOUND: "Seed directory not found\n\nRun: runa db seed init",
|
|
457
|
-
CONFIG_PARSE_FAILED: "Failed to parse config.toml, using default seed paths",
|
|
458
|
-
VALIDATION_FAILED: "Schema validation failed",
|
|
459
|
-
RISK_DETECTION_FAILED: "Risk detection failed",
|
|
460
|
-
SEED_VALIDATION_FAILED: "Seed validation failed",
|
|
461
|
-
TYPE_GENERATION_FAILED: "Type generation failed"
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
});
|
|
465
|
-
|
|
466
|
-
export { DATABASE_DEFAULTS, SCRIPT_LOCATIONS, SEED_DEFAULTS, buildLocalDatabaseUrl, constants_exports, detectLocalSupabasePorts, detectSupabasePorts, getLocalSupabaseEnvValues, getLocalValueDescriptions, init_constants, init_local_supabase };
|
|
277
|
+
export { LOCAL_DATABASE_URL, LOCAL_REPLACEMENT_KEYS, LOCAL_SUPABASE_ANON_KEY, LOCAL_SUPABASE_ENV_VALUES, LOCAL_SUPABASE_SERVICE_ROLE_KEY, LOCAL_SUPABASE_URL, LOCAL_VALUE_DESCRIPTIONS, buildLocalDatabaseUrl, buildLocalSupabaseUrl, clearLocalSupabaseDetectionCache, detectLocalSupabasePorts, getLocalSupabaseEnvValues, getLocalValueDescriptions, init_local_supabase, parseTomlPort, validateLocalhostValues };
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'module';
|
|
3
|
+
import { detectLocalSupabasePorts, buildLocalDatabaseUrl, buildLocalSupabaseUrl, init_local_supabase } from './chunk-F2AQ3EYJ.js';
|
|
4
|
+
import { __export, __esm, init_esm_shims } from './chunk-VRXHCR5K.js';
|
|
5
|
+
import { spawnSync } from 'child_process';
|
|
6
|
+
|
|
7
|
+
createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// src/commands/db/constants.ts
|
|
10
|
+
var constants_exports = {};
|
|
11
|
+
__export(constants_exports, {
|
|
12
|
+
DATABASE_DEFAULTS: () => DATABASE_DEFAULTS,
|
|
13
|
+
ERROR_MESSAGES: () => ERROR_MESSAGES,
|
|
14
|
+
SCRIPT_LOCATIONS: () => SCRIPT_LOCATIONS,
|
|
15
|
+
SEED_DEFAULTS: () => SEED_DEFAULTS,
|
|
16
|
+
detectSupabasePorts: () => detectSupabasePorts,
|
|
17
|
+
getSupabaseAccessPoints: () => getSupabaseAccessPoints
|
|
18
|
+
});
|
|
19
|
+
function detectSupabasePorts(projectRoot) {
|
|
20
|
+
const cwd = projectRoot || process.cwd();
|
|
21
|
+
const result = spawnSync("supabase", ["status", "--output", "json"], {
|
|
22
|
+
encoding: "utf-8",
|
|
23
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
24
|
+
timeout: 5e3,
|
|
25
|
+
// 5 second timeout
|
|
26
|
+
cwd
|
|
27
|
+
});
|
|
28
|
+
if (result.status !== 0 || !result.stdout) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"Supabase is not running.\n\nStart Supabase with: supabase start\nOr run: runa check --fix"
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
let status;
|
|
34
|
+
try {
|
|
35
|
+
const jsonMatch = result.stdout.match(/\{[\s\S]*\}/);
|
|
36
|
+
if (!jsonMatch) {
|
|
37
|
+
throw new Error("No JSON object found in output");
|
|
38
|
+
}
|
|
39
|
+
status = JSON.parse(jsonMatch[0]);
|
|
40
|
+
} catch {
|
|
41
|
+
throw new Error(
|
|
42
|
+
"Failed to parse Supabase status output.\n\nTry restarting Supabase: supabase stop && supabase start"
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
const apiUrl = status.API_URL || status["API URL"] || status.api_url;
|
|
46
|
+
const dbUrl = status.DB_URL || status["DB URL"] || status.db_url;
|
|
47
|
+
const studioUrl = status.STUDIO_URL || status["Studio URL"] || status.studio_url;
|
|
48
|
+
const extractPort = (url) => {
|
|
49
|
+
try {
|
|
50
|
+
const parsed = new URL(url);
|
|
51
|
+
return parsed.port ? Number.parseInt(parsed.port, 10) : null;
|
|
52
|
+
} catch {
|
|
53
|
+
const match = url.match(/:(\d+)\//);
|
|
54
|
+
return match ? Number.parseInt(match[1], 10) : null;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const apiPort = apiUrl ? extractPort(apiUrl) : null;
|
|
58
|
+
const dbPort = dbUrl ? extractPort(dbUrl) : null;
|
|
59
|
+
const studioPort = studioUrl ? extractPort(studioUrl) : null;
|
|
60
|
+
if (!apiPort || !dbPort) {
|
|
61
|
+
throw new Error(
|
|
62
|
+
"Could not detect Supabase ports from status output.\n\nTry restarting Supabase: supabase stop && supabase start"
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
api: apiPort,
|
|
67
|
+
db: dbPort,
|
|
68
|
+
studio: studioPort ?? apiPort + 2
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function getSupabaseAccessPoints(projectRoot) {
|
|
72
|
+
const ports = detectLocalSupabasePorts(projectRoot);
|
|
73
|
+
const buildSupabaseUrl = (port) => {
|
|
74
|
+
const url = new URL(buildLocalSupabaseUrl(projectRoot));
|
|
75
|
+
url.port = String(port);
|
|
76
|
+
return url.toString().replace(/\/$/, "");
|
|
77
|
+
};
|
|
78
|
+
return {
|
|
79
|
+
studio: buildSupabaseUrl(ports.studio),
|
|
80
|
+
api: buildLocalSupabaseUrl(projectRoot),
|
|
81
|
+
db: buildLocalDatabaseUrl(projectRoot)
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
var DATABASE_DEFAULTS, SEED_DEFAULTS, SCRIPT_LOCATIONS, ERROR_MESSAGES;
|
|
85
|
+
var init_constants = __esm({
|
|
86
|
+
"src/commands/db/constants.ts"() {
|
|
87
|
+
init_esm_shims();
|
|
88
|
+
init_local_supabase();
|
|
89
|
+
DATABASE_DEFAULTS = {
|
|
90
|
+
// Supabase Local defaults (for development)
|
|
91
|
+
// Note: PORT is detected from running Supabase instance
|
|
92
|
+
// AI HINT: Local Supabase Default Credentials (Non-Production)
|
|
93
|
+
// postgres:postgres is the standard default for `supabase start`.
|
|
94
|
+
// This is a documented public value, not a secret.
|
|
95
|
+
// Production uses environment variables via .env.production.
|
|
96
|
+
SUPABASE_LOCAL: {
|
|
97
|
+
get HOST() {
|
|
98
|
+
return detectLocalSupabasePorts().host;
|
|
99
|
+
},
|
|
100
|
+
get PORT() {
|
|
101
|
+
return detectSupabasePorts().db;
|
|
102
|
+
},
|
|
103
|
+
USER: "postgres",
|
|
104
|
+
PASSWORD: "postgres",
|
|
105
|
+
DATABASE: "postgres"
|
|
106
|
+
},
|
|
107
|
+
// Standard PostgreSQL defaults (more generic)
|
|
108
|
+
POSTGRES: {
|
|
109
|
+
HOST: "127.0.0.1",
|
|
110
|
+
PORT: 5432,
|
|
111
|
+
USER: "postgres",
|
|
112
|
+
PASSWORD: "",
|
|
113
|
+
DATABASE: "postgres"
|
|
114
|
+
},
|
|
115
|
+
// Timeouts
|
|
116
|
+
CONNECTION_TIMEOUT_MS: 5e3,
|
|
117
|
+
SCRIPT_TIMEOUT_MS: 3e5,
|
|
118
|
+
// 5 minutes for schema/seed operations
|
|
119
|
+
// Get actual connection URL from environment or default
|
|
120
|
+
get defaultUrl() {
|
|
121
|
+
if (process.env.NODE_ENV === "production") {
|
|
122
|
+
if (!process.env.DATABASE_URL) {
|
|
123
|
+
throw new Error(
|
|
124
|
+
"DATABASE_URL is required in production environment.\nSet DATABASE_URL environment variable or configure in .env file."
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return process.env.DATABASE_URL;
|
|
128
|
+
}
|
|
129
|
+
const databaseUrl = process.env.DATABASE_URL;
|
|
130
|
+
if (databaseUrl) {
|
|
131
|
+
try {
|
|
132
|
+
const url2 = new URL(databaseUrl);
|
|
133
|
+
const isLocalhost = url2.hostname === "127.0.0.1" || url2.hostname === "localhost" || url2.hostname === "host.docker.internal";
|
|
134
|
+
if (isLocalhost) {
|
|
135
|
+
return databaseUrl;
|
|
136
|
+
}
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const host = process.env.LOCAL_DB_HOST || process.env.DB_HOST || process.env.LOCAL_SUPABASE_HOST || this.SUPABASE_LOCAL.HOST;
|
|
141
|
+
const port = process.env.LOCAL_DB_PORT || process.env.DB_PORT || process.env.LOCAL_SUPABASE_DB_PORT || String(this.SUPABASE_LOCAL.PORT);
|
|
142
|
+
const user = process.env.LOCAL_DB_USER || process.env.DB_USER || this.SUPABASE_LOCAL.USER;
|
|
143
|
+
const password = process.env.LOCAL_DB_PASSWORD || process.env.DB_PASSWORD || this.SUPABASE_LOCAL.PASSWORD;
|
|
144
|
+
const database = process.env.LOCAL_DB_NAME || process.env.DB_NAME || this.SUPABASE_LOCAL.DATABASE;
|
|
145
|
+
const url = `postgresql://${user}:${password}@${host}:${port}/${database}`;
|
|
146
|
+
if (!process.env.DATABASE_URL && !process.env.LOCAL_DB_HOST && !process.env.DB_HOST) ;
|
|
147
|
+
return url;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
SEED_DEFAULTS = {
|
|
151
|
+
// Unified 'ci.sql' for local and CI/preview (production does not use seeds)
|
|
152
|
+
REQUIRED_FILES: ["ci.sql"],
|
|
153
|
+
// Generic default paths (used only if config.toml parse fails)
|
|
154
|
+
// Projects should define their own sql_paths in config.toml
|
|
155
|
+
DEFAULT_PATHS: [
|
|
156
|
+
"./seeds/[0-9]*.sql",
|
|
157
|
+
// Prerequisite seeds (e.g., 00_auth_users.sql)
|
|
158
|
+
"./seeds/ci.sql"
|
|
159
|
+
// Unified seed for local and CI/preview
|
|
160
|
+
],
|
|
161
|
+
CONFIG_SECTION: "[db.seed]"
|
|
162
|
+
};
|
|
163
|
+
SCRIPT_LOCATIONS = {
|
|
164
|
+
VALIDATE_SCHEMAS: {
|
|
165
|
+
relativePath: "supabase/validate-schemas.sh",
|
|
166
|
+
description: "Schema validation script",
|
|
167
|
+
required: true
|
|
168
|
+
},
|
|
169
|
+
DETECT_RISKS: {
|
|
170
|
+
relativePath: "supabase/detect-risks.sh",
|
|
171
|
+
description: "Risk detection script",
|
|
172
|
+
required: true
|
|
173
|
+
},
|
|
174
|
+
APPLY_SCHEMAS: {
|
|
175
|
+
relativePath: "supabase/apply-schemas.sh",
|
|
176
|
+
description: "Schema application script",
|
|
177
|
+
required: true
|
|
178
|
+
},
|
|
179
|
+
APPLY_SEEDS: {
|
|
180
|
+
relativePath: "packages/sdk/scripts/apply-seeds.sh",
|
|
181
|
+
description: "Seed application script (SDK)",
|
|
182
|
+
required: false
|
|
183
|
+
},
|
|
184
|
+
GENERATE_TYPES: {
|
|
185
|
+
relativePath: "packages/sdk/scripts/generate-types.sh",
|
|
186
|
+
description: "Type generation script (SDK)",
|
|
187
|
+
required: false
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
ERROR_MESSAGES = {
|
|
191
|
+
SCRIPT_NOT_FOUND: (scriptName, expectedPath) => `${scriptName} not found
|
|
192
|
+
|
|
193
|
+
Expected location: ${expectedPath}`,
|
|
194
|
+
SEED_DIR_NOT_FOUND: "Seed directory not found\n\nRun: runa db seed init",
|
|
195
|
+
CONFIG_PARSE_FAILED: "Failed to parse config.toml, using default seed paths",
|
|
196
|
+
VALIDATION_FAILED: "Schema validation failed",
|
|
197
|
+
RISK_DETECTION_FAILED: "Risk detection failed",
|
|
198
|
+
SEED_VALIDATION_FAILED: "Seed validation failed",
|
|
199
|
+
TYPE_GENERATION_FAILED: "Type generation failed"
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
export { DATABASE_DEFAULTS, SCRIPT_LOCATIONS, SEED_DEFAULTS, constants_exports, detectSupabasePorts, init_constants };
|