@celljs/cli 3.9.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 -76
- 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 -76
- 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 -76
- 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 -76
- 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 -77
- 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 -76
- 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 -76
- 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 -76
- package/templates/microservice/examples/backend-app/README.md +0 -76
- 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 -76
- 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 -76
- 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 -76
- 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 -76
- 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 -76
- 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 -76
- 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,189 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join, relative, resolve, sep } from 'node:path';
|
|
3
|
+
import { CellError, type OutputManifest, type ProjectModel } from '@celljs/kit';
|
|
4
|
+
import { CellBuilder, type CellBuilderOptions } from '@celljs/vite';
|
|
5
|
+
import { ExecutableCompiler } from '../build/executable-compiler.js';
|
|
6
|
+
import { type ConfigFlags, ConfigResolver } from '../config/config-resolver.js';
|
|
7
|
+
import type { CompileTarget } from '../config/types.js';
|
|
8
|
+
import { ProjectInspector } from '../info/project-inspector.js';
|
|
9
|
+
import { PresetOutput } from '../preset/preset-output.js';
|
|
10
|
+
import { Toolchain } from '../toolchain/toolchain.js';
|
|
11
|
+
import { Command, type CommandContext, type ParsedValues } from './command.js';
|
|
12
|
+
import type { Reporter } from './reporter.js';
|
|
13
|
+
|
|
14
|
+
export interface BuildResult {
|
|
15
|
+
options: CellBuilderOptions;
|
|
16
|
+
model: ProjectModel;
|
|
17
|
+
/** Absolute output directory. */
|
|
18
|
+
outDir: string;
|
|
19
|
+
manifest: OutputManifest;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** `cell build`: build every target into the output directory, as the preset prescribes. */
|
|
23
|
+
export class BuildCommand extends Command {
|
|
24
|
+
readonly name = 'build';
|
|
25
|
+
readonly description = 'Build the application into .cell/output';
|
|
26
|
+
/** Options that decide what is built; `cell info` accepts the same ones. */
|
|
27
|
+
static readonly OPTIONS = {
|
|
28
|
+
preset: { type: 'string' },
|
|
29
|
+
mode: { type: 'string', short: 'm', multiple: true },
|
|
30
|
+
format: { type: 'string' },
|
|
31
|
+
single: { type: 'boolean' },
|
|
32
|
+
compile: { type: 'string' },
|
|
33
|
+
'compile-target': { type: 'string' },
|
|
34
|
+
sourcemap: { type: 'boolean' },
|
|
35
|
+
'out-dir': { type: 'string' },
|
|
36
|
+
} as const;
|
|
37
|
+
static readonly USAGE = [
|
|
38
|
+
'--preset <name> shape of the output: node (default), cloudflare, cli',
|
|
39
|
+
'-m, --mode <mode> extra mode, reads cell.<mode>.yml (repeatable)',
|
|
40
|
+
'--format <esm|cjs> server bundle format',
|
|
41
|
+
'--single embed the frontend in server/index.mjs: one file runs the whole app',
|
|
42
|
+
'--compile [tool] one executable .cell/output/app: bun (default), node or deno',
|
|
43
|
+
'--compile-target <t> cross-compile with bun or deno, e.g. bun-linux-x64',
|
|
44
|
+
'--sourcemap emit source maps',
|
|
45
|
+
'--out-dir <dir> output directory (default: .cell/output)',
|
|
46
|
+
];
|
|
47
|
+
override readonly options = BuildCommand.OPTIONS;
|
|
48
|
+
override readonly usage = BuildCommand.USAGE;
|
|
49
|
+
|
|
50
|
+
static flags(values: ParsedValues): ConfigFlags {
|
|
51
|
+
const format = values.format as string | undefined;
|
|
52
|
+
if (format !== undefined && format !== 'esm' && format !== 'cjs') {
|
|
53
|
+
throw new CellError({ code: 'CELL_ARGUMENT_INVALID', message: `Invalid --format '${format}'.`, hint: 'Use --format esm or --format cjs.' });
|
|
54
|
+
}
|
|
55
|
+
const compile = values.compile as string | undefined;
|
|
56
|
+
if (compile !== undefined && !['bun', 'node', 'deno'].includes(compile)) {
|
|
57
|
+
throw new CellError({
|
|
58
|
+
code: 'CELL_ARGUMENT_INVALID',
|
|
59
|
+
message: `Invalid --compile '${compile}'.`,
|
|
60
|
+
hint: 'Use --compile, --compile bun, --compile node or --compile deno.',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return {
|
|
64
|
+
preset: values.preset as string | undefined,
|
|
65
|
+
mode: values.mode as string[] | undefined,
|
|
66
|
+
format,
|
|
67
|
+
single: values.single as boolean | undefined,
|
|
68
|
+
compile: compile as CompileTarget | undefined,
|
|
69
|
+
sourcemap: values.sourcemap as boolean | undefined,
|
|
70
|
+
outDir: values['out-dir'] as string | undefined,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Files of modules (`cell.addOutputFile`), relative to the output directory, which they must not leave. */
|
|
75
|
+
static writeFiles(outDir: string, files: Record<string, string | Uint8Array>): void {
|
|
76
|
+
for (const [path, content] of Object.entries(files)) {
|
|
77
|
+
const file = resolve(outDir, path);
|
|
78
|
+
if (!file.startsWith(outDir + sep)) {
|
|
79
|
+
throw new CellError({
|
|
80
|
+
code: 'CELL_MODULE_ERROR',
|
|
81
|
+
message: `Output file '${path}' is outside the output directory.`,
|
|
82
|
+
hint: 'Pass a path relative to the output directory to cell.addOutputFile().',
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
86
|
+
writeFileSync(file, content);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async run({ values, reporter, env }: CommandContext): Promise<number> {
|
|
91
|
+
const started = performance.now();
|
|
92
|
+
const toolchain = await Toolchain.create({
|
|
93
|
+
root: values.root as string | undefined,
|
|
94
|
+
command: 'build',
|
|
95
|
+
flags: BuildCommand.flags(values),
|
|
96
|
+
env,
|
|
97
|
+
quiet: reporter.json,
|
|
98
|
+
logger: reporter,
|
|
99
|
+
});
|
|
100
|
+
const { config, preset } = toolchain;
|
|
101
|
+
const compileTarget = values['compile-target'] as string | undefined;
|
|
102
|
+
if (compileTarget !== undefined && !config.build.compile) {
|
|
103
|
+
throw new CellError({
|
|
104
|
+
code: 'CELL_ARGUMENT_INVALID',
|
|
105
|
+
message: '--compile-target needs --compile.',
|
|
106
|
+
hint: 'Use --compile bun --compile-target bun-linux-x64, for example.',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
const { options, model, manifest } = await BuildCommand.build(toolchain, reporter, env, compileTarget);
|
|
110
|
+
await toolchain.close();
|
|
111
|
+
const outDir = relative(process.cwd(), `${config.root}/${options.outDir}`) || '.';
|
|
112
|
+
const durationMs = Math.round(performance.now() - started);
|
|
113
|
+
reporter.result(
|
|
114
|
+
'build',
|
|
115
|
+
{
|
|
116
|
+
root: config.root,
|
|
117
|
+
preset: preset.name,
|
|
118
|
+
format: options.format,
|
|
119
|
+
mode: config.mode,
|
|
120
|
+
targets: model.targets,
|
|
121
|
+
outDir: options.outDir,
|
|
122
|
+
entry: model.backend?.entry,
|
|
123
|
+
...(manifest.single ? { single: true } : {}),
|
|
124
|
+
...(manifest.executable ? { executable: manifest.executable } : {}),
|
|
125
|
+
durationMs,
|
|
126
|
+
},
|
|
127
|
+
manifest.executable
|
|
128
|
+
? `Built ${model.targets.join(' + ')} → ${join(outDir, manifest.executable.file)} in ${durationMs}ms`
|
|
129
|
+
: `Built ${model.targets.join(' + ')}${manifest.single ? ' (single file)' : ''} → ${outDir} in ${durationMs}ms`,
|
|
130
|
+
);
|
|
131
|
+
return 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Builds every target and writes the files of the preset and of modules: `cell build`, and `cell deploy` before it deploys. */
|
|
135
|
+
static async build(toolchain: Toolchain, reporter: Reporter, env: NodeJS.ProcessEnv, compileTarget?: string): Promise<BuildResult> {
|
|
136
|
+
const { config, preset, events } = toolchain;
|
|
137
|
+
const options = toolchain.builderOptions();
|
|
138
|
+
const cancelled = await events.gate('build:before', { config, preset });
|
|
139
|
+
if (cancelled) {
|
|
140
|
+
throw new CellError({
|
|
141
|
+
code: 'CELL_BUILD_CANCELLED',
|
|
142
|
+
message: `The build was cancelled: ${cancelled.reason}.`,
|
|
143
|
+
hint: 'Fix the reported hook or module, then build again.',
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
reporter.info(`Building with the ${preset.name} preset (${options.format}, mode ${config.mode.join(', ')})…`);
|
|
147
|
+
const model = await new CellBuilder({ ...options, env, logLevel: 'warn' }).build();
|
|
148
|
+
if (model.backend && preset.entry && !model.backend.entryComponent && !options.entry?.backend) {
|
|
149
|
+
reporter.warn(ProjectInspector.missingEntryWarning(preset));
|
|
150
|
+
}
|
|
151
|
+
// Backend variables matter where the server runs, not here; `cell info` checks them.
|
|
152
|
+
for (const problem of model.frontend?.envOverrides.problems ?? []) {
|
|
153
|
+
reporter.warn(ProjectInspector.envProblemWarning('frontend', problem));
|
|
154
|
+
}
|
|
155
|
+
const outDir = resolve(config.root, options.outDir ?? ConfigResolver.DEFAULT_OUT_DIR);
|
|
156
|
+
let manifest = await PresetOutput.write(preset, {
|
|
157
|
+
root: config.root,
|
|
158
|
+
outDir,
|
|
159
|
+
project: model,
|
|
160
|
+
env,
|
|
161
|
+
options: toolchain.presetOptions(),
|
|
162
|
+
warn: message => reporter.warn(message),
|
|
163
|
+
});
|
|
164
|
+
if (config.build.single && !manifest.single) {
|
|
165
|
+
reporter.warn(
|
|
166
|
+
'--single embeds the frontend in the server bundle, but the project does not build both a frontend and a backend: the output is as without it.',
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
if (config.build.compile) {
|
|
170
|
+
manifest = new ExecutableCompiler({
|
|
171
|
+
outDir,
|
|
172
|
+
manifest,
|
|
173
|
+
compiler: config.build.compile,
|
|
174
|
+
target: compileTarget,
|
|
175
|
+
env,
|
|
176
|
+
info: m => reporter.info(m),
|
|
177
|
+
}).compile();
|
|
178
|
+
writeFileSync(join(outDir, PresetOutput.MANIFEST), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
179
|
+
} else if (manifest.single && existsSync(join(outDir, 'server', 'node_modules'))) {
|
|
180
|
+
reporter.warn('server/node_modules (packages kept outside the bundle) must stay next to server/index.* for the single file to run.');
|
|
181
|
+
}
|
|
182
|
+
const files: Record<string, string | Uint8Array> = Object.fromEntries([...toolchain.modules.outputFiles].map(([path, { value }]) => [path, value]));
|
|
183
|
+
// build:done handlers may add, change or remove files before they are written.
|
|
184
|
+
const done = await events.emit('build:done', { config, preset, project: model, outDir: options.outDir, files });
|
|
185
|
+
BuildCommand.writeFiles(outDir, done.files);
|
|
186
|
+
await events.emit('output:done', { config, preset, outDir: done.outDir });
|
|
187
|
+
return { options, model, outDir, manifest };
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { parseArgs } from 'node:util';
|
|
3
|
+
import { CellError } from '@celljs/kit';
|
|
4
|
+
import { TextUtil } from '../utils/text-util.js';
|
|
5
|
+
import { AgentCommand } from './agent-command.js';
|
|
6
|
+
import { BuildCommand } from './build-command.js';
|
|
7
|
+
import { CheckCommand } from './check-command.js';
|
|
8
|
+
import type { Command, ParseArgsOptions, ParsedValues } from './command.js';
|
|
9
|
+
import { ConfigCommand } from './config-command.js';
|
|
10
|
+
import { DeployCommand } from './deploy-command.js';
|
|
11
|
+
import { DevCommand } from './dev-command.js';
|
|
12
|
+
import { DocsCommand } from './docs-command.js';
|
|
13
|
+
import { InfoCommand } from './info-command.js';
|
|
14
|
+
import { InitCommand } from './init-command.js';
|
|
15
|
+
import { McpCommand } from './mcp-command.js';
|
|
16
|
+
import { PreviewCommand } from './preview-command.js';
|
|
17
|
+
import { Reporter, type Writable } from './reporter.js';
|
|
18
|
+
|
|
19
|
+
export interface CellCliOptions {
|
|
20
|
+
stdout?: Writable;
|
|
21
|
+
stderr?: Writable;
|
|
22
|
+
env?: NodeJS.ProcessEnv;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The `cell` command line. Never prompts; every command accepts `--json`; failures print a
|
|
27
|
+
* CellError and exit with 1, invalid usage with 2 (docs/design/agent-first.md R5, R6, R9).
|
|
28
|
+
*/
|
|
29
|
+
export class CellCli {
|
|
30
|
+
static readonly COMMON_OPTIONS: ParseArgsOptions = {
|
|
31
|
+
root: { type: 'string' },
|
|
32
|
+
json: { type: 'boolean' },
|
|
33
|
+
help: { type: 'boolean', short: 'h' },
|
|
34
|
+
};
|
|
35
|
+
static readonly COMPILE_TARGETS = ['bun', 'node', 'deno'];
|
|
36
|
+
|
|
37
|
+
protected readonly commands: Command[] = [
|
|
38
|
+
new InitCommand(() => CellCli.version),
|
|
39
|
+
new DevCommand(),
|
|
40
|
+
new BuildCommand(),
|
|
41
|
+
new PreviewCommand(),
|
|
42
|
+
new DeployCommand(),
|
|
43
|
+
new InfoCommand(),
|
|
44
|
+
new CheckCommand(),
|
|
45
|
+
new ConfigCommand(),
|
|
46
|
+
new DocsCommand(),
|
|
47
|
+
new McpCommand(argv => this.capture(argv)),
|
|
48
|
+
new AgentCommand(() => CellCli.version),
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
constructor(protected readonly options: CellCliOptions = {}) {}
|
|
52
|
+
|
|
53
|
+
static get version(): string {
|
|
54
|
+
return JSON.parse(readFileSync(new URL('../../package.json', import.meta.url), 'utf8')).version;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async run(argv: string[]): Promise<number> {
|
|
58
|
+
const json = argv.includes('--json');
|
|
59
|
+
const reporter = new Reporter(json, this.options.stdout, this.options.stderr);
|
|
60
|
+
const [name, ...rest] = argv;
|
|
61
|
+
if (name === undefined || name === '--help' || name === '-h' || name === 'help') {
|
|
62
|
+
this.write(this.help());
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
if (name === '--version' || name === '-v') {
|
|
66
|
+
this.write(CellCli.version);
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
const command = this.commands.find(c => c.name === name);
|
|
70
|
+
try {
|
|
71
|
+
if (!command) {
|
|
72
|
+
const suggestion = TextUtil.closest(
|
|
73
|
+
name,
|
|
74
|
+
this.commands.map(c => c.name),
|
|
75
|
+
);
|
|
76
|
+
throw new CellError({
|
|
77
|
+
code: 'CELL_ARGUMENT_INVALID',
|
|
78
|
+
message: `Unknown command '${name}'.`,
|
|
79
|
+
hint: suggestion
|
|
80
|
+
? `Did you mean 'cell ${suggestion}'?`
|
|
81
|
+
: `Run 'cell --help' for the commands: ${this.commands.map(c => c.name).join(', ')}.`,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const { values, positionals } = this.parse(command, rest);
|
|
85
|
+
if (values.help) {
|
|
86
|
+
this.write(this.commandHelp(command));
|
|
87
|
+
return 0;
|
|
88
|
+
}
|
|
89
|
+
return await command.run({ values, positionals, reporter, env: this.options.env ?? process.env });
|
|
90
|
+
} catch (error) {
|
|
91
|
+
const cellError = Reporter.toCellError(error);
|
|
92
|
+
if (cellError.code === 'CELL_INTERNAL_ERROR' && (this.options.env ?? process.env).CELL_DEBUG) {
|
|
93
|
+
(this.options.stderr ?? process.stderr).write(`${(error as Error).stack}\n`);
|
|
94
|
+
}
|
|
95
|
+
reporter.error(command?.name, cellError);
|
|
96
|
+
return cellError.code === 'CELL_ARGUMENT_INVALID' ? 2 : 1;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
protected parse(command: Command, args: string[]): { values: ParsedValues; positionals: string[] } {
|
|
101
|
+
const options = { ...CellCli.COMMON_OPTIONS, ...command.options };
|
|
102
|
+
try {
|
|
103
|
+
const { values, positionals } = parseArgs({ args: this.normalizeCompile(args), options, allowPositionals: command.arguments !== '', strict: true });
|
|
104
|
+
return { values: values as ParsedValues, positionals };
|
|
105
|
+
} catch (error) {
|
|
106
|
+
const message = (error as Error).message.split('\n')[0];
|
|
107
|
+
const unknown = /Unknown option '(-{1,2}[^']+)'/.exec(message)?.[1];
|
|
108
|
+
const known = Object.keys(options).map(o => `--${o}`);
|
|
109
|
+
const suggestion = unknown && TextUtil.closest(unknown, known);
|
|
110
|
+
throw new CellError({
|
|
111
|
+
code: 'CELL_ARGUMENT_INVALID',
|
|
112
|
+
message,
|
|
113
|
+
hint: suggestion ? `Did you mean '${suggestion}'?` : `Run 'cell ${command.name} --help' for the options.`,
|
|
114
|
+
cause: error,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** `--compile` takes an optional target: a bare `--compile` means bun. */
|
|
120
|
+
protected normalizeCompile(args: string[]): string[] {
|
|
121
|
+
return args.flatMap((arg, i) => {
|
|
122
|
+
if (arg !== '--compile') {
|
|
123
|
+
return [arg];
|
|
124
|
+
}
|
|
125
|
+
const next = args[i + 1];
|
|
126
|
+
return next && CellCli.COMPILE_TARGETS.includes(next) ? [arg] : ['--compile=bun'];
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
protected help(): string {
|
|
131
|
+
const width = Math.max(...this.commands.map(c => c.name.length)) + 2;
|
|
132
|
+
return [
|
|
133
|
+
`cell ${CellCli.version}`,
|
|
134
|
+
'',
|
|
135
|
+
'Usage: cell <command> [options]',
|
|
136
|
+
'',
|
|
137
|
+
'Commands:',
|
|
138
|
+
...this.commands.map(c => ` ${c.name.padEnd(width)}${c.description}`),
|
|
139
|
+
'',
|
|
140
|
+
'Common options:',
|
|
141
|
+
' --root <dir> project root (default: current directory)',
|
|
142
|
+
' --json print one JSON result on stdout',
|
|
143
|
+
' -h, --help show help',
|
|
144
|
+
].join('\n');
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
protected commandHelp(command: Command): string {
|
|
148
|
+
return [
|
|
149
|
+
`Usage: cell ${command.name}${command.arguments ? ` ${command.arguments}` : ''} [options]`,
|
|
150
|
+
'',
|
|
151
|
+
command.description,
|
|
152
|
+
'',
|
|
153
|
+
'Options:',
|
|
154
|
+
...command.usage.map(line => ` ${line}`),
|
|
155
|
+
' --root <dir> project root',
|
|
156
|
+
' --json print one JSON result on stdout',
|
|
157
|
+
].join('\n');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Runs a command in this process with its stdout captured (`cell mcp`); stderr stays. */
|
|
161
|
+
protected async capture(argv: string[]): Promise<{ code: number; stdout: string }> {
|
|
162
|
+
let stdout = '';
|
|
163
|
+
const code = await new CellCli({
|
|
164
|
+
stdout: { write: chunk => (stdout += chunk) },
|
|
165
|
+
stderr: this.options.stderr ?? process.stderr,
|
|
166
|
+
env: this.options.env,
|
|
167
|
+
}).run(argv);
|
|
168
|
+
return { code, stdout };
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
protected write(text: string): void {
|
|
172
|
+
(this.options.stdout ?? process.stdout).write(`${text}\n`);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { relative } from 'node:path';
|
|
2
|
+
import type { CheckIssue } from '@celljs/kit';
|
|
3
|
+
import { ProjectChecker } from '../check/project-checker.js';
|
|
4
|
+
import { Toolchain } from '../toolchain/toolchain.js';
|
|
5
|
+
import { BuildCommand } from './build-command.js';
|
|
6
|
+
import { Command, type CommandContext } from './command.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `cell check`: configuration, types, decorator settings, DI bindings and module checks in one run.
|
|
10
|
+
* Exits with 1 when an error-level issue is found; `--json` lists every issue with a stable code.
|
|
11
|
+
*/
|
|
12
|
+
export class CheckCommand extends Command {
|
|
13
|
+
readonly name = 'check';
|
|
14
|
+
readonly description = 'Check configuration, types, decorators and DI bindings';
|
|
15
|
+
override readonly options = {
|
|
16
|
+
preset: BuildCommand.OPTIONS.preset,
|
|
17
|
+
mode: BuildCommand.OPTIONS.mode,
|
|
18
|
+
skip: { type: 'string', multiple: true },
|
|
19
|
+
} as const;
|
|
20
|
+
override readonly usage = [
|
|
21
|
+
'--preset <name> preset whose entry the backend uses (default: node)',
|
|
22
|
+
'-m, --mode <mode> extra mode, reads cell.<mode>.yml (repeatable)',
|
|
23
|
+
'--skip <check> skip a check: config, types, decorators, di or a module check (repeatable)',
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
async run({ values, reporter, env }: CommandContext): Promise<number> {
|
|
27
|
+
const started = performance.now();
|
|
28
|
+
const toolchain = await Toolchain.create({
|
|
29
|
+
root: values.root as string | undefined,
|
|
30
|
+
command: 'check',
|
|
31
|
+
flags: { preset: values.preset as string | undefined, mode: values.mode as string[] | undefined },
|
|
32
|
+
env,
|
|
33
|
+
quiet: reporter.json,
|
|
34
|
+
runHooks: false,
|
|
35
|
+
logger: reporter,
|
|
36
|
+
});
|
|
37
|
+
const reports = await new ProjectChecker(toolchain, { env, skip: values.skip as string[] | undefined }).run();
|
|
38
|
+
await toolchain.close();
|
|
39
|
+
const issues = reports.flatMap(report => report.issues.map(issue => ({ check: report.name, ...issue })));
|
|
40
|
+
const errors = issues.filter(issue => issue.level === 'error').length;
|
|
41
|
+
const warnings = issues.filter(issue => issue.level === 'warning').length;
|
|
42
|
+
const durationMs = Math.round(performance.now() - started);
|
|
43
|
+
const root = toolchain.config.root;
|
|
44
|
+
reporter.result(
|
|
45
|
+
'check',
|
|
46
|
+
{
|
|
47
|
+
root,
|
|
48
|
+
passed: errors === 0,
|
|
49
|
+
// `warnings` of the result are those of the command itself; the findings are in `issues`.
|
|
50
|
+
summary: { errors, warnings, info: issues.length - errors - warnings },
|
|
51
|
+
issues,
|
|
52
|
+
checks: reports.map(({ issues: found, ...report }) => ({ ...report, issues: found.length })),
|
|
53
|
+
durationMs,
|
|
54
|
+
},
|
|
55
|
+
[
|
|
56
|
+
...issues.filter(issue => issue.level !== 'info').map(issue => CheckCommand.formatIssue(issue, root)),
|
|
57
|
+
...reports.filter(report => report.skipped).map(report => `skipped ${report.name}: ${report.skipped}`),
|
|
58
|
+
`${errors === 0 ? 'Passed' : 'Failed'}: ${errors} error${errors === 1 ? '' : 's'}, ${warnings} warning${warnings === 1 ? '' : 's'} (${reports
|
|
59
|
+
.filter(r => !r.skipped)
|
|
60
|
+
.map(r => r.name)
|
|
61
|
+
.join(', ')}) in ${durationMs}ms`,
|
|
62
|
+
].join('\n'),
|
|
63
|
+
);
|
|
64
|
+
return errors === 0 ? 0 : 1;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** `src/a.ts:3:5 error TS2322 message`, like compilers print. */
|
|
68
|
+
static formatIssue(issue: CheckIssue & { check: string }, root: string): string {
|
|
69
|
+
const where = issue.file
|
|
70
|
+
? `${relative(root, issue.file) || issue.file}${issue.line ? `:${issue.line}${issue.column ? `:${issue.column}` : ''}` : ''} `
|
|
71
|
+
: '';
|
|
72
|
+
return `${where}${issue.level} ${issue.code} ${issue.message}${issue.hint ? `\n fix: ${issue.hint}` : ''}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ParseArgsConfig } from 'node:util';
|
|
2
|
+
|
|
3
|
+
export type ParseArgsOptions = NonNullable<ParseArgsConfig['options']>;
|
|
4
|
+
|
|
5
|
+
import type { Reporter } from './reporter.js';
|
|
6
|
+
|
|
7
|
+
export type ParsedValues = Record<string, string | boolean | string[] | undefined>;
|
|
8
|
+
|
|
9
|
+
export interface CommandContext {
|
|
10
|
+
values: ParsedValues;
|
|
11
|
+
positionals: string[];
|
|
12
|
+
reporter: Reporter;
|
|
13
|
+
env: NodeJS.ProcessEnv;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** One `cell <name>` command. Options are parsed with node:util `parseArgs`. */
|
|
17
|
+
export abstract class Command {
|
|
18
|
+
abstract readonly name: string;
|
|
19
|
+
abstract readonly description: string;
|
|
20
|
+
/** Options of this command in addition to the common ones (`--root`, `--json`, `--help`). */
|
|
21
|
+
readonly options: ParseArgsOptions = {};
|
|
22
|
+
/** One line per option for `--help`. */
|
|
23
|
+
readonly usage: string[] = [];
|
|
24
|
+
/** Positional arguments for `--help`, e.g. `get <key>`; commands without them reject positionals. */
|
|
25
|
+
readonly arguments: string = '';
|
|
26
|
+
|
|
27
|
+
/** Returns the process exit code. */
|
|
28
|
+
abstract run(context: CommandContext): Promise<number>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { CellError, type Target } from '@celljs/kit';
|
|
2
|
+
import { ProjectLoader } from '@celljs/vite';
|
|
3
|
+
import { ConfigExplainer, type ConfigValue } from '../config/config-explainer.js';
|
|
4
|
+
import { Toolchain } from '../toolchain/toolchain.js';
|
|
5
|
+
import { BuildCommand } from './build-command.js';
|
|
6
|
+
import { Command, type CommandContext } from './command.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `cell config get <key>`: one value of the merged application configuration (cell*.yml of every
|
|
10
|
+
* component and the active modes, then `CELL_<TARGET>__*` variables), with the files and variables
|
|
11
|
+
* that set it. Read-only, like `cell info`.
|
|
12
|
+
*/
|
|
13
|
+
export class ConfigCommand extends Command {
|
|
14
|
+
readonly name = 'config';
|
|
15
|
+
readonly description = 'Show a configuration value and where it comes from';
|
|
16
|
+
override readonly arguments = 'get <key>';
|
|
17
|
+
override readonly options = {
|
|
18
|
+
mode: BuildCommand.OPTIONS.mode,
|
|
19
|
+
target: { type: 'string' },
|
|
20
|
+
why: { type: 'boolean' },
|
|
21
|
+
} as const;
|
|
22
|
+
override readonly usage = [
|
|
23
|
+
'-m, --mode <mode> extra mode, reads cell.<mode>.yml (repeatable)',
|
|
24
|
+
'--target <target> backend or frontend (default: backend, else frontend)',
|
|
25
|
+
'--why list the files and variables that set the value',
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
async run({ values, positionals, reporter, env }: CommandContext): Promise<number> {
|
|
29
|
+
const [action, key, ...rest] = positionals;
|
|
30
|
+
if (action !== 'get' || key === undefined || rest.length > 0) {
|
|
31
|
+
throw new CellError({
|
|
32
|
+
code: 'CELL_ARGUMENT_INVALID',
|
|
33
|
+
message: action === 'get' ? 'cell config get takes one key.' : `Unknown config action '${action ?? ''}'.`,
|
|
34
|
+
hint: 'Use cell config get <key>, e.g. cell config get cell.server.port.',
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
const target = values.target as string | undefined;
|
|
38
|
+
if (target !== undefined && target !== 'backend' && target !== 'frontend') {
|
|
39
|
+
throw new CellError({
|
|
40
|
+
code: 'CELL_ARGUMENT_INVALID',
|
|
41
|
+
message: `Invalid --target '${target}'.`,
|
|
42
|
+
hint: 'Use --target backend or --target frontend.',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const toolchain = await Toolchain.create({
|
|
46
|
+
root: values.root as string | undefined,
|
|
47
|
+
command: 'config',
|
|
48
|
+
flags: { mode: values.mode as string[] | undefined },
|
|
49
|
+
env,
|
|
50
|
+
quiet: reporter.json,
|
|
51
|
+
runHooks: false,
|
|
52
|
+
logger: reporter,
|
|
53
|
+
});
|
|
54
|
+
await toolchain.close();
|
|
55
|
+
const model = new ProjectLoader({ ...toolchain.projectOptions(), env }).load();
|
|
56
|
+
const result = new ConfigExplainer(model, env).explain(key, target as Target | undefined);
|
|
57
|
+
reporter.result('config', { ...result }, ConfigCommand.format(result, values.why === true));
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static format(result: ConfigValue, why: boolean): string {
|
|
62
|
+
const value = typeof result.value === 'string' ? result.value : JSON.stringify(result.value, null, 2);
|
|
63
|
+
if (!why) {
|
|
64
|
+
return value;
|
|
65
|
+
}
|
|
66
|
+
return [
|
|
67
|
+
`${result.key} (${result.target}) = ${value}`,
|
|
68
|
+
...result.layers.map(layer => ` ${layer.file}${layer.section === 'shared' ? '' : ` [${layer.section}]`}: ${JSON.stringify(layer.value)}`),
|
|
69
|
+
...result.env.map(({ variable, path }) => ` ${variable} → ${path}`),
|
|
70
|
+
...(result.expressions ? [' ${...} is evaluated by the server at startup'] : []),
|
|
71
|
+
].join('\n');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { relative, resolve } from 'node:path';
|
|
2
|
+
import { CellError, type Deployment, type DeployPlan, type OutputManifest } from '@celljs/kit';
|
|
3
|
+
import { ConfigResolver } from '../config/config-resolver.js';
|
|
4
|
+
import { DeployerRegistry } from '../deploy/deployer-registry.js';
|
|
5
|
+
import { PresetOutput } from '../preset/preset-output.js';
|
|
6
|
+
import { Toolchain } from '../toolchain/toolchain.js';
|
|
7
|
+
import { BuildCommand } from './build-command.js';
|
|
8
|
+
import { Command, type CommandContext } from './command.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* `cell deploy`: build with the preset, then publish the output with the preset's deployer. The
|
|
12
|
+
* deployer plans first; `--dry-run` prints the plan and changes nothing (docs/design/agent-first.md R9).
|
|
13
|
+
*/
|
|
14
|
+
export class DeployCommand extends Command {
|
|
15
|
+
readonly name = 'deploy';
|
|
16
|
+
readonly description = 'Build and deploy the application (--dry-run to only plan)';
|
|
17
|
+
override readonly options = {
|
|
18
|
+
preset: BuildCommand.OPTIONS.preset,
|
|
19
|
+
mode: BuildCommand.OPTIONS.mode,
|
|
20
|
+
sourcemap: BuildCommand.OPTIONS.sourcemap,
|
|
21
|
+
'out-dir': BuildCommand.OPTIONS['out-dir'],
|
|
22
|
+
'dry-run': { type: 'boolean' },
|
|
23
|
+
'skip-build': { type: 'boolean' },
|
|
24
|
+
} as const;
|
|
25
|
+
override readonly usage = [
|
|
26
|
+
'--preset <name> platform: cloudflare, fc, scf, lambda or vercel',
|
|
27
|
+
'-m, --mode <mode> extra mode, reads cell.<mode>.yml (repeatable)',
|
|
28
|
+
'--dry-run build and plan only; nothing is deployed',
|
|
29
|
+
'--skip-build deploy the existing output in --out-dir',
|
|
30
|
+
'--sourcemap emit source maps',
|
|
31
|
+
'--out-dir <dir> output directory (default: .cell/output)',
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
async run({ values, reporter, env }: CommandContext): Promise<number> {
|
|
35
|
+
const started = performance.now();
|
|
36
|
+
const dryRun = values['dry-run'] === true;
|
|
37
|
+
const toolchain = await Toolchain.create({
|
|
38
|
+
root: values.root as string | undefined,
|
|
39
|
+
command: 'deploy',
|
|
40
|
+
flags: BuildCommand.flags(values),
|
|
41
|
+
env,
|
|
42
|
+
quiet: reporter.json,
|
|
43
|
+
logger: reporter,
|
|
44
|
+
});
|
|
45
|
+
const { config, events } = toolchain;
|
|
46
|
+
const outDir = resolve(config.root, config.build.outDir);
|
|
47
|
+
const existing = values['skip-build'] ? this.existingOutput(toolchain, outDir) : undefined;
|
|
48
|
+
// Checked before building: a preset without a deployer fails fast.
|
|
49
|
+
const preset = existing ? toolchain.presets.resolve(existing.preset ?? ConfigResolver.DEFAULT_PRESET) : toolchain.preset;
|
|
50
|
+
if (!preset.deployer) {
|
|
51
|
+
throw new CellError({
|
|
52
|
+
code: 'CELL_DEPLOY_UNSUPPORTED',
|
|
53
|
+
message: `The ${preset.name} preset has no deployer; its output in ${relative(process.cwd(), outDir) || '.'} runs wherever you start it.`,
|
|
54
|
+
file: config.preset.source === 'config' ? config.file : undefined,
|
|
55
|
+
hint: `Deploy with a preset that has a deployer: --preset ${DeployCommand.deployable(toolchain).join(', --preset ')}.`,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const deployer = DeployerRegistry.builtin().get(preset.deployer);
|
|
59
|
+
const manifest = existing ?? (await BuildCommand.build(toolchain, reporter, env)).manifest;
|
|
60
|
+
const context = {
|
|
61
|
+
root: config.root,
|
|
62
|
+
outDir,
|
|
63
|
+
manifest,
|
|
64
|
+
env,
|
|
65
|
+
options: toolchain.presetOptions(preset.name),
|
|
66
|
+
info: (message: string) => reporter.info(message),
|
|
67
|
+
warn: (message: string) => reporter.warn(message),
|
|
68
|
+
relay: (chunk: string, stream: 'stdout' | 'stderr') => reporter.relay(chunk, stream),
|
|
69
|
+
};
|
|
70
|
+
const cancelled = await events.gate('deploy:before', { config, preset, manifest, dryRun });
|
|
71
|
+
if (cancelled) {
|
|
72
|
+
throw new CellError({
|
|
73
|
+
code: 'CELL_DEPLOY_CANCELLED',
|
|
74
|
+
message: `The deployment was cancelled: ${cancelled.reason}.`,
|
|
75
|
+
hint: 'Fix the reported hook or module, then deploy again.',
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const { plan } = await events.emit('deploy:plan', { config, preset, plan: await deployer.plan(context) });
|
|
79
|
+
let deployment: Deployment | undefined;
|
|
80
|
+
if (!dryRun) {
|
|
81
|
+
reporter.info(`Deploying with ${deployer.name}…`);
|
|
82
|
+
deployment = await deployer.apply(context, plan);
|
|
83
|
+
await events.emit('deploy:done', { config, preset, plan, deployment });
|
|
84
|
+
}
|
|
85
|
+
await toolchain.close();
|
|
86
|
+
const durationMs = Math.round(performance.now() - started);
|
|
87
|
+
reporter.result(
|
|
88
|
+
'deploy',
|
|
89
|
+
{ root: config.root, preset: preset.name, deployer: deployer.name, dryRun, plan, ...(deployment ? { deployment } : {}), durationMs },
|
|
90
|
+
DeployCommand.describe(plan, deployment),
|
|
91
|
+
);
|
|
92
|
+
return 0;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** `--skip-build`: the output must exist and come from the preset this run chose. */
|
|
96
|
+
protected existingOutput(toolchain: Toolchain, outDir: string): OutputManifest {
|
|
97
|
+
const manifest = PresetOutput.read(outDir);
|
|
98
|
+
const chosen = toolchain.config.preset;
|
|
99
|
+
if (chosen.source !== 'default' && manifest.preset !== chosen.name) {
|
|
100
|
+
throw new CellError({
|
|
101
|
+
code: 'CELL_DEPLOY_OUTPUT_MISMATCH',
|
|
102
|
+
message: `The output in ${outDir} was built with the ${manifest.preset ?? 'unknown'} preset, not ${chosen.name}.`,
|
|
103
|
+
file: toolchain.config.file,
|
|
104
|
+
hint: `Run cell deploy without --skip-build, or cell build --preset ${chosen.name} first.`,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
return manifest;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Presets that have a deployer, for hints. */
|
|
111
|
+
static deployable(toolchain: Toolchain): string[] {
|
|
112
|
+
return toolchain.presets.names.filter(name => toolchain.presets.resolve(name).deployer);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
static describe(plan: DeployPlan, deployment?: Deployment): string {
|
|
116
|
+
const lines = plan.resources.map(r => ` ${r.action} ${r.type} ${r.name}${r.details ? ` ${JSON.stringify(r.details)}` : ''}`);
|
|
117
|
+
if (!deployment) {
|
|
118
|
+
return [`Plan (${plan.deployer}):`, ...lines, 'Nothing was deployed (--dry-run).'].join('\n');
|
|
119
|
+
}
|
|
120
|
+
return [`Deployed (${plan.deployer}):`, ...lines, ...(deployment.url ? [`URL: ${deployment.url}`] : [])].join('\n');
|
|
121
|
+
}
|
|
122
|
+
}
|