@zintrust/core 0.1.21 → 0.1.23
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.js +1 -1
- 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 +1 -1
- 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 +182 -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 +21 -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.d.ts.map +1 -1
- package/src/cli/commands/StartCommand.js +19 -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/d1/D1SqlMigrations.d.ts.map +1 -1
- package/src/cli/d1/D1SqlMigrations.js +4 -3
- package/src/cli/scaffolding/ModelGenerator.d.ts +1 -1
- package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -1
- package/src/cli/scaffolding/ModelGenerator.js +10 -2
- 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/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 +2 -2
- 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 +5 -5
- package/src/config/type.d.ts +122 -0
- package/src/config/type.d.ts.map +1 -1
- package/src/config/type.js +10 -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/migrations/MigrationLoader.d.ts +1 -1
- package/src/migrations/MigrationLoader.d.ts.map +1 -1
- package/src/migrations/Migrator.d.ts +3 -3
- package/src/migrations/Migrator.d.ts.map +1 -1
- package/src/migrations/Migrator.js +1 -1
- package/src/migrations/MigratorFactory.d.ts +1 -1
- package/src/migrations/MigratorFactory.d.ts.map +1 -1
- package/src/migrations/MigratorFactory.js +3 -3
- package/src/migrations/enum/index.d.ts +93 -0
- package/src/migrations/enum/index.d.ts.map +1 -0
- package/src/migrations/enum/index.js +92 -0
- package/src/migrations/schema/Blueprint.d.ts +1 -1
- package/src/migrations/schema/Blueprint.d.ts.map +1 -1
- package/src/migrations/schema/Blueprint.js +27 -25
- package/src/migrations/schema/Schema.d.ts +1 -1
- package/src/migrations/schema/Schema.d.ts.map +1 -1
- package/src/migrations/schema/Schema.js +4 -3
- package/src/migrations/schema/SchemaCompiler.d.ts +1 -1
- package/src/migrations/schema/SchemaCompiler.d.ts.map +1 -1
- package/src/migrations/schema/SchemaCompiler.js +99 -91
- package/src/migrations/schema/index.d.ts +4 -4
- package/src/migrations/schema/index.d.ts.map +1 -1
- package/src/migrations/schema/index.js +3 -3
- package/src/migrations/schema/types.d.ts +2 -1
- package/src/migrations/schema/types.d.ts.map +1 -1
- 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 +7 -5
- package/src/orm/ConnectionManager.d.ts.map +1 -1
- package/src/orm/ConnectionManager.js +249 -93
- package/src/orm/Database.d.ts +2 -1
- package/src/orm/Database.d.ts.map +1 -1
- package/src/orm/DatabaseAdapter.d.ts +3 -2
- package/src/orm/DatabaseAdapter.d.ts.map +1 -1
- package/src/orm/DatabaseAdapter.js +17 -0
- package/src/orm/Model.d.ts +8 -1
- package/src/orm/Model.d.ts.map +1 -1
- package/src/orm/Model.js +109 -26
- 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/D1Adapter.d.ts.map +1 -1
- package/src/orm/adapters/D1Adapter.js +2 -1
- package/src/orm/adapters/D1RemoteAdapter.d.ts +1 -1
- package/src/orm/adapters/D1RemoteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/D1RemoteAdapter.js +3 -2
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -1
- package/src/orm/adapters/MySQLAdapter.js +2 -1
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLServerAdapter.js +2 -1
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -1
- package/src/orm/adapters/SQLiteAdapter.js +2 -1
- package/src/orm/migrations/MigrationStore.d.ts.map +1 -1
- package/src/performance/Optimizer.d.ts.map +1 -1
- package/src/performance/Optimizer.js +57 -18
- package/src/profiling/RequestProfiler.d.ts.map +1 -1
- package/src/profiling/RequestProfiler.js +3 -1
- 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 +20 -4
- package/src/runtime/PluginManager.d.ts.map +1 -1
- package/src/runtime/PluginManager.js +23 -6
- package/src/runtime/RuntimeAdapter.d.ts +3 -3
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.d.ts +15 -13
- package/src/runtime/StartupConfigFileRegistry.d.ts.map +1 -1
- package/src/runtime/StartupConfigFileRegistry.js +12 -12
- 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 +20 -7
- package/src/toolkit/Secrets/providers/CloudflareKv.d.ts.map +1 -1
- package/src/toolkit/Secrets/providers/CloudflareKv.js +19 -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 +16 -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';
|
|
@@ -17,7 +17,7 @@ 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.');
|
|
@@ -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;
|
|
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;AAkdrE;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB;;OAEG;cACO,YAAY;EAUtB,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Migrate Command
|
|
3
3
|
* Run database migrations
|
|
4
4
|
*/
|
|
5
|
-
import { Migrator } from '../../migrations/Migrator.js';
|
|
6
5
|
import { BaseCommand } from '../BaseCommand.js';
|
|
7
6
|
import { D1SqlMigrations } from '../d1/D1SqlMigrations.js';
|
|
8
7
|
import { WranglerConfig } from '../d1/WranglerConfig.js';
|
|
@@ -11,6 +10,7 @@ import { PromptHelper } from '../PromptHelper.js';
|
|
|
11
10
|
import { databaseConfig } from '../../config/database.js';
|
|
12
11
|
import { Env } from '../../config/env.js';
|
|
13
12
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
13
|
+
import { Migrator } from '../../migrations/Migrator.js';
|
|
14
14
|
import * as path from '../../node-singletons/path.js';
|
|
15
15
|
import { Database } from '../../orm/Database.js';
|
|
16
16
|
import { DatabaseAdapterRegistry } from '../../orm/DatabaseAdapterRegistry.js';
|
|
@@ -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;AAkOrE,eAAO,MAAM,oBAAoB;cACrB,YAAY;EAUtB,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migrate Worker Command
|
|
3
|
+
* Run worker package migrations
|
|
4
|
+
*/
|
|
5
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
6
|
+
import { PromptHelper } from '../PromptHelper.js';
|
|
7
|
+
import { databaseConfig } from '../../config/database.js';
|
|
8
|
+
import { Env } from '../../config/env.js';
|
|
9
|
+
import { Migrator } from '../../migrations/Migrator.js';
|
|
10
|
+
import * as path from '../../node-singletons/path.js';
|
|
11
|
+
import { Database } from '../../orm/Database.js';
|
|
12
|
+
import { DatabaseAdapterRegistry } from '../../orm/DatabaseAdapterRegistry.js';
|
|
13
|
+
const addOptions = (command) => {
|
|
14
|
+
command
|
|
15
|
+
.option('--status', 'Display migration status (applied, pending, failed)')
|
|
16
|
+
.option('--fresh', 'Reset database: drop all tables and re-run all migrations')
|
|
17
|
+
.option('--reset', 'Rollback all migrations to initial state')
|
|
18
|
+
.option('--rollback', 'Rollback last migration batch')
|
|
19
|
+
.option('--step <number>', 'Number of batches to rollback (use with --rollback)', '1')
|
|
20
|
+
.option('--force', 'Skip production confirmation (allow unsafe operations in production)')
|
|
21
|
+
.option('--all', 'Run migrations for all configured database connections')
|
|
22
|
+
.option('--no-interactive', 'Disable interactive prompts (useful for CI/CD)');
|
|
23
|
+
};
|
|
24
|
+
const getInteractive = (options) => options['interactive'] !== false;
|
|
25
|
+
const mapConnectionToOrmConfig = (conn) => {
|
|
26
|
+
switch (conn.driver) {
|
|
27
|
+
case 'sqlite':
|
|
28
|
+
return { driver: 'sqlite', database: conn.database };
|
|
29
|
+
case 'postgresql':
|
|
30
|
+
return {
|
|
31
|
+
driver: 'postgresql',
|
|
32
|
+
host: conn.host,
|
|
33
|
+
port: conn.port,
|
|
34
|
+
database: conn.database,
|
|
35
|
+
username: conn.username,
|
|
36
|
+
password: conn.password,
|
|
37
|
+
};
|
|
38
|
+
case 'mysql':
|
|
39
|
+
return {
|
|
40
|
+
driver: 'mysql',
|
|
41
|
+
host: conn.host,
|
|
42
|
+
port: conn.port,
|
|
43
|
+
database: conn.database,
|
|
44
|
+
username: conn.username,
|
|
45
|
+
password: conn.password,
|
|
46
|
+
};
|
|
47
|
+
case 'sqlserver':
|
|
48
|
+
return {
|
|
49
|
+
driver: 'sqlserver',
|
|
50
|
+
host: conn.host,
|
|
51
|
+
port: conn.port,
|
|
52
|
+
database: conn.database,
|
|
53
|
+
username: conn.username,
|
|
54
|
+
password: conn.password,
|
|
55
|
+
};
|
|
56
|
+
default:
|
|
57
|
+
return { driver: 'sqlite', database: ':memory:' };
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const isDestructiveAction = (options) => options['fresh'] === true || options['reset'] === true || options['rollback'] === true;
|
|
61
|
+
const parseRollbackSteps = (options) => {
|
|
62
|
+
const stepRaw = typeof options['step'] === 'string' ? options['step'] : '1';
|
|
63
|
+
return Math.max(1, Number.parseInt(stepRaw, 10) || 1);
|
|
64
|
+
};
|
|
65
|
+
const confirmProductionRun = async (cmd, interactive, destructive, force) => {
|
|
66
|
+
if (Env.NODE_ENV !== 'production')
|
|
67
|
+
return true;
|
|
68
|
+
if (force)
|
|
69
|
+
return true;
|
|
70
|
+
const confirmed = await PromptHelper.confirm(`NODE_ENV=production. Continue running worker migrations${destructive ? ' (destructive)' : ''}?`, false, interactive);
|
|
71
|
+
if (!confirmed) {
|
|
72
|
+
cmd.warn('Cancelled.');
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
77
|
+
const printStatus = async (migrator, cmd) => {
|
|
78
|
+
const rows = await migrator.status();
|
|
79
|
+
if (rows.length === 0) {
|
|
80
|
+
cmd.info('No migrations found.');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
for (const row of rows) {
|
|
84
|
+
const tag = row.status ?? (row.applied ? 'applied' : 'pending');
|
|
85
|
+
const extra = row.applied ? ` (batch=${row.batch ?? '?'}, at=${row.appliedAt ?? '?'})` : '';
|
|
86
|
+
cmd.info(`${tag}: ${row.name}${extra}`);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const applyMigrations = async (migrator, cmd) => {
|
|
90
|
+
const result = await migrator.migrate();
|
|
91
|
+
if (result.appliedNames.length === 0) {
|
|
92
|
+
cmd.info('No pending worker migrations.');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
cmd.success('Worker migrations applied.');
|
|
96
|
+
for (const name of result.appliedNames) {
|
|
97
|
+
cmd.info(`✓ ${name}`);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const runActions = async (migrator, options, cmd, driver) => {
|
|
101
|
+
if (options['status'] === true) {
|
|
102
|
+
cmd.info(`Adapter: ${driver}`);
|
|
103
|
+
await printStatus(migrator, cmd);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (options['fresh'] === true) {
|
|
107
|
+
await migrator.fresh();
|
|
108
|
+
cmd.success('Worker migrations applied (fresh).');
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (options['reset'] === true) {
|
|
112
|
+
await migrator.resetAll();
|
|
113
|
+
cmd.success('Worker migrations reset.');
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (options['rollback'] === true) {
|
|
117
|
+
const steps = parseRollbackSteps(options);
|
|
118
|
+
const result = await migrator.rollbackLastBatch(steps);
|
|
119
|
+
cmd.success(`Worker migrations rolled back (${result.rolledBack}).`);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
await applyMigrations(migrator, cmd);
|
|
123
|
+
};
|
|
124
|
+
const runForConnection = async (conn, options, cmd, interactive) => {
|
|
125
|
+
const destructive = isDestructiveAction(options);
|
|
126
|
+
const proceed = await confirmProductionRun(cmd, interactive, destructive, options['force'] === true);
|
|
127
|
+
if (!proceed)
|
|
128
|
+
return;
|
|
129
|
+
if (!DatabaseAdapterRegistry.has(conn.driver)) {
|
|
130
|
+
cmd.warn(`Missing adapter for driver: ${conn.driver}`);
|
|
131
|
+
cmd.warn('Install via `zin plugin install adapter:postgres` (or `zin add db:postgres`).');
|
|
132
|
+
}
|
|
133
|
+
const ormConfig = mapConnectionToOrmConfig(conn);
|
|
134
|
+
const db = Database.create(ormConfig);
|
|
135
|
+
await db.connect();
|
|
136
|
+
try {
|
|
137
|
+
const migrator = Migrator.create({
|
|
138
|
+
db,
|
|
139
|
+
projectRoot: process.cwd(),
|
|
140
|
+
globalDir: path.join(process.cwd(), 'packages', 'workers', 'migrations'),
|
|
141
|
+
extension: databaseConfig.migrations.extension,
|
|
142
|
+
separateTracking: true,
|
|
143
|
+
});
|
|
144
|
+
await runActions(migrator, options, cmd, conn.driver);
|
|
145
|
+
}
|
|
146
|
+
finally {
|
|
147
|
+
await db.disconnect();
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
const executeMigrateWorker = async (options, cmd) => {
|
|
151
|
+
const interactive = getInteractive(options);
|
|
152
|
+
const targets = [];
|
|
153
|
+
if (options['all'] === true) {
|
|
154
|
+
for (const [name, config] of Object.entries(databaseConfig.connections)) {
|
|
155
|
+
targets.push({ name, config });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
targets.push({ name: 'default', config: databaseConfig.getConnection() });
|
|
160
|
+
}
|
|
161
|
+
let sequence = Promise.resolve();
|
|
162
|
+
for (const { name, config } of targets) {
|
|
163
|
+
sequence = sequence.then(async () => {
|
|
164
|
+
if (targets.length > 1) {
|
|
165
|
+
cmd.info(`\n--- Connection: ${name} (${config.driver}) ---`);
|
|
166
|
+
}
|
|
167
|
+
await runForConnection(config, options, cmd, interactive);
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
await sequence;
|
|
171
|
+
};
|
|
172
|
+
export const MigrateWorkerCommand = Object.freeze({
|
|
173
|
+
create() {
|
|
174
|
+
const cmd = BaseCommand.create({
|
|
175
|
+
name: 'migrate:worker',
|
|
176
|
+
description: 'Run worker package migrations',
|
|
177
|
+
addOptions,
|
|
178
|
+
execute: async (options) => executeMigrateWorker(options, cmd),
|
|
179
|
+
});
|
|
180
|
+
return cmd;
|
|
181
|
+
},
|
|
182
|
+
});
|
|
@@ -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;AAmQhD,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"}
|
|
@@ -5,6 +5,7 @@ import { ProjectScaffolder } from '../scaffolding/ProjectScaffolder.js';
|
|
|
5
5
|
import { SpawnUtil } from '../utils/spawn.js';
|
|
6
6
|
import { extractErrorMessage, resolvePackageManager } from '../../common/index.js';
|
|
7
7
|
import { appConfig } from '../../config/app.js';
|
|
8
|
+
import { Env } from '../../config/env.js';
|
|
8
9
|
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
9
10
|
import { execFileSync } from '../../node-singletons/child-process.js';
|
|
10
11
|
import * as path from '../../node-singletons/path.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,21 @@ 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
|
-
|
|
196
|
+
const readEnvString = (key) => {
|
|
197
|
+
const anyEnv = Env;
|
|
198
|
+
const fromEnv = typeof anyEnv.get === 'function' ? anyEnv.get(key, '') : '';
|
|
199
|
+
if (typeof fromEnv === 'string' && fromEnv.trim() !== '')
|
|
200
|
+
return fromEnv;
|
|
201
|
+
if (typeof process !== 'undefined') {
|
|
202
|
+
const raw = process.env?.[key];
|
|
203
|
+
if (typeof raw === 'string')
|
|
204
|
+
return raw;
|
|
205
|
+
}
|
|
206
|
+
return fromEnv ?? '';
|
|
207
|
+
};
|
|
208
|
+
const ciRaw = readEnvString('CI').trim().toLowerCase();
|
|
209
|
+
const isCi = ciRaw !== '' && ciRaw !== '0' && ciRaw !== 'false';
|
|
210
|
+
const allowAuto = readEnvString('ZINTRUST_ALLOW_AUTO_INSTALL') === '1' || force;
|
|
197
211
|
if (isCi && !allowAuto) {
|
|
198
212
|
log.info('Skipping automatic dependency installation in CI environment.');
|
|
199
213
|
return;
|
|
@@ -267,7 +281,7 @@ const resolveProjectTarget = async (options) => {
|
|
|
267
281
|
};
|
|
268
282
|
const createProject = async (target, options, command) => {
|
|
269
283
|
const config = await command.getProjectConfig(target.name, options);
|
|
270
|
-
command.info(chalk.bold(`\n🚀 Creating new
|
|
284
|
+
command.info(chalk.bold(`\n🚀 Creating new ZinTrust project in ${target.display}...\n`));
|
|
271
285
|
const overwrite = options['overwrite'] === true || options['force'] === true ? true : undefined;
|
|
272
286
|
const result = await command.runScaffolding(target.basePath, target.name, config, overwrite);
|
|
273
287
|
if (isFailureResult(result)) {
|
|
@@ -337,7 +351,7 @@ const createNewCommandInstance = () => {
|
|
|
337
351
|
};
|
|
338
352
|
const base = BaseCommand.create({
|
|
339
353
|
name: 'new',
|
|
340
|
-
description: 'Create a new
|
|
354
|
+
description: 'Create a new ZinTrust project',
|
|
341
355
|
addOptions,
|
|
342
356
|
execute: async (options) => {
|
|
343
357
|
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
|
+
});
|
|
@@ -331,7 +331,7 @@ const generateQAReport = (results) => {
|
|
|
331
331
|
<head>
|
|
332
332
|
<meta charset="UTF-8">
|
|
333
333
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
334
|
-
<title>
|
|
334
|
+
<title>ZinTrust QA Report</title>
|
|
335
335
|
<link rel="stylesheet" href="base.css">
|
|
336
336
|
<link rel="stylesheet" href="qa-report.css">
|
|
337
337
|
</head>
|
|
@@ -339,7 +339,7 @@ const generateQAReport = (results) => {
|
|
|
339
339
|
<main class="qa-shell">
|
|
340
340
|
<section class="qa-panel">
|
|
341
341
|
<header class="qa-hero">
|
|
342
|
-
<h1 class="qa-title">
|
|
342
|
+
<h1 class="qa-title">ZinTrust QA Report</h1>
|
|
343
343
|
<p class="qa-subtitle">Quality Assurance Suite Results</p>
|
|
344
344
|
<div class="qa-meta">Generated on ${timestamp}</div>
|
|
345
345
|
</header>
|
|
@@ -360,7 +360,7 @@ const generateQAReport = (results) => {
|
|
|
360
360
|
</div>
|
|
361
361
|
</div>
|
|
362
362
|
|
|
363
|
-
<footer class="qa-footer">
|
|
363
|
+
<footer class="qa-footer">ZinTrust Framework QA Suite | Generated automatically</footer>
|
|
364
364
|
</section>
|
|
365
365
|
</main>
|
|
366
366
|
</body>
|
|
@@ -430,7 +430,7 @@ const addOptions = (command) => {
|
|
|
430
430
|
};
|
|
431
431
|
const executeQA = async (qa, options) => {
|
|
432
432
|
try {
|
|
433
|
-
qa.info('Starting
|
|
433
|
+
qa.info('Starting ZinTrust QA Suite...');
|
|
434
434
|
const results = createResults();
|
|
435
435
|
await qa.runLint(results.lint);
|
|
436
436
|
await qa.runTypeCheck(results.typeCheck);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResourceControlCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/ResourceControlCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,eAAO,MAAM,sBAAsB,yCAuCjC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resource Control Command
|
|
3
|
+
* Control the resource monitor (start/stop) on the running worker service via HTTP
|
|
4
|
+
*/
|
|
5
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError.js';
|
|
6
|
+
import { BaseCommand } from '../BaseCommand.js';
|
|
7
|
+
import { Logger } from '../../config/logger.js';
|
|
8
|
+
export const ResourceControlCommand = BaseCommand.create({
|
|
9
|
+
name: 'resource:monitor',
|
|
10
|
+
description: 'Control the resource monitor (start/stop) on the running worker service',
|
|
11
|
+
aliases: ['rm'],
|
|
12
|
+
addOptions: (cmd) => {
|
|
13
|
+
cmd.argument('<action>', 'Action to perform: start or stop');
|
|
14
|
+
cmd.option('--port <port>', 'Worker service port', '7777');
|
|
15
|
+
cmd.option('--host <host>', 'Worker service host', '127.0.0.1');
|
|
16
|
+
},
|
|
17
|
+
execute: async (options) => {
|
|
18
|
+
const action = options.args?.[0];
|
|
19
|
+
const port = options['port'] ?? '7777';
|
|
20
|
+
const host = options['host'] ?? '127.0.0.1';
|
|
21
|
+
if (action === undefined || !['start', 'stop'].includes(action)) {
|
|
22
|
+
Logger.error('Invalid action. Use "start" or "stop".');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const url = `http://${host}:${port}/api/resources/${action}`;
|
|
26
|
+
try {
|
|
27
|
+
Logger.info(`Sending ${action} request to ${url}...`);
|
|
28
|
+
const response = await fetch(url, {
|
|
29
|
+
method: 'POST',
|
|
30
|
+
headers: { 'Content-Type': 'application/json' },
|
|
31
|
+
});
|
|
32
|
+
if (!response.ok) {
|
|
33
|
+
throw ErrorFactory.createCliError(`HTTP ${response.status}: ${await response.text()}`);
|
|
34
|
+
}
|
|
35
|
+
const data = (await response.json());
|
|
36
|
+
Logger.info(`Success: ${data.message}`);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
Logger.error(`Failed to ${action} resource monitor: ${e.message}`);
|
|
40
|
+
Logger.info('Ensure the worker service is running and the port is correct.');
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Simulate Command
|
|
3
|
-
* Internal dev tool that generates a simulated
|
|
3
|
+
* Internal dev tool that generates a simulated ZinTrust app under ./simulate/
|
|
4
4
|
* IMPORTANT: this uses the same ProjectScaffolder as `zin new`.
|
|
5
5
|
* Usage: zin -sim my-blog
|
|
6
6
|
*/
|