@duraxis/cli 0.3.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 (52) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +20 -71
  3. package/dist/admin.command-Dt5MnwJw.js +299 -0
  4. package/dist/admin.command-Dt5MnwJw.js.map +1 -0
  5. package/dist/cli.d.ts +7 -0
  6. package/dist/commands/admin.command.d.ts +3 -0
  7. package/dist/commands/doctor.command.d.ts +9 -0
  8. package/dist/commands/init.command.d.ts +3 -0
  9. package/dist/commands/migration.command.d.ts +3 -0
  10. package/dist/commands/minimal-admin.d.ts +4 -0
  11. package/dist/config-BKscNXeW.js +204 -0
  12. package/dist/config-BKscNXeW.js.map +1 -0
  13. package/dist/config.d.ts +10 -8
  14. package/dist/dependencies/configured-registry.d.ts +3 -0
  15. package/dist/dependencies/dependency-resolver.d.ts +2 -0
  16. package/dist/dependencies/installed-package.d.ts +1 -0
  17. package/dist/dependencies/package-manager.d.ts +10 -0
  18. package/dist/dependencies/registry-client.d.ts +21 -0
  19. package/dist/dependencies/version-compatibility.d.ts +9 -0
  20. package/dist/file-plan-D-Sj3yv0.js +130 -0
  21. package/dist/file-plan-D-Sj3yv0.js.map +1 -0
  22. package/dist/filesystem/file-plan.d.ts +32 -0
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +366 -551
  25. package/dist/index.js.map +1 -1
  26. package/dist/init/initialization-options.d.ts +32 -0
  27. package/dist/init/initialization-planner.d.ts +10 -0
  28. package/dist/init/nest-integration.d.ts +2 -0
  29. package/dist/init/project-detector.d.ts +27 -0
  30. package/dist/init/static-config.d.ts +16 -0
  31. package/dist/init.command-DrO29773.js +167 -0
  32. package/dist/init.command-DrO29773.js.map +1 -0
  33. package/dist/initialization-planner-B41PNGWc.js +315 -0
  34. package/dist/initialization-planner-B41PNGWc.js.map +1 -0
  35. package/dist/migration.command-dhRbN4UI.js +361 -0
  36. package/dist/migration.command-dhRbN4UI.js.map +1 -0
  37. package/dist/minimal-admin-B4ur_cON.js +232 -0
  38. package/dist/minimal-admin-B4ur_cON.js.map +1 -0
  39. package/dist/nest-integration-KCc7ZaG6.js +93 -0
  40. package/dist/nest-integration-KCc7ZaG6.js.map +1 -0
  41. package/dist/package-manager-Ca5ArUf-.js +269 -0
  42. package/dist/package-manager-Ca5ArUf-.js.map +1 -0
  43. package/dist/project-detector-BQWeQZ8Q.js +174 -0
  44. package/dist/project-detector-BQWeQZ8Q.js.map +1 -0
  45. package/dist/registry/argument-parser.d.ts +65 -0
  46. package/dist/registry/command-registry.d.ts +198 -0
  47. package/dist/rolldown-runtime-D8jQpDG7.js +12 -0
  48. package/dist/static-config-g_7qN12_.js +109 -0
  49. package/dist/static-config-g_7qN12_.js.map +1 -0
  50. package/dist/templates/project.d.ts +10 -0
  51. package/dist/terminal/prompts.d.ts +2 -0
  52. package/package.json +13 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @duraxis/cli
2
2
 
3
+ ## 0.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7eb57c1: Resolve installed dependency metadata from the selected application's node_modules tree, including hoisted and linked packages, and use the PnP resolver only for active PnP installations. Prevent dependencies available only to CLI tooling or test loaders from being mistaken for application installations and suppressing requested upgrades.
8
+
9
+ ## 0.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 6377fde: Add framework-independent configuration and owned database/ORM factories, bounded decorated-entity discovery, and shared NestJS/CLI schema resolution. Initialize projects with one source-root configuration and direct AST-guided AppModule integration. Support static inspection/mutation, centralized named connections, registry-free generators and source/compiled deployments without runtime CLI dependencies. Use shared typed configuration across runtime and CLI, standard Nest feature modules, and authenticated encrypted cursors. Document storage, migration, discovery and lifecycle contracts.
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [6377fde]
18
+ - @duraxis/core@0.5.0
19
+ - @duraxis/orm@0.5.0
20
+ - @duraxis/migrations@0.3.1
21
+
22
+ ## 0.4.0
23
+
24
+ ### Minor Changes
25
+
26
+ - 8ef8100: Expand the migration CLI into project setup and administration tooling with native interactive/non-interactive initialization, standalone Core/ORM and NestJS shared factories, official/custom storage integration, optional migrations, named connections, static diagnostics, configuration commands, generators and compatible dependency updates.
27
+
28
+ Generate command help and argument validation from one registry. Add native registry/version compatibility checks, package-manager execution, guarded filesystem plans and rollback. Migration cancellation now closes owned database resources cooperatively while preserving in-flight publication semantics and explicitly reporting cleanup failures. No new third-party dependencies or migration checksum compiler changes.
29
+
30
+ Pre-1.0 behavior change: `init` now creates functional project settings and shared application factories, installs dependencies by default, and requires `--yes` in non-interactive mode. Use `--no-install` for offline scaffolding and explicitly select migrations. Existing executable configurations remain supported and are never automatically rewritten. See the CLI README for trust boundaries and supported combinations.
31
+
3
32
  ## 0.3.0
4
33
 
5
34
  ### Minor Changes
package/README.md CHANGED
@@ -1,94 +1,45 @@
1
1
  # @duraxis/cli
2
2
 
3
- Standalone Duraxis migration tooling. Node.js 24.15.0 or newer is required. The CLI builds on
4
- `@duraxis/migrations` and the ORM's database-independent schema exporter.
3
+ Project initialization, configuration, diagnostics, generators, dependency updates and migrations for Duraxis. Node.js 24.15.0 or newer is required.
5
4
 
6
5
  ## Quick start
7
6
 
8
7
  ```bash
9
- pnpm add @duraxis/core @duraxis/orm @duraxis/migrations @duraxis/storage-disk
10
- pnpm add -D @duraxis/cli
8
+ npx --package @duraxis/cli@latest duraxis init
9
+ # After local installation:
11
10
  pnpm exec duraxis init
11
+ # Or with the executable on PATH:
12
+ duraxis init
12
13
  ```
13
14
 
14
- Edit the generated config to import your decorated entities and open your storage:
15
-
16
- ```ts
17
- import { fileURLToPath } from "node:url";
18
- import { defineDuraxisConfig } from "@duraxis/cli";
19
- import { DuraxisDatabase } from "@duraxis/core";
20
- import { AsyncDiskStorageDriver } from "@duraxis/storage-disk";
21
- import { User } from "./src/entities/user.entity.js";
22
-
23
- export default defineDuraxisConfig({
24
- entities: [User],
25
- migrations: {
26
- directory: "./duraxis/migrations",
27
- snapshots: "./duraxis/snapshots",
28
- format: "ts",
29
- },
30
- async createDatabase() {
31
- const storage = await AsyncDiskStorageDriver.open({
32
- directory: fileURLToPath(new URL("./data/duraxis", import.meta.url)),
33
- });
34
- return new DuraxisDatabase({ storage });
35
- },
36
- });
37
- ```
15
+ For a reproducible non-interactive persistent ORM project:
38
16
 
39
17
  ```bash
40
- pnpm exec duraxis migration:generate initial-schema
18
+ duraxis init --framework standalone --driver disk --orm --migrations --package-manager pnpm --yes
19
+ pnpm exec duraxis migration:generate initial
41
20
  pnpm exec duraxis migrate:up
42
- # Modify entity definitions to add an optional status column.
43
- pnpm exec duraxis migration:generate add-user-status
44
- pnpm exec duraxis migrate:diff
45
- pnpm exec duraxis migrate:up
46
- pnpm exec duraxis migrate:status
47
- pnpm exec duraxis migrate:check
48
- pnpm exec duraxis migrate:down --yes
21
+ pnpm exec duraxis doctor
49
22
  ```
50
23
 
51
- Generated rollback rejects populated fields or collections it would remove. For
52
- production, review generated files, constraints, data transformations, and backups
53
- before applying or reverting. Never edit a shared or applied migration.
54
-
55
- Without a local installation, use the scoped package name explicitly:
24
+ Use `--no-install` for offline scaffolding, `--dry-run` to inspect a plan, and `--yes` for redirected input. Migrations are optional; Memory defaults to no migrations. NestJS requires ORM. One source-root configuration serves runtime and administration without importing the CLI. Existing NestJS AppModules receive direct registration; unrelated application code and persistence integrations are preserved.
56
25
 
57
- ```bash
58
- npx --package @duraxis/cli duraxis --help
59
- ```
26
+ The [setup and administration guide](../../docs/CLI-SETUP.md) documents all options, package managers, storage configurations, named connections, environment provisioning, generated code, production deployment, safeguards and limitations.
60
27
 
61
- An unscoped `npx duraxis` does not identify this package. Install the dev dependency
62
- before using `pnpm exec duraxis`.
28
+ `duraxis help` lists every command; `duraxis help init` lists every initialization option. New administration commands include `doctor`, `config:show`, `config:validate`, `config:set`, `connection:add`, `connection:list`, `storage:list`, `storage:check`, `generate:entity`, `generate:module`, `upgrade --check/--apply`. An unscoped `npx duraxis` does not identify this package.
63
29
 
64
30
  ## Configuration and loading
65
31
 
66
- Discovery walks from the working directory upward for `duraxis.config.ts`,
67
- `duraxis.config.mts`, `duraxis.config.js`, `duraxis.config.mjs`,
68
- `duraxis.config.cts`, or `duraxis.config.cjs`. `--config <path>` overrides discovery.
69
- Migration and snapshot directories resolve relative to the config file. Paths
70
- inside your database factory are your responsibility; use `import.meta.url` as
71
- above instead of depending on the command's working directory.
72
-
73
- `entities` accepts a class array or an async factory returning classes, allowing
74
- project-specific entity discovery. `migrations.format` is `ts` (default) or `js`.
75
- A `databases` object can hold named connection configs with the same three fields
76
- (`entities`, `migrations`, `createDatabase`). Select one with `--database <name>`;
77
- the top-level connection is the default.
32
+ The preferred configuration uses `defineDuraxisConfig` from `@duraxis/core`, a driver factory, `location: import.meta.url` (or `__filename`), optional `autoLoadEntities` and `migrations: true`. See the [shared configuration API](../../docs/CLI-SETUP.md) for complete examples, exact discovery boundaries and source/compiled behavior.
78
33
 
79
- The factory returns an owned Core database, not a NestJS connection. The CLI closes
80
- that database and storage in a `finally` block. Factories must clean up resources
81
- if they fail before returning. Do not pass an application-owned connection to
82
- this CLI API; use the programmatic runner for that scenario.
34
+ The CLI searches conventional root config names and actual source roots detected from Nest/TypeScript project configuration. `--config <path>` resolves ambiguity. Runtime and CLI use the same normalized package-relative storage/migration paths and validated entity schema. Standalone `createDatabase(config)` and `createORM(config)` own factory-created resources without depending on CLI or NestJS.
83
35
 
84
36
  Duraxis registers synchronous Node.js `registerHooks()` before loading a config,
85
37
  entity, or migration, including programmatic `loadConfig()` calls. No manual
86
38
  loader registration, experimental Node flags, or extra runtime transpiler is
87
- required. Native type stripping alone cannot implement legacy decorators.
39
+ required. Native type stripping alone cannot implement TypeScript decorators.
88
40
 
89
41
  Supported configuration formats are `.ts`, `.mts`, `.js`, `.mjs`, `.cts`, and
90
- `.cjs`. Discovery checks those extensions in that order. `.ts` and `.mts` source
91
- modules execute as ESM; `.cts` uses CommonJS. JavaScript keeps Node's ordinary
42
+ `.cjs`. Discovery checks those extensions in that order. `.ts` follows package.json module semantics; `.mts` executes as ESM and `.cts` as CommonJS. JavaScript keeps Node's ordinary
92
43
  package/module semantics. Executable migration artifacts support ESM `.ts`,
93
44
  `.mts`, `.js`, and `.mjs`; CommonJS migration artifacts are unsupported because
94
45
  their executable form does not share the ESM checksum identity contract.
@@ -108,9 +59,7 @@ usual `reflect-metadata` dependency before decorated modules. Entity columns
108
59
  should declare their Core `type` explicitly. `tsconfig.json` path aliases,
109
60
  custom compiler plugins, `.tsx`/`.jsx`, and TypeScript package sources inside
110
61
  `node_modules` are not supported. Use relative imports or published package exports.
111
- When using a CommonJS config, load decorated entities and Duraxis connections
112
- from ESM with native dynamic imports. Mixing independent ESM and CommonJS copies
113
- of ORM decorators/Core constructors is unsupported; the CLI executes as ESM.
62
+ New CommonJS configurations use ordinary `.ts`/`.js` with package module semantics, and the CLI selects the matching ORM decorator registry. New migration files use ESM `.mts`/`.mjs` without per-directory module manifests. Avoid mixing independent ESM/CommonJS decorator registries within one entity graph.
114
63
  Config files and migrations are trusted executable code; keep module initialization
115
64
  free of database writes and external side effects.
116
65
 
@@ -141,11 +90,11 @@ releases that directory before invoking the CLI.
141
90
  Every command supports `--config`, `--database`, and `--json`. Unknown options and
142
91
  options inappropriate for a command are errors. Errors exit with code 1; success
143
92
  exits 0. `--json` emits machine-readable success results for inspection commands
144
- and JSON errors on stderr. No command requires an interactive prompt.
93
+ and JSON errors on stderr. Initialization prompts on a terminal unless `--yes` is provided; redirected input never waits for prompts.
145
94
 
146
95
  | Command | Behavior and options |
147
96
  | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
148
- | `init` | Creates a config, migration/snapshot directories, and an empty `baseline.json`; refuses existing files. Does not modify application source. |
97
+ | `init` | Creates the source-root configuration and integrates NestJS; installs compatible dependencies by default. Migrations and ORM are optional. Use --dry-run and --no-install as needed. |
149
98
  | `migration:create <name>` | Creates a throwing manual template. Complete it and provide an expected snapshot before use. |
150
99
  | `migration:snapshot --schema <file>` | Saves an intended snapshot for the latest manual migration from a JSON array of Core collection definitions. Never overwrites a snapshot. Application verifies the result atomically. |
151
100
  | `migration:generate <name>` | Compares the latest local snapshot with exported entities and generates a self-contained migration/snapshot pair. No file on no-change. `--allow-destructive` authorizes generating removals. |
@@ -217,7 +166,7 @@ checksum mismatches, and divergent chains are rejected. Production should contai
217
166
  one executable format per migration, not both `.ts` and `.js` copies.
218
167
 
219
168
  Artifact checksums normalize executable code with pinned TypeScript 5.9.3 (two
220
- passes, ES2022 ESM, comments removed, legacy decorators, metadata enabled,
169
+ passes, ES2022 ESM, comments removed, TypeScript decorators, metadata enabled,
221
170
  `useDefineForClassFields: false`). Compiled migrations must preserve this target
222
171
  and ESM module form. Comments/types/formatting do not change identity; executable
223
172
  edits do. External helper content is not transitively hashed: keep historical
@@ -0,0 +1,299 @@
1
+ import { a as configuredRegistry, i as resolveDependencies, n as runProcess, o as compare, r as RegistryClient, s as satisfies, t as installCommands } from "./package-manager-Ca5ArUf-.js";
2
+ import { detectProject, exists, readObject } from "./project-detector-BQWeQZ8Q.js";
3
+ import { executeFiles } from "./file-plan-D-Sj3yv0.js";
4
+ import { readFile } from "node:fs/promises";
5
+ import { basename, delimiter, dirname, join, resolve } from "node:path";
6
+ import { existsSync } from "node:fs";
7
+ import { createRequire } from "node:module";
8
+ // src/commands/doctor.command.ts
9
+ function available(project, name) {
10
+ if (!project.dependencies[name] && !project.devDependencies[name] && !existsSync(join(project.root, "node_modules", name))) return false;
11
+ try {
12
+ const require = createRequire(join(project.root, "package.json"));
13
+ let installed = false;
14
+ let directory = project.root;
15
+ while (true) {
16
+ if (existsSync(join(directory, ".pnp.cjs")) || existsSync(join(directory, "node_modules", name))) {
17
+ installed = true;
18
+ break;
19
+ }
20
+ if (dirname(directory) === directory) break;
21
+ directory = dirname(directory);
22
+ }
23
+ if (!installed) return false;
24
+ require.resolve(name);
25
+ return true;
26
+ } catch {
27
+ return false;
28
+ }
29
+ }
30
+ async function diagnostics(project) {
31
+ const checks = [];
32
+ const add = (level, check, message) => checks.push({
33
+ level,
34
+ check,
35
+ message
36
+ });
37
+ add(satisfies(process.versions.node, ">=24.15.0") ? "PASS" : "FAIL", "runtime", `Node.js ${process.versions.node}; requires >=24.15.0 (Bun is a package manager only)`);
38
+ add(project.hasManifest ? "PASS" : "FAIL", "manifest", project.hasManifest ? project.root : "Create package.json with duraxis init --yes");
39
+ add(project.managerConflict ? "FAIL" : "PASS", "package-manager", project.managerConflict ? "Conflicting lockfiles; choose --package-manager explicitly" : project.manager ?? "npm default (no lockfile detected)");
40
+ add("PASS", "workspace", project.workspace ? `Application ${project.root}; workspace ${project.workspace}; installations use the application directory` : "Standalone package");
41
+ const manager = project.manager ?? "npm";
42
+ const suffixes = process.platform === "win32" ? [
43
+ ".cmd",
44
+ ".exe",
45
+ ""
46
+ ] : [""];
47
+ const managerAvailable = (process.env.PATH ?? "").split(delimiter).slice(0, 512).some((directory) => suffixes.some((suffix) => existsSync(join(directory, manager + suffix))));
48
+ add(managerAvailable ? "PASS" : "WARN", "package-manager-availability", managerAvailable ? `${manager} executable found on PATH (not executed)` : `Install ${manager} or add it to PATH`);
49
+ add("PASS", "module-format", project.moduleFormat);
50
+ if (await exists(join(project.root, "tsconfig.json"))) {
51
+ const ts = (await import("typescript")).default;
52
+ const parsed = ts.readConfigFile(join(project.root, "tsconfig.json"), ts.sys.readFile);
53
+ if (parsed.error) add("FAIL", "typescript", "Cannot parse tsconfig.json");
54
+ else {
55
+ const compiler = ts.parseJsonConfigFileContent(parsed.config, ts.sys, project.root).options;
56
+ add(compiler.experimentalDecorators && compiler.emitDecoratorMetadata && compiler.useDefineForClassFields === false ? "PASS" : "WARN", "typescript", "ORM entities require experimentalDecorators:true, emitDecoratorMetadata:true, useDefineForClassFields:false; source configs follow package module semantics; NodeNext is supported");
57
+ }
58
+ } else add(project.language === "typescript" ? "WARN" : "SKIP", "typescript", "No tsconfig.json; use explicit fields with JavaScript decorator functions");
59
+ if (project.configFiles.length === 1) try {
60
+ const { inspectStaticConfig, property } = await import("./static-config-g_7qN12_.js");
61
+ const { readFile } = await import("node:fs/promises");
62
+ const inspection = inspectStaticConfig(await readFile(join(project.root, project.configFiles[0]), "utf8"), project.configFiles[0]);
63
+ const ts = (await import("typescript")).default;
64
+ const packages = /* @__PURE__ */ new Set(["@duraxis/core"]);
65
+ for (const statement of inspection.ast.statements) {
66
+ if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier)) packages.add(statement.moduleSpecifier.text);
67
+ if (ts.isVariableStatement(statement)) for (const declaration of statement.declarationList.declarations) {
68
+ const call = declaration.initializer;
69
+ if (call && ts.isCallExpression(call) && call.expression.getText(inspection.ast) === "require" && call.arguments[0] && ts.isStringLiteral(call.arguments[0])) packages.add(call.arguments[0].text);
70
+ }
71
+ }
72
+ for (const connection of inspection.connections.values()) {
73
+ if (property(connection, "entities") || property(connection, "autoLoadEntities")) packages.add("@duraxis/orm");
74
+ const migrations = property(connection, "migrations");
75
+ if (migrations && migrations.initializer.kind !== ts.SyntaxKind.FalseKeyword) packages.add("@duraxis/migrations");
76
+ }
77
+ if (project.nestjs) packages.add("@duraxis/nestjs");
78
+ for (const name of packages) if (name.startsWith("@duraxis/")) add(available(project, name) ? "PASS" : "FAIL", `package:${name}`, `Runtime dependency ${name} must be installed in the application`);
79
+ add("PASS", "static-configuration", `Connections: ${[...inspection.connections.keys()].join(", ")}; no executable code evaluated`);
80
+ } catch {
81
+ add("WARN", "static-configuration", "Dynamic or malformed configuration; inspect manually or use config:validate --evaluate for trusted code");
82
+ }
83
+ add(project.configFiles.length ? "WARN" : "FAIL", "configuration", project.configFiles.length ? "Executable configuration detected, not evaluated. Use config:validate --evaluate only for trusted code." : "Run duraxis init");
84
+ return checks;
85
+ }
86
+ // src/dependencies/installed-package.ts
87
+ async function installedPackage(root, name) {
88
+ if (!/^(?:@[a-z0-9._-]+\/)?[a-z0-9][a-z0-9._-]*$/i.test(name)) return void 0;
89
+ let directory = resolve(root);
90
+ let plugAndPlay = false;
91
+ while (true) {
92
+ const path = join(directory, "node_modules", name, "package.json");
93
+ if (await exists(path)) {
94
+ const manifest = await readObject(path);
95
+ return manifest.name === name ? manifest : void 0;
96
+ }
97
+ plugAndPlay ||= await exists(join(directory, ".pnp.cjs"));
98
+ if (dirname(directory) === directory) break;
99
+ directory = dirname(directory);
100
+ }
101
+ if (!plugAndPlay || !process.versions.pnp) return void 0;
102
+ try {
103
+ directory = dirname(createRequire(join(resolve(root), "package.json")).resolve(name));
104
+ } catch {
105
+ return;
106
+ }
107
+ for (let depth = 0; depth < 12; depth++) {
108
+ try {
109
+ const manifest = await readObject(join(directory, "package.json"));
110
+ if (manifest.name === name) return manifest;
111
+ } catch (error) {
112
+ if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
113
+ }
114
+ if (dirname(directory) === directory) break;
115
+ directory = dirname(directory);
116
+ }
117
+ }
118
+ // src/commands/admin.command.ts
119
+ function plan(root) {
120
+ return {
121
+ root,
122
+ files: [],
123
+ directories: [],
124
+ warnings: [],
125
+ dependencies: {},
126
+ devDependencies: {},
127
+ commands: []
128
+ };
129
+ }
130
+ function redact(value, seen = /* @__PURE__ */ new WeakSet(), depth = 0) {
131
+ if (depth > 16) return "[unresolved: inspection depth limit]";
132
+ if (value && typeof value === "object") {
133
+ if (seen.has(value)) return "[circular/shared reference]";
134
+ seen.add(value);
135
+ if (Array.isArray(value)) return value.map((item) => redact(item, seen, depth + 1));
136
+ return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, /secret|password|token|credential|signingkey|encryption|access[_-]?key|private[_-]?key|api[_-]?key|^keys?$/i.test(key) ? "[REDACTED]" : redact(item, seen, depth + 1)]));
137
+ }
138
+ if (typeof value === "function") return "[trusted function; not evaluated]";
139
+ if (typeof value === "string" && /^https?:/.test(value)) try {
140
+ const url = new URL(value);
141
+ if (url.username || url.password || url.search) return "[REDACTED URL]";
142
+ } catch {}
143
+ return value;
144
+ }
145
+ async function administer(parsed, io) {
146
+ const { values, definition } = parsed;
147
+ const cwd = values.directory ? resolve(io.cwd ?? process.cwd(), values.directory) : io.cwd ?? process.cwd();
148
+ const explicit = values.config ? resolve(cwd, values.config) : void 0;
149
+ if (explicit && !await exists(explicit)) throw new Error("Explicit configuration file does not exist");
150
+ const project = await detectProject(explicit ? dirname(explicit) : cwd);
151
+ if (explicit) project.configFiles = [basename(explicit)];
152
+ const root = project.root;
153
+ let configuredDriver;
154
+ if (project.configFiles.length === 1 && definition.name === "storage:list") try {
155
+ const { inspectStaticConfig, staticDriverInfo } = await import("./static-config-g_7qN12_.js");
156
+ const inspection = inspectStaticConfig(await readFile(explicit ?? join(project.root, project.configFiles[0]), "utf8"), explicit ?? project.configFiles[0]);
157
+ const object = inspection.connections.get(values.database ?? inspection.defaultConnection);
158
+ if (object) configuredDriver = staticDriverInfo(inspection, object).driver;
159
+ } catch {}
160
+ if (definition.name === "storage:list") return [
161
+ {
162
+ driver: "memory",
163
+ persistent: false,
164
+ limitation: "Process-local volatile data",
165
+ package: "@duraxis/storage-memory"
166
+ },
167
+ {
168
+ driver: "disk",
169
+ persistent: true,
170
+ limitation: "Single-owner local directory; recovery requires operator action",
171
+ package: "@duraxis/storage-disk"
172
+ },
173
+ {
174
+ driver: "s3",
175
+ persistent: true,
176
+ limitation: "Conditional-request-compatible provider required; destructive distributed GC unsupported",
177
+ package: "@duraxis/storage-s3"
178
+ },
179
+ {
180
+ driver: "custom",
181
+ persistent: "implementation-dependent",
182
+ limitation: "Conditional semantics and bounded reads required",
183
+ package: "@duraxis/storage"
184
+ }
185
+ ].map((driver) => ({
186
+ ...driver,
187
+ available: true,
188
+ installed: available(project, driver.package),
189
+ configured: configuredDriver === driver.driver
190
+ }));
191
+ if (definition.name === "doctor") {
192
+ const checks = await diagnostics(project);
193
+ return {
194
+ failed: checks.some((c) => c.level === "FAIL"),
195
+ diagnostics: checks
196
+ };
197
+ }
198
+ if (definition.name === "upgrade") {
199
+ const installed = Object.fromEntries(Object.entries({
200
+ ...project.dependencies,
201
+ ...project.devDependencies
202
+ }).filter(([name]) => name.startsWith("@duraxis/")));
203
+ if (!Object.keys(installed).length) throw new Error("No Duraxis dependencies found in the selected project");
204
+ for (const [name, specification] of Object.entries(installed)) try {
205
+ satisfies("0.0.0", specification);
206
+ } catch {
207
+ throw new Error(`Cannot upgrade unsupported dependency specification for ${name}; update workspace-owned versions with workspace release tooling, or use a supported registry version range`);
208
+ }
209
+ const resolved = await resolveDependencies(Object.keys(installed), {
210
+ ...project.dependencies,
211
+ ...project.devDependencies
212
+ }, new RegistryClient(await configuredRegistry(project, values.registry), io.fetch, io.signal), values.prerelease, process.versions.node, false);
213
+ const packages = await Promise.all(Object.keys(installed).map(async (name) => {
214
+ const actual = (await installedPackage(root, name))?.version ?? installed[name];
215
+ const downgradeBlocked = typeof actual === "string" && /^v?\d+\.\d+\.\d+(?:[-+]|$)/.test(actual) && compare(resolved[name], actual) < 0;
216
+ return {
217
+ package: name,
218
+ installed: actual,
219
+ declaration: installed[name],
220
+ target: resolved[name],
221
+ downgradeBlocked,
222
+ status: downgradeBlocked ? "downgrade blocked" : actual === resolved[name] ? "up to date" : "update available"
223
+ };
224
+ }));
225
+ if (!values.apply) return {
226
+ packages,
227
+ warning: "Pre-1.0 minor updates may break compatibility. Review changelogs. No data format migration is performed."
228
+ };
229
+ if (packages.some((item) => item.downgradeBlocked)) throw new Error("Automatic downgrades are unsupported; no dependencies were changed. Review the proposed versions and workspace release state manually.");
230
+ const production = Object.fromEntries(packages.filter((p) => project.dependencies[p.package] && p.target !== p.installed).map((p) => [p.package, p.target]));
231
+ const development = Object.fromEntries(packages.filter((p) => project.devDependencies[p.package] && p.target !== p.installed).map((p) => [p.package, p.target]));
232
+ const update = plan(root);
233
+ update.commands = installCommands((await import("./project-detector-BQWeQZ8Q.js")).selectManager(project, values["package-manager"]), production, development);
234
+ io.signal?.throwIfAborted();
235
+ await executeFiles(update, async () => {
236
+ for (const [command, ...args] of update.commands) await (io.runProcess ?? runProcess)({
237
+ command,
238
+ args,
239
+ cwd: root,
240
+ signal: io.signal
241
+ });
242
+ io.signal?.throwIfAborted();
243
+ });
244
+ return {
245
+ status: "updated",
246
+ packages,
247
+ warning: "Review pre-1.0 changes before deployment. Database formats were not migrated."
248
+ };
249
+ }
250
+ if (values.evaluate || definition.name === "storage:check" && values.live) {
251
+ const { config } = await (await import("./config-BKscNXeW.js").then((n) => n.t)).loadConfig(cwd, values.config, values.database);
252
+ if (definition.name === "config:show") return {
253
+ trustedCodeEvaluated: true,
254
+ configuration: redact(config)
255
+ };
256
+ if (definition.name === "config:validate") return {
257
+ valid: true,
258
+ trustedCodeEvaluated: true,
259
+ databaseOpened: false
260
+ };
261
+ if (definition.name === "storage:check") {
262
+ if (project.configFiles.length === 1) {
263
+ const { inspectStaticConfig, staticDriverInfo } = await import("./static-config-g_7qN12_.js");
264
+ let inspection;
265
+ try {
266
+ inspection = inspectStaticConfig(await readFile(explicit ?? join(project.root, project.configFiles[0]), "utf8"), explicit ?? project.configFiles[0]);
267
+ } catch {}
268
+ if (inspection) {
269
+ const connection = values.database ?? inspection.defaultConnection;
270
+ const object = inspection.connections.get(connection);
271
+ if (!object) throw new Error("Unknown named database");
272
+ const info = staticDriverInfo(inspection, object);
273
+ if (info.driver === "disk") {
274
+ const prefix = connection === "default" ? "DURAXIS" : `DURAXIS_${connection.toUpperCase().replace(/-/g, "_")}`;
275
+ const directory = process.env[`${prefix}_STORAGE_DIRECTORY`] ?? info.directory;
276
+ if (!directory || !await exists(resolve(project.root, directory, "journal.log"))) throw new Error("Live Disk check requires an existing initialized directory; refusing to create database files");
277
+ }
278
+ }
279
+ }
280
+ const database = await config.createDatabase();
281
+ try {
282
+ await database.getCollectionDefinitions();
283
+ return {
284
+ valid: true,
285
+ live: true,
286
+ warning: "Trusted factory executed. Disk ownership was temporarily acquired; normal driver recovery may occur. No test objects were written."
287
+ };
288
+ } finally {
289
+ await database.close({ closeStorage: true });
290
+ }
291
+ }
292
+ }
293
+ const configPath = explicit ?? (project.configFiles.length === 1 ? join(project.root, project.configFiles[0]) : void 0);
294
+ if (!configPath) throw new Error("Select a Duraxis configuration with --config, or run init");
295
+ return (await import("./minimal-admin-B4ur_cON.js")).minimalAdmin(parsed, io, project, configPath, redact);
296
+ }
297
+ export { administer };
298
+
299
+ //# sourceMappingURL=admin.command-Dt5MnwJw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin.command-Dt5MnwJw.js","names":[],"sources":["../src/commands/doctor.command.ts","../src/dependencies/installed-package.ts","../src/commands/admin.command.ts"],"sourcesContent":["import { satisfies } from \"../dependencies/version-compatibility.js\";\nimport { existsSync } from \"node:fs\";\nimport { join, delimiter, dirname } from \"node:path\";\nimport { createRequire } from \"node:module\";\nimport { exists, type ProjectContext } from \"../init/project-detector.js\";\ninterface Diagnostic {\n level: \"PASS\" | \"WARN\" | \"FAIL\" | \"SKIP\";\n check: string;\n message: string;\n}\nexport function available(project: ProjectContext, name: string): boolean {\n if (\n !project.dependencies[name] &&\n !project.devDependencies[name] &&\n !existsSync(join(project.root, \"node_modules\", name))\n )\n return false;\n try {\n const require = createRequire(join(project.root, \"package.json\"));\n let installed = false;\n let directory = project.root;\n while (true) {\n if (\n existsSync(join(directory, \".pnp.cjs\")) ||\n existsSync(join(directory, \"node_modules\", name))\n ) {\n installed = true;\n break;\n }\n if (dirname(directory) === directory) break;\n directory = dirname(directory);\n }\n if (!installed) return false;\n require.resolve(name);\n return true;\n } catch {\n return false;\n }\n}\nexport async function diagnostics(project: ProjectContext): Promise<Diagnostic[]> {\n const checks: Diagnostic[] = [];\n const add = (level: Diagnostic[\"level\"], check: string, message: string) =>\n checks.push({ level, check, message });\n add(\n satisfies(process.versions.node, \">=24.15.0\") ? \"PASS\" : \"FAIL\",\n \"runtime\",\n `Node.js ${process.versions.node}; requires >=24.15.0 (Bun is a package manager only)`,\n );\n add(\n project.hasManifest ? \"PASS\" : \"FAIL\",\n \"manifest\",\n project.hasManifest ? project.root : \"Create package.json with duraxis init --yes\",\n );\n add(\n project.managerConflict ? \"FAIL\" : \"PASS\",\n \"package-manager\",\n project.managerConflict\n ? \"Conflicting lockfiles; choose --package-manager explicitly\"\n : (project.manager ?? \"npm default (no lockfile detected)\"),\n );\n add(\n \"PASS\",\n \"workspace\",\n project.workspace\n ? `Application ${project.root}; workspace ${project.workspace}; installations use the application directory`\n : \"Standalone package\",\n );\n const manager = project.manager ?? \"npm\";\n const suffixes = process.platform === \"win32\" ? [\".cmd\", \".exe\", \"\"] : [\"\"];\n const managerAvailable = (process.env.PATH ?? \"\")\n .split(delimiter)\n .slice(0, 512)\n .some((directory) => suffixes.some((suffix) => existsSync(join(directory, manager + suffix))));\n add(\n managerAvailable ? \"PASS\" : \"WARN\",\n \"package-manager-availability\",\n managerAvailable\n ? `${manager} executable found on PATH (not executed)`\n : `Install ${manager} or add it to PATH`,\n );\n add(\"PASS\", \"module-format\", project.moduleFormat);\n if (await exists(join(project.root, \"tsconfig.json\"))) {\n const ts = (await import(\"typescript\")).default;\n const parsed = ts.readConfigFile(join(project.root, \"tsconfig.json\"), ts.sys.readFile);\n if (parsed.error) add(\"FAIL\", \"typescript\", \"Cannot parse tsconfig.json\");\n else {\n const config = ts.parseJsonConfigFileContent(parsed.config, ts.sys, project.root);\n const compiler = config.options;\n add(\n compiler.experimentalDecorators &&\n compiler.emitDecoratorMetadata &&\n compiler.useDefineForClassFields === false\n ? \"PASS\"\n : \"WARN\",\n \"typescript\",\n \"ORM entities require experimentalDecorators:true, emitDecoratorMetadata:true, useDefineForClassFields:false; source configs follow package module semantics; NodeNext is supported\",\n );\n }\n } else\n add(\n project.language === \"typescript\" ? \"WARN\" : \"SKIP\",\n \"typescript\",\n \"No tsconfig.json; use explicit fields with JavaScript decorator functions\",\n );\n if (project.configFiles.length === 1) {\n try {\n const { inspectStaticConfig, property } = await import(\"../init/static-config.js\");\n const { readFile } = await import(\"node:fs/promises\");\n const inspection = inspectStaticConfig(\n await readFile(join(project.root, project.configFiles[0]!), \"utf8\"),\n project.configFiles[0]!,\n );\n const ts = (await import(\"typescript\")).default;\n const packages = new Set([\"@duraxis/core\"]);\n for (const statement of inspection.ast.statements) {\n if (ts.isImportDeclaration(statement) && ts.isStringLiteral(statement.moduleSpecifier))\n packages.add(statement.moduleSpecifier.text);\n if (ts.isVariableStatement(statement))\n for (const declaration of statement.declarationList.declarations) {\n const call = declaration.initializer;\n if (\n call &&\n ts.isCallExpression(call) &&\n call.expression.getText(inspection.ast) === \"require\" &&\n call.arguments[0] &&\n ts.isStringLiteral(call.arguments[0])\n )\n packages.add(call.arguments[0].text);\n }\n }\n for (const connection of inspection.connections.values()) {\n if (property(connection, \"entities\") || property(connection, \"autoLoadEntities\"))\n packages.add(\"@duraxis/orm\");\n const migrations = property(connection, \"migrations\");\n if (migrations && migrations.initializer.kind !== ts.SyntaxKind.FalseKeyword)\n packages.add(\"@duraxis/migrations\");\n }\n if (project.nestjs) packages.add(\"@duraxis/nestjs\");\n for (const name of packages)\n if (name.startsWith(\"@duraxis/\"))\n add(\n available(project, name) ? \"PASS\" : \"FAIL\",\n `package:${name}`,\n `Runtime dependency ${name} must be installed in the application`,\n );\n add(\n \"PASS\",\n \"static-configuration\",\n `Connections: ${[...inspection.connections.keys()].join(\", \")}; no executable code evaluated`,\n );\n } catch {\n add(\n \"WARN\",\n \"static-configuration\",\n \"Dynamic or malformed configuration; inspect manually or use config:validate --evaluate for trusted code\",\n );\n }\n }\n add(\n project.configFiles.length ? \"WARN\" : \"FAIL\",\n \"configuration\",\n project.configFiles.length\n ? \"Executable configuration detected, not evaluated. Use config:validate --evaluate only for trusted code.\"\n : \"Run duraxis init\",\n );\n return checks;\n}\n","import { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { exists, readObject } from \"../init/project-detector.js\";\n\nexport async function installedPackage(\n root: string,\n name: string,\n): Promise<Record<string, unknown> | undefined> {\n if (!/^(?:@[a-z0-9._-]+\\/)?[a-z0-9][a-z0-9._-]*$/i.test(name)) return undefined;\n\n let directory = resolve(root);\n let plugAndPlay = false;\n while (true) {\n const path = join(directory, \"node_modules\", name, \"package.json\");\n if (await exists(path)) {\n const manifest = await readObject(path);\n return manifest.name === name ? manifest : undefined;\n }\n plugAndPlay ||= await exists(join(directory, \".pnp.cjs\"));\n if (dirname(directory) === directory) break;\n directory = dirname(directory);\n }\n\n // PnP installations have no node_modules tree; their active resolver owns lookup.\n // Otherwise, do not inherit packages available only to the CLI or a test loader.\n if (!plugAndPlay || !process.versions.pnp) return undefined;\n try {\n directory = dirname(createRequire(join(resolve(root), \"package.json\")).resolve(name));\n } catch {\n return undefined;\n }\n for (let depth = 0; depth < 12; depth++) {\n try {\n const manifest = await readObject(join(directory, \"package.json\"));\n if (manifest.name === name) return manifest;\n } catch (error) {\n if (!(error instanceof Error && \"code\" in error && error.code === \"ENOENT\")) throw error;\n }\n if (dirname(directory) === directory) break;\n directory = dirname(directory);\n }\n return undefined;\n}\n","import { compare, satisfies } from \"../dependencies/version-compatibility.js\";\nimport { diagnostics, available } from \"./doctor.command.js\";\nimport { installedPackage } from \"../dependencies/installed-package.js\";\nimport { configuredRegistry } from \"../dependencies/configured-registry.js\";\nimport { resolve, join, dirname, basename } from \"node:path\";\nimport { readFile } from \"node:fs/promises\";\nimport type { CLIIO } from \"../cli.js\";\nimport type { ParsedCommand } from \"../registry/argument-parser.js\";\nimport { detectProject, exists } from \"../init/project-detector.js\";\nimport { executeFiles, type FilePlan } from \"../filesystem/file-plan.js\";\nimport { resolveDependencies } from \"../dependencies/dependency-resolver.js\";\nimport { RegistryClient } from \"../dependencies/registry-client.js\";\nimport { installCommands, runProcess } from \"../dependencies/package-manager.js\";\nfunction plan(root: string): FilePlan {\n return {\n root,\n files: [],\n directories: [],\n warnings: [],\n dependencies: {},\n devDependencies: {},\n commands: [],\n };\n}\nfunction redact(value: unknown, seen = new WeakSet<object>(), depth = 0): unknown {\n if (depth > 16) return \"[unresolved: inspection depth limit]\";\n if (value && typeof value === \"object\") {\n if (seen.has(value)) return \"[circular/shared reference]\";\n seen.add(value);\n if (Array.isArray(value)) return value.map((item) => redact(item, seen, depth + 1));\n return Object.fromEntries(\n Object.entries(value).map(([key, item]) => [\n key,\n /secret|password|token|credential|signingkey|encryption|access[_-]?key|private[_-]?key|api[_-]?key|^keys?$/i.test(\n key,\n )\n ? \"[REDACTED]\"\n : redact(item, seen, depth + 1),\n ]),\n );\n }\n if (typeof value === \"function\") return \"[trusted function; not evaluated]\";\n if (typeof value === \"string\" && /^https?:/.test(value)) {\n try {\n const url = new URL(value);\n if (url.username || url.password || url.search) return \"[REDACTED URL]\";\n } catch {}\n }\n return value;\n}\nexport async function administer(parsed: ParsedCommand, io: CLIIO): Promise<unknown> {\n const { values, definition } = parsed;\n const cwd = values.directory\n ? resolve(io.cwd ?? process.cwd(), values.directory)\n : (io.cwd ?? process.cwd());\n const explicit = values.config ? resolve(cwd, values.config) : undefined;\n if (explicit && !(await exists(explicit)))\n throw new Error(\"Explicit configuration file does not exist\");\n const project = await detectProject(explicit ? dirname(explicit) : cwd);\n if (explicit) project.configFiles = [basename(explicit)];\n const root = project.root;\n let configuredDriver: string | undefined;\n if (project.configFiles.length === 1 && definition.name === \"storage:list\") {\n try {\n const { inspectStaticConfig, staticDriverInfo } = await import(\"../init/static-config.js\");\n const inspection = inspectStaticConfig(\n await readFile(explicit ?? join(project.root, project.configFiles[0]!), \"utf8\"),\n explicit ?? project.configFiles[0]!,\n );\n const object = inspection.connections.get(values.database ?? inspection.defaultConnection);\n if (object) configuredDriver = staticDriverInfo(inspection, object).driver;\n } catch {\n /* Dynamic configurations remain unresolved without evaluation. */\n }\n }\n if (definition.name === \"storage:list\")\n return [\n {\n driver: \"memory\",\n persistent: false,\n limitation: \"Process-local volatile data\",\n package: \"@duraxis/storage-memory\",\n },\n {\n driver: \"disk\",\n persistent: true,\n limitation: \"Single-owner local directory; recovery requires operator action\",\n package: \"@duraxis/storage-disk\",\n },\n {\n driver: \"s3\",\n persistent: true,\n limitation:\n \"Conditional-request-compatible provider required; destructive distributed GC unsupported\",\n package: \"@duraxis/storage-s3\",\n },\n {\n driver: \"custom\",\n persistent: \"implementation-dependent\",\n limitation: \"Conditional semantics and bounded reads required\",\n package: \"@duraxis/storage\",\n },\n ].map((driver) => ({\n ...driver,\n available: true,\n installed: available(project, driver.package),\n configured: configuredDriver === driver.driver,\n }));\n if (definition.name === \"doctor\") {\n const checks = await diagnostics(project);\n return { failed: checks.some((c) => c.level === \"FAIL\"), diagnostics: checks };\n }\n if (definition.name === \"upgrade\") {\n const installed = Object.fromEntries(\n Object.entries({ ...project.dependencies, ...project.devDependencies }).filter(([name]) =>\n name.startsWith(\"@duraxis/\"),\n ),\n );\n if (!Object.keys(installed).length)\n throw new Error(\"No Duraxis dependencies found in the selected project\");\n for (const [name, specification] of Object.entries(installed)) {\n try {\n satisfies(\"0.0.0\", specification);\n } catch {\n throw new Error(\n `Cannot upgrade unsupported dependency specification for ${name}; update workspace-owned versions with workspace release tooling, or use a supported registry version range`,\n );\n }\n }\n const resolved = await resolveDependencies(\n Object.keys(installed),\n { ...project.dependencies, ...project.devDependencies },\n new RegistryClient(await configuredRegistry(project, values.registry), io.fetch, io.signal),\n values.prerelease,\n process.versions.node,\n false,\n );\n const packages = await Promise.all(\n Object.keys(installed).map(async (name) => {\n const actual = (await installedPackage(root, name))?.version ?? installed[name];\n const downgradeBlocked =\n typeof actual === \"string\" &&\n /^v?\\d+\\.\\d+\\.\\d+(?:[-+]|$)/.test(actual) &&\n compare(resolved[name]!, actual) < 0;\n return {\n package: name,\n installed: actual,\n declaration: installed[name],\n target: resolved[name],\n downgradeBlocked,\n status: downgradeBlocked\n ? \"downgrade blocked\"\n : actual === resolved[name]\n ? \"up to date\"\n : \"update available\",\n };\n }),\n );\n if (!values.apply)\n return {\n packages,\n warning:\n \"Pre-1.0 minor updates may break compatibility. Review changelogs. No data format migration is performed.\",\n };\n if (packages.some((item) => item.downgradeBlocked))\n throw new Error(\n \"Automatic downgrades are unsupported; no dependencies were changed. Review the proposed versions and workspace release state manually.\",\n );\n const production = Object.fromEntries(\n packages\n .filter((p) => project.dependencies[p.package] && p.target !== p.installed)\n .map((p) => [p.package, p.target!]),\n );\n const development = Object.fromEntries(\n packages\n .filter((p) => project.devDependencies[p.package] && p.target !== p.installed)\n .map((p) => [p.package, p.target!]),\n );\n const update = plan(root);\n update.commands = installCommands(\n (await import(\"../init/project-detector.js\")).selectManager(\n project,\n values[\"package-manager\"],\n ),\n production,\n development,\n );\n io.signal?.throwIfAborted();\n await executeFiles(update, async () => {\n for (const [command, ...args] of update.commands)\n await (io.runProcess ?? runProcess)({\n command: command!,\n args,\n cwd: root,\n signal: io.signal,\n });\n io.signal?.throwIfAborted();\n });\n return {\n status: \"updated\",\n packages,\n warning: \"Review pre-1.0 changes before deployment. Database formats were not migrated.\",\n };\n }\n if (values.evaluate || (definition.name === \"storage:check\" && values.live)) {\n const { config } = await (\n await import(\"../config.js\")\n ).loadConfig(cwd, values.config, values.database);\n if (definition.name === \"config:show\")\n return { trustedCodeEvaluated: true, configuration: redact(config) };\n if (definition.name === \"config:validate\")\n return { valid: true, trustedCodeEvaluated: true, databaseOpened: false };\n if (definition.name === \"storage:check\") {\n if (project.configFiles.length === 1) {\n const { inspectStaticConfig, staticDriverInfo } = await import(\"../init/static-config.js\");\n let inspection: ReturnType<typeof inspectStaticConfig> | undefined;\n try {\n inspection = inspectStaticConfig(\n await readFile(explicit ?? join(project.root, project.configFiles[0]!), \"utf8\"),\n explicit ?? project.configFiles[0]!,\n );\n } catch {\n // --live already authorized the executable factory. Run dynamic\n // factory behavior when its storage path cannot be inspected statically.\n }\n if (inspection) {\n const connection = values.database ?? inspection.defaultConnection;\n const object = inspection.connections.get(connection);\n if (!object) throw new Error(\"Unknown named database\");\n const info = staticDriverInfo(inspection, object);\n if (info.driver === \"disk\") {\n const prefix =\n connection === \"default\"\n ? \"DURAXIS\"\n : `DURAXIS_${connection.toUpperCase().replace(/-/g, \"_\")}`;\n const directory = process.env[`${prefix}_STORAGE_DIRECTORY`] ?? info.directory;\n if (!directory || !(await exists(resolve(project.root, directory, \"journal.log\"))))\n throw new Error(\n \"Live Disk check requires an existing initialized directory; refusing to create database files\",\n );\n }\n }\n }\n const database = await config.createDatabase();\n try {\n await database.getCollectionDefinitions();\n return {\n valid: true,\n live: true,\n warning:\n \"Trusted factory executed. Disk ownership was temporarily acquired; normal driver recovery may occur. No test objects were written.\",\n };\n } finally {\n await database.close({ closeStorage: true });\n }\n }\n }\n const configPath =\n explicit ??\n (project.configFiles.length === 1 ? join(project.root, project.configFiles[0]!) : undefined);\n if (!configPath) throw new Error(\"Select a Duraxis configuration with --config, or run init\");\n return (await import(\"./minimal-admin.js\")).minimalAdmin(parsed, io, project, configPath, redact);\n}\n"],"mappings":";;;;;;;;AAUA,SAAgB,UAAU,SAAyB,MAAuB;CACxE,IACE,CAAC,QAAQ,aAAa,SACtB,CAAC,QAAQ,gBAAgB,SACzB,CAAC,WAAW,KAAK,QAAQ,MAAM,gBAAgB,IAAI,CAAC,GAEpD,OAAO;CACT,IAAI;EACF,MAAM,UAAU,cAAc,KAAK,QAAQ,MAAM,cAAc,CAAC;EAChE,IAAI,YAAY;EAChB,IAAI,YAAY,QAAQ;EACxB,OAAO,MAAM;GACX,IACE,WAAW,KAAK,WAAW,UAAU,CAAC,KACtC,WAAW,KAAK,WAAW,gBAAgB,IAAI,CAAC,GAChD;IACA,YAAY;IACZ;GACF;GACA,IAAI,QAAQ,SAAS,MAAM,WAAW;GACtC,YAAY,QAAQ,SAAS;EAC/B;EACA,IAAI,CAAC,WAAW,OAAO;EACvB,QAAQ,QAAQ,IAAI;EACpB,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;AACA,eAAsB,YAAY,SAAgD;CAChF,MAAM,SAAuB,CAAC;CAC9B,MAAM,OAAO,OAA4B,OAAe,YACtD,OAAO,KAAK;EAAE;EAAO;EAAO;CAAQ,CA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1B,MAAM,SACJ,eAAe,YACX,YACA,WAAW,WAAW,YAAY,CAAC,CAAC,QAAQ,MAAM,GAAG;MAC3D,MAAM,YAAY,QAAQ,IAAI,GAAG,OAAO,wBAAwB,KAAK;MACrE,IAAI,CAAC,aAAa,CAAE,MAAM,OAAO,QAAQ,QAAQ,MAAM,WAAW,aAAa,CAAC,GAC9E,MAAM,IAAI,MACR,+FACF;KACJ;IACF;GACF;GACA,MAAM,WAAW,MAAM,OAAO,eAAe;GAC7C,IAAI;IACF,MAAM,SAAS,yBAAyB;IACxC,OAAO;KACL,OAAO;KACP,MAAM;KACN,SACE;IACJ;GACF,UAAU;IACR,MAAM,SAAS,MAAM,EAAE,cAAc,KAAK,CAAC;GAC7C;EACF;CACF;CACA,MAAM,aACJ,aACC,QAAQ,YAAY,WAAW,IAAI,KAAK,QAAQ,MAAM,QAAQ,YAAY,EAAG,IAAI,KAAA;CACpF,IAAI,CAAC,YAAY,MAAM,IAAI,MAAM,2DAA2D;CAC5F,QAAQ,MAAM,OAAO,+BAAA,CAAuB,aAAa,QAAQ,IAAI,SAAS,YAAY,MAAM;AAClG"}
package/dist/cli.d.ts CHANGED
@@ -1,6 +1,13 @@
1
+ import type { ProcessRunner } from "./dependencies/package-manager.js";
2
+ import type { Prompt } from "./terminal/prompts.js";
1
3
  export interface CLIIO {
2
4
  readonly cwd?: string;
3
5
  readonly out?: (message: string) => void;
4
6
  readonly error?: (message: string) => void;
7
+ readonly fetch?: typeof fetch;
8
+ readonly runProcess?: ProcessRunner;
9
+ readonly prompt?: Prompt;
10
+ readonly interactive?: boolean;
11
+ readonly signal?: AbortSignal;
5
12
  }
6
13
  export declare function runCLI(args: readonly string[], io?: CLIIO): Promise<number>;
@@ -0,0 +1,3 @@
1
+ import type { CLIIO } from "../cli.js";
2
+ import type { ParsedCommand } from "../registry/argument-parser.js";
3
+ export declare function administer(parsed: ParsedCommand, io: CLIIO): Promise<unknown>;
@@ -0,0 +1,9 @@
1
+ import { type ProjectContext } from "../init/project-detector.js";
2
+ interface Diagnostic {
3
+ level: "PASS" | "WARN" | "FAIL" | "SKIP";
4
+ check: string;
5
+ message: string;
6
+ }
7
+ export declare function available(project: ProjectContext, name: string): boolean;
8
+ export declare function diagnostics(project: ProjectContext): Promise<Diagnostic[]>;
9
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { CLIIO } from "../cli.js";
2
+ import type { ParsedCommand } from "../registry/argument-parser.js";
3
+ export declare function initialize(parsed: ParsedCommand, io: CLIIO): Promise<unknown>;
@@ -0,0 +1,3 @@
1
+ import type { CLIIO } from "../cli.js";
2
+ import type { ParsedCommand } from "../registry/argument-parser.js";
3
+ export declare function executeMigration(parsed: ParsedCommand, io: CLIIO): Promise<number>;
@@ -0,0 +1,4 @@
1
+ import type { CLIIO } from "../cli.js";
2
+ import type { ParsedCommand } from "../registry/argument-parser.js";
3
+ import type { ProjectContext } from "../init/project-detector.js";
4
+ export declare function minimalAdmin(parsed: ParsedCommand, io: CLIIO, project: ProjectContext, path: string, redact: (value: unknown) => unknown): Promise<unknown>;