@zintrust/core 0.4.53 → 0.4.55
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/package.json +1 -1
- package/src/boot/registry/runtime.d.ts.map +1 -1
- package/src/boot/registry/runtime.js +19 -7
- package/src/boot.d.ts.map +1 -1
- package/src/boot.js +5 -29
- package/src/cli/commands/StartCommand.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +36 -28
- package/src/cli/commands/runner/index.d.ts +1 -0
- package/src/cli/commands/runner/index.d.ts.map +1 -1
- package/src/cli/commands/runner/index.js +9 -0
- package/src/index.js +3 -3
- package/src/runtime/NodeStartup.d.ts +14 -0
- package/src/runtime/NodeStartup.d.ts.map +1 -0
- package/src/runtime/NodeStartup.js +39 -0
- package/src/runtime/ProjectBootstrap.d.ts.map +1 -1
- package/src/runtime/ProjectBootstrap.js +14 -5
- package/src/start.d.ts.map +1 -1
- package/src/start.js +4 -0
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/boot/registry/runtime.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAOvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAuO9C,eAAO,MAAM,8BAA8B,GAAI,iBAAiB,gBAAgB,KAAG,IA4BlF,CAAC;AAsPF,eAAO,MAAM,eAAe,GAAI,QAAQ;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,eAAe,EAAE,gBAAgB,CAAC;IAClC,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,SAAS,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC,KAAG;IAAE,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CA+E7D,CAAC"}
|
|
@@ -61,13 +61,17 @@ const loadLocalSystemDebuggerModule = async () => {
|
|
|
61
61
|
return tryImportOptional('@runtime/plugins/system-debugger-runtime');
|
|
62
62
|
};
|
|
63
63
|
const loadRuntimeQueueConfig = async () => {
|
|
64
|
+
const startupQueueConfig = getStartupQueueConfig();
|
|
65
|
+
if (startupQueueConfig !== undefined) {
|
|
66
|
+
return startupQueueConfig;
|
|
67
|
+
}
|
|
64
68
|
try {
|
|
65
69
|
const modulePath = '@runtime-config/queue';
|
|
66
70
|
const loaded = (await import(modulePath));
|
|
67
|
-
return loaded.default ??
|
|
71
|
+
return loaded.default ?? getQueueConfig();
|
|
68
72
|
}
|
|
69
73
|
catch {
|
|
70
|
-
return
|
|
74
|
+
return getQueueConfig();
|
|
71
75
|
}
|
|
72
76
|
};
|
|
73
77
|
const readRuntimeConfig = (key, fallback) => {
|
|
@@ -79,6 +83,14 @@ const readRuntimeConfig = (key, fallback) => {
|
|
|
79
83
|
return fallback;
|
|
80
84
|
}
|
|
81
85
|
};
|
|
86
|
+
const getStartupQueueConfig = () => {
|
|
87
|
+
const startupQueueConfig = StartupConfigFileRegistry.get?.(StartupConfigFile.Queue);
|
|
88
|
+
return startupQueueConfig ?? undefined;
|
|
89
|
+
};
|
|
90
|
+
const getQueueConfig = () => {
|
|
91
|
+
return (getStartupQueueConfig() ??
|
|
92
|
+
readRuntimeConfig('queueConfig', RuntimeConfig.queueConfig));
|
|
93
|
+
};
|
|
82
94
|
const appConfig = readRuntimeConfig('appConfig', {
|
|
83
95
|
port: 7777,
|
|
84
96
|
dockerWorker: false,
|
|
@@ -86,7 +98,6 @@ const appConfig = readRuntimeConfig('appConfig', {
|
|
|
86
98
|
});
|
|
87
99
|
// exported solely for tests to exercise the default detectRuntime handler
|
|
88
100
|
const cacheConfig = readRuntimeConfig('cacheConfig', RuntimeConfig.cacheConfig);
|
|
89
|
-
const queueConfig = readRuntimeConfig('queueConfig', RuntimeConfig.queueConfig);
|
|
90
101
|
const storageConfig = readRuntimeConfig('storageConfig', RuntimeConfig.storageConfig);
|
|
91
102
|
const getDatabaseConfig = () => {
|
|
92
103
|
return readRuntimeConfig('databaseConfig', liveDatabaseConfig);
|
|
@@ -96,7 +107,7 @@ const dbLoader = async () => {
|
|
|
96
107
|
registerDatabasesFromRuntimeConfig(getDatabaseConfig());
|
|
97
108
|
};
|
|
98
109
|
const queuesLoader = async () => {
|
|
99
|
-
await registerQueuesFromRuntimeConfig(
|
|
110
|
+
await registerQueuesFromRuntimeConfig(getQueueConfig());
|
|
100
111
|
};
|
|
101
112
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
102
113
|
const cachesLoader = async () => {
|
|
@@ -225,8 +236,9 @@ const initializeArtifactDirectories = async (resolvedBasePath) => {
|
|
|
225
236
|
}
|
|
226
237
|
}
|
|
227
238
|
};
|
|
228
|
-
const extractRedisConfigFromQueueConfig = () => {
|
|
229
|
-
const redisConfig =
|
|
239
|
+
const extractRedisConfigFromQueueConfig = (runtimeQueueConfig) => {
|
|
240
|
+
const redisConfig = (runtimeQueueConfig ?? getQueueConfig())
|
|
241
|
+
.drivers?.redis ?? {};
|
|
230
242
|
const redisHost = typeof redisConfig['host'] === 'string' ? redisConfig['host'] : '127.0.0.1';
|
|
231
243
|
const redisPort = typeof redisConfig['port'] === 'number' && Number.isFinite(redisConfig['port'])
|
|
232
244
|
? redisConfig['port']
|
|
@@ -277,7 +289,7 @@ const initializeQueueMonitor = async (router) => {
|
|
|
277
289
|
Logger.debug('Queue Monitor is enabled in configuration but module failed to load or is invalid. Skipping Queue Monitor initialization.');
|
|
278
290
|
return;
|
|
279
291
|
}
|
|
280
|
-
const redisConfig = extractRedisConfigFromQueueConfig();
|
|
292
|
+
const redisConfig = extractRedisConfigFromQueueConfig(runQueueConfig);
|
|
281
293
|
const { QueueMonitor } = queueMonitorModule;
|
|
282
294
|
const resolveKnownQueues = async () => {
|
|
283
295
|
try {
|
package/src/boot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../../src/boot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../../src/boot.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC"}
|
package/src/boot.js
CHANGED
|
@@ -1,30 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const projectRoot = await resolveNodeProjectRoot();
|
|
7
|
-
if ((process.env?.['ZINTRUST_PROJECT_ROOT'] ?? '').trim() === '') {
|
|
8
|
-
process.env['ZINTRUST_PROJECT_ROOT'] = projectRoot;
|
|
9
|
-
}
|
|
10
|
-
const [{ EnvFileLoader }, { Logger }, { existsSync }, path] = await Promise.all([
|
|
11
|
-
import('./cli/utils/EnvFileLoader.js'),
|
|
12
|
-
import('./config/logger.js'),
|
|
13
|
-
import('./node-singletons/fs.js'),
|
|
14
|
-
import('./node-singletons/path.js'),
|
|
15
|
-
]);
|
|
16
|
-
const state = EnvFileLoader.ensureLoaded({
|
|
17
|
-
cwd: projectRoot,
|
|
18
|
-
includeCwd: true,
|
|
19
|
-
});
|
|
20
|
-
if (state.loadedFiles.length > 0)
|
|
21
|
-
return;
|
|
22
|
-
const resolvedDotEnv = path.join(projectRoot, '.env');
|
|
23
|
-
Logger.warn('Node bootstrap started without loaded env files.', {
|
|
24
|
-
projectRoot,
|
|
25
|
-
resolvedDotEnv: existsSync(resolvedDotEnv) ? resolvedDotEnv : 'missing',
|
|
26
|
-
entry: '@zintrust/core/boot',
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
await ensureNodeBootstrapEnv();
|
|
1
|
+
import { ensureNodeStartupEnvLoaded } from './runtime/NodeStartup.js';
|
|
2
|
+
await ensureNodeStartupEnvLoaded({
|
|
3
|
+
entry: '@zintrust/core/boot',
|
|
4
|
+
warnOnMissingEnv: true,
|
|
5
|
+
});
|
|
30
6
|
await import('./boot/bootstrap.js');
|
|
@@ -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;AAggCvF,eAAO,MAAM,YAAY;cACb,YAAY;;mCAp8BU,MAAM,KAAG,OAAO;4CAaP,MAAM,KAAG,MAAM;4CA4Bf,MAAM,KAAG,OAAO;sCAetB,MAAM,WAAW,MAAM,KAAG,OAAO;oCAmBnC,MAAM,KAAG,OAAO;;EAo6BjD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseCommand } from '../BaseCommand.js';
|
|
2
2
|
import { withWranglerDevVarsSnapshot } from '../cloudflare/CloudflareWranglerDevEnv.js';
|
|
3
|
-
import { createDenoRunnerSource, createLambdaRunnerSource } from '../commands/runner/index.js';
|
|
3
|
+
import { createDenoRunnerSource, createLambdaRunnerSource, createNodeRunnerSource, } from '../commands/runner/index.js';
|
|
4
4
|
import { EnvFileLoader } from '../utils/EnvFileLoader.js';
|
|
5
5
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
6
6
|
import { readEnvString } from '../../common/ExternalServiceUtils.js';
|
|
@@ -415,17 +415,25 @@ const resolveRuntimeStartModuleSpecifier = (cwd) => {
|
|
|
415
415
|
}
|
|
416
416
|
return '@zintrust/core/start';
|
|
417
417
|
};
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
return
|
|
422
|
-
}
|
|
423
|
-
const bootstrap = resolveBootstrapEntryTs(cwd);
|
|
424
|
-
if (bootstrap !== undefined) {
|
|
425
|
-
return { command: 'tsx', args: ['watch', bootstrap] };
|
|
418
|
+
const resolveRuntimeCompiledStartModuleSpecifier = (cwd) => {
|
|
419
|
+
const localCompiledStart = path.join(cwd, 'dist', 'src', 'start.js');
|
|
420
|
+
if (existsSync(localCompiledStart)) {
|
|
421
|
+
return '../dist/src/start.js';
|
|
426
422
|
}
|
|
427
|
-
|
|
428
|
-
|
|
423
|
+
return '@zintrust/core/start';
|
|
424
|
+
};
|
|
425
|
+
const hasNodeSourceEntrypoint = (cwd) => {
|
|
426
|
+
return resolveBootstrapEntryTs(cwd) !== undefined || existsSync(path.join(cwd, 'src/index.ts'));
|
|
427
|
+
};
|
|
428
|
+
const ensureNodeSourceRunner = (cwd) => {
|
|
429
|
+
return ensureTmpRunnerFile(cwd, 'zin-start-node.ts', createNodeRunnerSource(resolveRuntimeStartModuleSpecifier(cwd)));
|
|
430
|
+
};
|
|
431
|
+
const ensureNodeCompiledRunner = (cwd) => {
|
|
432
|
+
return ensureTmpRunnerFile(cwd, 'zin-start-node.mjs', createNodeRunnerSource(resolveRuntimeCompiledStartModuleSpecifier(cwd)));
|
|
433
|
+
};
|
|
434
|
+
const resolveNodeDevCommand = (cwd, packageJson) => {
|
|
435
|
+
if (isFrameworkRepo(packageJson) || hasNodeSourceEntrypoint(cwd)) {
|
|
436
|
+
return { command: 'tsx', args: ['watch', ensureNodeSourceRunner(cwd)] };
|
|
429
437
|
}
|
|
430
438
|
// Fallback: if the app provides a dev script, run it.
|
|
431
439
|
// IMPORTANT: avoid calling `npm run dev` when the dev script itself invokes `zin`/`zintrust`
|
|
@@ -440,24 +448,16 @@ const resolveNodeDevCommand = (cwd, packageJson) => {
|
|
|
440
448
|
};
|
|
441
449
|
const resolveNodeProdCommand = (cwd) => {
|
|
442
450
|
const compiledBoot = path.join(cwd, 'dist/src/boot/bootstrap.js');
|
|
443
|
-
let compiled;
|
|
444
451
|
if (existsSync(compiledBoot) && !runFromSource()) {
|
|
445
|
-
|
|
452
|
+
return { command: 'node', args: [ensureNodeCompiledRunner(cwd)] };
|
|
446
453
|
}
|
|
447
454
|
// If compiled app isn't available (or the env forces running from source),
|
|
448
455
|
// fall back to running the source entry with `tsx` so developers can test
|
|
449
456
|
// core files with production semantics without building.
|
|
450
|
-
if (
|
|
451
|
-
|
|
452
|
-
if (bootstrap !== undefined) {
|
|
453
|
-
return { command: 'tsx', args: [bootstrap] };
|
|
454
|
-
}
|
|
455
|
-
if (existsSync(path.join(cwd, 'src/index.ts'))) {
|
|
456
|
-
return { command: 'tsx', args: ['src/index.ts'] };
|
|
457
|
-
}
|
|
458
|
-
throw ErrorFactory.createCliError("Error: Compiled app not found at dist/src/boot/bootstrap.js. Run 'npm run build' first or set ZINTRUST_RUN_FROM_SOURCE=1 to run source in production.");
|
|
457
|
+
if (hasNodeSourceEntrypoint(cwd)) {
|
|
458
|
+
return { command: 'tsx', args: [ensureNodeSourceRunner(cwd)] };
|
|
459
459
|
}
|
|
460
|
-
|
|
460
|
+
throw ErrorFactory.createCliError("Error: Compiled app not found at dist/src/boot/bootstrap.js. Run 'npm run build' first or set ZINTRUST_RUN_FROM_SOURCE=1 to run source in production.");
|
|
461
461
|
};
|
|
462
462
|
const resolveWranglerDevConfig = (context, wranglerConfig) => {
|
|
463
463
|
const normalizedConfig = typeof wranglerConfig === 'string' ? wranglerConfig.trim() : '';
|
|
@@ -612,13 +612,15 @@ const executeNodeStart = async (cmd, context, mode, watchEnabled, _port) => {
|
|
|
612
612
|
if (mode === 'development') {
|
|
613
613
|
if (!watchEnabled) {
|
|
614
614
|
cmd.warn('Watch mode disabled; starting once.');
|
|
615
|
-
const
|
|
616
|
-
const args = bootstrap === undefined ? ['src/index.ts'] : [bootstrap];
|
|
615
|
+
const args = [ensureNodeSourceRunner(context.cwd)];
|
|
617
616
|
const exitCode = await SpawnUtil.spawnAndWait({
|
|
618
617
|
command: 'tsx',
|
|
619
618
|
args,
|
|
620
619
|
forwardSignals: false,
|
|
621
|
-
env:
|
|
620
|
+
env: {
|
|
621
|
+
...buildStartEnv(context.projectRoot),
|
|
622
|
+
ZINTRUST_BOOTSTRAP_PREFERENCE: 'source',
|
|
623
|
+
},
|
|
622
624
|
});
|
|
623
625
|
process.exit(exitCode);
|
|
624
626
|
}
|
|
@@ -628,7 +630,10 @@ const executeNodeStart = async (cmd, context, mode, watchEnabled, _port) => {
|
|
|
628
630
|
command: dev.command,
|
|
629
631
|
args: dev.args,
|
|
630
632
|
forwardSignals: false,
|
|
631
|
-
env:
|
|
633
|
+
env: {
|
|
634
|
+
...buildStartEnv(context.projectRoot),
|
|
635
|
+
ZINTRUST_BOOTSTRAP_PREFERENCE: 'source',
|
|
636
|
+
},
|
|
632
637
|
});
|
|
633
638
|
process.exit(exitCode);
|
|
634
639
|
}
|
|
@@ -638,7 +643,10 @@ const executeNodeStart = async (cmd, context, mode, watchEnabled, _port) => {
|
|
|
638
643
|
command: prod.command,
|
|
639
644
|
args: prod.args,
|
|
640
645
|
forwardSignals: false,
|
|
641
|
-
env:
|
|
646
|
+
env: {
|
|
647
|
+
...buildStartEnv(context.projectRoot),
|
|
648
|
+
ZINTRUST_BOOTSTRAP_PREFERENCE: runFromSource() ? 'source' : 'compiled',
|
|
649
|
+
},
|
|
642
650
|
});
|
|
643
651
|
process.exit(exitCode);
|
|
644
652
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export declare const createDenoRunnerSource: (startModuleSpecifier: string) => string;
|
|
2
2
|
export declare const createLambdaRunnerSource: (startModuleSpecifier: string) => string;
|
|
3
|
+
export declare const createNodeRunnerSource: (startModuleSpecifier: string) => string;
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/runner/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/runner/index.ts"],"names":[],"mappings":"AA2JA,eAAO,MAAM,sBAAsB,GAAI,sBAAsB,MAAM,KAAG,MAErE,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,sBAAsB,MAAM,KAAG,MAEvE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,sBAAsB,MAAM,KAAG,MAErE,CAAC"}
|
|
@@ -142,9 +142,18 @@ const lambdaRunnerTemplate = [
|
|
|
142
142
|
'});',
|
|
143
143
|
'',
|
|
144
144
|
].join('\n');
|
|
145
|
+
const nodeRunnerTemplate = [
|
|
146
|
+
`import { start } from ${START_MODULE_PLACEHOLDER};`,
|
|
147
|
+
'',
|
|
148
|
+
'await start();',
|
|
149
|
+
'',
|
|
150
|
+
].join('\n');
|
|
145
151
|
export const createDenoRunnerSource = (startModuleSpecifier) => {
|
|
146
152
|
return injectStartModuleSpecifier(denoRunnerTemplate, startModuleSpecifier);
|
|
147
153
|
};
|
|
148
154
|
export const createLambdaRunnerSource = (startModuleSpecifier) => {
|
|
149
155
|
return injectStartModuleSpecifier(lambdaRunnerTemplate, startModuleSpecifier);
|
|
150
156
|
};
|
|
157
|
+
export const createNodeRunnerSource = (startModuleSpecifier) => {
|
|
158
|
+
return injectStartModuleSpecifier(nodeRunnerTemplate, startModuleSpecifier);
|
|
159
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.4.
|
|
2
|
+
* @zintrust/core v0.4.55
|
|
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-04-04T15:
|
|
8
|
+
* Built: 2026-04-04T15:47:44.856Z
|
|
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-04-04T15:
|
|
24
|
+
export const ZINTRUST_BUILD_DATE = '2026-04-04T15:47:44.824Z'; // 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';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type NodeStartupLoadState = {
|
|
2
|
+
loadedFiles: string[];
|
|
3
|
+
mode?: string;
|
|
4
|
+
};
|
|
5
|
+
type EnsureNodeStartupEnvOptions = {
|
|
6
|
+
entry: string;
|
|
7
|
+
warnOnMissingEnv?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const ensureNodeStartupEnvLoaded: (options: EnsureNodeStartupEnvOptions) => Promise<NodeStartupLoadState | undefined>;
|
|
10
|
+
declare const _default: Readonly<{
|
|
11
|
+
ensureNodeStartupEnvLoaded: (options: EnsureNodeStartupEnvOptions) => Promise<NodeStartupLoadState | undefined>;
|
|
12
|
+
}>;
|
|
13
|
+
export default _default;
|
|
14
|
+
//# sourceMappingURL=NodeStartup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodeStartup.d.ts","sourceRoot":"","sources":["../../../src/runtime/NodeStartup.ts"],"names":[],"mappings":"AAGA,KAAK,oBAAoB,GAAG;IAC1B,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,2BAA2B,GAAG;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAmBF,eAAO,MAAM,0BAA0B,GACrC,SAAS,2BAA2B,KACnC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAuB1C,CAAC;;0CAxBS,2BAA2B,KACnC,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;;AAyB5C,wBAEG"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isNodeRuntime } from './detectRuntime.js';
|
|
2
|
+
import { resolveNodeProjectRoot } from './resolveNodeProjectRoot.js';
|
|
3
|
+
let pendingNodeStartupEnv;
|
|
4
|
+
const warnOnMissingEnvFiles = async (projectRoot, entry) => {
|
|
5
|
+
const [{ Logger }, { existsSync }, path] = await Promise.all([
|
|
6
|
+
import('../config/logger.js'),
|
|
7
|
+
import('../node-singletons/fs.js'),
|
|
8
|
+
import('../node-singletons/path.js'),
|
|
9
|
+
]);
|
|
10
|
+
const resolvedDotEnv = path.join(projectRoot, '.env');
|
|
11
|
+
Logger.warn('Node bootstrap started without loaded env files.', {
|
|
12
|
+
projectRoot,
|
|
13
|
+
resolvedDotEnv: existsSync(resolvedDotEnv) ? resolvedDotEnv : 'missing',
|
|
14
|
+
entry,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
export const ensureNodeStartupEnvLoaded = async (options) => {
|
|
18
|
+
if (!isNodeRuntime())
|
|
19
|
+
return undefined;
|
|
20
|
+
pendingNodeStartupEnv ??= (async () => {
|
|
21
|
+
const projectRoot = await resolveNodeProjectRoot();
|
|
22
|
+
if ((process.env?.['ZINTRUST_PROJECT_ROOT'] ?? '').trim() === '') {
|
|
23
|
+
process.env['ZINTRUST_PROJECT_ROOT'] = projectRoot;
|
|
24
|
+
}
|
|
25
|
+
const { EnvFileLoader } = await import('../cli/utils/EnvFileLoader.js');
|
|
26
|
+
const state = EnvFileLoader.ensureLoaded({
|
|
27
|
+
cwd: projectRoot,
|
|
28
|
+
includeCwd: true,
|
|
29
|
+
});
|
|
30
|
+
if (options.warnOnMissingEnv === true && state.loadedFiles.length === 0) {
|
|
31
|
+
await warnOnMissingEnvFiles(projectRoot, options.entry);
|
|
32
|
+
}
|
|
33
|
+
return state;
|
|
34
|
+
})();
|
|
35
|
+
return pendingNodeStartupEnv;
|
|
36
|
+
};
|
|
37
|
+
export default Object.freeze({
|
|
38
|
+
ensureNodeStartupEnvLoaded,
|
|
39
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectBootstrap.d.ts","sourceRoot":"","sources":["../../../src/runtime/ProjectBootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ProjectBootstrap.d.ts","sourceRoot":"","sources":["../../../src/runtime/ProjectBootstrap.ts"],"names":[],"mappings":"AA2CA,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAU1D;;;;AAED,wBAEG"}
|
|
@@ -8,11 +8,20 @@ const getProjectRoot = () => {
|
|
|
8
8
|
return fromEnv.trim();
|
|
9
9
|
return process.cwd();
|
|
10
10
|
};
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const getBootstrapPreference = () => {
|
|
12
|
+
const raw = process.env?.['ZINTRUST_BOOTSTRAP_PREFERENCE'] ?? '';
|
|
13
|
+
return raw.trim().toLowerCase() === 'compiled' ? 'compiled' : 'source';
|
|
14
|
+
};
|
|
15
|
+
const getBootstrapCandidates = (projectRoot) => {
|
|
16
|
+
const sourceCandidates = [
|
|
17
|
+
path.join(projectRoot, 'src', 'boot', 'bootstrap.ts'),
|
|
18
|
+
path.join(projectRoot, 'src', 'boot', 'bootstrap.js'),
|
|
19
|
+
];
|
|
20
|
+
const compiledCandidate = path.join(projectRoot, 'dist', 'src', 'boot', 'bootstrap.js');
|
|
21
|
+
return getBootstrapPreference() === 'compiled'
|
|
22
|
+
? [compiledCandidate, ...sourceCandidates]
|
|
23
|
+
: [sourceCandidates[0], compiledCandidate, sourceCandidates[1]];
|
|
24
|
+
};
|
|
16
25
|
const tryImportBootstrapCandidate = async (candidate) => {
|
|
17
26
|
if (!existsSync(candidate))
|
|
18
27
|
return false;
|
package/src/start.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/start.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/start.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAC;AAyBxC,eAAO,MAAM,UAAU,GAAI,eAAe,MAAM,KAAG,OAYlD,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,eAAe,OAAO,KAAG,oBASnE,CAAC;AAoEF,eAAO,MAAM,qBAAqB,GAChC,eAAe,MAAM,EACrB,eAAe,OAAO,KACrB,OAAO,CAAC,oBAAoB,CAS9B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,KAAK,QAAa,OAAO,CAAC,IAAI,CAW1C,CAAC;AAEF;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAElD;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
|
package/src/start.js
CHANGED
|
@@ -2,6 +2,7 @@ import { ErrorFactory } from './exceptions/ZintrustError.js';
|
|
|
2
2
|
import { isArray, isNonEmptyString, isObject } from './helper/index.js';
|
|
3
3
|
import { ZintrustLang } from './lang/lang.js';
|
|
4
4
|
import { normalizeActiveServiceRuntime, } from './microservices/ServiceManifest.js';
|
|
5
|
+
import { ensureNodeStartupEnvLoaded } from './runtime/NodeStartup.js';
|
|
5
6
|
import { ProjectRuntime } from './runtime/ProjectRuntime.js';
|
|
6
7
|
import { resolveNodeProjectRoot } from './runtime/resolveNodeProjectRoot.js';
|
|
7
8
|
import { isNodeRuntime } from './runtime/detectRuntime.js';
|
|
@@ -97,6 +98,9 @@ export const bootStandaloneService = async (importMetaUrl, activeService) => {
|
|
|
97
98
|
export const start = async () => {
|
|
98
99
|
if (!isNodeRuntime())
|
|
99
100
|
return;
|
|
101
|
+
await ensureNodeStartupEnvLoaded({
|
|
102
|
+
entry: '@zintrust/core/start',
|
|
103
|
+
});
|
|
100
104
|
const projectBootstrapModule = (await import('./runtime/ProjectBootstrap.js'));
|
|
101
105
|
await projectBootstrapModule.loadProjectBootstrap();
|
|
102
106
|
};
|