@duraxis/cli 0.4.0 → 0.5.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +9 -23
  3. package/dist/admin.command-Dt5MnwJw.js +299 -0
  4. package/dist/admin.command-Dt5MnwJw.js.map +1 -0
  5. package/dist/commands/doctor.command.d.ts +1 -2
  6. package/dist/commands/minimal-admin.d.ts +4 -0
  7. package/dist/{config-CjMUqEhV.js → config-BKscNXeW.js} +53 -14
  8. package/dist/config-BKscNXeW.js.map +1 -0
  9. package/dist/config.d.ts +4 -6
  10. package/dist/file-plan-D-Sj3yv0.js +130 -0
  11. package/dist/file-plan-D-Sj3yv0.js.map +1 -0
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +7 -7
  14. package/dist/index.js.map +1 -1
  15. package/dist/init/initialization-planner.d.ts +6 -3
  16. package/dist/init/nest-integration.d.ts +2 -0
  17. package/dist/init/static-config.d.ts +16 -0
  18. package/dist/{init.command-B2kKoyfi.js → init.command-DrO29773.js} +12 -17
  19. package/dist/init.command-DrO29773.js.map +1 -0
  20. package/dist/initialization-planner-B41PNGWc.js +315 -0
  21. package/dist/initialization-planner-B41PNGWc.js.map +1 -0
  22. package/dist/{migration.command-N7ahyx92.js → migration.command-dhRbN4UI.js} +4 -4
  23. package/dist/{migration.command-N7ahyx92.js.map → migration.command-dhRbN4UI.js.map} +1 -1
  24. package/dist/minimal-admin-B4ur_cON.js +232 -0
  25. package/dist/minimal-admin-B4ur_cON.js.map +1 -0
  26. package/dist/nest-integration-KCc7ZaG6.js +93 -0
  27. package/dist/nest-integration-KCc7ZaG6.js.map +1 -0
  28. package/dist/package-manager-Ca5ArUf-.js +269 -0
  29. package/dist/package-manager-Ca5ArUf-.js.map +1 -0
  30. package/dist/project-detector-BQWeQZ8Q.js +174 -0
  31. package/dist/project-detector-BQWeQZ8Q.js.map +1 -0
  32. package/dist/static-config-g_7qN12_.js +109 -0
  33. package/dist/static-config-g_7qN12_.js.map +1 -0
  34. package/dist/templates/project.d.ts +3 -1
  35. package/package.json +6 -6
  36. package/dist/admin.command-Chb6x9mF.js +0 -413
  37. package/dist/admin.command-Chb6x9mF.js.map +0 -1
  38. package/dist/config-CjMUqEhV.js.map +0 -1
  39. package/dist/init/managed-project.d.ts +0 -9
  40. package/dist/init.command-B2kKoyfi.js.map +0 -1
  41. package/dist/package-manager-BBRBhsIe.js +0 -972
  42. package/dist/package-manager-BBRBhsIe.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-BKscNXeW.js","names":[],"sources":["../src/runtime.mjs","../src/typescript-loader.ts","../src/config.ts"],"sourcesContent":["export const MINIMUM_NODE_VERSION = \"24.15.0\";\n\n/** Reject unsupported runtimes before importing the CLI and its Node.js APIs. */\nexport function assertSupportedRuntime(version = process.versions.node) {\n const actual = version.split(\".\").map(Number);\n const minimum = MINIMUM_NODE_VERSION.split(\".\").map(Number);\n const difference = actual.findIndex((part, index) => part !== minimum[index]);\n const supported =\n /^\\d+\\.\\d+\\.\\d+$/.test(version) &&\n (difference === -1 || actual[difference] > minimum[difference]);\n if (!supported)\n throw new Error(\n `Duraxis requires Node.js ${MINIMUM_NODE_VERSION} or newer.\\nCurrent version: ${version}\\nPlease upgrade your Node.js installation.`,\n );\n}\n","import { readFileSync, statSync } from \"node:fs\";\nimport { registerHooks, type ModuleHooks } from \"node:module\";\nimport { extname, dirname, join } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport ts from \"typescript\";\nimport { assertSupportedRuntime } from \"./runtime.mjs\";\n\nconst sourceExtensions: Readonly<Record<string, string>> = {\n \".js\": \".ts\",\n \".mjs\": \".mts\",\n \".cjs\": \".cts\",\n};\nlet hooks: ModuleHooks | undefined;\nconst modules = new Set<string>();\n\nfunction localFile(value: string): URL | undefined {\n if (!value.startsWith(\"file:\")) return;\n const url = new URL(value);\n const path = fileURLToPath(url);\n if (path.split(/[\\\\/]/).includes(\"node_modules\")) return;\n return url;\n}\nfunction exists(url: URL): boolean {\n try {\n return statSync(url).isFile();\n } catch (error) {\n if ([\"ENOENT\", \"ENOTDIR\"].includes((error as NodeJS.ErrnoException).code ?? \"\")) return false;\n throw error;\n }\n}\nfunction remember(url: string): void {\n if (localFile(url)) modules.add(url);\n}\n\n/** One hook pair per library instance, limited to explicitly loaded local module graphs. */\nexport function initializeTypeScriptLoader(entry: URL): void {\n assertSupportedRuntime();\n remember(entry.href);\n if (hooks) return;\n hooks = registerHooks({\n resolve(specifier, context, nextResolve) {\n const relative = /^(?:\\.{1,2}[\\\\/]|\\/|file:)/.test(specifier);\n const managed =\n relative &&\n (modules.has(specifier) ||\n (context.parentURL !== undefined && modules.has(context.parentURL)));\n try {\n const resolved = nextResolve(specifier, context);\n if (managed) remember(resolved.url);\n return resolved;\n } catch (error) {\n if (\n !managed ||\n ![\"ERR_MODULE_NOT_FOUND\", \"MODULE_NOT_FOUND\"].includes(\n (error as NodeJS.ErrnoException).code ?? \"\",\n )\n )\n throw error;\n const requested = localFile(new URL(specifier, context.parentURL).href);\n if (!requested || exists(requested)) throw error;\n const path = fileURLToPath(requested);\n const extension = extname(path);\n const mapped = sourceExtensions[extension];\n if (!mapped) throw error;\n const candidate = pathToFileURL(path.slice(0, -extension.length) + mapped);\n candidate.search = requested.search;\n candidate.hash = requested.hash;\n if (!exists(candidate)) throw error;\n const resolved = nextResolve(\n context.conditions.includes(\"require\") ? fileURLToPath(candidate) : candidate.href,\n context,\n );\n remember(resolved.url);\n return resolved;\n }\n },\n load(url, context, nextLoad) {\n if (!modules.has(url)) return nextLoad(url, context);\n const file = localFile(url);\n if (!file) return nextLoad(url, context);\n const path = fileURLToPath(file);\n if (!/\\.(?:ts|mts|cts)$/.test(path) || /\\.d\\.(?:ts|mts|cts)$/.test(path))\n return nextLoad(url, context);\n let commonjs = path.endsWith(\".cts\");\n if (path.endsWith(\".ts\")) {\n let directory = dirname(path);\n while (true) {\n try {\n commonjs =\n JSON.parse(readFileSync(join(directory, \"package.json\"), \"utf8\")).type !== \"module\";\n break;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n if (dirname(directory) === directory) {\n commonjs = true;\n break;\n }\n directory = dirname(directory);\n }\n }\n const result = ts.transpileModule(readFileSync(file, \"utf8\"), {\n fileName: path,\n reportDiagnostics: true,\n compilerOptions: {\n target: ts.ScriptTarget.ES2022,\n module: commonjs ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext,\n\n experimentalDecorators: true,\n emitDecoratorMetadata: true,\n useDefineForClassFields: false,\n sourceMap: false,\n },\n });\n const errors = (result.diagnostics ?? []).filter(\n (item) => item.category == ts.DiagnosticCategory.Error,\n );\n if (errors.length)\n throw new Error(\n ts.formatDiagnosticsWithColorAndContext(errors, {\n getCurrentDirectory: () => process.cwd(),\n getCanonicalFileName: (file) => file,\n getNewLine: () => \"\\n\",\n }),\n );\n // Imported CommonJS source otherwise receives the ESM translator's synthetic\n // require, which bypasses customization hooks. Use Node's hook-aware require.\n return {\n format: commonjs ? \"commonjs\" : \"module\",\n source:\n (commonjs\n ? '\"use strict\";\\nrequire = require(\"node:module\").createRequire(__filename);\\n'\n : \"\") + result.outputText,\n shortCircuit: true,\n };\n },\n });\n}\n\n/** Call only when no config/entity/migration callbacks need further dynamic imports. Node's module cache is retained. */\nexport function disposeTypeScriptLoader(): void {\n hooks?.deregister();\n hooks = undefined;\n // Retain graph identity alongside Node's module cache so cached callbacks can\n // resolve further imports after a later initialization.\n}\n","import { access, readFile } from \"node:fs/promises\";\nimport { dirname, resolve } from \"node:path\";\nimport { initializeTypeScriptLoader } from \"./typescript-loader.js\";\nimport { pathToFileURL } from \"node:url\";\nimport {\n createDatabase,\n normalizeDuraxisConnection,\n selectDuraxisConnection,\n type DuraxisConfiguration,\n type DuraxisDatabase,\n} from \"@duraxis/core\";\nimport { discoverEntities } from \"@duraxis/orm\";\nimport type { EntityClass } from \"@duraxis/orm\";\n\nexport interface DuraxisConnectionConfig {\n readonly settings?: unknown;\n readonly moduleFormat?: \"esm\" | \"cjs\";\n readonly entities?:\n readonly EntityClass[] | (() => readonly EntityClass[] | Promise<readonly EntityClass[]>);\n readonly migrations?: {\n readonly directory: string;\n readonly snapshots: string;\n readonly format?: \"ts\" | \"js\" | \"mts\" | \"mjs\";\n };\n readonly createDatabase: () => DuraxisDatabase | Promise<DuraxisDatabase>;\n}\n\nexport type DuraxisConfig = DuraxisConfiguration;\n\nexport async function importFile(path: string | URL): Promise<unknown> {\n const url = path instanceof URL ? path : pathToFileURL(path);\n initializeTypeScriptLoader(url);\n return import(url.href);\n}\n\nexport async function loadConfig(\n cwd: string,\n explicit?: string,\n database?: string,\n): Promise<{ config: DuraxisConnectionConfig; root: string; path: string }> {\n let path: string | undefined;\n\n if (explicit) path = resolve(cwd, explicit);\n else {\n let directory = resolve(cwd);\n\n while (true) {\n for (const name of [\n \"duraxis.config.ts\",\n \"duraxis.config.mts\",\n \"duraxis.config.js\",\n \"duraxis.config.mjs\",\n \"duraxis.config.cts\",\n \"duraxis.config.cjs\",\n ]) {\n const candidate = resolve(directory, name);\n\n try {\n await access(candidate);\n\n path = candidate;\n\n break;\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code != \"ENOENT\") throw error;\n }\n }\n\n if (!path) {\n const project = await (\n await import(\"./init/project-detector.js\")\n ).detectProject(directory, true);\n if (project.configFiles.length > 1)\n throw new Error(\"Multiple Duraxis configurations found; select one with --config\");\n if (project.configFiles.length === 1) path = resolve(directory, project.configFiles[0]!);\n }\n if (path || dirname(directory) == directory) break;\n\n directory = dirname(directory);\n }\n }\n\n if (!path) throw new Error(\"No duraxis.config.ts or JavaScript configuration found\");\n\n const module = (await importFile(path)) as { default?: DuraxisConfig };\n\n let base = module.default;\n // TypeScript CommonJS default exports may be wrapped by Node's ESM namespace.\n if (base && \"default\" in base) base = (base as unknown as { default: DuraxisConfig }).default;\n if (!base || typeof base !== \"object\" || (!(\"driver\" in base) && !(\"connections\" in base)))\n throw new Error(\"Invalid Duraxis configuration; configure a driver or named connections\");\n const selected = selectDuraxisConnection(base as unknown as DuraxisConfiguration, database);\n const options = normalizeDuraxisConnection({\n ...selected,\n location: selected.location ?? path,\n });\n const context = options.context;\n const moduleFormat = /\\.[cm][jt]s$/.test(path)\n ? /\\.c[jt]s$/.test(path)\n ? \"cjs\"\n : \"esm\"\n : (await (await import(\"./init/project-detector.js\")).detectProject(context.root, true))\n .moduleFormat;\n let discover = discoverEntities;\n if (moduleFormat === \"cjs\" && (options.entities !== undefined || options.autoLoadEntities)) {\n const require = (await import(\"node:module\")).createRequire(path);\n discover = (require(\"@duraxis/orm\") as typeof import(\"@duraxis/orm\")).discoverEntities;\n }\n const config: DuraxisConnectionConfig = {\n settings: {\n ...selected,\n database: options.database,\n schema: options.schema,\n migrations: options.migrations,\n },\n createDatabase: () => createDatabase(options),\n ...(options.entities !== undefined || options.autoLoadEntities\n ? { entities: () => discover(options, (url) => importFile(url)) }\n : {}),\n ...(options.migrations ? { migrations: options.migrations } : {}),\n moduleFormat,\n };\n return { config, root: context.root, path };\n}\n\nexport async function readJSON<T>(path: string): Promise<T> {\n return JSON.parse(await readFile(path, \"utf8\")) as T;\n}\n\nexport function requireMigrationConfig(\n config: DuraxisConnectionConfig,\n): asserts config is DuraxisConnectionConfig & {\n migrations: NonNullable<DuraxisConnectionConfig[\"migrations\"]>;\n} {\n if (!config.migrations)\n throw new Error(\n \"Migrations are disabled for this connection. Enable them before running migration commands.\",\n );\n}\n"],"mappings":";;;;;;;;;;AAAA,IAAa,uBAAuB;;AAGpC,SAAgB,uBAAuB,UAAU,QAAQ,SAAS,MAAM;CACtE,MAAM,SAAS,QAAQ,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CAC5C,MAAM,UAAU,qBAAqB,MAAM,GAAG,CAAC,CAAC,IAAI,MAAM;CAC1D,MAAM,aAAa,OAAO,WAAW,MAAM,UAAU,SAAS,QAA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CAAC;GAC/D;EAEO;EAAQ,MAAM,QAAQ;EAAM;CAAK;AAC5C;AAEA,eAAsB,SAAY,MAA0B;CAC1D,OAAO,KAAK,MAAM,MAAM,SAAS,MAAM,MAAM,CAAC;AAChD;AAEA,SAAgB,uBACd,QAGA;CACA,IAAI,CAAC,OAAO,YACV,MAAM,IAAI,MACR,6FACF;AACJ"}
package/dist/config.d.ts CHANGED
@@ -1,19 +1,17 @@
1
- import type { DuraxisDatabase } from "@duraxis/core";
1
+ import { type DuraxisConfiguration, type DuraxisDatabase } from "@duraxis/core";
2
2
  import type { EntityClass } from "@duraxis/orm";
3
3
  export interface DuraxisConnectionConfig {
4
+ readonly settings?: unknown;
4
5
  readonly moduleFormat?: "esm" | "cjs";
5
6
  readonly entities?: readonly EntityClass[] | (() => readonly EntityClass[] | Promise<readonly EntityClass[]>);
6
7
  readonly migrations?: {
7
8
  readonly directory: string;
8
9
  readonly snapshots: string;
9
- readonly format?: "ts" | "js";
10
+ readonly format?: "ts" | "js" | "mts" | "mjs";
10
11
  };
11
12
  readonly createDatabase: () => DuraxisDatabase | Promise<DuraxisDatabase>;
12
13
  }
13
- export interface DuraxisConfig extends DuraxisConnectionConfig {
14
- readonly databases?: Readonly<Record<string, DuraxisConnectionConfig>>;
15
- }
16
- export declare function defineDuraxisConfig<const T extends DuraxisConfig>(config: T): T;
14
+ export type DuraxisConfig = DuraxisConfiguration;
17
15
  export declare function importFile(path: string | URL): Promise<unknown>;
18
16
  export declare function loadConfig(cwd: string, explicit?: string, database?: string): Promise<{
19
17
  config: DuraxisConnectionConfig;
@@ -0,0 +1,130 @@
1
+ import { chmod, lstat, mkdir, readFile, rename, rmdir, unlink, writeFile } from "node:fs/promises";
2
+ import { dirname, isAbsolute, join, relative, resolve } from "node:path";
3
+ import { randomUUID } from "node:crypto";
4
+ // src/filesystem/file-plan.ts
5
+ function safeRelative(path) {
6
+ if (!path || isAbsolute(path) || path.includes("\\") || path.includes("\0") || path.split("/").some((p) => p === ".." || p === "." || !p) || path.includes(":")) throw new Error(`Unsafe project path: ${path}`);
7
+ return path;
8
+ }
9
+ async function assertNoSymlinks(path) {
10
+ let cursor = resolve(path);
11
+ while (true) {
12
+ try {
13
+ if ((await lstat(cursor)).isSymbolicLink()) throw new Error(`Symlinks are not allowed in managed paths: ${cursor}`);
14
+ } catch (error) {
15
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
16
+ }
17
+ if (dirname(cursor) === cursor) break;
18
+ cursor = dirname(cursor);
19
+ }
20
+ }
21
+ async function addFile(plan, path, content, update = false) {
22
+ safeRelative(path);
23
+ const target = resolve(plan.root, path);
24
+ await assertNoSymlinks(target);
25
+ let before;
26
+ try {
27
+ before = await readFile(target, "utf8");
28
+ } catch (error) {
29
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
30
+ }
31
+ if (before === content) return;
32
+ if (before !== void 0 && !update) throw new Error(`Refusing to overwrite ${path}`);
33
+ if (plan.files.some((f) => f.path === path)) throw new Error(`Duplicate planned file: ${path}`);
34
+ plan.files.push({
35
+ path,
36
+ content,
37
+ ...before === void 0 ? {} : { before }
38
+ });
39
+ }
40
+ async function executeFiles(plan, after) {
41
+ await assertNoSymlinks(plan.root);
42
+ await mkdir(plan.root, { recursive: true });
43
+ const lockPath = join(plan.root, ".duraxis-init.lock");
44
+ const lock = await import("node:fs/promises").then((fs) => fs.open(lockPath, "wx"));
45
+ const applied = [];
46
+ const createdDirectories = [];
47
+ const ensureDirectory = async (path) => {
48
+ if (path === plan.root) return;
49
+ if (relative(plan.root, path).startsWith("..")) throw new Error("Directory escapes project");
50
+ await assertNoSymlinks(path);
51
+ try {
52
+ if (!(await lstat(path)).isDirectory()) throw new Error("Expected a directory");
53
+ return;
54
+ } catch (error) {
55
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
56
+ }
57
+ await ensureDirectory(dirname(path));
58
+ await mkdir(path);
59
+ createdDirectories.push(path);
60
+ };
61
+ const replace = async (target, content) => {
62
+ const temporary = `${target}.${randomUUID()}.tmp`;
63
+ try {
64
+ const mode = (await lstat(target)).mode & 511;
65
+ await writeFile(temporary, content, {
66
+ flag: "wx",
67
+ mode
68
+ });
69
+ await chmod(temporary, mode);
70
+ await rename(temporary, target);
71
+ } finally {
72
+ await unlink(temporary).catch((error) => {
73
+ if (error.code !== "ENOENT") throw error;
74
+ });
75
+ }
76
+ };
77
+ try {
78
+ for (const path of plan.directories) await ensureDirectory(resolve(plan.root, safeRelative(path)));
79
+ for (const file of plan.files) {
80
+ const target = resolve(plan.root, safeRelative(file.path));
81
+ await assertNoSymlinks(target);
82
+ await ensureDirectory(dirname(target));
83
+ if (file.before === void 0) await writeFile(target, file.content, { flag: "wx" });
84
+ else {
85
+ if (await readFile(target, "utf8") !== file.before) throw new Error(`File changed since planning: ${file.path}`);
86
+ await replace(target, file.content);
87
+ }
88
+ applied.push(file);
89
+ }
90
+ return await after();
91
+ } catch (cause) {
92
+ const failures = [];
93
+ for (const file of applied.reverse()) try {
94
+ const target = resolve(plan.root, file.path);
95
+ await assertNoSymlinks(target);
96
+ if (await readFile(target, "utf8") !== file.content) throw new Error(`Rollback preserved a concurrently changed file: ${file.path}`);
97
+ if (file.before === void 0) await unlink(target);
98
+ else await replace(target, file.before);
99
+ } catch (error) {
100
+ failures.push(error);
101
+ }
102
+ for (const path of createdDirectories.reverse()) await rmdir(path).catch((error) => {
103
+ if (!["ENOTEMPTY", "ENOENT"].includes(error.code)) failures.push(error);
104
+ });
105
+ if (failures.length) throw new AggregateError([cause, ...failures], "Initialization failed; some files changed externally and were preserved. Inspect package.json and lockfiles before retrying.");
106
+ throw cause;
107
+ } finally {
108
+ await lock.close();
109
+ await unlink(lockPath);
110
+ }
111
+ }
112
+ /** Public plans describe changes without echoing secrets in existing file contents. */
113
+ function describePlan(plan) {
114
+ return {
115
+ root: plan.root,
116
+ files: plan.files.map((file) => ({
117
+ path: file.path,
118
+ action: file.before === void 0 ? "create" : "modify",
119
+ bytes: Buffer.byteLength(file.content)
120
+ })),
121
+ directories: plan.directories,
122
+ dependencies: plan.dependencies,
123
+ devDependencies: plan.devDependencies,
124
+ commands: plan.commands,
125
+ warnings: plan.warnings
126
+ };
127
+ }
128
+ export { addFile, describePlan, executeFiles, safeRelative };
129
+
130
+ //# sourceMappingURL=file-plan-D-Sj3yv0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-plan-D-Sj3yv0.js","names":[],"sources":["../src/filesystem/file-plan.ts"],"sourcesContent":["import { lstat, readFile, writeFile, mkdir, rename, unlink, rmdir, chmod } from \"node:fs/promises\";\nimport { resolve, relative, dirname, isAbsolute, join } from \"node:path\";\nimport { randomUUID } from \"node:crypto\";\nexport interface FileChange {\n path: string;\n content: string;\n before?: string;\n}\nexport interface FilePlan {\n root: string;\n files: FileChange[];\n directories: string[];\n warnings: string[];\n dependencies: Record<string, string>;\n devDependencies: Record<string, string>;\n commands: string[][];\n}\nexport function safeRelative(path: string): string {\n if (\n !path ||\n isAbsolute(path) ||\n path.includes(\"\\\\\") ||\n path.includes(\"\\0\") ||\n path.split(\"/\").some((p) => p === \"..\" || p === \".\" || !p) ||\n path.includes(\":\")\n )\n throw new Error(`Unsafe project path: ${path}`);\n return path;\n}\nexport async function assertNoSymlinks(path: string): Promise<void> {\n const absolute = resolve(path);\n let cursor = absolute;\n while (true) {\n try {\n if ((await lstat(cursor)).isSymbolicLink())\n throw new Error(`Symlinks are not allowed in managed paths: ${cursor}`);\n } catch (error) {\n if (!(error instanceof Error && \"code\" in error && error.code === \"ENOENT\")) throw error;\n }\n if (dirname(cursor) === cursor) break;\n cursor = dirname(cursor);\n }\n}\nexport async function addFile(\n plan: FilePlan,\n path: string,\n content: string,\n update = false,\n): Promise<void> {\n safeRelative(path);\n const target = resolve(plan.root, path);\n await assertNoSymlinks(target);\n let before: string | undefined;\n try {\n before = await readFile(target, \"utf8\");\n } catch (error) {\n if (!(error instanceof Error && \"code\" in error && error.code === \"ENOENT\")) throw error;\n }\n if (before === content) return;\n if (before !== undefined && !update) throw new Error(`Refusing to overwrite ${path}`);\n if (plan.files.some((f) => f.path === path)) throw new Error(`Duplicate planned file: ${path}`);\n plan.files.push({ path, content, ...(before === undefined ? {} : { before }) });\n}\nexport async function executeFiles<T>(plan: FilePlan, after: () => Promise<T>): Promise<T> {\n await assertNoSymlinks(plan.root);\n await mkdir(plan.root, { recursive: true });\n const lockPath = join(plan.root, \".duraxis-init.lock\");\n const lock = await import(\"node:fs/promises\").then((fs) => fs.open(lockPath, \"wx\"));\n const applied: FileChange[] = [];\n const createdDirectories: string[] = [];\n const ensureDirectory = async (path: string): Promise<void> => {\n if (path === plan.root) return;\n if (relative(plan.root, path).startsWith(\"..\")) throw new Error(\"Directory escapes project\");\n await assertNoSymlinks(path);\n try {\n const stat = await lstat(path);\n if (!stat.isDirectory()) throw new Error(\"Expected a directory\");\n return;\n } catch (error) {\n if (!(error instanceof Error && \"code\" in error && error.code === \"ENOENT\")) throw error;\n }\n await ensureDirectory(dirname(path));\n await mkdir(path);\n createdDirectories.push(path);\n };\n const replace = async (target: string, content: string) => {\n const temporary = `${target}.${randomUUID()}.tmp`;\n try {\n const mode = (await lstat(target)).mode & 0o777;\n await writeFile(temporary, content, { flag: \"wx\", mode });\n await chmod(temporary, mode);\n await rename(temporary, target);\n } finally {\n await unlink(temporary).catch((error) => {\n if (error.code !== \"ENOENT\") throw error;\n });\n }\n };\n try {\n for (const path of plan.directories)\n await ensureDirectory(resolve(plan.root, safeRelative(path)));\n for (const file of plan.files) {\n const target = resolve(plan.root, safeRelative(file.path));\n await assertNoSymlinks(target);\n await ensureDirectory(dirname(target));\n if (file.before === undefined) await writeFile(target, file.content, { flag: \"wx\" });\n else {\n if ((await readFile(target, \"utf8\")) !== file.before)\n throw new Error(`File changed since planning: ${file.path}`);\n await replace(target, file.content);\n }\n applied.push(file);\n }\n return await after();\n } catch (cause) {\n const failures: unknown[] = [];\n for (const file of applied.reverse())\n try {\n const target = resolve(plan.root, file.path);\n await assertNoSymlinks(target);\n if ((await readFile(target, \"utf8\")) !== file.content)\n throw new Error(`Rollback preserved a concurrently changed file: ${file.path}`);\n if (file.before === undefined) await unlink(target);\n else await replace(target, file.before);\n } catch (error) {\n failures.push(error);\n }\n for (const path of createdDirectories.reverse())\n await rmdir(path).catch((error) => {\n if (![\"ENOTEMPTY\", \"ENOENT\"].includes(error.code)) failures.push(error);\n });\n if (failures.length)\n throw new AggregateError(\n [cause, ...failures],\n \"Initialization failed; some files changed externally and were preserved. Inspect package.json and lockfiles before retrying.\",\n );\n throw cause;\n } finally {\n await lock.close();\n await unlink(lockPath);\n }\n}\n\n/** Public plans describe changes without echoing secrets in existing file contents. */\nexport function describePlan(plan: FilePlan) {\n return {\n root: plan.root,\n files: plan.files.map((file) => ({\n path: file.path,\n action: file.before === undefined ? \"create\" : \"modify\",\n bytes: Buffer.byteLength(file.content),\n })),\n directories: plan.directories,\n dependencies: plan.dependencies,\n devDependencies: plan.devDependencies,\n commands: plan.commands,\n warnings: plan.warnings,\n };\n}\n"],"mappings":";;;;AAiBA,SAAgB,aAAa,MAAsB;CACjD,IACE,CAAC,QACD,WAAW,IAAI,KACf,KAAK,SAAS,IAAI,KAClB,KAAK,SAAS,IAAI,KAClB,KAAK,MAAM,GAAG,CAAC,CAAC,MAAM,MAAM,MAAM,QAAQ,MAAM,OAAO,CAAC,CAAC,KACzD,KAAK,SAAS,GAAG,GAEjB,MAAM,IAAI,MAAM,wBAAwB,MAAM;CAChD,OAAO;AACT;AACA,eAAsB,iBAAiB,MAA6B;CAElE,IAAI,SADa,QAAQ,IACZ;CACb,OAAO,MAAM;EACX,IAAI;GACF,KAAK,MAAM,MAAM,MAAM,EAAA,CAAG,eAAe,GACvC,MAAM,IAAI,MAAM,8CAA8C,QAAQ;EAC1E,SAAS,OAAO;GACd,IAAI,EAAE,iBAAiB,SAAS,UAAU,SAAS,MAAM,SAAS,WAAW,MAAM;EACrF;EACA,IAAI,QAAQ,MAAM,MAAM,QAAQ;EACh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AS,QAAQ,KAAK,MAAM,KAAK,IAAI;GAC3C,MAAM,iBAAiB,MAAM;GAC7B,IAAK,MAAM,SAAS,QAAQ,MAAM,MAAO,KAAK,SAC5C,MAAM,IAAI,MAAM,mDAAmD,KAAK,MAAM;GAChF,IAAI,KAAK,WAAW,KAAA,GAAW,MAAM,OAAO,MAAM;QAC7C,MAAM,QAAQ,QAAQ,KAAK,MAAM;EACxC,SAAS,OAAO;GACd,SAAS,KAAK,KAAK;EACrB;EACF,KAAK,MAAM,QAAQ,mBAAmB,QAAQ,GAC5C,MAAM,MAAM,IAAI,CAAC,CAAC,OAAO,UAAU;GACjC,IAAI,CAAC,CAAC,aAAa,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI,GAAG,SAAS,KAAK,KAAK;EACxE,CAAC;EACH,IAAI,SAAS,QACX,MAAM,IAAI,eACR,CAAC,OAAO,GAAG,QAAQ,GACnB,8HACF;EACF,MAAM;CACR,UAAU;EACR,MAAM,KAAK,MAAM;EACjB,MAAM,OAAO,QAAQ;CACvB;AACF;;AAGA,SAAgB,aAAa,MAAgB;CAC3C,OAAO;EACL,MAAM,KAAK;EACX,OAAO,KAAK,MAAM,KAAK,UAAU;GAC/B,MAAM,KAAK;GACX,QAAQ,KAAK,WAAW,KAAA,IAAY,WAAW;GAC/C,OAAO,OAAO,WAAW,KAAK,OAAO;EACvC,EAAE;EACF,aAAa,KAAK;EAClB,cAAc,KAAK;EACnB,iBAAiB,KAAK;EACtB,UAAU,KAAK;EACf,UAAU,KAAK;CACjB;AACF"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { runCLI } from "./cli.js";
2
2
  export type { CLIIO } from "./cli.js";
3
- export { defineDuraxisConfig, loadConfig } from "./config.js";
3
+ export { loadConfig } from "./config.js";
4
4
  export type { DuraxisConfig, DuraxisConnectionConfig } from "./config.js";
5
5
  export { disposeTypeScriptLoader } from "./typescript-loader.js";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { i as loadConfig, n as defineDuraxisConfig, s as disposeTypeScriptLoader } from "./config-CjMUqEhV.js";
1
+ import { o as disposeTypeScriptLoader, r as loadConfig } from "./config-BKscNXeW.js";
2
2
  import { parseArgs } from "node:util";
3
3
  // src/registry/command-registry.ts
4
4
  var options = {
@@ -157,12 +157,12 @@ var commands = [
157
157
  options: ["evaluate"],
158
158
  configuration: "static"
159
159
  }),
160
- command("config:set", "CONFIGURATION", "Set a supported managed connection value", "admin", {
160
+ command("config:set", "CONFIGURATION", "Safely edit literal connection settings", "admin", {
161
161
  positional: ["key", "value"],
162
162
  options: ["dry-run"],
163
163
  configuration: "static"
164
164
  }),
165
- command("connection:add", "CONFIGURATION", "Add a managed named connection", "admin", {
165
+ command("connection:add", "CONFIGURATION", "Add a named connection to the central configuration", "admin", {
166
166
  positional: ["name"],
167
167
  options: initOptions,
168
168
  configuration: "static"
@@ -173,7 +173,7 @@ var commands = [
173
173
  options: ["live"],
174
174
  configuration: "static"
175
175
  }),
176
- command("generate:entity", "GENERATORS", "Generate an ORM entity and update a managed registry", "admin", {
176
+ command("generate:entity", "GENERATORS", "Generate an ORM entity discovered by file convention", "admin", {
177
177
  positional: ["name"],
178
178
  options: ["dry-run"],
179
179
  configuration: "static"
@@ -370,11 +370,11 @@ async function runCLI(args, io = {}) {
370
370
  }
371
371
  if (parsed.definition.handler === "migration") {
372
372
  migrationCommand = true;
373
- const code = await (await import("./migration.command-N7ahyx92.js")).executeMigration(parsed, context);
373
+ const code = await (await import("./migration.command-dhRbN4UI.js")).executeMigration(parsed, context);
374
374
  context.signal.throwIfAborted();
375
375
  return code;
376
376
  }
377
- const result = parsed.definition.handler === "init" ? await (await import("./init.command-B2kKoyfi.js")).initialize(parsed, context) : await (await import("./admin.command-Chb6x9mF.js")).administer(parsed, context);
377
+ const result = parsed.definition.handler === "init" ? await (await import("./init.command-DrO29773.js")).initialize(parsed, context) : await (await import("./admin.command-Dt5MnwJw.js")).administer(parsed, context);
378
378
  out(json ? JSON.stringify(result) : typeof result === "string" ? result : JSON.stringify(result, null, 2));
379
379
  return result && typeof result === "object" && "failed" in result && result.failed === true ? 1 : 0;
380
380
  } catch (cause) {
@@ -389,6 +389,6 @@ async function runCLI(args, io = {}) {
389
389
  process.removeListener("SIGINT", interrupt);
390
390
  }
391
391
  }
392
- export { defineDuraxisConfig, disposeTypeScriptLoader, loadConfig, runCLI };
392
+ export { disposeTypeScriptLoader, loadConfig, runCLI };
393
393
 
394
394
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/registry/command-registry.ts","../src/registry/argument-parser.ts","../src/cli.ts"],"sourcesContent":["export const options = {\n config: { type: \"string\" },\n database: { type: \"string\" },\n json: { type: \"boolean\" },\n help: { type: \"boolean\", short: \"h\" },\n version: { type: \"boolean\" },\n framework: { type: \"string\" },\n driver: { type: \"string\" },\n orm: { type: \"boolean\" },\n \"no-orm\": { type: \"boolean\" },\n migrations: { type: \"boolean\" },\n \"no-migrations\": { type: \"boolean\" },\n \"package-manager\": { type: \"string\" },\n language: { type: \"string\" },\n \"module-format\": { type: \"string\" },\n namespace: { type: \"string\" },\n directory: { type: \"string\" },\n \"source-dir\": { type: \"string\" },\n \"storage-directory\": { type: \"string\" },\n bucket: { type: \"string\" },\n prefix: { type: \"string\" },\n region: { type: \"string\" },\n endpoint: { type: \"string\" },\n \"force-path-style\": { type: \"boolean\" },\n \"schema-mode\": { type: \"string\" },\n example: { type: \"boolean\" },\n \"no-example\": { type: \"boolean\" },\n install: { type: \"boolean\" },\n \"no-install\": { type: \"boolean\" },\n \"dry-run\": { type: \"boolean\" },\n yes: { type: \"boolean\" },\n steps: { type: \"string\" },\n to: { type: \"string\" },\n \"allow-destructive\": { type: \"boolean\" },\n offline: { type: \"boolean\" },\n persisted: { type: \"boolean\" },\n schema: { type: \"string\" },\n live: { type: \"boolean\" },\n evaluate: { type: \"boolean\" },\n check: { type: \"boolean\" },\n apply: { type: \"boolean\" },\n registry: { type: \"string\" },\n prerelease: { type: \"boolean\" },\n \"custom-module\": { type: \"string\" },\n \"custom-export\": { type: \"string\" },\n \"custom-constructor\": { type: \"boolean\" },\n \"custom-options\": { type: \"string\" },\n \"max-stored-bytes\": { type: \"string\" },\n \"max-object-bytes\": { type: \"string\" },\n \"max-entries\": { type: \"string\" },\n \"max-metadata-bytes\": { type: \"string\" },\n \"max-journal-bytes\": { type: \"string\" },\n \"max-queued-operations\": { type: \"string\" },\n \"max-pending-operations\": { type: \"string\" },\n \"max-attempts\": { type: \"string\" },\n \"ownership-recovery\": { type: \"string\" },\n \"application-id\": { type: \"string\" },\n \"resources-file\": { type: \"string\" },\n \"cursor-key-env\": { type: \"string\" },\n} as const;\nexport type OptionName = keyof typeof options;\nexport interface CommandDefinition {\n readonly name: string;\n readonly aliases: readonly string[];\n readonly category: string;\n readonly description: string;\n readonly positional: readonly string[];\n readonly optionalPositionals?: boolean;\n readonly options: readonly OptionName[];\n readonly required: readonly OptionName[];\n readonly defaults: Readonly<Record<string, string | boolean>>;\n readonly exclusive: readonly (readonly OptionName[])[];\n readonly examples: readonly string[];\n readonly configuration: \"none\" | \"static\" | \"migration\";\n readonly database: boolean | \"conditional\";\n readonly interactive: boolean;\n readonly handler: \"init\" | \"admin\" | \"migration\" | \"help\" | \"version\";\n}\nconst initOptions: readonly OptionName[] = [\n \"framework\",\n \"driver\",\n \"orm\",\n \"no-orm\",\n \"migrations\",\n \"no-migrations\",\n \"package-manager\",\n \"language\",\n \"module-format\",\n \"namespace\",\n \"directory\",\n \"source-dir\",\n \"storage-directory\",\n \"bucket\",\n \"prefix\",\n \"region\",\n \"endpoint\",\n \"force-path-style\",\n \"schema-mode\",\n \"example\",\n \"no-example\",\n \"install\",\n \"no-install\",\n \"dry-run\",\n \"yes\",\n \"registry\",\n \"prerelease\",\n \"custom-module\",\n \"custom-export\",\n \"custom-constructor\",\n \"custom-options\",\n \"max-stored-bytes\",\n \"max-object-bytes\",\n \"max-entries\",\n \"max-metadata-bytes\",\n \"max-journal-bytes\",\n \"max-queued-operations\",\n \"max-pending-operations\",\n \"max-attempts\",\n \"resources-file\",\n \"cursor-key-env\",\n \"ownership-recovery\",\n \"application-id\",\n];\nfunction command(\n name: string,\n category: string,\n description: string,\n handler: CommandDefinition[\"handler\"],\n extra: Partial<CommandDefinition> = {},\n): CommandDefinition {\n return {\n name,\n category,\n description,\n handler,\n aliases: [],\n positional: [],\n options: [],\n required: [],\n defaults: {},\n exclusive: [],\n examples: [`duraxis ${name}`],\n configuration: \"none\",\n database: false,\n interactive: false,\n ...extra,\n };\n}\nexport const commands: readonly CommandDefinition[] = [\n command(\"init\", \"SETUP\", \"Initialize and configure Duraxis\", \"init\", {\n options: initOptions,\n interactive: true,\n defaults: {\n driver: \"disk\",\n framework: \"auto\",\n language: \"auto\",\n \"module-format\": \"auto\",\n namespace: \"default\",\n install: true,\n },\n exclusive: [\n [\"orm\", \"no-orm\"],\n [\"migrations\", \"no-migrations\"],\n [\"install\", \"no-install\"],\n [\"example\", \"no-example\"],\n ],\n examples: [\n \"duraxis init --driver disk --migrations --yes\",\n \"duraxis init --driver memory --no-orm --no-install --yes\",\n ],\n }),\n command(\n \"doctor\",\n \"SETUP\",\n \"Diagnose project and environment without executing configuration\",\n \"admin\",\n ),\n command(\n \"config:show\",\n \"CONFIGURATION\",\n \"Show redacted static configuration (or trusted code with --evaluate)\",\n \"admin\",\n { options: [\"evaluate\"], configuration: \"static\" },\n ),\n command(\n \"config:validate\",\n \"CONFIGURATION\",\n \"Validate configuration without opening storage\",\n \"admin\",\n { options: [\"evaluate\"], configuration: \"static\" },\n ),\n command(\"config:set\", \"CONFIGURATION\", \"Set a supported managed connection value\", \"admin\", {\n positional: [\"key\", \"value\"],\n options: [\"dry-run\"],\n configuration: \"static\",\n }),\n command(\"connection:add\", \"CONFIGURATION\", \"Add a managed named connection\", \"admin\", {\n positional: [\"name\"],\n options: initOptions,\n configuration: \"static\",\n }),\n command(\n \"connection:list\",\n \"CONFIGURATION\",\n \"List connections without opening databases\",\n \"admin\",\n { configuration: \"static\" },\n ),\n command(\"storage:list\", \"STORAGE\", \"List official drivers and operational limits\", \"admin\"),\n command(\n \"storage:check\",\n \"STORAGE\",\n \"Check configuration; --live opens storage read-only\",\n \"admin\",\n { options: [\"live\"], configuration: \"static\" },\n ),\n command(\n \"generate:entity\",\n \"GENERATORS\",\n \"Generate an ORM entity and update a managed registry\",\n \"admin\",\n { positional: [\"name\"], options: [\"dry-run\"], configuration: \"static\" },\n ),\n command(\"generate:module\", \"GENERATORS\", \"Generate a NestJS feature module\", \"admin\", {\n positional: [\"name\"],\n options: [\"dry-run\"],\n configuration: \"static\",\n }),\n ...(\n [\n [\"migration:create\", \"Create a manual migration\", [\"name\"], []],\n [\"migration:generate\", \"Generate a schema migration\", [\"name\"], [\"allow-destructive\"]],\n [\"migration:snapshot\", \"Save expected schema snapshot\", [], [\"schema\"]],\n [\"migration:remove\", \"Remove latest unpublished migration\", [], [\"yes\"]],\n [\"migration:baseline\", \"Adopt existing schema\", [\"name\"], [\"yes\"]],\n [\n \"migrate:up\",\n \"Apply pending migrations\",\n [],\n [\"steps\", \"to\", \"dry-run\", \"allow-destructive\"],\n ],\n [\"migrate:down\", \"Roll back migrations (target retained)\", [], [\"steps\", \"to\", \"yes\"]],\n [\"migrate:status\", \"Display migration history\", [], []],\n [\"migrate:diff\", \"Compare schemas\", [], [\"persisted\"]],\n [\"migrate:check\", \"Validate migration integrity\", [], [\"offline\"]],\n ] satisfies [string, string, string[], OptionName[]][]\n ).map(([name, description, positional, supported]) =>\n command(name, \"MIGRATIONS\", description, \"migration\", {\n positional,\n options: supported,\n configuration: \"migration\",\n required:\n name === \"migration:snapshot\"\n ? [\"schema\"]\n : [\"migration:remove\", \"migration:baseline\", \"migrate:down\"].includes(name)\n ? [\"yes\"]\n : [],\n database: name.startsWith(\"migrate:\")\n ? \"conditional\"\n : [\"migration:baseline\", \"migration:remove\"].includes(name),\n exclusive: [[\"steps\", \"to\"]],\n }),\n ),\n command(\n \"upgrade\",\n \"DEPENDENCIES\",\n \"Check or explicitly apply compatible published updates\",\n \"admin\",\n {\n options: [\"check\", \"apply\", \"package-manager\", \"registry\", \"prerelease\"],\n exclusive: [[\"check\", \"apply\"]],\n defaults: { check: true },\n },\n ),\n command(\"help\", \"INFORMATION\", \"Display command documentation\", \"help\", {\n positional: [\"command\"],\n optionalPositionals: true,\n }),\n command(\"version\", \"INFORMATION\", \"Display the CLI version\", \"version\", {\n aliases: [\"--version\"],\n }),\n];\nexport function findCommand(name: string): CommandDefinition {\n const found = commands.find((c) => c.name === name || c.aliases.includes(name));\n if (!found) throw new Error(`Unknown command: ${name}. Run duraxis help.`);\n return found;\n}\nexport function helpText(definition?: CommandDefinition): string {\n if (!definition)\n return `Duraxis CLI\\n\\nUsage: duraxis <command> [options]\\n\\n${[\n ...new Set(commands.map((c) => c.category)),\n ]\n .map(\n (category) =>\n `${category}\\n${commands\n .filter((c) => c.category === category)\n .map((c) => ` ${c.name.padEnd(22)} ${c.description}`)\n .join(\"\\n\")}`,\n )\n .join(\n \"\\n\\n\",\n )}\\n\\nExamples:\\n duraxis init\\n duraxis doctor\\n duraxis help init\\n duraxis migrate:status\\n duraxis upgrade --check\\n`;\n const supportedOptions: readonly OptionName[] = [\n \"config\",\n \"database\",\n \"json\",\n \"help\",\n ...definition.options,\n ];\n return `${definition.description}\\n\\nUsage: duraxis ${definition.name} ${definition.positional.map((p) => `<${p}>`).join(\" \")} [options]\\n\\n${supportedOptions.map((name) => ` --${name}${options[name].type === \"string\" ? \" <value>\" : \"\"}${definition.defaults[name] !== undefined ? ` (default: ${definition.defaults[name]})` : \"\"}${definition.required.includes(name) ? \" (required)\" : \"\"}`).join(\"\\n\")}\\n\\nConfiguration: ${definition.configuration}; database access: ${definition.database === \"conditional\" ? \"depends on command flags\" : definition.database ? \"required\" : \"not required by default\"}.\\n${definition.exclusive.map((group) => `Mutually exclusive: ${group.map((n) => `--${n}`).join(\", \")}`).join(\"\\n\")}\\n${definition.name === \"storage:check\" ? \"Live Disk checks may acquire exclusive directory ownership. No test objects are written.\" : \"\"}\\nExamples:\\n${definition.examples.map((e) => ` ${e}`).join(\"\\n\")}`;\n}\n","import { parseArgs } from \"node:util\";\nimport { options, findCommand } from \"./command-registry.js\";\nexport function parseCommand(args: readonly string[]) {\n const parsed = parseArgs({ args: [...args], options, allowPositionals: true, strict: true });\n const name = parsed.values.version ? \"version\" : (parsed.positionals[0] ?? \"help\");\n const definition = findCommand(name);\n const positionals = parsed.positionals.slice(parsed.positionals[0] ? 1 : 0);\n if (positionals.length > definition.positional.length)\n throw new Error(\"Unexpected positional arguments\");\n for (const option of Object.keys(parsed.values))\n if (![\"config\", \"database\", \"json\", \"help\", \"version\", ...definition.options].includes(option))\n throw new Error(`Option --${option} is not supported by ${name}`);\n if (!parsed.values.help) {\n if (!definition.optionalPositionals && positionals.length < definition.positional.length)\n throw new Error(`Missing positional arguments: ${definition.positional.join(\", \")}`);\n for (const group of definition.exclusive)\n if (group.filter((n) => parsed.values[n] !== undefined).length > 1)\n throw new Error(`Mutually exclusive options: ${group.map((n) => `--${n}`).join(\", \")}`);\n for (const option of definition.required)\n if (parsed.values[option] === undefined) throw new Error(`Missing required --${option}`);\n }\n return { ...parsed, definition, positionals };\n}\nexport type ParsedCommand = ReturnType<typeof parseCommand>;\n","import { parseCommand } from \"./registry/argument-parser.js\";\nimport { helpText, findCommand } from \"./registry/command-registry.js\";\nimport type { ProcessRunner } from \"./dependencies/package-manager.js\";\nimport type { Prompt } from \"./terminal/prompts.js\";\nexport interface CLIIO {\n readonly cwd?: string;\n readonly out?: (message: string) => void;\n readonly error?: (message: string) => void;\n readonly fetch?: typeof fetch;\n readonly runProcess?: ProcessRunner;\n readonly prompt?: Prompt;\n readonly interactive?: boolean;\n readonly signal?: AbortSignal;\n}\nexport async function runCLI(args: readonly string[], io: CLIIO = {}): Promise<number> {\n const out = io.out ?? console.log;\n const error = io.error ?? console.error;\n let json = args.includes(\"--json\");\n let migrationCommand = false;\n const controller = new AbortController();\n const interrupt = () => controller.abort(new Error(\"Operation cancelled\"));\n process.once(\"SIGINT\", interrupt);\n const context = {\n ...io,\n signal: io.signal ? AbortSignal.any([io.signal, controller.signal]) : controller.signal,\n };\n try {\n const parsed = parseCommand(args);\n json = parsed.values.json ?? false;\n if (parsed.values.help || parsed.definition.handler === \"help\") {\n const target =\n parsed.definition.handler === \"help\" && parsed.positionals[0]\n ? findCommand(parsed.positionals[0])\n : parsed.definition.handler === \"help\"\n ? undefined\n : parsed.definition;\n out(json ? JSON.stringify({ help: helpText(target) }) : helpText(target));\n return 0;\n }\n if (parsed.definition.handler === \"version\") {\n const { readFile } = await import(\"node:fs/promises\");\n const { dirname, join } = await import(\"node:path\");\n let root = import.meta.dirname;\n while (true) {\n try {\n const manifest: unknown = JSON.parse(await readFile(join(root, \"package.json\"), \"utf8\"));\n if (\n manifest &&\n typeof manifest === \"object\" &&\n \"name\" in manifest &&\n manifest.name === \"@duraxis/cli\" &&\n \"version\" in manifest\n ) {\n out(json ? JSON.stringify({ version: manifest.version }) : String(manifest.version));\n return 0;\n }\n } catch (cause) {\n if (!(cause instanceof Error && \"code\" in cause && cause.code === \"ENOENT\")) throw cause;\n }\n if (dirname(root) === root) throw new Error(\"CLI package version unavailable\");\n root = dirname(root);\n }\n }\n if (parsed.definition.handler === \"migration\") {\n migrationCommand = true;\n const code = await (\n await import(\"./commands/migration.command.js\")\n ).executeMigration(parsed, context);\n context.signal.throwIfAborted();\n return code;\n }\n const result =\n parsed.definition.handler === \"init\"\n ? await (await import(\"./commands/init.command.js\")).initialize(parsed, context)\n : await (await import(\"./commands/admin.command.js\")).administer(parsed, context);\n out(\n json\n ? JSON.stringify(result)\n : typeof result === \"string\"\n ? result\n : JSON.stringify(result, null, 2),\n );\n return result && typeof result === \"object\" && \"failed\" in result && result.failed === true\n ? 1\n : 0;\n } catch (cause) {\n const cleanupFailed = cause instanceof Error && cause.name === \"DuraxisMigrationCleanupError\";\n const message = cleanupFailed\n ? \"Migration database cleanup failed; inspect storage health and migration status before retrying\"\n : context.signal.aborted\n ? migrationCommand\n ? \"Migration operation cancelled. Inspect local artifacts and migrate:status before retrying; publication may have completed.\"\n : \"Operation cancelled\"\n : cause instanceof Error\n ? cause.message\n : \"Command failed\";\n error(\n json\n ? JSON.stringify({\n error: {\n code: cleanupFailed\n ? \"CLEANUP_FAILED\"\n : context.signal.aborted\n ? \"CANCELLED\"\n : \"COMMAND_FAILED\",\n message,\n },\n })\n : message,\n );\n return 1;\n } finally {\n process.removeListener(\"SIGINT\", interrupt);\n }\n}\n"],"mappings":";;;AAAA,IAAa,UAAU;CACrB,QAAQ,EAAE,MAAM,SAAS;CACzB,UAAU,EAAE,MAAM,SAAS;CAC3B,MAAM,EAAE,MAAM,UAAU;CACxB,MAAM;EAAE,MAAM;EAAW,OAAO;CAAI;CACpC,SAAS,EAAE,MAAM,UAAU;CAC3B,WAAW,EAAE,MAAM,SAAS;CAC5B,QAAQ,EAAE,MAAM,SAAS;CACzB,KAAK,EAAE,MAAM,UAAU;CACvB,UAAU,EAAE,MAAM,UAAU;CAC5B,YAAY,EAAE,MAAM,UAAU;CAC9B,iBAAiB,EAAE,MAAM,UAAU;CACnC,mBAAmB,EAAE,MAAM,SAAS;CACpC,UAAU,EAAE,MAAM,SAAS;CAC3B,iBAAiB,EAAE,MAAM,SAAS;CAClC,WAAW,EAAE,MAAM,SAAS;CAC5B,WAAW,EAAE,MAAM,SAAS;CAC5B,cAAc,EAAE,MAAM,SAAS;CAC/B,qBAAqB,EAAE,MAAM,SAAS;CACtC,QAAQ,EAAE,MAAM,SAAS;CACzB,QAAQ,EAAE,MAAM,SAAS;CACzB,QAAQ,EAAE,MAAM,SAAS;CACzB,UAAU,EAAE,MAAM,SAAS;CAC3B,oBAAoB,EAAE,MAAM,UAAU;CACtC,eAAe,EAAE,MAAM,SAAS;CAChC,SAAS,EAAE,MAAM,UAAU;CAC3B,cAAc,EAAE,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["../src/registry/command-registry.ts","../src/registry/argument-parser.ts","../src/cli.ts"],"sourcesContent":["export const options = {\n config: { type: \"string\" },\n database: { type: \"string\" },\n json: { type: \"boolean\" },\n help: { type: \"boolean\", short: \"h\" },\n version: { type: \"boolean\" },\n framework: { type: \"string\" },\n driver: { type: \"string\" },\n orm: { type: \"boolean\" },\n \"no-orm\": { type: \"boolean\" },\n migrations: { type: \"boolean\" },\n \"no-migrations\": { type: \"boolean\" },\n \"package-manager\": { type: \"string\" },\n language: { type: \"string\" },\n \"module-format\": { type: \"string\" },\n namespace: { type: \"string\" },\n directory: { type: \"string\" },\n \"source-dir\": { type: \"string\" },\n \"storage-directory\": { type: \"string\" },\n bucket: { type: \"string\" },\n prefix: { type: \"string\" },\n region: { type: \"string\" },\n endpoint: { type: \"string\" },\n \"force-path-style\": { type: \"boolean\" },\n \"schema-mode\": { type: \"string\" },\n example: { type: \"boolean\" },\n \"no-example\": { type: \"boolean\" },\n install: { type: \"boolean\" },\n \"no-install\": { type: \"boolean\" },\n \"dry-run\": { type: \"boolean\" },\n yes: { type: \"boolean\" },\n steps: { type: \"string\" },\n to: { type: \"string\" },\n \"allow-destructive\": { type: \"boolean\" },\n offline: { type: \"boolean\" },\n persisted: { type: \"boolean\" },\n schema: { type: \"string\" },\n live: { type: \"boolean\" },\n evaluate: { type: \"boolean\" },\n check: { type: \"boolean\" },\n apply: { type: \"boolean\" },\n registry: { type: \"string\" },\n prerelease: { type: \"boolean\" },\n \"custom-module\": { type: \"string\" },\n \"custom-export\": { type: \"string\" },\n \"custom-constructor\": { type: \"boolean\" },\n \"custom-options\": { type: \"string\" },\n \"max-stored-bytes\": { type: \"string\" },\n \"max-object-bytes\": { type: \"string\" },\n \"max-entries\": { type: \"string\" },\n \"max-metadata-bytes\": { type: \"string\" },\n \"max-journal-bytes\": { type: \"string\" },\n \"max-queued-operations\": { type: \"string\" },\n \"max-pending-operations\": { type: \"string\" },\n \"max-attempts\": { type: \"string\" },\n \"ownership-recovery\": { type: \"string\" },\n \"application-id\": { type: \"string\" },\n \"resources-file\": { type: \"string\" },\n \"cursor-key-env\": { type: \"string\" },\n} as const;\nexport type OptionName = keyof typeof options;\nexport interface CommandDefinition {\n readonly name: string;\n readonly aliases: readonly string[];\n readonly category: string;\n readonly description: string;\n readonly positional: readonly string[];\n readonly optionalPositionals?: boolean;\n readonly options: readonly OptionName[];\n readonly required: readonly OptionName[];\n readonly defaults: Readonly<Record<string, string | boolean>>;\n readonly exclusive: readonly (readonly OptionName[])[];\n readonly examples: readonly string[];\n readonly configuration: \"none\" | \"static\" | \"migration\";\n readonly database: boolean | \"conditional\";\n readonly interactive: boolean;\n readonly handler: \"init\" | \"admin\" | \"migration\" | \"help\" | \"version\";\n}\nconst initOptions: readonly OptionName[] = [\n \"framework\",\n \"driver\",\n \"orm\",\n \"no-orm\",\n \"migrations\",\n \"no-migrations\",\n \"package-manager\",\n \"language\",\n \"module-format\",\n \"namespace\",\n \"directory\",\n \"source-dir\",\n \"storage-directory\",\n \"bucket\",\n \"prefix\",\n \"region\",\n \"endpoint\",\n \"force-path-style\",\n \"schema-mode\",\n \"example\",\n \"no-example\",\n \"install\",\n \"no-install\",\n \"dry-run\",\n \"yes\",\n \"registry\",\n \"prerelease\",\n \"custom-module\",\n \"custom-export\",\n \"custom-constructor\",\n \"custom-options\",\n \"max-stored-bytes\",\n \"max-object-bytes\",\n \"max-entries\",\n \"max-metadata-bytes\",\n \"max-journal-bytes\",\n \"max-queued-operations\",\n \"max-pending-operations\",\n \"max-attempts\",\n \"resources-file\",\n \"cursor-key-env\",\n \"ownership-recovery\",\n \"application-id\",\n];\nfunction command(\n name: string,\n category: string,\n description: string,\n handler: CommandDefinition[\"handler\"],\n extra: Partial<CommandDefinition> = {},\n): CommandDefinition {\n return {\n name,\n category,\n description,\n handler,\n aliases: [],\n positional: [],\n options: [],\n required: [],\n defaults: {},\n exclusive: [],\n examples: [`duraxis ${name}`],\n configuration: \"none\",\n database: false,\n interactive: false,\n ...extra,\n };\n}\nexport const commands: readonly CommandDefinition[] = [\n command(\"init\", \"SETUP\", \"Initialize and configure Duraxis\", \"init\", {\n options: initOptions,\n interactive: true,\n defaults: {\n driver: \"disk\",\n framework: \"auto\",\n language: \"auto\",\n \"module-format\": \"auto\",\n namespace: \"default\",\n install: true,\n },\n exclusive: [\n [\"orm\", \"no-orm\"],\n [\"migrations\", \"no-migrations\"],\n [\"install\", \"no-install\"],\n [\"example\", \"no-example\"],\n ],\n examples: [\n \"duraxis init --driver disk --migrations --yes\",\n \"duraxis init --driver memory --no-orm --no-install --yes\",\n ],\n }),\n command(\n \"doctor\",\n \"SETUP\",\n \"Diagnose project and environment without executing configuration\",\n \"admin\",\n ),\n command(\n \"config:show\",\n \"CONFIGURATION\",\n \"Show redacted static configuration (or trusted code with --evaluate)\",\n \"admin\",\n { options: [\"evaluate\"], configuration: \"static\" },\n ),\n command(\n \"config:validate\",\n \"CONFIGURATION\",\n \"Validate configuration without opening storage\",\n \"admin\",\n { options: [\"evaluate\"], configuration: \"static\" },\n ),\n command(\"config:set\", \"CONFIGURATION\", \"Safely edit literal connection settings\", \"admin\", {\n positional: [\"key\", \"value\"],\n options: [\"dry-run\"],\n configuration: \"static\",\n }),\n command(\n \"connection:add\",\n \"CONFIGURATION\",\n \"Add a named connection to the central configuration\",\n \"admin\",\n {\n positional: [\"name\"],\n options: initOptions,\n configuration: \"static\",\n },\n ),\n command(\n \"connection:list\",\n \"CONFIGURATION\",\n \"List connections without opening databases\",\n \"admin\",\n { configuration: \"static\" },\n ),\n command(\"storage:list\", \"STORAGE\", \"List official drivers and operational limits\", \"admin\"),\n command(\n \"storage:check\",\n \"STORAGE\",\n \"Check configuration; --live opens storage read-only\",\n \"admin\",\n { options: [\"live\"], configuration: \"static\" },\n ),\n command(\n \"generate:entity\",\n \"GENERATORS\",\n \"Generate an ORM entity discovered by file convention\",\n \"admin\",\n { positional: [\"name\"], options: [\"dry-run\"], configuration: \"static\" },\n ),\n command(\"generate:module\", \"GENERATORS\", \"Generate a NestJS feature module\", \"admin\", {\n positional: [\"name\"],\n options: [\"dry-run\"],\n configuration: \"static\",\n }),\n ...(\n [\n [\"migration:create\", \"Create a manual migration\", [\"name\"], []],\n [\"migration:generate\", \"Generate a schema migration\", [\"name\"], [\"allow-destructive\"]],\n [\"migration:snapshot\", \"Save expected schema snapshot\", [], [\"schema\"]],\n [\"migration:remove\", \"Remove latest unpublished migration\", [], [\"yes\"]],\n [\"migration:baseline\", \"Adopt existing schema\", [\"name\"], [\"yes\"]],\n [\n \"migrate:up\",\n \"Apply pending migrations\",\n [],\n [\"steps\", \"to\", \"dry-run\", \"allow-destructive\"],\n ],\n [\"migrate:down\", \"Roll back migrations (target retained)\", [], [\"steps\", \"to\", \"yes\"]],\n [\"migrate:status\", \"Display migration history\", [], []],\n [\"migrate:diff\", \"Compare schemas\", [], [\"persisted\"]],\n [\"migrate:check\", \"Validate migration integrity\", [], [\"offline\"]],\n ] satisfies [string, string, string[], OptionName[]][]\n ).map(([name, description, positional, supported]) =>\n command(name, \"MIGRATIONS\", description, \"migration\", {\n positional,\n options: supported,\n configuration: \"migration\",\n required:\n name === \"migration:snapshot\"\n ? [\"schema\"]\n : [\"migration:remove\", \"migration:baseline\", \"migrate:down\"].includes(name)\n ? [\"yes\"]\n : [],\n database: name.startsWith(\"migrate:\")\n ? \"conditional\"\n : [\"migration:baseline\", \"migration:remove\"].includes(name),\n exclusive: [[\"steps\", \"to\"]],\n }),\n ),\n command(\n \"upgrade\",\n \"DEPENDENCIES\",\n \"Check or explicitly apply compatible published updates\",\n \"admin\",\n {\n options: [\"check\", \"apply\", \"package-manager\", \"registry\", \"prerelease\"],\n exclusive: [[\"check\", \"apply\"]],\n defaults: { check: true },\n },\n ),\n command(\"help\", \"INFORMATION\", \"Display command documentation\", \"help\", {\n positional: [\"command\"],\n optionalPositionals: true,\n }),\n command(\"version\", \"INFORMATION\", \"Display the CLI version\", \"version\", {\n aliases: [\"--version\"],\n }),\n];\nexport function findCommand(name: string): CommandDefinition {\n const found = commands.find((c) => c.name === name || c.aliases.includes(name));\n if (!found) throw new Error(`Unknown command: ${name}. Run duraxis help.`);\n return found;\n}\nexport function helpText(definition?: CommandDefinition): string {\n if (!definition)\n return `Duraxis CLI\\n\\nUsage: duraxis <command> [options]\\n\\n${[\n ...new Set(commands.map((c) => c.category)),\n ]\n .map(\n (category) =>\n `${category}\\n${commands\n .filter((c) => c.category === category)\n .map((c) => ` ${c.name.padEnd(22)} ${c.description}`)\n .join(\"\\n\")}`,\n )\n .join(\n \"\\n\\n\",\n )}\\n\\nExamples:\\n duraxis init\\n duraxis doctor\\n duraxis help init\\n duraxis migrate:status\\n duraxis upgrade --check\\n`;\n const supportedOptions: readonly OptionName[] = [\n \"config\",\n \"database\",\n \"json\",\n \"help\",\n ...definition.options,\n ];\n return `${definition.description}\\n\\nUsage: duraxis ${definition.name} ${definition.positional.map((p) => `<${p}>`).join(\" \")} [options]\\n\\n${supportedOptions.map((name) => ` --${name}${options[name].type === \"string\" ? \" <value>\" : \"\"}${definition.defaults[name] !== undefined ? ` (default: ${definition.defaults[name]})` : \"\"}${definition.required.includes(name) ? \" (required)\" : \"\"}`).join(\"\\n\")}\\n\\nConfiguration: ${definition.configuration}; database access: ${definition.database === \"conditional\" ? \"depends on command flags\" : definition.database ? \"required\" : \"not required by default\"}.\\n${definition.exclusive.map((group) => `Mutually exclusive: ${group.map((n) => `--${n}`).join(\", \")}`).join(\"\\n\")}\\n${definition.name === \"storage:check\" ? \"Live Disk checks may acquire exclusive directory ownership. No test objects are written.\" : \"\"}\\nExamples:\\n${definition.examples.map((e) => ` ${e}`).join(\"\\n\")}`;\n}\n","import { parseArgs } from \"node:util\";\nimport { options, findCommand } from \"./command-registry.js\";\nexport function parseCommand(args: readonly string[]) {\n const parsed = parseArgs({ args: [...args], options, allowPositionals: true, strict: true });\n const name = parsed.values.version ? \"version\" : (parsed.positionals[0] ?? \"help\");\n const definition = findCommand(name);\n const positionals = parsed.positionals.slice(parsed.positionals[0] ? 1 : 0);\n if (positionals.length > definition.positional.length)\n throw new Error(\"Unexpected positional arguments\");\n for (const option of Object.keys(parsed.values))\n if (![\"config\", \"database\", \"json\", \"help\", \"version\", ...definition.options].includes(option))\n throw new Error(`Option --${option} is not supported by ${name}`);\n if (!parsed.values.help) {\n if (!definition.optionalPositionals && positionals.length < definition.positional.length)\n throw new Error(`Missing positional arguments: ${definition.positional.join(\", \")}`);\n for (const group of definition.exclusive)\n if (group.filter((n) => parsed.values[n] !== undefined).length > 1)\n throw new Error(`Mutually exclusive options: ${group.map((n) => `--${n}`).join(\", \")}`);\n for (const option of definition.required)\n if (parsed.values[option] === undefined) throw new Error(`Missing required --${option}`);\n }\n return { ...parsed, definition, positionals };\n}\nexport type ParsedCommand = ReturnType<typeof parseCommand>;\n","import { parseCommand } from \"./registry/argument-parser.js\";\nimport { helpText, findCommand } from \"./registry/command-registry.js\";\nimport type { ProcessRunner } from \"./dependencies/package-manager.js\";\nimport type { Prompt } from \"./terminal/prompts.js\";\nexport interface CLIIO {\n readonly cwd?: string;\n readonly out?: (message: string) => void;\n readonly error?: (message: string) => void;\n readonly fetch?: typeof fetch;\n readonly runProcess?: ProcessRunner;\n readonly prompt?: Prompt;\n readonly interactive?: boolean;\n readonly signal?: AbortSignal;\n}\nexport async function runCLI(args: readonly string[], io: CLIIO = {}): Promise<number> {\n const out = io.out ?? console.log;\n const error = io.error ?? console.error;\n let json = args.includes(\"--json\");\n let migrationCommand = false;\n const controller = new AbortController();\n const interrupt = () => controller.abort(new Error(\"Operation cancelled\"));\n process.once(\"SIGINT\", interrupt);\n const context = {\n ...io,\n signal: io.signal ? AbortSignal.any([io.signal, controller.signal]) : controller.signal,\n };\n try {\n const parsed = parseCommand(args);\n json = parsed.values.json ?? false;\n if (parsed.values.help || parsed.definition.handler === \"help\") {\n const target =\n parsed.definition.handler === \"help\" && parsed.positionals[0]\n ? findCommand(parsed.positionals[0])\n : parsed.definition.handler === \"help\"\n ? undefined\n : parsed.definition;\n out(json ? JSON.stringify({ help: helpText(target) }) : helpText(target));\n return 0;\n }\n if (parsed.definition.handler === \"version\") {\n const { readFile } = await import(\"node:fs/promises\");\n const { dirname, join } = await import(\"node:path\");\n let root = import.meta.dirname;\n while (true) {\n try {\n const manifest: unknown = JSON.parse(await readFile(join(root, \"package.json\"), \"utf8\"));\n if (\n manifest &&\n typeof manifest === \"object\" &&\n \"name\" in manifest &&\n manifest.name === \"@duraxis/cli\" &&\n \"version\" in manifest\n ) {\n out(json ? JSON.stringify({ version: manifest.version }) : String(manifest.version));\n return 0;\n }\n } catch (cause) {\n if (!(cause instanceof Error && \"code\" in cause && cause.code === \"ENOENT\")) throw cause;\n }\n if (dirname(root) === root) throw new Error(\"CLI package version unavailable\");\n root = dirname(root);\n }\n }\n if (parsed.definition.handler === \"migration\") {\n migrationCommand = true;\n const code = await (\n await import(\"./commands/migration.command.js\")\n ).executeMigration(parsed, context);\n context.signal.throwIfAborted();\n return code;\n }\n const result =\n parsed.definition.handler === \"init\"\n ? await (await import(\"./commands/init.command.js\")).initialize(parsed, context)\n : await (await import(\"./commands/admin.command.js\")).administer(parsed, context);\n out(\n json\n ? JSON.stringify(result)\n : typeof result === \"string\"\n ? result\n : JSON.stringify(result, null, 2),\n );\n return result && typeof result === \"object\" && \"failed\" in result && result.failed === true\n ? 1\n : 0;\n } catch (cause) {\n const cleanupFailed = cause instanceof Error && cause.name === \"DuraxisMigrationCleanupError\";\n const message = cleanupFailed\n ? \"Migration database cleanup failed; inspect storage health and migration status before retrying\"\n : context.signal.aborted\n ? migrationCommand\n ? \"Migration operation cancelled. Inspect local artifacts and migrate:status before retrying; publication may have completed.\"\n : \"Operation cancelled\"\n : cause instanceof Error\n ? cause.message\n : \"Command failed\";\n error(\n json\n ? JSON.stringify({\n error: {\n code: cleanupFailed\n ? \"CLEANUP_FAILED\"\n : context.signal.aborted\n ? \"CANCELLED\"\n : \"COMMAND_FAILED\",\n message,\n },\n })\n : message,\n );\n return 1;\n } finally {\n process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;GACrB;EACF;EACA,IAAI,OAAO,WAAW,YAAY,aAAa;GAC7C,mBAAmB;GACnB,MAAM,OAAO,OACX,MAAM,OAAO,mCAAA,CACb,iBAAiB,QAAQ,OAAO;GAClC,QAAQ,OAAO,eAAe;GAC9B,OAAO;EACT;EACA,MAAM,SACJ,OAAO,WAAW,YAAY,SAC1B,OAAO,MAAM,OAAO,8BAAA,CAA+B,WAAW,QAAQ,OAAO,IAC7E,OAAO,MAAM,OAAO,+BAAA,CAAgC,WAAW,QAAQ,OAAO;EACpF,IACE,OACI,KAAK,UAAU,MAAM,IACrB,OAAO,WAAW,WAChB,SACA,KAAK,UAAU,QAAQ,MAAM,CAAC,CACtC;EACA,OAAO,UAAU,OAAO,WAAW,YAAY,YAAY,UAAU,OAAO,WAAW,OACnF,IACA;CACN,SAAS,OAAO;EACd,MAAM,gBAAgB,iBAAiB,SAAS,MAAM,SAAS;EAC/D,MAAM,UAAU,gBACZ,mGACA,QAAQ,OAAO,UACb,mBACE,+HACA,wBACF,iBAAiB,QACf,MAAM,UACN;EACR,MACE,OACI,KAAK,UAAU,EACb,OAAO;GACL,MAAM,gBACF,mBACA,QAAQ,OAAO,UACb,cACA;GACN;EACF,EACF,CAAC,IACD,OACN;EACA,OAAO;CACT,UAAU;EACR,QAAQ,eAAe,UAAU,SAAS;CAC5C;AACF"}
@@ -1,7 +1,10 @@
1
1
  import { type FilePlan } from "../filesystem/file-plan.js";
2
2
  import { type ProjectContext } from "./project-detector.js";
3
3
  import type { InitializationOptions } from "./initialization-options.js";
4
- import type { ManagedProject } from "./managed-project.js";
4
+ export interface ProjectConfiguration {
5
+ defaultConnection: string;
6
+ connections: Record<string, InitializationOptions>;
7
+ }
5
8
  export declare function requiredPackages(options: InitializationOptions): string[];
6
- export declare function configSource(managed: ManagedProject): string;
7
- export declare function planInitialization(context: ProjectContext, options: InitializationOptions, dependencies: Record<string, string>, devDependencies: Record<string, string>, existing?: ManagedProject, name?: string): Promise<FilePlan>;
9
+ export { configurationSource as configSource } from "../templates/project.js";
10
+ export declare function planInitialization(context: ProjectContext, options: InitializationOptions, dependencies: Record<string, string>, devDependencies: Record<string, string>, name?: string): Promise<FilePlan>;
@@ -0,0 +1,2 @@
1
+ /** Surgical AST-guided edits preserve every unrelated byte, including comments. */
2
+ export declare function integrateNestModule(source: string, path: string, configPath: string): string;
@@ -0,0 +1,16 @@
1
+ import ts from "typescript";
2
+ export interface StaticConfig {
3
+ ast: ts.SourceFile;
4
+ object: ts.ObjectLiteralExpression;
5
+ connections: Map<string, ts.ObjectLiteralExpression>;
6
+ defaultConnection: string;
7
+ value: unknown;
8
+ }
9
+ export declare function property(object: ts.ObjectLiteralExpression, name: string): ts.PropertyAssignment | undefined;
10
+ export declare function inspectStaticConfig(source: string, filename: string): StaticConfig;
11
+ export declare function replaceExpression(source: string, node: ts.Node, replacement: string, ast: ts.SourceFile): string;
12
+ export declare function setLiteralProperty(source: string, object: ts.ObjectLiteralExpression, key: string, literal: string, ast: ts.SourceFile): string;
13
+ export declare function staticDriverInfo(config: StaticConfig, connection: ts.ObjectLiteralExpression): {
14
+ driver?: string;
15
+ directory?: string;
16
+ };
@@ -1,4 +1,7 @@
1
- import { _ as executeFiles, d as planInitialization, f as requiredPackages, g as describePlan, i as resolveDependencies, l as readManaged, n as runProcess, o as initializationOptions, r as RegistryClient, t as installCommands, u as configuredRegistry, v as detectProject, y as exists } from "./package-manager-BBRBhsIe.js";
1
+ import { a as configuredRegistry, i as resolveDependencies, n as runProcess, r as RegistryClient, t as installCommands } from "./package-manager-Ca5ArUf-.js";
2
+ import { detectProject, exists } from "./project-detector-BQWeQZ8Q.js";
3
+ import { n as requiredPackages, o as initializationOptions, t as planInitialization } from "./initialization-planner-B41PNGWc.js";
4
+ import { describePlan, executeFiles } from "./file-plan-D-Sj3yv0.js";
2
5
  import { resolve } from "node:path";
3
6
  import { createInterface } from "node:readline/promises";
4
7
  // src/terminal/prompts.ts
@@ -50,20 +53,12 @@ async function initialize(parsed, io) {
50
53
  const project = await detectProject(resolve(io.cwd ?? process.cwd(), values.directory ?? "."), !!values.directory);
51
54
  if (!values.directory && project.root !== resolve(io.cwd ?? process.cwd()) && (project.manifest.workspaces || await exists(resolve(project.root, "pnpm-workspace.yaml")))) throw new Error("Initialization from a nested directory would target the workspace root. Select the application explicitly with --directory; use --directory . to create a new package here.");
52
55
  if (await exists(resolve(project.root, ".duraxis-init.lock"))) throw new Error("Another initialization/update owns .duraxis-init.lock. Wait for it to finish; inspect stale guards before manual removal.");
53
- if (await exists(resolve(project.root, "duraxis.project.json"))) {
54
- const settings = await readManaged(project.root);
55
- return {
56
- status: "already-initialized",
57
- root: project.root,
58
- connections: Object.keys(settings.connections),
59
- actions: [
60
- "config:show",
61
- "config:set",
62
- "connection:add",
63
- "doctor"
64
- ]
65
- };
66
- }
56
+ if (project.configFiles.length) return {
57
+ status: "already-initialized",
58
+ root: project.root,
59
+ configuration: project.configFiles,
60
+ actions: ["config:show", "doctor"]
61
+ };
67
62
  const interactive = io.interactive ?? (process.stdin.isTTY && process.stdout.isTTY && !values.json);
68
63
  if (values.framework === "auto") values.framework = project.nestjs ? "nestjs" : "standalone";
69
64
  const wizard = async (ask) => {
@@ -164,9 +159,9 @@ async function initialize(parsed, io) {
164
159
  "Implement the manual migration",
165
160
  "duraxis migration:snapshot --schema collections.json",
166
161
  "duraxis migrate:up"
167
- ] : ["Import createDatabase/createORM from generated shared factory", "Always close resources in finally"]
162
+ ] : ["Import createDatabase from @duraxis/core or createORM from @duraxis/orm and pass your duraxis.config", "Always close resources in finally"]
168
163
  };
169
164
  }
170
165
  export { initialize };
171
166
 
172
- //# sourceMappingURL=init.command-B2kKoyfi.js.map
167
+ //# sourceMappingURL=init.command-DrO29773.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.command-DrO29773.js","names":[],"sources":["../src/terminal/prompts.ts","../src/commands/init.command.ts"],"sourcesContent":["import { createInterface } from \"node:readline/promises\";\nexport type Prompt = (\n question: string,\n fallback: string,\n choices?: readonly string[],\n) => Promise<string>;\nexport async function withPrompts<T>(\n run: (ask: Prompt) => Promise<T>,\n signal?: AbortSignal,\n): Promise<T> {\n const terminal = createInterface({\n input: process.stdin,\n output: process.stderr,\n terminal: false,\n });\n const ask: Prompt = async (question, fallback, choices) => {\n signal?.throwIfAborted();\n const numbered = choices\n ? `\\n${choices.map((choice, index) => ` ${index + 1}. ${choice}`).join(\"\\n\")}\\n`\n : \"\";\n const value = await new Promise<string>((resolve, reject) => {\n const cancel = () => {\n cleanup();\n reject(new Error(\"Initialization cancelled (EOF or Ctrl+C)\"));\n };\n const cleanup = () => {\n terminal.removeListener(\"close\", cancel);\n terminal.removeListener(\"SIGINT\", cancel);\n };\n terminal.once(\"close\", cancel);\n terminal.once(\"SIGINT\", cancel);\n terminal.question(`${question}${numbered} [${fallback}]: `, { signal }).then(\n (answer) => {\n cleanup();\n resolve(answer.trim() || fallback);\n },\n (error) => {\n cleanup();\n reject(error);\n },\n );\n });\n if (choices && /^\\d+$/.test(value)) {\n const selected = choices[Number(value) - 1];\n if (!selected) throw new Error(\"Invalid numbered selection\");\n return selected;\n }\n if (choices && !choices.includes(value))\n throw new Error(`Choose one of: ${choices.join(\", \")}`);\n return value;\n };\n try {\n return await run(ask);\n } finally {\n terminal.close();\n }\n}\n","import { configuredRegistry } from \"../dependencies/configured-registry.js\";\nimport { resolve } from \"node:path\";\nimport type { CLIIO } from \"../cli.js\";\nimport type { ParsedCommand } from \"../registry/argument-parser.js\";\nimport { detectProject, exists } from \"../init/project-detector.js\";\nimport { initializationOptions } from \"../init/initialization-options.js\";\nimport { planInitialization, requiredPackages } from \"../init/initialization-planner.js\";\nimport { executeFiles, describePlan } from \"../filesystem/file-plan.js\";\nimport { RegistryClient } from \"../dependencies/registry-client.js\";\nimport { resolveDependencies } from \"../dependencies/dependency-resolver.js\";\nimport { installCommands, runProcess } from \"../dependencies/package-manager.js\";\nimport { withPrompts, type Prompt } from \"../terminal/prompts.js\";\nexport async function initialize(parsed: ParsedCommand, io: CLIIO): Promise<unknown> {\n const values = { ...parsed.values };\n const project = await detectProject(\n resolve(io.cwd ?? process.cwd(), values.directory ?? \".\"),\n !!values.directory,\n );\n if (\n !values.directory &&\n project.root !== resolve(io.cwd ?? process.cwd()) &&\n (project.manifest.workspaces || (await exists(resolve(project.root, \"pnpm-workspace.yaml\"))))\n )\n throw new Error(\n \"Initialization from a nested directory would target the workspace root. Select the application explicitly with --directory; use --directory . to create a new package here.\",\n );\n if (await exists(resolve(project.root, \".duraxis-init.lock\")))\n throw new Error(\n \"Another initialization/update owns .duraxis-init.lock. Wait for it to finish; inspect stale guards before manual removal.\",\n );\n if (project.configFiles.length)\n return {\n status: \"already-initialized\",\n root: project.root,\n configuration: project.configFiles,\n actions: [\"config:show\", \"doctor\"],\n };\n const interactive =\n io.interactive ?? (process.stdin.isTTY && process.stdout.isTTY && !values.json);\n if (values.framework === \"auto\") values.framework = project.nestjs ? \"nestjs\" : \"standalone\";\n const wizard = async (ask: Prompt) => {\n if (\n !project.hasManifest &&\n (await ask(\"Create a minimal Node.js project manifest?\", \"yes\", [\"yes\", \"no\"])) !== \"yes\"\n )\n throw new Error(\"Initialization cancelled\");\n values.framework ??= await ask(\"Integration\", project.nestjs ? \"nestjs\" : \"standalone\", [\n \"standalone\",\n \"nestjs\",\n ]);\n values.driver ??= await ask(\"Storage driver\", \"disk\", [\"disk\", \"memory\", \"s3\", \"custom\"]);\n if (values.framework === \"nestjs\") {\n if (values[\"no-orm\"]) throw new Error(\"NestJS requires ORM\");\n values.orm = true;\n } else if (values.orm === undefined && !values[\"no-orm\"])\n values.orm = (await ask(\"Enable ORM?\", \"yes\", [\"yes\", \"no\"])) === \"yes\";\n if (values.migrations === undefined && !values[\"no-migrations\"])\n values.migrations =\n (await ask(\"Enable migrations?\", values.driver === \"memory\" ? \"no\" : \"yes\", [\n \"yes\",\n \"no\",\n ])) === \"yes\";\n values.namespace ??= await ask(\"Database namespace (not an authorization boundary)\", \"default\");\n if (values.driver === \"s3\") {\n values.bucket ??= await ask(\"S3 bucket\", \"\");\n values.region ??= await ask(\"AWS region\", \"us-east-1\");\n }\n if (values.driver === \"custom\")\n values[\"custom-module\"] ??= await ask(\"Trusted custom storage module\", \"./storage.mjs\");\n if (project.managerConflict)\n values[\"package-manager\"] ??= await ask(\"Package manager\", \"npm\", [\n \"npm\",\n \"pnpm\",\n \"yarn\",\n \"bun\",\n ]);\n if ((await ask(\"Configure advanced settings?\", \"no\", [\"yes\", \"no\"])) === \"yes\") {\n values[\"source-dir\"] ??= await ask(\"Source directory\", \"src\");\n if (values.driver === \"disk\")\n values[\"storage-directory\"] ??= await ask(\"Storage directory\", \"./data/duraxis\");\n values[\"schema-mode\"] ??= await ask(\n \"Schema mode\",\n values.migrations ? \"validate-managed\" : \"create\",\n [\"create\", \"validate\", \"validate-managed\"],\n );\n }\n if (values.orm && values.example === undefined && !values[\"no-example\"])\n values.example = (await ask(\"Generate example entity?\", \"no\", [\"yes\", \"no\"])) === \"yes\";\n if (values.install === undefined && !values[\"no-install\"])\n values.install =\n (await ask(\"Install required dependencies?\", \"yes\", [\"yes\", \"no\"])) === \"yes\";\n };\n if (!values.yes && !values[\"dry-run\"]) {\n if (!interactive)\n throw new Error(\n \"Non-interactive initialization requires --yes or --dry-run. No files were changed.\",\n );\n if (io.prompt) await wizard(io.prompt);\n else await withPrompts(wizard, io.signal);\n }\n const options = await initializationOptions(project, values);\n const requested = [\n ...requiredPackages(options),\n \"@duraxis/cli\",\n ...(options.language === \"typescript\" ? [\"typescript\", \"@types/node\"] : []),\n ];\n const existing = { ...project.dependencies, ...project.devDependencies };\n const resolved = options.install\n ? await resolveDependencies(\n requested,\n existing,\n new RegistryClient(await configuredRegistry(project, values.registry), io.fetch, io.signal),\n values.prerelease,\n )\n : Object.fromEntries(requested.map((name) => [name, existing[name] ?? \"latest\"]));\n const devNames = new Set([\"@duraxis/cli\", \"typescript\", \"@types/node\"]);\n const dependencies = Object.fromEntries(\n Object.entries(resolved).filter(\n ([name]) =>\n (!devNames.has(name) || !!project.dependencies[name]) &&\n (requested.includes(name) || !name.startsWith(\"@duraxis/\")) &&\n (!existing[name] || existing[name] !== resolved[name]),\n ),\n );\n const development = Object.fromEntries(\n Object.entries(resolved).filter(\n ([name]) =>\n devNames.has(name) &&\n !project.dependencies[name] &&\n (!existing[name] || existing[name] !== resolved[name]),\n ),\n );\n const plan = await planInitialization(project, options, dependencies, development);\n plan.commands = options.install\n ? installCommands(options.manager, dependencies, development)\n : [];\n if (options.install && !plan.commands.length) plan.commands.push([options.manager, \"install\"]);\n io.signal?.throwIfAborted();\n if (values[\"dry-run\"]) return { status: \"planned\", ...describePlan(plan) };\n await executeFiles(plan, async () => {\n io.signal?.throwIfAborted();\n for (const [command, ...args] of plan.commands)\n await (io.runProcess ?? runProcess)({\n command: command!,\n args,\n cwd: project.root,\n signal: io.signal,\n });\n io.signal?.throwIfAborted();\n });\n return {\n status:\n options.driver === \"custom\"\n ? \"configured-custom-driver-not-evaluated\"\n : options.install\n ? \"initialized\"\n : \"configured-dependencies-not-installed\",\n databaseOpened: false,\n dependenciesInstalled: options.install,\n root: project.root,\n files: plan.files.map((f) => f.path),\n dependencies,\n devDependencies: development,\n warnings: plan.warnings,\n next: options.migrations\n ? options.orm\n ? [\n \"Review entities\",\n \"duraxis migration:generate initial\",\n \"duraxis migrate:up\",\n \"Start application after migrations\",\n ]\n : [\n \"duraxis migration:create initial\",\n \"Implement the manual migration\",\n \"duraxis migration:snapshot --schema collections.json\",\n \"duraxis migrate:up\",\n ]\n : [\n \"Import createDatabase from @duraxis/core or createORM from @duraxis/orm and pass your duraxis.config\",\n \"Always close resources in finally\",\n ],\n };\n}\n"],"mappings":";;;;;;;AAMA,eAAsB,YACpB,KACA,QACY;CACZ,MAAM,WAAW,gBAAgB;EAC/B,OAAO,QAAQ;EACf,QAAQ,QAAQ;EAChB,UAAU;CACZ,CAAC;CACD,MAAM,MAAc,OAAO,UAAU,UAAU,YAAY;EACzD,QAAQ,eAA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