@zintrust/core 0.1.22 ā 0.1.24
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/z.d.ts +1 -1
- package/bin/z.js +1 -1
- package/bin/zin.d.ts +1 -1
- package/bin/zin.js +1 -1
- package/bin/zintrust-main.d.ts +1 -1
- package/bin/zintrust-main.js +2 -2
- package/bin/zintrust-microservices.d.ts +1 -1
- package/bin/zintrust-microservices.js +1 -1
- package/bin/zintrust.d.ts +1 -1
- package/bin/zintrust.js +1 -1
- package/bin/zt.d.ts +1 -1
- package/bin/zt.js +1 -1
- package/package.json +2 -3
- package/public/index.html +3 -3
- package/routes/api.js +1 -1
- package/routes/health.d.ts +3 -4
- package/routes/health.d.ts.map +1 -1
- package/routes/health.js +3 -125
- package/src/boot/Application.d.ts.map +1 -1
- package/src/boot/Application.js +11 -22
- package/src/boot/bootstrap.d.ts +1 -1
- package/src/boot/bootstrap.js +48 -7
- package/src/builder/BundleOptimizer.d.ts +1 -1
- package/src/builder/BundleOptimizer.js +1 -1
- package/src/cache/drivers/KVRemoteDriver.d.ts +1 -1
- package/src/cache/drivers/KVRemoteDriver.js +1 -1
- package/src/cli/CLI.d.ts.map +1 -1
- package/src/cli/CLI.js +15 -1
- package/src/cli/ErrorHandler.js +3 -3
- package/src/cli/commands/AddCommand.d.ts +1 -1
- package/src/cli/commands/AddCommand.d.ts.map +1 -1
- package/src/cli/commands/AddCommand.js +1 -1
- package/src/cli/commands/DbSeedCommand.d.ts.map +1 -1
- package/src/cli/commands/DbSeedCommand.js +7 -39
- package/src/cli/commands/MakeMailTemplateCommand.js +2 -1
- package/src/cli/commands/MakeNotificationTemplateCommand.js +2 -1
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -1
- package/src/cli/commands/MigrateCommand.js +12 -55
- package/src/cli/commands/MigrateWorkerCommand.d.ts +9 -0
- package/src/cli/commands/MigrateWorkerCommand.d.ts.map +1 -0
- package/src/cli/commands/MigrateWorkerCommand.js +136 -0
- package/src/cli/commands/NewCommand.d.ts +1 -1
- package/src/cli/commands/NewCommand.d.ts.map +1 -1
- package/src/cli/commands/NewCommand.js +9 -7
- package/src/cli/commands/PublishCommand.d.ts +5 -0
- package/src/cli/commands/PublishCommand.d.ts.map +1 -0
- package/src/cli/commands/PublishCommand.js +54 -0
- package/src/cli/commands/QACommand.js +4 -4
- package/src/cli/commands/ResourceControlCommand.d.ts +6 -0
- package/src/cli/commands/ResourceControlCommand.d.ts.map +1 -0
- package/src/cli/commands/ResourceControlCommand.js +43 -0
- package/src/cli/commands/SimulateCommand.d.ts +1 -1
- package/src/cli/commands/SimulateCommand.js +4 -4
- package/src/cli/commands/StartCommand.js +7 -7
- package/src/cli/commands/UpgradeCommand.d.ts +1 -1
- package/src/cli/commands/UpgradeCommand.js +2 -2
- package/src/cli/commands/WorkerCommands.d.ts +17 -0
- package/src/cli/commands/WorkerCommands.d.ts.map +1 -0
- package/src/cli/commands/WorkerCommands.js +264 -0
- package/src/cli/commands/index.d.ts +2 -0
- package/src/cli/commands/index.d.ts.map +1 -1
- package/src/cli/commands/index.js +2 -0
- package/src/cli/config/ConfigSchema.d.ts +1 -1
- package/src/cli/config/ConfigSchema.d.ts.map +1 -1
- package/src/cli/config/ConfigSchema.js +4 -3
- package/src/cli/scaffolding/ProjectScaffolder.js +5 -5
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/RouteGenerator.js +21 -2
- package/src/cli/scaffolding/TemplateEngine.js +1 -1
- package/src/cli/utils/DatabaseCliUtils.d.ts +20 -0
- package/src/cli/utils/DatabaseCliUtils.d.ts.map +1 -0
- package/src/cli/utils/DatabaseCliUtils.js +54 -0
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -1
- package/src/common/ExternalServiceUtils.d.ts +63 -0
- package/src/common/ExternalServiceUtils.d.ts.map +1 -0
- package/src/common/ExternalServiceUtils.js +116 -0
- package/src/common/HealthRoutes.d.ts +10 -0
- package/src/common/HealthRoutes.d.ts.map +1 -0
- package/src/common/HealthRoutes.js +114 -0
- package/src/config/SecretsManager.d.ts.map +1 -1
- package/src/config/SecretsManager.js +2 -1
- package/src/config/app.d.ts +2 -1
- package/src/config/app.d.ts.map +1 -1
- package/src/config/app.js +98 -52
- package/src/config/broadcast.d.ts.map +1 -1
- package/src/config/broadcast.js +1 -1
- package/src/config/cache.d.ts.map +1 -1
- package/src/config/cache.js +2 -2
- package/src/config/database.d.ts.map +1 -1
- package/src/config/database.js +24 -5
- package/src/config/env.d.ts +43 -1
- package/src/config/env.d.ts.map +1 -1
- package/src/config/env.js +68 -21
- package/src/config/index.d.ts +10 -1
- package/src/config/index.d.ts.map +1 -1
- package/src/config/index.js +1 -0
- package/src/config/mail.d.ts.map +1 -1
- package/src/config/mail.js +3 -3
- package/src/config/middleware.d.ts.map +1 -1
- package/src/config/middleware.js +1 -1
- package/src/config/notification.d.ts.map +1 -1
- package/src/config/notification.js +2 -2
- package/src/config/queue.d.ts +14 -0
- package/src/config/queue.d.ts.map +1 -1
- package/src/config/queue.js +61 -36
- package/src/config/security.js +2 -2
- package/src/config/storage.d.ts.map +1 -1
- package/src/config/storage.js +1 -1
- package/src/config/type.d.ts +111 -0
- package/src/config/type.d.ts.map +1 -1
- package/src/config/workers.d.ts +13 -0
- package/src/config/workers.d.ts.map +1 -0
- package/src/config/workers.js +173 -0
- package/src/database/Paginator.d.ts +37 -0
- package/src/database/Paginator.d.ts.map +1 -0
- package/src/database/Paginator.js +81 -0
- package/src/exceptions/ZintrustError.d.ts +5 -2
- package/src/exceptions/ZintrustError.d.ts.map +1 -1
- package/src/exceptions/ZintrustError.js +6 -2
- package/src/features/Auth.d.ts +1 -1
- package/src/features/Auth.d.ts.map +1 -1
- package/src/features/Auth.js +3 -2
- package/src/features/Queue.d.ts.map +1 -1
- package/src/features/Queue.js +0 -2
- package/src/index.d.ts +15 -5
- package/src/index.d.ts.map +1 -1
- package/src/index.js +24 -3
- package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -1
- package/src/microservices/MicroserviceBootstrap.js +3 -1
- package/src/microservices/MicroserviceGenerator.js +4 -4
- package/src/microservices/MicroserviceManager.d.ts +1 -1
- package/src/microservices/MicroserviceManager.js +1 -1
- package/src/middleware/RateLimiter.d.ts.map +1 -1
- package/src/middleware/RateLimiter.js +4 -3
- package/src/node-singletons/crypto.d.ts +1 -1
- package/src/node-singletons/crypto.d.ts.map +1 -1
- package/src/node-singletons/crypto.js +1 -1
- package/src/node-singletons/os.d.ts +10 -1
- package/src/node-singletons/os.d.ts.map +1 -1
- package/src/node-singletons/os.js +10 -1
- package/src/openapi/OpenApiGenerator.js +2 -2
- package/src/orm/ConnectionManager.d.ts +1 -1
- package/src/orm/ConnectionManager.d.ts.map +1 -1
- package/src/orm/ConnectionManager.js +37 -19
- package/src/orm/Model.d.ts +8 -1
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +85 -24
- package/src/orm/QueryBuilder.d.ts +12 -2
- package/src/orm/QueryBuilder.d.ts.map +1 -1
- package/src/orm/QueryBuilder.js +438 -38
- package/src/orm/Relationships.d.ts +61 -1
- package/src/orm/Relationships.d.ts.map +1 -1
- package/src/orm/Relationships.js +190 -0
- package/src/orm/adapters/D1RemoteAdapter.d.ts +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +1 -1
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +2 -4
- package/src/routing/CoreRoutes.d.ts +1 -1
- package/src/routing/CoreRoutes.d.ts.map +1 -1
- package/src/routing/CoreRoutes.js +2 -116
- package/src/routing/error.d.ts.map +1 -1
- package/src/routing/error.js +3 -2
- package/src/routing/publicRoot.d.ts.map +1 -1
- package/src/routing/publicRoot.js +4 -2
- package/src/runtime/PluginAutoImports.d.ts.map +1 -1
- package/src/runtime/PluginAutoImports.js +8 -4
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +11 -6
- package/src/runtime/RuntimeAdapter.d.ts +3 -3
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.d.ts +2 -1
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.js +2 -1
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/CloudflareAdapter.js +1 -1
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/DenoAdapter.js +1 -1
- package/src/runtime/adapters/FargateAdapter.d.ts +2 -2
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/FargateAdapter.js +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts +1 -1
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -1
- package/src/runtime/adapters/LambdaAdapter.js +6 -4
- package/src/runtime/adapters/NodeServerAdapter.js +1 -1
- package/src/scripts/GenerateEnvArtifacts.js +1 -1
- package/src/security/SignedRequest.js +1 -1
- package/src/security/StartupSecretValidation.d.ts.map +1 -1
- package/src/security/StartupSecretValidation.js +7 -1
- package/src/start.d.ts.map +1 -1
- package/src/start.js +0 -2
- package/src/templates/features/Auth.ts.tpl +4 -4
- package/src/templates/project/basic/README.md.tpl +1 -1
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +1 -1
- package/src/templates/project/basic/config/notification.ts.tpl +1 -1
- package/src/templates/project/basic/routes/api.ts.tpl +1 -3
- package/src/templates/project/basic/src/index.ts.tpl +1 -1
- package/src/templates/project/basic/src/zintrust.plugins.ts.tpl +1 -1
- package/src/templates/project/basic/template.json +1 -1
- package/src/toolkit/Secrets/index.d.ts.map +1 -1
- package/src/toolkit/Secrets/index.js +13 -9
- package/src/toolkit/Secrets/providers/AwsSecretsManager.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/AwsSecretsManager.js +8 -7
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/CloudflareKv.js +7 -6
- package/src/tools/http/Http.js +1 -1
- package/src/tools/mail/drivers/Ses.d.ts.map +1 -1
- package/src/tools/mail/drivers/Ses.js +5 -4
- package/src/tools/mail/templates/index.js +2 -2
- package/src/tools/notification/drivers/Termii.d.ts.map +1 -1
- package/src/tools/notification/drivers/Termii.js +6 -17
- package/src/tools/notification/testingHelpers.d.ts.map +1 -1
- package/src/tools/queue/Queue.d.ts.map +1 -1
- package/src/tools/queue/Queue.js +3 -5
- package/src/tools/queue/drivers/Redis.d.ts.map +1 -1
- package/src/tools/queue/drivers/Redis.js +7 -1
- package/src/tools/storage/drivers/S3.d.ts.map +1 -1
- package/src/tools/storage/drivers/S3.js +4 -3
- package/src/routes/health.d.ts +0 -2
- package/src/routes/health.d.ts.map +0 -1
- package/src/routes/health.js +0 -1
- package/src/runtime/RuntimeDetector.d.ts +0 -15
- package/src/runtime/RuntimeDetector.d.ts.map +0 -1
- package/src/runtime/RuntimeDetector.js +0 -271
- package/src/templates/project/basic/routes/health.ts.tpl +0 -143
- package/src/templates/project/basic/routes/metrics.ts.tpl +0 -22
- package/src/workers/BroadcastWorker.d.ts +0 -22
- package/src/workers/BroadcastWorker.d.ts.map +0 -1
- package/src/workers/BroadcastWorker.js +0 -24
- package/src/workers/NotificationWorker.d.ts +0 -22
- package/src/workers/NotificationWorker.d.ts.map +0 -1
- package/src/workers/NotificationWorker.js +0 -23
- package/src/workers/createQueueWorker.d.ts +0 -24
- package/src/workers/createQueueWorker.d.ts.map +0 -1
- package/src/workers/createQueueWorker.js +0 -114
package/src/cli/CLI.js
CHANGED
|
@@ -15,18 +15,22 @@ import { KeyGenerateCommand } from './commands/KeyGenerateCommand.js';
|
|
|
15
15
|
import { MakeMailTemplateCommand } from './commands/MakeMailTemplateCommand.js';
|
|
16
16
|
import { MakeNotificationTemplateCommand } from './commands/MakeNotificationTemplateCommand.js';
|
|
17
17
|
import { MigrateCommand } from './commands/MigrateCommand.js';
|
|
18
|
+
import { MigrateWorkerCommand } from './commands/MigrateWorkerCommand.js';
|
|
18
19
|
import { NewCommand } from './commands/NewCommand.js';
|
|
19
20
|
import { NotificationWorkCommand } from './commands/NotificationWorkCommand.js';
|
|
20
21
|
import { PluginCommand } from './commands/PluginCommand.js';
|
|
21
22
|
import { PrepareCommand } from './commands/PrepareCommand.js';
|
|
23
|
+
import { PublishCommand } from './commands/PublishCommand.js';
|
|
22
24
|
import { QACommand } from './commands/QACommand.js';
|
|
23
25
|
import { QueueCommand } from './commands/QueueCommand.js';
|
|
26
|
+
import { ResourceControlCommand } from './commands/ResourceControlCommand.js';
|
|
24
27
|
import { RoutesCommand } from './commands/RoutesCommand.js';
|
|
25
28
|
import { SecretsCommand } from './commands/SecretsCommand.js';
|
|
26
29
|
import { SimulateCommand } from './commands/SimulateCommand.js';
|
|
27
30
|
import { StartCommand } from './commands/StartCommand.js';
|
|
28
31
|
import { TemplatesCommand } from './commands/TemplatesCommand.js';
|
|
29
32
|
import { UpgradeCommand } from './commands/UpgradeCommand.js';
|
|
33
|
+
import { WorkerCommands } from './commands/WorkerCommands.js';
|
|
30
34
|
import { ErrorHandler } from './ErrorHandler.js';
|
|
31
35
|
import { esmDirname } from '../common/index.js';
|
|
32
36
|
import { Logger } from '../config/logger.js';
|
|
@@ -56,7 +60,7 @@ const loadVersion = () => {
|
|
|
56
60
|
const setupProgram = (program, version) => {
|
|
57
61
|
program
|
|
58
62
|
.name('zintrust')
|
|
59
|
-
.description('
|
|
63
|
+
.description('ZinTrust Framework CLI - Build production-grade TypeScript APIs')
|
|
60
64
|
.version(version, '-v, --version', 'Output version number')
|
|
61
65
|
.helpOption('-h, --help', 'Display help for command')
|
|
62
66
|
.usage('[command] [options]');
|
|
@@ -79,6 +83,8 @@ const registerCommands = (program) => {
|
|
|
79
83
|
QueueCommand.create(),
|
|
80
84
|
BroadcastWorkCommand.create(),
|
|
81
85
|
NotificationWorkCommand.create(),
|
|
86
|
+
ResourceControlCommand,
|
|
87
|
+
MigrateWorkerCommand.create(),
|
|
82
88
|
MigrateCommand.create(),
|
|
83
89
|
DbSeedCommand.create(),
|
|
84
90
|
D1MigrateCommand.create(),
|
|
@@ -86,6 +92,7 @@ const registerCommands = (program) => {
|
|
|
86
92
|
SecretsCommand.create(),
|
|
87
93
|
ConfigCommand.create(),
|
|
88
94
|
PluginCommand.create(),
|
|
95
|
+
PublishCommand.create(),
|
|
89
96
|
QACommand(),
|
|
90
97
|
FixCommand.create(),
|
|
91
98
|
KeyGenerateCommand.create(),
|
|
@@ -95,6 +102,13 @@ const registerCommands = (program) => {
|
|
|
95
102
|
MakeNotificationTemplateCommand.create(),
|
|
96
103
|
RoutesCommand.create(),
|
|
97
104
|
JwtDevCommand,
|
|
105
|
+
// Worker management commands
|
|
106
|
+
WorkerCommands.createWorkerListCommand(),
|
|
107
|
+
WorkerCommands.createWorkerStatusCommand(),
|
|
108
|
+
WorkerCommands.createWorkerStartCommand(),
|
|
109
|
+
WorkerCommands.createWorkerStopCommand(),
|
|
110
|
+
WorkerCommands.createWorkerRestartCommand(),
|
|
111
|
+
WorkerCommands.createWorkerSummaryCommand(),
|
|
98
112
|
];
|
|
99
113
|
for (const command of commands) {
|
|
100
114
|
program.addCommand(command.getCommand());
|
package/src/cli/ErrorHandler.js
CHANGED
|
@@ -43,10 +43,10 @@ const displayInfo = (message) => {
|
|
|
43
43
|
*/
|
|
44
44
|
const displayBanner = (version) => {
|
|
45
45
|
/* eslint-disable no-console */
|
|
46
|
-
const framework = '
|
|
46
|
+
const framework = 'ZinTrust Framework';
|
|
47
47
|
const bannerWidth = 46;
|
|
48
|
-
const env = Env.NODE_ENV
|
|
49
|
-
const db = Env.DB_CONNECTION
|
|
48
|
+
const env = Env.NODE_ENV ?? 'development';
|
|
49
|
+
const db = Env.DB_CONNECTION ?? 'sqlite';
|
|
50
50
|
const border = chalk.cyanBright;
|
|
51
51
|
const label = chalk.bold.white;
|
|
52
52
|
const frameworkValue = chalk.bold.cyanBright;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add Command - Phase 4 Integration
|
|
3
|
-
* Add services and features to existing
|
|
3
|
+
* Add services and features to existing ZinTrust project
|
|
4
4
|
*/
|
|
5
5
|
import type { IBaseCommand } from '../BaseCommand';
|
|
6
6
|
import type { ResponseField } from '../scaffolding/ResponseFactoryGenerator';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AddCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/AddCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAarE,OAAO,KAAK,EAEV,aAAa,
|
|
1
|
+
{"version":3,"file":"AddCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/AddCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAarE,OAAO,KAAK,EAEV,aAAa,EACd,MAAM,2CAA2C,CAAC;AAwCnD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,GAAG,UAAU,CAAC;IAChC,IAAI,EAAE,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;CAC7C;AAED,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,UAAU,2BAA2B;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,UAAU,4BAA4B;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;CAClB;AAsmCD;;GAEG;AACH,eAAO,MAAM,UAAU;IACrB;;OAEG;cACO,YAAY;IAWtB;;;OAGG;;2CAnlC2C,MAAM,KAAG,OAAO,CAAC,oBAAoB,CAAC;mCA2EhD,OAAO,CAAC,oBAAoB,CAAC;qCA8D3B,OAAO,CAAC,sBAAsB,CAAC;iCAwGnC,OAAO,CAAC,kBAAkB,CAAC;sCA4DtB,OAAO,CAAC,uBAAuB,CAAC;kCAwDpC,OAAO,CAAC,mBAAmB,CAAC;mCAkE3B,OAAO,CAAC,oBAAoB,CAAC;kCA8I9B,OAAO,CAAC,mBAAmB,CAAC;0CAiHpB,OAAO,CAAC,2BAA2B,CAAC;yCAwFrC,OAAO,CAAC,MAAM,CAAC;2DAkBpC,MAAM,KAC1B,OAAO,CAAC,4BAA4B,CAAC;4CAoHzB,MAAM,KAClB,OAAO,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,KAAK,CAAA;SAAE,CAAC;iDAlE5C,MAAM,KAAG,aAAa,EAAE;;EA+RtE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add Command - Phase 4 Integration
|
|
3
|
-
* Add services and features to existing
|
|
3
|
+
* Add services and features to existing ZinTrust project
|
|
4
4
|
*/
|
|
5
5
|
import { BaseCommand } from '../BaseCommand.js';
|
|
6
6
|
import { ControllerGenerator } from '../scaffolding/ControllerGenerator.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DbSeedCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/DbSeedCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"DbSeedCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/DbSeedCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkKrE,eAAO,MAAM,aAAa;cACd,YAAY;EAUtB,CAAC"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { SeederDiscovery } from '../../seeders/SeederDiscovery.js';
|
|
6
6
|
import { SeederLoader } from '../../seeders/SeederLoader.js';
|
|
7
7
|
import { BaseCommand } from '../BaseCommand.js';
|
|
8
|
-
import {
|
|
8
|
+
import { confirmProductionRun, mapConnectionToOrmConfig } from '../utils/DatabaseCliUtils.js';
|
|
9
9
|
import { databaseConfig } from '../../config/database.js';
|
|
10
10
|
import { Env } from '../../config/env.js';
|
|
11
11
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
@@ -17,48 +17,12 @@ const addSeedOptions = (command) => {
|
|
|
17
17
|
.option('--only-service <domain/name>', 'Run only service-local seeders')
|
|
18
18
|
.option('--no-interactive', 'Skip interactive prompts');
|
|
19
19
|
};
|
|
20
|
-
const getInteractive = (options) => options['interactive'] !== false &&
|
|
20
|
+
const getInteractive = (options) => options['interactive'] !== false && Env.CI !== 'true';
|
|
21
21
|
const ensureNonD1Driver = (driver) => {
|
|
22
22
|
if (driver === 'd1' || driver === 'd1-remote') {
|
|
23
23
|
throw ErrorFactory.createCliError('This project is configured for D1. Seeding via `zin db:seed` is not supported yet.');
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
|
-
const mapConnectionToOrmConfig = (conn) => {
|
|
27
|
-
switch (conn.driver) {
|
|
28
|
-
case 'sqlite':
|
|
29
|
-
return { driver: 'sqlite', database: conn.database };
|
|
30
|
-
case 'postgresql':
|
|
31
|
-
return {
|
|
32
|
-
driver: 'postgresql',
|
|
33
|
-
host: conn.host,
|
|
34
|
-
port: conn.port,
|
|
35
|
-
database: conn.database,
|
|
36
|
-
username: conn.username,
|
|
37
|
-
password: conn.password,
|
|
38
|
-
};
|
|
39
|
-
case 'mysql':
|
|
40
|
-
return {
|
|
41
|
-
driver: 'mysql',
|
|
42
|
-
host: conn.host,
|
|
43
|
-
port: conn.port,
|
|
44
|
-
database: conn.database,
|
|
45
|
-
username: conn.username,
|
|
46
|
-
password: conn.password,
|
|
47
|
-
};
|
|
48
|
-
default:
|
|
49
|
-
return { driver: 'sqlite', database: ':memory:' };
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
const confirmProductionRun = async (cmd, interactive) => {
|
|
53
|
-
if (Env.NODE_ENV !== 'production')
|
|
54
|
-
return true;
|
|
55
|
-
const confirmed = await PromptHelper.confirm('NODE_ENV=production. Continue running seeders?', false, interactive);
|
|
56
|
-
if (!confirmed) {
|
|
57
|
-
cmd.warn('Cancelled.');
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
61
|
-
};
|
|
62
26
|
const getServiceArgs = (options) => {
|
|
63
27
|
let serviceArg;
|
|
64
28
|
if (typeof options['onlyService'] === 'string') {
|
|
@@ -105,7 +69,11 @@ const selectSeederFiles = (files, seederName) => {
|
|
|
105
69
|
};
|
|
106
70
|
const executeSeed = async (options, cmd) => {
|
|
107
71
|
const interactive = getInteractive(options);
|
|
108
|
-
const okToProceed = await confirmProductionRun(
|
|
72
|
+
const okToProceed = await confirmProductionRun({
|
|
73
|
+
cmd,
|
|
74
|
+
interactive,
|
|
75
|
+
message: 'NODE_ENV=production. Continue running seeders?',
|
|
76
|
+
});
|
|
109
77
|
if (!okToProceed)
|
|
110
78
|
return;
|
|
111
79
|
const conn = databaseConfig.getConnection();
|
|
@@ -7,6 +7,7 @@ import { ErrorHandler } from '../ErrorHandler.js';
|
|
|
7
7
|
import { PromptHelper } from '../PromptHelper.js';
|
|
8
8
|
import { FileGenerator } from '../scaffolding/FileGenerator.js';
|
|
9
9
|
import { TemplateGenerator } from '../scaffolding/TemplateGenerator.js';
|
|
10
|
+
import { Env } from '../../config/env.js';
|
|
10
11
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
11
12
|
import * as path from '../../node-singletons/path.js';
|
|
12
13
|
const addOptions = (command) => {
|
|
@@ -16,7 +17,7 @@ const addOptions = (command) => {
|
|
|
16
17
|
command.option('--overwrite', 'Overwrite existing file');
|
|
17
18
|
command.option('--no-interactive', 'Disable prompts (requires args/options)');
|
|
18
19
|
};
|
|
19
|
-
const defaultCopyright = () =>
|
|
20
|
+
const defaultCopyright = () => Env.TEMPLATE_COPYRIGHT;
|
|
20
21
|
export const MakeMailTemplateCommand = Object.freeze({
|
|
21
22
|
create() {
|
|
22
23
|
return BaseCommand.create({
|
|
@@ -7,6 +7,7 @@ import { ErrorHandler } from '../ErrorHandler.js';
|
|
|
7
7
|
import { PromptHelper } from '../PromptHelper.js';
|
|
8
8
|
import { FileGenerator } from '../scaffolding/FileGenerator.js';
|
|
9
9
|
import { TemplateGenerator } from '../scaffolding/TemplateGenerator.js';
|
|
10
|
+
import { Env } from '../../config/env.js';
|
|
10
11
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
11
12
|
import * as path from '../../node-singletons/path.js';
|
|
12
13
|
import inquirer from 'inquirer';
|
|
@@ -18,7 +19,7 @@ const addOptions = (command) => {
|
|
|
18
19
|
command.option('--overwrite', 'Overwrite existing file');
|
|
19
20
|
command.option('--no-interactive', 'Disable prompts (requires args/options)');
|
|
20
21
|
};
|
|
21
|
-
const defaultCopyright = () =>
|
|
22
|
+
const defaultCopyright = () => Env.TEMPLATE_COPYRIGHT;
|
|
22
23
|
const parseChannelsCsv = (csv) => {
|
|
23
24
|
if (csv === undefined || csv.trim() === '')
|
|
24
25
|
return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA4ZrE;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB;;OAEG;cACO,YAAY;EAUtB,CAAC"}
|
|
@@ -7,8 +7,9 @@ import { D1SqlMigrations } from '../d1/D1SqlMigrations.js';
|
|
|
7
7
|
import { WranglerConfig } from '../d1/WranglerConfig.js';
|
|
8
8
|
import { WranglerD1 } from '../d1/WranglerD1.js';
|
|
9
9
|
import { PromptHelper } from '../PromptHelper.js';
|
|
10
|
+
import { confirmProductionRun, mapConnectionToOrmConfig, parseRollbackSteps, } from '../utils/DatabaseCliUtils.js';
|
|
11
|
+
import { readEnvString } from '../../common/ExternalServiceUtils.js';
|
|
10
12
|
import { databaseConfig } from '../../config/database.js';
|
|
11
|
-
import { Env } from '../../config/env.js';
|
|
12
13
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
13
14
|
import { Migrator } from '../../migrations/Migrator.js';
|
|
14
15
|
import * as path from '../../node-singletons/path.js';
|
|
@@ -32,9 +33,10 @@ const addMigrateOptions = (command) => {
|
|
|
32
33
|
};
|
|
33
34
|
const getInteractive = (options) => options['interactive'] !== false;
|
|
34
35
|
const getMigrationDirs = () => {
|
|
35
|
-
const globalDir =
|
|
36
|
+
const globalDir = readEnvString('MIGRATIONS_GLOBAL_DIR', databaseConfig.migrations.directory);
|
|
36
37
|
const extension = databaseConfig.migrations.extension;
|
|
37
|
-
const
|
|
38
|
+
const separateTrackingRaw = readEnvString('MIGRATIONS_SEPARATE_TRACKING', '').trim();
|
|
39
|
+
const separateTracking = separateTrackingRaw === '1' || separateTrackingRaw.toLowerCase() === 'true';
|
|
38
40
|
return { globalDir, extension, separateTracking };
|
|
39
41
|
};
|
|
40
42
|
const getServiceArgs = (options) => {
|
|
@@ -64,53 +66,6 @@ const describeTargetDatabase = (conn) => {
|
|
|
64
66
|
return `${conn.driver}`;
|
|
65
67
|
}
|
|
66
68
|
};
|
|
67
|
-
const mapConnectionToOrmConfig = (conn) => {
|
|
68
|
-
switch (conn.driver) {
|
|
69
|
-
case 'sqlite':
|
|
70
|
-
return { driver: 'sqlite', database: conn.database };
|
|
71
|
-
case 'postgresql':
|
|
72
|
-
return {
|
|
73
|
-
driver: 'postgresql',
|
|
74
|
-
host: conn.host,
|
|
75
|
-
port: conn.port,
|
|
76
|
-
database: conn.database,
|
|
77
|
-
username: conn.username,
|
|
78
|
-
password: conn.password,
|
|
79
|
-
};
|
|
80
|
-
case 'mysql':
|
|
81
|
-
return {
|
|
82
|
-
driver: 'mysql',
|
|
83
|
-
host: conn.host,
|
|
84
|
-
port: conn.port,
|
|
85
|
-
database: conn.database,
|
|
86
|
-
username: conn.username,
|
|
87
|
-
password: conn.password,
|
|
88
|
-
};
|
|
89
|
-
case 'sqlserver':
|
|
90
|
-
return {
|
|
91
|
-
driver: 'sqlserver',
|
|
92
|
-
host: conn.host,
|
|
93
|
-
port: conn.port,
|
|
94
|
-
database: conn.database,
|
|
95
|
-
username: conn.username,
|
|
96
|
-
password: conn.password,
|
|
97
|
-
};
|
|
98
|
-
default:
|
|
99
|
-
return { driver: 'sqlite', database: ':memory:' };
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const confirmProductionRun = async (cmd, interactive, destructive, force) => {
|
|
103
|
-
if (Env.NODE_ENV !== 'production')
|
|
104
|
-
return true;
|
|
105
|
-
if (force)
|
|
106
|
-
return true;
|
|
107
|
-
const confirmed = await PromptHelper.confirm(`NODE_ENV=production. Continue running migrations${destructive ? ' (destructive)' : ''}?`, false, interactive);
|
|
108
|
-
if (!confirmed) {
|
|
109
|
-
cmd.warn('Cancelled.');
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
return true;
|
|
113
|
-
};
|
|
114
69
|
const printStatus = (cmd, rows) => {
|
|
115
70
|
if (rows.length === 0) {
|
|
116
71
|
cmd.info('No migrations found.');
|
|
@@ -133,10 +88,6 @@ const logAppliedMigrations = (cmd, appliedNames) => {
|
|
|
133
88
|
cmd.info(`ā ${name}`);
|
|
134
89
|
}
|
|
135
90
|
};
|
|
136
|
-
const parseRollbackSteps = (options) => {
|
|
137
|
-
const stepRaw = typeof options['step'] === 'string' ? options['step'] : '1';
|
|
138
|
-
return Math.max(1, Number.parseInt(stepRaw, 10) || 1);
|
|
139
|
-
};
|
|
140
91
|
const handleStatusAction = async (migrator, cmd, driver) => {
|
|
141
92
|
cmd.info(`Adapter: ${driver}`);
|
|
142
93
|
const rows = await migrator.status();
|
|
@@ -267,7 +218,13 @@ const processConnection = async (conn, options, cmd, interactive) => {
|
|
|
267
218
|
const ormConfig = mapConnectionToOrmConfig(conn);
|
|
268
219
|
const destructive = isDestructiveAction(options);
|
|
269
220
|
const force = options['force'] === true;
|
|
270
|
-
const okToProceed = await confirmProductionRun(
|
|
221
|
+
const okToProceed = await confirmProductionRun({
|
|
222
|
+
cmd,
|
|
223
|
+
interactive,
|
|
224
|
+
destructive,
|
|
225
|
+
force,
|
|
226
|
+
message: 'NODE_ENV=production. Continue running migrations?',
|
|
227
|
+
});
|
|
271
228
|
if (!okToProceed)
|
|
272
229
|
return;
|
|
273
230
|
cmd.info(`[i] Target database: ${describeTargetDatabase(conn)}`);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migrate Worker Command
|
|
3
|
+
* Run worker package migrations
|
|
4
|
+
*/
|
|
5
|
+
import type { IBaseCommand } from '../BaseCommand';
|
|
6
|
+
export declare const MigrateWorkerCommand: Readonly<{
|
|
7
|
+
create(): IBaseCommand;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=MigrateWorkerCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrateWorkerCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateWorkerCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAkB,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAmKrE,eAAO,MAAM,oBAAoB;cACrB,YAAY;EAUtB,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migrate Worker Command
|
|
3
|
+
* Run worker package migrations
|
|
4
|
+
*/
|
|
5
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
6
|
+
import { confirmProductionRun, mapConnectionToOrmConfig, parseRollbackSteps, } from '../utils/DatabaseCliUtils.js';
|
|
7
|
+
import { databaseConfig } from '../../config/database.js';
|
|
8
|
+
import { Migrator } from '../../migrations/Migrator.js';
|
|
9
|
+
import * as path from '../../node-singletons/path.js';
|
|
10
|
+
import { Database } from '../../orm/Database.js';
|
|
11
|
+
import { DatabaseAdapterRegistry } from '../../orm/DatabaseAdapterRegistry.js';
|
|
12
|
+
const addOptions = (command) => {
|
|
13
|
+
command
|
|
14
|
+
.option('--status', 'Display migration status (applied, pending, failed)')
|
|
15
|
+
.option('--fresh', 'Reset database: drop all tables and re-run all migrations')
|
|
16
|
+
.option('--reset', 'Rollback all migrations to initial state')
|
|
17
|
+
.option('--rollback', 'Rollback last migration batch')
|
|
18
|
+
.option('--step <number>', 'Number of batches to rollback (use with --rollback)', '1')
|
|
19
|
+
.option('--force', 'Skip production confirmation (allow unsafe operations in production)')
|
|
20
|
+
.option('--all', 'Run migrations for all configured database connections')
|
|
21
|
+
.option('--no-interactive', 'Disable interactive prompts (useful for CI/CD)');
|
|
22
|
+
};
|
|
23
|
+
const getInteractive = (options) => options['interactive'] !== false;
|
|
24
|
+
const isDestructiveAction = (options) => options['fresh'] === true || options['reset'] === true || options['rollback'] === true;
|
|
25
|
+
const printStatus = async (migrator, cmd) => {
|
|
26
|
+
const rows = await migrator.status();
|
|
27
|
+
if (rows.length === 0) {
|
|
28
|
+
cmd.info('No migrations found.');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
for (const row of rows) {
|
|
32
|
+
const tag = row.status ?? (row.applied ? 'applied' : 'pending');
|
|
33
|
+
const extra = row.applied ? ` (batch=${row.batch ?? '?'}, at=${row.appliedAt ?? '?'})` : '';
|
|
34
|
+
cmd.info(`${tag}: ${row.name}${extra}`);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const applyMigrations = async (migrator, cmd) => {
|
|
38
|
+
const result = await migrator.migrate();
|
|
39
|
+
if (result.appliedNames.length === 0) {
|
|
40
|
+
cmd.info('No pending worker migrations.');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
cmd.success('Worker migrations applied.');
|
|
44
|
+
for (const name of result.appliedNames) {
|
|
45
|
+
cmd.info(`ā ${name}`);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const runActions = async (migrator, options, cmd, driver) => {
|
|
49
|
+
if (options['status'] === true) {
|
|
50
|
+
cmd.info(`Adapter: ${driver}`);
|
|
51
|
+
await printStatus(migrator, cmd);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (options['fresh'] === true) {
|
|
55
|
+
await migrator.fresh();
|
|
56
|
+
cmd.success('Worker migrations applied (fresh).');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (options['reset'] === true) {
|
|
60
|
+
await migrator.resetAll();
|
|
61
|
+
cmd.success('Worker migrations reset.');
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (options['rollback'] === true) {
|
|
65
|
+
const steps = parseRollbackSteps(options);
|
|
66
|
+
const result = await migrator.rollbackLastBatch(steps);
|
|
67
|
+
cmd.success(`Worker migrations rolled back (${result.rolledBack}).`);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
await applyMigrations(migrator, cmd);
|
|
71
|
+
};
|
|
72
|
+
const runForConnection = async (conn, options, cmd, interactive) => {
|
|
73
|
+
const destructive = isDestructiveAction(options);
|
|
74
|
+
const proceed = await confirmProductionRun({
|
|
75
|
+
cmd,
|
|
76
|
+
interactive,
|
|
77
|
+
destructive,
|
|
78
|
+
force: options['force'] === true,
|
|
79
|
+
message: 'NODE_ENV=production. Continue running worker migrations?',
|
|
80
|
+
});
|
|
81
|
+
if (!proceed)
|
|
82
|
+
return;
|
|
83
|
+
if (!DatabaseAdapterRegistry.has(conn.driver)) {
|
|
84
|
+
cmd.warn(`Missing adapter for driver: ${conn.driver}`);
|
|
85
|
+
cmd.warn('Install via `zin plugin install adapter:postgres` (or `zin add db:postgres`).');
|
|
86
|
+
}
|
|
87
|
+
const ormConfig = mapConnectionToOrmConfig(conn);
|
|
88
|
+
const db = Database.create(ormConfig);
|
|
89
|
+
await db.connect();
|
|
90
|
+
try {
|
|
91
|
+
const migrator = Migrator.create({
|
|
92
|
+
db,
|
|
93
|
+
projectRoot: process.cwd(),
|
|
94
|
+
globalDir: path.join(process.cwd(), 'packages', 'workers', 'migrations'),
|
|
95
|
+
extension: databaseConfig.migrations.extension,
|
|
96
|
+
separateTracking: true,
|
|
97
|
+
});
|
|
98
|
+
await runActions(migrator, options, cmd, conn.driver);
|
|
99
|
+
}
|
|
100
|
+
finally {
|
|
101
|
+
await db.disconnect();
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
const executeMigrateWorker = async (options, cmd) => {
|
|
105
|
+
const interactive = getInteractive(options);
|
|
106
|
+
const targets = [];
|
|
107
|
+
if (options['all'] === true) {
|
|
108
|
+
for (const [name, config] of Object.entries(databaseConfig.connections)) {
|
|
109
|
+
targets.push({ name, config });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
targets.push({ name: 'default', config: databaseConfig.getConnection() });
|
|
114
|
+
}
|
|
115
|
+
let sequence = Promise.resolve();
|
|
116
|
+
for (const { name, config } of targets) {
|
|
117
|
+
sequence = sequence.then(async () => {
|
|
118
|
+
if (targets.length > 1) {
|
|
119
|
+
cmd.info(`\n--- Connection: ${name} (${config.driver}) ---`);
|
|
120
|
+
}
|
|
121
|
+
await runForConnection(config, options, cmd, interactive);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
await sequence;
|
|
125
|
+
};
|
|
126
|
+
export const MigrateWorkerCommand = Object.freeze({
|
|
127
|
+
create() {
|
|
128
|
+
const cmd = BaseCommand.create({
|
|
129
|
+
name: 'migrate:worker',
|
|
130
|
+
description: 'Run worker package migrations',
|
|
131
|
+
addOptions,
|
|
132
|
+
execute: async (options) => executeMigrateWorker(options, cmd),
|
|
133
|
+
});
|
|
134
|
+
return cmd;
|
|
135
|
+
},
|
|
136
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* New Command - Project scaffolding CLI command
|
|
3
|
-
* Handles creation of new
|
|
3
|
+
* Handles creation of new ZinTrust projects
|
|
4
4
|
*/
|
|
5
5
|
import type { CommandOptions, IBaseCommand } from '../BaseCommand';
|
|
6
6
|
type TemplateType = 'basic' | 'api' | 'microservice' | 'fullstack';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NewCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/NewCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"NewCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/NewCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAerE,KAAK,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG,cAAc,GAAG,WAAW,CAAC;AACnE,KAAK,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,GAAG,WAAW,CAAC;AAYhF,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,KAAK,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAwPhD,UAAU,WAAY,SAAQ,YAAY;IACxC,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACxF,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACzF,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,sBAAsB,GAAG,gBAAgB,EAAE,CAAC;IACjF,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC;IAChC,YAAY,IAAI,MAAM,CAAC;IACvB,cAAc,CACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,sBAAsB,EAC9B,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACpE;AAwOD;;;GAGG;AACH,eAAO,MAAM,UAAU;IACrB;;OAEG;cACO,WAAW;EAGrB,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { PromptHelper } from '../PromptHelper.js';
|
|
|
3
3
|
import { GovernanceScaffolder } from '../scaffolding/GovernanceScaffolder.js';
|
|
4
4
|
import { ProjectScaffolder } from '../scaffolding/ProjectScaffolder.js';
|
|
5
5
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
6
|
+
import { readEnvString } from '../../common/ExternalServiceUtils.js';
|
|
6
7
|
import { extractErrorMessage, resolvePackageManager } from '../../common/index.js';
|
|
7
8
|
import { appConfig } from '../../config/app.js';
|
|
8
9
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
@@ -26,7 +27,7 @@ const initializeGitRepo = (projectPath, log) => {
|
|
|
26
27
|
const env = appConfig.getSafeEnv();
|
|
27
28
|
execFileSync(git, ['init'], { cwd: projectPath, stdio: 'ignore', env });
|
|
28
29
|
execFileSync(git, ['add', '.'], { cwd: projectPath, stdio: 'ignore', env });
|
|
29
|
-
execFileSync(git, ['commit', '-m', 'Initial commit from
|
|
30
|
+
execFileSync(git, ['commit', '-m', 'Initial commit from ZinTrust'], {
|
|
30
31
|
cwd: projectPath,
|
|
31
32
|
stdio: 'ignore',
|
|
32
33
|
env,
|
|
@@ -69,7 +70,7 @@ const getProjectDefaults = (name, options) => {
|
|
|
69
70
|
const portParsed = Number.parseInt(portRaw, 10);
|
|
70
71
|
const port = Number.isFinite(portParsed) && portParsed > 0 ? portParsed : 7777;
|
|
71
72
|
const author = getStringOption(options, 'author', '');
|
|
72
|
-
const description = getStringOption(options, 'description', `A new
|
|
73
|
+
const description = getStringOption(options, 'description', `A new ZinTrust project: ${name}`);
|
|
73
74
|
const interactive = getBooleanOption(options, 'interactive', true);
|
|
74
75
|
return { name, template, database, port, author, description, interactive };
|
|
75
76
|
};
|
|
@@ -122,7 +123,7 @@ const getQuestions = (name, defaults) => {
|
|
|
122
123
|
type: 'input',
|
|
123
124
|
name: 'description',
|
|
124
125
|
message: 'Project description:',
|
|
125
|
-
default: defaults.description === '' ? `A new
|
|
126
|
+
default: defaults.description === '' ? `A new ZinTrust project: ${name}` : defaults.description,
|
|
126
127
|
},
|
|
127
128
|
];
|
|
128
129
|
};
|
|
@@ -192,8 +193,9 @@ const promptForPackageManager = async (defaultPm) => {
|
|
|
192
193
|
};
|
|
193
194
|
const installDependencies = async (projectPath, log, packageManager, force = false) => {
|
|
194
195
|
// Respect CI by default ā avoid network installs in CI unless explicitly allowed
|
|
195
|
-
const
|
|
196
|
-
const
|
|
196
|
+
const ciRaw = readEnvString('CI').trim().toLowerCase();
|
|
197
|
+
const isCi = ciRaw !== '' && ciRaw !== '0' && ciRaw !== 'false';
|
|
198
|
+
const allowAuto = readEnvString('ZINTRUST_ALLOW_AUTO_INSTALL') === '1' || force;
|
|
197
199
|
if (isCi && !allowAuto) {
|
|
198
200
|
log.info('Skipping automatic dependency installation in CI environment.');
|
|
199
201
|
return;
|
|
@@ -267,7 +269,7 @@ const resolveProjectTarget = async (options) => {
|
|
|
267
269
|
};
|
|
268
270
|
const createProject = async (target, options, command) => {
|
|
269
271
|
const config = await command.getProjectConfig(target.name, options);
|
|
270
|
-
command.info(chalk.bold(`\nš Creating new
|
|
272
|
+
command.info(chalk.bold(`\nš Creating new ZinTrust project in ${target.display}...\n`));
|
|
271
273
|
const overwrite = options['overwrite'] === true || options['force'] === true ? true : undefined;
|
|
272
274
|
const result = await command.runScaffolding(target.basePath, target.name, config, overwrite);
|
|
273
275
|
if (isFailureResult(result)) {
|
|
@@ -337,7 +339,7 @@ const createNewCommandInstance = () => {
|
|
|
337
339
|
};
|
|
338
340
|
const base = BaseCommand.create({
|
|
339
341
|
name: 'new',
|
|
340
|
-
description: 'Create a new
|
|
342
|
+
description: 'Create a new ZinTrust project',
|
|
341
343
|
addOptions,
|
|
342
344
|
execute: async (options) => {
|
|
343
345
|
await executeImpl(options);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublishCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/PublishCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AA0DlE,eAAO,MAAM,cAAc;cACf,YAAY;EAmBtB,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
2
|
+
import { Logger } from '../../config/logger.js';
|
|
3
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
4
|
+
import fs from '../../node-singletons/fs.js';
|
|
5
|
+
import path from '../../node-singletons/path.js';
|
|
6
|
+
const publishQueueMonitorConfig = (cwd) => {
|
|
7
|
+
const targetPath = path.join(cwd, 'config', 'queueMonitor.ts');
|
|
8
|
+
if (fs.existsSync(targetPath)) {
|
|
9
|
+
Logger.warn('Configuration file already exists: config/queueMonitor.ts');
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
// 1. Try resolving through node_modules (production usage)
|
|
13
|
+
const nodeModulesPath = path.join(cwd, 'node_modules', '@zintrust', 'queue-monitor', 'src', 'config', 'queueMonitor.ts');
|
|
14
|
+
// 2. Fallback for monorepo development (local usage)
|
|
15
|
+
const monorepoPath = path.join(cwd, 'packages', 'queue-monitor', 'src', 'config', 'queueMonitor.ts');
|
|
16
|
+
let sourcePath = '';
|
|
17
|
+
if (fs.existsSync(nodeModulesPath)) {
|
|
18
|
+
sourcePath = nodeModulesPath;
|
|
19
|
+
}
|
|
20
|
+
else if (fs.existsSync(monorepoPath)) {
|
|
21
|
+
sourcePath = monorepoPath;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
throw ErrorFactory.createCliError(`Could not locate source configuration file. Ensure @zintrust/queue-monitor is installed.`);
|
|
25
|
+
}
|
|
26
|
+
// Ensure config directory exists
|
|
27
|
+
const configDir = path.dirname(targetPath);
|
|
28
|
+
if (!fs.existsSync(configDir)) {
|
|
29
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
30
|
+
}
|
|
31
|
+
fs.copyFileSync(sourcePath, targetPath);
|
|
32
|
+
Logger.info('Published configuration: config/queueMonitor.ts');
|
|
33
|
+
};
|
|
34
|
+
export const PublishCommand = Object.freeze({
|
|
35
|
+
create() {
|
|
36
|
+
return BaseCommand.create({
|
|
37
|
+
name: 'publish:config',
|
|
38
|
+
description: 'Publish configuration files from packages to your project',
|
|
39
|
+
aliases: ['p:config'],
|
|
40
|
+
addOptions: (command) => {
|
|
41
|
+
command.option('--queue-monitor', 'Publish Queue Monitor configuration');
|
|
42
|
+
},
|
|
43
|
+
execute: async (options) => {
|
|
44
|
+
const cwd = process.cwd();
|
|
45
|
+
if (options['queueMonitor'] !== undefined && options['queueMonitor'] !== null) {
|
|
46
|
+
await publishQueueMonitorConfig(cwd); //NOSONAR
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
Logger.warn('Please specify a configuration to publish (e.g., --queue-monitor)');
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
});
|