@warlock.js/core 5.24.0 → 5.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -1
- package/bin/warlock.js +0 -0
- package/esm/application/application.d.mts +21 -0
- package/esm/application/application.d.mts.map +1 -1
- package/esm/application/application.mjs +29 -1
- package/esm/application/application.mjs.map +1 -1
- package/esm/application/boot-signal.d.mts +2 -1
- package/esm/application/boot-signal.d.mts.map +1 -1
- package/esm/application/boot-signal.mjs.map +1 -1
- package/esm/application/index.d.mts +1 -0
- package/esm/application/index.mjs +1 -0
- package/esm/application/roles.d.mts +72 -0
- package/esm/application/roles.d.mts.map +1 -0
- package/esm/application/roles.mjs +124 -0
- package/esm/application/roles.mjs.map +1 -0
- package/esm/cli/commands/add.command.mjs.map +1 -1
- package/esm/cli/commands/create-database.command.mjs.map +1 -1
- package/esm/cli/commands/dev-server.command.mjs.map +1 -1
- package/esm/cli/commands/doctor/boot-for-diagnostics.mjs.map +1 -1
- package/esm/cli/commands/drop-tables.command.mjs.map +1 -1
- package/esm/cli/commands/generate/utils/path-resolver.mjs.map +1 -1
- package/esm/cli/commands/migrate.command.mjs.map +1 -1
- package/esm/cli/commands/routes.command.mjs.map +1 -1
- package/esm/cli/commands/seed.command.mjs.map +1 -1
- package/esm/cli/commands/start-production.command.mjs +54 -5
- 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/storage-put.command.mjs.map +1 -1
- package/esm/cli/commands/typings-generator.command.mjs +17 -1
- package/esm/cli/commands/typings-generator.command.mjs.map +1 -1
- package/esm/cli/commands/update.command.mjs.map +1 -1
- package/esm/cli/commands-loader.mjs.map +1 -1
- package/esm/config/config-loader.d.mts.map +1 -1
- package/esm/config/config-loader.mjs +3 -1
- package/esm/config/config-loader.mjs.map +1 -1
- package/esm/connectors/connectors-manager.mjs.map +1 -1
- package/esm/connectors/database-connector.mjs.map +1 -1
- package/esm/connectors/herald-connector.mjs.map +1 -1
- package/esm/connectors/http-connector.d.mts.map +1 -1
- package/esm/connectors/http-connector.mjs +7 -0
- package/esm/connectors/http-connector.mjs.map +1 -1
- package/esm/connectors/logger-connector.mjs.map +1 -1
- package/esm/connectors/mail-connector.mjs.map +1 -1
- package/esm/connectors/types.d.mts +8 -0
- package/esm/connectors/types.d.mts.map +1 -1
- package/esm/connectors/types.mjs.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 +2 -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 +2 -1
- package/esm/database/seed-command-action.mjs.map +1 -1
- package/esm/dev-server/dependency-graph.mjs.map +1 -1
- package/esm/dev-server/development-server.mjs +2 -0
- package/esm/dev-server/development-server.mjs.map +1 -1
- package/esm/dev-server/files-orchestrator.mjs.map +1 -1
- package/esm/dev-server/layer-executor.mjs.map +1 -1
- package/esm/dev-server/manifest-manager.mjs.map +1 -1
- package/esm/dev-server/module-loader.mjs +10 -5
- package/esm/dev-server/module-loader.mjs.map +1 -1
- package/esm/dev-server/register-installed-devtools.mjs +47 -0
- package/esm/dev-server/register-installed-devtools.mjs.map +1 -0
- package/esm/dev-server/run-connector-typings.mjs +28 -0
- package/esm/dev-server/run-connector-typings.mjs.map +1 -0
- package/esm/dev-server/special-file-patterns.mjs +3 -1
- package/esm/dev-server/special-file-patterns.mjs.map +1 -1
- package/esm/dev-server/special-files-collector.d.mts +2 -2
- package/esm/dev-server/special-files-collector.d.mts.map +1 -1
- package/esm/dev-server/special-files-collector.mjs +7 -4
- package/esm/dev-server/special-files-collector.mjs.map +1 -1
- package/esm/encryption/password.mjs.map +1 -1
- package/esm/generations/add-command.action.mjs +3 -1
- package/esm/generations/add-command.action.mjs.map +1 -1
- package/esm/generations/features/access.feature.mjs.map +1 -1
- package/esm/generations/features/ai-anthropic.feature.mjs.map +1 -1
- package/esm/generations/features/ai-bedrock.feature.mjs.map +1 -1
- package/esm/generations/features/ai-google.feature.mjs.map +1 -1
- package/esm/generations/features/ai-ollama.feature.mjs.map +1 -1
- package/esm/generations/features/ai-openai.feature.mjs.map +1 -1
- package/esm/generations/features/ai-panoptic.feature.mjs.map +1 -1
- package/esm/generations/features/ai-tools.feature.mjs.map +1 -1
- package/esm/generations/features/ai-workspace.feature.mjs.map +1 -1
- package/esm/generations/features/ai.feature.mjs.map +1 -1
- package/esm/generations/features/devtools.feature.mjs +23 -0
- package/esm/generations/features/devtools.feature.mjs.map +1 -0
- package/esm/generations/features/herald.feature.mjs.map +1 -1
- package/esm/generations/features/image.feature.mjs.map +1 -1
- package/esm/generations/features/index.mjs +2 -0
- package/esm/generations/features/index.mjs.map +1 -1
- package/esm/generations/features/mail.feature.mjs.map +1 -1
- package/esm/generations/features/mongodb.feature.mjs.map +1 -1
- package/esm/generations/features/notifications.feature.mjs.map +1 -1
- package/esm/generations/features/postgres.feature.mjs.map +1 -1
- package/esm/generations/features/react-email.feature.mjs.map +1 -1
- package/esm/generations/features/react.feature.mjs.map +1 -1
- package/esm/generations/features/redis.feature.mjs.map +1 -1
- package/esm/generations/features/s3.feature.mjs.map +1 -1
- package/esm/generations/features/scheduler.feature.mjs.map +1 -1
- package/esm/generations/features/ses.feature.mjs.map +1 -1
- package/esm/generations/features/socket.feature.mjs.map +1 -1
- package/esm/generations/features/test.feature.mjs +6 -2
- package/esm/generations/features/test.feature.mjs.map +1 -1
- package/esm/generations/features/types.mjs.map +1 -1
- package/esm/generations/features/web.feature.mjs.map +1 -1
- package/esm/http/database/RequestLog.mjs.map +1 -1
- package/esm/http/index.d.mts +2 -1
- package/esm/http/index.mjs +2 -1
- package/esm/http/middleware/inject-request-context.d.mts.map +1 -1
- package/esm/http/middleware/inject-request-context.mjs +9 -1
- package/esm/http/middleware/inject-request-context.mjs.map +1 -1
- package/esm/http/response.d.mts +5 -5
- package/esm/http/response.d.mts.map +1 -1
- package/esm/http/response.mjs.map +1 -1
- package/esm/http/server-rebuilt.d.mts +20 -0
- package/esm/http/server-rebuilt.d.mts.map +1 -0
- package/esm/http/server-rebuilt.mjs +21 -0
- package/esm/http/server-rebuilt.mjs.map +1 -0
- package/esm/http/tracing/index.mjs +1 -1
- package/esm/http/tracing/tracing-dispatcher.d.mts +13 -6
- package/esm/http/tracing/tracing-dispatcher.d.mts.map +1 -1
- package/esm/http/tracing/tracing-dispatcher.mjs +46 -14
- package/esm/http/tracing/tracing-dispatcher.mjs.map +1 -1
- package/esm/http/tracing/tracing.type.d.mts +2 -1
- package/esm/http/tracing/tracing.type.d.mts.map +1 -1
- package/esm/http/types.d.mts +9 -0
- package/esm/http/types.d.mts.map +1 -1
- package/esm/image/image.mjs.map +1 -1
- package/esm/index.d.mts +4 -2
- package/esm/index.mjs +4 -2
- package/esm/loader/app-module-importer.d.mts +17 -0
- package/esm/loader/app-module-importer.d.mts.map +1 -0
- package/esm/loader/app-module-importer.mjs +20 -0
- package/esm/loader/app-module-importer.mjs.map +1 -0
- package/esm/logger/logger.mjs.map +1 -1
- package/esm/mail/events.d.mts +7 -0
- package/esm/mail/events.d.mts.map +1 -1
- package/esm/mail/events.mjs +7 -0
- package/esm/mail/events.mjs.map +1 -1
- package/esm/mail/send-mail.d.mts.map +1 -1
- package/esm/mail/send-mail.mjs +23 -2
- package/esm/mail/send-mail.mjs.map +1 -1
- package/esm/mail/types.d.mts +5 -1
- package/esm/mail/types.d.mts.map +1 -1
- package/esm/mail/types.mjs.map +1 -1
- package/esm/manifest/manifest-manager.mjs.map +1 -1
- package/esm/production/build-contributions.mjs +19 -3
- package/esm/production/build-contributions.mjs.map +1 -1
- package/esm/production/production-builder.mjs +28 -8
- package/esm/production/production-builder.mjs.map +1 -1
- package/esm/production/production-supervisor.mjs +6 -0
- package/esm/production/production-supervisor.mjs.map +1 -1
- package/esm/production/resolve-build-config.d.mts +1 -1
- package/esm/production/resolve-build-config.mjs +15 -0
- package/esm/production/resolve-build-config.mjs.map +1 -1
- package/esm/production/route-registration-child.mjs +14 -2
- package/esm/production/route-registration-child.mjs.map +1 -1
- package/esm/production/route-registration-snapshot.mjs +9 -2
- package/esm/production/route-registration-snapshot.mjs.map +1 -1
- package/esm/resource/resource-field-builder.mjs +1 -1
- package/esm/resource/resource-field-builder.mjs.map +1 -1
- package/esm/resource/resource.d.mts +5 -0
- package/esm/resource/resource.d.mts.map +1 -1
- package/esm/resource/resource.mjs +17 -6
- package/esm/resource/resource.mjs.map +1 -1
- package/esm/router/router.d.mts.map +1 -1
- package/esm/router/router.mjs +1 -0
- package/esm/router/router.mjs.map +1 -1
- package/esm/router/types.d.mts +2 -1
- package/esm/router/types.d.mts.map +1 -1
- package/esm/tests/index.d.mts +3 -2
- package/esm/tests/index.mjs +3 -2
- package/esm/tests/vitest-setup.d.mts +16 -1
- package/esm/tests/vitest-setup.d.mts.map +1 -1
- package/esm/tests/vitest-setup.mjs +20 -2
- package/esm/tests/vitest-setup.mjs.map +1 -1
- package/esm/use-cases/use-case-events.mjs.map +1 -1
- package/esm/utils/is-test-file.mjs +15 -0
- package/esm/utils/is-test-file.mjs.map +1 -0
- package/esm/utils/normalized-path.d.mts +3 -1
- package/esm/utils/normalized-path.d.mts.map +1 -1
- package/esm/utils/normalized-path.mjs +4 -2
- package/esm/utils/normalized-path.mjs.map +1 -1
- package/esm/utils/paths.mjs.map +1 -1
- package/esm/validation/plugins/database-plugin.mjs.map +1 -1
- package/esm/validation/validateAll.mjs +9 -3
- package/esm/validation/validateAll.mjs.map +1 -1
- package/esm/warlock-config/default-configurations.mjs +1 -0
- package/esm/warlock-config/default-configurations.mjs.map +1 -1
- package/esm/warlock-config/types.d.mts +7 -0
- package/esm/warlock-config/types.d.mts.map +1 -1
- package/esm/warlock-config/warlock-config.manager.mjs.map +1 -1
- package/llms-full.txt +264 -139
- package/package.json +15 -11
- package/skills/configure-app/SKILL.md +2 -0
- package/skills/define-resource/SKILL.md +4 -0
- package/skills/request-tracing/SKILL.md +38 -15
- package/skills/run-app/SKILL.md +71 -34
- package/skills/send-mail/SKILL.md +55 -25
- package/skills/test-http/SKILL.md +19 -8
- package/skills/test-service/SKILL.md +61 -40
- package/skills/warlock-conventions/SKILL.md +26 -18
- package/skills/write-cli-command/SKILL.md +50 -45
|
@@ -1 +1 @@
|
|
|
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,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AAW,aAAa,kBAAkB,KAAK,CAAC,CAAC,KAAK,cAAc,UAAU,IAAI;CAClF,WAAW,aAAa,WAAW,WAAW,QAAQ,SAAS;EAC7D,OAAO,CAAC,kBAAkB,cAAc,IAAI;CAC9C,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
|
+
{"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\";\nimport { connectorsManager } from \"../../../connectors/connectors-manager\";\nimport { registerConfiguredConnectors } from \"../../../connectors/register-configured-connectors\";\nimport { ConnectorLifecyclePhase } from \"../../../connectors/types\";\nimport { container } from \"../../../container\";\nimport { filesOrchestrator } from \"../../../dev-server/files-orchestrator\";\nimport { ModuleLoadError } from \"../../../dev-server/module-loader\";\nimport { router } from \"../../../router/router\";\nimport type { DoctorBootContext, ModuleFailure } from \"./check.types\";\n\n/**\n * @fileoverview The boot pass `warlock doctor` runs before its checks.\n *\n * THE RULE: **doctor boots, it never starts.**\n *\n * The connector contract already splits the two things doctor needs to keep\n * apart. `boot()` is where a connector REGISTERS — the HTTP connector builds a\n * Fastify instance and adds `/health` + `/ready` to it, the web connector\n * installs one route per page on the app router — and `start()` is where it\n * CONNECTS: opens the database, dials the cache, binds the port. Doctor runs\n * every `boot()` and no `start()`, so it sees the exact surface a served app\n * would have while opening no connection and binding no port.\n *\n * That seam is what makes the checks true. Before it existed here, doctor\n * preloaded config and framework bootstrap only: no app module was ever\n * imported, so no route module ever ran, so `routes` reported `0` on an app\n * `warlock dev` served 14 routes for — while `health` reported the endpoints as\n * \"registered\" from a config flag alone. Two checks, one app, contradictory\n * answers, and the wrong one was the one users acted on.\n *\n * ORDERING mirrors `DevelopmentServer.start()` exactly, because the route\n * surface is order-dependent: early connectors boot, then models (decorator\n * registries the route modules resolve against), then locales/events/mains/\n * routes, then late connectors — which is where `web` turns pages into routes.\n * Get the order wrong and the count is wrong, which is the defect this replaces.\n *\n * NOT read-only in one narrow sense: it imports the app's own modules, so\n * whatever a module does at import time happens. That is unavoidable — routes\n * only exist as the side effect of importing the file that declares them — and\n * it is the same import the dev server performs. It also refreshes\n * `.warlock/manifest.json`, the framework's own file cache. Nothing in the\n * app's data, and no network, is touched.\n */\n\n/**\n * The one connector whose `boot()` can bind a port. See {@link shouldSkipBoot}.\n */\nconst SOCKET_CONNECTOR = \"socket\";\n\n/**\n * Normalize anything thrown into a one-line message.\n */\nfunction messageOf(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\n/**\n * Whether doctor must refuse to boot this connector, and why.\n *\n * Exactly one case, and it is not a taste call: `SocketConnector.boot()` shares\n * the HTTP connector's raw server when there is one, and CREATES its own —\n * `server.listen(socketConfig.port)` — when there is not. The HTTP connector\n * boots first (lower priority number), so the shared path is what normally\n * happens; an app that configures `socket` without `http` is the exception, and\n * for that app booting socket would make a diagnostic command open a listening\n * port. Detected by asking the container what HTTP actually left behind rather\n * than by re-deriving the condition from config.\n */\nfunction shouldSkipBoot(name: string): string | undefined {\n if (name === SOCKET_CONNECTOR && !container.has(\"http.server\")) {\n return \"no http connector to share a server with — booting it would bind a port\";\n }\n\n return undefined;\n}\n\n/**\n * Boot every registered connector in one lifecycle phase, isolating failures.\n *\n * A connector that throws on boot is recorded and the loop continues: one bad\n * connector must not hide the rest of the report, and \"which connector failed\n * to boot\" is itself a finding worth printing.\n */\nasync function bootPhase(\n phase: ConnectorLifecyclePhase,\n connectors: DoctorBootContext[\"connectors\"],\n): Promise<void> {\n for (const connector of connectorsManager.list()) {\n if (connector.lifecyclePhase !== phase) continue;\n\n const skipReason = shouldSkipBoot(connector.name);\n\n if (skipReason) {\n connectors.skipped.push({ name: connector.name, reason: skipReason });\n continue;\n }\n\n try {\n await connector.boot();\n connectors.booted.push(connector.name);\n } catch (error) {\n connectors.failures.push({ name: connector.name, message: messageOf(error) });\n }\n }\n}\n\n/**\n * Import every app module the dev server imports at boot, collecting failures\n * instead of letting the first one abort the pass.\n *\n * `loadAll()` is deliberately reused rather than reimplemented: it owns the\n * canonical order (locale → event → main → route) and the `withSourceFile`\n * scoping that gives each route its origin file. It aggregates its failures and\n * throws them at the end, which is exactly the shape needed here — every module\n * is attempted, and one broken route file cannot mask another.\n */\nasync function loadAppModules(): Promise<ModuleFailure[]> {\n try {\n await filesOrchestrator.moduleLoader.loadAll();\n return [];\n } catch (error) {\n if (error instanceof AggregateError) {\n return (error.errors as unknown[]).map((failure) => {\n return failure instanceof ModuleLoadError\n ? { file: failure.file.relativePath, message: messageOf(failure.cause) }\n : { file: \"unknown\", message: messageOf(failure) };\n });\n }\n\n return [{ file: \"unknown\", message: messageOf(error) }];\n }\n}\n\n/**\n * Eagerly import model files so the decorator-driven registries the route\n * modules resolve names against are populated first — the same reason\n * `DevelopmentServer.autoDiscoverFiles()` exists, and it must keep the same\n * position in the sequence.\n */\nasync function discoverModels(): Promise<ModuleFailure[]> {\n const failures: ModuleFailure[] = [];\n\n for (const file of filesOrchestrator.files.values()) {\n if (file.type !== \"model\") continue;\n\n try {\n await filesOrchestrator.moduleLoader.loadModule(file, \"model\");\n } catch (error) {\n failures.push({\n file: file.relativePath,\n message: error instanceof ModuleLoadError ? messageOf(error.cause) : messageOf(error),\n });\n }\n }\n\n return failures;\n}\n\n/**\n * Run the boot pass and report what it found.\n *\n * Never throws. Every failure mode — a connector array the config manager\n * refuses, a connector that throws on boot, a route module that fails to\n * import — becomes a field on the returned context, which the checks turn into\n * a printed verdict. A diagnostic command that crashes while diagnosing tells\n * the user nothing.\n */\nexport async function bootForDiagnostics(): Promise<DoctorBootContext> {\n const connectors: DoctorBootContext[\"connectors\"] = {\n registered: [],\n configured: [],\n booted: [],\n skipped: [],\n failures: [],\n };\n\n const context: DoctorBootContext = {\n booted: false,\n routeModules: 0,\n appRoutes: 0,\n totalRoutes: 0,\n moduleFailures: [],\n connectors,\n };\n\n try {\n // `init()` is idempotent and the preloader already ran it; calling it again\n // costs nothing and keeps this function honest on its own.\n await filesOrchestrator.init();\n await filesOrchestrator.initializeAll();\n\n filesOrchestrator.specialFilesCollector.collect(filesOrchestrator.getFiles());\n\n context.routeModules = filesOrchestrator.specialFilesCollector.getFilesByType(\"route\").length;\n } catch (error) {\n context.moduleFailures.push({ file: \"src/\", message: messageOf(error) });\n\n return context;\n }\n\n // The app's own connectors (`warlock.config.ts > connectors`) must be\n // registered before any phase boots, exactly as the dev preloader does it —\n // otherwise doctor would report on the eleven built-ins alone and miss the\n // connector the app actually configured. This is also the call that refuses a\n // duplicate or reserved connector name, so a config that would crash the next\n // real boot is caught here instead.\n try {\n registerConfiguredConnectors();\n } catch (error) {\n connectors.registrationError = messageOf(error);\n }\n\n connectors.registered = connectorsManager.list().map((connector) => connector.name);\n connectors.configured = connectors.registered.filter((name) => {\n return !connectorsManager.isBuiltInName(name);\n });\n\n await bootPhase(ConnectorLifecyclePhase.Early, connectors);\n\n context.moduleFailures.push(...(await discoverModels()));\n context.moduleFailures.push(...(await loadAppModules()));\n\n // Snapshot BEFORE the late phase: everything the app's own route modules\n // registered. The difference between this and the total is what connectors\n // contributed (pages, for `web`), and reporting the two separately is what\n // lets a user reconcile doctor's number with the dev server's.\n context.appRoutes = router.routeCount();\n\n await bootPhase(ConnectorLifecyclePhase.Late, connectors);\n\n context.totalRoutes = router.routeCount();\n\n context.booted = true;\n\n return context;\n}\n\n/**\n * Whether the app declares an HTTP surface at all. Checks that only make sense\n * for a served app use this to opt out instead of inventing a verdict.\n */\nexport function hasHttpConfig(): boolean {\n return Boolean(config.get(\"http\"));\n}\n"],"mappings":";;;;;;;;;;;;;;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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop-tables.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/drop-tables.command.ts"],"sourcesContent":["import { dropTablesAction } from \"../../database/drop-tables-action\";\
|
|
1
|
+
{"version":3,"file":"drop-tables.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/drop-tables.command.ts"],"sourcesContent":["import { dropTablesAction } from \"../../database/drop-tables-action\";\nimport { command } from \"../../commands/cli-command\";\n\nexport const dropTablesCommand = command({\n name: \"drop.tables\",\n description: \"Drop all tables in the database\",\n action: dropTablesAction,\n preload: {\n config: [\"database\", \"log\"],\n env: true,\n connectors: [\"database\", \"logger\"],\n },\n options: [\n {\n text: \"--force, -f\",\n description: \"Drop tables without confirmation\",\n type: \"boolean\",\n },\n ],\n});\n"],"mappings":";;;;AAGA,MAAa,oBAAoB,QAAQ;CACvC,MAAM;CACN,aAAa;CACb,QAAQ;CACR,SAAS;EACP,QAAQ,CAAC,YAAY,KAAK;EAC1B,KAAK;EACL,YAAY,CAAC,YAAY,QAAQ;CACnC;CACA,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-resolver.mjs","names":["ensureDirectoryAsync"],"sources":["../../../../../../../../../../core/src/cli/commands/generate/utils/path-resolver.ts"],"sourcesContent":["import { directoryExistsAsync, fileExistsAsync } from \"@warlock.js/fs\";\
|
|
1
|
+
{"version":3,"file":"path-resolver.mjs","names":["ensureDirectoryAsync"],"sources":["../../../../../../../../../../core/src/cli/commands/generate/utils/path-resolver.ts"],"sourcesContent":["import { directoryExistsAsync, fileExistsAsync } from \"@warlock.js/fs\";\nimport path from \"node:path\";\nimport { appPath } from \"../../../../utils\";\nimport { ensureDirectoryAsync } from \"./writer\";\n\n/**\n * Resolve module path\n * Returns absolute path to module directory\n */\nexport function resolveModulePath(module: string): string {\n return appPath(module);\n}\n\n/**\n * Resolve component path within a module\n * @param module - Module name (e.g., \"users\")\n * @param type - Component type (e.g., \"controllers\", \"services\")\n * @param name - Component name (e.g., \"create-user\")\n * @param extension - File extension (default: \".ts\")\n */\nexport function resolveComponentPath(\n module: string,\n type: string,\n name: string,\n extension = \".ts\",\n): string {\n return path.join(resolveModulePath(module), type, `${name}${extension}`);\n}\n\n/**\n * Check if module exists\n *\n * A module is a DIRECTORY under the app path, so this uses\n * `directoryExistsAsync` — `fileExistsAsync` would resolve `false` for a folder\n * and wrongly gate every module-scoped generator behind \"module does not exist\".\n */\nexport async function moduleExists(module: string): Promise<boolean> {\n return await directoryExistsAsync(resolveModulePath(module));\n}\n\n/**\n * Check if file exists\n */\nexport async function componentExists(\n module: string,\n type: string,\n name: string,\n extension = \".ts\",\n): Promise<boolean> {\n return (await fileExistsAsync(resolveComponentPath(module, type, name, extension))) as boolean;\n}\n\n/**\n * Ensure directory exists, create if missing\n */\nexport async function ensureDirectory(dirPath: string): Promise<void> {\n await ensureDirectoryAsync(dirPath);\n}\n\n/**\n * Ensure component directory exists\n */\nexport async function ensureComponentDirectory(module: string, type: string): Promise<void> {\n const dirPath = path.join(resolveModulePath(module), type);\n await ensureDirectory(dirPath);\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAgB,kBAAkB,QAAwB;CACxD,OAAO,QAAQ,MAAM;AACvB;;;;;;;;AASA,SAAgB,qBACd,QACA,MACA,MACA,YAAY,OACJ;CACR,OAAO,KAAK,KAAK,kBAAkB,MAAM,GAAG,MAAM,GAAG,OAAO,WAAW;AACzE;;;;;;;;AASA,eAAsB,aAAa,QAAkC;CACnE,OAAO,MAAM,qBAAqB,kBAAkB,MAAM,CAAC;AAC7D;;;;AAKA,eAAsB,gBACpB,QACA,MACA,MACA,YAAY,OACM;CAClB,OAAQ,MAAM,gBAAgB,qBAAqB,QAAQ,MAAM,MAAM,SAAS,CAAC;AACnF;;;;AAKA,eAAsB,gBAAgB,SAAgC;CACpE,MAAMA,uBAAqB,OAAO;AACpC;;;;AAKA,eAAsB,yBAAyB,QAAgB,MAA6B;CAE1F,MAAM,gBADU,KAAK,KAAK,kBAAkB,MAAM,GAAG,IACzB,CAAC;AAC/B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/migrate.command.ts"],"sourcesContent":["import { migrateAction } from \"../../database/migrate-action\";\
|
|
1
|
+
{"version":3,"file":"migrate.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/migrate.command.ts"],"sourcesContent":["import { migrateAction } from \"../../database/migrate-action\";\nimport { command } from \"../../commands/cli-command\";\n\nexport const migrateCommand = command({\n action: migrateAction,\n name: \"migrate\",\n description: \"Run database migrations\",\n preload: {\n config: [\"database\", \"log\"],\n connectors: [\"database\", \"logger\", \"storage\"],\n },\n options: [\n {\n text: \"--fresh, -f\",\n description: \"Drop all tables and re-run migrations\",\n type: \"boolean\",\n },\n {\n text: \"--rollback, -r\",\n description: \"Rollback migrations, drop all tables\",\n type: \"boolean\",\n },\n {\n text: \"--path, -p\",\n description: \"Migration file path, if not provided, all migrations will be wroking\",\n type: \"string\",\n },\n {\n text: \"--list, -l\",\n description: \"Show migration state: executed migrations, then what will run next\",\n type: \"boolean\",\n },\n {\n text: \"--pending\",\n description:\n \"List only what will run next, in execution order. Exits 0 if nothing is pending, 1 if something is, 2 if it could not be determined\",\n type: \"boolean\",\n },\n {\n text: \"--all, -a\",\n description: \"List all migrations files in the app\",\n type: \"boolean\",\n },\n {\n text: \"--sql, -s\",\n description: \"Export all migrations as phase-ordered SQL files instead of executing them\",\n type: \"boolean\",\n },\n {\n text: \"--pending-only\",\n description: \"When used with --sql, exports only pending migrations instead of all\",\n type: \"boolean\",\n },\n {\n text: \"--compact, -c\",\n description:\n \"When used with --sql, strips out generated comments and blank lines to reduce file size\",\n type: \"boolean\",\n },\n ],\n});\n"],"mappings":";;;;AAGA,MAAa,iBAAiB,QAAQ;CACpC,QAAQ;CACR,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ,CAAC,YAAY,KAAK;EAC1B,YAAY;GAAC;GAAY;GAAU;EAAS;CAC9C;CACA,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;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/routes.command.ts"],"sourcesContent":["import { command } from \"../../commands/cli-command\";\
|
|
1
|
+
{"version":3,"file":"routes.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/routes.command.ts"],"sourcesContent":["import { command } from \"../../commands/cli-command\";\nimport { routesCommandAction } from \"./routes/routes-command.action\";\nimport { routesDiffCommandAction } from \"./routes/routes-diff.action\";\n\n/**\n * `warlock routes` — list every registered HTTP route as a table (a read-only\n * sibling of `warlock doctor`). Filter with `--method` / `--path` / `--name`,\n * or emit the normalized rows as JSON with `--json`.\n *\n * The preload is config-only and imports no route modules; the action loads them\n * through `bootForDiagnostics()`, the same loader the server uses at boot. A\n * route file that throws on import is reported on stderr instead of being\n * silently omitted from the table.\n */\nexport const routesCommand = command({\n name: \"routes\",\n description:\n \"List the registered HTTP routes as a table (read-only); filter with --method / --path / --name, or emit JSON with --json\",\n action: routesCommandAction,\n preload: {\n config: true,\n env: true,\n bootstrap: true,\n },\n options: [\n {\n text: \"--method, -m\",\n description: \"Filter by HTTP method (case-insensitive, e.g. GET, POST)\",\n type: \"string\",\n },\n {\n text: \"--path, -p\",\n description: \"Filter by a case-insensitive path substring\",\n type: \"string\",\n },\n {\n text: \"--name, -n\",\n description: \"Filter by a case-insensitive route-name substring\",\n type: \"string\",\n },\n {\n text: \"--json, -j\",\n description: \"Output the routes as JSON instead of a table\",\n type: \"boolean\",\n },\n ],\n});\n\n/** Compare live development page routes with the last successful build. */\nexport const routesDiffCommand = command({\n name: \"routes:diff\",\n description: \"Compare live page routes with the last successful production build\",\n action: routesDiffCommandAction,\n preload: {\n runtimeStrategy: \"development\",\n warlockConfig: true,\n config: true,\n env: true,\n bootstrap: true,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,gBAAgB,QAAQ;CACnC,MAAM;CACN,aACE;CACF,QAAQ;CACR,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;CACb;CACA,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;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC;;AAGD,MAAa,oBAAoB,QAAQ;CACvC,MAAM;CACN,aAAa;CACb,QAAQ;CACR,SAAS;EACP,iBAAiB;EACjB,eAAe;EACf,QAAQ;EACR,KAAK;EACL,WAAW;CACb;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/seed.command.ts"],"sourcesContent":["import { seedCommandAction } from \"../../database/seed-command-action\";\
|
|
1
|
+
{"version":3,"file":"seed.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/seed.command.ts"],"sourcesContent":["import { seedCommandAction } from \"../../database/seed-command-action\";\nimport { command } from \"../../commands/cli-command\";\n\nexport const seedCommand = command({\n action: seedCommandAction,\n name: \"seed\",\n description: \"Run database seeds\",\n preload: {\n config: true,\n env: true,\n bootstrap: true,\n connectors: [\"database\", \"cache\", \"logger\", \"storage\"],\n },\n options: [\n {\n text: \"--fresh, -f\",\n description: \"Drop all tables records and run seeds\",\n type: \"boolean\",\n },\n {\n text: \"--list, -l\",\n description: \"Display the seeds list in order without execution\",\n type: \"boolean\",\n },\n {\n text: \"--transaction, -t\",\n description: \"Run seeds in a transaction\",\n type: \"boolean\",\n defaultValue: true,\n },\n {\n text: \"--drop, -d\",\n description:\n 'Undo seeded data — delete tracked records (reverse order) and reset the seed log; scope to one seeder with --drop=\"Seed Name\"',\n type: \"string\",\n },\n ],\n});\n"],"mappings":";;;;AAGA,MAAa,cAAc,QAAQ;CACjC,QAAQ;CACR,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;EACX,YAAY;GAAC;GAAY;GAAS;GAAU;EAAS;CACvD;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACN,cAAc;EAChB;EACA;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;CACF;AACF,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertSitesRequireWebRole, parseRoles, parseSites } from "../../application/roles.mjs";
|
|
1
2
|
import { command } from "../../commands/cli-command.mjs";
|
|
2
3
|
import { resolveBuildConfig } from "../../production/resolve-build-config.mjs";
|
|
3
4
|
import { checkDistReadyToStartAsync } from "../../production/assert-dist-ready-to-start.mjs";
|
|
@@ -5,12 +6,29 @@ import { superviseProductionProcess } from "../../production/production-supervis
|
|
|
5
6
|
|
|
6
7
|
//#region ../core/src/cli/commands/start-production.command.ts
|
|
7
8
|
const NODE_FLAG_PATTERN = /^--(inspect(-brk|-wait)?(=.*)?|max-old-space-size=.*|enable-source-maps|trace-.*)$/;
|
|
9
|
+
/** `--role`/`--sites`, in both `--role=x` and `--role x` forms — recognised
|
|
10
|
+
* here so they never leak into the child's app argv (they become
|
|
11
|
+
* `WARLOCK_ROLES`/`WARLOCK_SITES` env vars instead). */
|
|
12
|
+
const ROLE_OPTION_PATTERN = /^--(role|sites)(=.*)?$/;
|
|
8
13
|
const startProductionCommand = command({
|
|
9
14
|
name: "start",
|
|
10
15
|
description: "Start production server",
|
|
11
16
|
persistent: true,
|
|
12
17
|
preload: { warlockConfig: true },
|
|
13
|
-
action: async () => {
|
|
18
|
+
action: async (data) => {
|
|
19
|
+
const roleOption = typeof data.options.role === "string" ? data.options.role : void 0;
|
|
20
|
+
const sitesOption = typeof data.options.sites === "string" ? data.options.sites : void 0;
|
|
21
|
+
let roles;
|
|
22
|
+
let sites;
|
|
23
|
+
try {
|
|
24
|
+
roles = parseRoles(roleOption);
|
|
25
|
+
sites = parseSites(sitesOption);
|
|
26
|
+
assertSitesRequireWebRole(roles, sites);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(`✖ ${error.message}`);
|
|
29
|
+
process.exit(1);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
14
32
|
const { entryPath, sourcemap, outdir } = resolveBuildConfig();
|
|
15
33
|
const readiness = await checkDistReadyToStartAsync(outdir);
|
|
16
34
|
if (!readiness.ready) {
|
|
@@ -22,13 +40,44 @@ const startProductionCommand = command({
|
|
|
22
40
|
if (sourcemap !== false) nodeArgs.push("--enable-source-maps");
|
|
23
41
|
const appArgs = [];
|
|
24
42
|
const startIndex = process.argv.findIndex((arg) => arg === "start");
|
|
25
|
-
if (startIndex !== -1 && startIndex < process.argv.length - 1)
|
|
26
|
-
|
|
43
|
+
if (startIndex !== -1 && startIndex < process.argv.length - 1) {
|
|
44
|
+
const rest = process.argv.slice(startIndex + 1);
|
|
45
|
+
for (let i = 0; i < rest.length; i++) {
|
|
46
|
+
const arg = rest[i];
|
|
47
|
+
if (NODE_FLAG_PATTERN.test(arg)) {
|
|
48
|
+
nodeArgs.push(arg);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (ROLE_OPTION_PATTERN.test(arg)) {
|
|
52
|
+
const next = rest[i + 1];
|
|
53
|
+
if (!arg.includes("=") && next !== void 0 && !next.startsWith("-")) i++;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
appArgs.push(arg);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
27
59
|
nodeArgs.push(entryPath, ...appArgs);
|
|
28
60
|
console.error(`🚀 Starting production server...\n`);
|
|
29
|
-
const
|
|
61
|
+
const env = {
|
|
62
|
+
...process.env,
|
|
63
|
+
WARLOCK_ROLES: [...roles].join(",")
|
|
64
|
+
};
|
|
65
|
+
if (sites) env.WARLOCK_SITES = [...sites].join(",");
|
|
66
|
+
const { exitCode } = await superviseProductionProcess({
|
|
67
|
+
nodeArgs,
|
|
68
|
+
env
|
|
69
|
+
});
|
|
30
70
|
process.exit(exitCode);
|
|
31
|
-
}
|
|
71
|
+
},
|
|
72
|
+
options: [{
|
|
73
|
+
text: "--role",
|
|
74
|
+
description: "Comma-separated roles to serve: api, web, worker. Defaults to every role.",
|
|
75
|
+
type: "string"
|
|
76
|
+
}, {
|
|
77
|
+
text: "--sites",
|
|
78
|
+
description: "Comma-separated site keys to install pages for. Requires --role=web.",
|
|
79
|
+
type: "string"
|
|
80
|
+
}]
|
|
32
81
|
});
|
|
33
82
|
|
|
34
83
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start-production.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/start-production.command.ts"],"sourcesContent":["import { checkDistReadyToStartAsync } from \"../../production/assert-dist-ready-to-start\";\
|
|
1
|
+
{"version":3,"file":"start-production.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/start-production.command.ts"],"sourcesContent":["import { assertSitesRequireWebRole, parseRoles, parseSites } from \"../../application/roles\";\nimport { checkDistReadyToStartAsync } from \"../../production/assert-dist-ready-to-start\";\nimport { superviseProductionProcess } from \"../../production/production-supervisor\";\nimport { resolveBuildConfig } from \"../../production/resolve-build-config\";\nimport { command } from \"../../commands/cli-command\";\n\nconst NODE_FLAG_PATTERN =\n /^--(inspect(-brk|-wait)?(=.*)?|max-old-space-size=.*|enable-source-maps|trace-.*)$/;\n\n/** `--role`/`--sites`, in both `--role=x` and `--role x` forms — recognised\n * here so they never leak into the child's app argv (they become\n * `WARLOCK_ROLES`/`WARLOCK_SITES` env vars instead). */\nconst ROLE_OPTION_PATTERN = /^--(role|sites)(=.*)?$/;\n\nexport const startProductionCommand = command({\n name: \"start\",\n description: \"Start production server\",\n persistent: true,\n preload: {\n warlockConfig: true,\n },\n action: async (data) => {\n // Validated BEFORE the dist check and the spawn: an unknown role or a\n // `--sites` without `web` is an operator mistake, and the sooner it fails\n // the less it looks like the build (or the child) is at fault.\n const roleOption = typeof data.options.role === \"string\" ? data.options.role : undefined;\n const sitesOption = typeof data.options.sites === \"string\" ? data.options.sites : undefined;\n\n let roles;\n let sites;\n\n try {\n roles = parseRoles(roleOption);\n sites = parseSites(sitesOption);\n assertSitesRequireWebRole(roles, sites);\n } catch (error) {\n console.error(`✖ ${(error as Error).message}`);\n process.exit(1);\n return;\n }\n\n const { entryPath, sourcemap, outdir } = resolveBuildConfig();\n\n // Refuse a `dist` that did not come from a successful `warlock build` —\n // named explicitly, rather than failing later and incidentally because\n // some file the server happens to need (the client manifest, say) is\n // missing. See `assert-dist-ready-to-start.ts`.\n const readiness = await checkDistReadyToStartAsync(outdir);\n\n if (!readiness.ready) {\n console.error(`✖ ${readiness.reason}`);\n process.exit(1);\n return;\n }\n\n // Build node args\n const nodeArgs: string[] = [];\n\n // Enable source maps if configured\n if (sourcemap !== false) {\n nodeArgs.push(\"--enable-source-maps\");\n }\n\n // Recognised Node flags go BEFORE the entry file; everything else is app argv.\n // process.argv = [node, cli.ts, start, ...extra]\n const appArgs: string[] = [];\n const startIndex = process.argv.findIndex((arg) => arg === \"start\");\n if (startIndex !== -1 && startIndex < process.argv.length - 1) {\n const rest = process.argv.slice(startIndex + 1);\n\n for (let i = 0; i < rest.length; i++) {\n const arg = rest[i] as string;\n\n if (NODE_FLAG_PATTERN.test(arg)) {\n nodeArgs.push(arg);\n continue;\n }\n\n // `--role`/`--sites` are framework plumbing, resolved above into\n // `WARLOCK_ROLES`/`WARLOCK_SITES` — they must not also reach the\n // child as app argv.\n if (ROLE_OPTION_PATTERN.test(arg)) {\n const next = rest[i + 1];\n\n // `--role=x` already carries its value; `--role x` consumes the\n // following token too, unless it looks like another flag.\n if (!arg.includes(\"=\") && next !== undefined && !next.startsWith(\"-\")) {\n i++;\n }\n\n continue;\n }\n\n appArgs.push(arg);\n }\n }\n\n nodeArgs.push(entryPath, ...appArgs);\n\n // Progress goes to stderr, never stdout. Stdout carries exactly one claim —\n // \"started\" — so that whatever greps it cannot mistake an intention for an\n // outcome. The banner that used to print here, in `preAction`, printed\n // before the child had even been spawned.\n console.error(`🚀 Starting production server...\\n`);\n\n const env: NodeJS.ProcessEnv = { ...process.env, WARLOCK_ROLES: [...roles].join(\",\") };\n\n if (sites) {\n env.WARLOCK_SITES = [...sites].join(\",\");\n }\n\n const { exitCode } = await superviseProductionProcess({ nodeArgs, env });\n\n process.exit(exitCode);\n },\n options: [\n {\n text: \"--role\",\n description: \"Comma-separated roles to serve: api, web, worker. Defaults to every role.\",\n type: \"string\",\n },\n {\n text: \"--sites\",\n description: \"Comma-separated site keys to install pages for. Requires --role=web.\",\n type: \"string\",\n },\n ],\n});\n"],"mappings":";;;;;;;AAMA,MAAM,oBACJ;;;;AAKF,MAAM,sBAAsB;AAE5B,MAAa,yBAAyB,QAAQ;CAC5C,MAAM;CACN,aAAa;CACb,YAAY;CACZ,SAAS,EACP,eAAe,KACjB;CACA,QAAQ,OAAO,SAAS;EAItB,MAAM,aAAa,OAAO,KAAK,QAAQ,SAAS,WAAW,KAAK,QAAQ,OAAO;EAC/E,MAAM,cAAc,OAAO,KAAK,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F,IAAI,gBAAgB,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK,GAAG;EAGzC,MAAM,EAAE,aAAa,MAAM,2BAA2B;GAAE;GAAU;EAAI,CAAC;EAEvE,QAAQ,KAAK,QAAQ;CACvB;CACA,SAAS,CACP;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;CACR,CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-put.action.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/storage-put.action.ts"],"sourcesContent":["import fs from \"fs/promises\";\
|
|
1
|
+
{"version":3,"file":"storage-put.action.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/storage-put.action.ts"],"sourcesContent":["import fs from \"fs/promises\";\nimport path from \"path\";\nimport { config } from \"../../config\";\nimport { storage } from \"../../storage\";\nimport type { CommandActionData } from \"../../commands/types\";\n\n/**\n * Action for `warlock storage.put <localPath> [destination] [--driver <name>] [--concurrency <n>]`\n *\n * Uploads a local file or directory into any configured storage driver.\n * Auto-detects whether <localPath> is a file or directory and calls the\n * appropriate storage method.\n *\n * @example\n * # Upload entire uploads directory to R2 (root of bucket)\n * warlock storage.put ./uploads --driver r2\n *\n * @example\n * # Upload to a specific destination prefix\n * warlock storage.put ./uploads backups/2026 --driver r2\n *\n * @example\n * # Single file upload with custom concurrency\n * warlock storage.put ./public/logo.png assets/logo.png --driver s3\n */\nexport async function storagePutAction({ args, options }: CommandActionData): Promise<void> {\n const [localPath, destination = \"\"] = args;\n\n if (!localPath) {\n console.error(\"✖ Missing required argument: <localPath>\");\n console.error(\" Usage: warlock storage.put <localPath> [destination] [--driver <name>]\");\n process.exit(1);\n }\n\n // Resolve to absolute path relative to CWD\n const absolutePath = path.resolve(process.cwd(), localPath);\n const driverName = options.driver as string | undefined;\n const concurrency = options.concurrency ? Number(options.concurrency) : 5;\n\n // Verify the local path exists\n let stat: Awaited<ReturnType<typeof fs.stat>>;\n try {\n stat = await fs.stat(absolutePath);\n } catch {\n console.error(`✖ Path not found: ${absolutePath}`);\n process.exit(1);\n }\n\n // Select the driver — use named driver or fall back to default\n const store = driverName ? storage.use(driverName) : storage;\n const driverLabel = driverName ?? config.get(\"storage.default\");\n\n console.log(`\\n Driver : ${driverLabel}`);\n console.log(` Source : ${absolutePath}`);\n console.log(` Dest : ${destination || \"(root)\"}\\n`);\n\n if (stat.isDirectory()) {\n // ── Directory upload ────────────────────────────────────────────────────\n const result = await store.putDirectory(absolutePath, destination, {\n concurrency,\n // Skip hidden files (e.g. .DS_Store) by default\n filter: (_, rel) => !path.basename(rel).startsWith(\".\"),\n onProgress: (done, total, file) => {\n process.stdout.write(`\\r Progress : ${done}/${total} ${file.path}`);\n },\n });\n\n // Clear the progress line and print summary\n process.stdout.write(\"\\n\");\n console.log(`\\n ✔ ${result.uploaded.length} file(s) uploaded`);\n\n if (result.failed.length > 0) {\n console.warn(`\\n ⚠ ${result.failed.length} file(s) failed:`);\n for (const { localPath: fp, error } of result.failed) {\n console.warn(` - ${fp}: ${error.message}`);\n }\n\n process.exitCode = 1;\n }\n } else {\n // ── Single file upload ──────────────────────────────────────────────────\n // Destination is used as the storage path; if empty, fall back to filename\n const storagePath = destination || path.basename(absolutePath);\n\n console.log(` Uploading : ${path.basename(absolutePath)} → ${storagePath}`);\n\n const file = await store.putFromPath(absolutePath, storagePath);\n\n console.log(`\\n ✔ Uploaded: ${file.url}`);\n }\n\n console.log();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,eAAsB,iBAAiB,EAAE,MAAM,WAA6C;CAC1F,MAAM,CAAC,WAAW,cAAc,MAAM;CAEtC,IAAI,CAAC,WAAW;EACd,QAAQ,MAAM,2CAA2C;EACzD,QAAQ,MAAM,2EAA2E;EACzF,QAAQ,KAAK,CAAC;CAChB;CAGA,MAAM,eAAe,KAAK,QAAQ,QAAQ,IAAI,GAAG,SAAS;CAC1D,MA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;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-put.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/storage-put.command.ts"],"sourcesContent":["import { command } from \"../../commands/cli-command\";\
|
|
1
|
+
{"version":3,"file":"storage-put.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/storage-put.command.ts"],"sourcesContent":["import { command } from \"../../commands/cli-command\";\nimport { storagePutAction } from \"./storage-put.action\";\n\n/**\n * `storage.put` CLI command\n *\n * Uploads a local file or directory to any configured storage driver.\n * Auto-detects file vs directory and streams each file (no full buffer in memory).\n *\n * @example\n * # Upload full uploads/ directory to R2 (migrating from local to cloud)\n * warlock storage.put ./uploads --driver r2\n *\n * @example\n * # Upload under a specific prefix\n * warlock storage.put ./uploads backups/2026 --driver r2\n *\n * @example\n * # Single file upload to default driver\n * warlock storage.put ./public/logo.png assets/logo.png\n */\nexport const storagePutCommand = command({\n name: \"storage.put <localPath> [destination]\",\n alias: \"sput\",\n action: storagePutAction,\n description: \"Upload a local file or directory to storage\",\n preload: {\n env: true,\n config: [\"storage\"],\n connectors: [\"storage\"],\n },\n options: [\n {\n text: \"--driver, -d\",\n description:\n \"Storage driver name (as defined in config). Defaults to the configured default driver.\",\n },\n {\n text: \"--concurrency, -c\",\n description: \"Number of concurrent uploads when uploading a directory\",\n type: \"number\",\n defaultValue: 5,\n },\n ],\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,oBAAoB,QAAQ;CACvC,MAAM;CACN,OAAO;CACP,QAAQ;CACR,aAAa;CACb,SAAS;EACP,KAAK;EACL,QAAQ,CAAC,SAAS;EAClB,YAAY,CAAC,SAAS;CACxB;CACA,SAAS,CACP;EACE,MAAM;EACN,aACE;CACJ,GACA;EACE,MAAM;EACN,aAAa;EACb,MAAM;EACN,cAAc;CAChB,CACF;AACF,CAAC"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { rootPath } from "../../utils/paths.mjs";
|
|
2
|
+
import "../../utils/index.mjs";
|
|
1
3
|
import { command } from "../../commands/cli-command.mjs";
|
|
4
|
+
import { warlockConfigManager } from "../../warlock-config/warlock-config.manager.mjs";
|
|
2
5
|
import { filesOrchestrator } from "../../dev-server/files-orchestrator.mjs";
|
|
6
|
+
import { collectRouteRegistrationSnapshot } from "../../production/route-registration-snapshot.mjs";
|
|
7
|
+
import { resolveBuildConfig } from "../../production/resolve-build-config.mjs";
|
|
3
8
|
import { typeGenerator } from "../../dev-server/type-generator.mjs";
|
|
9
|
+
import { runConnectorTypings } from "../../dev-server/run-connector-typings.mjs";
|
|
4
10
|
|
|
5
11
|
//#region ../core/src/cli/commands/typings-generator.command.ts
|
|
6
12
|
/**
|
|
@@ -16,6 +22,9 @@ import { typeGenerator } from "../../dev-server/type-generator.mjs";
|
|
|
16
22
|
* Not `filesOrchestrator.init()` — that also registers the ESM loader hook
|
|
17
23
|
* for dynamically importing project code, which typings generation, being
|
|
18
24
|
* purely static AST inspection, never does.
|
|
25
|
+
*
|
|
26
|
+
* Connectors then write their own typings through the `build.typings` hook
|
|
27
|
+
* (web's `web-routes.d.ts`), so a clean checkout typechecks before any build.
|
|
19
28
|
*/
|
|
20
29
|
const typingsGeneratorCommand = command({
|
|
21
30
|
name: "generate.typings",
|
|
@@ -23,7 +32,14 @@ const typingsGeneratorCommand = command({
|
|
|
23
32
|
action: async () => {
|
|
24
33
|
await filesOrchestrator.initializeAll();
|
|
25
34
|
await typeGenerator.generateAll();
|
|
26
|
-
|
|
35
|
+
await runConnectorTypings({
|
|
36
|
+
connectors: warlockConfigManager.isLoaded ? warlockConfigManager.get("connectors") ?? [] : [],
|
|
37
|
+
appRoot: rootPath(),
|
|
38
|
+
options: resolveBuildConfig,
|
|
39
|
+
collectRoutes: async () => (await collectRouteRegistrationSnapshot({ cwd: rootPath() })).routes
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
preload: { warlockConfig: true }
|
|
27
43
|
});
|
|
28
44
|
|
|
29
45
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typings-generator.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/typings-generator.command.ts"],"sourcesContent":["import { filesOrchestrator } from \"../../dev-server/files-orchestrator\";\nimport { typeGenerator } from \"../../dev-server/type-generator\";\nimport { command } from \"../../commands/cli-command\";\n\n/**\n * Standalone `warlock generate.typings`.\n *\n * Runs `filesOrchestrator.initializeAll()` before generating — the same\n * full-project discovery `warlock dev` performs at boot — so this produces\n * the identical registry from a fresh checkout instead of only whatever\n * config files a caller happened to list. A prior version added just the\n * config directory's files, which left `TranslationKeyRegistry` empty on any\n * app whose translation keys came from source outside `src/config`.\n *\n * Not `filesOrchestrator.init()` — that also registers the ESM loader hook\n * for dynamically importing project code, which typings generation, being\n * purely static AST inspection, never does.\n */\nexport const typingsGeneratorCommand = command({\n name: \"generate.typings\",\n description: \"Generate type definitions for the project\",\n action: async () => {\n await filesOrchestrator.initializeAll();\n\n await typeGenerator.generateAll();\n },\n});\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"typings-generator.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/typings-generator.command.ts"],"sourcesContent":["import { filesOrchestrator } from \"../../dev-server/files-orchestrator\";\nimport { runConnectorTypings } from \"../../dev-server/run-connector-typings\";\nimport { typeGenerator } from \"../../dev-server/type-generator\";\nimport { command } from \"../../commands/cli-command\";\nimport { collectRouteRegistrationSnapshot } from \"../../production/route-registration-snapshot\";\nimport { resolveBuildConfig } from \"../../production/resolve-build-config\";\nimport { rootPath } from \"../../utils\";\nimport { warlockConfigManager } from \"../../warlock-config/warlock-config.manager\";\n\n/**\n * Standalone `warlock generate.typings`.\n *\n * Runs `filesOrchestrator.initializeAll()` before generating — the same\n * full-project discovery `warlock dev` performs at boot — so this produces\n * the identical registry from a fresh checkout instead of only whatever\n * config files a caller happened to list. A prior version added just the\n * config directory's files, which left `TranslationKeyRegistry` empty on any\n * app whose translation keys came from source outside `src/config`.\n *\n * Not `filesOrchestrator.init()` — that also registers the ESM loader hook\n * for dynamically importing project code, which typings generation, being\n * purely static AST inspection, never does.\n *\n * Connectors then write their own typings through the `build.typings` hook\n * (web's `web-routes.d.ts`), so a clean checkout typechecks before any build.\n */\nexport const typingsGeneratorCommand = command({\n name: \"generate.typings\",\n description: \"Generate type definitions for the project\",\n action: async () => {\n await filesOrchestrator.initializeAll();\n\n await typeGenerator.generateAll();\n\n await runConnectorTypings({\n connectors: warlockConfigManager.isLoaded ? (warlockConfigManager.get(\"connectors\") ?? []) : [],\n appRoot: rootPath(),\n options: resolveBuildConfig,\n collectRoutes: async () => (await collectRouteRegistrationSnapshot({ cwd: rootPath() })).routes,\n });\n },\n preload: {\n warlockConfig: true,\n },\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,0BAA0B,QAAQ;CAC7C,MAAM;CACN,aAAa;CACb,QAAQ,YAAY;EAClB,MAAM,kBAAkB,cAAc;EAEtC,MAAM,cAAc,YAAY;EAEhC,MAAM,oBAAoB;GACxB,YAAY,qBAAqB,WAAY,qBAAqB,IAAI,YAAY,KAAK,CAAC,IAAK,CAAC;GAC9F,SAAS,SAAS;GAClB,SAAS;GACT,eAAe,aAAa,MAAM,iCAAiC,EAAE,KAAK,SAAS,EAAE,CAAC,EAAC,CAAE;EAC3F,CAAC;CACH;CACA,SAAS,EACP,eAAe,KACjB;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/update.command.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\
|
|
1
|
+
{"version":3,"file":"update.command.mjs","names":[],"sources":["../../../../../../../../core/src/cli/commands/update.command.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { updateWarlockPackages } from \"../../updater/update-warlock-packages\";\nimport { command } from \"../../commands/cli-command\";\n\nexport const updateCommand = command({\n name: \"update\",\n description: \"Update all @warlock.js packages in this project to their latest version\",\n action: async (data) => {\n // `parseCliArgs` camelCases every flag, so `--no-install` arrives as\n // `options.noInstall` (not `options[\"no-install\"]`).\n const check = Boolean(data.options.check);\n const dryRun = check || Boolean(data.options.dryRun);\n\n const result = await updateWarlockPackages({\n install: !data.options.noInstall,\n dryRun,\n });\n\n // `updateWarlockPackages` resolves on a failed install so the dev-server\n // shortcut can survive it; a one-shot CLI run must still exit non-zero.\n if (result.outcome === \"install-failed\") {\n throw result.error ?? new Error(\"Package manager install failed.\");\n }\n\n // `--check` must not pass blind: an unanswered registry is exit 2.\n if (check && result.outcome === \"registry-unreachable\") {\n process.exit(2);\n }\n\n // `--check` is a gate, so its exit code carries the answer: 0 current,\n // 1 behind, 2 registry unreachable. `--dry-run` only reports, and always succeeds.\n if (check && result.outcome === \"outdated\") {\n console.log(\n colors.dim(\"Run \") +\n colors.cyan(\"warlock update\") +\n colors.dim(\" to apply these, or --dry-run to preview without a gate.\"),\n );\n process.exit(1);\n }\n },\n options: [\n {\n text: \"--no-install\",\n description:\n \"Rewrite the @warlock.js versions in package.json without running the package manager install\",\n type: \"boolean\",\n },\n {\n text: \"--dry-run\",\n description: \"Show which packages would be updated without changing package.json\",\n type: \"boolean\",\n },\n {\n text: \"--check\",\n description:\n \"Like --dry-run, but exits 1 when any package is behind — a CI gate for staying current\",\n type: \"boolean\",\n },\n ],\n});\n"],"mappings":";;;;;AAIA,MAAa,gBAAgB,QAAQ;CACnC,MAAM;CACN,aAAa;CACb,QAAQ,OAAO,SAAS;EAGtB,MAAM,QAAQ,QAAQ,KAAK,QAAQ,KAAK;EACxC,MAAM,SAAS,SAAS,QAAQ,KAAK,QAAQ,MAAM;EAEnD,MAAM,SAAS,MAAM,sBAAsB;GACzC,SAAS,CAAC,KAAK,QAAQ;GACvB;EACF,CAAC;EAID,IAAI,OAAO,YAAY,kBACrB,MAAM,OAAO,yBAAS,IAAI,MAAM,iCAAiC;EAInE,IAAI,SAAS,OAAO,YAAY,wBAC9B,QAAQ,KAAK,CAAC;EAKhB,IAAI,SAAS,OAAO,YAAY,YAAY;GAC1C,QAAQ,IACN,OAAO,IAAI,MAAM,IACf,OAAO,KAAK,gBAAgB,IAC5B,OAAO,IAAI,0DAA0D,CACzE;GACA,QAAQ,KAAK,CAAC;EAChB;CACF;CACA,SAAS;EACP;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands-loader.mjs","names":[],"sources":["../../../../../../../core/src/cli/commands-loader.ts"],"sourcesContent":["import { filesOrchestrator } from \"../dev-server/files-orchestrator\";\
|
|
1
|
+
{"version":3,"file":"commands-loader.mjs","names":[],"sources":["../../../../../../../core/src/cli/commands-loader.ts"],"sourcesContent":["import { filesOrchestrator } from \"../dev-server/files-orchestrator\";\nimport { Path } from \"../utils/normalized-path\";\nimport { getFilesFromDirectory } from \"../dev-server/utils\";\nimport { srcPath } from \"../utils\";\nimport { CLICommand } from \"../commands/cli-command\";\nimport { isMatchingCommandName } from \"./cli-commands.utils\";\n\nexport class CLICommandsLoader {\n /**\n * Locate command by name\n */\n public async locate(commandName: string): Promise<CLICommand | undefined> {\n const files = await getFilesFromDirectory(srcPath(\"app\"), \"**/commands/*.{ts,tsx}\");\n // now convert them into relative paths\n const relativeFiles = files.map((path) => Path.toRelative(path));\n\n for (const relativeFile of relativeFiles) {\n const command = await this.load(relativeFile);\n if (command) {\n command.$relativePath(relativeFile);\n if (isMatchingCommandName(command.name, commandName)) {\n return command;\n }\n }\n }\n\n return;\n }\n\n /**\n * Scan all project commands and return them\n * Used for warm cache functionality\n */\n public async scanAll(): Promise<CLICommand[]> {\n const files = await getFilesFromDirectory(srcPath(\"app\"), \"**/commands/*.{ts,tsx}\");\n const relativeFiles = files.map((path) => Path.toRelative(path));\n const commands: CLICommand[] = [];\n\n for (const relativeFile of relativeFiles) {\n const command = await this.load(relativeFile);\n if (command) {\n command.$relativePath(relativeFile);\n commands.push(command);\n }\n }\n\n return commands;\n }\n\n /**\n * Load command from a relative path\n */\n public async load(relativePath: string): Promise<CLICommand | undefined> {\n const output = await filesOrchestrator.load<{ default: CLICommand }>(relativePath);\n\n return output?.default;\n }\n}\n\nexport const cliCommandsLoader = new CLICommandsLoader();\n"],"mappings":";;;;;;;;AAOA,IAAa,oBAAb,MAA+B;;;;CAI7B,MAAa,OAAO,aAAsD;EAGxE,MAAM,iBAAgB,MAFF,sBAAsB,QAAQ,KAAK,GAAG,wBAAwB,EAEvD,CAAC,KAAK,SAAS,KAAK,WAAW,IAAI,CAAC;EAE/D,KAAK,MAAM,gBAAgB,eAAe;GACxC,MAAM,UAAU,MAAM,KAAK,KAAK,YAAY;GAC5C,IAAI,SAAS;IACX,QAAQ,cAAc,YAAY;IAClC,IAAI,sBAAsB,QAAQ,MAAM,WAAW,GACjD,OAAO;GAEX;EACF;CAGF;;;;;CAMA,MAAa,UAAiC;EAE5C,MAAM,iBAAgB,MADF,sBAAsB,QAAQ,KAAK,GAAG,wBAAwB,EACvD,CAAC,KAAK,SAAS,KAAK,WAAW,IAAI,CAAC;EAC/D,MAAM,WAAyB,CAAC;EAEhC,KAAK,MAAM,gBAAgB,eAAe;GACxC,MAAM,UAAU,MAAM,KAAK,KAAK,YAAY;GAC5C,IAAI,SAAS;IACX,QAAQ,cAAc,YAAY;IAClC,SAAS,KAAK,OAAO;GACvB;EACF;EAEA,OAAO;CACT;;;;CAKA,MAAa,KAAK,cAAuD;EAGvE,QAAO,MAFc,kBAAkB,KAA8B,YAAY,EAEpE,EAAE;CACjB;AACF;AAEA,MAAa,oBAAoB,IAAI,kBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.d.mts","names":[],"sources":["../../../../../../../core/src/config/config-loader.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"config-loader.d.mts","names":[],"sources":["../../../../../../../core/src/config/config-loader.ts"],"mappings":";AAgBA;;;;AAAA,KAAY,oBAAA,IAAwB,WAAA,oBAA+B,OAAO"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { configSpecialHandlers } from "./config-special-handlers.mjs";
|
|
2
|
+
import { importAppModule } from "../loader/app-module-importer.mjs";
|
|
2
3
|
import { configKeyFromPath } from "./config-key-from-path.mjs";
|
|
3
4
|
import config from "@mongez/config";
|
|
4
5
|
import { colors } from "@mongez/copper";
|
|
@@ -23,7 +24,8 @@ var ConfigLoader = class {
|
|
|
23
24
|
async loadConfig(file) {
|
|
24
25
|
const configName = this.getConfigName(file.relativePath);
|
|
25
26
|
try {
|
|
26
|
-
const
|
|
27
|
+
const fileUrl = pathToFileURL(file.absolutePath).href;
|
|
28
|
+
const configValue = (await importAppModule(fileUrl)).default;
|
|
27
29
|
if (configValue === void 0) {
|
|
28
30
|
console.log(colors.red(`config error: `), `Config file ${colors.yellow(file.relativePath)} does not have a default export`);
|
|
29
31
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-loader.mjs","names":[],"sources":["../../../../../../../core/src/config/config-loader.ts"],"sourcesContent":["import config from \"@mongez/config\";\
|
|
1
|
+
{"version":3,"file":"config-loader.mjs","names":[],"sources":["../../../../../../../core/src/config/config-loader.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { colors } from \"@mongez/copper\";\nimport { pathToFileURL } from \"node:url\";\nimport type { FileManager } from \"../dev-server/file-manager\";\nimport { importAppModule } from \"../loader/app-module-importer\";\nimport { configKeyFromPath } from \"./config-key-from-path\";\nimport { configSpecialHandlers } from \"./config-special-handlers\";\n\n/**\n * Special Config Handler\n * A function that handles special configuration loading\n */\n// Returns unknown, not void: ConfigSpecialHandlers.execute() RETURNS handler(config)\n// rather than discarding it, and a test pins that (\"returns the handler's resolved\n// value\"). The implementation and the test agreed; only this type said handlers\n// produce nothing, which made any value-returning handler fail to typecheck.\nexport type SpecialConfigHandler = (configValue: any) => unknown | Promise<unknown>;\n\n/**\n * Config Loader\n * Dynamically loads all configuration files and registers them with @mongez/config\n * Supports special handlers for configs that require additional processing\n */\nexport class ConfigLoader {\n public async loadAll(configFiles: FileManager[]): Promise<void> {\n for (const file of configFiles) {\n await this.loadConfig(file);\n }\n }\n\n /**\n * Load a single configuration file.\n *\n * The ESM loader hook stamps a version token onto the URL so that each HMR\n * cycle gets a fresh module — no manual cache-busting needed here.\n */\n public async loadConfig(file: FileManager): Promise<void> {\n const configName = this.getConfigName(file.relativePath);\n\n try {\n const fileUrl = pathToFileURL(file.absolutePath).href;\n const configModule = await importAppModule(fileUrl);\n const configValue = configModule.default;\n\n if (configValue === undefined) {\n console.log(\n colors.red(`config error: `),\n `Config file ${colors.yellow(file.relativePath)} does not have a default export`,\n );\n return;\n }\n\n config.set(configName, configValue);\n await configSpecialHandlers.execute(configName, configValue);\n } catch (error) {\n throw error;\n }\n }\n\n public async reloadConfig(file: FileManager): Promise<void> {\n await this.loadConfig(file);\n }\n\n private getConfigName(relativePath: string): string {\n const configName = configKeyFromPath(relativePath);\n\n if (!configName) {\n throw new Error(`Invalid config file path: ${relativePath}`);\n }\n\n return configName;\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAuBA,IAAa,eAAb,MAA0B;CACxB,MAAa,QAAQ,aAA2C;EAC9D,KAAK,MAAM,QAAQ,aACjB,MAAM,KAAK,WAAW,IAAI;CAE9B;;;;;;;CAQA,MAAa,WAAW,MAAkC;EACxD,MAAM,aAAa,KAAK,cAAc,KAAK,YAAY;EAEvD,IAAI;GACF,MAAM,UAAU,cAAc,KAAK,YAAY,CAAC,CAAC;GAEjD,MAAM,eAAc,MADO,gBAAgB,OAAO,EAClB,CAAC;GAEjC,IAAI,gBAAgB,QAAW;IAC7B,QAAQ,IACN,OAAO,IAAI,gBAAgB,GAC3B,eAAe,OAAO,OAAO,KAAK,YAAY,EAAE,gCAClD;IACA;GACF;GAEA,OAAO,IAAI,YAAY,WAAW;GAClC,MAAM,sBAAsB,QAAQ,YAAY,WAAW;EAC7D,SAAS,OAAO;GACd,MAAM;EACR;CACF;CAEA,MAAa,aAAa,MAAkC;EAC1D,MAAM,KAAK,WAAW,IAAI;CAC5B;CAEA,AAAQ,cAAc,cAA8B;EAClD,MAAM,aAAa,kBAAkB,YAAY;EAEjD,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,6BAA6B,cAAc;EAG7D,OAAO;CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectors-manager.mjs","names":[],"sources":["../../../../../../../core/src/connectors/connectors-manager.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { Application } from \"../application\";\r\nimport { log } from \"@warlock.js/logger\";\r\nimport { AccessConnector } from \"./access-connector\";\r\nimport { AiConnector } from \"./ai-connector\";\r\nimport { CacheConnector } from \"./cache-connector\";\r\nimport { DatabaseConnector } from \"./database-connector\";\r\nimport { HeraldConnector } from \"./herald-connector\";\r\nimport { HttpConnector } from \"./http-connector\";\r\nimport { LoggerConnector } from \"./logger-connector\";\r\nimport { MailerConnector } from \"./mail-connector\";\r\nimport { NotificationsConnector } from \"./notifications-connector\";\r\nimport { SocketConnector } from \"./socket-connector\";\r\nimport { StorageConnector } from \"./storage.connector\";\r\nimport { ConnectorLifecyclePhase } from \"./types\";\r\nimport type { Connector, ConnectorName } from \"./types\";\r\n\r\n/**\r\n * Overall shutdown budget in ms. Override via `app.shutdownTimeout`.\r\n */\r\nconst DEFAULT_SHUTDOWN_TIMEOUT = 10_000;\r\n\r\nexport class ConnectorsManager {\r\n /**\r\n * Connectors list\r\n */\r\n private readonly connectors: Connector[] = [];\r\n\r\n /**\r\n * The names the framework's own connectors hold.\r\n *\r\n * Filled by the constructor's own registration calls rather than declared\r\n * beside them, so there is exactly ONE place a built-in name exists: the\r\n * connector that owns it. A second list — in the builder, in a config\r\n * validator, in a test double — is a list that drifts the moment a built-in\r\n * is added or renamed, and it drifts silently, because nothing compares the\r\n * two. Both halves of a connector's life read this one through\r\n * {@link isBuiltInName}: the build refuses a `connectors` array that claims\r\n * a built-in name, and so does registration.\r\n */\r\n private readonly builtInNames = new Set<string>();\r\n\r\n /**\r\n * Constructor\r\n */\r\n public constructor() {\r\n this.registerBuiltIn(new LoggerConnector());\r\n this.registerBuiltIn(new MailerConnector());\r\n this.registerBuiltIn(new HttpConnector());\r\n this.registerBuiltIn(new DatabaseConnector());\r\n this.registerBuiltIn(new HeraldConnector());\r\n this.registerBuiltIn(new CacheConnector());\r\n this.registerBuiltIn(new StorageConnector());\r\n this.registerBuiltIn(new SocketConnector());\r\n this.registerBuiltIn(new NotificationsConnector());\r\n this.registerBuiltIn(new AccessConnector());\r\n this.registerBuiltIn(new AiConnector());\r\n }\r\n\r\n /**\r\n * Register a framework-owned connector and reserve its name.\r\n *\r\n * Private on purpose: an app connector must not be able to reserve a name,\r\n * and the set is only correct if every entry in it came from a connector\r\n * this class constructed itself.\r\n */\r\n private registerBuiltIn(...connectors: Connector[]): void {\r\n for (const connector of connectors) {\r\n this.builtInNames.add(connector.name);\r\n }\r\n\r\n this.register(...connectors);\r\n }\r\n\r\n /**\r\n * Whether the given name belongs to a framework built-in connector.\r\n *\r\n * Reserved, not merely taken: a configured connector carrying one of these\r\n * names would be skipped by {@link has} at boot while the build had already\r\n * drained its contribution, so the artifact would carry a connector the\r\n * server never runs. Callers refuse the name instead of skipping it.\r\n */\r\n public isBuiltInName(name: string): boolean {\r\n return this.builtInNames.has(name);\r\n }\r\n\r\n /**\r\n * Register a connector\r\n */\r\n public register(...connectors: Connector[]): void {\r\n this.connectors.push(...connectors);\r\n // sort connectors by priority\r\n this.connectors.sort((a, b) => a.priority - b.priority);\r\n }\r\n\r\n /**\r\n * Get all connectors\r\n */\r\n public list(): Connector[] {\r\n return this.connectors;\r\n }\r\n\r\n /**\r\n * Whether a connector with the given name is already registered.\r\n *\r\n * Names are the identity of a connector here, which is what lets a caller\r\n * that may run more than once per process register idempotently instead of\r\n * stacking duplicates that would each boot and shut down.\r\n */\r\n public has(name: ConnectorName): boolean {\r\n return this.connectors.some((connector) => connector.name === name);\r\n }\r\n\r\n /**\r\n * start all connectors\r\n */\r\n public async start(connectorsNames?: ConnectorName[]): Promise<void> {\r\n const connectorsList = connectorsNames\r\n ? this.connectors.filter((connector) => connectorsNames.includes(connector.name))\r\n : this.connectors;\r\n\r\n for (const connector of connectorsList) {\r\n await connector.boot();\r\n }\r\n\r\n for (const connector of connectorsList) {\r\n await connector.start();\r\n }\r\n }\r\n\r\n /**\r\n * Start all connectors in the given lifecycle phase.\r\n *\r\n * The production builder and dev preload split startup around app\r\n * code: early phase before app imports, late phase after. Within a\r\n * phase, all connectors `boot()` first, then all `start()`, so\r\n * cross-connector wiring inside the phase still works (e.g. socket\r\n * reads http's instance during its own boot).\r\n */\r\n public async startPhase(phase: ConnectorLifecyclePhase): Promise<void> {\r\n const phaseConnectors = this.connectors.filter(\r\n (connector) => connector.lifecyclePhase === phase,\r\n );\r\n\r\n for (const connector of phaseConnectors) {\r\n await connector.boot();\r\n }\r\n\r\n for (const connector of phaseConnectors) {\r\n await connector.start();\r\n }\r\n }\r\n\r\n /**\r\n * Start all connectors except the given ones\r\n */\r\n public async startWithout(excludedConnectors: ConnectorName[]): Promise<void> {\r\n await this.start(\r\n this.connectors\r\n .filter((connector) => !excludedConnectors.includes(connector.name))\r\n .map((connector) => connector.name),\r\n );\r\n }\r\n\r\n /**\r\n * Shutdown all connectors\r\n */\r\n public async shutdown(): Promise<void> {\r\n // App-owned teardown runs first, while every connector (db, cache, http) is\r\n // still up, so cleanup hooks can use them. Idempotent + error-isolated.\r\n await Application.runShutdownHooks();\r\n\r\n // HTTP stops accepting and drains in-flight requests FIRST, while storage,\r\n // socket, etc. are still up; then the rest go in reverse priority. Copy the\r\n // list first — `reverse()` mutates in place, so reversing the live array\r\n // would corrupt the order on a second shutdown pass.\r\n const reversed = [...this.connectors].reverse();\r\n const ordered = [\r\n ...reversed.filter((connector) => connector.name === \"http\"),\r\n ...reversed.filter((connector) => connector.name !== \"http\"),\r\n ];\r\n\r\n const timeout = config.get(\"app.shutdownTimeout\", DEFAULT_SHUTDOWN_TIMEOUT);\r\n let current: string | undefined;\r\n\r\n const timer = setTimeout(() => {\r\n // Sync write: the process exits right after, so an async log would be lost.\r\n console.error(\r\n `Shutdown timed out after ${timeout}ms; connector still shutting down: ${current ?? \"none\"}`,\r\n );\r\n process.exit(1);\r\n }, timeout);\r\n timer.unref?.();\r\n\r\n try {\r\n for (const connector of ordered) {\r\n current = connector.name;\r\n await this.shutdownOne(connector);\r\n }\r\n current = undefined;\r\n } finally {\r\n clearTimeout(timer);\r\n }\r\n\r\n // `Logger.log()` hands each entry to `channel.log()` without awaiting it, so\r\n // awaiting the calls above is not enough on its own — a buffered or async\r\n // channel (file, Sentry) still loses the entry when the process exits.\r\n await log.flush();\r\n }\r\n\r\n /**\r\n * Shut one connector down, isolating and reporting its failure.\r\n */\r\n private async shutdownOne(connector: Connector): Promise<void> {\r\n try {\r\n await connector.shutdown();\r\n } catch (error) {\r\n try {\r\n // Awaited deliberately: the caller (`shutdownOnProcessKill`) calls\r\n // `process.exit(0)` as soon as this resolves, so an un-awaited log is\r\n // a log that never happens.\r\n await log.error(\"connectors\", \"shutdown\", error as Error, { connector: connector.name });\r\n } catch {\r\n // Reporting a failure must never become a worse failure than the one\r\n // being reported: a channel that throws synchronously rejects this call\r\n // INSIDE the catch, which would abort the remaining teardown. Swallowed\r\n // rather than re-reported: the only channel we could report it through\r\n // is the one that just threw.\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Shutdown connectors on process kill\r\n *\r\n * Registers signal handlers that run an idempotent graceful shutdown:\r\n * - SIGINT: Ctrl+C on Unix, also caught on Windows but unreliable in child processes\r\n * - SIGTERM: Termination signal (Unix primarily)\r\n * - SIGHUP: registered on Windows (`win32`) only, to catch Ctrl+C / console close\r\n *\r\n * Note: no `beforeExit` handler is registered — `beforeExit` cannot reliably\r\n * await async teardown (the process exits once the callback returns), so\r\n * shutdown is driven entirely by the signal handlers above.\r\n */\r\n public shutdownOnProcessKill(): void {\r\n let isShuttingDown = false;\r\n\r\n const gracefulShutdown = async (signal: string) => {\r\n if (isShuttingDown) return;\r\n isShuttingDown = true;\r\n\r\n console.log(`\\nExiting...`);\r\n await this.shutdown();\r\n process.exit(0);\r\n };\r\n\r\n // Unix signals\r\n process.on(\"SIGINT\", () => gracefulShutdown(\"SIGINT\"));\r\n process.on(\"SIGTERM\", () => gracefulShutdown(\"SIGTERM\"));\r\n\r\n // Windows-specific: handle when process is about to exit\r\n // This is more reliable on Windows for spawned child processes\r\n if (process.platform === \"win32\") {\r\n // Handle Ctrl+C on Windows specifically\r\n process.on(\"SIGHUP\", () => gracefulShutdown(\"SIGHUP\"));\r\n }\r\n }\r\n}\r\n\r\nexport const connectorsManager = new ConnectorsManager();\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,2BAA2B;AAEjC,IAAa,oBAAb,MAA+B;;;;CAuB7B,AAAO,cAAc;oBAnBsB,CAAC;sCAcZ,IAAI,IAAY;EAM9C,KAAK,gBAAgB,IAAI,gBAAgB,CAAC;EAC1C,KAAK,gBAAgB,IAAI,gBAAgB,CAAC;EAC1C,KAAK,gBAAgB,IAAI,cAAc,CAAC;EACxC,KAAK,gBAAgB,IAAI,kBAAkB,CAAC;EAC5C,KAAK,gBAAgB,IAAI,gBAAgB,CAAC;EAC1C,KAAK,gBAAgB,IAAI,eAAe,CAAC;EACzC,KAAK,gBAAgB,IAAI,iBAAiB,CAAC;EAC3C,KAAK,gBAAgB,IAAI,gBAAgB,CAAC;EAC1C,KAAK,gBAAgB,IAAI,uBAAuB,CAAC;EACjD,KAAK,gBAAgB,IAAI,gBAAgB,CAAC;EAC1C,KAAK,gBAAgB,IAAI,YAAY,CAAC;CACxC;;;;;;;;CASA,AAAQ,gBAAgB,GAAG,YAA+B;EACxD,KAA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GAC3D,GAAG,SAAS,QAAQ,cAAc,UAAU,SAAS,MAAM,CAC7D;EAEA,MAAM,UAAU,OAAO,IAAI,uBAAuB,wBAAwB;EAC1E,IAAI;EAEJ,MAAM,QAAQ,iBAAiB;GAE7B,QAAQ,MACN,4BAA4B,QAAQ,qCAAqC,WAAW,QACtF;GACA,QAAQ,KAAK,CAAC;EAChB,GAAG,OAAO;EACV,MAAM,QAAQ;EAEd,IAAI;GACF,KAAK,MAAM,aAAa,SAAS;IAC/B,UAAU,UAAU;IACpB,MAAM,KAAK,YAAY,SAAS;GAClC;GACA,UAAU;EACZ,UAAU;GACR,aAAa,KAAK;EACpB;EAKA,MAAM,IAAI,MAAM;CAClB;;;;CAKA,MAAc,YAAY,WAAqC;EAC7D,IAAI;GACF,MAAM,UAAU,SAAS;EAC3B,SAAS,OAAO;GACd,IAAI;IAIF,MAAM,IAAI,MAAM,cAAc,YAAY,OAAgB,EAAE,WAAW,UAAU,KAAK,CAAC;GACzF,QAAQ,CAMR;EACF;CACF;;;;;;;;;;;;;CAcA,AAAO,wBAA8B;EACnC,IAAI,iBAAiB;EAErB,MAAM,mBAAmB,OAAO,WAAmB;GACjD,IAAI,gBAAgB;GACpB,iBAAiB;GAEjB,QAAQ,IAAI,cAAc;GAC1B,MAAM,KAAK,SAAS;GACpB,QAAQ,KAAK,CAAC;EAChB;EAGA,QAAQ,GAAG,gBAAgB,iBAAiB,QAAQ,CAAC;EACrD,QAAQ,GAAG,iBAAiB,iBAAiB,SAAS,CAAC;EAIvD,IAAI,QAAQ,aAAa,SAEvB,QAAQ,GAAG,gBAAgB,iBAAiB,QAAQ,CAAC;CAEzD;AACF;AAEA,MAAa,oBAAoB,IAAI,kBAAkB"}
|
|
1
|
+
{"version":3,"file":"connectors-manager.mjs","names":[],"sources":["../../../../../../../core/src/connectors/connectors-manager.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { Application } from \"../application\";\nimport { log } from \"@warlock.js/logger\";\nimport { AccessConnector } from \"./access-connector\";\nimport { AiConnector } from \"./ai-connector\";\nimport { CacheConnector } from \"./cache-connector\";\nimport { DatabaseConnector } from \"./database-connector\";\nimport { HeraldConnector } from \"./herald-connector\";\nimport { HttpConnector } from \"./http-connector\";\nimport { LoggerConnector } from \"./logger-connector\";\nimport { MailerConnector } from \"./mail-connector\";\nimport { NotificationsConnector } from \"./notifications-connector\";\nimport { SocketConnector } from \"./socket-connector\";\nimport { StorageConnector } from \"./storage.connector\";\nimport { ConnectorLifecyclePhase } from \"./types\";\nimport type { Connector, ConnectorName } from \"./types\";\n\n/**\n * Overall shutdown budget in ms. Override via `app.shutdownTimeout`.\n */\nconst DEFAULT_SHUTDOWN_TIMEOUT = 10_000;\n\nexport class ConnectorsManager {\n /**\n * Connectors list\n */\n private readonly connectors: Connector[] = [];\n\n /**\n * The names the framework's own connectors hold.\n *\n * Filled by the constructor's own registration calls rather than declared\n * beside them, so there is exactly ONE place a built-in name exists: the\n * connector that owns it. A second list — in the builder, in a config\n * validator, in a test double — is a list that drifts the moment a built-in\n * is added or renamed, and it drifts silently, because nothing compares the\n * two. Both halves of a connector's life read this one through\n * {@link isBuiltInName}: the build refuses a `connectors` array that claims\n * a built-in name, and so does registration.\n */\n private readonly builtInNames = new Set<string>();\n\n /**\n * Constructor\n */\n public constructor() {\n this.registerBuiltIn(new LoggerConnector());\n this.registerBuiltIn(new MailerConnector());\n this.registerBuiltIn(new HttpConnector());\n this.registerBuiltIn(new DatabaseConnector());\n this.registerBuiltIn(new HeraldConnector());\n this.registerBuiltIn(new CacheConnector());\n this.registerBuiltIn(new StorageConnector());\n this.registerBuiltIn(new SocketConnector());\n this.registerBuiltIn(new NotificationsConnector());\n this.registerBuiltIn(new AccessConnector());\n this.registerBuiltIn(new AiConnector());\n }\n\n /**\n * Register a framework-owned connector and reserve its name.\n *\n * Private on purpose: an app connector must not be able to reserve a name,\n * and the set is only correct if every entry in it came from a connector\n * this class constructed itself.\n */\n private registerBuiltIn(...connectors: Connector[]): void {\n for (const connector of connectors) {\n this.builtInNames.add(connector.name);\n }\n\n this.register(...connectors);\n }\n\n /**\n * Whether the given name belongs to a framework built-in connector.\n *\n * Reserved, not merely taken: a configured connector carrying one of these\n * names would be skipped by {@link has} at boot while the build had already\n * drained its contribution, so the artifact would carry a connector the\n * server never runs. Callers refuse the name instead of skipping it.\n */\n public isBuiltInName(name: string): boolean {\n return this.builtInNames.has(name);\n }\n\n /**\n * Register a connector\n */\n public register(...connectors: Connector[]): void {\n this.connectors.push(...connectors);\n // sort connectors by priority\n this.connectors.sort((a, b) => a.priority - b.priority);\n }\n\n /**\n * Get all connectors\n */\n public list(): Connector[] {\n return this.connectors;\n }\n\n /**\n * Whether a connector with the given name is already registered.\n *\n * Names are the identity of a connector here, which is what lets a caller\n * that may run more than once per process register idempotently instead of\n * stacking duplicates that would each boot and shut down.\n */\n public has(name: ConnectorName): boolean {\n return this.connectors.some((connector) => connector.name === name);\n }\n\n /**\n * start all connectors\n */\n public async start(connectorsNames?: ConnectorName[]): Promise<void> {\n const connectorsList = connectorsNames\n ? this.connectors.filter((connector) => connectorsNames.includes(connector.name))\n : this.connectors;\n\n for (const connector of connectorsList) {\n await connector.boot();\n }\n\n for (const connector of connectorsList) {\n await connector.start();\n }\n }\n\n /**\n * Start all connectors in the given lifecycle phase.\n *\n * The production builder and dev preload split startup around app\n * code: early phase before app imports, late phase after. Within a\n * phase, all connectors `boot()` first, then all `start()`, so\n * cross-connector wiring inside the phase still works (e.g. socket\n * reads http's instance during its own boot).\n */\n public async startPhase(phase: ConnectorLifecyclePhase): Promise<void> {\n const phaseConnectors = this.connectors.filter(\n (connector) => connector.lifecyclePhase === phase,\n );\n\n for (const connector of phaseConnectors) {\n await connector.boot();\n }\n\n for (const connector of phaseConnectors) {\n await connector.start();\n }\n }\n\n /**\n * Start all connectors except the given ones\n */\n public async startWithout(excludedConnectors: ConnectorName[]): Promise<void> {\n await this.start(\n this.connectors\n .filter((connector) => !excludedConnectors.includes(connector.name))\n .map((connector) => connector.name),\n );\n }\n\n /**\n * Shutdown all connectors\n */\n public async shutdown(): Promise<void> {\n // App-owned teardown runs first, while every connector (db, cache, http) is\n // still up, so cleanup hooks can use them. Idempotent + error-isolated.\n await Application.runShutdownHooks();\n\n // HTTP stops accepting and drains in-flight requests FIRST, while storage,\n // socket, etc. are still up; then the rest go in reverse priority. Copy the\n // list first — `reverse()` mutates in place, so reversing the live array\n // would corrupt the order on a second shutdown pass.\n const reversed = [...this.connectors].reverse();\n const ordered = [\n ...reversed.filter((connector) => connector.name === \"http\"),\n ...reversed.filter((connector) => connector.name !== \"http\"),\n ];\n\n const timeout = config.get(\"app.shutdownTimeout\", DEFAULT_SHUTDOWN_TIMEOUT);\n let current: string | undefined;\n\n const timer = setTimeout(() => {\n // Sync write: the process exits right after, so an async log would be lost.\n console.error(\n `Shutdown timed out after ${timeout}ms; connector still shutting down: ${current ?? \"none\"}`,\n );\n process.exit(1);\n }, timeout);\n timer.unref?.();\n\n try {\n for (const connector of ordered) {\n current = connector.name;\n await this.shutdownOne(connector);\n }\n current = undefined;\n } finally {\n clearTimeout(timer);\n }\n\n // `Logger.log()` hands each entry to `channel.log()` without awaiting it, so\n // awaiting the calls above is not enough on its own — a buffered or async\n // channel (file, Sentry) still loses the entry when the process exits.\n await log.flush();\n }\n\n /**\n * Shut one connector down, isolating and reporting its failure.\n */\n private async shutdownOne(connector: Connector): Promise<void> {\n try {\n await connector.shutdown();\n } catch (error) {\n try {\n // Awaited deliberately: the caller (`shutdownOnProcessKill`) calls\n // `process.exit(0)` as soon as this resolves, so an un-awaited log is\n // a log that never happens.\n await log.error(\"connectors\", \"shutdown\", error as Error, { connector: connector.name });\n } catch {\n // Reporting a failure must never become a worse failure than the one\n // being reported: a channel that throws synchronously rejects this call\n // INSIDE the catch, which would abort the remaining teardown. Swallowed\n // rather than re-reported: the only channel we could report it through\n // is the one that just threw.\n }\n }\n }\n\n /**\n * Shutdown connectors on process kill\n *\n * Registers signal handlers that run an idempotent graceful shutdown:\n * - SIGINT: Ctrl+C on Unix, also caught on Windows but unreliable in child processes\n * - SIGTERM: Termination signal (Unix primarily)\n * - SIGHUP: registered on Windows (`win32`) only, to catch Ctrl+C / console close\n *\n * Note: no `beforeExit` handler is registered — `beforeExit` cannot reliably\n * await async teardown (the process exits once the callback returns), so\n * shutdown is driven entirely by the signal handlers above.\n */\n public shutdownOnProcessKill(): void {\n let isShuttingDown = false;\n\n const gracefulShutdown = async (signal: string) => {\n if (isShuttingDown) return;\n isShuttingDown = true;\n\n console.log(`\\nExiting...`);\n await this.shutdown();\n process.exit(0);\n };\n\n // Unix signals\n process.on(\"SIGINT\", () => gracefulShutdown(\"SIGINT\"));\n process.on(\"SIGTERM\", () => gracefulShutdown(\"SIGTERM\"));\n\n // Windows-specific: handle when process is about to exit\n // This is more reliable on Windows for spawned child processes\n if (process.platform === \"win32\") {\n // Handle Ctrl+C on Windows specifically\n process.on(\"SIGHUP\", () => gracefulShutdown(\"SIGHUP\"));\n }\n }\n}\n\nexport const connectorsManager = new ConnectorsManager();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,2BAA2B;AAEjC,IAAa,oBAAb,MAA+B;;;;CAuB7B,AAAO,cAAc;oBAnBsB,CAAC;sCAcZ,IAAI,IAAY;EAM9C,KAAK,gBAAgB,IAAI,gBAAgB,CAAC;EAC1C,KAAK,gBAAgB,IAAI,gBAAgB,CAAC;EAC1C,KAAK,gBAAgB,IAAI,cAAc,CAAC;EACxC,KAAK,gBAAgB,IAAI,kBAAkB,CAAC;EAC5C,KAAK,gBAAgB,IAAI,gBAAgB,CAAC;EAC1C,KAAK,gBAAgB,IAAI,eAAe,CAAC;EACzC,KAAK,gBAAgB,IAAI,iBAAiB,CAAC;EAC3C,KAAK,gBAAgB,IAAI,gBAAgB,CAAC;EAC1C,KAAK,gBAAgB,IAAI,uBAAuB,CAAC;EACjD,KAAK,gBAAgB,IAAI,gBAAgB,CAAC;EAC1C,KAAK,gBAAgB,IAAI,YAAY,C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import config from \"@mongez/config\";\
|
|
1
|
+
{"version":3,"file":"database-connector.mjs","names":[],"sources":["../../../../../../../core/src/connectors/database-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { connectToDatabase, dataSourceRegistry } from \"@warlock.js/cascade\";\nimport { container } from \"../container\";\nimport { BaseConnector } from \"./base-connector\";\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\n\n/**\n * Database Connector\n * Manages database connection lifecycle using @warlock.js/cascade\n */\nexport class DatabaseConnector extends BaseConnector {\n public readonly name = \"database\";\n public readonly priority = ConnectorPriority.DATABASE;\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\n\n /**\n * Files that trigger database restart\n */\n protected readonly watchedFiles = [\"src/config/database.ts\", \"src/config/database.tsx\"];\n\n /**\n * Initialize database connection\n */\n public async start(): Promise<void> {\n const databaseConfig = config.get(\"database\");\n\n if (!databaseConfig) {\n return;\n }\n\n try {\n const source = await connectToDatabase(databaseConfig);\n container.set(\"database.source\", source);\n this.active = true;\n } catch (error) {\n console.error(\"Failed to connect to database:\", error);\n throw error;\n }\n }\n\n /**\n * Shutdown database connection\n */\n public async shutdown(): Promise<void> {\n if (!this.active) {\n return;\n }\n\n try {\n // Disconnect all registered data sources\n const dataSources = dataSourceRegistry.getAllDataSources();\n\n for (const dataSource of dataSources) {\n if (dataSource.driver.isConnected) {\n await dataSource.driver.disconnect();\n }\n }\n\n this.active = false;\n } catch (error) {\n console.error(\"Failed to disconnect from database:\", error);\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,IAAa,oBAAb,cAAuC,cAAc;;;cAC5B;;;sBAOW,CAAC,0BAA0B,yBAAyB;;;;;CAKtF,MAAa,QAAuB;EAClC,MAAM,iBAAiB,OAAO,IAAI,UAAU;EAE5C,IAAI,CAAC,gBACH;EAGF,IAAI;GACF,MAAM,SAAS,MAAM,kBAAkB,cAAc;GACrD,UAAU,IAAI,mBAAmB,MAAM;GACvC,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,QAAQ,MAAM,kCAAkC,KAAK;GACrD,MAAM;EACR;CACF;;;;CAKA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAGF,IAAI;GAEF,MAAM,cAAc,mBAAmB,kBAAkB;GAEzD,KAAK,MAAM,cAAc,aACvB,IAAI,WAAW,OAAO,aACpB,MAAM,WAAW,OAAO,WAAW;GAIvC,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,QAAQ,MAAM,uCAAuC,KAAK;GAC1D,MAAM;EACR;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"herald-connector.mjs","names":[],"sources":["../../../../../../../core/src/connectors/herald-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\
|
|
1
|
+
{"version":3,"file":"herald-connector.mjs","names":[],"sources":["../../../../../../../core/src/connectors/herald-connector.ts"],"sourcesContent":["import config from \"@mongez/config\";\nimport { log } from \"@warlock.js/logger\";\nimport { BaseConnector } from \"./base-connector\";\nimport { ConnectorLifecyclePhase, ConnectorPriority } from \"./types\";\n\n/**\n * Herald Connector\n * Manages message broker connection lifecycle using @warlock.js/herald\n */\nexport class HeraldConnector extends BaseConnector {\n public readonly name = \"herald\";\n public readonly priority = ConnectorPriority.COMMUNICATOR;\n public readonly lifecyclePhase = ConnectorLifecyclePhase.Early;\n\n /**\n * Files that trigger herald restart\n */\n protected readonly watchedFiles = [\"src/config/herald.ts\"];\n\n /**\n * Initialize broker connection\n */\n public async start(): Promise<void> {\n const heraldConfig = config.get(\"herald\");\n\n if (!heraldConfig) {\n return;\n }\n\n try {\n const { connectToBroker } = await import(\"@warlock.js/herald\");\n\n log.info(`herald.${heraldConfig.driver}`, \"connection\", \"Connecting to message broker\");\n await connectToBroker(heraldConfig);\n log.success(`herald.${heraldConfig.driver}`, \"connection\", \"Connected to message broker\");\n this.active = true;\n } catch (error) {\n // Boot-time broker connection failure is unrecoverable — `fatal` makes\n // \"page on fatal only\" alerting clean, aligned with the cascade and\n // cache drivers. Disconnect failures (shutdown path) stay at error.\n log.fatal(\n `herald.${heraldConfig.driver}`,\n \"connection\",\n \"Failed to connect to message broker\",\n );\n throw error;\n }\n }\n\n /**\n * Shutdown broker connection\n */\n public async shutdown(): Promise<void> {\n if (!this.active) {\n return;\n }\n\n try {\n const { brokerRegistry } = await import(\"@warlock.js/herald\");\n\n // Disconnect all registered brokers\n const brokers = brokerRegistry.getAll();\n\n for (const broker of brokers) {\n if (broker.driver.isConnected) {\n await broker.driver.disconnect();\n }\n }\n\n // Clear the registry for clean restart\n brokerRegistry.clear();\n\n this.active = false;\n } catch (error) {\n log.error(\"herald\", \"shutdown\", \"Failed to disconnect from message broker\");\n throw error;\n }\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,kBAAb,cAAqC,cAAc;;;cAC1B;;;sBAOW,CAAC,sBAAsB;;;;;CAKzD,MAAa,QAAuB;EAClC,MAAM,eAAe,OAAO,IAAI,QAAQ;EAExC,IAAI,CAAC,cACH;EAGF,IAAI;GACF,MAAM,EAAE,oBAAoB,MAAM,OAAO;GAEzC,IAAI,KAAK,UAAU,aAAa,UAAU,cAAc,8BAA8B;GACtF,MAAM,gBAAgB,YAAY;GAClC,IAAI,QAAQ,UAAU,aAAa,UAAU,cAAc,6BAA6B;GACxF,KAAK,SAAS;EAChB,SAAS,OAAO;GAId,IAAI,MACF,UAAU,aAAa,UACvB,cACA,qCACF;GACA,MAAM;EACR;CACF;;;;CAKA,MAAa,WAA0B;EACrC,IAAI,CAAC,KAAK,QACR;EAGF,IAAI;GACF,MAAM,EAAE,mBAAmB,MAAM,OAAO;GAGxC,MAAM,UAAU,eAAe,OAAO;GAEtC,KAAK,MAAM,UAAU,SACnB,IAAI,OAAO,OAAO,aAChB,MAAM,OAAO,OAAO,WAAW;GAKnC,eAAe,MAAM;GAErB,KAAK,SAAS;EAChB,SAAS,OAAO;GACd,IAAI,MAAM,UAAU,YAAY,0CAA0C;GAC1E,MAAM;EACR;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-connector.d.mts","names":[],"sources":["../../../../../../../core/src/connectors/http-connector.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"http-connector.d.mts","names":[],"sources":["../../../../../../../core/src/connectors/http-connector.ts"],"mappings":";;;;;;;AAiDA;;cAAa,aAAA,SAAsB,aAAA;EAAA,SACjB,IAAA;EAAA,SACA,QAAA,GAAQ,iBAAA,CAAA,IAAA;EAAA,SACR,cAAA,GAAc,uBAAA,CAAA,IAAA;EAwCb;;;;;EAAA,mBAjCE,YAAA;EAV2B;;;EAAA,UAepC,IAAA,GAAO,eAAA;EAbO;;;;;;;;;;;;;;;;;EAAA,cAgCV,iBAAA;EAwRP;;;AAAoC;;EA/Q9B,IAAA,IAAI,OAAA;;;;;;;;UAmCT,oBAAA;;;;;;EAgCK,KAAA,IAAS,OAAA;;;;;;EAkKT,OAAA,IAAW,OAAA;;;;EAcX,QAAA,IAAY,OAAA;;;;;;EA4BlB,aAAA,CAAc,YAAA;AAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { setBaseUrl } from "../utils/urls.mjs";
|
|
2
2
|
import { container } from "../container/index.mjs";
|
|
3
|
+
import { getRoles, servesHttp } from "../application/roles.mjs";
|
|
3
4
|
import { Application } from "../application/application.mjs";
|
|
4
5
|
import { router } from "../router/router.mjs";
|
|
5
6
|
import { registerHttpPlugins } from "../http/plugins.mjs";
|
|
@@ -9,6 +10,7 @@ import { health } from "../http/health.mjs";
|
|
|
9
10
|
import { assertPortIsAvailable } from "../http/port-preflight.mjs";
|
|
10
11
|
import { isCanonicalPortValue, resolveBindPort } from "../http/resolve-bind-port.mjs";
|
|
11
12
|
import { setHttpReadyReport } from "../http/ready-report.mjs";
|
|
13
|
+
import { notifyHttpServerRebuilt } from "../http/server-rebuilt.mjs";
|
|
12
14
|
import { ConnectorLifecyclePhase, ConnectorPriority } from "./types.mjs";
|
|
13
15
|
import { BaseConnector } from "./base-connector.mjs";
|
|
14
16
|
import { ensureFatalIsVisible } from "../logger/fatal-visibility.mjs";
|
|
@@ -110,6 +112,10 @@ var HttpConnector = class extends BaseConnector {
|
|
|
110
112
|
async start() {
|
|
111
113
|
const httpConfig = config.get("http");
|
|
112
114
|
if (!httpConfig || !this.http) return;
|
|
115
|
+
if (!servesHttp()) {
|
|
116
|
+
log.info("http", "connection", `http: not started (role: ${[...getRoles()].join(", ")})`);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
113
119
|
const deferToReadyBlock = this.rendersReadyBlock;
|
|
114
120
|
if (Application.runtimeStrategy === "development") router.scanDevServer(this.http);
|
|
115
121
|
else router.scan(this.http);
|
|
@@ -156,6 +162,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
156
162
|
async restart() {
|
|
157
163
|
await this.shutdown();
|
|
158
164
|
await this.boot();
|
|
165
|
+
if (this.http) notifyHttpServerRebuilt(this.http);
|
|
159
166
|
await this.start();
|
|
160
167
|
}
|
|
161
168
|
/**
|