@zintrust/core 0.1.0
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 +7 -0
- package/bin/z.d.ts.map +1 -0
- package/bin/z.js +6 -0
- package/bin/zin.d.ts +7 -0
- package/bin/zin.d.ts.map +1 -0
- package/bin/zin.js +6 -0
- package/bin/zintrust-microservices.d.ts +7 -0
- package/bin/zintrust-microservices.d.ts.map +1 -0
- package/bin/zintrust-microservices.js +165 -0
- package/bin/zintrust.d.ts +9 -0
- package/bin/zintrust.d.ts.map +1 -0
- package/bin/zintrust.js +51 -0
- package/bin/zt.d.ts +7 -0
- package/bin/zt.d.ts.map +1 -0
- package/bin/zt.js +6 -0
- package/package.json +80 -0
- package/src/boot/Application.d.ts +31 -0
- package/src/boot/Application.d.ts.map +1 -0
- package/src/boot/Application.js +159 -0
- package/src/boot/Server.d.ts +23 -0
- package/src/boot/Server.d.ts.map +1 -0
- package/src/boot/Server.js +236 -0
- package/src/boot/bootstrap.d.ts +7 -0
- package/src/boot/bootstrap.d.ts.map +1 -0
- package/src/boot/bootstrap.js +64 -0
- package/src/builder/BundleOptimizer.d.ts +42 -0
- package/src/builder/BundleOptimizer.d.ts.map +1 -0
- package/src/builder/BundleOptimizer.js +356 -0
- package/src/cache/Cache.d.ts +26 -0
- package/src/cache/Cache.d.ts.map +1 -0
- package/src/cache/Cache.js +89 -0
- package/src/cache/CacheDriver.d.ts +28 -0
- package/src/cache/CacheDriver.d.ts.map +1 -0
- package/src/cache/CacheDriver.js +6 -0
- package/src/cache/drivers/KVDriver.d.ts +12 -0
- package/src/cache/drivers/KVDriver.d.ts.map +1 -0
- package/src/cache/drivers/KVDriver.js +54 -0
- package/src/cache/drivers/MemoryDriver.d.ts +12 -0
- package/src/cache/drivers/MemoryDriver.d.ts.map +1 -0
- package/src/cache/drivers/MemoryDriver.js +50 -0
- package/src/cache/drivers/MongoDriver.d.ts +17 -0
- package/src/cache/drivers/MongoDriver.d.ts.map +1 -0
- package/src/cache/drivers/MongoDriver.js +80 -0
- package/src/cache/drivers/RedisDriver.d.ts +12 -0
- package/src/cache/drivers/RedisDriver.d.ts.map +1 -0
- package/src/cache/drivers/RedisDriver.js +79 -0
- package/src/cli/BaseCommand.d.ts +39 -0
- package/src/cli/BaseCommand.d.ts.map +1 -0
- package/src/cli/BaseCommand.js +58 -0
- package/src/cli/CLI.d.ts +21 -0
- package/src/cli/CLI.d.ts.map +1 -0
- package/src/cli/CLI.js +203 -0
- package/src/cli/ErrorHandler.d.ts +23 -0
- package/src/cli/ErrorHandler.d.ts.map +1 -0
- package/src/cli/ErrorHandler.js +95 -0
- package/src/cli/PromptHelper.d.ts +47 -0
- package/src/cli/PromptHelper.d.ts.map +1 -0
- package/src/cli/PromptHelper.js +155 -0
- package/src/cli/commands/AddCommand.d.ts +15 -0
- package/src/cli/commands/AddCommand.d.ts.map +1 -0
- package/src/cli/commands/AddCommand.js +817 -0
- package/src/cli/commands/ConfigCommand.d.ts +15 -0
- package/src/cli/commands/ConfigCommand.d.ts.map +1 -0
- package/src/cli/commands/ConfigCommand.js +273 -0
- package/src/cli/commands/D1MigrateCommand.d.ts +15 -0
- package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -0
- package/src/cli/commands/D1MigrateCommand.js +73 -0
- package/src/cli/commands/DebugCommand.d.ts +15 -0
- package/src/cli/commands/DebugCommand.d.ts.map +1 -0
- package/src/cli/commands/DebugCommand.js +52 -0
- package/src/cli/commands/FixCommand.d.ts +15 -0
- package/src/cli/commands/FixCommand.d.ts.map +1 -0
- package/src/cli/commands/FixCommand.js +80 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts +9 -0
- package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -0
- package/src/cli/commands/KeyGenerateCommand.js +76 -0
- package/src/cli/commands/LogsCommand.d.ts +19 -0
- package/src/cli/commands/LogsCommand.d.ts.map +1 -0
- package/src/cli/commands/LogsCommand.js +185 -0
- package/src/cli/commands/MigrateCommand.d.ts +15 -0
- package/src/cli/commands/MigrateCommand.d.ts.map +1 -0
- package/src/cli/commands/MigrateCommand.js +56 -0
- package/src/cli/commands/NewCommand.d.ts +32 -0
- package/src/cli/commands/NewCommand.d.ts.map +1 -0
- package/src/cli/commands/NewCommand.js +280 -0
- package/src/cli/commands/PluginCommand.d.ts +9 -0
- package/src/cli/commands/PluginCommand.d.ts.map +1 -0
- package/src/cli/commands/PluginCommand.js +94 -0
- package/src/cli/commands/PrepareCommand.d.ts +8 -0
- package/src/cli/commands/PrepareCommand.d.ts.map +1 -0
- package/src/cli/commands/PrepareCommand.js +51 -0
- package/src/cli/commands/QACommand.d.ts +33 -0
- package/src/cli/commands/QACommand.d.ts.map +1 -0
- package/src/cli/commands/QACommand.js +490 -0
- package/src/cli/commands/SimulateCommand.d.ts +12 -0
- package/src/cli/commands/SimulateCommand.d.ts.map +1 -0
- package/src/cli/commands/SimulateCommand.js +79 -0
- package/src/cli/commands/StartCommand.d.ts +5 -0
- package/src/cli/commands/StartCommand.d.ts.map +1 -0
- package/src/cli/commands/StartCommand.js +227 -0
- package/src/cli/commands/index.d.ts +11 -0
- package/src/cli/commands/index.d.ts.map +1 -0
- package/src/cli/commands/index.js +10 -0
- package/src/cli/config/ConfigManager.d.ts +42 -0
- package/src/cli/config/ConfigManager.d.ts.map +1 -0
- package/src/cli/config/ConfigManager.js +175 -0
- package/src/cli/config/ConfigSchema.d.ts +195 -0
- package/src/cli/config/ConfigSchema.d.ts.map +1 -0
- package/src/cli/config/ConfigSchema.js +171 -0
- package/src/cli/config/ConfigValidator.d.ts +41 -0
- package/src/cli/config/ConfigValidator.d.ts.map +1 -0
- package/src/cli/config/ConfigValidator.js +200 -0
- package/src/cli/config/index.d.ts +8 -0
- package/src/cli/config/index.d.ts.map +1 -0
- package/src/cli/config/index.js +7 -0
- package/src/cli/debug/Dashboard.d.ts +34 -0
- package/src/cli/debug/Dashboard.d.ts.map +1 -0
- package/src/cli/debug/Dashboard.js +152 -0
- package/src/cli/index.d.ts +14 -0
- package/src/cli/index.d.ts.map +1 -0
- package/src/cli/index.js +14 -0
- package/src/cli/logger/Logger.d.ts +43 -0
- package/src/cli/logger/Logger.d.ts.map +1 -0
- package/src/cli/logger/Logger.js +137 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts +44 -0
- package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ControllerGenerator.js +540 -0
- package/src/cli/scaffolding/FactoryGenerator.d.ts +47 -0
- package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/FactoryGenerator.js +356 -0
- package/src/cli/scaffolding/FeatureScaffolder.d.ts +40 -0
- package/src/cli/scaffolding/FeatureScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/FeatureScaffolder.js +747 -0
- package/src/cli/scaffolding/FileGenerator.d.ts +31 -0
- package/src/cli/scaffolding/FileGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/FileGenerator.js +222 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts +35 -0
- package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/MigrationGenerator.js +257 -0
- package/src/cli/scaffolding/ModelGenerator.d.ts +81 -0
- package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ModelGenerator.js +249 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts +66 -0
- package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/ProjectScaffolder.js +439 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.d.ts +50 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/RequestFactoryGenerator.js +465 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts +43 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ResponseFactoryGenerator.js +321 -0
- package/src/cli/scaffolding/RouteGenerator.d.ts +66 -0
- package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/RouteGenerator.js +306 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts +47 -0
- package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/SeederGenerator.js +286 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts +40 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +267 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts +45 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceRequestFactoryGenerator.js +397 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts +45 -0
- package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -0
- package/src/cli/scaffolding/ServiceScaffolder.js +367 -0
- package/src/cli/scaffolding/TemplateEngine.d.ts +35 -0
- package/src/cli/scaffolding/TemplateEngine.d.ts.map +1 -0
- package/src/cli/scaffolding/TemplateEngine.js +379 -0
- package/src/cli/scaffolding/WorkflowGenerator.d.ts +31 -0
- package/src/cli/scaffolding/WorkflowGenerator.d.ts.map +1 -0
- package/src/cli/scaffolding/WorkflowGenerator.js +193 -0
- package/src/cli/scaffolding/index.d.ts +34 -0
- package/src/cli/scaffolding/index.d.ts.map +1 -0
- package/src/cli/scaffolding/index.js +18 -0
- package/src/cli/utils/DistPackager.d.ts +8 -0
- package/src/cli/utils/DistPackager.d.ts.map +1 -0
- package/src/cli/utils/DistPackager.js +94 -0
- package/src/cli/utils/EnvFileLoader.d.ts +21 -0
- package/src/cli/utils/EnvFileLoader.d.ts.map +1 -0
- package/src/cli/utils/EnvFileLoader.js +166 -0
- package/src/cli/utils/spawn.d.ts +11 -0
- package/src/cli/utils/spawn.d.ts.map +1 -0
- package/src/cli/utils/spawn.js +81 -0
- package/src/common/index.d.ts +87 -0
- package/src/common/index.d.ts.map +1 -0
- package/src/common/index.js +207 -0
- package/src/config/SecretsManager.d.ts +122 -0
- package/src/config/SecretsManager.d.ts.map +1 -0
- package/src/config/SecretsManager.js +328 -0
- package/src/config/app.d.ts +56 -0
- package/src/config/app.d.ts.map +1 -0
- package/src/config/app.js +77 -0
- package/src/config/cache.d.ts +76 -0
- package/src/config/cache.d.ts.map +1 -0
- package/src/config/cache.js +62 -0
- package/src/config/constants.d.ts +108 -0
- package/src/config/constants.d.ts.map +1 -0
- package/src/config/constants.js +64 -0
- package/src/config/database.d.ts +122 -0
- package/src/config/database.d.ts.map +1 -0
- package/src/config/database.js +89 -0
- package/src/config/env.d.ts +56 -0
- package/src/config/env.d.ts.map +1 -0
- package/src/config/env.js +133 -0
- package/src/config/features.d.ts +27 -0
- package/src/config/features.d.ts.map +1 -0
- package/src/config/features.js +49 -0
- package/src/config/index.d.ts +554 -0
- package/src/config/index.d.ts.map +1 -0
- package/src/config/index.js +31 -0
- package/src/config/logger.d.ts +17 -0
- package/src/config/logger.d.ts.map +1 -0
- package/src/config/logger.js +77 -0
- package/src/config/microservices.d.ts +88 -0
- package/src/config/microservices.d.ts.map +1 -0
- package/src/config/microservices.js +90 -0
- package/src/config/queue.d.ts +107 -0
- package/src/config/queue.d.ts.map +1 -0
- package/src/config/queue.js +74 -0
- package/src/config/security.d.ts +108 -0
- package/src/config/security.d.ts.map +1 -0
- package/src/config/security.js +134 -0
- package/src/config/storage.d.ts +105 -0
- package/src/config/storage.d.ts.map +1 -0
- package/src/config/storage.js +79 -0
- package/src/container/ServiceContainer.d.ts +25 -0
- package/src/container/ServiceContainer.d.ts.map +1 -0
- package/src/container/ServiceContainer.js +75 -0
- package/src/database/migrations/index.d.ts +2 -0
- package/src/database/migrations/index.d.ts.map +1 -0
- package/src/database/migrations/index.js +1 -0
- package/src/exceptions/ZintrustError.d.ts +88 -0
- package/src/exceptions/ZintrustError.d.ts.map +1 -0
- package/src/exceptions/ZintrustError.js +110 -0
- package/src/features/Auth.d.ts +20 -0
- package/src/features/Auth.d.ts.map +1 -0
- package/src/features/Auth.js +32 -0
- package/src/features/Queue.d.ts +21 -0
- package/src/features/Queue.d.ts.map +1 -0
- package/src/features/Queue.js +59 -0
- package/src/functions/cloudflare.d.ts +5 -0
- package/src/functions/cloudflare.d.ts.map +1 -0
- package/src/functions/cloudflare.js +34 -0
- package/src/functions/deno.d.ts +3 -0
- package/src/functions/deno.d.ts.map +1 -0
- package/src/functions/deno.js +31 -0
- package/src/functions/lambda.d.ts +2 -0
- package/src/functions/lambda.d.ts.map +1 -0
- package/src/functions/lambda.js +32 -0
- package/src/http/Controller.d.ts +20 -0
- package/src/http/Controller.d.ts.map +1 -0
- package/src/http/Controller.js +46 -0
- package/src/http/Kernel.d.ts +24 -0
- package/src/http/Kernel.d.ts.map +1 -0
- package/src/http/Kernel.js +72 -0
- package/src/http/Request.d.ts +36 -0
- package/src/http/Request.d.ts.map +1 -0
- package/src/http/Request.js +142 -0
- package/src/http/Response.d.ts +32 -0
- package/src/http/Response.d.ts.map +1 -0
- package/src/http/Response.js +70 -0
- package/src/index.d.ts +43 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +37 -0
- package/src/microservices/MicroserviceBootstrap.d.ts +75 -0
- package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -0
- package/src/microservices/MicroserviceBootstrap.js +285 -0
- package/src/microservices/MicroserviceGenerator.d.ts +27 -0
- package/src/microservices/MicroserviceGenerator.d.ts.map +1 -0
- package/src/microservices/MicroserviceGenerator.js +436 -0
- package/src/microservices/MicroserviceManager.d.ts +68 -0
- package/src/microservices/MicroserviceManager.d.ts.map +1 -0
- package/src/microservices/MicroserviceManager.js +266 -0
- package/src/microservices/PostgresAdapter.d.ts +90 -0
- package/src/microservices/PostgresAdapter.d.ts.map +1 -0
- package/src/microservices/PostgresAdapter.js +286 -0
- package/src/microservices/RequestTracingMiddleware.d.ts +41 -0
- package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -0
- package/src/microservices/RequestTracingMiddleware.js +122 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts +58 -0
- package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -0
- package/src/microservices/ServiceAuthMiddleware.js +240 -0
- package/src/microservices/ServiceBundler.d.ts +45 -0
- package/src/microservices/ServiceBundler.d.ts.map +1 -0
- package/src/microservices/ServiceBundler.js +297 -0
- package/src/microservices/ServiceHealthMonitor.d.ts +96 -0
- package/src/microservices/ServiceHealthMonitor.d.ts.map +1 -0
- package/src/microservices/ServiceHealthMonitor.js +379 -0
- package/src/middleware/CsrfMiddleware.d.ts +19 -0
- package/src/middleware/CsrfMiddleware.d.ts.map +1 -0
- package/src/middleware/CsrfMiddleware.js +121 -0
- package/src/middleware/MiddlewareStack.d.ts +27 -0
- package/src/middleware/MiddlewareStack.d.ts.map +1 -0
- package/src/middleware/MiddlewareStack.js +43 -0
- package/src/middleware/RateLimiter.d.ts +22 -0
- package/src/middleware/RateLimiter.d.ts.map +1 -0
- package/src/middleware/RateLimiter.js +72 -0
- package/src/middleware/SecurityMiddleware.d.ts +33 -0
- package/src/middleware/SecurityMiddleware.d.ts.map +1 -0
- package/src/middleware/SecurityMiddleware.js +106 -0
- package/src/middleware/index.d.ts +9 -0
- package/src/middleware/index.d.ts.map +1 -0
- package/src/middleware/index.js +8 -0
- package/src/node-singletons/child-process.d.ts +7 -0
- package/src/node-singletons/child-process.d.ts.map +1 -0
- package/src/node-singletons/child-process.js +6 -0
- package/src/node-singletons/crypto.d.ts +7 -0
- package/src/node-singletons/crypto.d.ts.map +1 -0
- package/src/node-singletons/crypto.js +6 -0
- package/src/node-singletons/events.d.ts +7 -0
- package/src/node-singletons/events.d.ts.map +1 -0
- package/src/node-singletons/events.js +6 -0
- package/src/node-singletons/fs.d.ts +12 -0
- package/src/node-singletons/fs.d.ts.map +1 -0
- package/src/node-singletons/fs.js +14 -0
- package/src/node-singletons/http.d.ts +8 -0
- package/src/node-singletons/http.d.ts.map +1 -0
- package/src/node-singletons/http.js +6 -0
- package/src/node-singletons/index.d.ts +30 -0
- package/src/node-singletons/index.d.ts.map +1 -0
- package/src/node-singletons/index.js +31 -0
- package/src/node-singletons/os.d.ts +9 -0
- package/src/node-singletons/os.d.ts.map +1 -0
- package/src/node-singletons/os.js +9 -0
- package/src/node-singletons/path.d.ts +7 -0
- package/src/node-singletons/path.d.ts.map +1 -0
- package/src/node-singletons/path.js +6 -0
- package/src/node-singletons/perf-hooks.d.ts +7 -0
- package/src/node-singletons/perf-hooks.d.ts.map +1 -0
- package/src/node-singletons/perf-hooks.js +6 -0
- package/src/node-singletons/readline.d.ts +10 -0
- package/src/node-singletons/readline.d.ts.map +1 -0
- package/src/node-singletons/readline.js +9 -0
- package/src/node-singletons/url.d.ts +7 -0
- package/src/node-singletons/url.d.ts.map +1 -0
- package/src/node-singletons/url.js +6 -0
- package/src/orm/ConnectionManager.d.ts +118 -0
- package/src/orm/ConnectionManager.d.ts.map +1 -0
- package/src/orm/ConnectionManager.js +401 -0
- package/src/orm/Database.d.ts +31 -0
- package/src/orm/Database.d.ts.map +1 -0
- package/src/orm/Database.js +163 -0
- package/src/orm/DatabaseAdapter.d.ts +96 -0
- package/src/orm/DatabaseAdapter.d.ts.map +1 -0
- package/src/orm/DatabaseAdapter.js +40 -0
- package/src/orm/Model.d.ts +91 -0
- package/src/orm/Model.d.ts.map +1 -0
- package/src/orm/Model.js +206 -0
- package/src/orm/QueryBuilder.d.ts +52 -0
- package/src/orm/QueryBuilder.d.ts.map +1 -0
- package/src/orm/QueryBuilder.js +134 -0
- package/src/orm/Relationships.d.ts +53 -0
- package/src/orm/Relationships.d.ts.map +1 -0
- package/src/orm/Relationships.js +98 -0
- package/src/orm/Schema.d.ts +123 -0
- package/src/orm/Schema.d.ts.map +1 -0
- package/src/orm/Schema.js +169 -0
- package/src/orm/adapters/D1Adapter.d.ts +15 -0
- package/src/orm/adapters/D1Adapter.d.ts.map +1 -0
- package/src/orm/adapters/D1Adapter.js +125 -0
- package/src/orm/adapters/MySQLAdapter.d.ts +16 -0
- package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -0
- package/src/orm/adapters/MySQLAdapter.js +87 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts +16 -0
- package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -0
- package/src/orm/adapters/PostgreSQLAdapter.js +87 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts +16 -0
- package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SQLServerAdapter.js +81 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts +11 -0
- package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -0
- package/src/orm/adapters/SQLiteAdapter.js +131 -0
- package/src/performance/Benchmark.d.ts +87 -0
- package/src/performance/Benchmark.d.ts.map +1 -0
- package/src/performance/Benchmark.js +304 -0
- package/src/performance/CodeGenerationBenchmark.d.ts +23 -0
- package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -0
- package/src/performance/CodeGenerationBenchmark.js +249 -0
- package/src/performance/Optimizer.d.ts +99 -0
- package/src/performance/Optimizer.d.ts.map +1 -0
- package/src/performance/Optimizer.js +396 -0
- package/src/performance/establish-baseline.d.ts +9 -0
- package/src/performance/establish-baseline.d.ts.map +1 -0
- package/src/performance/establish-baseline.js +55 -0
- package/src/profiling/MemoryProfiler.d.ts +32 -0
- package/src/profiling/MemoryProfiler.d.ts.map +1 -0
- package/src/profiling/MemoryProfiler.js +84 -0
- package/src/profiling/N1Detector.d.ts +16 -0
- package/src/profiling/N1Detector.d.ts.map +1 -0
- package/src/profiling/N1Detector.js +120 -0
- package/src/profiling/QueryLogger.d.ts +107 -0
- package/src/profiling/QueryLogger.d.ts.map +1 -0
- package/src/profiling/QueryLogger.js +148 -0
- package/src/profiling/RequestProfiler.d.ts +30 -0
- package/src/profiling/RequestProfiler.d.ts.map +1 -0
- package/src/profiling/RequestProfiler.js +94 -0
- package/src/profiling/types.d.ts +77 -0
- package/src/profiling/types.d.ts.map +1 -0
- package/src/profiling/types.js +5 -0
- package/src/routing/Router.d.ts +52 -0
- package/src/routing/Router.d.ts.map +1 -0
- package/src/routing/Router.js +191 -0
- package/src/runtime/PluginManager.d.ts +30 -0
- package/src/runtime/PluginManager.d.ts.map +1 -0
- package/src/runtime/PluginManager.js +197 -0
- package/src/runtime/PluginRegistry.d.ts +22 -0
- package/src/runtime/PluginRegistry.d.ts.map +1 -0
- package/src/runtime/PluginRegistry.js +93 -0
- package/src/runtime/RuntimeAdapter.d.ts +126 -0
- package/src/runtime/RuntimeAdapter.d.ts.map +1 -0
- package/src/runtime/RuntimeAdapter.js +127 -0
- package/src/runtime/RuntimeDetector.d.ts +15 -0
- package/src/runtime/RuntimeDetector.d.ts.map +1 -0
- package/src/runtime/RuntimeDetector.js +219 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts +43 -0
- package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/CloudflareAdapter.js +175 -0
- package/src/runtime/adapters/DenoAdapter.d.ts +30 -0
- package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/DenoAdapter.js +191 -0
- package/src/runtime/adapters/FargateAdapter.d.ts +40 -0
- package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/FargateAdapter.js +156 -0
- package/src/runtime/adapters/LambdaAdapter.d.ts +13 -0
- package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/LambdaAdapter.js +302 -0
- package/src/runtime/adapters/NodeServerAdapter.d.ts +16 -0
- package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -0
- package/src/runtime/adapters/NodeServerAdapter.js +199 -0
- package/src/scripts/TemplateSync.d.ts +7 -0
- package/src/scripts/TemplateSync.d.ts.map +1 -0
- package/src/scripts/TemplateSync.js +234 -0
- package/src/security/CsrfTokenManager.d.ts +28 -0
- package/src/security/CsrfTokenManager.d.ts.map +1 -0
- package/src/security/CsrfTokenManager.js +78 -0
- package/src/security/Encryptor.d.ts +15 -0
- package/src/security/Encryptor.d.ts.map +1 -0
- package/src/security/Encryptor.js +142 -0
- package/src/security/JwtManager.d.ts +41 -0
- package/src/security/JwtManager.d.ts.map +1 -0
- package/src/security/JwtManager.js +229 -0
- package/src/security/UrlValidator.d.ts +21 -0
- package/src/security/UrlValidator.d.ts.map +1 -0
- package/src/security/UrlValidator.js +42 -0
- package/src/security/XssProtection.d.ts +24 -0
- package/src/security/XssProtection.d.ts.map +1 -0
- package/src/security/XssProtection.js +133 -0
- package/src/templates/TemplateRegistry.d.ts +40 -0
- package/src/templates/TemplateRegistry.d.ts.map +1 -0
- package/src/templates/TemplateRegistry.js +78 -0
- package/src/templates/TemplateRegistry.ts +91 -0
- package/src/templates/adapters/MySQLAdapter.ts.tpl +97 -0
- package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +101 -0
- package/src/templates/adapters/SQLServerAdapter.ts.tpl +95 -0
- package/src/templates/adapters/SQLiteAdapter.ts.tpl +189 -0
- package/src/templates/features/Auth.ts.tpl +40 -0
- package/src/templates/features/Queue.ts.tpl +75 -0
- package/src/templates/project/basic/.env.example.tpl +26 -0
- package/src/templates/project/basic/.env.tpl +164 -0
- package/src/templates/project/basic/README.md.tpl +13 -0
- package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +155 -0
- package/src/templates/project/basic/app/Middleware/ProfilerMiddleware.ts.tpl +55 -0
- package/src/templates/project/basic/app/Middleware/index.ts.tpl +304 -0
- package/src/templates/project/basic/app/Models/Post.ts.tpl +30 -0
- package/src/templates/project/basic/app/Models/User.ts.tpl +53 -0
- package/src/templates/project/basic/config/SecretsManager.ts.tpl +453 -0
- package/src/templates/project/basic/config/app.ts.tpl +97 -0
- package/src/templates/project/basic/config/cache.ts.tpl +117 -0
- package/src/templates/project/basic/config/constants.ts.tpl +70 -0
- package/src/templates/project/basic/config/database.ts.tpl +152 -0
- package/src/templates/project/basic/config/env.ts.tpl +148 -0
- package/src/templates/project/basic/config/features.ts.tpl +57 -0
- package/src/templates/project/basic/config/index.ts.tpl +36 -0
- package/src/templates/project/basic/config/logger.ts.tpl +95 -0
- package/src/templates/project/basic/config/microservices.ts.tpl +104 -0
- package/src/templates/project/basic/config/queue.ts.tpl +134 -0
- package/src/templates/project/basic/config/security.ts.tpl +149 -0
- package/src/templates/project/basic/config/storage.ts.tpl +136 -0
- package/src/templates/project/basic/database/factories/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/database/migrations/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/database/migrations/index.ts.tpl +2 -0
- package/src/templates/project/basic/database/seeders/.gitkeep.tpl +0 -0
- package/src/templates/project/basic/package.json.tpl +22 -0
- package/src/templates/project/basic/routes/api.ts.tpl +135 -0
- package/src/templates/project/basic/src/index.ts.tpl +49 -0
- package/src/templates/project/basic/template.json +17 -0
- package/src/templates/project/basic/tsconfig.json.tpl +20 -0
- package/src/validation/ValidationError.d.ts +42 -0
- package/src/validation/ValidationError.d.ts.map +1 -0
- package/src/validation/ValidationError.js +53 -0
- package/src/validation/Validator.d.ts +60 -0
- package/src/validation/Validator.d.ts.map +1 -0
- package/src/validation/Validator.js +190 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LogsCommand - CLI command for viewing and managing logs
|
|
3
|
+
* Commands: zin logs, zin logs --follow, zin logs --level error, zin logs --clear
|
|
4
|
+
*/
|
|
5
|
+
import { BaseCommand } from '../BaseCommand';
|
|
6
|
+
import { Logger as FileLogger } from '../logger/Logger';
|
|
7
|
+
import { Logger } from '../../config/logger';
|
|
8
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
9
|
+
import fs from '../../node-singletons/fs';
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
const normalizeLogsOptions = (options) => {
|
|
13
|
+
const level = typeof options['level'] === 'string' ? options['level'] : 'info';
|
|
14
|
+
const clear = options['clear'] === true;
|
|
15
|
+
const follow = options['follow'] === true;
|
|
16
|
+
const linesRaw = typeof options['lines'] === 'string' ? options['lines'] : '50';
|
|
17
|
+
const linesParsed = Number.parseInt(linesRaw, 10);
|
|
18
|
+
const lines = Number.isFinite(linesParsed) ? linesParsed : 50;
|
|
19
|
+
const category = typeof options['category'] === 'string' ? options['category'] : 'app';
|
|
20
|
+
return { level, clear, follow, lines, category };
|
|
21
|
+
};
|
|
22
|
+
const getLevelColor = (level) => {
|
|
23
|
+
switch (level.toLowerCase()) {
|
|
24
|
+
case 'debug':
|
|
25
|
+
return chalk.gray;
|
|
26
|
+
case 'info':
|
|
27
|
+
return chalk.blue;
|
|
28
|
+
case 'warn':
|
|
29
|
+
return chalk.yellow;
|
|
30
|
+
case 'error':
|
|
31
|
+
return chalk.red;
|
|
32
|
+
default:
|
|
33
|
+
return chalk.white;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const printLogEntry = (log) => {
|
|
37
|
+
const timestamp = chalk.gray(log.timestamp);
|
|
38
|
+
const levelColor = getLevelColor(log.level);
|
|
39
|
+
const level = levelColor(`[${log.level.toUpperCase()}]`);
|
|
40
|
+
let output = `${timestamp} ${level} ${log.message}`;
|
|
41
|
+
if (log.data !== undefined && Object.keys(log.data).length > 0) {
|
|
42
|
+
output += ` ${chalk.cyan(JSON.stringify(log.data))}`;
|
|
43
|
+
}
|
|
44
|
+
Logger.info(output);
|
|
45
|
+
};
|
|
46
|
+
const parseLogEntry = (loggerInstance, line) => {
|
|
47
|
+
const maybe = loggerInstance;
|
|
48
|
+
if (typeof maybe.parseLogEntry !== 'function') {
|
|
49
|
+
throw ErrorFactory.createGeneralError('LoggerInstance does not support parseLogEntry');
|
|
50
|
+
}
|
|
51
|
+
return maybe.parseLogEntry(line);
|
|
52
|
+
};
|
|
53
|
+
const processLogChunk = (chunk, loggerInstance) => {
|
|
54
|
+
const chunkStr = typeof chunk === 'string' ? chunk : chunk.toString('utf-8');
|
|
55
|
+
const lines = chunkStr.split('\n').filter((line) => line.trim() !== '');
|
|
56
|
+
for (const line of lines) {
|
|
57
|
+
try {
|
|
58
|
+
const entry = parseLogEntry(loggerInstance, line);
|
|
59
|
+
printLogEntry(entry);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
ErrorFactory.createTryCatchError('Failed to process log line', error);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const displayLogs = (loggerInstance, level, lines, category) => {
|
|
67
|
+
const logs = loggerInstance.getLogs(category, lines);
|
|
68
|
+
if (logs.length === 0) {
|
|
69
|
+
Logger.info(chalk.yellow('ℹ No logs found'));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
let filtered = logs;
|
|
73
|
+
if (level !== '' && level !== 'all') {
|
|
74
|
+
filtered = loggerInstance.filterByLevel(logs, level);
|
|
75
|
+
}
|
|
76
|
+
if (filtered.length === 0) {
|
|
77
|
+
Logger.info(chalk.yellow(`ℹ No logs found with level: ${level}`));
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
Logger.info(chalk.blue(`📋 Last ${filtered.length} log entries (${category}):\n`));
|
|
81
|
+
for (const log of [...filtered].reverse()) {
|
|
82
|
+
printLogEntry(log);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const followLogs = (category) => {
|
|
86
|
+
const loggerInstance = FileLogger.getInstance();
|
|
87
|
+
const logsDir = loggerInstance.getLogsDirectory();
|
|
88
|
+
const categoryDir = path.join(logsDir, category);
|
|
89
|
+
if (!fs.existsSync(categoryDir)) {
|
|
90
|
+
Logger.info(chalk.red(`✗ Log category directory not found: ${categoryDir}`));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const today = new Date().toISOString().split('T')[0];
|
|
94
|
+
const logFile = path.join(categoryDir, `${today}.log`);
|
|
95
|
+
Logger.info(chalk.blue(`👀 Following logs: ${logFile}\n`));
|
|
96
|
+
Logger.info(chalk.gray('Press Ctrl+C to stop...\n'));
|
|
97
|
+
let lastSize = 0;
|
|
98
|
+
const interval = setInterval(() => {
|
|
99
|
+
if (!fs.existsSync(logFile))
|
|
100
|
+
return;
|
|
101
|
+
const stats = fs.statSync(logFile);
|
|
102
|
+
if (stats.size <= lastSize)
|
|
103
|
+
return;
|
|
104
|
+
const stream = fs.createReadStream(logFile, {
|
|
105
|
+
start: lastSize,
|
|
106
|
+
encoding: 'utf-8',
|
|
107
|
+
});
|
|
108
|
+
stream.on('data', (chunk) => {
|
|
109
|
+
processLogChunk(chunk, loggerInstance);
|
|
110
|
+
});
|
|
111
|
+
lastSize = stats.size;
|
|
112
|
+
}, 1000);
|
|
113
|
+
process.on('SIGINT', () => {
|
|
114
|
+
clearInterval(interval);
|
|
115
|
+
Logger.info(chalk.yellow('\n\nLog following stopped'));
|
|
116
|
+
process.exit(0);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const clearLogs = (loggerInstance, category) => {
|
|
120
|
+
const confirmed = true;
|
|
121
|
+
if (!confirmed) {
|
|
122
|
+
Logger.info(chalk.yellow('Clearing logs cancelled'));
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const success = loggerInstance.clearLogs(category);
|
|
126
|
+
if (success === true) {
|
|
127
|
+
Logger.info(chalk.green(`✓ Cleared logs for category: ${category}`));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
Logger.info(chalk.red(`✗ Failed to clear logs for category: ${category}`));
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
const executeLogs = (options) => {
|
|
134
|
+
const normalized = normalizeLogsOptions(options);
|
|
135
|
+
const loggerInstance = FileLogger.getInstance();
|
|
136
|
+
if (normalized.clear) {
|
|
137
|
+
clearLogs(loggerInstance, normalized.category);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (normalized.follow) {
|
|
141
|
+
followLogs(normalized.category);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
displayLogs(loggerInstance, normalized.level, normalized.lines, normalized.category);
|
|
145
|
+
};
|
|
146
|
+
export const LogsCommand = Object.freeze({
|
|
147
|
+
/**
|
|
148
|
+
* Create a new logs command instance
|
|
149
|
+
*/
|
|
150
|
+
create() {
|
|
151
|
+
const addOptions = (command) => {
|
|
152
|
+
command
|
|
153
|
+
.option('-l, --level <level>', 'Filter by log level (debug, info, warn, error)', 'info')
|
|
154
|
+
.option('-c, --clear', 'Clear all logs')
|
|
155
|
+
.option('-f, --follow', 'Follow logs in real-time (like tail -f)')
|
|
156
|
+
.option('-n, --lines <number>', 'Number of lines to show', '50')
|
|
157
|
+
.option('--category <category>', 'Log category (app, cli, errors, migrations, debug)', 'app');
|
|
158
|
+
};
|
|
159
|
+
const cmd = BaseCommand.create({
|
|
160
|
+
name: 'logs',
|
|
161
|
+
description: 'View and manage application logs',
|
|
162
|
+
addOptions,
|
|
163
|
+
execute: (options) => executeLogs(options),
|
|
164
|
+
});
|
|
165
|
+
return cmd;
|
|
166
|
+
},
|
|
167
|
+
/**
|
|
168
|
+
* Register the command with Commander
|
|
169
|
+
* @deprecated Use create() instead
|
|
170
|
+
*/
|
|
171
|
+
register(program) {
|
|
172
|
+
const cmd = program.command('logs');
|
|
173
|
+
cmd.description('View and manage application logs');
|
|
174
|
+
cmd
|
|
175
|
+
.option('-l, --level <level>', 'Filter by log level (debug, info, warn, error)', 'info')
|
|
176
|
+
.option('-c, --clear', 'Clear all logs')
|
|
177
|
+
.option('-f, --follow', 'Follow logs in real-time (like tail -f)')
|
|
178
|
+
.option('-n, --lines <number>', 'Number of lines to show', '50')
|
|
179
|
+
.option('--category <category>', 'Log category (app, cli, errors, migrations, debug)', 'app');
|
|
180
|
+
cmd.action((options) => {
|
|
181
|
+
executeLogs(options);
|
|
182
|
+
});
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
export default LogsCommand;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migrate Command
|
|
3
|
+
* Run database migrations
|
|
4
|
+
*/
|
|
5
|
+
import { IBaseCommand } from '../BaseCommand';
|
|
6
|
+
/**
|
|
7
|
+
* Migrate Command Factory
|
|
8
|
+
*/
|
|
9
|
+
export declare const MigrateCommand: Readonly<{
|
|
10
|
+
/**
|
|
11
|
+
* Create a new migrate command instance
|
|
12
|
+
*/
|
|
13
|
+
create(): IBaseCommand;
|
|
14
|
+
}>;
|
|
15
|
+
//# sourceMappingURL=MigrateCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrateCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/MigrateCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAI7E;;GAEG;AACH,eAAO,MAAM,cAAc;IACzB;;OAEG;cACO,YAAY;EA8CtB,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Migrate Command
|
|
3
|
+
* Run database migrations
|
|
4
|
+
*/
|
|
5
|
+
import { BaseCommand } from '../BaseCommand';
|
|
6
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
7
|
+
/**
|
|
8
|
+
* Migrate Command Factory
|
|
9
|
+
*/
|
|
10
|
+
export const MigrateCommand = Object.freeze({
|
|
11
|
+
/**
|
|
12
|
+
* Create a new migrate command instance
|
|
13
|
+
*/
|
|
14
|
+
create() {
|
|
15
|
+
const addOptions = (command) => {
|
|
16
|
+
command
|
|
17
|
+
.option('--fresh', 'Drop all tables and re-run migrations')
|
|
18
|
+
.option('--rollback', 'Rollback last migration batch')
|
|
19
|
+
.option('--reset', 'Rollback all migrations')
|
|
20
|
+
.option('--step <number>', 'Number of batches to rollback', '0');
|
|
21
|
+
};
|
|
22
|
+
const execute = async (options, cmd) => {
|
|
23
|
+
cmd.debug(`Migrate command executed with options: ${JSON.stringify(options)}`);
|
|
24
|
+
try {
|
|
25
|
+
cmd.info('Loading configuration...');
|
|
26
|
+
// Configuration loading would go here
|
|
27
|
+
if (options['fresh'] === true) {
|
|
28
|
+
cmd.warn('This will drop all tables and re-run migrations');
|
|
29
|
+
// Confirmation would go here
|
|
30
|
+
cmd.success('Fresh migration completed');
|
|
31
|
+
}
|
|
32
|
+
else if (options['rollback'] === true) {
|
|
33
|
+
cmd.success('Migrations rolled back');
|
|
34
|
+
}
|
|
35
|
+
else if (options['reset'] === true) {
|
|
36
|
+
cmd.warn('Resetting all migrations');
|
|
37
|
+
cmd.success('All migrations reset');
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
cmd.info('Running pending migrations...');
|
|
41
|
+
cmd.success('Migrations completed successfully');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
throw ErrorFactory.createTryCatchError(`Migration failed: ${error.message}`, error);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const cmd = BaseCommand.create({
|
|
49
|
+
name: 'migrate',
|
|
50
|
+
description: 'Run database migrations',
|
|
51
|
+
addOptions,
|
|
52
|
+
execute: async (options) => execute(options, cmd),
|
|
53
|
+
});
|
|
54
|
+
return cmd;
|
|
55
|
+
},
|
|
56
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { CommandOptions, IBaseCommand } from '../BaseCommand';
|
|
2
|
+
type TemplateType = 'basic' | 'api' | 'microservice';
|
|
3
|
+
type DatabaseType = 'sqlite' | 'mysql' | 'postgresql' | 'mongodb';
|
|
4
|
+
interface NewProjectConfigResult {
|
|
5
|
+
template: TemplateType;
|
|
6
|
+
database: DatabaseType;
|
|
7
|
+
port: number;
|
|
8
|
+
author: string;
|
|
9
|
+
description: string;
|
|
10
|
+
}
|
|
11
|
+
type InquirerQuestion = Record<string, unknown>;
|
|
12
|
+
interface INewCommand extends IBaseCommand {
|
|
13
|
+
promptForConfig(name: string, options: CommandOptions): Promise<NewProjectConfigResult>;
|
|
14
|
+
getProjectConfig(name: string, options: CommandOptions): Promise<NewProjectConfigResult>;
|
|
15
|
+
getQuestions(name: string, defaults: NewProjectConfigResult): InquirerQuestion[];
|
|
16
|
+
getSafeEnv(): NodeJS.ProcessEnv;
|
|
17
|
+
getGitBinary(): string;
|
|
18
|
+
runScaffolding(name: string, config: NewProjectConfigResult, overwrite?: boolean): Promise<unknown>;
|
|
19
|
+
initializeGit(name: string): void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* New Command Factory
|
|
23
|
+
* Sealed namespace for immutability
|
|
24
|
+
*/
|
|
25
|
+
export declare const NewCommand: Readonly<{
|
|
26
|
+
/**
|
|
27
|
+
* Create a new project command instance
|
|
28
|
+
*/
|
|
29
|
+
create(): INewCommand;
|
|
30
|
+
}>;
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=NewCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NewCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/NewCommand.ts"],"names":[],"mappings":"AAOA,OAAO,EAAe,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAS7E,KAAK,YAAY,GAAG,OAAO,GAAG,KAAK,GAAG,cAAc,CAAC;AACrD,KAAK,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,GAAG,SAAS,CAAC;AAYlE,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;AAwLhD,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,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,sBAAsB,EAC9B,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,OAAO,CAAC,CAAC;IACpB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC;AAsHD;;;GAGG;AACH,eAAO,MAAM,UAAU;IACrB;;OAEG;cACO,WAAW;EAGrB,CAAC"}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { appConfig } from '../../config/app';
|
|
2
|
+
/**
|
|
3
|
+
* New Command - Project scaffolding CLI command
|
|
4
|
+
* Handles creation of new Zintrust projects
|
|
5
|
+
*/
|
|
6
|
+
import { resolveNpmPath } from '../../common';
|
|
7
|
+
import { BaseCommand } from '../BaseCommand';
|
|
8
|
+
import { PromptHelper } from '../PromptHelper';
|
|
9
|
+
import { ProjectScaffolder } from '../scaffolding/ProjectScaffolder';
|
|
10
|
+
import { ErrorFactory } from '../../exceptions/ZintrustError';
|
|
11
|
+
import { execFileSync } from '../../node-singletons/child-process';
|
|
12
|
+
import * as path from '../../node-singletons/path';
|
|
13
|
+
import chalk from 'chalk';
|
|
14
|
+
const errorToMessage = (error) => {
|
|
15
|
+
if (error instanceof Error)
|
|
16
|
+
return error.message;
|
|
17
|
+
return 'Unknown error';
|
|
18
|
+
};
|
|
19
|
+
const getGitBinary = () => 'git';
|
|
20
|
+
const checkGitInstalled = () => {
|
|
21
|
+
try {
|
|
22
|
+
execFileSync(getGitBinary(), ['--version'], { stdio: 'ignore', env: appConfig.getSafeEnv() });
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
ErrorFactory.createCliError('Git check failed', error);
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const initializeGitRepo = (projectPath, log) => {
|
|
31
|
+
try {
|
|
32
|
+
const git = getGitBinary();
|
|
33
|
+
const env = appConfig.getSafeEnv();
|
|
34
|
+
execFileSync(git, ['init'], { cwd: projectPath, stdio: 'ignore', env });
|
|
35
|
+
execFileSync(git, ['add', '.'], { cwd: projectPath, stdio: 'ignore', env });
|
|
36
|
+
execFileSync(git, ['commit', '-m', 'Initial commit from Zintrust'], {
|
|
37
|
+
cwd: projectPath,
|
|
38
|
+
stdio: 'ignore',
|
|
39
|
+
env,
|
|
40
|
+
});
|
|
41
|
+
log.info('✅ Git repository initialized');
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
ErrorFactory.createCliError('Git initialization failed', error);
|
|
45
|
+
log.warn('Could not initialize git repository');
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const getStringOption = (options, key, fallback) => {
|
|
49
|
+
const value = options[key];
|
|
50
|
+
return typeof value === 'string' && value !== '' ? value : fallback;
|
|
51
|
+
};
|
|
52
|
+
const getBooleanOption = (options, key, fallback) => {
|
|
53
|
+
const value = options[key];
|
|
54
|
+
return typeof value === 'boolean' ? value : fallback;
|
|
55
|
+
};
|
|
56
|
+
const getProjectDefaults = (name, options) => {
|
|
57
|
+
const template = getStringOption(options, 'template', 'basic');
|
|
58
|
+
const database = getStringOption(options, 'database', 'sqlite');
|
|
59
|
+
const portRaw = getStringOption(options, 'port', '3003');
|
|
60
|
+
const portParsed = Number.parseInt(portRaw, 10);
|
|
61
|
+
const port = Number.isFinite(portParsed) && portParsed > 0 ? portParsed : 3000;
|
|
62
|
+
const author = getStringOption(options, 'author', '');
|
|
63
|
+
const description = getStringOption(options, 'description', `A new Zintrust project: ${name}`);
|
|
64
|
+
const interactive = getBooleanOption(options, 'interactive', true);
|
|
65
|
+
return { name, template, database, port, author, description, interactive };
|
|
66
|
+
};
|
|
67
|
+
const toConfigResult = (config) => ({
|
|
68
|
+
template: config.template,
|
|
69
|
+
database: config.database,
|
|
70
|
+
port: config.port,
|
|
71
|
+
author: config.author,
|
|
72
|
+
description: config.description,
|
|
73
|
+
});
|
|
74
|
+
const getQuestions = (name, defaults) => {
|
|
75
|
+
return [
|
|
76
|
+
{
|
|
77
|
+
type: 'list',
|
|
78
|
+
name: 'template',
|
|
79
|
+
message: 'Project template:',
|
|
80
|
+
choices: ['basic', 'api', 'microservice'],
|
|
81
|
+
default: defaults.template,
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: 'list',
|
|
85
|
+
name: 'database',
|
|
86
|
+
message: 'Database driver:',
|
|
87
|
+
choices: ['sqlite', 'mysql', 'postgresql', 'mongodb'],
|
|
88
|
+
default: defaults.database,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'input',
|
|
92
|
+
name: 'port',
|
|
93
|
+
message: 'Default port number:',
|
|
94
|
+
default: String(defaults.port),
|
|
95
|
+
validate: (value) => {
|
|
96
|
+
const port = Number.parseInt(value, 10);
|
|
97
|
+
return Number.isFinite(port) && port > 0 && port < 65536;
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'input',
|
|
102
|
+
name: 'author',
|
|
103
|
+
message: 'Project author:',
|
|
104
|
+
default: defaults.author,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'input',
|
|
108
|
+
name: 'description',
|
|
109
|
+
message: 'Project description:',
|
|
110
|
+
default: defaults.description === '' ? `A new Zintrust project: ${name}` : defaults.description,
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
};
|
|
114
|
+
const mergePromptAnswers = (defaults, answers) => {
|
|
115
|
+
const template = typeof answers['template'] === 'string'
|
|
116
|
+
? answers['template']
|
|
117
|
+
: defaults.template;
|
|
118
|
+
const database = typeof answers['database'] === 'string'
|
|
119
|
+
? answers['database']
|
|
120
|
+
: defaults.database;
|
|
121
|
+
let port = defaults.port;
|
|
122
|
+
const portAnswer = answers['port'];
|
|
123
|
+
if (typeof portAnswer === 'string') {
|
|
124
|
+
const parsed = Number.parseInt(portAnswer, 10);
|
|
125
|
+
if (Number.isFinite(parsed))
|
|
126
|
+
port = parsed;
|
|
127
|
+
}
|
|
128
|
+
else if (typeof portAnswer === 'number') {
|
|
129
|
+
if (Number.isFinite(portAnswer))
|
|
130
|
+
port = portAnswer;
|
|
131
|
+
}
|
|
132
|
+
const author = typeof answers['author'] === 'string' ? answers['author'] : defaults.author;
|
|
133
|
+
const description = typeof answers['description'] === 'string' ? answers['description'] : defaults.description;
|
|
134
|
+
return {
|
|
135
|
+
...defaults,
|
|
136
|
+
template,
|
|
137
|
+
database,
|
|
138
|
+
port,
|
|
139
|
+
author,
|
|
140
|
+
description,
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
const promptForConfig = async (name, options) => {
|
|
144
|
+
const defaults = getProjectDefaults(name, options);
|
|
145
|
+
if (defaults.interactive === false)
|
|
146
|
+
return defaults;
|
|
147
|
+
const questions = getQuestions(name, defaults);
|
|
148
|
+
const answers = await PromptHelper.prompt(questions);
|
|
149
|
+
return mergePromptAnswers(defaults, answers);
|
|
150
|
+
};
|
|
151
|
+
const isFailureResult = (result) => {
|
|
152
|
+
if (typeof result !== 'object' || result === null)
|
|
153
|
+
return false;
|
|
154
|
+
const maybe = result;
|
|
155
|
+
return maybe.success === false;
|
|
156
|
+
};
|
|
157
|
+
const installDependencies = (projectPath, log) => {
|
|
158
|
+
log.info('📦 Installing dependencies (this may take a minute)...');
|
|
159
|
+
try {
|
|
160
|
+
const npmPath = resolveNpmPath();
|
|
161
|
+
execFileSync(npmPath, ['install'], {
|
|
162
|
+
cwd: projectPath,
|
|
163
|
+
stdio: 'inherit',
|
|
164
|
+
env: appConfig.getSafeEnv(),
|
|
165
|
+
});
|
|
166
|
+
log.info('✅ Dependencies installed successfully');
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
ErrorFactory.createCliError('Dependency installation failed', error);
|
|
170
|
+
log.warn('Please run "npm install" manually in the project directory');
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
const addOptions = (command) => {
|
|
174
|
+
command.argument('<name>', 'Project name');
|
|
175
|
+
command.option('--template <type>', 'Project template (basic, api, microservice)', 'basic');
|
|
176
|
+
command.option('--database <type>', 'Database driver (sqlite, mysql, postgresql)', 'sqlite');
|
|
177
|
+
command.option('--port <number>', 'Default port number', '3003');
|
|
178
|
+
command.option('--author <name>', 'Project author');
|
|
179
|
+
command.option('--description <text>', 'Project description');
|
|
180
|
+
command.option('--interactive', 'Run in interactive mode', true);
|
|
181
|
+
command.option('--no-interactive', 'Disable interactive mode');
|
|
182
|
+
command.option('--no-git', 'Skip git initialization');
|
|
183
|
+
command.option('--no-install', 'Skip dependency installation');
|
|
184
|
+
command.option('--force', 'Overwrite existing directory');
|
|
185
|
+
command.option('--overwrite', 'Overwrite existing directory');
|
|
186
|
+
};
|
|
187
|
+
const executeNewCommand = async (options, command) => {
|
|
188
|
+
try {
|
|
189
|
+
const argName = options.args?.[0];
|
|
190
|
+
const projectName = argName ?? (await PromptHelper.projectName('my-zintrust-app', true));
|
|
191
|
+
if (!projectName)
|
|
192
|
+
throw ErrorFactory.createCliError('Project name is required');
|
|
193
|
+
const config = await command.getProjectConfig(projectName, options);
|
|
194
|
+
command.info(chalk.bold(`\n🚀 Creating new Zintrust project in ${projectName}...\n`));
|
|
195
|
+
const overwrite = options['overwrite'] === true || options['force'] === true ? true : undefined;
|
|
196
|
+
const result = await command.runScaffolding(projectName, config, overwrite);
|
|
197
|
+
if (isFailureResult(result)) {
|
|
198
|
+
throw ErrorFactory.createCliError(result.message ?? 'Project scaffolding failed', result);
|
|
199
|
+
}
|
|
200
|
+
if (options['git'] !== false) {
|
|
201
|
+
command.initializeGit(projectName);
|
|
202
|
+
}
|
|
203
|
+
if (options['install'] !== false) {
|
|
204
|
+
const projectPath = path.resolve(process.cwd(), projectName);
|
|
205
|
+
installDependencies(projectPath, command);
|
|
206
|
+
}
|
|
207
|
+
command.success(`\n✨ Project ${projectName} created successfully!`);
|
|
208
|
+
command.info(`\nNext steps:\n cd ${projectName}\n npm run dev\n`);
|
|
209
|
+
}
|
|
210
|
+
catch (error) {
|
|
211
|
+
throw ErrorFactory.createCliError(`Project creation failed: ${errorToMessage(error)}`, error);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const createNewCommandInstance = () => {
|
|
215
|
+
const base = BaseCommand.create({
|
|
216
|
+
name: 'new',
|
|
217
|
+
description: 'Create a new Zintrust project',
|
|
218
|
+
addOptions,
|
|
219
|
+
execute: async (_options) => {
|
|
220
|
+
// replaced below with NewCommand-aware execute implementation
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
const commandInstance = {
|
|
224
|
+
...base,
|
|
225
|
+
promptForConfig: async (name, options) => {
|
|
226
|
+
const config = await promptForConfig(name, options);
|
|
227
|
+
return toConfigResult(config);
|
|
228
|
+
},
|
|
229
|
+
getSafeEnv: () => appConfig.getSafeEnv(),
|
|
230
|
+
getGitBinary: () => getGitBinary(),
|
|
231
|
+
getQuestions: (name, defaults) => {
|
|
232
|
+
const fullDefaults = {
|
|
233
|
+
name,
|
|
234
|
+
template: defaults.template,
|
|
235
|
+
database: defaults.database,
|
|
236
|
+
port: defaults.port,
|
|
237
|
+
author: defaults.author,
|
|
238
|
+
description: defaults.description,
|
|
239
|
+
interactive: true,
|
|
240
|
+
};
|
|
241
|
+
return getQuestions(name, fullDefaults);
|
|
242
|
+
},
|
|
243
|
+
getProjectConfig: async (name, options) => {
|
|
244
|
+
return commandInstance.promptForConfig(name, options);
|
|
245
|
+
},
|
|
246
|
+
runScaffolding: async (name, config, overwrite) => {
|
|
247
|
+
return ProjectScaffolder.scaffold(process.cwd(), {
|
|
248
|
+
name,
|
|
249
|
+
force: overwrite === true,
|
|
250
|
+
template: config.template,
|
|
251
|
+
database: config.database,
|
|
252
|
+
port: config.port,
|
|
253
|
+
author: config.author,
|
|
254
|
+
description: config.description,
|
|
255
|
+
});
|
|
256
|
+
},
|
|
257
|
+
initializeGit: (name) => {
|
|
258
|
+
const projectPath = path.resolve(process.cwd(), name);
|
|
259
|
+
if (checkGitInstalled()) {
|
|
260
|
+
initializeGitRepo(projectPath, commandInstance);
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
execute: async (options) => {
|
|
264
|
+
await executeNewCommand(options, commandInstance);
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
return commandInstance;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* New Command Factory
|
|
271
|
+
* Sealed namespace for immutability
|
|
272
|
+
*/
|
|
273
|
+
export const NewCommand = Object.freeze({
|
|
274
|
+
/**
|
|
275
|
+
* Create a new project command instance
|
|
276
|
+
*/
|
|
277
|
+
create() {
|
|
278
|
+
return createNewCommandInstance();
|
|
279
|
+
},
|
|
280
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginCommand.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/PluginCommand.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAA+B,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAK7E,eAAO,MAAM,aAAa;cACd,YAAY;EAsDtB,CAAC"}
|