@runa-ai/runa-cli 0.5.49 → 0.5.51

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.
@@ -1,9 +1,10 @@
1
1
  /**
2
- * AI HINT: App runtime helpers for CI
2
+ * AI HINT: App runtime helpers for CI and Dev
3
3
  *
4
4
  * - Write `.env.local` for Next.js runtime
5
5
  * - Start app in background
6
6
  * - Wait for readiness
7
+ * - Clean stale Next.js dev state
7
8
  */
8
9
  export declare function writeEnvLocal(params: {
9
10
  appDir: string;
@@ -15,6 +16,20 @@ export declare function writeEnvLocal(params: {
15
16
  * - 'start': Production mode (next start, requires build)
16
17
  */
17
18
  export type AppMode = 'dev' | 'start';
19
+ /**
20
+ * Clean stale Next.js dev state that prevents `next dev` from starting.
21
+ *
22
+ * When Next.js dev server is killed without graceful shutdown (SIGKILL, crash,
23
+ * power loss), the .next directory can be left in a corrupted state.
24
+ * Subsequent `next dev` starts may fail with manifest errors or port conflicts
25
+ * even though no process is actually running.
26
+ *
27
+ * This function detects and cleans stale .next state before starting.
28
+ */
29
+ export declare function cleanStaleNextDevState(appDir: string): {
30
+ cleaned: boolean;
31
+ reason?: string;
32
+ };
18
33
  export declare function startAppBackground(params: {
19
34
  repoRoot: string;
20
35
  appDir: string;
@@ -1 +1 @@
1
- {"version":3,"file":"app-runtime.d.ts","sourceRoot":"","sources":["../../../../src/commands/ci/utils/app-runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+GH,wBAAsB,aAAa,CAAC,MAAM,EAAE;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhB;AAiHD;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,OAAO,CAAC;AA4DtC,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAC/C,QAAQ,EAAE,MA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M,CAAC;IACf,6FAA6F;IAC7F,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wEAAwE;IACxE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,IAAI,CAAA;CAAE,CAAC,CA+DvD;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CAOhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"preflight-check.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/utils/preflight-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAsBH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAwrBD;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAenF"}
1
+ {"version":3,"file":"preflight-check.d.ts","sourceRoot":"","sources":["../../../../src/commands/db/utils/preflight-check.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAsBH,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAspBD;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAenF"}
@@ -1 +1 @@
1
- {"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../../../src/commands/dev/machine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GA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AAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,UAAU,cAAc;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAuCD,UAAU,aAAa;IACrB,GAAG,EAAE,MAAM,CAAC;CACb;AAoBD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAIH,QAAQ;cAAY,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;EA8K5C,CAAC;AAMH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC;AAC3C,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;AAM1D;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,CAa1D;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,WAAW,GAAG,OAAO,CAEzD;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAE7D"}
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ import path10__default, { join, dirname, resolve, relative, basename, sep, isAbs
5
5
  import { fileURLToPath } from 'url';
6
6
  import { execSync, spawnSync, execFileSync, exec, spawn } from 'child_process';
7
7
  import * as fs5 from 'fs';
8
- import fs5__default, { existsSync, readFileSync, readdirSync, mkdtempSync, writeFileSync, mkdirSync, copyFileSync, createWriteStream, statSync, rmSync, realpathSync, promises, lstatSync, accessSync, constants, chmodSync, unlinkSync } from 'fs';
8
+ import fs5__default, { existsSync, readFileSync, readdirSync, mkdtempSync, writeFileSync, mkdirSync, copyFileSync, createWriteStream, statSync, rmSync, realpathSync, renameSync, promises, lstatSync, accessSync, constants, chmodSync, unlinkSync } from 'fs';
9
9
  import { createCLILogger, cacheClear, CacheClearOutputSchema, CLIError, cachePrune, CachePruneOutputSchema, cacheStats, CacheStatsOutputSchema, cacheList, CacheListOutputSchema, cacheInvalidate, CacheInvalidateOutputSchema, syncFromProduction, dbGenerateDiagram, DbDiagramGenerateOutputSchema, createDbSnapshot, syncDatabase, emitDbPushFailureCapsule, emitDbAnnotations, writeDbPushStepSummary, exportDbReportJson, DbSyncOutputSchema, databasePaths, detectRequiredServices, formatDetectionResults, dbStart, DbLifecycleStartOutputSchema, dbStop, DbLifecycleStopOutputSchema, dbReset, DbLifecycleResetOutputSchema, dbValidateSchemas, DbSchemaValidateOutputSchema, DbSchemaRisksOutputSchema, dbDetectSchemaRisks, dbApplySchemas, DbSchemaApplyOutputSchema, dbGenerateTypes, DbSchemaGenerateOutputSchema, extractSchemaFilter, dbSeedInit, DbSeedInitOutputSchema, dbSeedValidate, DbSeedValidateOutputSchema, dbSeedGenerate, DbSeedGenerateOutputSchema, dbVerifySeeds, DbSeedVerifyOutputSchema, DbSnapshotCreateOutputSchema, restoreDbSnapshot, DbSnapshotRestoreOutputSchema, listDbSnapshots, DbSnapshotListOutputSchema, dbGeneratePgTapTests, DbTestGenOutputSchema, dbUpdateGoldenRecord, DbTestUpdateGoldenOutputSchema, repairRunaConfig, detectExistingInitConfig, initProject, validateInitResult, linkCliGlobally, LinkCliOutputSchema, unlinkCliGlobally, UnlinkCliOutputSchema, checkRepoStatus, CheckRepoStatusOutputSchema, enableTelemetry, disableTelemetry, getTelemetryStatus, uploadTelemetry, TelemetryUploadOutputSchema, runTest, TestRunOutputSchema, runTestService, TestServiceOutputSchema, runTestIntegration, TestIntegrationOutputSchema, runTestStatic, TestStaticOutputSchema, generateOwaspTop10Tests, TestOwaspGenerateOutputSchema, updateGoldenRecord, generateE2ETests, generateSecurityTests, generateUnitTests, generateApiTests, generateComponentTests, generateE2EScaffold, validateConfig, ValidateConfigOutputSchema, deploySchemaToProduction, WorkflowNotifyOutputSchema, devopsSync, workflowSync, validateInfrastructure, emitWorkflowValidateFailureCapsule, emitWorkflowAnnotations, writeWorkflowValidateStepSummary, exportWorkflowReportJson, WorkflowValidateInfrastructureOutputSchema, createSuccessEnvelopeSchema, CLI_CONTRACT_VERSION, runChecks, RunCheckOutputSchema, formatDuration as formatDuration$1, GITHUB_API, loadRunaConfig, getClassificationForProfile, loadRunaConfigOrThrow, recordSchemaAudit, RecordSchemaAuditOutputSchema, createBackup, CreateBackupOutputSchema, listBackups, ListBackupsOutputSchema, getBackupMetadata, restoreBackup, RestoreBackupOutputSchema, deleteBackup, DeleteBackupOutputSchema, detectSchemaNames, SUPABASE_SYSTEM_SCHEMAS, dbSeedApply, writeDbSeedStepSummary, DbSeedApplyOutputSchema, emitDbSeedFailureCapsule, syncEnvironment, EnvSyncOutputSchema, detectDatabasePackage, findProjectRoot as findProjectRoot$1, TelemetryEnableOutputSchema, TelemetryDisableOutputSchema, TelemetryStatusOutputSchema, workflowNotify, DevOpsSyncOutputSchema, WorkflowSyncOutputSchema, formatCLIError, getStatusIcon as getStatusIcon$1, findWorkspaceRoot as findWorkspaceRoot$1, checkExtensionConfig, UpgradeTransaction, readRunaVersion, syncTemplates, SyncOutputSchema, DATABASE_PACKAGE_CANDIDATES, ErrorEnvelopeSchema, preCheckSync, findConflictFiles, TestUnitGenOutputSchema, TestE2EGenerateOutputSchema, TestSecurityGenOutputSchema, TestApiGenOutputSchema, TestComponentGenOutputSchema } from '@runa-ai/runa';
10
10
  import { z } from 'zod';
11
11
  import fs9, { mkdir, writeFile, appendFile, readFile, rm, stat, realpath, cp, readdir, lstat } from 'fs/promises';
@@ -929,7 +929,7 @@ var CLI_VERSION, HAS_ADMIN_COMMAND;
929
929
  var init_version = __esm({
930
930
  "src/version.ts"() {
931
931
  init_esm_shims();
932
- CLI_VERSION = "0.5.49";
932
+ CLI_VERSION = "0.5.51";
933
933
  HAS_ADMIN_COMMAND = false;
934
934
  }
935
935
  });
@@ -7867,6 +7867,48 @@ function determineAppCommand(mode, isMonorepo2, rootScripts, appScripts, repoRoo
7867
7867
  useRootScript: false
7868
7868
  };
7869
7869
  }
7870
+ var NEXT_CRITICAL_FILES = ["routes-manifest.json", "build-manifest.json"];
7871
+ function cleanStaleNextDevState(appDir) {
7872
+ const nextDir = path10__default.join(appDir, ".next");
7873
+ if (!existsSync(nextDir)) {
7874
+ return { cleaned: false };
7875
+ }
7876
+ for (const file of NEXT_CRITICAL_FILES) {
7877
+ if (!existsSync(path10__default.join(nextDir, file))) {
7878
+ cleanNextDir(nextDir, `Missing ${file}`);
7879
+ return { cleaned: true, reason: `Missing ${file}` };
7880
+ }
7881
+ }
7882
+ const serverDir = path10__default.join(nextDir, "server");
7883
+ if (!existsSync(serverDir)) {
7884
+ try {
7885
+ const nextStat = statSync(nextDir);
7886
+ const ageHours = (Date.now() - nextStat.mtimeMs) / (1e3 * 60 * 60);
7887
+ if (ageHours > 1) {
7888
+ cleanNextDir(nextDir, "Stale .next without server directory");
7889
+ return { cleaned: true, reason: "Stale .next without server directory" };
7890
+ }
7891
+ } catch {
7892
+ }
7893
+ }
7894
+ return { cleaned: false };
7895
+ }
7896
+ function cleanNextDir(nextDir, reason) {
7897
+ console.log(`[runa] Stale .next detected: ${reason}`);
7898
+ console.log("[runa] Cleaning up .next directory...");
7899
+ try {
7900
+ rmSync(nextDir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 });
7901
+ console.log("[runa] Cleanup complete");
7902
+ } catch {
7903
+ const staleDir = `${nextDir}-stale-${Date.now()}`;
7904
+ console.log(`[runa] Could not remove .next, quarantining to ${path10__default.basename(staleDir)}`);
7905
+ try {
7906
+ renameSync(nextDir, staleDir);
7907
+ } catch {
7908
+ console.warn("[runa] Failed to quarantine .next. Run: rm -rf .next");
7909
+ }
7910
+ }
7911
+ }
7870
7912
  async function startAppBackground(params) {
7871
7913
  const mode = params.mode ?? "start";
7872
7914
  const isMonorepo2 = params.appDir !== params.repoRoot;
@@ -8060,6 +8102,7 @@ var appStartActor = fromPromise(
8060
8102
  const { repoRoot, appDir, port, tmpDir, stream } = input3;
8061
8103
  const fullTmpDir = path10__default.join(repoRoot, tmpDir);
8062
8104
  await mkdir(fullTmpDir, { recursive: true });
8105
+ cleanStaleNextDevState(appDir);
8063
8106
  const result = await startAppBackground({
8064
8107
  repoRoot,
8065
8108
  appDir,
@@ -21339,7 +21382,7 @@ async function runOrphanCheck(env2, dbPackagePath, result, logger16, step) {
21339
21382
  logger16.warn(`Orphan check skipped: ${message}`);
21340
21383
  }
21341
21384
  }
21342
- function runExtensionConfigCheck(result, logger16, step) {
21385
+ function runExtensionConfigCheck(_result, logger16, step) {
21343
21386
  logger16.step("Checking PostgreSQL extension configuration", step.next());
21344
21387
  try {
21345
21388
  const extensionResult = checkExtensionConfig(process.cwd());
@@ -21347,43 +21390,17 @@ function runExtensionConfigCheck(result, logger16, step) {
21347
21390
  logger16.success("No extensions detected in SQL files");
21348
21391
  return;
21349
21392
  }
21350
- if (extensionResult.passed) {
21351
- logger16.success(
21352
- `All ${extensionResult.usedExtensions.length} extension(s) are enabled in config.toml`
21353
- );
21354
- return;
21393
+ const parts = [];
21394
+ if (extensionResult.sqlManagedExtensions.length > 0) {
21395
+ parts.push(`${extensionResult.sqlManagedExtensions.length} SQL-managed`);
21355
21396
  }
21356
21397
  if (extensionResult.supabaseManagedExtensions.length > 0) {
21357
- logger16.info(
21358
- `Supabase-managed: ${extensionResult.supabaseManagedExtensions.join(", ")} (auto-enabled)`
21359
- );
21360
- }
21361
- if (extensionResult.missingExtensions.length > 0) {
21362
- for (const warning of extensionResult.warnings) {
21363
- recordWarning(result, warning);
21364
- }
21365
- logger16.warn(
21366
- `Missing ${extensionResult.missingExtensions.length} extension(s) in config.toml:`
21367
- );
21368
- for (const ext of extensionResult.missingExtensions) {
21369
- const sqlFile = extensionResult.sqlFilePaths.get(ext);
21370
- logger16.info(` \u2022 ${ext}${sqlFile ? ` (used in ${path10__default.basename(sqlFile)})` : ""}`);
21371
- }
21372
- logger16.info("");
21373
- logger16.info(" To fix, add to supabase/config.toml:");
21374
- logger16.info(" [db.extensions]");
21375
- for (const ext of extensionResult.missingExtensions) {
21376
- logger16.info(` ${ext} = "enabled"`);
21377
- }
21378
- logger16.info("");
21379
- logger16.info(" Then restart Supabase: supabase stop && supabase start");
21380
- logger16.info("");
21398
+ parts.push(`${extensionResult.supabaseManagedExtensions.length} Supabase-managed`);
21381
21399
  }
21382
- if (extensionResult.notes.length > 0) {
21383
- for (const note of extensionResult.notes) {
21384
- logger16.info(` Note: ${note}`);
21385
- }
21386
- logger16.info("");
21400
+ const summary = parts.join(", ");
21401
+ logger16.success(`${extensionResult.usedExtensions.length} extension(s) found (${summary})`);
21402
+ for (const note of extensionResult.notes) {
21403
+ logger16.info(` ${note}`);
21387
21404
  }
21388
21405
  } catch (error) {
21389
21406
  const message = error instanceof Error ? error.message : "Unknown error";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runa-ai/runa-cli",
3
- "version": "0.5.49",
3
+ "version": "0.5.51",
4
4
  "private": false,
5
5
  "description": "AI-powered DevOps CLI",
6
6
  "type": "module",