@zintrust/core 0.4.1 → 0.4.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/bin/zintrust-main.d.ts.map +1 -1
- package/bin/zintrust-main.js +17 -0
- package/package.json +15 -6
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +2 -10
- package/src/cli/OptionalCliCommandRegistry.d.ts +12 -0
- package/src/cli/OptionalCliCommandRegistry.d.ts.map +1 -0
- package/src/cli/OptionalCliCommandRegistry.js +25 -0
- package/src/cli/OptionalCliExtensions.d.ts +32 -0
- package/src/cli/OptionalCliExtensions.d.ts.map +1 -0
- package/src/cli/OptionalCliExtensions.js +205 -0
- package/src/cli/index.d.ts +1 -0
- package/src/cli/index.d.ts.map +1 -1
- package/src/cli/index.js +1 -0
- package/src/cli/scaffolding/GovernanceScaffolder.js +4 -4
- package/src/cli.d.ts +4 -1
- package/src/cli.d.ts.map +1 -1
- package/src/cli.js +3 -1
- package/src/index.js +3 -3
- package/src/node.d.ts +5 -0
- package/src/node.d.ts.map +1 -1
- package/src/node.js +5 -0
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +1 -3
- package/src/templates/project/basic/database/seeders/DatabaseSeeder.ts.tpl +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zintrust-main.d.ts","sourceRoot":"","sources":["../../bin/zintrust-main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuGH,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"zintrust-main.d.ts","sourceRoot":"","sources":["../../bin/zintrust-main.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAuGH,wBAAsB,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,CAsEzC;AAED,OAAO,EAAE,CAAC"}
|
package/bin/zintrust-main.js
CHANGED
|
@@ -99,6 +99,23 @@ export async function run() {
|
|
|
99
99
|
}
|
|
100
100
|
const { EnvFileLoader } = await import('../src/cli/utils/EnvFileLoader.js');
|
|
101
101
|
EnvFileLoader.ensureLoaded();
|
|
102
|
+
// Auto-load install-only CLI extension packages that self-register commands.
|
|
103
|
+
let optionalCliExtensions;
|
|
104
|
+
let optionalCliStatuses = [];
|
|
105
|
+
try {
|
|
106
|
+
({ OptionalCliExtensions: optionalCliExtensions } =
|
|
107
|
+
await import('../src/cli/OptionalCliExtensions.js'));
|
|
108
|
+
optionalCliStatuses = await optionalCliExtensions.tryImportInstalledExtensions();
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
// best-effort; missing optional extensions must not block the CLI
|
|
112
|
+
}
|
|
113
|
+
const missingOptionalExtension = optionalCliExtensions?.findMissingExtensionForArgs(args0, optionalCliStatuses);
|
|
114
|
+
if (missingOptionalExtension !== undefined) {
|
|
115
|
+
const { ErrorFactory } = await import('../src/exceptions/ZintrustError.js');
|
|
116
|
+
throw ErrorFactory.createCliError(optionalCliExtensions?.getMissingExtensionMessage(missingOptionalExtension) ??
|
|
117
|
+
`Missing optional CLI package: ${missingOptionalExtension.packageName}`);
|
|
118
|
+
}
|
|
102
119
|
// Ensure project-installed adapters/drivers are registered for CLI commands.
|
|
103
120
|
// (This is driven by src/zintrust.plugins.ts generated by `zin plugin install`.)
|
|
104
121
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Production-grade TypeScript backend framework for JavaScript",
|
|
5
5
|
"homepage": "https://zintrust.com",
|
|
6
6
|
"repository": {
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@cloudflare/containers": "^0.1.1",
|
|
49
|
-
"@zintrust/workers": "^0.
|
|
49
|
+
"@zintrust/workers": "^0.4.0",
|
|
50
50
|
"bcryptjs": "^3.0.3",
|
|
51
|
-
"bullmq": "^5.
|
|
51
|
+
"bullmq": "^5.71.0",
|
|
52
52
|
"chalk": "^5.6.2",
|
|
53
53
|
"commander": "^14.0.3",
|
|
54
|
-
"inquirer": "^13.3.
|
|
54
|
+
"inquirer": "^13.3.2",
|
|
55
55
|
"jsonwebtoken": "^9.0.3",
|
|
56
|
-
"mysql2": "^3.
|
|
56
|
+
"mysql2": "^3.20.0",
|
|
57
57
|
"pg": "^8.20.0"
|
|
58
58
|
},
|
|
59
59
|
"overrides": {
|
|
@@ -64,7 +64,16 @@
|
|
|
64
64
|
"glob": "^11.1.0",
|
|
65
65
|
"minimatch": "^10.2.2",
|
|
66
66
|
"rollup": "^4.59.0",
|
|
67
|
-
"
|
|
67
|
+
"flatted": "^3.4.2",
|
|
68
|
+
"@actions/github": {
|
|
69
|
+
"undici": "^6.24.0"
|
|
70
|
+
},
|
|
71
|
+
"@actions/http-client": {
|
|
72
|
+
"undici": "^6.24.0"
|
|
73
|
+
},
|
|
74
|
+
"miniflare": {
|
|
75
|
+
"undici": "^7.24.4"
|
|
76
|
+
}
|
|
68
77
|
},
|
|
69
78
|
"bin": {
|
|
70
79
|
"zintrust": "bin/zintrust.js",
|
package/src/cli/CLI.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../../../src/cli/CLI.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC,MAAM,WAAW,IAAI;IACnB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACnC,UAAU,IAAI,OAAO,CAAC;CACvB;AAsPD;;;;;;;GAOG;AACH,eAAO,MAAM,GAAG;cACJ,IAAI;EAed,CAAC"}
|
package/src/cli/CLI.js
CHANGED
|
@@ -58,15 +58,14 @@ import { SqlServerProxyCommand } from './commands/SqlServerProxyCommand.js';
|
|
|
58
58
|
import { StartCommand } from './commands/StartCommand.js';
|
|
59
59
|
import { TemplatesCommand } from './commands/TemplatesCommand.js';
|
|
60
60
|
import { UpgradeCommand } from './commands/UpgradeCommand.js';
|
|
61
|
-
import { WorkerCommands } from './commands/WorkerCommands.js';
|
|
62
61
|
import { ErrorHandler } from './ErrorHandler.js';
|
|
62
|
+
import { OptionalCliCommandRegistry } from './OptionalCliCommandRegistry.js';
|
|
63
63
|
import { VersionChecker } from './services/VersionChecker.js';
|
|
64
64
|
import { esmDirname } from '../common/index.js';
|
|
65
65
|
import { Logger } from '../config/logger.js';
|
|
66
66
|
import { ErrorFactory } from '../exceptions/ZintrustError.js';
|
|
67
67
|
import { readFileSync } from '../node-singletons/fs.js';
|
|
68
68
|
import { join } from '../node-singletons/path.js';
|
|
69
|
-
import { D1Migrator } from '../../packages/d1-migrator/src/index.js';
|
|
70
69
|
import { Command } from 'commander';
|
|
71
70
|
const __dirname = esmDirname(import.meta.url);
|
|
72
71
|
const isCommandProvider = (command) => {
|
|
@@ -106,7 +105,6 @@ const buildCommandRegistry = () => {
|
|
|
106
105
|
DbSeedCommand.create(),
|
|
107
106
|
D1LearnCommand.create(),
|
|
108
107
|
D1MigrateCommand.create(),
|
|
109
|
-
D1Migrator.MigrateToD1Command,
|
|
110
108
|
DebugCommand.create(),
|
|
111
109
|
SecretsCommand.create(),
|
|
112
110
|
ConfigCommand.create(),
|
|
@@ -136,13 +134,7 @@ const buildCommandRegistry = () => {
|
|
|
136
134
|
SqlServerProxyCommand.create(),
|
|
137
135
|
RedisProxyCommand.create(),
|
|
138
136
|
SmtpProxyCommand.create(),
|
|
139
|
-
|
|
140
|
-
WorkerCommands.createWorkerStatusCommand(),
|
|
141
|
-
WorkerCommands.createWorkerStartCommand(),
|
|
142
|
-
WorkerCommands.createWorkerStartAllCommand(),
|
|
143
|
-
WorkerCommands.createWorkerStopCommand(),
|
|
144
|
-
WorkerCommands.createWorkerRestartCommand(),
|
|
145
|
-
WorkerCommands.createWorkerSummaryCommand(),
|
|
137
|
+
...OptionalCliCommandRegistry.list(),
|
|
146
138
|
];
|
|
147
139
|
};
|
|
148
140
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
export type CliCommandProvider = {
|
|
3
|
+
getCommand: () => Command;
|
|
4
|
+
name?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const OptionalCliCommandRegistry: Readonly<{
|
|
7
|
+
register(id: string, provider: CliCommandProvider): void;
|
|
8
|
+
get(id: string): CliCommandProvider | undefined;
|
|
9
|
+
has(id: string): boolean;
|
|
10
|
+
list(): CliCommandProvider[];
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=OptionalCliCommandRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OptionalCliCommandRegistry.d.ts","sourceRoot":"","sources":["../../../src/cli/OptionalCliCommandRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,UAAU,EAAE,MAAM,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAiBF,eAAO,MAAM,0BAA0B;iBACxB,MAAM,YAAY,kBAAkB,GAAG,IAAI;YAMhD,MAAM,GAAG,kBAAkB,GAAG,SAAS;YAIvC,MAAM,GAAG,OAAO;YAIhB,kBAAkB,EAAE;EAG5B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isObject } from '../helper/index.js';
|
|
2
|
+
const globalWithRegistry = globalThis;
|
|
3
|
+
const registry = globalWithRegistry.__zintrust_cli_command_registry__ ??
|
|
4
|
+
(globalWithRegistry.__zintrust_cli_command_registry__ = new Map());
|
|
5
|
+
const isCliCommandProvider = (value) => {
|
|
6
|
+
return isObject(value) && typeof value['getCommand'] === 'function';
|
|
7
|
+
};
|
|
8
|
+
const normalizeId = (id) => id.trim();
|
|
9
|
+
export const OptionalCliCommandRegistry = Object.freeze({
|
|
10
|
+
register(id, provider) {
|
|
11
|
+
const normalizedId = normalizeId(id);
|
|
12
|
+
if (normalizedId === '' || !isCliCommandProvider(provider))
|
|
13
|
+
return;
|
|
14
|
+
registry.set(normalizedId, provider);
|
|
15
|
+
},
|
|
16
|
+
get(id) {
|
|
17
|
+
return registry.get(normalizeId(id));
|
|
18
|
+
},
|
|
19
|
+
has(id) {
|
|
20
|
+
return registry.has(normalizeId(id));
|
|
21
|
+
},
|
|
22
|
+
list() {
|
|
23
|
+
return Array.from(registry.values());
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type OptionalCliExtension = {
|
|
2
|
+
packageName: string;
|
|
3
|
+
specifier: string;
|
|
4
|
+
commands: string[];
|
|
5
|
+
installCommand: string;
|
|
6
|
+
localCandidates: string[];
|
|
7
|
+
};
|
|
8
|
+
type OptionalCliExtensionLoadSource = 'project' | 'package' | 'local-fallback' | 'missing';
|
|
9
|
+
export type OptionalCliExtensionStatus = Readonly<{
|
|
10
|
+
packageName: string;
|
|
11
|
+
commands: string[];
|
|
12
|
+
installCommand: string;
|
|
13
|
+
loaded: boolean;
|
|
14
|
+
source: OptionalCliExtensionLoadSource;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const OptionalCliExtensions: Readonly<{
|
|
17
|
+
tryImportInstalledExtensions(): Promise<OptionalCliExtensionStatus[]>;
|
|
18
|
+
findMissingExtensionForArgs(args: string[], statuses: ReadonlyArray<OptionalCliExtensionStatus>): OptionalCliExtensionStatus | undefined;
|
|
19
|
+
getMissingExtensionMessage(status: OptionalCliExtensionStatus): string;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const OptionalCliExtensionsInternal: Readonly<{
|
|
22
|
+
getProjectCwd: () => string;
|
|
23
|
+
resolveProjectRoot: () => string;
|
|
24
|
+
resolveProjectInstalledUrl: (entry: OptionalCliExtension) => string | null;
|
|
25
|
+
tryImportProjectInstalledPackage: (entry: OptionalCliExtension) => Promise<boolean>;
|
|
26
|
+
tryImportLocalCandidate: (entry: OptionalCliExtension) => Promise<boolean>;
|
|
27
|
+
tryImportPackageSpecifier: (entry: OptionalCliExtension) => Promise<boolean>;
|
|
28
|
+
tryImportExtension: (entry: OptionalCliExtension) => Promise<OptionalCliExtensionStatus>;
|
|
29
|
+
getRequestedCommand: (args: string[]) => string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=OptionalCliExtensions.d.ts.map
|
|
@@ -0,0 +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,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF,KAAK,8BAA8B,GAAG,SAAS,GAAG,SAAS,GAAG,gBAAgB,GAAG,SAAS,CAAC;AAE3F,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAAC;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,8BAA8B,CAAC;CACxC,CAAC,CAAC;AA2LH,eAAO,MAAM,qBAAqB;oCACM,OAAO,CAAC,0BAA0B,EAAE,CAAC;sCAKnE,MAAM,EAAE,YACJ,aAAa,CAAC,0BAA0B,CAAC,GAClD,0BAA0B,GAAG,SAAS;uCASN,0BAA0B,GAAG,MAAM;EAOtE,CAAC;AAEH,eAAO,MAAM,6BAA6B;yBAhNhB,MAAM;8BAQD,MAAM;wCAuCM,oBAAoB,KAAG,MAAM,GAAG,IAAI;8CAiBxB,oBAAoB,KAAG,OAAO,CAAC,OAAO,CAAC;qCAqBhD,oBAAoB,KAAG,OAAO,CAAC,OAAO,CAAC;uCA2BrC,oBAAoB,KAAG,OAAO,CAAC,OAAO,CAAC;gCAmB9E,oBAAoB,KAC1B,OAAO,CAAC,0BAA0B,CAAC;gCAwCH,MAAM,EAAE,KAAG,MAAM,GAAG,SAAS;EA6C9D,CAAC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { readEnvString } from '../common/ExternalServiceUtils.js';
|
|
2
|
+
import { esmDirname } from '../common/index.js';
|
|
3
|
+
import { Logger } from '../config/logger.js';
|
|
4
|
+
import { existsSync } from '../node-singletons/fs.js';
|
|
5
|
+
import { createRequire } from '../node-singletons/module.js';
|
|
6
|
+
import * as path from '../node-singletons/path.js';
|
|
7
|
+
import { pathToFileURL } from '../node-singletons/url.js';
|
|
8
|
+
const __dirname = esmDirname(import.meta.url);
|
|
9
|
+
const packageRoot = path.resolve(__dirname, '../..');
|
|
10
|
+
const getProjectCwd = () => {
|
|
11
|
+
if (typeof process !== 'undefined' && typeof process.cwd === 'function') {
|
|
12
|
+
return process.cwd();
|
|
13
|
+
}
|
|
14
|
+
return packageRoot;
|
|
15
|
+
};
|
|
16
|
+
const resolveProjectRoot = () => {
|
|
17
|
+
const configured = readEnvString('ZINTRUST_PROJECT_ROOT').trim();
|
|
18
|
+
if (configured !== '')
|
|
19
|
+
return configured;
|
|
20
|
+
return getProjectCwd();
|
|
21
|
+
};
|
|
22
|
+
const OPTIONAL_CLI_EXTENSIONS = Object.freeze([
|
|
23
|
+
{
|
|
24
|
+
packageName: '@zintrust/d1-migrator',
|
|
25
|
+
specifier: '@zintrust/d1-migrator/register',
|
|
26
|
+
commands: ['migrate-to-d1', 'd1:transfer'],
|
|
27
|
+
installCommand: 'npm install @zintrust/d1-migrator',
|
|
28
|
+
localCandidates: [
|
|
29
|
+
path.join(packageRoot, 'packages', 'd1-migrator', 'src', 'register.ts'),
|
|
30
|
+
path.join(packageRoot, 'packages', 'd1-migrator', 'src', 'register.js'),
|
|
31
|
+
path.join(packageRoot, 'dist', 'packages', 'd1-migrator', 'src', 'register.js'),
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
packageName: '@zintrust/workers',
|
|
36
|
+
specifier: '@zintrust/workers/register',
|
|
37
|
+
commands: [
|
|
38
|
+
'worker:list',
|
|
39
|
+
'worker:status',
|
|
40
|
+
'worker:start',
|
|
41
|
+
'worker:start-all',
|
|
42
|
+
'worker:stop',
|
|
43
|
+
'worker:restart',
|
|
44
|
+
'worker:summary',
|
|
45
|
+
],
|
|
46
|
+
installCommand: 'npm install @zintrust/workers',
|
|
47
|
+
localCandidates: [
|
|
48
|
+
path.join(packageRoot, 'packages', 'workers', 'src', 'register.ts'),
|
|
49
|
+
path.join(packageRoot, 'packages', 'workers', 'src', 'register.js'),
|
|
50
|
+
path.join(packageRoot, 'dist', 'packages', 'workers', 'src', 'register.js'),
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
]);
|
|
54
|
+
const resolveProjectInstalledUrl = (entry) => {
|
|
55
|
+
try {
|
|
56
|
+
const projectRoot = resolveProjectRoot();
|
|
57
|
+
const requireFromProject = createRequire(path.join(projectRoot, 'package.json'));
|
|
58
|
+
const resolved = requireFromProject.resolve(entry.specifier);
|
|
59
|
+
return pathToFileURL(resolved).href;
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
Logger.debug('[cli] Optional CLI extension not resolved from project root', {
|
|
63
|
+
packageName: entry.packageName,
|
|
64
|
+
specifier: entry.specifier,
|
|
65
|
+
projectRoot: resolveProjectRoot(),
|
|
66
|
+
error: error instanceof Error ? error.message : String(error),
|
|
67
|
+
});
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const tryImportProjectInstalledPackage = async (entry) => {
|
|
72
|
+
const resolvedUrl = resolveProjectInstalledUrl(entry);
|
|
73
|
+
if (resolvedUrl === null)
|
|
74
|
+
return false;
|
|
75
|
+
try {
|
|
76
|
+
await import(resolvedUrl);
|
|
77
|
+
Logger.debug('[cli] Loaded optional CLI extension from project install', {
|
|
78
|
+
packageName: entry.packageName,
|
|
79
|
+
resolvedUrl,
|
|
80
|
+
});
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
Logger.debug('[cli] Optional CLI extension project import failed', {
|
|
85
|
+
packageName: entry.packageName,
|
|
86
|
+
resolvedUrl,
|
|
87
|
+
error: error instanceof Error ? error.message : String(error),
|
|
88
|
+
});
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const tryImportLocalCandidate = async (entry) => {
|
|
93
|
+
const existingCandidates = entry.localCandidates.filter((candidate) => existsSync(candidate));
|
|
94
|
+
if (existingCandidates.length === 0)
|
|
95
|
+
return false;
|
|
96
|
+
const results = await Promise.all(existingCandidates.map(async (candidate) => {
|
|
97
|
+
try {
|
|
98
|
+
await import(pathToFileURL(candidate).href);
|
|
99
|
+
Logger.debug('[cli] Loaded optional CLI extension from local fallback', {
|
|
100
|
+
packageName: entry.packageName,
|
|
101
|
+
candidate,
|
|
102
|
+
});
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
Logger.debug('[cli] Optional CLI extension local fallback failed', {
|
|
107
|
+
packageName: entry.packageName,
|
|
108
|
+
candidate,
|
|
109
|
+
error: error instanceof Error ? error.message : String(error),
|
|
110
|
+
});
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}));
|
|
114
|
+
return results.some(Boolean);
|
|
115
|
+
};
|
|
116
|
+
const tryImportPackageSpecifier = async (entry) => {
|
|
117
|
+
try {
|
|
118
|
+
await import(entry.specifier);
|
|
119
|
+
Logger.debug('[cli] Loaded optional CLI extension package', {
|
|
120
|
+
packageName: entry.packageName,
|
|
121
|
+
specifier: entry.specifier,
|
|
122
|
+
});
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
Logger.debug('[cli] Optional CLI extension package not loaded', {
|
|
127
|
+
packageName: entry.packageName,
|
|
128
|
+
specifier: entry.specifier,
|
|
129
|
+
error: error instanceof Error ? error.message : String(error),
|
|
130
|
+
});
|
|
131
|
+
return false;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const tryImportExtension = async (entry) => {
|
|
135
|
+
if (await tryImportProjectInstalledPackage(entry)) {
|
|
136
|
+
return {
|
|
137
|
+
packageName: entry.packageName,
|
|
138
|
+
commands: [...entry.commands],
|
|
139
|
+
installCommand: entry.installCommand,
|
|
140
|
+
loaded: true,
|
|
141
|
+
source: 'project',
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (await tryImportPackageSpecifier(entry)) {
|
|
145
|
+
return {
|
|
146
|
+
packageName: entry.packageName,
|
|
147
|
+
commands: [...entry.commands],
|
|
148
|
+
installCommand: entry.installCommand,
|
|
149
|
+
loaded: true,
|
|
150
|
+
source: 'package',
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
if (await tryImportLocalCandidate(entry)) {
|
|
154
|
+
return {
|
|
155
|
+
packageName: entry.packageName,
|
|
156
|
+
commands: [...entry.commands],
|
|
157
|
+
installCommand: entry.installCommand,
|
|
158
|
+
loaded: true,
|
|
159
|
+
source: 'local-fallback',
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
return {
|
|
163
|
+
packageName: entry.packageName,
|
|
164
|
+
commands: [...entry.commands],
|
|
165
|
+
installCommand: entry.installCommand,
|
|
166
|
+
loaded: false,
|
|
167
|
+
source: 'missing',
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
const getRequestedCommand = (args) => {
|
|
171
|
+
if (args.length === 0)
|
|
172
|
+
return undefined;
|
|
173
|
+
if (args[0] === 'help') {
|
|
174
|
+
return typeof args[1] === 'string' && args[1].trim() !== '' ? args[1].trim() : undefined;
|
|
175
|
+
}
|
|
176
|
+
return typeof args[0] === 'string' && args[0].trim() !== '' ? args[0].trim() : undefined;
|
|
177
|
+
};
|
|
178
|
+
export const OptionalCliExtensions = Object.freeze({
|
|
179
|
+
async tryImportInstalledExtensions() {
|
|
180
|
+
return Promise.all(OPTIONAL_CLI_EXTENSIONS.map(tryImportExtension));
|
|
181
|
+
},
|
|
182
|
+
findMissingExtensionForArgs(args, statuses) {
|
|
183
|
+
const requestedCommand = getRequestedCommand(args);
|
|
184
|
+
if (requestedCommand === undefined)
|
|
185
|
+
return undefined;
|
|
186
|
+
return statuses.find((status) => status.loaded !== true && status.commands.includes(requestedCommand));
|
|
187
|
+
},
|
|
188
|
+
getMissingExtensionMessage(status) {
|
|
189
|
+
const primaryCommand = status.commands[0] ?? status.packageName;
|
|
190
|
+
return [
|
|
191
|
+
`Command "${primaryCommand}" requires optional package "${status.packageName}".`,
|
|
192
|
+
`Install it and try again: ${status.installCommand}`,
|
|
193
|
+
].join(' ');
|
|
194
|
+
},
|
|
195
|
+
});
|
|
196
|
+
export const OptionalCliExtensionsInternal = Object.freeze({
|
|
197
|
+
getProjectCwd,
|
|
198
|
+
resolveProjectRoot,
|
|
199
|
+
resolveProjectInstalledUrl,
|
|
200
|
+
tryImportProjectInstalledPackage,
|
|
201
|
+
tryImportLocalCandidate,
|
|
202
|
+
tryImportPackageSpecifier,
|
|
203
|
+
tryImportExtension,
|
|
204
|
+
getRequestedCommand,
|
|
205
|
+
});
|
package/src/cli/index.d.ts
CHANGED
|
@@ -16,4 +16,5 @@ export { PostgresProxyCommand } from './commands/PostgresProxyCommand';
|
|
|
16
16
|
export { ProxyCommand } from './commands/ProxyCommand';
|
|
17
17
|
export { RedisProxyCommand } from './commands/RedisProxyCommand';
|
|
18
18
|
export { SecretsCommand } from './commands/SecretsCommand';
|
|
19
|
+
export { WorkerCommands } from './commands/WorkerCommands';
|
|
19
20
|
//# sourceMappingURL=index.d.ts.map
|
package/src/cli/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,KAAK,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGrE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC"}
|
package/src/cli/index.js
CHANGED
|
@@ -17,3 +17,4 @@ export { PostgresProxyCommand } from './commands/PostgresProxyCommand.js';
|
|
|
17
17
|
export { ProxyCommand } from './commands/ProxyCommand.js';
|
|
18
18
|
export { RedisProxyCommand } from './commands/RedisProxyCommand.js';
|
|
19
19
|
export { SecretsCommand } from './commands/SecretsCommand.js';
|
|
20
|
+
export { WorkerCommands } from './commands/WorkerCommands.js';
|
|
@@ -67,8 +67,7 @@ export default zintrustAppEslintConfig({
|
|
|
67
67
|
const wrote = FileGenerator.writeFile(eslintConfigPath, content, { overwrite: false });
|
|
68
68
|
return wrote ? [eslintConfigPath] : [];
|
|
69
69
|
};
|
|
70
|
-
const IMPORT_BOUNDARIES_ARCH_TEST_CONTENT = `import
|
|
71
|
-
import * as path from 'node:path';
|
|
70
|
+
const IMPORT_BOUNDARIES_ARCH_TEST_CONTENT = `import { fs, path } from '@zintrust/core/node';
|
|
72
71
|
import * as ts from 'typescript';
|
|
73
72
|
import { describe, expect, it } from 'vitest';
|
|
74
73
|
|
|
@@ -84,6 +83,7 @@ type Violation = {
|
|
|
84
83
|
};
|
|
85
84
|
|
|
86
85
|
const repoRoot = process.cwd();
|
|
86
|
+
const fsPromises = fs.fsPromises;
|
|
87
87
|
|
|
88
88
|
const isTsFile = (filePath: string): boolean => {
|
|
89
89
|
if (!filePath.endsWith('.ts')) return false;
|
|
@@ -92,7 +92,7 @@ const isTsFile = (filePath: string): boolean => {
|
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
const walkTsFiles = async (dir: string): Promise<string[]> => {
|
|
95
|
-
const entries = await
|
|
95
|
+
const entries = await fsPromises.readdir(dir, { withFileTypes: true });
|
|
96
96
|
|
|
97
97
|
const files = entries
|
|
98
98
|
.filter((ent) => ent.isFile())
|
|
@@ -162,7 +162,7 @@ const findViolations = async (
|
|
|
162
162
|
): Promise<Violation[]> => {
|
|
163
163
|
const perFile = await Promise.all(
|
|
164
164
|
files.map(async (file): Promise<Violation[]> => {
|
|
165
|
-
const contents = await
|
|
165
|
+
const contents = await fsPromises.readFile(file, 'utf-8');
|
|
166
166
|
const imports = extractImportSpecifiers(contents, file);
|
|
167
167
|
|
|
168
168
|
return imports
|
package/src/cli.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { BaseCommand } from './cli/BaseCommand';
|
|
2
2
|
export type { CommandOptions } from './cli/BaseCommand';
|
|
3
3
|
export { CLI } from './cli/CLI';
|
|
4
|
-
export {
|
|
4
|
+
export { ErrorHandler, EXIT_CODES } from './cli/ErrorHandler';
|
|
5
|
+
export { WorkerCommands } from './cli/commands/WorkerCommands';
|
|
6
|
+
export { OptionalCliCommandRegistry } from './cli/OptionalCliCommandRegistry';
|
|
7
|
+
export type { CliCommandProvider } from './cli/OptionalCliCommandRegistry';
|
|
5
8
|
//# sourceMappingURL=cli.d.ts.map
|
package/src/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAC7E,YAAY,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC"}
|
package/src/cli.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// CLI utilities (for build tools and scripting)
|
|
2
2
|
export { BaseCommand } from './cli/BaseCommand.js';
|
|
3
3
|
export { CLI } from './cli/CLI.js';
|
|
4
|
-
export {
|
|
4
|
+
export { ErrorHandler, EXIT_CODES } from './cli/ErrorHandler.js';
|
|
5
|
+
export { WorkerCommands } from './cli/commands/WorkerCommands.js';
|
|
6
|
+
export { OptionalCliCommandRegistry } from './cli/OptionalCliCommandRegistry.js';
|
package/src/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @zintrust/core v0.4.
|
|
2
|
+
* @zintrust/core v0.4.2
|
|
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-20T09:35:09.203Z
|
|
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-20T09:35:09.174Z'; // 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';
|
package/src/node.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
export * as crypto from './node-singletons/crypto';
|
|
2
|
+
export * as fs from './node-singletons/fs';
|
|
3
|
+
export * as path from './node-singletons/path';
|
|
4
|
+
export { performance } from './node-singletons/perf-hooks';
|
|
1
5
|
export { default, default as process } from './node-singletons/process';
|
|
6
|
+
export * as url from './node-singletons/url';
|
|
2
7
|
export { cleanOnce, FileLogWriter } from './config/FileLogWriter';
|
|
3
8
|
export { listTemplates, loadTemplate, renderTemplate } from './tools/mail/templates';
|
|
4
9
|
export { MailFake } from './tools/mail/testing';
|
package/src/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AAClD,OAAO,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,uBAAuB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,KAAK,GAAG,MAAM,sBAAsB,CAAC;AAE5C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EACV,gBAAgB,EAChB,sBAAsB,EACtB,WAAW,EACX,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,aAAa,IAAI,yBAAyB,EAC1C,YAAY,IAAI,wBAAwB,EACxC,cAAc,IAAI,0BAA0B,GAC7C,MAAM,kCAAkC,CAAC"}
|
package/src/node.js
CHANGED
|
@@ -4,7 +4,12 @@ const __coverageMarker = true;
|
|
|
4
4
|
if (__coverageMarker !== true) {
|
|
5
5
|
throw Logger.error('Unreachable');
|
|
6
6
|
}
|
|
7
|
+
export * as crypto from './node-singletons/crypto.js';
|
|
8
|
+
export * as fs from './node-singletons/fs.js';
|
|
9
|
+
export * as path from './node-singletons/path.js';
|
|
10
|
+
export { performance } from './node-singletons/perf-hooks.js';
|
|
7
11
|
export { default, default as process } from './node-singletons/process.js';
|
|
12
|
+
export * as url from './node-singletons/url.js';
|
|
8
13
|
export { cleanOnce, FileLogWriter } from './config/FileLogWriter.js';
|
|
9
14
|
export { listTemplates, loadTemplate, renderTemplate } from './tools/mail/templates/index.js';
|
|
10
15
|
export { MailFake } from './tools/mail/testing.js';
|
|
@@ -7,9 +7,7 @@
|
|
|
7
7
|
import { FeatureFlags } from '@zintrust/core';
|
|
8
8
|
import { Logger } from '@zintrust/core';
|
|
9
9
|
import { ErrorFactory } from '@zintrust/core';
|
|
10
|
-
import fs from 'node
|
|
11
|
-
import * as path from 'node:path';
|
|
12
|
-
import { performance } from 'node:perf_hooks';
|
|
10
|
+
import { fs, path, performance } from '@zintrust/core/node';
|
|
13
11
|
import { DatabaseConfig, IDatabaseAdapter, QueryResult } from '@zintrust/core';
|
|
14
12
|
import { QueryBuilder } from '@zintrust/core';
|
|
15
13
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SeederDiscovery } from '@zintrust/core/seeders';
|
|
2
2
|
import { SeederLoader } from '@zintrust/core/seeders';
|
|
3
3
|
import { CommonUtils } from '@zintrust/core/common';
|
|
4
|
-
import
|
|
4
|
+
import { path } from '@zintrust/core/node';
|
|
5
5
|
import type { IDatabase } from '@zintrust/core/orm';
|
|
6
6
|
|
|
7
7
|
export const DatabaseSeeder = Object.freeze({
|