@warlock.js/core 5.1.0 → 5.2.1
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/CHANGELOG.md +152 -0
- package/esm/application/application.d.mts.map +1 -1
- package/esm/application/application.mjs.map +1 -1
- package/esm/benchmark/benchmark-snapshots.d.mts.map +1 -1
- package/esm/benchmark/benchmark.d.mts.map +1 -1
- package/esm/benchmark/channels/console.channel.mjs.map +1 -1
- package/esm/benchmark/channels/noop.channel.d.mts.map +1 -1
- package/esm/benchmark/profiler.d.mts.map +1 -1
- package/esm/benchmark/profiler.mjs.map +1 -1
- package/esm/bootstrap/setup.d.mts.map +1 -1
- package/esm/bootstrap/setup.mjs.map +1 -1
- package/esm/bootstrap.d.mts.map +1 -1
- package/esm/cache/database-cache-driver.d.mts.map +1 -1
- package/esm/cache/database-cache-driver.mjs.map +1 -1
- package/esm/cli/cli-commands.manager.mjs.map +1 -1
- package/esm/cli/cli-commands.utils.mjs +16 -10
- package/esm/cli/cli-commands.utils.mjs.map +1 -1
- package/esm/cli/commands/doctor/boot-for-diagnostics.mjs.map +1 -1
- package/esm/cli/commands/doctor/checks/connectors.check.mjs.map +1 -1
- package/esm/cli/commands/doctor/checks/handler-signature.check.mjs.map +1 -1
- package/esm/cli/commands/doctor/checks/health.check.mjs.map +1 -1
- package/esm/cli/commands/doctor/checks/optional-peers.check.mjs.map +1 -1
- package/esm/cli/commands/doctor/checks/routes.check.mjs.map +1 -1
- package/esm/cli/commands/generate/generate.command.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/column-dsl-parser.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/migration.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/generators/model.generator.mjs.map +1 -1
- package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -1
- package/esm/cli/commands/generate/utils/name-parser.mjs.map +1 -1
- package/esm/cli/commands/generate/utils/prompt.mjs.map +1 -1
- package/esm/cli/commands/routes/diff-page-routes.mjs +84 -0
- package/esm/cli/commands/routes/diff-page-routes.mjs.map +1 -0
- package/esm/cli/commands/routes/format-routes-table.mjs.map +1 -1
- package/esm/cli/commands/routes/route-row.mjs.map +1 -1
- package/esm/cli/commands/routes/routes-command.action.mjs.map +1 -1
- package/esm/cli/commands/routes/routes-diff.action.mjs +84 -0
- package/esm/cli/commands/routes/routes-diff.action.mjs.map +1 -0
- package/esm/cli/commands/routes.command.mjs +15 -1
- package/esm/cli/commands/routes.command.mjs.map +1 -1
- package/esm/cli/commands/start-production.command.mjs +8 -1
- package/esm/cli/commands/start-production.command.mjs.map +1 -1
- package/esm/cli/commands/storage-put.action.mjs.map +1 -1
- package/esm/cli/commands/typings-generator.command.mjs.map +1 -1
- package/esm/cli/commands-loader.mjs.map +1 -1
- package/esm/cli/framework-cli-commands.mjs +2 -1
- package/esm/cli/framework-cli-commands.mjs.map +1 -1
- package/esm/cli/start.mjs.map +1 -1
- package/esm/cli/string-similarity.mjs.map +1 -1
- package/esm/commands/cli-command.mjs.map +1 -1
- package/esm/config/config-loader.d.mts +1 -1
- package/esm/config/config-loader.d.mts.map +1 -1
- package/esm/config/config-loader.mjs.map +1 -1
- package/esm/config/config-setter.d.mts.map +1 -1
- package/esm/config/config-special-handlers.d.mts +1 -1
- package/esm/config/config-special-handlers.mjs.map +1 -1
- package/esm/config/load-config-files.mjs.map +1 -1
- package/esm/connectors/access-connector.d.mts.map +1 -1
- package/esm/connectors/ai-connector.d.mts.map +1 -1
- package/esm/connectors/assert-no-reserved-connector-names.mjs.map +1 -1
- package/esm/connectors/assert-unique-connector-names.mjs.map +1 -1
- package/esm/connectors/base-connector.d.mts.map +1 -1
- package/esm/connectors/base-connector.mjs.map +1 -1
- package/esm/connectors/cache-connector.d.mts.map +1 -1
- package/esm/connectors/connectors-manager.d.mts.map +1 -1
- package/esm/connectors/connectors-manager.mjs.map +1 -1
- package/esm/connectors/database-connector.d.mts.map +1 -1
- package/esm/connectors/describe-server-address.mjs +20 -3
- package/esm/connectors/describe-server-address.mjs.map +1 -1
- package/esm/connectors/herald-connector.d.mts.map +1 -1
- package/esm/connectors/http-connector.d.mts.map +1 -1
- package/esm/connectors/http-connector.mjs +5 -1
- package/esm/connectors/http-connector.mjs.map +1 -1
- package/esm/connectors/logger-connector.d.mts.map +1 -1
- package/esm/connectors/mail-connector.d.mts.map +1 -1
- package/esm/connectors/notifications-connector.d.mts.map +1 -1
- package/esm/connectors/register-configured-connectors.mjs.map +1 -1
- package/esm/connectors/socket-connector.d.mts.map +1 -1
- package/esm/connectors/socket-connector.mjs.map +1 -1
- package/esm/connectors/storage.connector.d.mts.map +1 -1
- package/esm/container/index.d.mts.map +1 -1
- package/esm/database/create-database-action.mjs.map +1 -1
- package/esm/database/drop-tables-action.mjs.map +1 -1
- package/esm/database/migrate-action.mjs.map +1 -1
- package/esm/database/models/database-log/database-log.mjs.map +1 -1
- package/esm/database/seed-command-action.mjs.map +1 -1
- package/esm/database/seeds/seed-records-table-migration.mjs +1 -1
- package/esm/database/seeds/seed-records-table-migration.mjs.map +1 -1
- package/esm/database/seeds/seeder.mjs.map +1 -1
- package/esm/database/seeds/seeders.manager.mjs.map +1 -1
- package/esm/database/seeds/seeds-table-migration.mjs +1 -1
- package/esm/database/seeds/seeds-table-migration.mjs.map +1 -1
- package/esm/database/utils.mjs.map +1 -1
- package/esm/dev-server/check-for-updates.mjs.map +1 -1
- package/esm/dev-server/dependency-graph.d.mts.map +1 -1
- package/esm/dev-server/dependency-graph.mjs.map +1 -1
- package/esm/dev-server/dev-logger.mjs.map +1 -1
- package/esm/dev-server/development-server.mjs.map +1 -1
- package/esm/dev-server/file-event-handler.mjs.map +1 -1
- package/esm/dev-server/file-manager.d.mts.map +1 -1
- package/esm/dev-server/file-manager.mjs.map +1 -1
- package/esm/dev-server/file-operations.d.mts.map +1 -1
- package/esm/dev-server/files-orchestrator.mjs.map +1 -1
- package/esm/dev-server/files-watcher.mjs.map +1 -1
- package/esm/dev-server/health-checker/checkers/eslint-health-checker.mjs.map +1 -1
- package/esm/dev-server/health-checker/checkers/typescript-health-checker.mjs.map +1 -1
- package/esm/dev-server/health-checker/file-health-result.d.mts.map +1 -1
- package/esm/dev-server/health-checker/file-health-result.mjs.map +1 -1
- package/esm/dev-server/health-checker/files-healthcare.manager.mjs.map +1 -1
- package/esm/dev-server/layer-executor.mjs +10 -3
- package/esm/dev-server/layer-executor.mjs.map +1 -1
- package/esm/dev-server/loader/hook-thread.d.mts.map +1 -1
- package/esm/dev-server/loader/own-resolver.mjs.map +1 -1
- package/esm/dev-server/loader/register-loader.mjs.map +1 -1
- package/esm/dev-server/loader/resolve-hook.mjs.map +1 -1
- package/esm/dev-server/loader/source-slug.mjs.map +1 -1
- package/esm/dev-server/loader/transpile-cache.mjs +12 -3
- package/esm/dev-server/loader/transpile-cache.mjs.map +1 -1
- package/esm/dev-server/loader/version-registry.mjs.map +1 -1
- package/esm/dev-server/manifest-manager.d.mts.map +1 -1
- package/esm/dev-server/manifest-manager.mjs.map +1 -1
- package/esm/dev-server/module-loader.mjs.map +1 -1
- package/esm/dev-server/package-json-manager.mjs.map +1 -1
- package/esm/dev-server/parse-imports.mjs.map +1 -1
- package/esm/dev-server/ready-block.mjs.map +1 -1
- package/esm/dev-server/special-files-collector.d.mts.map +1 -1
- package/esm/dev-server/special-files-collector.mjs.map +1 -1
- package/esm/dev-server/supervisor.mjs +9 -6
- package/esm/dev-server/supervisor.mjs.map +1 -1
- package/esm/dev-server/tsconfig-manager.mjs.map +1 -1
- package/esm/dev-server/type-generator.mjs.map +1 -1
- package/esm/dev-server/utils.mjs.map +1 -1
- package/esm/encryption/encrypt.mjs.map +1 -1
- package/esm/encryption/hash.mjs.map +1 -1
- package/esm/encryption/password.mjs.map +1 -1
- package/esm/generations/add-command.action.mjs +11 -4
- package/esm/generations/add-command.action.mjs.map +1 -1
- package/esm/generations/features/access.feature.mjs +2 -1
- package/esm/generations/features/access.feature.mjs.map +1 -1
- package/esm/generations/features/ai-anthropic.feature.mjs +3 -1
- package/esm/generations/features/ai-anthropic.feature.mjs.map +1 -1
- package/esm/generations/features/ai-bedrock.feature.mjs +3 -1
- package/esm/generations/features/ai-bedrock.feature.mjs.map +1 -1
- package/esm/generations/features/ai-google.feature.mjs +3 -1
- package/esm/generations/features/ai-google.feature.mjs.map +1 -1
- package/esm/generations/features/ai-ollama.feature.mjs +3 -1
- package/esm/generations/features/ai-ollama.feature.mjs.map +1 -1
- package/esm/generations/features/ai-openai.feature.mjs +3 -1
- package/esm/generations/features/ai-openai.feature.mjs.map +1 -1
- package/esm/generations/features/ai-panoptic.feature.mjs +2 -1
- package/esm/generations/features/ai-panoptic.feature.mjs.map +1 -1
- package/esm/generations/features/ai-tools.feature.mjs +2 -1
- package/esm/generations/features/ai-tools.feature.mjs.map +1 -1
- package/esm/generations/features/ai-workspace.feature.mjs +2 -1
- package/esm/generations/features/ai-workspace.feature.mjs.map +1 -1
- package/esm/generations/features/ai.feature.mjs +2 -1
- package/esm/generations/features/ai.feature.mjs.map +1 -1
- package/esm/generations/features/herald.feature.mjs +2 -1
- package/esm/generations/features/herald.feature.mjs.map +1 -1
- package/esm/generations/features/notifications.feature.mjs +3 -2
- package/esm/generations/features/notifications.feature.mjs.map +1 -1
- package/esm/generations/features/scheduler.feature.mjs +3 -1
- package/esm/generations/features/scheduler.feature.mjs.map +1 -1
- package/esm/generations/features/shadcn.feature.mjs.map +1 -1
- package/esm/generations/features/shared/migration-timestamp.mjs.map +1 -1
- package/esm/generations/features/tailwind.feature.mjs.map +1 -1
- package/esm/generations/features/types.mjs +14 -0
- package/esm/generations/features/types.mjs.map +1 -0
- package/esm/generations/features/web.feature.mjs +10 -2
- package/esm/generations/features/web.feature.mjs.map +1 -1
- package/esm/generations/stubs.mjs +169 -28
- package/esm/generations/stubs.mjs.map +1 -1
- package/esm/http/boot-port-preflight.d.mts +46 -0
- package/esm/http/boot-port-preflight.d.mts.map +1 -0
- package/esm/http/boot-port-preflight.mjs +87 -0
- package/esm/http/boot-port-preflight.mjs.map +1 -0
- package/esm/http/context/request-context.d.mts.map +1 -1
- package/esm/http/context/request-context.mjs.map +1 -1
- package/esm/http/context/request-memo.d.mts.map +1 -1
- package/esm/http/context/request-memo.mjs.map +1 -1
- package/esm/http/createHttpApplication.d.mts.map +1 -1
- package/esm/http/createHttpApplication.mjs.map +1 -1
- package/esm/http/health.d.mts.map +1 -1
- package/esm/http/index.d.mts +1 -0
- package/esm/http/index.mjs +1 -0
- package/esm/http/middleware/cache-response-middleware.mjs.map +1 -1
- package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
- package/esm/http/middleware/inject-request-context.mjs.map +1 -1
- package/esm/http/middleware/ip-filter.middleware.d.mts +1 -1
- package/esm/http/middleware/ip-filter.middleware.mjs +1 -1
- package/esm/http/middleware/ip-filter.middleware.mjs.map +1 -1
- package/esm/http/middleware/maintenance.middleware.mjs.map +1 -1
- package/esm/http/middleware/utils/idempotency-key.mjs.map +1 -1
- package/esm/http/port-preflight.d.mts +8 -0
- package/esm/http/port-preflight.d.mts.map +1 -1
- package/esm/http/port-preflight.mjs +8 -1
- package/esm/http/port-preflight.mjs.map +1 -1
- package/esm/http/ready-report.d.mts.map +1 -1
- package/esm/http/request-controller.d.mts.map +1 -1
- package/esm/http/request.d.mts +14 -2
- package/esm/http/request.d.mts.map +1 -1
- package/esm/http/request.mjs +16 -2
- package/esm/http/request.mjs.map +1 -1
- package/esm/http/response.d.mts +3 -3
- package/esm/http/response.d.mts.map +1 -1
- package/esm/http/response.mjs.map +1 -1
- package/esm/http/server.d.mts.map +1 -1
- package/esm/http/server.mjs +26 -2
- package/esm/http/server.mjs.map +1 -1
- package/esm/http/types.d.mts +1 -3
- package/esm/http/types.d.mts.map +1 -1
- package/esm/http/uploaded-file.d.mts.map +1 -1
- package/esm/http/uploaded-file.mjs.map +1 -1
- package/esm/http/uploads-config.d.mts.map +1 -1
- package/esm/image/image.d.mts.map +1 -1
- package/esm/image/image.mjs.map +1 -1
- package/esm/index.d.mts +6 -1
- package/esm/index.mjs +6 -1
- package/esm/logger/fatal-visibility.d.mts +25 -0
- package/esm/logger/fatal-visibility.d.mts.map +1 -0
- package/esm/logger/fatal-visibility.mjs +31 -0
- package/esm/logger/fatal-visibility.mjs.map +1 -0
- package/esm/logger/index.d.mts +1 -0
- package/esm/logger/index.mjs +1 -0
- package/esm/logger/logger.mjs.map +1 -1
- package/esm/mail/config.d.mts.map +1 -1
- package/esm/mail/events.d.mts.map +1 -1
- package/esm/mail/mail.d.mts.map +1 -1
- package/esm/mail/mail.mjs.map +1 -1
- package/esm/mail/mailer-pool.d.mts.map +1 -1
- package/esm/mail/mailer-pool.mjs +2 -0
- package/esm/mail/mailer-pool.mjs.map +1 -1
- package/esm/mail/send-mail.mjs.map +1 -1
- package/esm/mail/test-mailbox.d.mts.map +1 -1
- package/esm/mail/test-mailbox.mjs.map +1 -1
- package/esm/production/assert-dist-ready-to-start.mjs +24 -0
- package/esm/production/assert-dist-ready-to-start.mjs.map +1 -0
- package/esm/production/assert-generated-imports.mjs.map +1 -1
- package/esm/production/build-app-production.mjs.map +1 -1
- package/esm/production/dist-build-manifest.mjs +47 -0
- package/esm/production/dist-build-manifest.mjs.map +1 -0
- package/esm/production/production-builder.mjs +68 -13
- package/esm/production/production-builder.mjs.map +1 -1
- package/esm/production/production-supervisor.mjs +21 -9
- package/esm/production/production-supervisor.mjs.map +1 -1
- package/esm/production/promote-dist.mjs +115 -0
- package/esm/production/promote-dist.mjs.map +1 -0
- package/esm/production/resolve-build-config.mjs.map +1 -1
- package/esm/repositories/adapters/cascade/cascade-adapter.d.mts.map +1 -1
- package/esm/repositories/adapters/cascade/cascade-adapter.mjs.map +1 -1
- package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts.map +1 -1
- package/esm/repositories/adapters/cascade/cascade-query-builder.mjs.map +1 -1
- package/esm/repositories/adapters/cascade/filter-applicator.mjs.map +1 -1
- package/esm/repositories/repository.manager.d.mts.map +1 -1
- package/esm/repositories/repository.manager.mjs.map +1 -1
- package/esm/resource/register-resource.d.mts.map +1 -1
- package/esm/resource/resource-field-builder.d.mts.map +1 -1
- package/esm/resource/resource-field-builder.mjs.map +1 -1
- package/esm/resource/resource.d.mts.map +1 -1
- package/esm/resource/resource.mjs.map +1 -1
- package/esm/restful/restful.d.mts.map +1 -1
- package/esm/restful/restful.mjs.map +1 -1
- package/esm/router/index.d.mts +3 -0
- package/esm/router/index.mjs +3 -0
- package/esm/router/log-request-lifecycle.mjs.map +1 -1
- package/esm/router/normalize-request-path.d.mts +14 -0
- package/esm/router/normalize-request-path.d.mts.map +1 -0
- package/esm/router/normalize-request-path.mjs +18 -0
- package/esm/router/normalize-request-path.mjs.map +1 -0
- package/esm/router/normalize-route-path.d.mts +28 -0
- package/esm/router/normalize-route-path.d.mts.map +1 -0
- package/esm/router/normalize-route-path.mjs +33 -0
- package/esm/router/normalize-route-path.mjs.map +1 -0
- package/esm/router/positional-handler-diagnostics.d.mts.map +1 -1
- package/esm/router/positional-handler-diagnostics.mjs.map +1 -1
- package/esm/router/route-name-method-suffix.d.mts +33 -0
- package/esm/router/route-name-method-suffix.d.mts.map +1 -0
- package/esm/router/route-name-method-suffix.mjs +39 -0
- package/esm/router/route-name-method-suffix.mjs.map +1 -0
- package/esm/router/route-registry.d.mts.map +1 -1
- package/esm/router/route-registry.mjs +3 -2
- package/esm/router/route-registry.mjs.map +1 -1
- package/esm/router/router.d.mts +14 -0
- package/esm/router/router.d.mts.map +1 -1
- package/esm/router/router.mjs +50 -11
- package/esm/router/router.mjs.map +1 -1
- package/esm/socket/utils.d.mts.map +1 -1
- package/esm/storage/config.d.mts.map +1 -1
- package/esm/storage/context/storage-driver-context.d.mts.map +1 -1
- package/esm/storage/drivers/cloud-driver.d.mts.map +1 -1
- package/esm/storage/drivers/cloud-driver.mjs.map +1 -1
- package/esm/storage/drivers/do-spaces-driver.d.mts.map +1 -1
- package/esm/storage/drivers/local-driver.d.mts.map +1 -1
- package/esm/storage/drivers/local-driver.mjs.map +1 -1
- package/esm/storage/drivers/r2-driver.d.mts.map +1 -1
- package/esm/storage/scoped-storage.d.mts.map +1 -1
- package/esm/storage/scoped-storage.mjs.map +1 -1
- package/esm/storage/storage-file.d.mts.map +1 -1
- package/esm/storage/storage-file.mjs.map +1 -1
- package/esm/storage/storage.d.mts.map +1 -1
- package/esm/storage/types.d.mts +14 -0
- package/esm/storage/types.d.mts.map +1 -1
- package/esm/storage/utils/safe-fetch.mjs.map +1 -1
- package/esm/tests/start-http-development-server.d.mts.map +1 -1
- package/esm/tests/start-http-development-server.mjs +2 -1
- package/esm/tests/start-http-development-server.mjs.map +1 -1
- package/esm/tests/test-connectors-selection.mjs.map +1 -1
- package/esm/tests/test-helpers.d.mts.map +1 -1
- package/esm/tests/test-setup-timeout.mjs.map +1 -1
- package/esm/tests/vitest-setup.d.mts.map +1 -1
- package/esm/tests/vitest-setup.mjs.map +1 -1
- package/esm/updater/update-warlock-packages.mjs.map +1 -1
- package/esm/use-cases/use-case-broadcast.d.mts.map +1 -1
- package/esm/use-cases/use-case-events.d.mts.map +1 -1
- package/esm/use-cases/use-case-pipeline.d.mts.map +1 -1
- package/esm/use-cases/use-case.d.mts.map +1 -1
- package/esm/use-cases/use-cases-registry.d.mts.map +1 -1
- package/esm/use-cases/use-cases-registry.mjs.map +1 -1
- package/esm/utils/database-log.d.mts.map +1 -1
- package/esm/utils/database-log.mjs.map +1 -1
- package/esm/utils/environment.d.mts.map +1 -1
- package/esm/utils/framework-vesion.mjs.map +1 -1
- package/esm/utils/get-localized.mjs.map +1 -1
- package/esm/utils/load-environment.mjs.map +1 -1
- package/esm/utils/normalized-path.d.mts.map +1 -1
- package/esm/utils/paths.d.mts.map +1 -1
- package/esm/utils/promise-all-object.d.mts.map +1 -1
- package/esm/utils/promise-all-object.mjs.map +1 -1
- package/esm/utils/sluggable.mjs.map +1 -1
- package/esm/utils/version-compare.mjs.map +1 -1
- package/esm/validation/database/exists-except-current-id.mjs.map +1 -1
- package/esm/validation/database/exists-except-current-user.mjs.map +1 -1
- package/esm/validation/database/unique-except-current-id.mjs.map +1 -1
- package/esm/validation/plugins/localized-plugin.mjs.map +1 -1
- package/esm/validation/validators/file-validator.mjs.map +1 -1
- package/esm/vite/lower-stage3-decorators.d.mts.map +1 -1
- package/esm/warlock-config/default-configurations.mjs.map +1 -1
- package/esm/warlock-config/warlock-config.manager.d.mts.map +1 -1
- package/esm/warlock-config/warlock-config.manager.mjs.map +1 -1
- package/llms-full.txt +205 -90
- package/llms.txt +5 -5
- package/package.json +12 -12
- package/skills/add-connector/SKILL.md +35 -28
- package/skills/create-controller/SKILL.md +1 -1
- package/skills/create-module/SKILL.md +12 -12
- package/skills/hash-password/SKILL.md +4 -4
- package/skills/run-app/SKILL.md +77 -16
- package/skills/send-mail/SKILL.md +2 -2
- package/skills/use-middleware/SKILL.md +13 -4
- package/skills/use-model-transformers/SKILL.md +2 -2
- package/skills/use-repository/SKILL.md +1 -1
- package/skills/validate-input/SKILL.md +1 -1
- package/skills/warlock-conventions/SKILL.md +1 -1
- package/skills/warlock-doctor/SKILL.md +3 -3
- package/skills/warlock-routes/SKILL.md +47 -9
- package/skills/write-cli-command/SKILL.md +1 -1
- package/skills/write-seeder/SKILL.md +8 -8
|
@@ -47,23 +47,29 @@ async function displayProductionReadyBanner({ bootDurationMs } = {}) {
|
|
|
47
47
|
/**
|
|
48
48
|
* Report that the production server died before it ever served anything.
|
|
49
49
|
*
|
|
50
|
-
* Written to **
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
50
|
+
* Written to **stderr** only. `warlock start` inherits both child streams, and
|
|
51
|
+
* production launchers commonly merge them (`2>&1`), so mirroring this block to
|
|
52
|
+
* stdout prints every line twice. The command's non-zero exit code is the
|
|
53
|
+
* machine-readable failure signal; stdout remains reserved for the ready
|
|
54
|
+
* banner.
|
|
55
|
+
*
|
|
56
|
+
* `causeWasCaptured` gates the "the cause is printed above" line. The
|
|
57
|
+
* supervisor cannot always guarantee the child wrote anything before it
|
|
58
|
+
* died — an import that throws before the logger configures its channels,
|
|
59
|
+
* a bundle with no console channel at all — and claiming a cause is above
|
|
60
|
+
* when nothing was ever captured sends the developer looking for output
|
|
61
|
+
* that doesn't exist, which is worse than admitting the gap.
|
|
54
62
|
*/
|
|
55
|
-
function displayProductionStartFailure(exitCode) {
|
|
63
|
+
function displayProductionStartFailure(exitCode, causeWasCaptured) {
|
|
64
|
+
const causeLine = causeWasCaptured ? ` ${colors.dim("the cause is printed above, in the application's own output")}` : ` ${colors.dim("no output was captured from the application process — its cause did not reach this terminal")}`;
|
|
56
65
|
const lines = [
|
|
57
66
|
"",
|
|
58
67
|
` ${colors.red("✖")} ${colors.bold("warlock start")} failed — the server never finished booting`,
|
|
59
68
|
` ${colors.dim(`the application process exited with code ${exitCode}`)}`,
|
|
60
|
-
|
|
69
|
+
causeLine,
|
|
61
70
|
""
|
|
62
71
|
];
|
|
63
|
-
for (const line of lines)
|
|
64
|
-
console.error(line);
|
|
65
|
-
console.log(line);
|
|
66
|
-
}
|
|
72
|
+
for (const line of lines) console.error(line);
|
|
67
73
|
}
|
|
68
74
|
/**
|
|
69
75
|
* Note that a running child has not reported readiness yet.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-commands.utils.mjs","names":[],"sources":["../../../../../../../core/src/cli/cli-commands.utils.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { Environment } from \"../utils\";\nimport { getWarlockVersion } from \"../utils/framework-vesion\";\n\nexport function isMatchingCommandName(commandName: string, targetingCommandName: string) {\n return commandName.split(\" \")[0] === targetingCommandName;\n}\n\n/**\n * Display the Warlock.js version banner\n */\nexport async function displayWarlockVersionInTerminal() {\n const version = await getWarlockVersion();\n console.log(`⚡ ${colors.bold(\"Warlock.js\")} ${colors.greenBright(`v${version}`)}`);\n}\n\ntype StartBannerOptions = {\n environment: Environment;\n};\n\nfunction getTextColorMethod(environment: Environment) {\n switch (environment) {\n case \"development\":\n return colors.yellowBright;\n case \"production\":\n return colors.greenBright;\n case \"test\":\n return colors.blueBright;\n default:\n return colors.whiteBright;\n }\n}\n\n/**\n * Display CLI startup banner\n */\nexport async function displayStartupBanner({ environment }: StartBannerOptions) {\n const version = await getWarlockVersion();\n const textColorMethod = getTextColorMethod(environment);\n console.log(` ⚡ ${colors.bold(textColorMethod(\"Warlock.js\"))} ${colors.dim(`v${version}`)}`);\n console.log();\n}\n\ntype ProductionReadyBannerOptions = {\n bootDurationMs?: number;\n};\n\n/**\n * Announce that the production server is up — printed on **stdout**, and only\n * after the child process reported a completed boot.\n *\n * Stdout is the channel a supervisor or CI gate greps to decide the service is\n * healthy, so nothing optimistic may be written to it: this function is the\n * single place allowed to say \"started\", and it is called from exactly one\n * place, the `warlock:ready` handler in the `start` command.\n */\nexport async function displayProductionReadyBanner({\n bootDurationMs,\n}: ProductionReadyBannerOptions = {}) {\n const version = await getWarlockVersion();\n const duration = bootDurationMs ? colors.dim(` in ${bootDurationMs}ms`) : \"\";\n\n console.log(\n ` ⚡ ${colors.bold(colors.greenBright(\"Warlock.js\"))} ${colors.dim(`v${version}`)} ${colors.green(\"✔\")} production server started${duration}`,\n );\n console.log();\n}\n\n/**\n * Report that the production server died before it ever served anything.\n *\n * Written to **both** streams on purpose. Stderr is where a human and a log\n * collector look; stdout is where a supervisor that greps for the success\n * banner looks, and it must find a failure there rather than silence — silence\n * on stdout is what let a boot failure be recorded as a healthy start.\n */\nexport function displayProductionStartFailure(exitCode: number) {\n const lines = [\n \"\",\n ` ${colors.red(\"✖\")} ${colors.bold(\"warlock start\")} failed — the server never finished booting`,\n ` ${colors.dim(`the application process exited with code ${exitCode}`)}`,\n ` ${colors.dim(\"the cause is printed above, in the application's own output\")}`,\n \"\",\n ];\n\n for (const line of lines) {\n console.error(line);\n console.log(line);\n }\n}\n\n/**\n * Note that a running child has not reported readiness yet.\n *\n * Emitted on **stderr** only. The process may be perfectly healthy — an older\n * bundle has no readiness signal at all — so saying anything on stdout would be\n * the very false-green this channel exists to prevent.\n *\n * The wording offers the likely causes rather than asserting one. It cannot\n * distinguish an old bundle from a slow boot from a boot that is about to fail,\n * and an earlier version claimed \"the bundle predates readiness reporting\" —\n * which was simply wrong when a current bundle was mid-crash, and sent the\n * reader after the wrong thing.\n */\nexport function displayMissingReadinessNotice(waitedMs: number) {\n console.error();\n console.error(\n ` ${colors.yellow(\"!\")} still running after ${Math.round(waitedMs / 1000)}s with no readiness signal`,\n );\n console.error(` ${colors.dim(\"either the boot is still in progress, or this bundle was built\")}`);\n console.error(\n ` ${colors.dim(\"before readiness reporting — re-run\")} ${colors.cyan(\"warlock build\")} ${colors.dim(\"if the banner never appears\")}`,\n );\n console.error();\n}\n\n/**\n * Display command execution header\n */\nexport function displayExecutingCommand(commandName: string) {\n console.log(` ${colors.cyan(\"›\")} Running ${colors.bold(colors.white(commandName))}...`);\n console.log();\n}\n\n/**\n * Display command not found error with optional suggestions\n */\nexport function displayCommandNotFound(commandName: string, suggestions?: string[]) {\n console.log();\n console.log(` ${colors.red(\"✖\")} Command ${colors.magenta(commandName)} not found`);\n\n if (suggestions && suggestions.length > 0) {\n console.log();\n console.log(` ${colors.yellow(\"Did you mean?\")}`);\n suggestions.forEach((suggestion) => {\n console.log(` ${colors.cyan(\"→\")} ${colors.white(suggestion)}`);\n });\n }\n\n console.log();\n console.log(\n ` ${colors.dim(\"Run\")} ${colors.cyan(\"warlock --help\")} ${colors.dim(\"to see available commands\")}`,\n );\n console.log();\n}\n\n/**\n * Display missing command error\n */\nexport function displayMissingCommand() {\n console.log();\n console.log(` ${colors.red(\"✖\")} No command specified`);\n console.log(\n ` ${colors.dim(\"Run\")} ${colors.cyan(\"warlock --help\")} ${colors.dim(\"to see available commands\")}`,\n );\n console.log();\n}\n\n/**\n * Display command success message\n */\nexport function displayCommandSuccess(commandName: string, durationMs?: number) {\n const duration = durationMs ? colors.dim(` (${durationMs}ms)`) : \"\";\n console.log();\n console.log(\n ` ${colors.green(\"✔\")} ${colors.bold(commandName)} completed successfully${duration}`,\n );\n console.log();\n}\n\n/**\n * Display command error message\n */\nexport function displayCommandError(commandName: string, error: Error) {\n console.log();\n console.log(` ${colors.red(\"✖\")} ${colors.bold(commandName)} failed`);\n console.log(` ${colors.dim(error.message)}`);\n console.log();\n}\n\n/**\n * Display a FATAL boot/preload failure and exit information.\n *\n * Preload failures — a bad import in a config file, a connector that throws\n * on startup, a missing module export — happen BEFORE the command's run loop\n * exists, so there is nothing to recover into: they are always fatal. Unlike\n * `displayCommandError`, this prints the full stack (not just `error.message`)\n * because the stack names the exact file + line of the offending import, which\n * is the single most useful clue when a config file pulls in a broken module.\n *\n * Surfacing this loudly is the difference between a clear error and a silent\n * hang: an unhandled preload rejection used to escape while the already-started\n * loader worker thread kept the process alive, leaving `warlock dev` frozen\n * just after the banner with no message at all.\n *\n * @example\n * // SyntaxError: The requested module '@warlock.js/cascade' does not\n * // provide an export named 'belongsTo'\n * // at src/app/.../permission.model.ts:2\n */\nexport function displayBootError(commandName: string, error: Error) {\n console.log();\n console.log(` ${colors.red(\"✖\")} ${colors.bold(commandName)} failed to start`);\n console.log(` ${colors.red(error.message)}`);\n if (error.stack) {\n console.log();\n console.log(colors.dim(error.stack));\n }\n console.log();\n}\n\n/**\n * Display missing required options error\n */\nexport function displayMissingOptions(options: { name: string; text: string }[]) {\n console.log();\n console.log(` ${colors.red(\"✖\")} Missing required options:`);\n options.forEach((opt) => {\n console.log(` ${colors.yellow(opt.text)} ${colors.dim(`(--${opt.name})`)}`);\n });\n console.log();\n}\n\n/**\n * Command info for help display\n */\nexport type HelpCommandInfo = {\n name: string;\n alias?: string;\n description?: string;\n source: \"framework\" | \"plugin\" | \"project\";\n};\n\n/**\n * Display global help with all commands grouped by source\n */\nexport async function displayHelp(commands: HelpCommandInfo[]) {\n const version = await getWarlockVersion();\n\n console.log();\n console.log(\n ` ⚡ ${colors.bold(colors.yellowBright(\"Warlock.js\"))} CLI ${colors.dim(`v${version}`)}`,\n );\n console.log();\n console.log(\n ` ${colors.bold(\"Usage:\")} ${colors.cyan(\"warlock\")} ${colors.dim(\"<command>\")} ${colors.dim(\"[options]\")}`,\n );\n console.log();\n\n // Group by source\n const grouped: Record<string, HelpCommandInfo[]> = {\n framework: [],\n plugin: [],\n project: [],\n };\n\n commands.forEach((cmd) => {\n grouped[cmd.source]?.push(cmd);\n });\n\n // Display each group\n const groupLabels: Record<string, string> = {\n framework: \"Framework Commands\",\n plugin: \"Plugin Commands\",\n project: \"Project Commands\",\n };\n\n for (const [source, cmds] of Object.entries(grouped)) {\n if (cmds.length === 0) continue;\n\n console.log(` ${colors.bold(colors.white(groupLabels[source]))}`);\n console.log();\n\n // Find max name length for alignment\n const maxLen = Math.max(...cmds.map((c) => c.name.length + (c.alias ? c.alias.length + 4 : 0)));\n\n cmds.forEach((cmd) => {\n const aliasStr = cmd.alias ? colors.dim(` (${cmd.alias})`) : \"\";\n const nameWithAlias = cmd.name + (cmd.alias ? ` (${cmd.alias})` : \"\");\n const padding = \" \".repeat(maxLen - nameWithAlias.length + 2);\n // const desc = cmd.description || colors.dim(\"No description\");\n const desc = cmd.description || \"\";\n console.log(` ${colors.cyan(cmd.name)}${aliasStr}${padding}${desc}`);\n });\n console.log();\n }\n\n // Display global flags\n console.log(` ${colors.bold(colors.white(\"Global Flags\"))}`);\n console.log();\n\n const globalFlags = [\n { flag: \"--help, -h\", description: \"Show help for a command\" },\n { flag: \"--version, -v\", description: \"Show Warlock version\" },\n { flag: \"--no-cache\", description: \"Force reload without cache\" },\n { flag: \"--warm-cache\", description: \"Pre-cache all project commands\" },\n ];\n\n const maxFlagLen = Math.max(...globalFlags.map((f) => f.flag.length));\n\n globalFlags.forEach(({ flag, description }) => {\n const padding = \" \".repeat(maxFlagLen - flag.length + 2);\n console.log(` ${colors.yellow(flag)}${padding}${description}`);\n });\n console.log();\n\n console.log(\n ` ${colors.dim(\"Run\")} ${colors.cyan(\"warlock <command> --help\")} ${colors.dim(\"for command-specific help\")}`,\n );\n console.log();\n}\n\n/**\n * Display help for a specific command\n */\nexport function displayCommandHelp(command: {\n name: string;\n alias?: string;\n description?: string;\n options?: { name: string; text: string; description?: string; required?: boolean }[];\n}) {\n console.log();\n console.log(\n ` ${colors.bold(colors.cyan(command.name))}${command.alias ? colors.dim(` (${command.alias})`) : \"\"}`,\n );\n\n if (command.description) {\n console.log(` ${command.description}`);\n }\n console.log();\n\n if (command.options && command.options.length > 0) {\n console.log(` ${colors.bold(\"Options:\")}`);\n console.log();\n\n const maxLen = Math.max(...command.options.map((o) => o.text.length));\n\n command.options.forEach((opt) => {\n const padding = \" \".repeat(maxLen - opt.text.length + 2);\n const required = opt.required ? colors.red(\" (required)\") : \"\";\n const desc = opt.description || \"\";\n console.log(` ${colors.green(opt.text)}${padding}${desc}${required}`);\n });\n console.log();\n } else {\n console.log(` ${colors.dim(\"No options available\")}`);\n console.log();\n }\n}\n"],"mappings":";;;;AAIA,SAAgB,sBAAsB,aAAqB,sBAA8B;CACvF,OAAO,YAAY,MAAM,GAAG,CAAC,CAAC,OAAO;AACvC;;;;AAKA,eAAsB,kCAAkC;CACtD,MAAM,UAAU,MAAM,kBAAkB;CACxC,QAAQ,IAAI,KAAK,OAAO,KAAK,YAAY,EAAE,GAAG,OAAO,YAAY,IAAI,SAAS,GAAG;AACnF;AAMA,SAAS,mBAAmB,aAA0B;CACpD,QAAQ,aAAR;EACE,KAAK,eACH,OAAO,OAAO;EAChB,KAAK,cACH,OAAO,OAAO;EAChB,KAAK,QACH,OAAO,OAAO;EAChB,SACE,OAAO,OAAO;CAClB;AACF;;;;AAKA,eAAsB,qBAAqB,EAAE,eAAmC;CAC9E,MAAM,UAAU,MAAM,kBAAkB;CACxC,MAAM,kBAAkB,mBAAmB,WAAW;CACtD,QAAQ,IAAI,OAAO,OAAO,KAAK,gBAAgB,YAAY,CAAC,EAAE,GAAG,OAAO,IAAI,IAAI,SAAS,GAAG;CAC5F,QAAQ,IAAI;AACd;;;;;;;;;;AAeA,eAAsB,6BAA6B,EACjD,mBACgC,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QAAQ,IACN,KAAK,OAAO,KAAK,OAAO,KAAK,QAAQ,IAAI,CAAC,IAAI,QAAQ,QAAQ,OAAO,IAAI,KAAK,QAAQ,MAAM,EAAE,IAAI,IACpG;CAEA,IAAI,QAAQ,aACV,QAAQ,IAAI,KAAK,QAAQ,aAAa;CAExC,QAAQ,IAAI;CAEZ,IAAI,QAAQ,WAAW,QAAQ,QAAQ,SAAS,GAAG;EACjD,QAAQ,IAAI,KAAK,OAAO,KAAK,UAAU,GAAG;EAC1C,QAAQ,IAAI;EAEZ,MAAM,SAAS,KAAK,IAAI,GAAG,QAAQ,QAAQ,KAAK,MAAM,EAAE,KAAK,MAAM,CAAC;EAEpE,QAAQ,QAAQ,SAAS,QAAQ;GAC/B,MAAM,UAAU,IAAI,OAAO,SAAS,IAAI,KAAK,SAAS,CAAC;GACvD,MAAM,WAAW,IAAI,WAAW,OAAO,IAAI,aAAa,IAAI;GAC5D,MAAM,OAAO,IAAI,eAAe;GAChC,QAAQ,IAAI,OAAO,OAAO,MAAM,IAAI,IAAI,IAAI,UAAU,OAAO,UAAU;EACzE,CAAC;EACD,QAAQ,IAAI;CACd,OAAO;EACL,QAAQ,IAAI,KAAK,OAAO,IAAI,sBAAsB,GAAG;EACrD,QAAQ,IAAI;CACd;AACF"}
|
|
1
|
+
{"version":3,"file":"cli-commands.utils.mjs","names":[],"sources":["../../../../../../../core/src/cli/cli-commands.utils.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { Environment } from \"../utils\";\nimport { getWarlockVersion } from \"../utils/framework-vesion\";\n\nexport function isMatchingCommandName(commandName: string, targetingCommandName: string) {\n return commandName.split(\" \")[0] === targetingCommandName;\n}\n\n/**\n * Display the Warlock.js version banner\n */\nexport async function displayWarlockVersionInTerminal() {\n const version = await getWarlockVersion();\n console.log(`⚡ ${colors.bold(\"Warlock.js\")} ${colors.greenBright(`v${version}`)}`);\n}\n\ntype StartBannerOptions = {\n environment: Environment;\n};\n\nfunction getTextColorMethod(environment: Environment) {\n switch (environment) {\n case \"development\":\n return colors.yellowBright;\n case \"production\":\n return colors.greenBright;\n case \"test\":\n return colors.blueBright;\n default:\n return colors.whiteBright;\n }\n}\n\n/**\n * Display CLI startup banner\n */\nexport async function displayStartupBanner({ environment }: StartBannerOptions) {\n const version = await getWarlockVersion();\n const textColorMethod = getTextColorMethod(environment);\n console.log(` ⚡ ${colors.bold(textColorMethod(\"Warlock.js\"))} ${colors.dim(`v${version}`)}`);\n console.log();\n}\n\ntype ProductionReadyBannerOptions = {\n bootDurationMs?: number;\n};\n\n/**\n * Announce that the production server is up — printed on **stdout**, and only\n * after the child process reported a completed boot.\n *\n * Stdout is the channel a supervisor or CI gate greps to decide the service is\n * healthy, so nothing optimistic may be written to it: this function is the\n * single place allowed to say \"started\", and it is called from exactly one\n * place, the `warlock:ready` handler in the `start` command.\n */\nexport async function displayProductionReadyBanner({\n bootDurationMs,\n}: ProductionReadyBannerOptions = {}) {\n const version = await getWarlockVersion();\n const duration = bootDurationMs ? colors.dim(` in ${bootDurationMs}ms`) : \"\";\n\n console.log(\n ` ⚡ ${colors.bold(colors.greenBright(\"Warlock.js\"))} ${colors.dim(`v${version}`)} ${colors.green(\"✔\")} production server started${duration}`,\n );\n console.log();\n}\n\n/**\n * Report that the production server died before it ever served anything.\n *\n * Written to **stderr** only. `warlock start` inherits both child streams, and\n * production launchers commonly merge them (`2>&1`), so mirroring this block to\n * stdout prints every line twice. The command's non-zero exit code is the\n * machine-readable failure signal; stdout remains reserved for the ready\n * banner.\n *\n * `causeWasCaptured` gates the \"the cause is printed above\" line. The\n * supervisor cannot always guarantee the child wrote anything before it\n * died — an import that throws before the logger configures its channels,\n * a bundle with no console channel at all — and claiming a cause is above\n * when nothing was ever captured sends the developer looking for output\n * that doesn't exist, which is worse than admitting the gap.\n */\nexport function displayProductionStartFailure(\n exitCode: number,\n causeWasCaptured: boolean,\n) {\n const causeLine = causeWasCaptured\n ? ` ${colors.dim(\"the cause is printed above, in the application's own output\")}`\n : ` ${colors.dim(\"no output was captured from the application process — its cause did not reach this terminal\")}`;\n\n const lines = [\n \"\",\n ` ${colors.red(\"✖\")} ${colors.bold(\"warlock start\")} failed — the server never finished booting`,\n ` ${colors.dim(`the application process exited with code ${exitCode}`)}`,\n causeLine,\n \"\",\n ];\n\n for (const line of lines) {\n console.error(line);\n }\n}\n\n/**\n * Note that a running child has not reported readiness yet.\n *\n * Emitted on **stderr** only. The process may be perfectly healthy — an older\n * bundle has no readiness signal at all — so saying anything on stdout would be\n * the very false-green this channel exists to prevent.\n *\n * The wording offers the likely causes rather than asserting one. It cannot\n * distinguish an old bundle from a slow boot from a boot that is about to fail,\n * and an earlier version claimed \"the bundle predates readiness reporting\" —\n * which was simply wrong when a current bundle was mid-crash, and sent the\n * reader after the wrong thing.\n */\nexport function displayMissingReadinessNotice(waitedMs: number) {\n console.error();\n console.error(\n ` ${colors.yellow(\"!\")} still running after ${Math.round(waitedMs / 1000)}s with no readiness signal`,\n );\n console.error(` ${colors.dim(\"either the boot is still in progress, or this bundle was built\")}`);\n console.error(\n ` ${colors.dim(\"before readiness reporting — re-run\")} ${colors.cyan(\"warlock build\")} ${colors.dim(\"if the banner never appears\")}`,\n );\n console.error();\n}\n\n/**\n * Display command execution header\n */\nexport function displayExecutingCommand(commandName: string) {\n console.log(` ${colors.cyan(\"›\")} Running ${colors.bold(colors.white(commandName))}...`);\n console.log();\n}\n\n/**\n * Display command not found error with optional suggestions\n */\nexport function displayCommandNotFound(commandName: string, suggestions?: string[]) {\n console.log();\n console.log(` ${colors.red(\"✖\")} Command ${colors.magenta(commandName)} not found`);\n\n if (suggestions && suggestions.length > 0) {\n console.log();\n console.log(` ${colors.yellow(\"Did you mean?\")}`);\n suggestions.forEach((suggestion) => {\n console.log(` ${colors.cyan(\"→\")} ${colors.white(suggestion)}`);\n });\n }\n\n console.log();\n console.log(\n ` ${colors.dim(\"Run\")} ${colors.cyan(\"warlock --help\")} ${colors.dim(\"to see available commands\")}`,\n );\n console.log();\n}\n\n/**\n * Display missing command error\n */\nexport function displayMissingCommand() {\n console.log();\n console.log(` ${colors.red(\"✖\")} No command specified`);\n console.log(\n ` ${colors.dim(\"Run\")} ${colors.cyan(\"warlock --help\")} ${colors.dim(\"to see available commands\")}`,\n );\n console.log();\n}\n\n/**\n * Display command success message\n */\nexport function displayCommandSuccess(commandName: string, durationMs?: number) {\n const duration = durationMs ? colors.dim(` (${durationMs}ms)`) : \"\";\n console.log();\n console.log(\n ` ${colors.green(\"✔\")} ${colors.bold(commandName)} completed successfully${duration}`,\n );\n console.log();\n}\n\n/**\n * Display command error message\n */\nexport function displayCommandError(commandName: string, error: Error) {\n console.log();\n console.log(` ${colors.red(\"✖\")} ${colors.bold(commandName)} failed`);\n console.log(` ${colors.dim(error.message)}`);\n console.log();\n}\n\n/**\n * Display a FATAL boot/preload failure and exit information.\n *\n * Preload failures — a bad import in a config file, a connector that throws\n * on startup, a missing module export — happen BEFORE the command's run loop\n * exists, so there is nothing to recover into: they are always fatal. Unlike\n * `displayCommandError`, this prints the full stack (not just `error.message`)\n * because the stack names the exact file + line of the offending import, which\n * is the single most useful clue when a config file pulls in a broken module.\n *\n * Surfacing this loudly is the difference between a clear error and a silent\n * hang: an unhandled preload rejection used to escape while the already-started\n * loader worker thread kept the process alive, leaving `warlock dev` frozen\n * just after the banner with no message at all.\n *\n * @example\n * // SyntaxError: The requested module '@warlock.js/cascade' does not\n * // provide an export named 'belongsTo'\n * // at src/app/.../permission.model.ts:2\n */\nexport function displayBootError(commandName: string, error: Error) {\n console.log();\n console.log(` ${colors.red(\"✖\")} ${colors.bold(commandName)} failed to start`);\n console.log(` ${colors.red(error.message)}`);\n if (error.stack) {\n console.log();\n console.log(colors.dim(error.stack));\n }\n console.log();\n}\n\n/**\n * Display missing required options error\n */\nexport function displayMissingOptions(options: { name: string; text: string }[]) {\n console.log();\n console.log(` ${colors.red(\"✖\")} Missing required options:`);\n options.forEach((opt) => {\n console.log(` ${colors.yellow(opt.text)} ${colors.dim(`(--${opt.name})`)}`);\n });\n console.log();\n}\n\n/**\n * Command info for help display\n */\nexport type HelpCommandInfo = {\n name: string;\n alias?: string;\n description?: string;\n source: \"framework\" | \"plugin\" | \"project\";\n};\n\n/**\n * Display global help with all commands grouped by source\n */\nexport async function displayHelp(commands: HelpCommandInfo[]) {\n const version = await getWarlockVersion();\n\n console.log();\n console.log(\n ` ⚡ ${colors.bold(colors.yellowBright(\"Warlock.js\"))} CLI ${colors.dim(`v${version}`)}`,\n );\n console.log();\n console.log(\n ` ${colors.bold(\"Usage:\")} ${colors.cyan(\"warlock\")} ${colors.dim(\"<command>\")} ${colors.dim(\"[options]\")}`,\n );\n console.log();\n\n // Group by source\n const grouped: Record<string, HelpCommandInfo[]> = {\n framework: [],\n plugin: [],\n project: [],\n };\n\n commands.forEach((cmd) => {\n grouped[cmd.source]?.push(cmd);\n });\n\n // Display each group\n const groupLabels: Record<string, string> = {\n framework: \"Framework Commands\",\n plugin: \"Plugin Commands\",\n project: \"Project Commands\",\n };\n\n for (const [source, cmds] of Object.entries(grouped)) {\n if (cmds.length === 0) continue;\n\n console.log(` ${colors.bold(colors.white(groupLabels[source]))}`);\n console.log();\n\n // Find max name length for alignment\n const maxLen = Math.max(...cmds.map((c) => c.name.length + (c.alias ? c.alias.length + 4 : 0)));\n\n cmds.forEach((cmd) => {\n const aliasStr = cmd.alias ? colors.dim(` (${cmd.alias})`) : \"\";\n const nameWithAlias = cmd.name + (cmd.alias ? ` (${cmd.alias})` : \"\");\n const padding = \" \".repeat(maxLen - nameWithAlias.length + 2);\n // const desc = cmd.description || colors.dim(\"No description\");\n const desc = cmd.description || \"\";\n console.log(` ${colors.cyan(cmd.name)}${aliasStr}${padding}${desc}`);\n });\n console.log();\n }\n\n // Display global flags\n console.log(` ${colors.bold(colors.white(\"Global Flags\"))}`);\n console.log();\n\n const globalFlags = [\n { flag: \"--help, -h\", description: \"Show help for a command\" },\n { flag: \"--version, -v\", description: \"Show Warlock version\" },\n { flag: \"--no-cache\", description: \"Force reload without cache\" },\n { flag: \"--warm-cache\", description: \"Pre-cache all project commands\" },\n ];\n\n const maxFlagLen = Math.max(...globalFlags.map((f) => f.flag.length));\n\n globalFlags.forEach(({ flag, description }) => {\n const padding = \" \".repeat(maxFlagLen - flag.length + 2);\n console.log(` ${colors.yellow(flag)}${padding}${description}`);\n });\n console.log();\n\n console.log(\n ` ${colors.dim(\"Run\")} ${colors.cyan(\"warlock <command> --help\")} ${colors.dim(\"for command-specific help\")}`,\n );\n console.log();\n}\n\n/**\n * Display help for a specific command\n */\nexport function displayCommandHelp(command: {\n name: string;\n alias?: string;\n description?: string;\n options?: { name: string; text: string; description?: string; required?: boolean }[];\n}) {\n console.log();\n console.log(\n ` ${colors.bold(colors.cyan(command.name))}${command.alias ? colors.dim(` (${command.alias})`) : \"\"}`,\n );\n\n if (command.description) {\n console.log(` ${command.description}`);\n }\n console.log();\n\n if (command.options && command.options.length > 0) {\n console.log(` ${colors.bold(\"Options:\")}`);\n console.log();\n\n const maxLen = Math.max(...command.options.map((o) => o.text.length));\n\n command.options.forEach((opt) => {\n const padding = \" \".repeat(maxLen - opt.text.length + 2);\n const required = opt.required ? colors.red(\" (required)\") : \"\";\n const desc = opt.description || \"\";\n console.log(` ${colors.green(opt.text)}${padding}${desc}${required}`);\n });\n console.log();\n } else {\n console.log(` ${colors.dim(\"No options available\")}`);\n console.log();\n }\n}\n"],"mappings":";;;;AAIA,SAAgB,sBAAsB,aAAqB,sBAA8B;CACvF,OAAO,YAAY,MAAM,GAAG,EAAE,OAAO;AACvC;;;;AAKA,eAAsB,kCAAkC;CACtD,MAAM,UAAU,MAAM,kBAAkB;CACxC,QAAQ,IAAI,KAAK,OAAO,KAAK,YAAY,EAAE,GAAG,OAAO,YAAY,IAAI,SAAS,GAAG;AACnF;AAMA,SAAS,mBAAmB,aAA0B;CACpD,QAAQ,aAAR;EACE,KAAK,eACH,OAAO,OAAO;EAChB,KAAK,cACH,OAAO,OAAO;EAChB,KAAK,QACH,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src/cli/commands/doctor/boot-for-diagnostics.ts"],"sourcesContent":["import { config } from \"../../../config/config-getter\";\r\nimport { connectorsManager } from \"../../../connectors/connectors-manager\";\r\nimport { registerConfiguredConnectors } from \"../../../connectors/register-configured-connectors\";\r\nimport { ConnectorLifecyclePhase } from \"../../../connectors/types\";\r\nimport { container } from \"../../../container\";\r\nimport { filesOrchestrator } from \"../../../dev-server/files-orchestrator\";\r\nimport { ModuleLoadError } from \"../../../dev-server/module-loader\";\r\nimport { router } from \"../../../router/router\";\r\nimport type { DoctorBootContext, ModuleFailure } from \"./check.types\";\r\n\r\n/**\r\n * @fileoverview The boot pass `warlock doctor` runs before its checks.\r\n *\r\n * THE RULE: **doctor boots, it never starts.**\r\n *\r\n * The connector contract already splits the two things doctor needs to keep\r\n * apart. `boot()` is where a connector REGISTERS — the HTTP connector builds a\r\n * Fastify instance and adds `/health` + `/ready` to it, the web connector\r\n * installs one route per page on the app router — and `start()` is where it\r\n * CONNECTS: opens the database, dials the cache, binds the port. Doctor runs\r\n * every `boot()` and no `start()`, so it sees the exact surface a served app\r\n * would have while opening no connection and binding no port.\r\n *\r\n * That seam is what makes the checks true. Before it existed here, doctor\r\n * preloaded config and framework bootstrap only: no app module was ever\r\n * imported, so no route module ever ran, so `routes` reported `0` on an app\r\n * `warlock dev` served 14 routes for — while `health` reported the endpoints as\r\n * \"registered\" from a config flag alone. Two checks, one app, contradictory\r\n * answers, and the wrong one was the one users acted on.\r\n *\r\n * ORDERING mirrors `DevelopmentServer.start()` exactly, because the route\r\n * surface is order-dependent: early connectors boot, then models (decorator\r\n * registries the route modules resolve against), then locales/events/mains/\r\n * routes, then late connectors — which is where `web` turns pages into routes.\r\n * Get the order wrong and the count is wrong, which is the defect this replaces.\r\n *\r\n * NOT read-only in one narrow sense: it imports the app's own modules, so\r\n * whatever a module does at import time happens. That is unavoidable — routes\r\n * only exist as the side effect of importing the file that declares them — and\r\n * it is the same import the dev server performs. It also refreshes\r\n * `.warlock/manifest.json`, the framework's own file cache. Nothing in the\r\n * app's data, and no network, is touched.\r\n */\r\n\r\n/**\r\n * The one connector whose `boot()` can bind a port. See {@link shouldSkipBoot}.\r\n */\r\nconst SOCKET_CONNECTOR = \"socket\";\r\n\r\n/**\r\n * Normalize anything thrown into a one-line message.\r\n */\r\nfunction messageOf(error: unknown): string {\r\n return error instanceof Error ? error.message : String(error);\r\n}\r\n\r\n/**\r\n * Whether doctor must refuse to boot this connector, and why.\r\n *\r\n * Exactly one case, and it is not a taste call: `SocketConnector.boot()` shares\r\n * the HTTP connector's raw server when there is one, and CREATES its own —\r\n * `server.listen(socketConfig.port)` — when there is not. The HTTP connector\r\n * boots first (lower priority number), so the shared path is what normally\r\n * happens; an app that configures `socket` without `http` is the exception, and\r\n * for that app booting socket would make a diagnostic command open a listening\r\n * port. Detected by asking the container what HTTP actually left behind rather\r\n * than by re-deriving the condition from config.\r\n */\r\nfunction shouldSkipBoot(name: string): string | undefined {\r\n if (name === SOCKET_CONNECTOR && !container.has(\"http.server\")) {\r\n return \"no http connector to share a server with — booting it would bind a port\";\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Boot every registered connector in one lifecycle phase, isolating failures.\r\n *\r\n * A connector that throws on boot is recorded and the loop continues: one bad\r\n * connector must not hide the rest of the report, and \"which connector failed\r\n * to boot\" is itself a finding worth printing.\r\n */\r\nasync function bootPhase(\r\n phase: ConnectorLifecyclePhase,\r\n connectors: DoctorBootContext[\"connectors\"],\r\n): Promise<void> {\r\n for (const connector of connectorsManager.list()) {\r\n if (connector.lifecyclePhase !== phase) continue;\r\n\r\n const skipReason = shouldSkipBoot(connector.name);\r\n\r\n if (skipReason) {\r\n connectors.skipped.push({ name: connector.name, reason: skipReason });\r\n continue;\r\n }\r\n\r\n try {\r\n await connector.boot();\r\n connectors.booted.push(connector.name);\r\n } catch (error) {\r\n connectors.failures.push({ name: connector.name, message: messageOf(error) });\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Import every app module the dev server imports at boot, collecting failures\r\n * instead of letting the first one abort the pass.\r\n *\r\n * `loadAll()` is deliberately reused rather than reimplemented: it owns the\r\n * canonical order (locale → event → main → route) and the `withSourceFile`\r\n * scoping that gives each route its origin file. It aggregates its failures and\r\n * throws them at the end, which is exactly the shape needed here — every module\r\n * is attempted, and one broken route file cannot mask another.\r\n */\r\nasync function loadAppModules(): Promise<ModuleFailure[]> {\r\n try {\r\n await filesOrchestrator.moduleLoader.loadAll();\r\n return [];\r\n } catch (error) {\r\n if (error instanceof AggregateError) {\r\n return (error.errors as unknown[]).map((failure) => {\r\n return failure instanceof ModuleLoadError\r\n ? { file: failure.file.relativePath, message: messageOf(failure.cause) }\r\n : { file: \"unknown\", message: messageOf(failure) };\r\n });\r\n }\r\n\r\n return [{ file: \"unknown\", message: messageOf(error) }];\r\n }\r\n}\r\n\r\n/**\r\n * Eagerly import model files so the decorator-driven registries the route\r\n * modules resolve names against are populated first — the same reason\r\n * `DevelopmentServer.autoDiscoverFiles()` exists, and it must keep the same\r\n * position in the sequence.\r\n */\r\nasync function discoverModels(): Promise<ModuleFailure[]> {\r\n const failures: ModuleFailure[] = [];\r\n\r\n for (const file of filesOrchestrator.files.values()) {\r\n if (file.type !== \"model\") continue;\r\n\r\n try {\r\n await filesOrchestrator.moduleLoader.loadModule(file, \"model\");\r\n } catch (error) {\r\n failures.push({\r\n file: file.relativePath,\r\n message: error instanceof ModuleLoadError ? messageOf(error.cause) : messageOf(error),\r\n });\r\n }\r\n }\r\n\r\n return failures;\r\n}\r\n\r\n/**\r\n * Run the boot pass and report what it found.\r\n *\r\n * Never throws. Every failure mode — a connector array the config manager\r\n * refuses, a connector that throws on boot, a route module that fails to\r\n * import — becomes a field on the returned context, which the checks turn into\r\n * a printed verdict. A diagnostic command that crashes while diagnosing tells\r\n * the user nothing.\r\n */\r\nexport async function bootForDiagnostics(): Promise<DoctorBootContext> {\r\n const connectors: DoctorBootContext[\"connectors\"] = {\r\n registered: [],\r\n configured: [],\r\n booted: [],\r\n skipped: [],\r\n failures: [],\r\n };\r\n\r\n const context: DoctorBootContext = {\r\n booted: false,\r\n routeModules: 0,\r\n appRoutes: 0,\r\n totalRoutes: 0,\r\n moduleFailures: [],\r\n connectors,\r\n };\r\n\r\n try {\r\n // `init()` is idempotent and the preloader already ran it; calling it again\r\n // costs nothing and keeps this function honest on its own.\r\n await filesOrchestrator.init();\r\n await filesOrchestrator.initializeAll();\r\n\r\n filesOrchestrator.specialFilesCollector.collect(filesOrchestrator.getFiles());\r\n\r\n context.routeModules = filesOrchestrator.specialFilesCollector.getFilesByType(\"route\").length;\r\n } catch (error) {\r\n context.moduleFailures.push({ file: \"src/\", message: messageOf(error) });\r\n\r\n return context;\r\n }\r\n\r\n // The app's own connectors (`warlock.config.ts > connectors`) must be\r\n // registered before any phase boots, exactly as the dev preloader does it —\r\n // otherwise doctor would report on the eleven built-ins alone and miss the\r\n // connector the app actually configured. This is also the call that refuses a\r\n // duplicate or reserved connector name, so a config that would crash the next\r\n // real boot is caught here instead.\r\n try {\r\n registerConfiguredConnectors();\r\n } catch (error) {\r\n connectors.registrationError = messageOf(error);\r\n }\r\n\r\n connectors.registered = connectorsManager.list().map((connector) => connector.name);\r\n connectors.configured = connectors.registered.filter((name) => {\r\n return !connectorsManager.isBuiltInName(name);\r\n });\r\n\r\n await bootPhase(ConnectorLifecyclePhase.Early, connectors);\r\n\r\n context.moduleFailures.push(...(await discoverModels()));\r\n context.moduleFailures.push(...(await loadAppModules()));\r\n\r\n // Snapshot BEFORE the late phase: everything the app's own route modules\r\n // registered. The difference between this and the total is what connectors\r\n // contributed (pages, for `web`), and reporting the two separately is what\r\n // lets a user reconcile doctor's number with the dev server's.\r\n context.appRoutes = router.routeCount();\r\n\r\n await bootPhase(ConnectorLifecyclePhase.Late, connectors);\r\n\r\n context.totalRoutes = router.routeCount();\r\n\r\n context.booted = true;\r\n\r\n return context;\r\n}\r\n\r\n/**\r\n * Whether the app declares an HTTP surface at all. Checks that only make sense\r\n * for a served app use this to opt out instead of inventing a verdict.\r\n */\r\nexport function hasHttpConfig(): boolean {\r\n return Boolean(config.get(\"http\"));\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,mBAAmB;;;;AAKzB,SAAS,UAAU,OAAwB;CACzC,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;;;;;;;;;;;;;AAcA,SAAS,eAAe,MAAkC;CACxD,IAAI,SAAS,oBAAoB,CAAC,UAAU,IAAI,aAAa,GAC3D,OAAO;AAIX;;;;;;;;AASA,eAAe,UACb,OACA,YACe;CACf,KAAK,MAAM,aAAa,kBAAkB,KAAK,GAAG;EAChD,IAAI,UAAU,mBAAmB,OAAO;EAExC,MAAM,aAAa,eAAe,UAAU,IAAI;EAEhD,IAAI,YAAY;GACd,WAAW,QAAQ,KAAK;IAAE,MAAM,UAAU;IAAM,QAAQ;GAAW,CAAC;GACpE;EACF;EAEA,IAAI;GACF,MAAM,UAAU,KAAK;GACrB,WAAW,OAAO,KAAK,UAAU,IAAI;EACvC,SAAS,OAAO;GACd,WAAW,SAAS,KAAK;IAAE,MAAM,UAAU;IAAM,SAAS,UAAU,KAAK;GAAE,CAAC;EAC9E;CACF;AACF;;;;;;;;;;;AAYA,eAAe,iBAA2C;CACxD,IAAI;EACF,MAAM,kBAAkB,aAAa,QAAQ;EAC7C,OAAO,CAAC;CACV,SAAS,OAAO;EACd,IAAI,iBAAiB,gBACnB,OAAQ,MAAM,OAAqB,KAAK,YAAY;GAClD,OAAO,mBAAmB,kBACtB;IAAE,MAAM,QAAQ,KAAK;IAAc,SAAS,UAAU,QAAQ,KAAK;GAAE,IACrE;IAAE,MAAM;IAAW,SAAS,UAAU,OAAO;GAAE;EACrD,CAAC;EAGH,OAAO,CAAC;GAAE,MAAM;GAAW,SAAS,UAAU,KAAK;EAAE,CAAC;CACxD;AACF;;;;;;;AAQA,eAAe,iBAA2C;CACxD,MAAM,W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,WAAW;CAEtC,MAAM,kBAAwC,UAAU;CAExD,QAAQ,cAAc,OAAO,WAAW;CAExC,QAAQ,SAAS;CAEjB,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"boot-for-diagnostics.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/doctor/boot-for-diagnostics.ts"],"sourcesContent":["import { config } from \"../../../config/config-getter\";\r\nimport { connectorsManager } from \"../../../connectors/connectors-manager\";\r\nimport { registerConfiguredConnectors } from \"../../../connectors/register-configured-connectors\";\r\nimport { ConnectorLifecyclePhase } from \"../../../connectors/types\";\r\nimport { container } from \"../../../container\";\r\nimport { filesOrchestrator } from \"../../../dev-server/files-orchestrator\";\r\nimport { ModuleLoadError } from \"../../../dev-server/module-loader\";\r\nimport { router } from \"../../../router/router\";\r\nimport type { DoctorBootContext, ModuleFailure } from \"./check.types\";\r\n\r\n/**\r\n * @fileoverview The boot pass `warlock doctor` runs before its checks.\r\n *\r\n * THE RULE: **doctor boots, it never starts.**\r\n *\r\n * The connector contract already splits the two things doctor needs to keep\r\n * apart. `boot()` is where a connector REGISTERS — the HTTP connector builds a\r\n * Fastify instance and adds `/health` + `/ready` to it, the web connector\r\n * installs one route per page on the app router — and `start()` is where it\r\n * CONNECTS: opens the database, dials the cache, binds the port. Doctor runs\r\n * every `boot()` and no `start()`, so it sees the exact surface a served app\r\n * would have while opening no connection and binding no port.\r\n *\r\n * That seam is what makes the checks true. Before it existed here, doctor\r\n * preloaded config and framework bootstrap only: no app module was ever\r\n * imported, so no route module ever ran, so `routes` reported `0` on an app\r\n * `warlock dev` served 14 routes for — while `health` reported the endpoints as\r\n * \"registered\" from a config flag alone. Two checks, one app, contradictory\r\n * answers, and the wrong one was the one users acted on.\r\n *\r\n * ORDERING mirrors `DevelopmentServer.start()` exactly, because the route\r\n * surface is order-dependent: early connectors boot, then models (decorator\r\n * registries the route modules resolve against), then locales/events/mains/\r\n * routes, then late connectors — which is where `web` turns pages into routes.\r\n * Get the order wrong and the count is wrong, which is the defect this replaces.\r\n *\r\n * NOT read-only in one narrow sense: it imports the app's own modules, so\r\n * whatever a module does at import time happens. That is unavoidable — routes\r\n * only exist as the side effect of importing the file that declares them — and\r\n * it is the same import the dev server performs. It also refreshes\r\n * `.warlock/manifest.json`, the framework's own file cache. Nothing in the\r\n * app's data, and no network, is touched.\r\n */\r\n\r\n/**\r\n * The one connector whose `boot()` can bind a port. See {@link shouldSkipBoot}.\r\n */\r\nconst SOCKET_CONNECTOR = \"socket\";\r\n\r\n/**\r\n * Normalize anything thrown into a one-line message.\r\n */\r\nfunction messageOf(error: unknown): string {\r\n return error instanceof Error ? error.message : String(error);\r\n}\r\n\r\n/**\r\n * Whether doctor must refuse to boot this connector, and why.\r\n *\r\n * Exactly one case, and it is not a taste call: `SocketConnector.boot()` shares\r\n * the HTTP connector's raw server when there is one, and CREATES its own —\r\n * `server.listen(socketConfig.port)` — when there is not. The HTTP connector\r\n * boots first (lower priority number), so the shared path is what normally\r\n * happens; an app that configures `socket` without `http` is the exception, and\r\n * for that app booting socket would make a diagnostic command open a listening\r\n * port. Detected by asking the container what HTTP actually left behind rather\r\n * than by re-deriving the condition from config.\r\n */\r\nfunction shouldSkipBoot(name: string): string | undefined {\r\n if (name === SOCKET_CONNECTOR && !container.has(\"http.server\")) {\r\n return \"no http connector to share a server with — booting it would bind a port\";\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\n/**\r\n * Boot every registered connector in one lifecycle phase, isolating failures.\r\n *\r\n * A connector that throws on boot is recorded and the loop continues: one bad\r\n * connector must not hide the rest of the report, and \"which connector failed\r\n * to boot\" is itself a finding worth printing.\r\n */\r\nasync function bootPhase(\r\n phase: ConnectorLifecyclePhase,\r\n connectors: DoctorBootContext[\"connectors\"],\r\n): Promise<void> {\r\n for (const connector of connectorsManager.list()) {\r\n if (connector.lifecyclePhase !== phase) continue;\r\n\r\n const skipReason = shouldSkipBoot(connector.name);\r\n\r\n if (skipReason) {\r\n connectors.skipped.push({ name: connector.name, reason: skipReason });\r\n continue;\r\n }\r\n\r\n try {\r\n await connector.boot();\r\n connectors.booted.push(connector.name);\r\n } catch (error) {\r\n connectors.failures.push({ name: connector.name, message: messageOf(error) });\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Import every app module the dev server imports at boot, collecting failures\r\n * instead of letting the first one abort the pass.\r\n *\r\n * `loadAll()` is deliberately reused rather than reimplemented: it owns the\r\n * canonical order (locale → event → main → route) and the `withSourceFile`\r\n * scoping that gives each route its origin file. It aggregates its failures and\r\n * throws them at the end, which is exactly the shape needed here — every module\r\n * is attempted, and one broken route file cannot mask another.\r\n */\r\nasync function loadAppModules(): Promise<ModuleFailure[]> {\r\n try {\r\n await filesOrchestrator.moduleLoader.loadAll();\r\n return [];\r\n } catch (error) {\r\n if (error instanceof AggregateError) {\r\n return (error.errors as unknown[]).map((failure) => {\r\n return failure instanceof ModuleLoadError\r\n ? { file: failure.file.relativePath, message: messageOf(failure.cause) }\r\n : { file: \"unknown\", message: messageOf(failure) };\r\n });\r\n }\r\n\r\n return [{ file: \"unknown\", message: messageOf(error) }];\r\n }\r\n}\r\n\r\n/**\r\n * Eagerly import model files so the decorator-driven registries the route\r\n * modules resolve names against are populated first — the same reason\r\n * `DevelopmentServer.autoDiscoverFiles()` exists, and it must keep the same\r\n * position in the sequence.\r\n */\r\nasync function discoverModels(): Promise<ModuleFailure[]> {\r\n const failures: ModuleFailure[] = [];\r\n\r\n for (const file of filesOrchestrator.files.values()) {\r\n if (file.type !== \"model\") continue;\r\n\r\n try {\r\n await filesOrchestrator.moduleLoader.loadModule(file, \"model\");\r\n } catch (error) {\r\n failures.push({\r\n file: file.relativePath,\r\n message: error instanceof ModuleLoadError ? messageOf(error.cause) : messageOf(error),\r\n });\r\n }\r\n }\r\n\r\n return failures;\r\n}\r\n\r\n/**\r\n * Run the boot pass and report what it found.\r\n *\r\n * Never throws. Every failure mode — a connector array the config manager\r\n * refuses, a connector that throws on boot, a route module that fails to\r\n * import — becomes a field on the returned context, which the checks turn into\r\n * a printed verdict. A diagnostic command that crashes while diagnosing tells\r\n * the user nothing.\r\n */\r\nexport async function bootForDiagnostics(): Promise<DoctorBootContext> {\r\n const connectors: DoctorBootContext[\"connectors\"] = {\r\n registered: [],\r\n configured: [],\r\n booted: [],\r\n skipped: [],\r\n failures: [],\r\n };\r\n\r\n const context: DoctorBootContext = {\r\n booted: false,\r\n routeModules: 0,\r\n appRoutes: 0,\r\n totalRoutes: 0,\r\n moduleFailures: [],\r\n connectors,\r\n };\r\n\r\n try {\r\n // `init()` is idempotent and the preloader already ran it; calling it again\r\n // costs nothing and keeps this function honest on its own.\r\n await filesOrchestrator.init();\r\n await filesOrchestrator.initializeAll();\r\n\r\n filesOrchestrator.specialFilesCollector.collect(filesOrchestrator.getFiles());\r\n\r\n context.routeModules = filesOrchestrator.specialFilesCollector.getFilesByType(\"route\").length;\r\n } catch (error) {\r\n context.moduleFailures.push({ file: \"src/\", message: messageOf(error) });\r\n\r\n return context;\r\n }\r\n\r\n // The app's own connectors (`warlock.config.ts > connectors`) must be\r\n // registered before any phase boots, exactly as the dev preloader does it —\r\n // otherwise doctor would report on the eleven built-ins alone and miss the\r\n // connector the app actually configured. This is also the call that refuses a\r\n // duplicate or reserved connector name, so a config that would crash the next\r\n // real boot is caught here instead.\r\n try {\r\n registerConfiguredConnectors();\r\n } catch (error) {\r\n connectors.registrationError = messageOf(error);\r\n }\r\n\r\n connectors.registered = connectorsManager.list().map((connector) => connector.name);\r\n connectors.configured = connectors.registered.filter((name) => {\r\n return !connectorsManager.isBuiltInName(name);\r\n });\r\n\r\n await bootPhase(ConnectorLifecyclePhase.Early, connectors);\r\n\r\n context.moduleFailures.push(...(await discoverModels()));\r\n context.moduleFailures.push(...(await loadAppModules()));\r\n\r\n // Snapshot BEFORE the late phase: everything the app's own route modules\r\n // registered. The difference between this and the total is what connectors\r\n // contributed (pages, for `web`), and reporting the two separately is what\r\n // lets a user reconcile doctor's number with the dev server's.\r\n context.appRoutes = router.routeCount();\r\n\r\n await bootPhase(ConnectorLifecyclePhase.Late, connectors);\r\n\r\n context.totalRoutes = router.routeCount();\r\n\r\n context.booted = true;\r\n\r\n return context;\r\n}\r\n\r\n/**\r\n * Whether the app declares an HTTP surface at all. Checks that only make sense\r\n * for a served app use this to opt out instead of inventing a verdict.\r\n */\r\nexport function hasHttpConfig(): boolean {\r\n return Boolean(config.get(\"http\"));\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,mBAAmB;;;;AAKzB,SAAS,UAAU,OAAwB;CACzC,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAC9D;;;;;;;;;;;;;AAcA,SAAS,eAAe,MAAkC;CACxD,IAAI,SAAS,oBAAoB,CAAC,UAAU,IAAI,aAAa,GAC3D,OAAO;AAIX;;;;;;;;AASA,eAAe,UACb,OACA,YACe;CACf,KAAK,MAAM,aAAa,kBAAkB,KAAK,GAAG;EAChD,IAAI,UAAU,mBAAmB,OAAO;EAExC,MAAM,aAAa,eAAe,UAAU,IAAI;EAEhD,IAAI,YAAY;GACd,WAAW,QAAQ,KAAK;IAAE,MAAM,UAAU;IAAM,QAAQ;GAAW,CAAC;GACpE;EACF;EAEA,IAAI;GACF,MAAM,UAAU,KAAK;GACrB,WAAW,OAAO,KAAK,UAAU,IAAI;EACvC,SAAS,OAAO;GACd,WAAW,SAAS,KAAK;IAAE,MAAM,UAAU;IAAM,SAAS,UAAU,KAAK;GAAE,CAAC;EAC9E;CACF;AACF;;;;;;;;;;;AAYA,eAAe,iBAA2C;CACxD,IAAI;EACF,MAAM,kBAAkB,aAAa,QAAQ;EAC7C,OAAO,CAAC;CACV,SAAS,OAAO;EACd,IAAI,iBAAiB,gBACnB,OAAQ,MAAM,OAAqB,KAAK,YAAY;GAClD,OAAO,mBAAmB,kBACtB;IAAE,MAAM,QAAQ,KAAK;IAAc,SAAS,UAAU,QAAQ,KAAK;GAAE,IACrE;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9C,CAAC;CAED,MAAM,mBAAyC,UAAU;CAEzD,QAAQ,eAAe,KAAK,GAAI,MAAM,eAAe,CAAE;CACvD,QAAQ,eAAe,KAAK,GAAI,MAAM,eAAe,CAAE;CAMvD,QAAQ,YAAY,OAAO,WAAW;CAEtC,MAAM,kBAAwC,UAAU;CAExD,QAAQ,cAAc,OAAO,WAAW;CAExC,QAAQ,SAAS;CAEjB,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectors.check.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/doctor/checks/connectors.check.ts"],"sourcesContent":["import type { DoctorCheck } from \"../check.types\";\n\n/**\n * Reports whether the app's connectors survive boot.\n *\n * NEEDS A BOOTED APP: the boot pass runs every connector's `boot()` and no\n * `start()`, and this check reads the outcome.\n *\n * WHAT THIS REPLACED, AND WHY: the previous version printed\n * `11 registered, none active`. Both halves were tautologies. Eleven is the\n * number of built-in connectors the manager constructs when its module is\n * imported — it is the same on every project that has ever existed and says\n * nothing about the app. And \"none active\" was guaranteed, because `active` is\n * set by `start()` and doctor deliberately never starts anything: the warning\n * could not be absent from a healthy app, so it could not mean anything on a\n * broken one.\n *\n * What is reported instead is a fact that varies with the project and can be\n * wrong: the connectors the app itself configured, and whether each of them\n * boots. A connector that throws on boot is a boot-time crash the user has not\n * hit yet.\n *\n * Verdicts:\n * - `warlock.config.ts > connectors` refused (duplicate or reserved name) →\n * `fail`. The next real boot would throw the same error;\n * - a connector's `boot()` threw → `fail`, named, with the message;\n * - otherwise → `ok`, listing what booted.\n */\nexport const connectorsCheck: DoctorCheck = {\n name: \"connectors\",\n run: (context) => {\n const { connectors } = context;\n\n if (connectors.registrationError) {\n return {\n name: \"connectors\",\n status: \"fail\",\n detail: `warlock.config.ts > connectors was refused: ${connectors.registrationError}`,\n };\n }\n\n if (connectors.failures.length > 0) {\n return {\n name: \"connectors\",\n status: \"fail\",\n detail:\n `${connectors.failures.length} connector(s) failed to boot:\\n` +\n connectors.failures\n .map((failure) => ` - ${failure.name}: ${failure.message}`)\n .join(\"\\n\"),\n };\n }\n\n if (!context.booted) {\n return undefined;\n }\n\n const skipped = connectors.skipped\n .map((entry) => `; skipped ${entry.name} (${entry.reason})`)\n .join(\"\");\n\n const configured =\n connectors.configured.length > 0\n ? `${connectors.configured.join(\", \")} from warlock.config.ts + ` +\n `${connectors.registered.length - connectors.configured.length} built-in`\n : `${connectors.registered.length} built-in, none configured in warlock.config.ts`;\n\n return {\n name: \"connectors\",\n status: \"ok\",\n detail: `all booted without error (${configured})${skipped}`,\n };\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,kBAA+B;CAC1C,MAAM;CACN,MAAM,YAAY;EAChB,MAAM,EAAE,eAAe;EAEvB,IAAI,WAAW,mBACb,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QAAQ,+CAA+C,WAAW;EACpE;EAGF,IAAI,WAAW,SAAS,SAAS,GAC/B,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QACE,GAAG,WAAW,SAAS,OAAO,mCAC9B,WAAW,SACR,KAAK,YAAY,OAAO,QAAQ,KAAK,IAAI,QAAQ,SAAS,
|
|
1
|
+
{"version":3,"file":"connectors.check.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/doctor/checks/connectors.check.ts"],"sourcesContent":["import type { DoctorCheck } from \"../check.types\";\n\n/**\n * Reports whether the app's connectors survive boot.\n *\n * NEEDS A BOOTED APP: the boot pass runs every connector's `boot()` and no\n * `start()`, and this check reads the outcome.\n *\n * WHAT THIS REPLACED, AND WHY: the previous version printed\n * `11 registered, none active`. Both halves were tautologies. Eleven is the\n * number of built-in connectors the manager constructs when its module is\n * imported — it is the same on every project that has ever existed and says\n * nothing about the app. And \"none active\" was guaranteed, because `active` is\n * set by `start()` and doctor deliberately never starts anything: the warning\n * could not be absent from a healthy app, so it could not mean anything on a\n * broken one.\n *\n * What is reported instead is a fact that varies with the project and can be\n * wrong: the connectors the app itself configured, and whether each of them\n * boots. A connector that throws on boot is a boot-time crash the user has not\n * hit yet.\n *\n * Verdicts:\n * - `warlock.config.ts > connectors` refused (duplicate or reserved name) →\n * `fail`. The next real boot would throw the same error;\n * - a connector's `boot()` threw → `fail`, named, with the message;\n * - otherwise → `ok`, listing what booted.\n */\nexport const connectorsCheck: DoctorCheck = {\n name: \"connectors\",\n run: (context) => {\n const { connectors } = context;\n\n if (connectors.registrationError) {\n return {\n name: \"connectors\",\n status: \"fail\",\n detail: `warlock.config.ts > connectors was refused: ${connectors.registrationError}`,\n };\n }\n\n if (connectors.failures.length > 0) {\n return {\n name: \"connectors\",\n status: \"fail\",\n detail:\n `${connectors.failures.length} connector(s) failed to boot:\\n` +\n connectors.failures\n .map((failure) => ` - ${failure.name}: ${failure.message}`)\n .join(\"\\n\"),\n };\n }\n\n if (!context.booted) {\n return undefined;\n }\n\n const skipped = connectors.skipped\n .map((entry) => `; skipped ${entry.name} (${entry.reason})`)\n .join(\"\");\n\n const configured =\n connectors.configured.length > 0\n ? `${connectors.configured.join(\", \")} from warlock.config.ts + ` +\n `${connectors.registered.length - connectors.configured.length} built-in`\n : `${connectors.registered.length} built-in, none configured in warlock.config.ts`;\n\n return {\n name: \"connectors\",\n status: \"ok\",\n detail: `all booted without error (${configured})${skipped}`,\n };\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,kBAA+B;CAC1C,MAAM;CACN,MAAM,YAAY;EAChB,MAAM,EAAE,eAAe;EAEvB,IAAI,WAAW,mBACb,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QAAQ,+CAA+C,WAAW;EACpE;EAGF,IAAI,WAAW,SAAS,SAAS,GAC/B,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QACE,GAAG,WAAW,SAAS,OAAO,mCAC9B,WAAW,SACR,KAAK,YAAY,OAAO,QAAQ,KAAK,IAAI,QAAQ,SAAS,EAC1D,KAAK,IAAI;EAChB;EAGF,IAAI,CAAC,QAAQ,QACX;EAGF,MAAM,UAAU,WAAW,QACxB,KAAK,UAAU,aAAa,MAAM,KAAK,IAAI,MAAM,OAAO,EAAE,EAC1D,KAAK,EAAE;EAQV,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QAAQ,6BARR,WAAW,WAAW,SAAS,IAC3B,GAAG,WAAW,WAAW,KAAK,IAAI,EAAE,4BACjC,WAAW,WAAW,SAAS,WAAW,WAAW,OAAO,aAC/D,GAAG,WAAW,WAAW,OAAO,iDAKY,GAAG;EACrD;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler-signature.check.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/doctor/checks/handler-signature.check.ts"],"sourcesContent":["import {\n describePositionalHandlerSuspect,\n listPositionalHandlerSuspects,\n} from \"../../../../router/positional-handler-diagnostics\";\nimport type { DoctorCheck } from \"../check.types\";\n\n/**\n * Surfaces route handlers still written against the v4 positional signature,\n * `(request, response)`. v5 calls a handler with a single context object, so\n * the second parameter is always `undefined` and the route fails on its first\n * request with a `TypeError` that names nothing.\n *\n * Verdicts:\n * - one or more suspects → `warn`;\n * - otherwise → `ok`.\n *\n * `warn`, never `fail`: the detection is a heuristic on the handler's declared\n * parameters, so a false positive is possible and must not break a build.\n *\n * NEEDS A BOOTED APP: the router collects suspects as routes register, so this\n * reads a list the boot pass filled. Before that pass existed the list was\n * always empty and this check always passed — it was green because it had\n * nothing to look at, which is indistinguishable from green because the app is\n * fine. It stays silent when there are no routes for the same reason: a check\n * with no input reports nothing rather than a clean bill of health.\n */\nexport const handlerSignatureCheck: DoctorCheck = {\n name: \"handler-signature\",\n run: (context) => {\n if (context.totalRoutes === 0) {\n return undefined;\n }\n\n const suspects = listPositionalHandlerSuspects();\n\n if (suspects.length === 0) {\n return {\n name: \"handler-signature\",\n status: \"ok\",\n detail: \"no handlers look like the v4 positional signature\",\n };\n }\n\n const headline =\n suspects.length === 1\n ? \"1 handler looks like the v4 positional signature\"\n : `${suspects.length} handlers look like the v4 positional signature`;\n\n return {\n name: \"handler-signature\",\n status: \"warn\",\n detail:\n `${headline}:\\n` +\n suspects.map((suspect) => ` - ${describePositionalHandlerSuspect(suspect)}`).join(\"\\n\"),\n };\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,wBAAqC;CAChD,MAAM;CACN,MAAM,YAAY;EAChB,IAAI,QAAQ,gBAAgB,GAC1B;EAGF,MAAM,WAAW,8BAA8B;EAE/C,IAAI,SAAS,WAAW,GACtB,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QAAQ;EACV;EAQF,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QACE,GARF,SAAS,WAAW,IAChB,qDACA,GAAG,SAAS,OAAO,iDAMT,OACZ,SAAS,KAAK,YAAY,OAAO,iCAAiC,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"handler-signature.check.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/doctor/checks/handler-signature.check.ts"],"sourcesContent":["import {\n describePositionalHandlerSuspect,\n listPositionalHandlerSuspects,\n} from \"../../../../router/positional-handler-diagnostics\";\nimport type { DoctorCheck } from \"../check.types\";\n\n/**\n * Surfaces route handlers still written against the v4 positional signature,\n * `(request, response)`. v5 calls a handler with a single context object, so\n * the second parameter is always `undefined` and the route fails on its first\n * request with a `TypeError` that names nothing.\n *\n * Verdicts:\n * - one or more suspects → `warn`;\n * - otherwise → `ok`.\n *\n * `warn`, never `fail`: the detection is a heuristic on the handler's declared\n * parameters, so a false positive is possible and must not break a build.\n *\n * NEEDS A BOOTED APP: the router collects suspects as routes register, so this\n * reads a list the boot pass filled. Before that pass existed the list was\n * always empty and this check always passed — it was green because it had\n * nothing to look at, which is indistinguishable from green because the app is\n * fine. It stays silent when there are no routes for the same reason: a check\n * with no input reports nothing rather than a clean bill of health.\n */\nexport const handlerSignatureCheck: DoctorCheck = {\n name: \"handler-signature\",\n run: (context) => {\n if (context.totalRoutes === 0) {\n return undefined;\n }\n\n const suspects = listPositionalHandlerSuspects();\n\n if (suspects.length === 0) {\n return {\n name: \"handler-signature\",\n status: \"ok\",\n detail: \"no handlers look like the v4 positional signature\",\n };\n }\n\n const headline =\n suspects.length === 1\n ? \"1 handler looks like the v4 positional signature\"\n : `${suspects.length} handlers look like the v4 positional signature`;\n\n return {\n name: \"handler-signature\",\n status: \"warn\",\n detail:\n `${headline}:\\n` +\n suspects.map((suspect) => ` - ${describePositionalHandlerSuspect(suspect)}`).join(\"\\n\"),\n };\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,wBAAqC;CAChD,MAAM;CACN,MAAM,YAAY;EAChB,IAAI,QAAQ,gBAAgB,GAC1B;EAGF,MAAM,WAAW,8BAA8B;EAE/C,IAAI,SAAS,WAAW,GACtB,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QAAQ;EACV;EAQF,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QACE,GARF,SAAS,WAAW,IAChB,qDACA,GAAG,SAAS,OAAO,iDAMT,OACZ,SAAS,KAAK,YAAY,OAAO,iCAAiC,OAAO,GAAG,EAAE,KAAK,IAAI;EAC3F;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.check.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/doctor/checks/health.check.ts"],"sourcesContent":["import { config } from \"../../../../config/config-getter\";\nimport { container } from \"../../../../container\";\nimport { router } from \"../../../../router/router\";\nimport type { DoctorCheck } from \"../check.types\";\n\n/**\n * Ask the booted Fastify instance whether a GET route exists at this path.\n *\n * `hasRoute` is the instance's own answer, not a re-derivation of the config\n * that was supposed to produce it — which is the entire point of asking it.\n * Guarded because it is the one part of this check that depends on a Fastify\n * API: if the instance cannot answer, the check says so instead of inventing a\n * verdict from the config flag it is meant to be verifying.\n */\nfunction fastifyHasGet(path: string): boolean | undefined {\n const http = container.has(\"http.server\") ? container.get<any>(\"http.server\") : undefined;\n\n if (!http || typeof http.hasRoute !== \"function\") return undefined;\n\n try {\n return Boolean(http.hasRoute({ method: \"GET\", url: path }));\n } catch {\n return undefined;\n }\n}\n\n/**\n * Whether an app route already claims this path. The HTTP connector puts the\n * probes on the Fastify instance directly and the router scans app routes onto\n * the same instance at `start()`, so a collision is a duplicate registration:\n * Fastify refuses it and the server does not start.\n */\nfunction appRouteClaims(path: string): boolean {\n return router.list().some((route) => {\n const method = String(route.method).toUpperCase();\n\n return route.path === path && (method === \"GET\" || method === \"ALL\");\n });\n}\n\n/**\n * Confirms the liveness (`/health`) and readiness (`/ready`) endpoints are\n * really there.\n *\n * NEEDS A BOOTED APP: the HTTP connector registers the probes during `boot()`,\n * which the boot pass runs. Previously this check read `http.health.enabled`\n * and reported the endpoints as \"registered\" on that basis alone — in the same\n * report where `routes` said zero, because nothing had been booted at all. It\n * was reporting an intention as a fact, and the two lines contradicted each\n * other in the owner's own run.\n *\n * Verdicts:\n * - no `http` config → not applicable, no line;\n * - `http.health.enabled = false` → `ok`. Turning the probes off is a supported\n * choice, and a warning that fires on a deliberate setting every single run\n * is not read by the time it matters;\n * - an app route already claims a probe's path → `fail`: Fastify will refuse\n * the duplicate and the server will not start;\n * - the instance says the route is absent → `fail`;\n * - otherwise → `ok`, with the paths that are actually registered.\n */\nexport const healthCheck: DoctorCheck = {\n name: \"health\",\n run: (context) => {\n if (!config.get(\"http\")) {\n return undefined;\n }\n\n const healthConfig = config.get(\"http.health\");\n\n if (healthConfig?.enabled === false) {\n return {\n name: \"health\",\n status: \"ok\",\n detail: \"probes disabled by config (http.health.enabled = false)\",\n };\n }\n\n const livenessPath = healthConfig?.path ?? \"/health\";\n const readinessPath = healthConfig?.readinessPath ?? \"/ready\";\n\n const collisions = [livenessPath, readinessPath].filter(appRouteClaims);\n\n if (collisions.length > 0) {\n return {\n name: \"health\",\n status: \"fail\",\n detail:\n `an app route already claims ${collisions.join(\" and \")} — Fastify refuses the ` +\n \"duplicate registration and the server will not start. Move the app route, or \" +\n \"rename the probe via http.health.path / http.health.readinessPath\",\n };\n }\n\n // The HTTP connector is what registers the probes. If it did not boot, the\n // connectors check already says so with the reason — reporting the same\n // defect a second time here as a health failure would inflate one problem\n // into two.\n if (!context.connectors.booted.includes(\"http\")) {\n return undefined;\n }\n\n const registered = [livenessPath, readinessPath].map(fastifyHasGet);\n\n if (registered.some((answer) => answer === undefined)) {\n return {\n name: \"health\",\n status: \"warn\",\n detail:\n \"could not read the http server's route table — \" +\n `${livenessPath} + ${readinessPath} unverified`,\n };\n }\n\n const missing = [livenessPath, readinessPath].filter((_path, index) => !registered[index]);\n\n if (missing.length > 0) {\n return {\n name: \"health\",\n status: \"fail\",\n detail: `enabled in config but not registered on the http server: ${missing.join(\", \")}`,\n };\n }\n\n return {\n name: \"health\",\n status: \"ok\",\n detail: `liveness ${livenessPath} + readiness ${readinessPath} registered`,\n };\n },\n};\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,cAAc,MAAmC;CACxD,MAAM,OAAO,UAAU,IAAI,aAAa,IAAI,UAAU,IAAS,aAAa,IAAI;CAEhF,IAAI,CAAC,QAAQ,OAAO,KAAK,aAAa,YAAY,OAAO;CAEzD,IAAI;EACF,OAAO,QAAQ,KAAK,SAAS;GAAE,QAAQ;GAAO,KAAK;EAAK,CAAC,CAAC;CAC5D,QAAQ;EACN;CACF;AACF;;;;;;;AAQA,SAAS,eAAe,MAAuB;CAC7C,OAAO,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"health.check.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/doctor/checks/health.check.ts"],"sourcesContent":["import { config } from \"../../../../config/config-getter\";\nimport { container } from \"../../../../container\";\nimport { router } from \"../../../../router/router\";\nimport type { DoctorCheck } from \"../check.types\";\n\n/**\n * Ask the booted Fastify instance whether a GET route exists at this path.\n *\n * `hasRoute` is the instance's own answer, not a re-derivation of the config\n * that was supposed to produce it — which is the entire point of asking it.\n * Guarded because it is the one part of this check that depends on a Fastify\n * API: if the instance cannot answer, the check says so instead of inventing a\n * verdict from the config flag it is meant to be verifying.\n */\nfunction fastifyHasGet(path: string): boolean | undefined {\n const http = container.has(\"http.server\") ? container.get<any>(\"http.server\") : undefined;\n\n if (!http || typeof http.hasRoute !== \"function\") return undefined;\n\n try {\n return Boolean(http.hasRoute({ method: \"GET\", url: path }));\n } catch {\n return undefined;\n }\n}\n\n/**\n * Whether an app route already claims this path. The HTTP connector puts the\n * probes on the Fastify instance directly and the router scans app routes onto\n * the same instance at `start()`, so a collision is a duplicate registration:\n * Fastify refuses it and the server does not start.\n */\nfunction appRouteClaims(path: string): boolean {\n return router.list().some((route) => {\n const method = String(route.method).toUpperCase();\n\n return route.path === path && (method === \"GET\" || method === \"ALL\");\n });\n}\n\n/**\n * Confirms the liveness (`/health`) and readiness (`/ready`) endpoints are\n * really there.\n *\n * NEEDS A BOOTED APP: the HTTP connector registers the probes during `boot()`,\n * which the boot pass runs. Previously this check read `http.health.enabled`\n * and reported the endpoints as \"registered\" on that basis alone — in the same\n * report where `routes` said zero, because nothing had been booted at all. It\n * was reporting an intention as a fact, and the two lines contradicted each\n * other in the owner's own run.\n *\n * Verdicts:\n * - no `http` config → not applicable, no line;\n * - `http.health.enabled = false` → `ok`. Turning the probes off is a supported\n * choice, and a warning that fires on a deliberate setting every single run\n * is not read by the time it matters;\n * - an app route already claims a probe's path → `fail`: Fastify will refuse\n * the duplicate and the server will not start;\n * - the instance says the route is absent → `fail`;\n * - otherwise → `ok`, with the paths that are actually registered.\n */\nexport const healthCheck: DoctorCheck = {\n name: \"health\",\n run: (context) => {\n if (!config.get(\"http\")) {\n return undefined;\n }\n\n const healthConfig = config.get(\"http.health\");\n\n if (healthConfig?.enabled === false) {\n return {\n name: \"health\",\n status: \"ok\",\n detail: \"probes disabled by config (http.health.enabled = false)\",\n };\n }\n\n const livenessPath = healthConfig?.path ?? \"/health\";\n const readinessPath = healthConfig?.readinessPath ?? \"/ready\";\n\n const collisions = [livenessPath, readinessPath].filter(appRouteClaims);\n\n if (collisions.length > 0) {\n return {\n name: \"health\",\n status: \"fail\",\n detail:\n `an app route already claims ${collisions.join(\" and \")} — Fastify refuses the ` +\n \"duplicate registration and the server will not start. Move the app route, or \" +\n \"rename the probe via http.health.path / http.health.readinessPath\",\n };\n }\n\n // The HTTP connector is what registers the probes. If it did not boot, the\n // connectors check already says so with the reason — reporting the same\n // defect a second time here as a health failure would inflate one problem\n // into two.\n if (!context.connectors.booted.includes(\"http\")) {\n return undefined;\n }\n\n const registered = [livenessPath, readinessPath].map(fastifyHasGet);\n\n if (registered.some((answer) => answer === undefined)) {\n return {\n name: \"health\",\n status: \"warn\",\n detail:\n \"could not read the http server's route table — \" +\n `${livenessPath} + ${readinessPath} unverified`,\n };\n }\n\n const missing = [livenessPath, readinessPath].filter((_path, index) => !registered[index]);\n\n if (missing.length > 0) {\n return {\n name: \"health\",\n status: \"fail\",\n detail: `enabled in config but not registered on the http server: ${missing.join(\", \")}`,\n };\n }\n\n return {\n name: \"health\",\n status: \"ok\",\n detail: `liveness ${livenessPath} + readiness ${readinessPath} registered`,\n };\n },\n};\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,cAAc,MAAmC;CACxD,MAAM,OAAO,UAAU,IAAI,aAAa,IAAI,UAAU,IAAS,aAAa,IAAI;CAEhF,IAAI,CAAC,QAAQ,OAAO,KAAK,aAAa,YAAY,OAAO;CAEzD,IAAI;EACF,OAAO,QAAQ,KAAK,SAAS;GAAE,QAAQ;GAAO,KAAK;EAAK,CAAC,CAAC;CAC5D,QAAQ;EACN;CACF;AACF;;;;;;;AAQA,SAAS,eAAe,MAAuB;CAC7C,OAAO,OAAO,KAAK,EAAE,MAAM,UAAU;EACnC,MAAM,SAAS,OAAO,MAAM,MAAM,EAAE,YAAY;EAEhD,OAAO,MAAM,SAAS,SAAS,WAAW,SAAS,WAAW;CAChE,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,cAA2B;CACtC,MAAM;CACN,MAAM,YAAY;EAChB,IAAI,CAAC,OAAO,IAAI,MAAM,GACpB;EAGF,MAAM,eAAe,OAAO,IAAI,aAAa;EAE7C,IAAI,cAAc,YAAY,OAC5B,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QAAQ;EACV;EAGF,MAAM,eAAe,cAAc,QAAQ;EAC3C,MAAM,gBAAgB,cAAc,iBAAiB;EAErD,MAAM,aAAa,CAAC,cAAc,aAAa,EAAE,OAAO,cAAc;EAEtE,IAAI,WAAW,SAAS,GACtB,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QACE,+BAA+B,WAAW,KAAK,OAAO,EAAE;EAG5D;EAOF,IAAI,CAAC,QAAQ,WAAW,OAAO,SAAS,MAAM,GAC5C;EAGF,MAAM,aAAa,CAAC,cAAc,aAAa,EAAE,IAAI,aAAa;EAElE,IAAI,WAAW,MAAM,WAAW,WAAW,MAAS,GAClD,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QACE,kDACG,aAAa,KAAK,cAAc;EACvC;EAGF,MAAM,UAAU,CAAC,cAAc,aAAa,EAAE,QAAQ,OAAO,UAAU,CAAC,WAAW,MAAM;EAEzF,IAAI,QAAQ,SAAS,GACnB,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QAAQ,4DAA4D,QAAQ,KAAK,IAAI;EACvF;EAGF,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QAAQ,YAAY,aAAa,eAAe,cAAc;EAChE;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optional-peers.check.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/doctor/checks/optional-peers.check.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { config } from \"../../../../config/config-getter\";\nimport type { CheckStatus, DoctorCheck } from \"../check.types\";\n\n/**\n * A package this project's own configuration requires, and what asked for it.\n */\ntype RequiredPeer = {\n /** The npm package name to probe via `require.resolve`. */\n package: string;\n\n /** The config that asked for it, quoted back to the user verbatim. */\n because: string;\n};\n\n/**\n * Resolve from the project's working directory, not from core's own\n * `node_modules`, so the probe reflects what the *consuming app* has installed.\n */\nconst projectRequire = createRequire(`${process.cwd()}/package.json`);\n\n/**\n * Whether a package can be resolved from the project. A failed resolve (the\n * normal \"not installed\" case) is swallowed and reported as missing.\n */\nfunction isInstalled(packageName: string): boolean {\n try {\n projectRequire.resolve(packageName);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * A non-empty string, or `undefined`. Config values arrive from `env(...)` and\n * an unset variable yields `undefined` — but a `.env` line with nothing after\n * the `=` yields `\"\"`, which is \"not configured\" just as much.\n */\nfunction text(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : undefined;\n}\n\n/**\n * The database driver's package. `driver` is a closed union in cascade\n * (`mongodb | postgres | mysql`), so an unrecognised value means the config is\n * wrong in a way this check is not the right one to report.\n */\nfunction databasePeer(): RequiredPeer | undefined {\n const driver = text(config.get(\"database.driver\"));\n\n const packageName =\n driver === \"mongodb\"\n ? \"mongodb\"\n : driver === \"postgres\"\n ? \"pg\"\n : driver === \"mysql\"\n ? \"mysql2\"\n : undefined;\n\n return packageName ? { package: packageName, because: `database.driver = \"${driver}\"` } : undefined;\n}\n\n/**\n * The selected cache driver. Only the DEFAULT matters: `cache.drivers` is a\n * menu the scaffold fills in for every driver the framework ships, and warning\n * about a menu entry nobody selected is the false positive this whole check was\n * rewritten to remove.\n */\nfunction cachePeer(): RequiredPeer | undefined {\n const selected = text(config.get(\"cache.default\"));\n\n if (!selected || !/redis/i.test(selected)) return undefined;\n\n return { package: \"redis\", because: `cache.default = \"${selected}\"` };\n}\n\n/**\n * The selected storage driver, read through its canonical `driver` field\n * (`local` / `s3` / `r2` / `spaces`) rather than the key the app happened to\n * name it, so a driver called \"cdn\" is still recognised as S3.\n */\nfunction storagePeer(): RequiredPeer | undefined {\n const selected = text(config.get(\"storage.default\"));\n\n if (!selected) return undefined;\n\n const driver = text(config.get(`storage.drivers.${selected}.driver`));\n\n if (!driver || driver === \"local\") return undefined;\n\n return {\n package: \"@aws-sdk/client-s3\",\n because: `storage.default = \"${selected}\" (driver \"${driver}\")`,\n };\n}\n\n/**\n * The mail transport. A `mail` config with no host and no driver is the\n * scaffold's placeholder — every field is an unset env var — so it asks for\n * nothing and this stays quiet.\n */\nfunction mailPeer(): RequiredPeer | undefined {\n const driver = text(config.get(\"mail.driver\"));\n\n if (driver === \"ses\") {\n return { package: \"@aws-sdk/client-sesv2\", because: `mail.driver = \"ses\"` };\n }\n\n const host = text(config.get(\"mail.host\"));\n\n if (!host) return undefined;\n\n return { package: \"nodemailer\", because: `mail.host = \"${host}\"` };\n}\n\n/**\n * Realtime sockets. The connector no-ops without a `socket` config, so the\n * presence of that config is exactly the request for the peer.\n */\nfunction socketPeer(): RequiredPeer | undefined {\n if (!config.get(\"socket\")) return undefined;\n\n return { package: \"socket.io\", because: \"a socket config is present\" };\n}\n\n/**\n * Every peer THIS project's configuration asks for.\n */\nfunction requiredPeers(): RequiredPeer[] {\n return [databasePeer(), cachePeer(), storagePeer(), mailPeer(), socketPeer()].filter(\n (peer): peer is RequiredPeer => Boolean(peer),\n );\n}\n\n/**\n * Checks that every optional peer the project's own configuration selects is\n * actually installed.\n *\n * NEEDS NO BOOTED APP — it reads config and resolves module paths. It runs after\n * the boot pass only because config is loaded by then.\n *\n * WHAT THIS REPLACED, AND WHY: the previous version probed nine packages and\n * warned about every one that was absent. Every one of them is an OPTIONAL\n * peer — a fresh app installs none of them by design — so the check warned, at\n * length, about the framework's own default state. \"No MySQL driver installed\"\n * is not a diagnosis for someone who never wanted MySQL; it is noise that\n * teaches the reader to skim past the line where a real finding will one day\n * appear.\n *\n * Inverted, it becomes a genuine one: a project whose config selects a driver\n * whose package is missing is broken — it will throw the first time that\n * feature is used — so a missing peer here is a `fail`, not a warning.\n */\nexport const optionalPeersCheck: DoctorCheck = {\n name: \"optional-peers\",\n run: () => {\n const required = requiredPeers();\n\n if (required.length === 0) {\n return undefined;\n }\n\n const missing = required.filter((peer) => !isInstalled(peer.package));\n\n const status: CheckStatus = missing.length > 0 ? \"fail\" : \"ok\";\n\n if (missing.length > 0) {\n return {\n name: \"optional-peers\",\n status,\n detail:\n `${missing.length} configured feature(s) have no driver installed:\\n` +\n missing.map((peer) => ` - ${peer.package} — required by ${peer.because}`).join(\"\\n\"),\n };\n }\n\n return {\n name: \"optional-peers\",\n status,\n detail: `every configured driver is installed (${required\n .map((peer) => peer.package)\n .join(\", \")})`,\n };\n },\n};\n"],"mappings":";;;;;;;;AAmBA,MAAM,iBAAiB,cAAc,GAAG,QAAQ,IAAI,EAAE,cAAc;;;;;AAMpE,SAAS,YAAY,aAA8B;CACjD,IAAI;EACF,eAAe,QAAQ,WAAW;EAClC,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;AAOA,SAAS,KAAK,OAAoC;CAChD,OAAO,OAAO,UAAU,YAAY,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"optional-peers.check.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/doctor/checks/optional-peers.check.ts"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { config } from \"../../../../config/config-getter\";\nimport type { CheckStatus, DoctorCheck } from \"../check.types\";\n\n/**\n * A package this project's own configuration requires, and what asked for it.\n */\ntype RequiredPeer = {\n /** The npm package name to probe via `require.resolve`. */\n package: string;\n\n /** The config that asked for it, quoted back to the user verbatim. */\n because: string;\n};\n\n/**\n * Resolve from the project's working directory, not from core's own\n * `node_modules`, so the probe reflects what the *consuming app* has installed.\n */\nconst projectRequire = createRequire(`${process.cwd()}/package.json`);\n\n/**\n * Whether a package can be resolved from the project. A failed resolve (the\n * normal \"not installed\" case) is swallowed and reported as missing.\n */\nfunction isInstalled(packageName: string): boolean {\n try {\n projectRequire.resolve(packageName);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * A non-empty string, or `undefined`. Config values arrive from `env(...)` and\n * an unset variable yields `undefined` — but a `.env` line with nothing after\n * the `=` yields `\"\"`, which is \"not configured\" just as much.\n */\nfunction text(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : undefined;\n}\n\n/**\n * The database driver's package. `driver` is a closed union in cascade\n * (`mongodb | postgres | mysql`), so an unrecognised value means the config is\n * wrong in a way this check is not the right one to report.\n */\nfunction databasePeer(): RequiredPeer | undefined {\n const driver = text(config.get(\"database.driver\"));\n\n const packageName =\n driver === \"mongodb\"\n ? \"mongodb\"\n : driver === \"postgres\"\n ? \"pg\"\n : driver === \"mysql\"\n ? \"mysql2\"\n : undefined;\n\n return packageName ? { package: packageName, because: `database.driver = \"${driver}\"` } : undefined;\n}\n\n/**\n * The selected cache driver. Only the DEFAULT matters: `cache.drivers` is a\n * menu the scaffold fills in for every driver the framework ships, and warning\n * about a menu entry nobody selected is the false positive this whole check was\n * rewritten to remove.\n */\nfunction cachePeer(): RequiredPeer | undefined {\n const selected = text(config.get(\"cache.default\"));\n\n if (!selected || !/redis/i.test(selected)) return undefined;\n\n return { package: \"redis\", because: `cache.default = \"${selected}\"` };\n}\n\n/**\n * The selected storage driver, read through its canonical `driver` field\n * (`local` / `s3` / `r2` / `spaces`) rather than the key the app happened to\n * name it, so a driver called \"cdn\" is still recognised as S3.\n */\nfunction storagePeer(): RequiredPeer | undefined {\n const selected = text(config.get(\"storage.default\"));\n\n if (!selected) return undefined;\n\n const driver = text(config.get(`storage.drivers.${selected}.driver`));\n\n if (!driver || driver === \"local\") return undefined;\n\n return {\n package: \"@aws-sdk/client-s3\",\n because: `storage.default = \"${selected}\" (driver \"${driver}\")`,\n };\n}\n\n/**\n * The mail transport. A `mail` config with no host and no driver is the\n * scaffold's placeholder — every field is an unset env var — so it asks for\n * nothing and this stays quiet.\n */\nfunction mailPeer(): RequiredPeer | undefined {\n const driver = text(config.get(\"mail.driver\"));\n\n if (driver === \"ses\") {\n return { package: \"@aws-sdk/client-sesv2\", because: `mail.driver = \"ses\"` };\n }\n\n const host = text(config.get(\"mail.host\"));\n\n if (!host) return undefined;\n\n return { package: \"nodemailer\", because: `mail.host = \"${host}\"` };\n}\n\n/**\n * Realtime sockets. The connector no-ops without a `socket` config, so the\n * presence of that config is exactly the request for the peer.\n */\nfunction socketPeer(): RequiredPeer | undefined {\n if (!config.get(\"socket\")) return undefined;\n\n return { package: \"socket.io\", because: \"a socket config is present\" };\n}\n\n/**\n * Every peer THIS project's configuration asks for.\n */\nfunction requiredPeers(): RequiredPeer[] {\n return [databasePeer(), cachePeer(), storagePeer(), mailPeer(), socketPeer()].filter(\n (peer): peer is RequiredPeer => Boolean(peer),\n );\n}\n\n/**\n * Checks that every optional peer the project's own configuration selects is\n * actually installed.\n *\n * NEEDS NO BOOTED APP — it reads config and resolves module paths. It runs after\n * the boot pass only because config is loaded by then.\n *\n * WHAT THIS REPLACED, AND WHY: the previous version probed nine packages and\n * warned about every one that was absent. Every one of them is an OPTIONAL\n * peer — a fresh app installs none of them by design — so the check warned, at\n * length, about the framework's own default state. \"No MySQL driver installed\"\n * is not a diagnosis for someone who never wanted MySQL; it is noise that\n * teaches the reader to skim past the line where a real finding will one day\n * appear.\n *\n * Inverted, it becomes a genuine one: a project whose config selects a driver\n * whose package is missing is broken — it will throw the first time that\n * feature is used — so a missing peer here is a `fail`, not a warning.\n */\nexport const optionalPeersCheck: DoctorCheck = {\n name: \"optional-peers\",\n run: () => {\n const required = requiredPeers();\n\n if (required.length === 0) {\n return undefined;\n }\n\n const missing = required.filter((peer) => !isInstalled(peer.package));\n\n const status: CheckStatus = missing.length > 0 ? \"fail\" : \"ok\";\n\n if (missing.length > 0) {\n return {\n name: \"optional-peers\",\n status,\n detail:\n `${missing.length} configured feature(s) have no driver installed:\\n` +\n missing.map((peer) => ` - ${peer.package} — required by ${peer.because}`).join(\"\\n\"),\n };\n }\n\n return {\n name: \"optional-peers\",\n status,\n detail: `every configured driver is installed (${required\n .map((peer) => peer.package)\n .join(\", \")})`,\n };\n },\n};\n"],"mappings":";;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,SAAS,gBAAgB,KAAK;CAAG;AACnE;;;;;AAMA,SAAS,aAAuC;CAC9C,IAAI,CAAC,OAAO,IAAI,QAAQ,GAAG,OAAO;CAElC,OAAO;EAAE,SAAS;EAAa,SAAS;CAA6B;AACvE;;;;AAKA,SAAS,gBAAgC;CACvC,OAAO;EAAC,aAAa;EAAG,UAAU;EAAG,YAAY;EAAG,SAAS;EAAG,WAAW;CAAC,EAAE,QAC3E,SAA+B,QAAQ,IAAI,CAC9C;AACF;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,qBAAkC;CAC7C,MAAM;CACN,WAAW;EACT,MAAM,WAAW,cAAc;EAE/B,IAAI,SAAS,WAAW,GACtB;EAGF,MAAM,UAAU,SAAS,QAAQ,SAAS,CAAC,YAAY,KAAK,OAAO,CAAC;EAEpE,MAAM,SAAsB,QAAQ,SAAS,IAAI,SAAS;EAE1D,IAAI,QAAQ,SAAS,GACnB,OAAO;GACL,MAAM;GACN;GACA,QACE,GAAG,QAAQ,OAAO,sDAClB,QAAQ,KAAK,SAAS,OAAO,KAAK,QAAQ,iBAAiB,KAAK,SAAS,EAAE,KAAK,IAAI;EACxF;EAGF,OAAO;GACL,MAAM;GACN;GACA,QAAQ,yCAAyC,SAC9C,KAAK,SAAS,KAAK,OAAO,EAC1B,KAAK,IAAI,EAAE;EAChB;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.check.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/doctor/checks/routes.check.ts"],"sourcesContent":["import type { DoctorBootContext, DoctorCheck } from \"../check.types\";\n\n/**\n * Describe the failed modules as an indented block, one per line, cause first.\n * The file that failed is the only thing that makes this actionable, so it is\n * never summarised away.\n */\nfunction describeFailures(context: DoctorBootContext): string {\n return context.moduleFailures\n .map((failure) => ` - ${failure.file}: ${failure.message}`)\n .join(\"\\n\");\n}\n\n/**\n * Reports the route surface the app will actually serve.\n *\n * NEEDS A BOOTED APP — and now gets one. Routes exist only as the side effect of\n * importing the module that declares them, so a doctor that did not import app\n * code reported `0 routes` for an app the dev server served fourteen routes\n * for. The boot pass imports the same modules, in the same order, and boots\n * (never starts) the same connectors, so the number printed here is the number\n * `warlock dev` prints for the same project — the two are read off the same\n * router after the same registrations.\n *\n * Verdicts:\n * - a module failed to import → `fail`, naming every file and its cause. This\n * is the finding doctor exists for: a route file that throws on import is\n * invisible at runtime, it just 404s;\n * - route modules on disk but nothing registered → `fail` (they loaded and\n * registered nothing, which is not a state a working app is in);\n * - no route modules at all → `ok`, stated plainly. A worker or CLI-only app is\n * a legitimate shape and must not be nagged;\n * - otherwise → `ok` with the count, split into what app code registered and\n * what connectors added.\n */\nexport const routesCheck: DoctorCheck = {\n name: \"routes\",\n run: (context) => {\n if (context.moduleFailures.length > 0) {\n const count = context.moduleFailures.length;\n\n return {\n name: \"routes\",\n status: \"fail\",\n detail:\n `${count} app module(s) failed to load — the routes they declare will 404:\\n` +\n describeFailures(context),\n };\n }\n\n if (!context.booted) {\n return {\n name: \"routes\",\n status: \"fail\",\n detail: \"app modules could not be discovered — nothing to report on\",\n };\n }\n\n if (context.totalRoutes === 0) {\n if (context.routeModules === 0) {\n return {\n name: \"routes\",\n status: \"ok\",\n detail: \"no route modules found (src/app/*/routes.ts) — this app serves no HTTP routes\",\n };\n }\n\n return {\n name: \"routes\",\n status: \"fail\",\n detail:\n `${context.routeModules} route module(s) loaded without error but registered 0 routes — ` +\n \"every request will 404\",\n };\n }\n\n const fromConnectors = context.totalRoutes - context.appRoutes;\n const breakdown =\n fromConnectors > 0\n ? `${context.appRoutes} from ${context.routeModules} route module(s), ` +\n `${fromConnectors} from connectors`\n : `from ${context.routeModules} route module(s)`;\n\n return {\n name: \"routes\",\n status: \"ok\",\n detail: `${context.totalRoutes} registered (${breakdown})`,\n };\n },\n};\n"],"mappings":";;;;;;AAOA,SAAS,iBAAiB,SAAoC;CAC5D,OAAO,QAAQ,eACZ,KAAK,YAAY,OAAO,QAAQ,KAAK,IAAI,QAAQ,SAAS,
|
|
1
|
+
{"version":3,"file":"routes.check.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/doctor/checks/routes.check.ts"],"sourcesContent":["import type { DoctorBootContext, DoctorCheck } from \"../check.types\";\n\n/**\n * Describe the failed modules as an indented block, one per line, cause first.\n * The file that failed is the only thing that makes this actionable, so it is\n * never summarised away.\n */\nfunction describeFailures(context: DoctorBootContext): string {\n return context.moduleFailures\n .map((failure) => ` - ${failure.file}: ${failure.message}`)\n .join(\"\\n\");\n}\n\n/**\n * Reports the route surface the app will actually serve.\n *\n * NEEDS A BOOTED APP — and now gets one. Routes exist only as the side effect of\n * importing the module that declares them, so a doctor that did not import app\n * code reported `0 routes` for an app the dev server served fourteen routes\n * for. The boot pass imports the same modules, in the same order, and boots\n * (never starts) the same connectors, so the number printed here is the number\n * `warlock dev` prints for the same project — the two are read off the same\n * router after the same registrations.\n *\n * Verdicts:\n * - a module failed to import → `fail`, naming every file and its cause. This\n * is the finding doctor exists for: a route file that throws on import is\n * invisible at runtime, it just 404s;\n * - route modules on disk but nothing registered → `fail` (they loaded and\n * registered nothing, which is not a state a working app is in);\n * - no route modules at all → `ok`, stated plainly. A worker or CLI-only app is\n * a legitimate shape and must not be nagged;\n * - otherwise → `ok` with the count, split into what app code registered and\n * what connectors added.\n */\nexport const routesCheck: DoctorCheck = {\n name: \"routes\",\n run: (context) => {\n if (context.moduleFailures.length > 0) {\n const count = context.moduleFailures.length;\n\n return {\n name: \"routes\",\n status: \"fail\",\n detail:\n `${count} app module(s) failed to load — the routes they declare will 404:\\n` +\n describeFailures(context),\n };\n }\n\n if (!context.booted) {\n return {\n name: \"routes\",\n status: \"fail\",\n detail: \"app modules could not be discovered — nothing to report on\",\n };\n }\n\n if (context.totalRoutes === 0) {\n if (context.routeModules === 0) {\n return {\n name: \"routes\",\n status: \"ok\",\n detail: \"no route modules found (src/app/*/routes.ts) — this app serves no HTTP routes\",\n };\n }\n\n return {\n name: \"routes\",\n status: \"fail\",\n detail:\n `${context.routeModules} route module(s) loaded without error but registered 0 routes — ` +\n \"every request will 404\",\n };\n }\n\n const fromConnectors = context.totalRoutes - context.appRoutes;\n const breakdown =\n fromConnectors > 0\n ? `${context.appRoutes} from ${context.routeModules} route module(s), ` +\n `${fromConnectors} from connectors`\n : `from ${context.routeModules} route module(s)`;\n\n return {\n name: \"routes\",\n status: \"ok\",\n detail: `${context.totalRoutes} registered (${breakdown})`,\n };\n },\n};\n"],"mappings":";;;;;;AAOA,SAAS,iBAAiB,SAAoC;CAC5D,OAAO,QAAQ,eACZ,KAAK,YAAY,OAAO,QAAQ,KAAK,IAAI,QAAQ,SAAS,EAC1D,KAAK,IAAI;AACd;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,cAA2B;CACtC,MAAM;CACN,MAAM,YAAY;EAChB,IAAI,QAAQ,eAAe,SAAS,GAGlC,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QACE,GANU,QAAQ,eAAe,OAMxB,uEACT,iBAAiB,OAAO;EAC5B;EAGF,IAAI,CAAC,QAAQ,QACX,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QAAQ;EACV;EAGF,IAAI,QAAQ,gBAAgB,GAAG;GAC7B,IAAI,QAAQ,iBAAiB,GAC3B,OAAO;IACL,MAAM;IACN,QAAQ;IACR,QAAQ;GACV;GAGF,OAAO;IACL,MAAM;IACN,QAAQ;IACR,QACE,GAAG,QAAQ,aAAa;GAE5B;EACF;EAEA,MAAM,iBAAiB,QAAQ,cAAc,QAAQ;EACrD,MAAM,YACJ,iBAAiB,IACb,GAAG,QAAQ,UAAU,QAAQ,QAAQ,aAAa,oBAC/C,eAAe,oBAClB,QAAQ,QAAQ,aAAa;EAEnC,OAAO;GACL,MAAM;GACN,QAAQ;GACR,QAAQ,GAAG,QAAQ,YAAY,eAAe,UAAU;EAC1D;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate.command.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/generate/generate.command.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport { command } from \"../../../commands/cli-command\";\r\nimport type { CommandActionData } from \"../../../commands/types\";\r\nimport { generateController } from \"./generators/controller.generator\";\r\nimport { generateMigration } from \"./generators/migration.generator\";\r\nimport { generateModel } from \"./generators/model.generator\";\r\nimport { generateModule } from \"./generators/module.generator\";\r\nimport { generateRepository } from \"./generators/repository.generator\";\r\nimport { generateResource } from \"./generators/resource.generator\";\r\nimport { generateService } from \"./generators/service.generator\";\r\n\r\nconst generators: Record<string, (data: CommandActionData) => Promise<void>> = {\r\n module: generateModule,\r\n controller: generateController,\r\n service: generateService,\r\n model: generateModel,\r\n migration: generateMigration,\r\n repository: generateRepository,\r\n resource: generateResource,\r\n};\r\n\r\nasync function generateCommandAction(data: CommandActionData) {\r\n const commandName = data.args[0];\r\n\r\n if (!commandName) {\r\n console.log(colors.red(\"Error: Generator name is required\"));\r\n console.log(colors.yellow(\"\\nAvailable generators:\"));\r\n Object.keys(generators).forEach((cmd) => {\r\n console.log(colors.cyan(` - ${cmd}`));\r\n });\r\n console.log(colors.yellow(\"\\nUsage: warlock generate <generator> <name> [options]\"));\r\n process.exit(1);\r\n }\r\n\r\n const generator = generators[commandName];\r\n\r\n if (!generator) {\r\n console.log(colors.red(`Error: Unknown generator \"${commandName}\"`));\r\n console.log(colors.yellow(\"\\nAvailable generators:\"));\r\n Object.keys(generators).forEach((cmd) => {\r\n console.log(colors.cyan(` - ${cmd}`));\r\n });\r\n process.exit(1);\r\n }\r\n\r\n // Remove the command name from args for the generator\r\n const generatorData: CommandActionData = {\r\n ...data,\r\n args: data.args.slice(1),\r\n };\r\n\r\n await generator(generatorData);\r\n}\r\n\r\n// Master generate command\r\nexport const generateCommand = command({\r\n name: \"generate <generator> [args...]\",\r\n alias: \"g\", // Allows 'warlock g module ...'\r\n description: \"Scaffold a new component\",\r\n action: generateCommandAction,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\n// Individual commands\r\nexport const generateModuleCommand = command({\r\n name: \"generate.module <name>\",\r\n alias: \"gen.m\",\r\n description: \"Generate a new module\",\r\n action: generateModule,\r\n options: [\r\n {\r\n text: \"--minimal, -m\",\r\n description:\r\n \"Generate a minimal skeleton (routes, main, locales, empty subfolders) instead of the full CRUD scaffold\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateControllerCommand = command({\r\n name: \"generate.controller <module>/<name>\",\r\n alias: \"gen.c\",\r\n description: \"Generate a new controller\",\r\n action: generateController,\r\n options: [\r\n {\r\n text: \"--with-validation, -v\",\r\n description: \"Generate a validation schema and bind it to the controller\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateServiceCommand = command({\r\n name: \"generate.service <module>/<name>\",\r\n alias: \"gen.s\",\r\n description: \"Generate a new service\",\r\n action: generateService,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateModelCommand = command({\r\n name: \"generate.model <module>/<name>\",\r\n alias: \"gen.md\",\r\n description: \"Generate a new model with migration\",\r\n action: generateModel,\r\n options: [\r\n {\r\n text: \"--with-resource, -rs\",\r\n description: \"Generate resource\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--table <name>\",\r\n description: \"Specify table name\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--timestamps [bool]\",\r\n description: \"Include timestamps in migration (default: true)\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateRepositoryCommand = command({\r\n name: \"generate.repository <module>/<name>\",\r\n alias: \"gen.r\",\r\n description: \"Generate a new repository\",\r\n action: generateRepository,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateResourceCommand = command({\r\n name: \"generate.resource <module>/<name>\",\r\n alias: \"gen.rs\",\r\n description: \"Generate a new resource\",\r\n action: generateResource,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateMigrationCommand = command({\r\n name: \"generate.migration <model-path>\",\r\n alias: \"gen.mig\",\r\n description: \"Generate a new migration for a model\",\r\n action: generateMigration,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--add <columns>\",\r\n description: \"Columns to add (DSL: name:type:modifier,...)\",\r\n },\r\n {\r\n text: \"--drop <columns>\",\r\n description: \"Columns to drop (comma-separated names)\",\r\n },\r\n {\r\n text: \"--rename <columns>\",\r\n description: \"Columns to rename (DSL: old:new,...)\",\r\n },\r\n {\r\n text: \"--timestamps [bool]\",\r\n description: \"Include timestamps (default: true)\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,aAAyE;CAC7E,QAAQ;CACR,YAAY;CACZ,SAAS;CACT,OAAO;CACP,WAAW;CACX,YAAY;CACZ,UAAU;AACZ;AAEA,eAAe,sBAAsB,MAAyB;CAC5D,MAAM,cAAc,KAAK,KAAK;CAE9B,IAAI,CAAC,aAAa;EAChB,QAAQ,IAAI,OAAO,IAAI,mCAAmC,CAAC;EAC3D,QAAQ,IAAI,OAAO,OAAO,yBAAyB,CAAC;EACpD,OAAO,KAAK,UAAU,CAAC,CAAC,SAAS,QAAQ;GACvC,QAAQ,IAAI,OAAO,KAAK,OAAO,KAAK,CAAC;EACvC,CAAC;EACD,QAAQ,IAAI,OAAO,OAAO,wDAAwD,CAAC;EACnF,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,YAAY,WAAW;CAE7B,IAAI,CAAC,WAAW;EACd,QAAQ,IAAI,OAAO,IAAI,6BAA6B,YAAY,EAAE,CAAC;EACnE,QAAQ,IAAI,OAAO,OAAO,yBAAyB,CAAC;EACpD,OAAO,KAAK,UAAU,CAAC,CAAC,SAAS,QAAQ;GACvC,QAAQ,IAAI,OAAO,KAAK,OAAO,KAAK,CAAC;EACvC,CAAC;EACD,QAAQ,KAAK,CAAC;CAChB;CAQA,MAAM,UAAU;EAJd,GAAG;EACH,MAAM,KAAK,KAAK,MAAM,CAAC;CAGG,CAAC;AAC/B;AAGA,MAAa,kBAAkB,QAAQ;CACrC,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC;AAGD,MAAa,wBAAwB,QAAQ;CAC3C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS;EACP;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC;AAED,MAAa,4BAA4B,QAAQ;CAC/C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC;AAED,MAAa,yBAAyB,QAAQ;CAC5C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC;AAED,MAAa,uBAAuB,QAAQ;CAC1C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC;AAED,MAAa,4BAA4B,QAAQ;CAC/C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC;AAED,MAAa,0BAA0B,QAAQ;CAC7C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC;AAED,MAAa,2BAA2B,QAAQ;CAC9C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"generate.command.mjs","names":[],"sources":["../../../../../../../../../core/src/cli/commands/generate/generate.command.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport { command } from \"../../../commands/cli-command\";\r\nimport type { CommandActionData } from \"../../../commands/types\";\r\nimport { generateController } from \"./generators/controller.generator\";\r\nimport { generateMigration } from \"./generators/migration.generator\";\r\nimport { generateModel } from \"./generators/model.generator\";\r\nimport { generateModule } from \"./generators/module.generator\";\r\nimport { generateRepository } from \"./generators/repository.generator\";\r\nimport { generateResource } from \"./generators/resource.generator\";\r\nimport { generateService } from \"./generators/service.generator\";\r\n\r\nconst generators: Record<string, (data: CommandActionData) => Promise<void>> = {\r\n module: generateModule,\r\n controller: generateController,\r\n service: generateService,\r\n model: generateModel,\r\n migration: generateMigration,\r\n repository: generateRepository,\r\n resource: generateResource,\r\n};\r\n\r\nasync function generateCommandAction(data: CommandActionData) {\r\n const commandName = data.args[0];\r\n\r\n if (!commandName) {\r\n console.log(colors.red(\"Error: Generator name is required\"));\r\n console.log(colors.yellow(\"\\nAvailable generators:\"));\r\n Object.keys(generators).forEach((cmd) => {\r\n console.log(colors.cyan(` - ${cmd}`));\r\n });\r\n console.log(colors.yellow(\"\\nUsage: warlock generate <generator> <name> [options]\"));\r\n process.exit(1);\r\n }\r\n\r\n const generator = generators[commandName];\r\n\r\n if (!generator) {\r\n console.log(colors.red(`Error: Unknown generator \"${commandName}\"`));\r\n console.log(colors.yellow(\"\\nAvailable generators:\"));\r\n Object.keys(generators).forEach((cmd) => {\r\n console.log(colors.cyan(` - ${cmd}`));\r\n });\r\n process.exit(1);\r\n }\r\n\r\n // Remove the command name from args for the generator\r\n const generatorData: CommandActionData = {\r\n ...data,\r\n args: data.args.slice(1),\r\n };\r\n\r\n await generator(generatorData);\r\n}\r\n\r\n// Master generate command\r\nexport const generateCommand = command({\r\n name: \"generate <generator> [args...]\",\r\n alias: \"g\", // Allows 'warlock g module ...'\r\n description: \"Scaffold a new component\",\r\n action: generateCommandAction,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\n// Individual commands\r\nexport const generateModuleCommand = command({\r\n name: \"generate.module <name>\",\r\n alias: \"gen.m\",\r\n description: \"Generate a new module\",\r\n action: generateModule,\r\n options: [\r\n {\r\n text: \"--minimal, -m\",\r\n description:\r\n \"Generate a minimal skeleton (routes, main, locales, empty subfolders) instead of the full CRUD scaffold\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateControllerCommand = command({\r\n name: \"generate.controller <module>/<name>\",\r\n alias: \"gen.c\",\r\n description: \"Generate a new controller\",\r\n action: generateController,\r\n options: [\r\n {\r\n text: \"--with-validation, -v\",\r\n description: \"Generate a validation schema and bind it to the controller\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateServiceCommand = command({\r\n name: \"generate.service <module>/<name>\",\r\n alias: \"gen.s\",\r\n description: \"Generate a new service\",\r\n action: generateService,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateModelCommand = command({\r\n name: \"generate.model <module>/<name>\",\r\n alias: \"gen.md\",\r\n description: \"Generate a new model with migration\",\r\n action: generateModel,\r\n options: [\r\n {\r\n text: \"--with-resource, -rs\",\r\n description: \"Generate resource\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--table <name>\",\r\n description: \"Specify table name\",\r\n },\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--timestamps [bool]\",\r\n description: \"Include timestamps in migration (default: true)\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateRepositoryCommand = command({\r\n name: \"generate.repository <module>/<name>\",\r\n alias: \"gen.r\",\r\n description: \"Generate a new repository\",\r\n action: generateRepository,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateResourceCommand = command({\r\n name: \"generate.resource <module>/<name>\",\r\n alias: \"gen.rs\",\r\n description: \"Generate a new resource\",\r\n action: generateResource,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n\r\nexport const generateMigrationCommand = command({\r\n name: \"generate.migration <model-path>\",\r\n alias: \"gen.mig\",\r\n description: \"Generate a new migration for a model\",\r\n action: generateMigration,\r\n options: [\r\n {\r\n text: \"--force, -f\",\r\n description: \"Overwrite existing files\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--dry-run\",\r\n description: \"Preview the files that would be generated without writing anything\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--add <columns>\",\r\n description: \"Columns to add (DSL: name:type:modifier,...)\",\r\n },\r\n {\r\n text: \"--drop <columns>\",\r\n description: \"Columns to drop (comma-separated names)\",\r\n },\r\n {\r\n text: \"--rename <columns>\",\r\n description: \"Columns to rename (DSL: old:new,...)\",\r\n },\r\n {\r\n text: \"--timestamps [bool]\",\r\n description: \"Include timestamps (default: true)\",\r\n type: \"boolean\",\r\n },\r\n ],\r\n});\r\n"],"mappings":";;;;;;;;;;;AAWA,MAAM,aAAyE;CAC7E,QAAQ;CACR,YAAY;CACZ,SAAS;CACT,OAAO;CACP,WAAW;CACX,YAAY;CACZ,UAAU;AACZ;AAEA,eAAe,sBAAsB,MAAyB;CAC5D,MAAM,cAAc,KAAK,KAAK;CAE9B,IAAI,CAAC,aAAa;EAChB,QAAQ,IAAI,OAAO,IAAI,mCAAmC,CAAC;EAC3D,QAAQ,IAAI,OAAO,OAAO,yBAAyB,CAAC;EACpD,OAAO,KAAK,UAAU,EAAE,SAAS,QAAQ;GACvC,QAAQ,IAAI,OAAO,KAAK,OAAO,KAAK,CAAC;EACvC,CAAC;EACD,QAAQ,IAAI,OAAO,OAAO,wDAAwD,CAAC;EACnF,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,YAAY,WA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CACb,QAAQ;CACR,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC;AAED,MAAa,4BAA4B,QAAQ;CAC/C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC;AAED,MAAa,0BAA0B,QAAQ;CAC7C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC;AAED,MAAa,2BAA2B,QAAQ;CAC9C,MAAM;CACN,OAAO;CACP,aAAa;CACb,QAAQ;CACR,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;EACf;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column-dsl-parser.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/column-dsl-parser.ts"],"sourcesContent":["export type ParsedColumn = {\n name: string;\n helper: string; // e.g. \"text\", \"boolCol\", \"decimal\"\n modifiers: string[]; // e.g. [\".nullable()\", \".unsigned()\"]\n};\n\nconst typeMapping: Record<string, string> = {\n text: \"text\",\n string: \"string\",\n integer: \"integer\",\n int: \"integer\",\n bigInteger: \"bigInteger\",\n bigInt: \"bigInteger\",\n boolean: \"boolCol\",\n bool: \"boolCol\",\n uuid: \"uuid\",\n timestamp: \"timestamp\",\n date: \"date\",\n json: \"json\",\n object: \"objectCol\",\n decimal: \"decimal\",\n float: \"float\",\n enum: \"enumCol\",\n set: \"setCol\",\n blob: \"blobCol\",\n binary: \"blobCol\",\n};\n\n/**\n * Parses a subset DSL for column schemas:\n * \"phone:text:nullable,price:decimal:notNullable:unsigned\"\n */\nexport function parseColumnDsl(input: string): ParsedColumn[] {\n if (!input) return [];\n\n const columns = input.split(\",\").map((c) => c.trim()).filter(Boolean);\n \n return columns.map((colStr) => {\n const parts = colStr.split(\":\").map((p) => p.trim());\n const name = parts[0];\n const rawType = parts[1] || \"string\";\n const helper = typeMapping[rawType] || rawType; // fallback to raw string if not mapped\n\n const modifiers: string[] = [];\n for (let i = 2; i < parts.length; i++) {\n let modifier = parts[i];\n // Basic modifiers that translates to builder calls\n modifiers.push(`.${modifier}()`);\n }\n\n return {\n name,\n helper,\n modifiers,\n };\n });\n}\n"],"mappings":";AAMA,MAAM,cAAsC;CAC1C,MAAM;CACN,QAAQ;CACR,SAAS;CACT,KAAK;CACL,YAAY;CACZ,QAAQ;CACR,SAAS;CACT,MAAM;CACN,MAAM;CACN,WAAW;CACX,MAAM;CACN,MAAM;CACN,QAAQ;CACR,SAAS;CACT,OAAO;CACP,MAAM;CACN,KAAK;CACL,MAAM;CACN,QAAQ;AACV;;;;;AAMA,SAAgB,eAAe,OAA+B;CAC5D,IAAI,CAAC,OAAO,OAAO,CAAC;CAIpB,OAFgB,MAAM,MAAM,GAAG,
|
|
1
|
+
{"version":3,"file":"column-dsl-parser.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/column-dsl-parser.ts"],"sourcesContent":["export type ParsedColumn = {\n name: string;\n helper: string; // e.g. \"text\", \"boolCol\", \"decimal\"\n modifiers: string[]; // e.g. [\".nullable()\", \".unsigned()\"]\n};\n\nconst typeMapping: Record<string, string> = {\n text: \"text\",\n string: \"string\",\n integer: \"integer\",\n int: \"integer\",\n bigInteger: \"bigInteger\",\n bigInt: \"bigInteger\",\n boolean: \"boolCol\",\n bool: \"boolCol\",\n uuid: \"uuid\",\n timestamp: \"timestamp\",\n date: \"date\",\n json: \"json\",\n object: \"objectCol\",\n decimal: \"decimal\",\n float: \"float\",\n enum: \"enumCol\",\n set: \"setCol\",\n blob: \"blobCol\",\n binary: \"blobCol\",\n};\n\n/**\n * Parses a subset DSL for column schemas:\n * \"phone:text:nullable,price:decimal:notNullable:unsigned\"\n */\nexport function parseColumnDsl(input: string): ParsedColumn[] {\n if (!input) return [];\n\n const columns = input.split(\",\").map((c) => c.trim()).filter(Boolean);\n \n return columns.map((colStr) => {\n const parts = colStr.split(\":\").map((p) => p.trim());\n const name = parts[0];\n const rawType = parts[1] || \"string\";\n const helper = typeMapping[rawType] || rawType; // fallback to raw string if not mapped\n\n const modifiers: string[] = [];\n for (let i = 2; i < parts.length; i++) {\n let modifier = parts[i];\n // Basic modifiers that translates to builder calls\n modifiers.push(`.${modifier}()`);\n }\n\n return {\n name,\n helper,\n modifiers,\n };\n });\n}\n"],"mappings":";AAMA,MAAM,cAAsC;CAC1C,MAAM;CACN,QAAQ;CACR,SAAS;CACT,KAAK;CACL,YAAY;CACZ,QAAQ;CACR,SAAS;CACT,MAAM;CACN,MAAM;CACN,WAAW;CACX,MAAM;CACN,MAAM;CACN,QAAQ;CACR,SAAS;CACT,OAAO;CACP,MAAM;CACN,KAAK;CACL,MAAM;CACN,QAAQ;AACV;;;;;AAMA,SAAgB,eAAe,OAA+B;CAC5D,IAAI,CAAC,OAAO,OAAO,CAAC;CAIpB,OAFgB,MAAM,MAAM,GAAG,EAAE,KAAK,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,OAEhD,EAAE,KAAK,WAAW;EAC7B,MAAM,QAAQ,OAAO,MAAM,GAAG,EAAE,KAAK,MAAM,EAAE,KAAK,CAAC;EACnD,MAAM,OAAO,MAAM;EACnB,MAAM,UAAU,MAAM,MAAM;EAC5B,MAAM,SAAS,YAAY,YAAY;EAEvC,MAAM,YAAsB,CAAC;EAC7B,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;GACrC,IAAI,WAAW,MAAM;GAErB,UAAU,KAAK,IAAI,SAAS,GAAG;EACjC;EAEA,OAAO;GACL;GACA;GACA;EACF;CACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/migration.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport path from \"node:path\";\r\nimport { appPath } from \"../../../../utils\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport { migrationAlterStub, migrationStub } from \"../templates/stubs\";\r\nimport { parseColumnDsl } from \"./column-dsl-parser\";\r\nimport { parseName } from \"../utils/name-parser\";\r\nimport { ensureDirectoryAsync, putFileAsync, setDryRun } from \"../utils/writer\";\r\n\r\n/**\r\n * Generate a migration file for a model\r\n */\r\n/**\r\n * Create a migration file for a model\r\n */\r\nexport async function createMigrationFile(moduleName: string, entityName: string, options: any = {}) {\r\n const entity = parseName(entityName);\r\n\r\n // Generate timestamp: MM-DD-YYYY_HH-MM-SS\r\n const now = new Date();\r\n const timestamp = `${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}-${now.getFullYear()}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\r\n\r\n const migrationFileName = `${timestamp}-${entity.kebab}.migration.ts`;\r\n const migrationsPath = path.join(appPath(), moduleName, \"models\", entity.kebab, \"migrations\");\r\n\r\n // Ensure migrations directory exists\r\n await ensureDirectoryAsync(migrationsPath);\r\n\r\n const addParams = options.add as string;\r\n const dropParams = options.drop as string;\r\n const renameParams = options.rename as string;\r\n const timestamps = options.timestamps !== \"false\" && options.timestamps !== false;\r\n\r\n let migrationContent = \"\";\r\n\r\n if (addParams || dropParams || renameParams) {\r\n // Generate alter stub\r\n const parsedAdd = parseColumnDsl(addParams || \"\");\r\n const helpersSet = new Set<string>();\r\n \r\n const addLines = parsedAdd.map((col) => {\r\n helpersSet.add(col.helper);\r\n return ` ${col.name}: ${col.helper}()${col.modifiers.join(\"\")},`;\r\n });\r\n\r\n let formattedDrop: string | undefined = undefined;\r\n if (dropParams) {\r\n formattedDrop = JSON.stringify(dropParams.split(\",\").map((s) => s.trim()));\r\n }\r\n\r\n let formattedRename: string | undefined = undefined;\r\n if (renameParams) {\r\n const obj: Record<string, string> = {};\r\n renameParams.split(\",\").map((s) => s.trim()).forEach((p) => {\r\n const [oldN, newN] = p.split(\":\").map((s) => s.trim());\r\n if (oldN && newN) obj[oldN] = newN;\r\n });\r\n formattedRename = JSON.stringify(obj, null, 2).replace(/\\n/g, '\\n ');\r\n }\r\n\r\n migrationContent = migrationAlterStub(entity, {\r\n add: addLines.length > 0 ? addLines.join(\"\\n\") : undefined,\r\n drop: formattedDrop,\r\n rename: formattedRename,\r\n imports: Array.from(helpersSet),\r\n });\r\n } else {\r\n // Generate create stub\r\n migrationContent = migrationStub(entity, {\r\n timestamps,\r\n });\r\n }\r\n\r\n // Create migration file\r\n const migrationFilePath = path.join(migrationsPath, migrationFileName);\r\n await putFileAsync(migrationFilePath, migrationContent);\r\n\r\n return migrationFilePath;\r\n}\r\n\r\n/**\r\n * Generate a migration file for a model\r\n */\r\nexport async function generateMigration(data: CommandActionData) {\r\n const modelPath = data.args[0] as string;\r\n\r\n if (!modelPath) {\r\n console.log(colors.red(\"Error: Model path is required\"));\r\n console.log(colors.gray(\"Usage: warlock gen.migration <model-path>\"));\r\n console.log(colors.gray(\"Example: warlock gen.migration products/product\"));\r\n return;\r\n }\r\n\r\n // Parse model path (e.g., \"products/product\")\r\n const [moduleName, entityName] = modelPath.split(\"/\");\r\n\r\n if (!moduleName || !entityName) {\r\n console.log(colors.red(\"Error: Invalid model path format. Expected: <module>/<entity>\"));\r\n console.log(colors.gray(\"Example: warlock gen.migration products/product\"));\r\n return;\r\n }\r\n\r\n setDryRun(Boolean(data.options.dryRun));\r\n\r\n const migrationFilePath = await createMigrationFile(moduleName, entityName, data.options);\r\n\r\n console.log(\r\n colors.cyan(`\\n✨ Migration file created at: ${path.relative(appPath(), migrationFilePath)}`),\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,eAAsB,oBAAoB,YAAoB,YAAoB,UAAe,CAAC,GAAG;CACnG,MAAM,SAAS,UAAU,UAAU;CAGnC,MAAM,sBAAM,IAAI,KAAK;CAGrB,MAAM,oBAAoB,GAAG,GAFR,OAAO,IAAI,SAAS,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"migration.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/migration.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport path from \"node:path\";\r\nimport { appPath } from \"../../../../utils\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport { migrationAlterStub, migrationStub } from \"../templates/stubs\";\r\nimport { parseColumnDsl } from \"./column-dsl-parser\";\r\nimport { parseName } from \"../utils/name-parser\";\r\nimport { ensureDirectoryAsync, putFileAsync, setDryRun } from \"../utils/writer\";\r\n\r\n/**\r\n * Generate a migration file for a model\r\n */\r\n/**\r\n * Create a migration file for a model\r\n */\r\nexport async function createMigrationFile(moduleName: string, entityName: string, options: any = {}) {\r\n const entity = parseName(entityName);\r\n\r\n // Generate timestamp: MM-DD-YYYY_HH-MM-SS\r\n const now = new Date();\r\n const timestamp = `${String(now.getMonth() + 1).padStart(2, \"0\")}-${String(now.getDate()).padStart(2, \"0\")}-${now.getFullYear()}_${String(now.getHours()).padStart(2, \"0\")}-${String(now.getMinutes()).padStart(2, \"0\")}-${String(now.getSeconds()).padStart(2, \"0\")}`;\r\n\r\n const migrationFileName = `${timestamp}-${entity.kebab}.migration.ts`;\r\n const migrationsPath = path.join(appPath(), moduleName, \"models\", entity.kebab, \"migrations\");\r\n\r\n // Ensure migrations directory exists\r\n await ensureDirectoryAsync(migrationsPath);\r\n\r\n const addParams = options.add as string;\r\n const dropParams = options.drop as string;\r\n const renameParams = options.rename as string;\r\n const timestamps = options.timestamps !== \"false\" && options.timestamps !== false;\r\n\r\n let migrationContent = \"\";\r\n\r\n if (addParams || dropParams || renameParams) {\r\n // Generate alter stub\r\n const parsedAdd = parseColumnDsl(addParams || \"\");\r\n const helpersSet = new Set<string>();\r\n \r\n const addLines = parsedAdd.map((col) => {\r\n helpersSet.add(col.helper);\r\n return ` ${col.name}: ${col.helper}()${col.modifiers.join(\"\")},`;\r\n });\r\n\r\n let formattedDrop: string | undefined = undefined;\r\n if (dropParams) {\r\n formattedDrop = JSON.stringify(dropParams.split(\",\").map((s) => s.trim()));\r\n }\r\n\r\n let formattedRename: string | undefined = undefined;\r\n if (renameParams) {\r\n const obj: Record<string, string> = {};\r\n renameParams.split(\",\").map((s) => s.trim()).forEach((p) => {\r\n const [oldN, newN] = p.split(\":\").map((s) => s.trim());\r\n if (oldN && newN) obj[oldN] = newN;\r\n });\r\n formattedRename = JSON.stringify(obj, null, 2).replace(/\\n/g, '\\n ');\r\n }\r\n\r\n migrationContent = migrationAlterStub(entity, {\r\n add: addLines.length > 0 ? addLines.join(\"\\n\") : undefined,\r\n drop: formattedDrop,\r\n rename: formattedRename,\r\n imports: Array.from(helpersSet),\r\n });\r\n } else {\r\n // Generate create stub\r\n migrationContent = migrationStub(entity, {\r\n timestamps,\r\n });\r\n }\r\n\r\n // Create migration file\r\n const migrationFilePath = path.join(migrationsPath, migrationFileName);\r\n await putFileAsync(migrationFilePath, migrationContent);\r\n\r\n return migrationFilePath;\r\n}\r\n\r\n/**\r\n * Generate a migration file for a model\r\n */\r\nexport async function generateMigration(data: CommandActionData) {\r\n const modelPath = data.args[0] as string;\r\n\r\n if (!modelPath) {\r\n console.log(colors.red(\"Error: Model path is required\"));\r\n console.log(colors.gray(\"Usage: warlock gen.migration <model-path>\"));\r\n console.log(colors.gray(\"Example: warlock gen.migration products/product\"));\r\n return;\r\n }\r\n\r\n // Parse model path (e.g., \"products/product\")\r\n const [moduleName, entityName] = modelPath.split(\"/\");\r\n\r\n if (!moduleName || !entityName) {\r\n console.log(colors.red(\"Error: Invalid model path format. Expected: <module>/<entity>\"));\r\n console.log(colors.gray(\"Example: warlock gen.migration products/product\"));\r\n return;\r\n }\r\n\r\n setDryRun(Boolean(data.options.dryRun));\r\n\r\n const migrationFilePath = await createMigrationFile(moduleName, entityName, data.options);\r\n\r\n console.log(\r\n colors.cyan(`\\n✨ Migration file created at: ${path.relative(appPath(), migrationFilePath)}`),\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,eAAsB,oBAAoB,YAAoB,YAAoB,UAAe,CAAC,GAAG;CACnG,MAAM,SAAS,UAAU,UAAU;CAGnC,MAAM,sBAAM,IAAI,KAAK;CAGrB,MAAM,oBAAoB,GAAG,GAFR,OAAO,IAAI,SAAS,IAAI,CAAC,EAAE,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,IAAI,QAAQ,CAAC,EAAE,SAAS,GAAG,GAAG,EAAE,GAAG,IAAI,YAAY,EAAE,GAAG,OAAO,IAAI,SAAS,CAAC,EAAE,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,IAAI,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG,EAAE,GAAG,OAAO,IAAI,WAAW,CAAC,EAAE,SAAS,GAAG,GAAG,IAE5N,GAAG,OAAO,MAAM;CACvD,MAAM,iBAAiB,KAAK,KAAK,QAAQ,GAAG,YAAY,UAAU,OAAO,OAAO,YAAY;CAG5F,MAAM,qBAAqB,cAAc;CAEzC,MAAM,YAAY,QAAQ;CAC1B,MAAM,aAAa,QAAQ;CAC3B,MAAM,eAAe,QAAQ;CAC7B,MAAM,aAAa,QAA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AQ,IAAI,OAAO,KAAK,2CAA2C,CAAC;EACpE,QAAQ,IAAI,OAAO,KAAK,iDAAiD,CAAC;EAC1E;CACF;CAGA,MAAM,CAAC,YAAY,cAAc,UAAU,MAAM,GAAG;CAEpD,IAAI,CAAC,cAAc,CAAC,YAAY;EAC9B,QAAQ,IAAI,OAAO,IAAI,+DAA+D,CAAC;EACvF,QAAQ,IAAI,OAAO,KAAK,iDAAiD,CAAC;EAC1E;CACF;CAEA,UAAU,QAAQ,KAAK,QAAQ,MAAM,CAAC;CAEtC,MAAM,oBAAoB,MAAM,oBAAoB,YAAY,YAAY,KAAK,OAAO;CAExF,QAAQ,IACN,OAAO,KAAK,oCAAoC,KAAK,SAAS,QAAQ,GAAG,iBAAiB,GAAG,CAC/F;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/model.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport path from \"node:path\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport { migrationStub, modelStub } from \"../templates/stubs\";\r\nimport { parseModulePath, singularName } from \"../utils/name-parser\";\r\nimport { componentExists, moduleExists, resolveModulePath } from \"../utils/path-resolver\";\r\nimport { ensureDirectoryAsync, putFileAsync, setDryRun } from \"../utils/writer\";\r\n\r\nexport async function generateModel(data: CommandActionData): Promise<void> {\r\n const input = data.args[0];\r\n\r\n if (!input) {\r\n console.log(colors.red(\"Error: Model name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.model <module>/<name>\"));\r\n console.log(colors.yellow(\"Example: warlock create.model users/user\"));\r\n process.exit(1);\r\n }\r\n\r\n const { module, name: componentName } = parseModulePath(input);\r\n\r\n if (!module) {\r\n console.log(colors.red(\"Error: Module name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.model <module>/<name>\"));\r\n process.exit(1);\r\n }\r\n\r\n // Check if module exists\r\n if (!(await moduleExists(module))) {\r\n console.log(colors.red(`Error: Module \"${module}\" does not exist`));\r\n console.log(colors.yellow(`Run: warlock create.module ${module}`));\r\n process.exit(1);\r\n }\r\n\r\n const name = singularName(componentName);\r\n const force = data.options.force || data.options.f;\r\n setDryRun(Boolean(data.options.dryRun));\r\n const withResource = data.options.withResource || data.options.rs;\r\n const tableName = (data.options.table as string) || name.plural.snake;\r\n\r\n // Check if model already exists\r\n const modelDir = path.join(resolveModulePath(module), \"models\", name.kebab);\r\n const modelPath = path.join(modelDir, `${name.kebab}.model.ts`);\r\n\r\n if ((await componentExists(module, `models/${name.kebab}`, `${name.kebab}.model`)) && !force) {\r\n console.log(colors.red(`Error: Model \"${name.kebab}\" already exists`));\r\n console.log(colors.yellow(\"Use --force to overwrite\"));\r\n process.exit(1);\r\n }\r\n\r\n // Ensure directories exist\r\n await ensureDirectoryAsync(modelDir);\r\n await ensureDirectoryAsync(path.join(modelDir, \"migrations\"));\r\n\r\n // Generate model\r\n const modelContent = modelStub(name, { tableName, withResource: !!withResource });\r\n await putFileAsync(modelPath, modelContent);\r\n\r\n // Generate index.ts\r\n const indexContent = `export * from \"./${name.kebab}.model\";\r\n`;\r\n await putFileAsync(path.join(modelDir, \"index.ts\"), indexContent);\r\n\r\n // Generate migration\r\n const timestamp = new Date().toISOString().replace(/[-:T]/g, \"_\").split(\".\")[0];\r\n const migrationPath = path.join(\r\n modelDir,\r\n \"migrations\",\r\n `${timestamp}_${name.kebab}.migration.ts`,\r\n );\r\n\r\n const migrationContent = migrationStub(name, {\r\n timestamps: data.options.timestamps !== \"false\" && data.options.timestamps !== false,\r\n });\r\n\r\n await putFileAsync(migrationPath, migrationContent);\r\n\r\n console.log(colors.cyan(`\\n✨ Model \"${name.pascal}\" generated successfully!`));\r\n console.log(colors.gray(`\\nNext steps:`));\r\n console.log(colors.gray(` 1. Update model schema in ${name.kebab}.model.ts`));\r\n console.log(\r\n colors.gray(` 2. Update migration in migrations/${timestamp}_${name.kebab}.migration.ts`),\r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;EACrE,QAAQ,IAAI,OAAO,OAAO,0BAA0B,CAAC;EACrD,QAAQ,KAAK,CAAC;CAChB;CAGA,MAAM,qBAAqB,QAAQ;CACnC,MAAM,qBAAqB,KAAK,KAAK,UAAU,YAAY,CAAC;CAI5D,MAAM,aAAa,WADE,UAAU,MAAM;EAAE;EAAW,cAAc,CAAC,CAAC;CAAa,CACtC,CAAC;CAG1C,MAAM,eAAe,oBAAoB,KAAK,MAAM;;CAEpD,MAAM,aAAa,KAAK,KAAK,UAAU,UAAU,GAAG,YAAY;CAGhE,MAAM,6BAAY,IAAI,KAAK,
|
|
1
|
+
{"version":3,"file":"model.generator.mjs","names":[],"sources":["../../../../../../../../../../core/src/cli/commands/generate/generators/model.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\r\nimport path from \"node:path\";\r\nimport type { CommandActionData } from \"../../../../commands/types\";\r\nimport { migrationStub, modelStub } from \"../templates/stubs\";\r\nimport { parseModulePath, singularName } from \"../utils/name-parser\";\r\nimport { componentExists, moduleExists, resolveModulePath } from \"../utils/path-resolver\";\r\nimport { ensureDirectoryAsync, putFileAsync, setDryRun } from \"../utils/writer\";\r\n\r\nexport async function generateModel(data: CommandActionData): Promise<void> {\r\n const input = data.args[0];\r\n\r\n if (!input) {\r\n console.log(colors.red(\"Error: Model name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.model <module>/<name>\"));\r\n console.log(colors.yellow(\"Example: warlock create.model users/user\"));\r\n process.exit(1);\r\n }\r\n\r\n const { module, name: componentName } = parseModulePath(input);\r\n\r\n if (!module) {\r\n console.log(colors.red(\"Error: Module name is required\"));\r\n console.log(colors.yellow(\"Usage: warlock create.model <module>/<name>\"));\r\n process.exit(1);\r\n }\r\n\r\n // Check if module exists\r\n if (!(await moduleExists(module))) {\r\n console.log(colors.red(`Error: Module \"${module}\" does not exist`));\r\n console.log(colors.yellow(`Run: warlock create.module ${module}`));\r\n process.exit(1);\r\n }\r\n\r\n const name = singularName(componentName);\r\n const force = data.options.force || data.options.f;\r\n setDryRun(Boolean(data.options.dryRun));\r\n const withResource = data.options.withResource || data.options.rs;\r\n const tableName = (data.options.table as string) || name.plural.snake;\r\n\r\n // Check if model already exists\r\n const modelDir = path.join(resolveModulePath(module), \"models\", name.kebab);\r\n const modelPath = path.join(modelDir, `${name.kebab}.model.ts`);\r\n\r\n if ((await componentExists(module, `models/${name.kebab}`, `${name.kebab}.model`)) && !force) {\r\n console.log(colors.red(`Error: Model \"${name.kebab}\" already exists`));\r\n console.log(colors.yellow(\"Use --force to overwrite\"));\r\n process.exit(1);\r\n }\r\n\r\n // Ensure directories exist\r\n await ensureDirectoryAsync(modelDir);\r\n await ensureDirectoryAsync(path.join(modelDir, \"migrations\"));\r\n\r\n // Generate model\r\n const modelContent = modelStub(name, { tableName, withResource: !!withResource });\r\n await putFileAsync(modelPath, modelContent);\r\n\r\n // Generate index.ts\r\n const indexContent = `export * from \"./${name.kebab}.model\";\r\n`;\r\n await putFileAsync(path.join(modelDir, \"index.ts\"), indexContent);\r\n\r\n // Generate migration\r\n const timestamp = new Date().toISOString().replace(/[-:T]/g, \"_\").split(\".\")[0];\r\n const migrationPath = path.join(\r\n modelDir,\r\n \"migrations\",\r\n `${timestamp}_${name.kebab}.migration.ts`,\r\n );\r\n\r\n const migrationContent = migrationStub(name, {\r\n timestamps: data.options.timestamps !== \"false\" && data.options.timestamps !== false,\r\n });\r\n\r\n await putFileAsync(migrationPath, migrationContent);\r\n\r\n console.log(colors.cyan(`\\n✨ Model \"${name.pascal}\" generated successfully!`));\r\n console.log(colors.gray(`\\nNext steps:`));\r\n console.log(colors.gray(` 1. Update model schema in ${name.kebab}.model.ts`));\r\n console.log(\r\n colors.gray(` 2. Update migration in migrations/${timestamp}_${name.kebab}.migration.ts`),\r\n );\r\n console.log(colors.gray(` 3. Run migration: warlock migrate`));\r\n}\r\n"],"mappings":";;;;;;;;AAQA,eAAsB,cAAc,MAAwC;CAC1E,MAAM,QAAQ,KAAK,KAAK;CAExB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