@zintrust/core 0.4.2 → 0.4.3
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/bin/zintrust-main.js +1 -1
- package/package.json +1 -1
- package/src/cli/OptionalCliExtensions.d.ts +14 -5
- package/src/cli/OptionalCliExtensions.d.ts.map +1 -1
- package/src/cli/OptionalCliExtensions.js +57 -18
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +24 -0
- package/src/index.js +3 -3
package/bin/zintrust-main.js
CHANGED
|
@@ -105,7 +105,7 @@ export async function run() {
|
|
|
105
105
|
try {
|
|
106
106
|
({ OptionalCliExtensions: optionalCliExtensions } =
|
|
107
107
|
await import('../src/cli/OptionalCliExtensions.js'));
|
|
108
|
-
optionalCliStatuses = await optionalCliExtensions.
|
|
108
|
+
optionalCliStatuses = await optionalCliExtensions.loadForArgs(args0);
|
|
109
109
|
}
|
|
110
110
|
catch {
|
|
111
111
|
// best-effort; missing optional extensions must not block the CLI
|
package/package.json
CHANGED
|
@@ -13,20 +13,29 @@ export type OptionalCliExtensionStatus = Readonly<{
|
|
|
13
13
|
loaded: boolean;
|
|
14
14
|
source: OptionalCliExtensionLoadSource;
|
|
15
15
|
}>;
|
|
16
|
+
type OptionalCliExtensionLoadOptions = Readonly<{
|
|
17
|
+
logFailures?: boolean;
|
|
18
|
+
}>;
|
|
16
19
|
export declare const OptionalCliExtensions: Readonly<{
|
|
17
20
|
tryImportInstalledExtensions(): Promise<OptionalCliExtensionStatus[]>;
|
|
21
|
+
loadForArgs(args: string[]): Promise<OptionalCliExtensionStatus[]>;
|
|
18
22
|
findMissingExtensionForArgs(args: string[], statuses: ReadonlyArray<OptionalCliExtensionStatus>): OptionalCliExtensionStatus | undefined;
|
|
19
23
|
getMissingExtensionMessage(status: OptionalCliExtensionStatus): string;
|
|
24
|
+
findRequestedExtension: (args: string[]) => OptionalCliExtension | undefined;
|
|
20
25
|
}>;
|
|
21
26
|
export declare const OptionalCliExtensionsInternal: Readonly<{
|
|
22
27
|
getProjectCwd: () => string;
|
|
23
28
|
resolveProjectRoot: () => string;
|
|
24
|
-
resolveProjectInstalledUrl: (entry: OptionalCliExtension) => string | null;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
resolveProjectInstalledUrl: (entry: OptionalCliExtension, options?: OptionalCliExtensionLoadOptions) => string | null;
|
|
30
|
+
shouldLogFailures: (options?: OptionalCliExtensionLoadOptions) => boolean;
|
|
31
|
+
debugFailure: (message: string, meta: Record<string, unknown>, options?: OptionalCliExtensionLoadOptions) => void;
|
|
32
|
+
tryImportProjectInstalledPackage: (entry: OptionalCliExtension, options?: OptionalCliExtensionLoadOptions) => Promise<boolean>;
|
|
33
|
+
tryImportLocalCandidate: (entry: OptionalCliExtension, options?: OptionalCliExtensionLoadOptions) => Promise<boolean>;
|
|
34
|
+
tryImportPackageSpecifier: (entry: OptionalCliExtension, options?: OptionalCliExtensionLoadOptions) => Promise<boolean>;
|
|
35
|
+
tryImportExtension: (entry: OptionalCliExtension, options?: OptionalCliExtensionLoadOptions) => Promise<OptionalCliExtensionStatus>;
|
|
29
36
|
getRequestedCommand: (args: string[]) => string | undefined;
|
|
37
|
+
findRequestedExtension: (args: string[]) => OptionalCliExtension | undefined;
|
|
38
|
+
isRootHelpRequest: (args: string[]) => boolean;
|
|
30
39
|
}>;
|
|
31
40
|
export {};
|
|
32
41
|
//# sourceMappingURL=OptionalCliExtensions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OptionalCliExtensions.d.ts","sourceRoot":"","sources":["../../../src/cli/OptionalCliExtensions.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,oBAAoB,GAAG;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB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,GAClD,0BAA0B,GAAG,SAAS;uCASN,0BAA0B,GAAG,MAAM;mCArDlC,MAAM,EAAE,KAAG,oBAAoB,GAAG,SAAS;EA8D/E,CAAC;AAEH,eAAO,MAAM,6BAA6B;yBAjShB,MAAM;8BAQD,MAAM;wCAsD5B,oBAAoB,YACjB,+BAA+B,KACxC,MAAM,GAAG,IAAI;kCAlDqB,+BAA+B,KAAG,OAAO;4BAMnE,MAAM,QACT,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YACnB,+BAA+B,KACxC,IAAI;8CA+DE,oBAAoB,YACjB,+BAA+B,KACxC,OAAO,CAAC,OAAO,CAAC;qCA0BV,oBAAoB,YACjB,+BAA+B,KACxC,OAAO,CAAC,OAAO,CAAC;uCAgCV,oBAAoB,YACjB,+BAA+B,KACxC,OAAO,CAAC,OAAO,CAAC;gCAuBV,oBAAoB,YACjB,+BAA+B,KACxC,OAAO,CAAC,0BAA0B,CAAC;gCAwCH,MAAM,EAAE,KAAG,MAAM,GAAG,SAAS;mCAU1B,MAAM,EAAE,KAAG,oBAAoB,GAAG,SAAS;8BAOhD,MAAM,EAAE,KAAG,OAAO;EAsEjD,CAAC"}
|
|
@@ -19,6 +19,16 @@ const resolveProjectRoot = () => {
|
|
|
19
19
|
return configured;
|
|
20
20
|
return getProjectCwd();
|
|
21
21
|
};
|
|
22
|
+
const shouldLogFailures = (options) => {
|
|
23
|
+
if (options?.logFailures === true)
|
|
24
|
+
return true;
|
|
25
|
+
return readEnvString('ZINTRUST_DEBUG_OPTIONAL_CLI_EXTENSIONS').trim() === '1';
|
|
26
|
+
};
|
|
27
|
+
const debugFailure = (message, meta, options) => {
|
|
28
|
+
if (!shouldLogFailures(options))
|
|
29
|
+
return;
|
|
30
|
+
Logger.debug(message, meta);
|
|
31
|
+
};
|
|
22
32
|
const OPTIONAL_CLI_EXTENSIONS = Object.freeze([
|
|
23
33
|
{
|
|
24
34
|
packageName: '@zintrust/d1-migrator',
|
|
@@ -51,7 +61,7 @@ const OPTIONAL_CLI_EXTENSIONS = Object.freeze([
|
|
|
51
61
|
],
|
|
52
62
|
},
|
|
53
63
|
]);
|
|
54
|
-
const resolveProjectInstalledUrl = (entry) => {
|
|
64
|
+
const resolveProjectInstalledUrl = (entry, options) => {
|
|
55
65
|
try {
|
|
56
66
|
const projectRoot = resolveProjectRoot();
|
|
57
67
|
const requireFromProject = createRequire(path.join(projectRoot, 'package.json'));
|
|
@@ -59,17 +69,17 @@ const resolveProjectInstalledUrl = (entry) => {
|
|
|
59
69
|
return pathToFileURL(resolved).href;
|
|
60
70
|
}
|
|
61
71
|
catch (error) {
|
|
62
|
-
|
|
72
|
+
debugFailure('[cli] Optional CLI extension not resolved from project root', {
|
|
63
73
|
packageName: entry.packageName,
|
|
64
74
|
specifier: entry.specifier,
|
|
65
75
|
projectRoot: resolveProjectRoot(),
|
|
66
76
|
error: error instanceof Error ? error.message : String(error),
|
|
67
|
-
});
|
|
77
|
+
}, options);
|
|
68
78
|
return null;
|
|
69
79
|
}
|
|
70
80
|
};
|
|
71
|
-
const tryImportProjectInstalledPackage = async (entry) => {
|
|
72
|
-
const resolvedUrl = resolveProjectInstalledUrl(entry);
|
|
81
|
+
const tryImportProjectInstalledPackage = async (entry, options) => {
|
|
82
|
+
const resolvedUrl = resolveProjectInstalledUrl(entry, options);
|
|
73
83
|
if (resolvedUrl === null)
|
|
74
84
|
return false;
|
|
75
85
|
try {
|
|
@@ -81,15 +91,15 @@ const tryImportProjectInstalledPackage = async (entry) => {
|
|
|
81
91
|
return true;
|
|
82
92
|
}
|
|
83
93
|
catch (error) {
|
|
84
|
-
|
|
94
|
+
debugFailure('[cli] Optional CLI extension project import failed', {
|
|
85
95
|
packageName: entry.packageName,
|
|
86
96
|
resolvedUrl,
|
|
87
97
|
error: error instanceof Error ? error.message : String(error),
|
|
88
|
-
});
|
|
98
|
+
}, options);
|
|
89
99
|
return false;
|
|
90
100
|
}
|
|
91
101
|
};
|
|
92
|
-
const tryImportLocalCandidate = async (entry) => {
|
|
102
|
+
const tryImportLocalCandidate = async (entry, options) => {
|
|
93
103
|
const existingCandidates = entry.localCandidates.filter((candidate) => existsSync(candidate));
|
|
94
104
|
if (existingCandidates.length === 0)
|
|
95
105
|
return false;
|
|
@@ -103,17 +113,17 @@ const tryImportLocalCandidate = async (entry) => {
|
|
|
103
113
|
return true;
|
|
104
114
|
}
|
|
105
115
|
catch (error) {
|
|
106
|
-
|
|
116
|
+
debugFailure('[cli] Optional CLI extension local fallback failed', {
|
|
107
117
|
packageName: entry.packageName,
|
|
108
118
|
candidate,
|
|
109
119
|
error: error instanceof Error ? error.message : String(error),
|
|
110
|
-
});
|
|
120
|
+
}, options);
|
|
111
121
|
return false;
|
|
112
122
|
}
|
|
113
123
|
}));
|
|
114
124
|
return results.some(Boolean);
|
|
115
125
|
};
|
|
116
|
-
const tryImportPackageSpecifier = async (entry) => {
|
|
126
|
+
const tryImportPackageSpecifier = async (entry, options) => {
|
|
117
127
|
try {
|
|
118
128
|
await import(entry.specifier);
|
|
119
129
|
Logger.debug('[cli] Loaded optional CLI extension package', {
|
|
@@ -123,16 +133,16 @@ const tryImportPackageSpecifier = async (entry) => {
|
|
|
123
133
|
return true;
|
|
124
134
|
}
|
|
125
135
|
catch (error) {
|
|
126
|
-
|
|
136
|
+
debugFailure('[cli] Optional CLI extension package not loaded', {
|
|
127
137
|
packageName: entry.packageName,
|
|
128
138
|
specifier: entry.specifier,
|
|
129
139
|
error: error instanceof Error ? error.message : String(error),
|
|
130
|
-
});
|
|
140
|
+
}, options);
|
|
131
141
|
return false;
|
|
132
142
|
}
|
|
133
143
|
};
|
|
134
|
-
const tryImportExtension = async (entry) => {
|
|
135
|
-
if (await tryImportProjectInstalledPackage(entry)) {
|
|
144
|
+
const tryImportExtension = async (entry, options) => {
|
|
145
|
+
if (await tryImportProjectInstalledPackage(entry, options)) {
|
|
136
146
|
return {
|
|
137
147
|
packageName: entry.packageName,
|
|
138
148
|
commands: [...entry.commands],
|
|
@@ -141,7 +151,7 @@ const tryImportExtension = async (entry) => {
|
|
|
141
151
|
source: 'project',
|
|
142
152
|
};
|
|
143
153
|
}
|
|
144
|
-
if (await tryImportPackageSpecifier(entry)) {
|
|
154
|
+
if (await tryImportPackageSpecifier(entry, options)) {
|
|
145
155
|
return {
|
|
146
156
|
packageName: entry.packageName,
|
|
147
157
|
commands: [...entry.commands],
|
|
@@ -150,7 +160,7 @@ const tryImportExtension = async (entry) => {
|
|
|
150
160
|
source: 'package',
|
|
151
161
|
};
|
|
152
162
|
}
|
|
153
|
-
if (await tryImportLocalCandidate(entry)) {
|
|
163
|
+
if (await tryImportLocalCandidate(entry, options)) {
|
|
154
164
|
return {
|
|
155
165
|
packageName: entry.packageName,
|
|
156
166
|
commands: [...entry.commands],
|
|
@@ -175,9 +185,33 @@ const getRequestedCommand = (args) => {
|
|
|
175
185
|
}
|
|
176
186
|
return typeof args[0] === 'string' && args[0].trim() !== '' ? args[0].trim() : undefined;
|
|
177
187
|
};
|
|
188
|
+
const findRequestedExtension = (args) => {
|
|
189
|
+
const requestedCommand = getRequestedCommand(args);
|
|
190
|
+
if (requestedCommand === undefined)
|
|
191
|
+
return undefined;
|
|
192
|
+
return OPTIONAL_CLI_EXTENSIONS.find((entry) => entry.commands.includes(requestedCommand));
|
|
193
|
+
};
|
|
194
|
+
const isRootHelpRequest = (args) => {
|
|
195
|
+
if (args.length === 0)
|
|
196
|
+
return true;
|
|
197
|
+
const first = typeof args[0] === 'string' ? args[0].trim() : '';
|
|
198
|
+
if (first === '' || first === '-h' || first === '--help')
|
|
199
|
+
return true;
|
|
200
|
+
return first === 'help' && getRequestedCommand(args) === undefined;
|
|
201
|
+
};
|
|
178
202
|
export const OptionalCliExtensions = Object.freeze({
|
|
179
203
|
async tryImportInstalledExtensions() {
|
|
180
|
-
return Promise.all(OPTIONAL_CLI_EXTENSIONS.map(tryImportExtension));
|
|
204
|
+
return Promise.all(OPTIONAL_CLI_EXTENSIONS.map(async (entry) => tryImportExtension(entry, { logFailures: false })));
|
|
205
|
+
},
|
|
206
|
+
async loadForArgs(args) {
|
|
207
|
+
const requestedExtension = findRequestedExtension(args);
|
|
208
|
+
if (requestedExtension !== undefined) {
|
|
209
|
+
return [await tryImportExtension(requestedExtension, { logFailures: false })];
|
|
210
|
+
}
|
|
211
|
+
if (isRootHelpRequest(args)) {
|
|
212
|
+
return Promise.all(OPTIONAL_CLI_EXTENSIONS.map(async (entry) => tryImportExtension(entry, { logFailures: false })));
|
|
213
|
+
}
|
|
214
|
+
return [];
|
|
181
215
|
},
|
|
182
216
|
findMissingExtensionForArgs(args, statuses) {
|
|
183
217
|
const requestedCommand = getRequestedCommand(args);
|
|
@@ -192,14 +226,19 @@ export const OptionalCliExtensions = Object.freeze({
|
|
|
192
226
|
`Install it and try again: ${status.installCommand}`,
|
|
193
227
|
].join(' ');
|
|
194
228
|
},
|
|
229
|
+
findRequestedExtension,
|
|
195
230
|
});
|
|
196
231
|
export const OptionalCliExtensionsInternal = Object.freeze({
|
|
197
232
|
getProjectCwd,
|
|
198
233
|
resolveProjectRoot,
|
|
199
234
|
resolveProjectInstalledUrl,
|
|
235
|
+
shouldLogFailures,
|
|
236
|
+
debugFailure,
|
|
200
237
|
tryImportProjectInstalledPackage,
|
|
201
238
|
tryImportLocalCandidate,
|
|
202
239
|
tryImportPackageSpecifier,
|
|
203
240
|
tryImportExtension,
|
|
204
241
|
getRequestedCommand,
|
|
242
|
+
findRequestedExtension,
|
|
243
|
+
isRootHelpRequest,
|
|
205
244
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"StartCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/StartCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAspBvF,eAAO,MAAM,YAAY;cACb,YAAY;EA6BtB,CAAC"}
|
|
@@ -79,6 +79,28 @@ const resolveRuntime = (options) => {
|
|
|
79
79
|
const raw = typeof options.runtime === 'string' ? options.runtime.trim() : '';
|
|
80
80
|
return raw === '' ? undefined : raw;
|
|
81
81
|
};
|
|
82
|
+
const resolveConfiguredRuntime = (options) => {
|
|
83
|
+
const cliRuntime = resolveRuntime(options);
|
|
84
|
+
if (cliRuntime !== undefined && cliRuntime !== 'auto')
|
|
85
|
+
return cliRuntime;
|
|
86
|
+
const envRuntime = readEnvString('RUNTIME').trim();
|
|
87
|
+
if (envRuntime === '' || envRuntime === 'auto')
|
|
88
|
+
return undefined;
|
|
89
|
+
return envRuntime;
|
|
90
|
+
};
|
|
91
|
+
const isCloudflareRuntimeRequest = (runtime) => {
|
|
92
|
+
if (typeof runtime !== 'string')
|
|
93
|
+
return false;
|
|
94
|
+
const normalized = runtime.trim().toLowerCase();
|
|
95
|
+
return normalized === 'cloudflare' || normalized === 'cloudflare-workers';
|
|
96
|
+
};
|
|
97
|
+
const assertCompatibleStartVariant = (variant, configuredRuntime) => {
|
|
98
|
+
if (variant !== 'node')
|
|
99
|
+
return;
|
|
100
|
+
if (!isCloudflareRuntimeRequest(configuredRuntime))
|
|
101
|
+
return;
|
|
102
|
+
throw ErrorFactory.createCliError('Error: Cloudflare runtime requires Wrangler dev mode. Run "zin start --wg" (or "zin s --wg") instead of plain "zin start".');
|
|
103
|
+
};
|
|
82
104
|
const resolveStartVariant = (options) => {
|
|
83
105
|
const wantWrangler = options.wrangler === true || options.wg === true;
|
|
84
106
|
const wantDeno = options.deno === true;
|
|
@@ -423,6 +445,7 @@ const executeStart = async (options, cmd) => {
|
|
|
423
445
|
const mode = resolveMode(options);
|
|
424
446
|
const port = resolvePort(options);
|
|
425
447
|
const runtime = resolveRuntime(options);
|
|
448
|
+
const configuredRuntime = resolveConfiguredRuntime(options);
|
|
426
449
|
const variant = resolveStartVariant(options);
|
|
427
450
|
const envName = typeof options.env === 'string' ? options.env.trim() : '';
|
|
428
451
|
let effectiveRuntime = runtime;
|
|
@@ -434,6 +457,7 @@ const executeStart = async (options, cmd) => {
|
|
|
434
457
|
await executeSplitStart(cmd, cwd, options);
|
|
435
458
|
return;
|
|
436
459
|
}
|
|
460
|
+
assertCompatibleStartVariant(variant, configuredRuntime);
|
|
437
461
|
const cacheEnabled = resolveCacheEnabledPreference(options);
|
|
438
462
|
EnvFileLoader.applyCliOverrides({
|
|
439
463
|
nodeEnv: mode,
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.4.
|
|
2
|
+
* @zintrust/core v0.4.3
|
|
3
3
|
*
|
|
4
4
|
* ZinTrust Framework - Production-Grade TypeScript Backend
|
|
5
5
|
* Built for performance, type safety, and exceptional developer experience
|
|
6
6
|
*
|
|
7
7
|
* Build Information:
|
|
8
|
-
* Built: 2026-03-
|
|
8
|
+
* Built: 2026-03-20T12:13:34.410Z
|
|
9
9
|
* Node: >=20.0.0
|
|
10
10
|
* License: MIT
|
|
11
11
|
*
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* Available at runtime for debugging and health checks
|
|
22
22
|
*/
|
|
23
23
|
export const ZINTRUST_VERSION = '0.1.41';
|
|
24
|
-
export const ZINTRUST_BUILD_DATE = '2026-03-
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-03-20T12:13:34.378Z'; // Replaced during build
|
|
25
25
|
export { Application } from './boot/Application.js';
|
|
26
26
|
export { AwsSigV4 } from './common/index.js';
|
|
27
27
|
export { SignedRequest } from './security/SignedRequest.js';
|