@duraxis/cli 0.4.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/README.md +9 -23
- package/dist/admin.command-Dt5MnwJw.js +299 -0
- package/dist/admin.command-Dt5MnwJw.js.map +1 -0
- package/dist/commands/doctor.command.d.ts +1 -2
- package/dist/commands/minimal-admin.d.ts +4 -0
- package/dist/{config-CjMUqEhV.js → config-BKscNXeW.js} +53 -14
- package/dist/config-BKscNXeW.js.map +1 -0
- package/dist/config.d.ts +4 -6
- package/dist/file-plan-D-Sj3yv0.js +130 -0
- package/dist/file-plan-D-Sj3yv0.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/init/initialization-planner.d.ts +6 -3
- package/dist/init/nest-integration.d.ts +2 -0
- package/dist/init/static-config.d.ts +16 -0
- package/dist/{init.command-B2kKoyfi.js → init.command-DrO29773.js} +12 -17
- package/dist/init.command-DrO29773.js.map +1 -0
- package/dist/initialization-planner-B41PNGWc.js +315 -0
- package/dist/initialization-planner-B41PNGWc.js.map +1 -0
- package/dist/{migration.command-N7ahyx92.js → migration.command-dhRbN4UI.js} +4 -4
- package/dist/{migration.command-N7ahyx92.js.map → migration.command-dhRbN4UI.js.map} +1 -1
- package/dist/minimal-admin-B4ur_cON.js +232 -0
- package/dist/minimal-admin-B4ur_cON.js.map +1 -0
- package/dist/nest-integration-KCc7ZaG6.js +93 -0
- package/dist/nest-integration-KCc7ZaG6.js.map +1 -0
- package/dist/package-manager-Ca5ArUf-.js +269 -0
- package/dist/package-manager-Ca5ArUf-.js.map +1 -0
- package/dist/project-detector-BQWeQZ8Q.js +174 -0
- package/dist/project-detector-BQWeQZ8Q.js.map +1 -0
- package/dist/static-config-g_7qN12_.js +109 -0
- package/dist/static-config-g_7qN12_.js.map +1 -0
- package/dist/templates/project.d.ts +3 -1
- package/package.json +6 -6
- package/dist/admin.command-Chb6x9mF.js +0 -413
- package/dist/admin.command-Chb6x9mF.js.map +0 -1
- package/dist/config-CjMUqEhV.js.map +0 -1
- package/dist/init/managed-project.d.ts +0 -9
- package/dist/init.command-B2kKoyfi.js.map +0 -1
- package/dist/package-manager-BBRBhsIe.js +0 -972
- package/dist/package-manager-BBRBhsIe.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @duraxis/cli
|
|
2
2
|
|
|
3
|
+
## 0.5.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [bb8ec3f]
|
|
8
|
+
- @duraxis/orm@0.5.1
|
|
9
|
+
|
|
10
|
+
## 0.5.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 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.
|
|
15
|
+
|
|
16
|
+
## 0.5.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- 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.
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- Updated dependencies [6377fde]
|
|
25
|
+
- @duraxis/core@0.5.0
|
|
26
|
+
- @duraxis/orm@0.5.0
|
|
27
|
+
- @duraxis/migrations@0.3.1
|
|
28
|
+
|
|
3
29
|
## 0.4.0
|
|
4
30
|
|
|
5
31
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -21,39 +21,25 @@ pnpm exec duraxis migrate:up
|
|
|
21
21
|
pnpm exec duraxis doctor
|
|
22
22
|
```
|
|
23
23
|
|
|
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.
|
|
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.
|
|
25
25
|
|
|
26
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.
|
|
27
27
|
|
|
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`,
|
|
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.
|
|
29
29
|
|
|
30
30
|
## Configuration and loading
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
`duraxis.config.mts`, `duraxis.config.js`, `duraxis.config.mjs`,
|
|
34
|
-
`duraxis.config.cts`, or `duraxis.config.cjs`. `--config <path>` overrides discovery.
|
|
35
|
-
Migration and snapshot directories resolve relative to the config file. Paths
|
|
36
|
-
inside your database factory are your responsibility; use `import.meta.url` as
|
|
37
|
-
above instead of depending on the command's working directory.
|
|
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.
|
|
38
33
|
|
|
39
|
-
`
|
|
40
|
-
project-specific entity discovery. `migrations.format` is `ts` (default) or `js`.
|
|
41
|
-
A `databases` object can hold named connection configs with a required `createDatabase` factory and optional `entities`/`migrations`. Select one with `--database <name>`;
|
|
42
|
-
the top-level connection is the default.
|
|
43
|
-
|
|
44
|
-
The factory returns an owned Core database, not a NestJS connection. The CLI closes
|
|
45
|
-
that database and storage in a `finally` block. Factories must clean up resources
|
|
46
|
-
if they fail before returning. Do not pass an application-owned connection to
|
|
47
|
-
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.
|
|
48
35
|
|
|
49
36
|
Duraxis registers synchronous Node.js `registerHooks()` before loading a config,
|
|
50
37
|
entity, or migration, including programmatic `loadConfig()` calls. No manual
|
|
51
38
|
loader registration, experimental Node flags, or extra runtime transpiler is
|
|
52
|
-
required. Native type stripping alone cannot implement
|
|
39
|
+
required. Native type stripping alone cannot implement TypeScript decorators.
|
|
53
40
|
|
|
54
41
|
Supported configuration formats are `.ts`, `.mts`, `.js`, `.mjs`, `.cts`, and
|
|
55
|
-
`.cjs`. Discovery checks those extensions in that order. `.ts`
|
|
56
|
-
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
|
|
57
43
|
package/module semantics. Executable migration artifacts support ESM `.ts`,
|
|
58
44
|
`.mts`, `.js`, and `.mjs`; CommonJS migration artifacts are unsupported because
|
|
59
45
|
their executable form does not share the ESM checksum identity contract.
|
|
@@ -73,7 +59,7 @@ usual `reflect-metadata` dependency before decorated modules. Entity columns
|
|
|
73
59
|
should declare their Core `type` explicitly. `tsconfig.json` path aliases,
|
|
74
60
|
custom compiler plugins, `.tsx`/`.jsx`, and TypeScript package sources inside
|
|
75
61
|
`node_modules` are not supported. Use relative imports or published package exports.
|
|
76
|
-
|
|
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.
|
|
77
63
|
Config files and migrations are trusted executable code; keep module initialization
|
|
78
64
|
free of database writes and external side effects.
|
|
79
65
|
|
|
@@ -108,7 +94,7 @@ and JSON errors on stderr. Initialization prompts on a terminal unless `--yes` i
|
|
|
108
94
|
|
|
109
95
|
| Command | Behavior and options |
|
|
110
96
|
| ------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
111
|
-
| `init` | Creates
|
|
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. |
|
|
112
98
|
| `migration:create <name>` | Creates a throwing manual template. Complete it and provide an expected snapshot before use. |
|
|
113
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. |
|
|
114
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. |
|
|
@@ -180,7 +166,7 @@ checksum mismatches, and divergent chains are rejected. Production should contai
|
|
|
180
166
|
one executable format per migration, not both `.ts` and `.js` copies.
|
|
181
167
|
|
|
182
168
|
Artifact checksums normalize executable code with pinned TypeScript 5.9.3 (two
|
|
183
|
-
passes, ES2022 ESM, comments removed,
|
|
169
|
+
passes, ES2022 ESM, comments removed, TypeScript decorators, metadata enabled,
|
|
184
170
|
`useDefineForClassFields: false`). Compiled migrations must preserve this target
|
|
185
171
|
and ESM module form. Comments/types/formatting do not change identity; executable
|
|
186
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,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ectContext } from "../init/project-detector.js";
|
|
2
|
-
import type { ManagedProject } from "../init/managed-project.js";
|
|
3
2
|
interface Diagnostic {
|
|
4
3
|
level: "PASS" | "WARN" | "FAIL" | "SKIP";
|
|
5
4
|
check: string;
|
|
6
5
|
message: string;
|
|
7
6
|
}
|
|
8
7
|
export declare function available(project: ProjectContext, name: string): boolean;
|
|
9
|
-
export declare function diagnostics(project: ProjectContext
|
|
8
|
+
export declare function diagnostics(project: ProjectContext): Promise<Diagnostic[]>;
|
|
10
9
|
export {};
|
|
@@ -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>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D8jQpDG7.js";
|
|
2
2
|
import { access, readFile } from "node:fs/promises";
|
|
3
|
-
import { dirname, extname, resolve } from "node:path";
|
|
3
|
+
import { dirname, extname, join, resolve } from "node:path";
|
|
4
4
|
import { readFileSync, statSync } from "node:fs";
|
|
5
5
|
import { registerHooks } from "node:module";
|
|
6
6
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
7
7
|
import ts from "typescript";
|
|
8
|
+
import { createDatabase, normalizeDuraxisConnection, selectDuraxisConnection } from "@duraxis/core";
|
|
9
|
+
import { discoverEntities } from "@duraxis/orm";
|
|
8
10
|
// src/runtime.mjs
|
|
9
11
|
var MINIMUM_NODE_VERSION = "24.15.0";
|
|
10
12
|
/** Reject unsupported runtimes before importing the CLI and its Node.js APIs. */
|
|
@@ -74,14 +76,29 @@ function initializeTypeScriptLoader(entry) {
|
|
|
74
76
|
if (!file) return nextLoad(url, context);
|
|
75
77
|
const path = fileURLToPath(file);
|
|
76
78
|
if (!/\.(?:ts|mts|cts)$/.test(path) || /\.d\.(?:ts|mts|cts)$/.test(path)) return nextLoad(url, context);
|
|
77
|
-
|
|
79
|
+
let commonjs = path.endsWith(".cts");
|
|
80
|
+
if (path.endsWith(".ts")) {
|
|
81
|
+
let directory = dirname(path);
|
|
82
|
+
while (true) {
|
|
83
|
+
try {
|
|
84
|
+
commonjs = JSON.parse(readFileSync(join(directory, "package.json"), "utf8")).type !== "module";
|
|
85
|
+
break;
|
|
86
|
+
} catch (error) {
|
|
87
|
+
if (error.code !== "ENOENT") throw error;
|
|
88
|
+
}
|
|
89
|
+
if (dirname(directory) === directory) {
|
|
90
|
+
commonjs = true;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
directory = dirname(directory);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
78
96
|
const result = ts.transpileModule(readFileSync(file, "utf8"), {
|
|
79
97
|
fileName: path,
|
|
80
98
|
reportDiagnostics: true,
|
|
81
99
|
compilerOptions: {
|
|
82
100
|
target: ts.ScriptTarget.ES2022,
|
|
83
|
-
module: commonjs ? ts.ModuleKind.
|
|
84
|
-
...commonjs ? { moduleResolution: ts.ModuleResolutionKind.NodeNext } : {},
|
|
101
|
+
module: commonjs ? ts.ModuleKind.CommonJS : ts.ModuleKind.ESNext,
|
|
85
102
|
experimentalDecorators: true,
|
|
86
103
|
emitDecoratorMetadata: true,
|
|
87
104
|
useDefineForClassFields: false,
|
|
@@ -109,9 +126,6 @@ function disposeTypeScriptLoader() {
|
|
|
109
126
|
}
|
|
110
127
|
// src/config.ts
|
|
111
128
|
var config_exports = /* @__PURE__ */ __exportAll({ loadConfig: () => loadConfig });
|
|
112
|
-
function defineDuraxisConfig(config) {
|
|
113
|
-
return config;
|
|
114
|
-
}
|
|
115
129
|
async function importFile(path) {
|
|
116
130
|
const url = path instanceof URL ? path : pathToFileURL(path);
|
|
117
131
|
initializeTypeScriptLoader(url);
|
|
@@ -140,17 +154,42 @@ async function loadConfig(cwd, explicit, database) {
|
|
|
140
154
|
if (error.code != "ENOENT") throw error;
|
|
141
155
|
}
|
|
142
156
|
}
|
|
157
|
+
if (!path) {
|
|
158
|
+
const project = await (await import("./project-detector-BQWeQZ8Q.js")).detectProject(directory, true);
|
|
159
|
+
if (project.configFiles.length > 1) throw new Error("Multiple Duraxis configurations found; select one with --config");
|
|
160
|
+
if (project.configFiles.length === 1) path = resolve(directory, project.configFiles[0]);
|
|
161
|
+
}
|
|
143
162
|
if (path || dirname(directory) == directory) break;
|
|
144
163
|
directory = dirname(directory);
|
|
145
164
|
}
|
|
146
165
|
}
|
|
147
166
|
if (!path) throw new Error("No duraxis.config.ts or JavaScript configuration found");
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
if (!
|
|
167
|
+
let base = (await importFile(path)).default;
|
|
168
|
+
if (base && "default" in base) base = base.default;
|
|
169
|
+
if (!base || typeof base !== "object" || !("driver" in base) && !("connections" in base)) throw new Error("Invalid Duraxis configuration; configure a driver or named connections");
|
|
170
|
+
const selected = selectDuraxisConnection(base, database);
|
|
171
|
+
const options = normalizeDuraxisConnection({
|
|
172
|
+
...selected,
|
|
173
|
+
location: selected.location ?? path
|
|
174
|
+
});
|
|
175
|
+
const context = options.context;
|
|
176
|
+
const moduleFormat = /\.[cm][jt]s$/.test(path) ? /\.c[jt]s$/.test(path) ? "cjs" : "esm" : (await (await import("./project-detector-BQWeQZ8Q.js")).detectProject(context.root, true)).moduleFormat;
|
|
177
|
+
let discover = discoverEntities;
|
|
178
|
+
if (moduleFormat === "cjs" && (options.entities !== void 0 || options.autoLoadEntities)) discover = (await import("node:module")).createRequire(path)("@duraxis/orm").discoverEntities;
|
|
151
179
|
return {
|
|
152
|
-
config
|
|
153
|
-
|
|
180
|
+
config: {
|
|
181
|
+
settings: {
|
|
182
|
+
...selected,
|
|
183
|
+
database: options.database,
|
|
184
|
+
schema: options.schema,
|
|
185
|
+
migrations: options.migrations
|
|
186
|
+
},
|
|
187
|
+
createDatabase: () => createDatabase(options),
|
|
188
|
+
...options.entities !== void 0 || options.autoLoadEntities ? { entities: () => discover(options, (url) => importFile(url)) } : {},
|
|
189
|
+
...options.migrations ? { migrations: options.migrations } : {},
|
|
190
|
+
moduleFormat
|
|
191
|
+
},
|
|
192
|
+
root: context.root,
|
|
154
193
|
path
|
|
155
194
|
};
|
|
156
195
|
}
|
|
@@ -160,6 +199,6 @@ async function readJSON(path) {
|
|
|
160
199
|
function requireMigrationConfig(config) {
|
|
161
200
|
if (!config.migrations) throw new Error("Migrations are disabled for this connection. Enable them before running migration commands.");
|
|
162
201
|
}
|
|
163
|
-
export {
|
|
202
|
+
export { requireMigrationConfig as a, readJSON as i, importFile as n, disposeTypeScriptLoader as o, loadConfig as r, config_exports as t };
|
|
164
203
|
|
|
165
|
-
//# sourceMappingURL=config-
|
|
204
|
+
//# sourceMappingURL=config-BKscNXeW.js.map
|