@celljs/cli 3.8.0 → 4.0.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/README.md +442 -1
- package/agent/guide.md +39 -0
- package/bin/cell.js +2 -0
- package/lib/agent/agent-guide.d.ts +39 -0
- package/lib/agent/agent-guide.d.ts.map +1 -0
- package/lib/agent/agent-guide.js +67 -0
- package/lib/agent/agent-guide.js.map +1 -0
- package/lib/build/executable-compiler.d.ts +44 -0
- package/lib/build/executable-compiler.d.ts.map +1 -0
- package/lib/build/executable-compiler.js +145 -0
- package/lib/build/executable-compiler.js.map +1 -0
- package/lib/build/executable-compiler.spec.d.ts +2 -0
- package/lib/build/executable-compiler.spec.d.ts.map +1 -0
- package/lib/build/executable-compiler.spec.js +71 -0
- package/lib/build/executable-compiler.spec.js.map +1 -0
- package/lib/build/single-compile.spec.d.ts +2 -0
- package/lib/build/single-compile.spec.d.ts.map +1 -0
- package/lib/build/single-compile.spec.js +135 -0
- package/lib/build/single-compile.spec.js.map +1 -0
- package/lib/check/project-checker.d.ts +85 -0
- package/lib/check/project-checker.d.ts.map +1 -0
- package/lib/check/project-checker.js +332 -0
- package/lib/check/project-checker.js.map +1 -0
- package/lib/check/project-checker.spec.d.ts +2 -0
- package/lib/check/project-checker.spec.d.ts.map +1 -0
- package/lib/check/project-checker.spec.js +147 -0
- package/lib/check/project-checker.spec.js.map +1 -0
- package/lib/cli/agent-command.d.ts +15 -0
- package/lib/cli/agent-command.d.ts.map +1 -0
- package/lib/cli/agent-command.js +42 -0
- package/lib/cli/agent-command.js.map +1 -0
- package/lib/cli/build-command.d.ts +84 -0
- package/lib/cli/build-command.d.ts.map +1 -0
- package/lib/cli/build-command.js +170 -0
- package/lib/cli/build-command.js.map +1 -0
- package/lib/cli/cell-cli.d.ts +35 -0
- package/lib/cli/cell-cli.d.ts.map +1 -0
- package/lib/cli/cell-cli.js +159 -0
- package/lib/cli/cell-cli.js.map +1 -0
- package/lib/cli/cell-cli.spec.d.ts +2 -0
- package/lib/cli/cell-cli.spec.d.ts.map +1 -0
- package/lib/cli/cell-cli.spec.js +195 -0
- package/lib/cli/cell-cli.spec.js.map +1 -0
- package/lib/cli/check-command.d.ts +31 -0
- package/lib/cli/check-command.d.ts.map +1 -0
- package/lib/cli/check-command.js +67 -0
- package/lib/cli/check-command.js.map +1 -0
- package/lib/cli/command.d.ts +24 -0
- package/lib/cli/command.d.ts.map +1 -0
- package/lib/cli/command.js +10 -0
- package/lib/cli/command.js.map +1 -0
- package/lib/cli/config-command.d.ts +29 -0
- package/lib/cli/config-command.d.ts.map +1 -0
- package/lib/cli/config-command.js +71 -0
- package/lib/cli/config-command.js.map +1 -0
- package/lib/cli/config-command.spec.d.ts +2 -0
- package/lib/cli/config-command.spec.d.ts.map +1 -0
- package/lib/cli/config-command.spec.js +79 -0
- package/lib/cli/config-command.spec.js.map +1 -0
- package/lib/cli/deploy-command.d.ts +41 -0
- package/lib/cli/deploy-command.d.ts.map +1 -0
- package/lib/cli/deploy-command.js +114 -0
- package/lib/cli/deploy-command.js.map +1 -0
- package/lib/cli/dev-command.d.ts +47 -0
- package/lib/cli/dev-command.d.ts.map +1 -0
- package/lib/cli/dev-command.js +219 -0
- package/lib/cli/dev-command.js.map +1 -0
- package/lib/cli/dev-command.spec.d.ts +2 -0
- package/lib/cli/dev-command.spec.d.ts.map +1 -0
- package/lib/cli/dev-command.spec.js +149 -0
- package/lib/cli/dev-command.spec.js.map +1 -0
- package/lib/cli/docs-command.d.ts +19 -0
- package/lib/cli/docs-command.d.ts.map +1 -0
- package/lib/cli/docs-command.js +47 -0
- package/lib/cli/docs-command.js.map +1 -0
- package/lib/cli/info-command.d.ts +44 -0
- package/lib/cli/info-command.d.ts.map +1 -0
- package/lib/cli/info-command.js +39 -0
- package/lib/cli/info-command.js.map +1 -0
- package/lib/cli/info-command.spec.d.ts +2 -0
- package/lib/cli/info-command.spec.d.ts.map +1 -0
- package/lib/cli/info-command.spec.js +236 -0
- package/lib/cli/info-command.spec.js.map +1 -0
- package/lib/cli/init-command.d.ts +20 -0
- package/lib/cli/init-command.d.ts.map +1 -0
- package/lib/cli/init-command.js +43 -0
- package/lib/cli/init-command.js.map +1 -0
- package/lib/cli/main.d.ts +2 -0
- package/lib/cli/main.d.ts.map +1 -0
- package/lib/cli/main.js +3 -0
- package/lib/cli/main.js.map +1 -0
- package/lib/cli/mcp-command.d.ts +34 -0
- package/lib/cli/mcp-command.d.ts.map +1 -0
- package/lib/cli/mcp-command.js +85 -0
- package/lib/cli/mcp-command.js.map +1 -0
- package/lib/cli/mcp-command.spec.d.ts +2 -0
- package/lib/cli/mcp-command.spec.d.ts.map +1 -0
- package/lib/cli/mcp-command.spec.js +132 -0
- package/lib/cli/mcp-command.spec.js.map +1 -0
- package/lib/cli/preview-command.d.ts +24 -0
- package/lib/cli/preview-command.d.ts.map +1 -0
- package/lib/cli/preview-command.js +91 -0
- package/lib/cli/preview-command.js.map +1 -0
- package/lib/cli/reporter.d.ts +26 -0
- package/lib/cli/reporter.d.ts.map +1 -0
- package/lib/cli/reporter.js +58 -0
- package/lib/cli/reporter.js.map +1 -0
- package/lib/config/config-build.spec.d.ts +2 -0
- package/lib/config/config-build.spec.d.ts.map +1 -0
- package/lib/config/config-build.spec.js +111 -0
- package/lib/config/config-build.spec.js.map +1 -0
- package/lib/config/config-explainer.d.ts +48 -0
- package/lib/config/config-explainer.d.ts.map +1 -0
- package/lib/config/config-explainer.js +130 -0
- package/lib/config/config-explainer.js.map +1 -0
- package/lib/config/config-file-loader.d.ts +22 -0
- package/lib/config/config-file-loader.d.ts.map +1 -0
- package/lib/config/config-file-loader.js +63 -0
- package/lib/config/config-file-loader.js.map +1 -0
- package/lib/config/config-resolver.d.ts +111 -0
- package/lib/config/config-resolver.d.ts.map +1 -0
- package/lib/config/config-resolver.js +215 -0
- package/lib/config/config-resolver.js.map +1 -0
- package/lib/config/config-resolver.spec.d.ts +2 -0
- package/lib/config/config-resolver.spec.d.ts.map +1 -0
- package/lib/config/config-resolver.spec.js +159 -0
- package/lib/config/config-resolver.spec.js.map +1 -0
- package/lib/config/config-validator.d.ts +35 -0
- package/lib/config/config-validator.d.ts.map +1 -0
- package/lib/config/config-validator.js +160 -0
- package/lib/config/config-validator.js.map +1 -0
- package/lib/config/config-validator.spec.d.ts +2 -0
- package/lib/config/config-validator.spec.d.ts.map +1 -0
- package/lib/config/config-validator.spec.js +77 -0
- package/lib/config/config-validator.spec.js.map +1 -0
- package/lib/config/define-config.d.ts +4 -0
- package/lib/config/define-config.d.ts.map +1 -0
- package/lib/config/define-config.js +5 -0
- package/lib/config/define-config.js.map +1 -0
- package/lib/config/types.d.ts +53 -0
- package/lib/config/types.d.ts.map +1 -0
- package/lib/config/types.js +2 -0
- package/lib/config/types.js.map +1 -0
- package/lib/deploy/cloud-api.d.ts +58 -0
- package/lib/deploy/cloud-api.d.ts.map +1 -0
- package/lib/deploy/cloud-api.js +189 -0
- package/lib/deploy/cloud-api.js.map +1 -0
- package/lib/deploy/code-package.d.ts +15 -0
- package/lib/deploy/code-package.d.ts.map +1 -0
- package/lib/deploy/code-package.js +40 -0
- package/lib/deploy/code-package.js.map +1 -0
- package/lib/deploy/deploy-utils.spec.d.ts +2 -0
- package/lib/deploy/deploy-utils.spec.d.ts.map +1 -0
- package/lib/deploy/deploy-utils.spec.js +56 -0
- package/lib/deploy/deploy-utils.spec.js.map +1 -0
- package/lib/deploy/deployer-registry.d.ts +11 -0
- package/lib/deploy/deployer-registry.d.ts.map +1 -0
- package/lib/deploy/deployer-registry.js +40 -0
- package/lib/deploy/deployer-registry.js.map +1 -0
- package/lib/deploy/request-signer.d.ts +51 -0
- package/lib/deploy/request-signer.d.ts.map +1 -0
- package/lib/deploy/request-signer.js +109 -0
- package/lib/deploy/request-signer.js.map +1 -0
- package/lib/deploy/zip-writer.d.ts +32 -0
- package/lib/deploy/zip-writer.d.ts.map +1 -0
- package/lib/deploy/zip-writer.js +114 -0
- package/lib/deploy/zip-writer.js.map +1 -0
- package/lib/docs/docs-index.d.ts +54 -0
- package/lib/docs/docs-index.d.ts.map +1 -0
- package/lib/docs/docs-index.js +140 -0
- package/lib/docs/docs-index.js.map +1 -0
- package/lib/docs/docs-index.spec.d.ts +2 -0
- package/lib/docs/docs-index.spec.d.ts.map +1 -0
- package/lib/docs/docs-index.spec.js +52 -0
- package/lib/docs/docs-index.spec.js.map +1 -0
- package/lib/events/event-bus.d.ts +30 -0
- package/lib/events/event-bus.d.ts.map +1 -0
- package/lib/events/event-bus.js +81 -0
- package/lib/events/event-bus.js.map +1 -0
- package/lib/events/event-bus.spec.d.ts +2 -0
- package/lib/events/event-bus.spec.d.ts.map +1 -0
- package/lib/events/event-bus.spec.js +69 -0
- package/lib/events/event-bus.spec.js.map +1 -0
- package/lib/events/hook-runner.d.ts +27 -0
- package/lib/events/hook-runner.d.ts.map +1 -0
- package/lib/events/hook-runner.js +65 -0
- package/lib/events/hook-runner.js.map +1 -0
- package/lib/events/hook-runner.spec.d.ts +2 -0
- package/lib/events/hook-runner.spec.d.ts.map +1 -0
- package/lib/events/hook-runner.spec.js +36 -0
- package/lib/events/hook-runner.spec.js.map +1 -0
- package/lib/index.d.ts +57 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +57 -2
- package/lib/index.js.map +1 -1
- package/lib/info/project-inspector.d.ts +143 -0
- package/lib/info/project-inspector.d.ts.map +1 -0
- package/lib/info/project-inspector.js +244 -0
- package/lib/info/project-inspector.js.map +1 -0
- package/lib/init/project-initializer.d.ts +44 -0
- package/lib/init/project-initializer.d.ts.map +1 -0
- package/lib/init/project-initializer.js +90 -0
- package/lib/init/project-initializer.js.map +1 -0
- package/lib/init/project-initializer.spec.d.ts +2 -0
- package/lib/init/project-initializer.spec.d.ts.map +1 -0
- package/lib/init/project-initializer.spec.js +88 -0
- package/lib/init/project-initializer.spec.js.map +1 -0
- package/lib/mcp/dev-activity.d.ts +34 -0
- package/lib/mcp/dev-activity.d.ts.map +1 -0
- package/lib/mcp/dev-activity.js +46 -0
- package/lib/mcp/dev-activity.js.map +1 -0
- package/lib/mcp/dev-mcp-endpoint.d.ts +62 -0
- package/lib/mcp/dev-mcp-endpoint.d.ts.map +1 -0
- package/lib/mcp/dev-mcp-endpoint.js +280 -0
- package/lib/mcp/dev-mcp-endpoint.js.map +1 -0
- package/lib/mcp/dev-mcp-endpoint.spec.d.ts +2 -0
- package/lib/mcp/dev-mcp-endpoint.spec.d.ts.map +1 -0
- package/lib/mcp/dev-mcp-endpoint.spec.js +143 -0
- package/lib/mcp/dev-mcp-endpoint.spec.js.map +1 -0
- package/lib/mcp/mcp-server.d.ts +64 -0
- package/lib/mcp/mcp-server.d.ts.map +1 -0
- package/lib/mcp/mcp-server.js +201 -0
- package/lib/mcp/mcp-server.js.map +1 -0
- package/lib/mcp/mcp-server.spec.d.ts +2 -0
- package/lib/mcp/mcp-server.spec.d.ts.map +1 -0
- package/lib/mcp/mcp-server.spec.js +136 -0
- package/lib/mcp/mcp-server.spec.js.map +1 -0
- package/lib/mcp/project-mcp-tools.d.ts +35 -0
- package/lib/mcp/project-mcp-tools.d.ts.map +1 -0
- package/lib/mcp/project-mcp-tools.js +199 -0
- package/lib/mcp/project-mcp-tools.js.map +1 -0
- package/lib/modules/module-host.d.ts +118 -0
- package/lib/modules/module-host.d.ts.map +1 -0
- package/lib/modules/module-host.js +405 -0
- package/lib/modules/module-host.js.map +1 -0
- package/lib/modules/module-host.spec.d.ts +2 -0
- package/lib/modules/module-host.spec.d.ts.map +1 -0
- package/lib/modules/module-host.spec.js +220 -0
- package/lib/modules/module-host.spec.js.map +1 -0
- package/lib/preset/builtin-presets.d.ts +9 -0
- package/lib/preset/builtin-presets.d.ts.map +1 -0
- package/lib/preset/builtin-presets.js +24 -0
- package/lib/preset/builtin-presets.js.map +1 -0
- package/lib/preset/cloudflare/cloudflare-deployer.d.ts +26 -0
- package/lib/preset/cloudflare/cloudflare-deployer.d.ts.map +1 -0
- package/lib/preset/cloudflare/cloudflare-deployer.js +116 -0
- package/lib/preset/cloudflare/cloudflare-deployer.js.map +1 -0
- package/lib/preset/cloudflare/cloudflare-preset.d.ts +16 -0
- package/lib/preset/cloudflare/cloudflare-preset.d.ts.map +1 -0
- package/lib/preset/cloudflare/cloudflare-preset.js +97 -0
- package/lib/preset/cloudflare/cloudflare-preset.js.map +1 -0
- package/lib/preset/cloudflare/cloudflare.spec.d.ts +2 -0
- package/lib/preset/cloudflare/cloudflare.spec.d.ts.map +1 -0
- package/lib/preset/cloudflare/cloudflare.spec.js +212 -0
- package/lib/preset/cloudflare/cloudflare.spec.js.map +1 -0
- package/lib/preset/cloudflare/wrangler-config.d.ts +50 -0
- package/lib/preset/cloudflare/wrangler-config.d.ts.map +1 -0
- package/lib/preset/cloudflare/wrangler-config.js +160 -0
- package/lib/preset/cloudflare/wrangler-config.js.map +1 -0
- package/lib/preset/cloudflare/wrangler-config.spec.d.ts +2 -0
- package/lib/preset/cloudflare/wrangler-config.spec.d.ts.map +1 -0
- package/lib/preset/cloudflare/wrangler-config.spec.js +112 -0
- package/lib/preset/cloudflare/wrangler-config.spec.js.map +1 -0
- package/lib/preset/cloudflare/wrangler.d.ts +38 -0
- package/lib/preset/cloudflare/wrangler.d.ts.map +1 -0
- package/lib/preset/cloudflare/wrangler.js +90 -0
- package/lib/preset/cloudflare/wrangler.js.map +1 -0
- package/lib/preset/cloudflare/wrangler.spec.d.ts +2 -0
- package/lib/preset/cloudflare/wrangler.spec.d.ts.map +1 -0
- package/lib/preset/cloudflare/wrangler.spec.js +64 -0
- package/lib/preset/cloudflare/wrangler.spec.js.map +1 -0
- package/lib/preset/fc/fc-deployer.d.ts +50 -0
- package/lib/preset/fc/fc-deployer.d.ts.map +1 -0
- package/lib/preset/fc/fc-deployer.js +209 -0
- package/lib/preset/fc/fc-deployer.js.map +1 -0
- package/lib/preset/fc/fc-preset.d.ts +20 -0
- package/lib/preset/fc/fc-preset.d.ts.map +1 -0
- package/lib/preset/fc/fc-preset.js +46 -0
- package/lib/preset/fc/fc-preset.js.map +1 -0
- package/lib/preset/lambda/lambda-deployer.d.ts +50 -0
- package/lib/preset/lambda/lambda-deployer.d.ts.map +1 -0
- package/lib/preset/lambda/lambda-deployer.js +274 -0
- package/lib/preset/lambda/lambda-deployer.js.map +1 -0
- package/lib/preset/lambda/lambda-preset.d.ts +14 -0
- package/lib/preset/lambda/lambda-preset.d.ts.map +1 -0
- package/lib/preset/lambda/lambda-preset.js +44 -0
- package/lib/preset/lambda/lambda-preset.js.map +1 -0
- package/lib/preset/preset-output.d.ts +19 -0
- package/lib/preset/preset-output.d.ts.map +1 -0
- package/lib/preset/preset-output.js +45 -0
- package/lib/preset/preset-output.js.map +1 -0
- package/lib/preset/preset-registry.d.ts +16 -0
- package/lib/preset/preset-registry.d.ts.map +1 -0
- package/lib/preset/preset-registry.js +58 -0
- package/lib/preset/preset-registry.js.map +1 -0
- package/lib/preset/preset-registry.spec.d.ts +2 -0
- package/lib/preset/preset-registry.spec.d.ts.map +1 -0
- package/lib/preset/preset-registry.spec.js +28 -0
- package/lib/preset/preset-registry.spec.js.map +1 -0
- package/lib/preset/scf/scf-deployer.d.ts +54 -0
- package/lib/preset/scf/scf-deployer.d.ts.map +1 -0
- package/lib/preset/scf/scf-deployer.js +202 -0
- package/lib/preset/scf/scf-deployer.js.map +1 -0
- package/lib/preset/scf/scf-preset.d.ts +19 -0
- package/lib/preset/scf/scf-preset.d.ts.map +1 -0
- package/lib/preset/scf/scf-preset.js +43 -0
- package/lib/preset/scf/scf-preset.js.map +1 -0
- package/lib/preset/serverless-deployers.spec.d.ts +2 -0
- package/lib/preset/serverless-deployers.spec.d.ts.map +1 -0
- package/lib/preset/serverless-deployers.spec.js +307 -0
- package/lib/preset/serverless-deployers.spec.js.map +1 -0
- package/lib/preset/serverless-presets.spec.d.ts +2 -0
- package/lib/preset/serverless-presets.spec.d.ts.map +1 -0
- package/lib/preset/serverless-presets.spec.js +280 -0
- package/lib/preset/serverless-presets.spec.js.map +1 -0
- package/lib/preset/serverless-scripts.d.ts +29 -0
- package/lib/preset/serverless-scripts.d.ts.map +1 -0
- package/lib/preset/serverless-scripts.js +120 -0
- package/lib/preset/serverless-scripts.js.map +1 -0
- package/lib/preset/vercel/vercel-deployer.d.ts +38 -0
- package/lib/preset/vercel/vercel-deployer.d.ts.map +1 -0
- package/lib/preset/vercel/vercel-deployer.js +160 -0
- package/lib/preset/vercel/vercel-deployer.js.map +1 -0
- package/lib/preset/vercel/vercel-preset.d.ts +19 -0
- package/lib/preset/vercel/vercel-preset.d.ts.map +1 -0
- package/lib/preset/vercel/vercel-preset.js +102 -0
- package/lib/preset/vercel/vercel-preset.js.map +1 -0
- package/lib/test/fixture-project.d.ts +17 -0
- package/lib/test/fixture-project.d.ts.map +1 -0
- package/lib/test/fixture-project.js +43 -0
- package/lib/test/fixture-project.js.map +1 -0
- package/lib/testing/create-test-app.d.ts +27 -0
- package/lib/testing/create-test-app.d.ts.map +1 -0
- package/lib/testing/create-test-app.js +54 -0
- package/lib/testing/create-test-app.js.map +1 -0
- package/lib/testing/create-test-app.spec.d.ts +2 -0
- package/lib/testing/create-test-app.spec.d.ts.map +1 -0
- package/lib/testing/create-test-app.spec.js +66 -0
- package/lib/testing/create-test-app.spec.js.map +1 -0
- package/lib/toolchain/toolchain.d.ts +49 -0
- package/lib/toolchain/toolchain.d.ts.map +1 -0
- package/lib/toolchain/toolchain.js +100 -0
- package/lib/toolchain/toolchain.js.map +1 -0
- package/lib/utils/json-util.d.ts +11 -0
- package/lib/utils/json-util.d.ts.map +1 -0
- package/lib/utils/json-util.js +73 -0
- package/lib/utils/json-util.js.map +1 -0
- package/lib/utils/json-util.spec.d.ts +2 -0
- package/lib/utils/json-util.spec.d.ts.map +1 -0
- package/lib/utils/json-util.spec.js +18 -0
- package/lib/utils/json-util.spec.js.map +1 -0
- package/lib/utils/text-util.d.ts +19 -0
- package/lib/utils/text-util.d.ts.map +1 -0
- package/lib/utils/text-util.js +66 -0
- package/lib/utils/text-util.js.map +1 -0
- package/lib/utils/text-util.spec.d.ts +2 -0
- package/lib/utils/text-util.spec.d.ts.map +1 -0
- package/lib/utils/text-util.spec.js +22 -0
- package/lib/utils/text-util.spec.js.map +1 -0
- package/package.json +28 -30
- package/src/agent/agent-guide.ts +90 -0
- package/src/build/executable-compiler.ts +179 -0
- package/src/check/project-checker.ts +365 -0
- package/src/cli/agent-command.ts +46 -0
- package/src/cli/build-command.ts +189 -0
- package/src/cli/cell-cli.ts +174 -0
- package/src/cli/check-command.ts +74 -0
- package/src/cli/command.ts +29 -0
- package/src/cli/config-command.ts +73 -0
- package/src/cli/deploy-command.ts +122 -0
- package/src/cli/dev-command.ts +232 -0
- package/src/cli/docs-command.ts +53 -0
- package/src/cli/info-command.ts +40 -0
- package/src/cli/init-command.ts +53 -0
- package/src/cli/main.ts +3 -0
- package/src/cli/mcp-command.ts +98 -0
- package/src/cli/preview-command.ts +98 -0
- package/src/cli/reporter.ts +67 -0
- package/src/config/config-explainer.ts +158 -0
- package/src/config/config-file-loader.ts +76 -0
- package/src/config/config-resolver.ts +300 -0
- package/src/config/config-validator.ts +208 -0
- package/src/config/define-config.ts +6 -0
- package/src/config/types.ts +57 -0
- package/src/deploy/cloud-api.ts +194 -0
- package/src/deploy/code-package.ts +44 -0
- package/src/deploy/deployer-registry.ts +44 -0
- package/src/deploy/request-signer.ts +155 -0
- package/src/deploy/zip-writer.ts +132 -0
- package/src/docs/docs-index.ts +174 -0
- package/src/events/event-bus.ts +94 -0
- package/src/events/hook-runner.ts +78 -0
- package/src/index.ts +57 -0
- package/src/info/project-inspector.ts +352 -0
- package/src/init/project-initializer.ts +111 -0
- package/src/mcp/dev-activity.ts +71 -0
- package/src/mcp/dev-mcp-endpoint.ts +323 -0
- package/src/mcp/mcp-server.ts +251 -0
- package/src/mcp/project-mcp-tools.ts +216 -0
- package/src/modules/module-host.ts +489 -0
- package/src/preset/builtin-presets.ts +26 -0
- package/src/preset/cloudflare/cloudflare-deployer.ts +126 -0
- package/src/preset/cloudflare/cloudflare-preset.ts +97 -0
- package/src/preset/cloudflare/wrangler-config.ts +173 -0
- package/src/preset/cloudflare/wrangler.ts +113 -0
- package/src/preset/fc/fc-deployer.ts +237 -0
- package/src/preset/fc/fc-preset.ts +51 -0
- package/src/preset/lambda/lambda-deployer.ts +317 -0
- package/src/preset/lambda/lambda-preset.ts +45 -0
- package/src/preset/preset-output.ts +55 -0
- package/src/preset/preset-registry.ts +65 -0
- package/src/preset/scf/scf-deployer.ts +232 -0
- package/src/preset/scf/scf-preset.ts +45 -0
- package/src/preset/serverless-scripts.ts +132 -0
- package/src/preset/vercel/vercel-deployer.ts +168 -0
- package/src/preset/vercel/vercel-preset.ts +111 -0
- package/src/test/fixture-project.ts +50 -0
- package/src/testing/create-test-app.ts +73 -0
- package/src/toolchain/toolchain.ts +121 -0
- package/src/utils/json-util.ts +67 -0
- package/src/utils/text-util.ts +68 -0
- package/templates/backend/README.md +13 -0
- package/templates/backend/_gitignore +5 -0
- package/templates/backend/cell.yml +3 -0
- package/templates/backend/package.json +23 -0
- package/templates/{file-service/src → backend/src/node}/home-controller.ts +5 -2
- package/templates/{file-service/src → backend/src/node}/module.ts +0 -1
- package/templates/backend/template.json +3 -0
- package/templates/backend/test/app.spec.ts +19 -0
- package/templates/backend/tsconfig.json +25 -0
- package/templates/fullstack/README.md +13 -0
- package/templates/fullstack/_gitignore +5 -0
- package/templates/fullstack/cell.yml +6 -0
- package/templates/fullstack/package.json +27 -0
- package/templates/fullstack/src/browser/home.view.tsx +19 -0
- package/templates/{cell-component/src → fullstack/src/browser}/module.ts +1 -1
- package/templates/fullstack/src/common/greeting-protocol.ts +5 -0
- package/templates/fullstack/src/node/greeting-server.ts +13 -0
- package/templates/{admin-app/src/browser → fullstack/src/node}/module.ts +2 -1
- package/templates/fullstack/template.json +3 -0
- package/templates/fullstack/test/app.spec.ts +18 -0
- package/templates/fullstack/tsconfig.json +27 -0
- package/bin/cell +0 -2
- package/lib/build/build-manager.d.ts +0 -9
- package/lib/build/build-manager.d.ts.map +0 -1
- package/lib/build/build-manager.js +0 -41
- package/lib/build/build-manager.js.map +0 -1
- package/lib/build/build.d.ts +0 -6
- package/lib/build/build.d.ts.map +0 -1
- package/lib/build/build.js +0 -16
- package/lib/build/build.js.map +0 -1
- package/lib/cell-main.d.ts +0 -2
- package/lib/cell-main.d.ts.map +0 -1
- package/lib/cell-main.js +0 -110
- package/lib/cell-main.js.map +0 -1
- package/lib/cell.d.ts +0 -2
- package/lib/cell.d.ts.map +0 -1
- package/lib/cell.js +0 -194
- package/lib/cell.js.map +0 -1
- package/lib/config/config.d.ts +0 -12
- package/lib/config/config.d.ts.map +0 -1
- package/lib/config/config.js +0 -48
- package/lib/config/config.js.map +0 -1
- package/lib/deploy/deploy.d.ts +0 -7
- package/lib/deploy/deploy.d.ts.map +0 -1
- package/lib/deploy/deploy.js +0 -30
- package/lib/deploy/deploy.js.map +0 -1
- package/lib/info/info.d.ts +0 -6
- package/lib/info/info.d.ts.map +0 -1
- package/lib/info/info.js +0 -21
- package/lib/info/info.js.map +0 -1
- package/lib/init/init-manager.d.ts +0 -33
- package/lib/init/init-manager.d.ts.map +0 -1
- package/lib/init/init-manager.js +0 -141
- package/lib/init/init-manager.js.map +0 -1
- package/lib/init/init.d.ts +0 -4
- package/lib/init/init.d.ts.map +0 -1
- package/lib/init/init.js +0 -17
- package/lib/init/init.js.map +0 -1
- package/lib/init/templates.d.ts +0 -2
- package/lib/init/templates.d.ts.map +0 -1
- package/lib/init/templates.js +0 -23
- package/lib/init/templates.js.map +0 -1
- package/lib/package.spec.d.ts +0 -2
- package/lib/package.spec.d.ts.map +0 -1
- package/lib/package.spec.js +0 -7
- package/lib/package.spec.js.map +0 -1
- package/lib/props/props.d.ts +0 -9
- package/lib/props/props.d.ts.map +0 -1
- package/lib/props/props.js +0 -49
- package/lib/props/props.js.map +0 -1
- package/lib/serve/serve-manager.d.ts +0 -8
- package/lib/serve/serve-manager.d.ts.map +0 -1
- package/lib/serve/serve-manager.js +0 -44
- package/lib/serve/serve-manager.js.map +0 -1
- package/lib/serve/serve.d.ts +0 -8
- package/lib/serve/serve.d.ts.map +0 -1
- package/lib/serve/serve.js +0 -25
- package/lib/serve/serve.js.map +0 -1
- package/lib/update/update.d.ts +0 -9
- package/lib/update/update.d.ts.map +0 -1
- package/lib/update/update.js +0 -56
- package/lib/update/update.js.map +0 -1
- package/lib/utils/banner-util.d.ts +0 -6
- package/lib/utils/banner-util.d.ts.map +0 -1
- package/lib/utils/banner-util.js +0 -44
- package/lib/utils/banner-util.js.map +0 -1
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.d.ts.map +0 -1
- package/lib/utils/index.js +0 -18
- package/lib/utils/index.js.map +0 -1
- package/src/build/build-manager.ts +0 -50
- package/src/build/build.ts +0 -17
- package/src/cell-main.ts +0 -125
- package/src/cell.ts +0 -215
- package/src/config/config.ts +0 -56
- package/src/deploy/deploy.ts +0 -31
- package/src/info/info.ts +0 -23
- package/src/init/init-manager.ts +0 -163
- package/src/init/init.ts +0 -15
- package/src/init/templates.ts +0 -19
- package/src/package.spec.ts +0 -5
- package/src/props/props.ts +0 -48
- package/src/serve/serve-manager.ts +0 -51
- package/src/serve/serve.ts +0 -29
- package/src/update/update.ts +0 -61
- package/src/utils/banner-util.ts +0 -41
- package/src/utils/index.ts +0 -1
- package/templates/accounts/README.md +0 -92
- package/templates/accounts/cell-database.yml +0 -17
- package/templates/accounts/cell-locale.yml +0 -17
- package/templates/accounts/cell-oauth2.0.yml +0 -8
- package/templates/accounts/cell-theme.yml +0 -9
- package/templates/accounts/cell.yml +0 -10
- package/templates/accounts/favicon.ico +0 -0
- package/templates/accounts/package.json +0 -48
- package/templates/accounts/src/browser/home.view.tsx +0 -86
- package/templates/accounts/src/browser/index.ts +0 -3
- package/templates/accounts/src/browser/login.view.tsx +0 -78
- package/templates/accounts/src/browser/module.ts +0 -3
- package/templates/accounts/src/common/entity-protocol.ts +0 -7
- package/templates/accounts/src/common/index.ts +0 -1
- package/templates/accounts/src/node/authentication/authentication-success-handler.ts +0 -69
- package/templates/accounts/src/node/authentication/index.ts +0 -1
- package/templates/accounts/src/node/entity/base-entity.ts +0 -13
- package/templates/accounts/src/node/entity/connection.ts +0 -52
- package/templates/accounts/src/node/entity/index.ts +0 -1
- package/templates/accounts/src/node/entity/user.ts +0 -73
- package/templates/accounts/src/node/error/error.ts +0 -14
- package/templates/accounts/src/node/error/index.ts +0 -1
- package/templates/accounts/src/node/index.ts +0 -2
- package/templates/accounts/src/node/module.ts +0 -9
- package/templates/accounts/src/node/user/index.ts +0 -4
- package/templates/accounts/src/node/user/user-protocol.ts +0 -19
- package/templates/accounts/src/node/user/user-repository.ts +0 -72
- package/templates/accounts/src/node/user/user-service.ts +0 -36
- package/templates/accounts/tsconfig.json +0 -32
- package/templates/admin-app/.github/workflows/deploy.yml +0 -25
- package/templates/admin-app/.vscode/launch.json +0 -23
- package/templates/admin-app/README.md +0 -92
- package/templates/admin-app/cell-database.yml +0 -7
- package/templates/admin-app/cell.yml +0 -93
- package/templates/admin-app/package.json +0 -37
- package/templates/admin-app/src/browser/user.view.tsx +0 -40
- package/templates/admin-app/src/common/index.ts +0 -1
- package/templates/admin-app/src/common/user-protocol.ts +0 -23
- package/templates/admin-app/src/node/entity/index.ts +0 -1
- package/templates/admin-app/src/node/entity/user.ts +0 -15
- package/templates/admin-app/src/node/module.ts +0 -8
- package/templates/admin-app/src/node/user-service.ts +0 -41
- package/templates/admin-app/tsconfig.json +0 -32
- package/templates/backend-app/.github/workflows/deploy.yml +0 -25
- package/templates/backend-app/.vscode/launch.json +0 -23
- package/templates/backend-app/README.md +0 -92
- package/templates/backend-app/cell.yml +0 -0
- package/templates/backend-app/package.json +0 -33
- package/templates/backend-app/src/home-controller.ts +0 -11
- package/templates/backend-app/src/module.ts +0 -4
- package/templates/backend-app/src/user-controller.ts +0 -48
- package/templates/backend-app/test/home-controller.spec.ts +0 -19
- package/templates/backend-app/tsconfig.json +0 -32
- package/templates/cell-component/README.md +0 -27
- package/templates/cell-component/cell.yml +0 -0
- package/templates/cell-component/package.json +0 -29
- package/templates/cell-component/src/echo-service.ts +0 -16
- package/templates/cell-component/src/index.ts +0 -1
- package/templates/cell-component/src/package.spec.ts +0 -5
- package/templates/cell-component/tsconfig.json +0 -37
- package/templates/database-app/.github/workflows/deploy.yml +0 -25
- package/templates/database-app/.vscode/launch.json +0 -23
- package/templates/database-app/README.md +0 -92
- package/templates/database-app/cell.yml +0 -17
- package/templates/database-app/package.json +0 -31
- package/templates/database-app/src/entity/index.ts +0 -1
- package/templates/database-app/src/entity/user.ts +0 -13
- package/templates/database-app/src/home-controller.ts +0 -11
- package/templates/database-app/src/module.ts +0 -8
- package/templates/database-app/src/user-controller.ts +0 -43
- package/templates/database-app/tsconfig.json +0 -32
- package/templates/docker-app/.github/workflows/deploy.yml +0 -25
- package/templates/docker-app/.vscode/launch.json +0 -23
- package/templates/docker-app/Dockerfile +0 -27
- package/templates/docker-app/README.md +0 -93
- package/templates/docker-app/cell.yml +0 -0
- package/templates/docker-app/package.json +0 -31
- package/templates/docker-app/src/browser/assets/logo.png +0 -0
- package/templates/docker-app/src/browser/css-shims.d.ts +0 -30
- package/templates/docker-app/src/browser/hello.view.tsx +0 -31
- package/templates/docker-app/src/browser/module.ts +0 -3
- package/templates/docker-app/src/browser/style/hello.module.scss +0 -4
- package/templates/docker-app/src/common/welcome-protocol.ts +0 -5
- package/templates/docker-app/src/node/module.ts +0 -3
- package/templates/docker-app/src/node/welcome-server.ts +0 -9
- package/templates/docker-app/tsconfig.json +0 -33
- package/templates/file-service/.github/workflows/deploy.yml +0 -25
- package/templates/file-service/.vscode/launch.json +0 -23
- package/templates/file-service/README.md +0 -92
- package/templates/file-service/cell.yml +0 -12
- package/templates/file-service/package.json +0 -34
- package/templates/file-service/src/file-controller.ts +0 -47
- package/templates/file-service/tsconfig.json +0 -32
- package/templates/jwt-app/.github/workflows/deploy.yml +0 -25
- package/templates/jwt-app/.vscode/launch.json +0 -23
- package/templates/jwt-app/README.md +0 -92
- package/templates/jwt-app/cell.yml +0 -4
- package/templates/jwt-app/package.json +0 -36
- package/templates/jwt-app/src/context.ts +0 -16
- package/templates/jwt-app/src/error-handler.ts +0 -30
- package/templates/jwt-app/src/error.ts +0 -4
- package/templates/jwt-app/src/home-controller.ts +0 -23
- package/templates/jwt-app/src/index.ts +0 -5
- package/templates/jwt-app/src/jwt-middleware.ts +0 -36
- package/templates/jwt-app/src/module.ts +0 -3
- package/templates/jwt-app/test/home-controller.spec.ts +0 -19
- package/templates/jwt-app/tsconfig.json +0 -32
- package/templates/koa-app/app.js +0 -8
- package/templates/koa-app/package.json +0 -9
- package/templates/microservice/.github/workflows/deploy.yml +0 -28
- package/templates/microservice/.vscode/launch.json +0 -24
- package/templates/microservice/README.md +0 -92
- package/templates/microservice/examples/backend-app/README.md +0 -92
- package/templates/microservice/examples/backend-app/cell-remote.yml +0 -4
- package/templates/microservice/examples/backend-app/cell.yml +0 -3
- package/templates/microservice/examples/backend-app/package.json +0 -32
- package/templates/microservice/examples/backend-app/src/api-controller.ts +0 -31
- package/templates/microservice/examples/backend-app/src/module.ts +0 -3
- package/templates/microservice/examples/backend-app/tsconfig.json +0 -32
- package/templates/microservice/package.json +0 -20
- package/templates/microservice/packages/api/README.md +0 -92
- package/templates/microservice/packages/api/cell.yml +0 -0
- package/templates/microservice/packages/api/package.json +0 -25
- package/templates/microservice/packages/api/src/common/api-protocol.ts +0 -10
- package/templates/microservice/packages/api/src/common/index.ts +0 -1
- package/templates/microservice/packages/api/tsconfig.json +0 -30
- package/templates/microservice/packages/serviceA/.vscode/launch.json +0 -23
- package/templates/microservice/packages/serviceA/README.md +0 -92
- package/templates/microservice/packages/serviceA/cell.yml +0 -6
- package/templates/microservice/packages/serviceA/package.json +0 -29
- package/templates/microservice/packages/serviceA/src/node/module.ts +0 -3
- package/templates/microservice/packages/serviceA/src/node/service-a.ts +0 -9
- package/templates/microservice/packages/serviceA/tsconfig.json +0 -30
- package/templates/microservice/packages/serviceB/README.md +0 -92
- package/templates/microservice/packages/serviceB/cell.yml +0 -5
- package/templates/microservice/packages/serviceB/package.json +0 -29
- package/templates/microservice/packages/serviceB/src/node/module.ts +0 -3
- package/templates/microservice/packages/serviceB/src/node/service-b.ts +0 -9
- package/templates/microservice/packages/serviceB/tsconfig.json +0 -30
- package/templates/microservice/tsconfig.json +0 -32
- package/templates/mycli/.vscode/launch.json +0 -33
- package/templates/mycli/bin/mycli +0 -2
- package/templates/mycli/bin/mycli-deploy +0 -2
- package/templates/mycli/bin/mycli-init +0 -2
- package/templates/mycli/package.json +0 -33
- package/templates/mycli/src/bootstrap.ts +0 -7
- package/templates/mycli/src/constants.ts +0 -1
- package/templates/mycli/src/deploy/deploy-manager.ts +0 -12
- package/templates/mycli/src/deploy/deploy.ts +0 -16
- package/templates/mycli/src/deploy/index.ts +0 -1
- package/templates/mycli/src/index.ts +0 -2
- package/templates/mycli/src/init/index.ts +0 -1
- package/templates/mycli/src/init/init-manager.ts +0 -85
- package/templates/mycli/src/init/init.ts +0 -25
- package/templates/mycli/src/init/templates.ts +0 -3
- package/templates/mycli/src/module.ts +0 -3
- package/templates/mycli/src/mycli.ts +0 -13
- package/templates/mycli/templates/application-template/README.md +0 -0
- package/templates/mycli/tsconfig.json +0 -32
- package/templates/nest-app/.eslintrc.js +0 -25
- package/templates/nest-app/.prettierrc +0 -4
- package/templates/nest-app/README.md +0 -73
- package/templates/nest-app/nest-cli.json +0 -8
- package/templates/nest-app/package.json +0 -69
- package/templates/nest-app/src/app.controller.spec.ts +0 -22
- package/templates/nest-app/src/app.controller.ts +0 -12
- package/templates/nest-app/src/app.module.ts +0 -10
- package/templates/nest-app/src/app.service.ts +0 -8
- package/templates/nest-app/src/main.ts +0 -8
- package/templates/nest-app/test/app.e2e-spec.ts +0 -24
- package/templates/nest-app/test/jest-e2e.json +0 -9
- package/templates/nest-app/tsconfig.build.json +0 -12
- package/templates/nest-app/tsconfig.json +0 -25
- package/templates/nextjs-app/.eslintrc.json +0 -3
- package/templates/nextjs-app/README.md +0 -34
- package/templates/nextjs-app/next.config.js +0 -6
- package/templates/nextjs-app/package.json +0 -20
- package/templates/nextjs-app/pages/_app.js +0 -7
- package/templates/nextjs-app/pages/api/hello.js +0 -5
- package/templates/nextjs-app/pages/index.js +0 -69
- package/templates/nextjs-app/public/favicon.ico +0 -0
- package/templates/nextjs-app/public/vercel.svg +0 -4
- package/templates/nextjs-app/styles/Home.module.css +0 -116
- package/templates/nextjs-app/styles/globals.css +0 -16
- package/templates/sample-app/.github/workflows/deploy.yml +0 -25
- package/templates/sample-app/.vscode/launch.json +0 -23
- package/templates/sample-app/README.md +0 -92
- package/templates/sample-app/cell.yml +0 -0
- package/templates/sample-app/package.json +0 -31
- package/templates/sample-app/src/browser/assets/logo.png +0 -0
- package/templates/sample-app/src/browser/css-shims.d.ts +0 -30
- package/templates/sample-app/src/browser/hello.view.tsx +0 -31
- package/templates/sample-app/src/browser/module.ts +0 -3
- package/templates/sample-app/src/browser/style/hello.module.scss +0 -4
- package/templates/sample-app/src/common/welcome-protocol.ts +0 -5
- package/templates/sample-app/src/node/module.ts +0 -3
- package/templates/sample-app/src/node/welcome-server.ts +0 -9
- package/templates/sample-app/tsconfig.json +0 -32
- package/templates/schedule/.github/workflows/deploy.yml +0 -25
- package/templates/schedule/.vscode/launch.json +0 -23
- package/templates/schedule/README.md +0 -92
- package/templates/schedule/cell.yml +0 -1
- package/templates/schedule/package.json +0 -29
- package/templates/schedule/src/module.ts +0 -3
- package/templates/schedule/src/scheduler.ts +0 -10
- package/templates/schedule/tsconfig.json +0 -32
- package/templates/standalone-app/package.json +0 -17
- package/templates/standalone-app/src/app.service.ts +0 -10
- package/templates/standalone-app/src/main.ts +0 -14
- package/templates/standalone-app/src/module.ts +0 -3
- package/templates/standalone-app/tsconfig.json +0 -30
- package/templates/vue-app/.github/workflows/deploy.yml +0 -25
- package/templates/vue-app/.vscode/launch.json +0 -23
- package/templates/vue-app/README.md +0 -92
- package/templates/vue-app/cell.yml +0 -0
- package/templates/vue-app/package.json +0 -32
- package/templates/vue-app/src/browser/App.vue +0 -32
- package/templates/vue-app/src/browser/app.ts +0 -7
- package/templates/vue-app/src/browser/components/HelloWorld.vue +0 -42
- package/templates/vue-app/src/browser/declare.d.ts +0 -7
- package/templates/vue-app/src/browser/images/logo.png +0 -0
- package/templates/vue-app/src/browser/module.ts +0 -3
- package/templates/vue-app/src/browser/router.ts +0 -13
- package/templates/vue-app/src/browser/shims-vue.d.ts +0 -5
- package/templates/vue-app/src/browser/views/About.vue +0 -5
- package/templates/vue-app/src/browser/views/Root.vue +0 -37
- package/templates/vue-app/src/common/welcome-protocol.ts +0 -5
- package/templates/vue-app/src/node/module.ts +0 -3
- package/templates/vue-app/src/node/welcome-server.ts +0 -9
- package/templates/vue-app/tsconfig.json +0 -32
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process';
|
|
2
|
+
import { existsSync, statSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { join, resolve as resolvePath } from 'node:path';
|
|
5
|
+
import { pathToFileURL } from 'node:url';
|
|
6
|
+
import type {
|
|
7
|
+
CellAPI,
|
|
8
|
+
CellComponent,
|
|
9
|
+
CellEventName,
|
|
10
|
+
CellLogger,
|
|
11
|
+
CheckDefinition,
|
|
12
|
+
DevHandler,
|
|
13
|
+
McpToolDefinition,
|
|
14
|
+
Preset,
|
|
15
|
+
StandardSchema,
|
|
16
|
+
Target,
|
|
17
|
+
VitePluginLike,
|
|
18
|
+
} from '@celljs/kit';
|
|
19
|
+
import { CellError } from '@celljs/kit';
|
|
20
|
+
import type { ExtraModule } from '@celljs/vite';
|
|
21
|
+
import type { Plugin } from 'vite';
|
|
22
|
+
import type { ResolvedConfig } from '../config/config-resolver.js';
|
|
23
|
+
import type { EventBus } from '../events/event-bus.js';
|
|
24
|
+
import type { PresetRegistry } from '../preset/preset-registry.js';
|
|
25
|
+
import { TextUtil } from '../utils/text-util.js';
|
|
26
|
+
|
|
27
|
+
/** Where a toolchain module comes from. */
|
|
28
|
+
export interface ModuleSource {
|
|
29
|
+
/** Package name of the component, the package, or the path of a local module relative to the root. */
|
|
30
|
+
name: string;
|
|
31
|
+
kind: 'component' | 'package' | 'local';
|
|
32
|
+
/** Absolute file of the module. */
|
|
33
|
+
file: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** What one module registered; `cell info` lists it (docs/design/modules.md §3.5). */
|
|
37
|
+
export interface ModuleRegistrations {
|
|
38
|
+
name: string;
|
|
39
|
+
kind: ModuleSource['kind'];
|
|
40
|
+
file: string;
|
|
41
|
+
options: string[];
|
|
42
|
+
/** What `updateConfig` added, e.g. `build.external: sharp`, `vite.resolve`. */
|
|
43
|
+
config: string[];
|
|
44
|
+
vitePlugins: { name: string; env?: 'client' | 'server' }[];
|
|
45
|
+
runtimeModules: { target: Target; path: string; static: boolean }[];
|
|
46
|
+
virtualModules: string[];
|
|
47
|
+
entries: Partial<Record<Target, string>>;
|
|
48
|
+
devHandlers: string[];
|
|
49
|
+
watchFiles: string[];
|
|
50
|
+
presets: string[];
|
|
51
|
+
outputFiles: string[];
|
|
52
|
+
checks: string[];
|
|
53
|
+
mcpTools: string[];
|
|
54
|
+
docs: string[];
|
|
55
|
+
events: string[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface ModuleHostOptions {
|
|
59
|
+
config: ResolvedConfig;
|
|
60
|
+
events: EventBus;
|
|
61
|
+
presets: PresetRegistry;
|
|
62
|
+
components: CellComponent[];
|
|
63
|
+
logger: { info(message: string): void; warn(message: string): void };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface Registered<T> {
|
|
67
|
+
source: string;
|
|
68
|
+
value: T;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Loads toolchain modules and keeps what they register (docs/design/modules.md §3). Modules load in a
|
|
73
|
+
* fixed order: components in dependency order, then the `modules` entries of cell.config.ts. A
|
|
74
|
+
* factory only registers; anything it registers is listed by `cell info`.
|
|
75
|
+
*/
|
|
76
|
+
export class ModuleHost {
|
|
77
|
+
readonly loaded: ModuleRegistrations[] = [];
|
|
78
|
+
readonly checks: Registered<CheckDefinition>[] = [];
|
|
79
|
+
readonly mcpTools: Registered<McpToolDefinition>[] = [];
|
|
80
|
+
readonly docs: Registered<string>[] = [];
|
|
81
|
+
readonly outputFiles = new Map<string, Registered<string | Uint8Array>>();
|
|
82
|
+
protected readonly plugins: Registered<{ plugin: VitePluginLike; env?: 'client' | 'server' }>[] = [];
|
|
83
|
+
protected readonly virtualModules = new Map<string, Registered<string | (() => string)>>();
|
|
84
|
+
protected readonly runtimeModules: ExtraModule[] = [];
|
|
85
|
+
protected readonly devHandlers: Registered<{ path: string; handler: DevHandler }>[] = [];
|
|
86
|
+
protected readonly watchFiles: string[] = [];
|
|
87
|
+
protected readonly schemas = new Map<string, Registered<StandardSchema>>();
|
|
88
|
+
protected readonly claimed = new Map<string, string>();
|
|
89
|
+
protected readonly bus = new Map<string, ((payload: unknown) => unknown)[]>();
|
|
90
|
+
readonly entries: Partial<Record<Target, string>> = {};
|
|
91
|
+
|
|
92
|
+
constructor(protected readonly options: ModuleHostOptions) {}
|
|
93
|
+
|
|
94
|
+
/** Components of the project, in dependency order (the project last). */
|
|
95
|
+
get components(): readonly CellComponent[] {
|
|
96
|
+
return this.options.components;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Modules of the components (`cell.toolchain`) and of cell.config.ts, in load order. */
|
|
100
|
+
static sources(config: ResolvedConfig, components: (CellComponent & { toolchain?: string })[]): ModuleSource[] {
|
|
101
|
+
const off = new Set(config.modules.flatMap(spec => (spec.kind === 'filter' && !spec.toolchain ? [spec.name] : [])));
|
|
102
|
+
const sources: ModuleSource[] = [];
|
|
103
|
+
for (const component of components) {
|
|
104
|
+
if (component.toolchain && !off.has(component.name)) {
|
|
105
|
+
sources.push({ name: component.name, kind: 'component', file: ModuleHost.file(join(component.dir, component.toolchain), component.name) });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const require = createRequire(join(config.root, 'package.json'));
|
|
109
|
+
for (const spec of config.modules) {
|
|
110
|
+
if (spec.kind === 'local') {
|
|
111
|
+
sources.push({
|
|
112
|
+
name: spec.path.startsWith(config.root) ? spec.path.slice(config.root.length + 1) : spec.path,
|
|
113
|
+
kind: 'local',
|
|
114
|
+
file: ModuleHost.file(spec.path, spec.path),
|
|
115
|
+
});
|
|
116
|
+
} else if (spec.kind === 'package' && !sources.some(s => s.name === spec.name)) {
|
|
117
|
+
sources.push({ name: spec.name, kind: 'package', file: ModuleHost.resolvePackage(require, spec.name, config.file) });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return sources;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
protected static file(path: string, name: string): string {
|
|
124
|
+
for (const candidate of [
|
|
125
|
+
path,
|
|
126
|
+
...['.js', '.mjs', '.cjs', '.ts', '.mts'].map(ext => path + ext),
|
|
127
|
+
...['index.js', 'index.mjs', 'index.ts'].map(f => join(path, f)),
|
|
128
|
+
]) {
|
|
129
|
+
if (existsSync(candidate) && statSync(candidate).isFile()) {
|
|
130
|
+
return candidate;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
throw new CellError({
|
|
134
|
+
code: 'CELL_LOCAL_MODULE_NOT_FOUND',
|
|
135
|
+
message: `The toolchain module of ${name} is missing: ${path}.`,
|
|
136
|
+
file: path,
|
|
137
|
+
hint: 'Build the package, or fix the `cell.toolchain` field of its package.json / the path in `modules`.',
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
protected static resolvePackage(require: NodeJS.Require, name: string, file?: string): string {
|
|
142
|
+
try {
|
|
143
|
+
const manifest = require.resolve(`${name}/package.json`);
|
|
144
|
+
const pkg = require(manifest) as { cell?: { toolchain?: string } };
|
|
145
|
+
if (pkg.cell?.toolchain) {
|
|
146
|
+
return ModuleHost.file(join(manifest, '..', pkg.cell.toolchain), name);
|
|
147
|
+
}
|
|
148
|
+
return require.resolve(name);
|
|
149
|
+
} catch (cause) {
|
|
150
|
+
if (CellError.is(cause)) {
|
|
151
|
+
throw cause;
|
|
152
|
+
}
|
|
153
|
+
throw new CellError({
|
|
154
|
+
code: 'CELL_COMPONENT_NOT_FOUND',
|
|
155
|
+
message: `The toolchain module ${name} is not installed.`,
|
|
156
|
+
file,
|
|
157
|
+
hint: `Install it (npm install -D ${name}), or remove it from \`modules\` in cell.config.ts.`,
|
|
158
|
+
cause,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
async load(sources: ModuleSource[]): Promise<void> {
|
|
164
|
+
for (const source of sources) {
|
|
165
|
+
const factory = await this.import(source);
|
|
166
|
+
const record = this.record(source);
|
|
167
|
+
const api = this.api(source, record);
|
|
168
|
+
try {
|
|
169
|
+
await factory(api.cell);
|
|
170
|
+
} catch (error) {
|
|
171
|
+
throw CellError.is(error)
|
|
172
|
+
? error
|
|
173
|
+
: new CellError({
|
|
174
|
+
code: 'CELL_MODULE_ERROR',
|
|
175
|
+
message: `The toolchain module ${source.name} failed: ${(error as Error)?.message ?? String(error)}`,
|
|
176
|
+
file: source.file,
|
|
177
|
+
hint: `Fix the factory of ${source.name}, or turn it off with { source: '${source.name}', toolchain: false } in modules.`,
|
|
178
|
+
cause: error,
|
|
179
|
+
});
|
|
180
|
+
} finally {
|
|
181
|
+
api.close();
|
|
182
|
+
}
|
|
183
|
+
this.loaded.push(record);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** The field `key` of cell.config.ts belongs to `source` (a preset of the CLI), unless a module reads it already. */
|
|
188
|
+
claimOption(key: string, source: string, schema?: StandardSchema): void {
|
|
189
|
+
if (this.claimed.has(key)) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
this.claimed.set(key, source);
|
|
193
|
+
if (schema) {
|
|
194
|
+
this.schemas.set(key, { source, value: schema });
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** After `modules:done`: every option field of cell.config.ts must belong to a module, and match its schema. */
|
|
199
|
+
async checkOptions(): Promise<void> {
|
|
200
|
+
for (const [key, value] of Object.entries(this.options.config.options)) {
|
|
201
|
+
if (!this.claimed.has(key)) {
|
|
202
|
+
const suggestion = TextUtil.closest(key, [...this.claimed.keys()]);
|
|
203
|
+
throw new CellError({
|
|
204
|
+
code: 'CELL_CONFIG_UNKNOWN_OPTION',
|
|
205
|
+
message: `No toolchain module reads the '${key}' field of cell.config.ts.${this.claimed.size > 0 ? ` Module options: ${[...this.claimed.keys()].join(', ')}.` : ''}`,
|
|
206
|
+
file: this.options.config.file,
|
|
207
|
+
hint: suggestion ? `Did you mean '${suggestion}'?` : 'Remove the field, or add the module that reads it to `modules`.',
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
const schema = this.schemas.get(key);
|
|
211
|
+
if (schema) {
|
|
212
|
+
await this.validate(key, value, schema);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
protected async validate(key: string, value: unknown, { source, value: schema }: Registered<StandardSchema>): Promise<void> {
|
|
218
|
+
const result = (await schema['~standard'].validate(value)) as { issues?: ReadonlyArray<{ message: string; path?: ReadonlyArray<unknown> }> };
|
|
219
|
+
const issue = result.issues?.[0];
|
|
220
|
+
if (issue) {
|
|
221
|
+
const path = [key, ...(issue.path ?? []).map(p => String(typeof p === 'object' && p !== null ? (p as { key: unknown }).key : p))].join('.');
|
|
222
|
+
throw new CellError({
|
|
223
|
+
code: 'CELL_CONFIG_INVALID',
|
|
224
|
+
message: `${path}: ${issue.message}`,
|
|
225
|
+
file: this.options.config.file,
|
|
226
|
+
hint: `Fix the '${key}' options in cell.config.ts; they are defined by ${source}.`,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** Vite plugins of the modules: their own, and one serving the virtual modules. */
|
|
232
|
+
vitePlugins(): Plugin[] {
|
|
233
|
+
const plugins = this.plugins.map(
|
|
234
|
+
({ value: { plugin, env } }) =>
|
|
235
|
+
(env ? { ...plugin, applyToEnvironment: (environment: { name: string }) => environment.name === env } : plugin) as Plugin,
|
|
236
|
+
);
|
|
237
|
+
if (this.virtualModules.size > 0) {
|
|
238
|
+
const modules = this.virtualModules;
|
|
239
|
+
plugins.push({
|
|
240
|
+
name: 'cell:virtual-modules',
|
|
241
|
+
resolveId: id => (modules.has(id) ? `\0${id}` : null),
|
|
242
|
+
load: id => {
|
|
243
|
+
const code = id.startsWith('\0') ? modules.get(id.slice(1))?.value : undefined;
|
|
244
|
+
return code === undefined ? null : typeof code === 'function' ? code() : code;
|
|
245
|
+
},
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
return plugins;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
get extraModules(): ExtraModule[] {
|
|
252
|
+
return [...this.runtimeModules];
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
get devHandlerList(): { path: string; handler: DevHandler }[] {
|
|
256
|
+
return this.devHandlers.map(h => h.value);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
get watchFileList(): string[] {
|
|
260
|
+
return [...this.watchFiles];
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
protected async import(source: ModuleSource): Promise<(cell: CellAPI) => unknown> {
|
|
264
|
+
let exported: unknown;
|
|
265
|
+
try {
|
|
266
|
+
if (source.kind === 'local' && /\.[cm]?ts$/.test(source.file)) {
|
|
267
|
+
// TypeScript of the project: Vite's runner transpiles it (docs/design/modules.md §3).
|
|
268
|
+
const { runnerImport } = await import('vite');
|
|
269
|
+
exported = (await runnerImport<{ default?: unknown }>(source.file, { configFile: false, logLevel: 'error' })).module.default;
|
|
270
|
+
} else {
|
|
271
|
+
const module = (await import(pathToFileURL(source.file).href)) as { default?: unknown };
|
|
272
|
+
exported = module.default;
|
|
273
|
+
}
|
|
274
|
+
} catch (cause) {
|
|
275
|
+
throw new CellError({
|
|
276
|
+
code: 'CELL_MODULE_ERROR',
|
|
277
|
+
message: `Cannot load the toolchain module ${source.name}: ${(cause as Error)?.message ?? String(cause)}`,
|
|
278
|
+
file: source.file,
|
|
279
|
+
hint: 'Fix the module file; it must load without the project being built.',
|
|
280
|
+
cause,
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
// A CommonJS module compiled from `export default` has the factory one level down.
|
|
284
|
+
const factory = typeof exported === 'function' ? exported : (exported as { default?: unknown } | undefined)?.default;
|
|
285
|
+
if (typeof factory !== 'function') {
|
|
286
|
+
throw new CellError({
|
|
287
|
+
code: 'CELL_MODULE_INVALID',
|
|
288
|
+
message: `The toolchain module ${source.name} does not export a factory function by default.`,
|
|
289
|
+
file: source.file,
|
|
290
|
+
hint: 'Write `export default function (cell) { ... }` or `export default defineCellModule({ name }, cell => { ... })`.',
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
return factory as (cell: CellAPI) => unknown;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Deep merge of plain objects; `over` wins, arrays are replaced. */
|
|
297
|
+
static merge(under: Record<string, unknown>, over: Record<string, unknown>): Record<string, unknown> {
|
|
298
|
+
const result: Record<string, unknown> = { ...under };
|
|
299
|
+
for (const [key, value] of Object.entries(over)) {
|
|
300
|
+
const base = result[key];
|
|
301
|
+
const plain = (v: unknown): v is Record<string, unknown> =>
|
|
302
|
+
typeof v === 'object' && v !== null && !Array.isArray(v) && Object.getPrototypeOf(v) === Object.prototype;
|
|
303
|
+
result[key] = plain(base) && plain(value) ? ModuleHost.merge(base, value) : value;
|
|
304
|
+
}
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
protected record(source: ModuleSource): ModuleRegistrations {
|
|
309
|
+
return {
|
|
310
|
+
name: source.name,
|
|
311
|
+
kind: source.kind,
|
|
312
|
+
file: source.file,
|
|
313
|
+
options: [],
|
|
314
|
+
config: [],
|
|
315
|
+
vitePlugins: [],
|
|
316
|
+
runtimeModules: [],
|
|
317
|
+
virtualModules: [],
|
|
318
|
+
entries: {},
|
|
319
|
+
devHandlers: [],
|
|
320
|
+
watchFiles: [],
|
|
321
|
+
presets: [],
|
|
322
|
+
outputFiles: [],
|
|
323
|
+
checks: [],
|
|
324
|
+
mcpTools: [],
|
|
325
|
+
docs: [],
|
|
326
|
+
events: [],
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** The `cell` object of one module. `close()` ends the factory: options can no longer be read. */
|
|
331
|
+
protected api(source: ModuleSource, record: ModuleRegistrations): { cell: CellAPI; close(): void } {
|
|
332
|
+
const { config, events, presets, components } = this.options;
|
|
333
|
+
let open = true;
|
|
334
|
+
const name = source.name;
|
|
335
|
+
const claim = (key: string) => {
|
|
336
|
+
const owner = this.claimed.get(key);
|
|
337
|
+
if (owner && owner !== name) {
|
|
338
|
+
throw new CellError({
|
|
339
|
+
code: 'CELL_MODULE_ERROR',
|
|
340
|
+
message: `${name} reads the '${key}' options, which ${owner} already reads.`,
|
|
341
|
+
file: source.file,
|
|
342
|
+
hint: 'Each option field belongs to one module; use another key.',
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
this.claimed.set(key, name);
|
|
346
|
+
if (!record.options.includes(key)) {
|
|
347
|
+
record.options.push(key);
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
const prefix = `[${name}] `;
|
|
351
|
+
const logger: CellLogger = {
|
|
352
|
+
info: message => this.options.logger.info(prefix + message),
|
|
353
|
+
success: message => this.options.logger.info(prefix + message),
|
|
354
|
+
warn: message => this.options.logger.warn(prefix + message),
|
|
355
|
+
error: message => this.options.logger.warn(prefix + message),
|
|
356
|
+
};
|
|
357
|
+
const require = createRequire(join(config.root, 'package.json'));
|
|
358
|
+
const cell: CellAPI = {
|
|
359
|
+
command: config.command,
|
|
360
|
+
mode: [...config.mode],
|
|
361
|
+
dev: config.dev,
|
|
362
|
+
ci: config.ci,
|
|
363
|
+
root: config.root,
|
|
364
|
+
preset: config.preset.source === 'default' ? undefined : config.preset.name,
|
|
365
|
+
components,
|
|
366
|
+
logger,
|
|
367
|
+
options: <T extends object>(key: string, defaults?: T): T => {
|
|
368
|
+
if (!open) {
|
|
369
|
+
throw new CellError({
|
|
370
|
+
code: 'CELL_MODULE_ERROR',
|
|
371
|
+
message: `${name} read its options after its factory returned.`,
|
|
372
|
+
file: source.file,
|
|
373
|
+
hint: 'Call cell.options() synchronously in the factory and keep the result.',
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
claim(key);
|
|
377
|
+
return { ...(defaults ?? {}), ...(config.options[key] ?? {}) } as T;
|
|
378
|
+
},
|
|
379
|
+
updateConfig: partial => {
|
|
380
|
+
if (!open) {
|
|
381
|
+
throw new CellError({
|
|
382
|
+
code: 'CELL_MODULE_ERROR',
|
|
383
|
+
message: `${name} changed the configuration after its factory returned.`,
|
|
384
|
+
file: source.file,
|
|
385
|
+
hint: 'Call cell.updateConfig() in the factory.',
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
const external = partial.build?.external ?? [];
|
|
389
|
+
config.build.external = [...new Set([...config.build.external, ...external])];
|
|
390
|
+
if (partial.vite) {
|
|
391
|
+
config.vite = ModuleHost.merge(partial.vite, config.vite as Record<string, unknown>);
|
|
392
|
+
}
|
|
393
|
+
record.config.push(...external.map(e => `build.external: ${e}`), ...Object.keys(partial.vite ?? {}).map(k => `vite.${k}`));
|
|
394
|
+
},
|
|
395
|
+
addConfigSchema: (key, schema) => {
|
|
396
|
+
claim(key);
|
|
397
|
+
this.schemas.set(key, { source: name, value: schema });
|
|
398
|
+
},
|
|
399
|
+
addVitePlugin: (plugin, options) => {
|
|
400
|
+
this.plugins.push({ source: name, value: { plugin, env: options?.env } });
|
|
401
|
+
record.vitePlugins.push({ name: plugin.name, ...(options?.env ? { env: options.env } : {}) });
|
|
402
|
+
},
|
|
403
|
+
addRuntimeModule: (path, options) => {
|
|
404
|
+
const specifier = path.startsWith('.') ? resolvePath(config.root, path) : path;
|
|
405
|
+
this.runtimeModules.push({ target: options.target, specifier, static: options.static ?? false, component: name });
|
|
406
|
+
record.runtimeModules.push({ target: options.target, path: specifier, static: options.static ?? false });
|
|
407
|
+
},
|
|
408
|
+
addVirtualModule: (id, code) => {
|
|
409
|
+
this.virtualModules.set(id, { source: name, value: code });
|
|
410
|
+
record.virtualModules.push(id);
|
|
411
|
+
},
|
|
412
|
+
setEntry: (target, path) => {
|
|
413
|
+
const entry = path.startsWith('.') ? resolvePath(config.root, path) : path;
|
|
414
|
+
this.entries[target] = entry;
|
|
415
|
+
record.entries[target] = entry;
|
|
416
|
+
},
|
|
417
|
+
addDevHandler: (path, handler) => {
|
|
418
|
+
this.devHandlers.push({ source: name, value: { path, handler } });
|
|
419
|
+
record.devHandlers.push(path);
|
|
420
|
+
},
|
|
421
|
+
addWatchFile: path => {
|
|
422
|
+
const file = resolvePath(config.root, path);
|
|
423
|
+
this.watchFiles.push(file);
|
|
424
|
+
record.watchFiles.push(file);
|
|
425
|
+
},
|
|
426
|
+
addPreset: (preset: Preset) => {
|
|
427
|
+
presets.register(preset);
|
|
428
|
+
record.presets.push(preset.name);
|
|
429
|
+
},
|
|
430
|
+
addOutputFile: (path, content) => {
|
|
431
|
+
this.outputFiles.set(path, { source: name, value: content });
|
|
432
|
+
record.outputFiles.push(path);
|
|
433
|
+
},
|
|
434
|
+
addCheck: check => {
|
|
435
|
+
this.checks.push({ source: name, value: check });
|
|
436
|
+
record.checks.push(check.name);
|
|
437
|
+
},
|
|
438
|
+
addMcpTool: tool => {
|
|
439
|
+
this.mcpTools.push({ source: name, value: tool });
|
|
440
|
+
record.mcpTools.push(tool.name);
|
|
441
|
+
},
|
|
442
|
+
addDocs: dir => {
|
|
443
|
+
const path = resolvePath(source.file, '..', dir);
|
|
444
|
+
this.docs.push({ source: name, value: path });
|
|
445
|
+
record.docs.push(path);
|
|
446
|
+
},
|
|
447
|
+
on: (event: CellEventName, handler) => {
|
|
448
|
+
if (!record.events.includes(event)) {
|
|
449
|
+
record.events.push(event);
|
|
450
|
+
}
|
|
451
|
+
return events.on(event, handler, name);
|
|
452
|
+
},
|
|
453
|
+
events: {
|
|
454
|
+
on: (event, handler) => {
|
|
455
|
+
this.bus.set(event, [...(this.bus.get(event) ?? []), handler]);
|
|
456
|
+
return () =>
|
|
457
|
+
this.bus.set(
|
|
458
|
+
event,
|
|
459
|
+
(this.bus.get(event) ?? []).filter(h => h !== handler),
|
|
460
|
+
);
|
|
461
|
+
},
|
|
462
|
+
emit: async (event, payload) => {
|
|
463
|
+
for (const handler of [...(this.bus.get(event) ?? [])]) {
|
|
464
|
+
await handler(payload);
|
|
465
|
+
}
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
exec: (command, args = [], options = {}) =>
|
|
469
|
+
new Promise(resolve => {
|
|
470
|
+
execFile(
|
|
471
|
+
command,
|
|
472
|
+
args,
|
|
473
|
+
{ cwd: options.cwd ?? config.root, signal: options.signal, timeout: options.timeout, maxBuffer: 64 * 1024 * 1024 },
|
|
474
|
+
(error, stdout, stderr) => {
|
|
475
|
+
const code = error ? (typeof (error as { code?: unknown }).code === 'number' ? (error as { code: number }).code : 1) : 0;
|
|
476
|
+
resolve({ code, stdout: String(stdout), stderr: String(stderr) });
|
|
477
|
+
},
|
|
478
|
+
);
|
|
479
|
+
}),
|
|
480
|
+
resolve: specifier => require.resolve(specifier),
|
|
481
|
+
};
|
|
482
|
+
return {
|
|
483
|
+
cell,
|
|
484
|
+
close: () => {
|
|
485
|
+
open = false;
|
|
486
|
+
},
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { definePreset } from '@celljs/kit';
|
|
2
|
+
import { cloudflarePreset } from './cloudflare/cloudflare-preset.js';
|
|
3
|
+
import { fcPreset } from './fc/fc-preset.js';
|
|
4
|
+
import { lambdaPreset } from './lambda/lambda-preset.js';
|
|
5
|
+
import { scfPreset } from './scf/scf-preset.js';
|
|
6
|
+
import { vercelPreset } from './vercel/vercel-preset.js';
|
|
7
|
+
|
|
8
|
+
/** A Node.js HTTP server: `node server/index.mjs` listens on `cell.server.port` (override with `CELL_BACKEND__SERVER__PORT`). */
|
|
9
|
+
export const nodePreset = definePreset({
|
|
10
|
+
name: 'node',
|
|
11
|
+
description: 'Node.js HTTP server',
|
|
12
|
+
entry: 'http',
|
|
13
|
+
format: 'esm',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A Node.js command-line application: `node server/index.mjs` starts the application without a server;
|
|
18
|
+
* its components do the work (an `ApplicationLifecycle` reads arguments, opens a terminal UI, ...).
|
|
19
|
+
*/
|
|
20
|
+
export const cliPreset = definePreset({
|
|
21
|
+
name: 'cli',
|
|
22
|
+
description: 'Node.js command-line application (no server)',
|
|
23
|
+
format: 'esm',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const BUILTIN_PRESETS = [nodePreset, cloudflarePreset, cliPreset, fcPreset, scfPreset, lambdaPreset, vercelPreset];
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join, relative } from 'node:path';
|
|
4
|
+
import { CellError, type DeployContext, type Deployment, type DeployPlan, type DeployResource, defineDeployer } from '@celljs/kit';
|
|
5
|
+
import { Wrangler } from './wrangler.js';
|
|
6
|
+
import { WranglerConfig, type WranglerJson } from './wrangler-config.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Deploys the output of the cloudflare preset with Wrangler. `plan` runs `wrangler deploy --dry-run`,
|
|
10
|
+
* which bundles the worker and checks the configuration without uploading; `apply` runs `wrangler deploy`.
|
|
11
|
+
*/
|
|
12
|
+
export class CloudflareDeployment {
|
|
13
|
+
static readonly AUTH_HINT =
|
|
14
|
+
'Set CLOUDFLARE_API_TOKEN (a token with the "Edit Cloudflare Workers" template; also CLOUDFLARE_ACCOUNT_ID if it can access several accounts), or run `npx wrangler login` once.';
|
|
15
|
+
|
|
16
|
+
static readonly SUBDOMAIN_HINT =
|
|
17
|
+
'Register the workers.dev subdomain of the account once (open Workers & Pages in the Cloudflare dashboard, the link in the message), or deploy to your own domain with `routes` in wrangler.jsonc.';
|
|
18
|
+
|
|
19
|
+
protected readonly wrangler: Wrangler;
|
|
20
|
+
protected readonly file: string;
|
|
21
|
+
|
|
22
|
+
constructor(protected readonly context: DeployContext) {
|
|
23
|
+
this.wrangler = new Wrangler(context.root, context.env);
|
|
24
|
+
this.file = join(context.outDir, WranglerConfig.OUTPUT_FILE);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async plan(): Promise<DeployPlan> {
|
|
28
|
+
const config = this.readConfig();
|
|
29
|
+
const outdir = mkdtempSync(join(tmpdir(), 'cell-wrangler-'));
|
|
30
|
+
this.context.info('Checking the worker with wrangler deploy --dry-run…');
|
|
31
|
+
try {
|
|
32
|
+
const result = await this.wrangler.run(['deploy', '--dry-run', '--config', this.file, '--outdir', outdir], this.relay);
|
|
33
|
+
if (result.code !== 0) {
|
|
34
|
+
throw this.failure('CELL_DEPLOY_PLAN_FAILED', 'wrangler deploy --dry-run', result.output);
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
deployer: 'cloudflare',
|
|
38
|
+
resources: this.resources(config, result.output),
|
|
39
|
+
details: {
|
|
40
|
+
config: relative(this.context.root, this.file),
|
|
41
|
+
wrangler: result.source === 'project' ? 'project' : Wrangler.PACKAGE,
|
|
42
|
+
credentials: this.context.env.CLOUDFLARE_API_TOKEN ? 'CLOUDFLARE_API_TOKEN' : 'wrangler login',
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
} finally {
|
|
46
|
+
rmSync(outdir, { recursive: true, force: true });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async apply(_plan: DeployPlan): Promise<Deployment> {
|
|
51
|
+
this.readConfig();
|
|
52
|
+
const result = await this.wrangler.run(['deploy', '--config', this.file], this.relay);
|
|
53
|
+
if (result.code !== 0) {
|
|
54
|
+
throw this.failure('CELL_DEPLOY_FAILED', 'wrangler deploy', result.output);
|
|
55
|
+
}
|
|
56
|
+
const url = CloudflareDeployment.urlOf(result.output);
|
|
57
|
+
const version = /Current Version ID:\s*(\S+)/.exec(result.output)?.[1];
|
|
58
|
+
return { url, details: version ? { versionId: version } : undefined };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Where the worker answers: its first custom domain, else its workers.dev address (as Wrangler lists them after deploying). */
|
|
62
|
+
static urlOf(output: string): string | undefined {
|
|
63
|
+
const domain = /^\s+(\S+) \(custom domain\)\s*$/m.exec(output)?.[1];
|
|
64
|
+
return domain ? `https://${domain}` : /https:\/\/\S+\.workers\.dev\b/.exec(output)?.[0];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
protected readonly relay = (chunk: string, stream: 'stdout' | 'stderr') => this.context.relay(chunk, stream);
|
|
68
|
+
|
|
69
|
+
protected readConfig(): WranglerJson {
|
|
70
|
+
if (this.context.manifest.preset !== 'cloudflare' || !existsSync(this.file)) {
|
|
71
|
+
throw new CellError({
|
|
72
|
+
code: 'CELL_DEPLOY_OUTPUT_MISMATCH',
|
|
73
|
+
message: `${this.context.outDir} has no output of the cloudflare preset (built with: ${this.context.manifest.preset ?? 'no preset'}).`,
|
|
74
|
+
file: join(this.context.outDir, 'manifest.json'),
|
|
75
|
+
hint: 'Run `cell deploy --preset cloudflare` without --skip-build, or `cell build --preset cloudflare` first.',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return JSON.parse(readFileSync(this.file, 'utf8')) as WranglerJson;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The worker and its assets, with the sizes Wrangler reported in the dry run. */
|
|
82
|
+
protected resources(config: WranglerJson, output: string): DeployResource[] {
|
|
83
|
+
const name = String(config.name);
|
|
84
|
+
const upload = /Total Upload:\s*(.+)/.exec(output)?.[1]?.trim();
|
|
85
|
+
const files = /Read (\d+) files? from the assets directory/.exec(output)?.[1];
|
|
86
|
+
const resources: DeployResource[] = [];
|
|
87
|
+
if (config.main) {
|
|
88
|
+
resources.push({
|
|
89
|
+
type: 'worker',
|
|
90
|
+
name,
|
|
91
|
+
action: 'deploy',
|
|
92
|
+
details: {
|
|
93
|
+
main: config.main,
|
|
94
|
+
compatibilityDate: config.compatibility_date,
|
|
95
|
+
compatibilityFlags: config.compatibility_flags,
|
|
96
|
+
...(upload ? { upload } : {}),
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const directory = (config.assets as { directory?: string } | undefined)?.directory;
|
|
101
|
+
if (directory) {
|
|
102
|
+
resources.push({ type: 'assets', name, action: 'deploy', details: { directory, ...(files ? { files: Number(files) } : {}) } });
|
|
103
|
+
}
|
|
104
|
+
return resources;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
protected failure(code: string, step: string, output: string): CellError {
|
|
108
|
+
return new CellError({
|
|
109
|
+
code,
|
|
110
|
+
message: `${step} failed: ${Wrangler.errorOf(output)}`,
|
|
111
|
+
file: this.file,
|
|
112
|
+
hint: Wrangler.isSubdomainError(output)
|
|
113
|
+
? CloudflareDeployment.SUBDOMAIN_HINT
|
|
114
|
+
: Wrangler.isAuthError(output)
|
|
115
|
+
? CloudflareDeployment.AUTH_HINT
|
|
116
|
+
: 'Fix the reported problem (Wrangler printed the details above), then run cell deploy again.',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export const cloudflareDeployer = defineDeployer({
|
|
122
|
+
name: 'cloudflare',
|
|
123
|
+
description: "Cloudflare Workers through Wrangler (the project's, or wrangler@4 installed on first use)",
|
|
124
|
+
plan: context => new CloudflareDeployment(context).plan(),
|
|
125
|
+
apply: (context, plan) => new CloudflareDeployment(context).apply(plan),
|
|
126
|
+
});
|