@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,232 @@
|
|
|
1
|
+
import { type FSWatcher, watch } from 'node:fs';
|
|
2
|
+
import { relative } from 'node:path';
|
|
3
|
+
import { CellError } from '@celljs/kit';
|
|
4
|
+
import { CellDevServer } from '@celljs/vite';
|
|
5
|
+
import type { Logger } from 'vite';
|
|
6
|
+
import { ConfigResolver } from '../config/config-resolver.js';
|
|
7
|
+
import { DevActivity } from '../mcp/dev-activity.js';
|
|
8
|
+
import { DevMcpEndpoint } from '../mcp/dev-mcp-endpoint.js';
|
|
9
|
+
import { Toolchain } from '../toolchain/toolchain.js';
|
|
10
|
+
import { BuildCommand } from './build-command.js';
|
|
11
|
+
import { Command, type CommandContext, type ParsedValues } from './command.js';
|
|
12
|
+
import type { Reporter } from './reporter.js';
|
|
13
|
+
|
|
14
|
+
type Outcome = { kind: 'restart'; files: string[] } | { kind: 'exit' };
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* `cell dev`: frontend and backend on one port with the `development` mode. The frontend has
|
|
18
|
+
* Vite's HMR, the backend reloads when one of its files changes, and a change of cell*.yml,
|
|
19
|
+
* package.json or cell.config.* restarts everything with a new toolchain. Runs until SIGINT/SIGTERM.
|
|
20
|
+
*/
|
|
21
|
+
export class DevCommand extends Command {
|
|
22
|
+
readonly name = 'dev';
|
|
23
|
+
readonly description = 'Run the application for development: one port, frontend HMR, backend reload';
|
|
24
|
+
override readonly options = {
|
|
25
|
+
preset: BuildCommand.OPTIONS.preset,
|
|
26
|
+
mode: BuildCommand.OPTIONS.mode,
|
|
27
|
+
port: { type: 'string', short: 'p' },
|
|
28
|
+
host: { type: 'string' },
|
|
29
|
+
} as const;
|
|
30
|
+
override readonly usage = [
|
|
31
|
+
'--preset <name> preset whose entry runs the backend (default: node)',
|
|
32
|
+
'-m, --mode <mode> extra mode, reads cell.<mode>.yml (repeatable); development is always on',
|
|
33
|
+
'-p, --port <port> port (default: cell.server.port, else 3000)',
|
|
34
|
+
'--host <host> interface to listen on (default: cell.server.host, else 127.0.0.1)',
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
async run({ values, reporter, env }: CommandContext): Promise<number> {
|
|
38
|
+
const port = DevCommand.port(values);
|
|
39
|
+
const restore = reporter.json ? DevCommand.consoleToStderr() : undefined;
|
|
40
|
+
const activity = new DevActivity();
|
|
41
|
+
const stopCapture = activity.captureConsole();
|
|
42
|
+
let current: CellDevServer | undefined;
|
|
43
|
+
const { CellCli } = await import('./cell-cli.js');
|
|
44
|
+
const mcp = new DevMcpEndpoint(() => current, activity, CellCli.version);
|
|
45
|
+
let first = true;
|
|
46
|
+
let address: { host: string; port: number } | undefined;
|
|
47
|
+
try {
|
|
48
|
+
for (;;) {
|
|
49
|
+
const started = performance.now();
|
|
50
|
+
let toolchain: Toolchain;
|
|
51
|
+
let server: CellDevServer;
|
|
52
|
+
let settle!: (outcome: Outcome) => void;
|
|
53
|
+
const outcome = new Promise<Outcome>(resolve => {
|
|
54
|
+
settle = resolve;
|
|
55
|
+
});
|
|
56
|
+
try {
|
|
57
|
+
toolchain = await Toolchain.create({
|
|
58
|
+
root: values.root as string | undefined,
|
|
59
|
+
command: 'dev',
|
|
60
|
+
flags: { preset: values.preset as string | undefined, mode: values.mode as string[] | undefined },
|
|
61
|
+
env,
|
|
62
|
+
quiet: reporter.json,
|
|
63
|
+
logger: reporter,
|
|
64
|
+
// A failing module handler is reported; development goes on (docs/design/modules.md §3.4).
|
|
65
|
+
onNotifyError: error => reporter.info(error.format()),
|
|
66
|
+
});
|
|
67
|
+
const { config, preset, events } = toolchain;
|
|
68
|
+
server = await new CellDevServer({
|
|
69
|
+
...toolchain.projectOptions(),
|
|
70
|
+
plugins: toolchain.modules.vitePlugins(),
|
|
71
|
+
devHandlers: [{ path: DevMcpEndpoint.PATH, handler: mcp.handler }, ...(toolchain.modules.devHandlerList as never[])],
|
|
72
|
+
watchFiles: toolchain.modules.watchFileList,
|
|
73
|
+
env,
|
|
74
|
+
preset: preset.name,
|
|
75
|
+
format: ConfigResolver.format(config, preset),
|
|
76
|
+
outDir: config.build.outDir,
|
|
77
|
+
vite: config.vite,
|
|
78
|
+
// A restart keeps the address the first start got.
|
|
79
|
+
port: address?.port ?? port,
|
|
80
|
+
host: address?.host ?? (values.host as string | undefined),
|
|
81
|
+
logLevel: reporter.json ? 'warn' : 'info',
|
|
82
|
+
logger: reporter.json ? DevCommand.stderrLogger(reporter) : undefined,
|
|
83
|
+
onRestart: files => settle({ kind: 'restart', files }),
|
|
84
|
+
onRequest: record => activity.recordRequest(record),
|
|
85
|
+
onReload: (files, error) => {
|
|
86
|
+
if (error) {
|
|
87
|
+
activity.recordError(error, files);
|
|
88
|
+
reporter.info(error.format());
|
|
89
|
+
} else {
|
|
90
|
+
reporter.info(`Reloaded the backend (${files.map(file => relative(config.root, file)).join(', ')})`);
|
|
91
|
+
}
|
|
92
|
+
void events.emit('dev:reload', { files, error: error?.toJSON() }).catch(e => reporter.info(DevCommand.format(e)));
|
|
93
|
+
},
|
|
94
|
+
}).start();
|
|
95
|
+
} catch (error) {
|
|
96
|
+
if (first) {
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
// A broken cell.config.ts or cell.yml: report it and try again on the next change.
|
|
100
|
+
reporter.info(DevCommand.format(error));
|
|
101
|
+
const next = await DevCommand.waitForConfigChange(values.root as string | undefined);
|
|
102
|
+
if (next.kind === 'exit') {
|
|
103
|
+
return 0;
|
|
104
|
+
}
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const { config, preset, events } = toolchain;
|
|
108
|
+
current = server;
|
|
109
|
+
address = server.address;
|
|
110
|
+
const stopOnSignal = DevCommand.onSignal(() => settle({ kind: 'exit' }));
|
|
111
|
+
await events.emit('dev:ready', { url: server.url, port: address.port });
|
|
112
|
+
if (server.error) {
|
|
113
|
+
activity.recordError(server.error);
|
|
114
|
+
reporter.info(server.error.format());
|
|
115
|
+
}
|
|
116
|
+
const mcpUrl = `${server.url}${DevMcpEndpoint.PATH}`;
|
|
117
|
+
const durationMs = Math.round(performance.now() - started);
|
|
118
|
+
if (first) {
|
|
119
|
+
reporter.result(
|
|
120
|
+
'dev',
|
|
121
|
+
{
|
|
122
|
+
root: config.root,
|
|
123
|
+
url: server.url,
|
|
124
|
+
port: address.port,
|
|
125
|
+
preset: preset.name,
|
|
126
|
+
mode: config.mode,
|
|
127
|
+
targets: server.project.targets,
|
|
128
|
+
mcp: mcpUrl,
|
|
129
|
+
durationMs,
|
|
130
|
+
...(server.error ? { backendError: server.error.toJSON() } : {}),
|
|
131
|
+
},
|
|
132
|
+
`Ready at ${server.url} (${server.project.targets.join(' + ')}, mode ${config.mode.join(', ')}) in ${durationMs}ms\n MCP endpoint for agents: ${mcpUrl}`,
|
|
133
|
+
);
|
|
134
|
+
first = false;
|
|
135
|
+
} else {
|
|
136
|
+
reporter.info(`Restarted at ${server.url} in ${durationMs}ms`);
|
|
137
|
+
}
|
|
138
|
+
const result = await outcome;
|
|
139
|
+
stopOnSignal();
|
|
140
|
+
current = undefined;
|
|
141
|
+
await server.close();
|
|
142
|
+
await toolchain.close(result.kind);
|
|
143
|
+
if (result.kind === 'exit') {
|
|
144
|
+
return 0;
|
|
145
|
+
}
|
|
146
|
+
reporter.info(`${result.files.map(file => relative(config.root, file)).join(', ')} changed, restarting…`);
|
|
147
|
+
}
|
|
148
|
+
} finally {
|
|
149
|
+
stopCapture();
|
|
150
|
+
restore?.();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
static port(values: ParsedValues): number | undefined {
|
|
155
|
+
const port = values.port as string | undefined;
|
|
156
|
+
if (port !== undefined && !/^\d+$/.test(port)) {
|
|
157
|
+
throw new CellError({ code: 'CELL_ARGUMENT_INVALID', message: `Invalid --port '${port}'.`, hint: 'Pass a port number, e.g. --port 3000.' });
|
|
158
|
+
}
|
|
159
|
+
return port === undefined ? undefined : Number(port);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/** Resolves once on SIGINT or SIGTERM; returns the function that stops listening. */
|
|
163
|
+
protected static onSignal(handler: () => void): () => void {
|
|
164
|
+
process.once('SIGINT', handler);
|
|
165
|
+
process.once('SIGTERM', handler);
|
|
166
|
+
return () => {
|
|
167
|
+
process.off('SIGINT', handler);
|
|
168
|
+
process.off('SIGTERM', handler);
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
protected static waitForConfigChange(root = process.cwd()): Promise<Outcome> {
|
|
173
|
+
return new Promise(resolve => {
|
|
174
|
+
let watcher: FSWatcher | undefined;
|
|
175
|
+
const done = (outcome: Outcome) => {
|
|
176
|
+
watcher?.close();
|
|
177
|
+
stop();
|
|
178
|
+
resolve(outcome);
|
|
179
|
+
};
|
|
180
|
+
const stop = DevCommand.onSignal(() => done({ kind: 'exit' }));
|
|
181
|
+
watcher = watch(root, (_event, file) => {
|
|
182
|
+
if (file && CellDevServer.CONFIG_FILE.test(file)) {
|
|
183
|
+
done({ kind: 'restart', files: [file] });
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** `--json`: stdout carries only the result line, so the application's console output goes to stderr. */
|
|
190
|
+
protected static consoleToStderr(): () => void {
|
|
191
|
+
const { log, info, debug, error } = console;
|
|
192
|
+
// The stderr function of now: a later wrapper of console.error must not see these twice.
|
|
193
|
+
console.log = console.info = console.debug = (...args: unknown[]) => error.apply(console, args);
|
|
194
|
+
return () => {
|
|
195
|
+
Object.assign(console, { log, info, debug });
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
static format(error: unknown): string {
|
|
200
|
+
return (
|
|
201
|
+
CellError.is(error)
|
|
202
|
+
? error
|
|
203
|
+
: new CellError({
|
|
204
|
+
code: 'CELL_INTERNAL_ERROR',
|
|
205
|
+
message: String((error as Error)?.message ?? error),
|
|
206
|
+
hint: 'Rerun with CELL_DEBUG=1 and report it.',
|
|
207
|
+
})
|
|
208
|
+
).format();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
protected static stderrLogger(reporter: Reporter): Logger {
|
|
212
|
+
const warned = new Set<string>();
|
|
213
|
+
const logger: Logger = {
|
|
214
|
+
hasWarned: false,
|
|
215
|
+
info: message => reporter.info(message),
|
|
216
|
+
warn: message => {
|
|
217
|
+
logger.hasWarned = true;
|
|
218
|
+
reporter.info(message);
|
|
219
|
+
},
|
|
220
|
+
warnOnce: message => {
|
|
221
|
+
if (!warned.has(message)) {
|
|
222
|
+
warned.add(message);
|
|
223
|
+
logger.warn(message);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
error: message => reporter.info(message),
|
|
227
|
+
clearScreen: () => {},
|
|
228
|
+
hasErrorLogged: () => false,
|
|
229
|
+
};
|
|
230
|
+
return logger;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CellError } from '@celljs/kit';
|
|
2
|
+
import { DocsIndex } from '../docs/docs-index.js';
|
|
3
|
+
import { Toolchain } from '../toolchain/toolchain.js';
|
|
4
|
+
import { Command, type CommandContext } from './command.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `cell docs <query>`: searches the README.md and docs/ of the installed components and the docs
|
|
8
|
+
* of toolchain modules, the versions this project uses. Read-only; prints the best sections.
|
|
9
|
+
*/
|
|
10
|
+
export class DocsCommand extends Command {
|
|
11
|
+
readonly name = 'docs';
|
|
12
|
+
readonly description = 'Search the docs of the installed components and modules';
|
|
13
|
+
override readonly arguments = '<query...>';
|
|
14
|
+
override readonly options = { limit: { type: 'string' } } as const;
|
|
15
|
+
override readonly usage = ['--limit <n> number of sections (default: 5)'];
|
|
16
|
+
|
|
17
|
+
async run({ values, positionals, reporter, env }: CommandContext): Promise<number> {
|
|
18
|
+
const query = positionals.join(' ').trim();
|
|
19
|
+
if (!query) {
|
|
20
|
+
throw new CellError({ code: 'CELL_ARGUMENT_INVALID', message: 'cell docs needs a query.', hint: 'For example: cell docs transactional' });
|
|
21
|
+
}
|
|
22
|
+
const limit = DocsCommand.limit(values.limit as string | undefined);
|
|
23
|
+
const toolchain = await Toolchain.create({
|
|
24
|
+
root: values.root as string | undefined,
|
|
25
|
+
command: 'docs',
|
|
26
|
+
env,
|
|
27
|
+
quiet: reporter.json,
|
|
28
|
+
runHooks: false,
|
|
29
|
+
logger: reporter,
|
|
30
|
+
});
|
|
31
|
+
await toolchain.close();
|
|
32
|
+
const index = new DocsIndex(toolchain.config.root, DocsIndex.sourcesOf(toolchain.modules.components, toolchain.modules.docs));
|
|
33
|
+
const results = index.search(query, limit);
|
|
34
|
+
reporter.result(
|
|
35
|
+
'docs',
|
|
36
|
+
{ query, files: index.files, results },
|
|
37
|
+
results.length === 0
|
|
38
|
+
? `No section of ${index.files} doc file${index.files === 1 ? '' : 's'} matches '${query}'.`
|
|
39
|
+
: results.map(hit => `── ${hit.file}:${hit.line} (${hit.source})\n${hit.text}`).join('\n\n'),
|
|
40
|
+
);
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static limit(value: string | undefined): number {
|
|
45
|
+
if (value === undefined) {
|
|
46
|
+
return 5;
|
|
47
|
+
}
|
|
48
|
+
if (!/^\d+$/.test(value) || Number(value) < 1) {
|
|
49
|
+
throw new CellError({ code: 'CELL_ARGUMENT_INVALID', message: `Invalid --limit '${value}'.`, hint: 'Pass a positive number, e.g. --limit 5.' });
|
|
50
|
+
}
|
|
51
|
+
return Number(value);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ProjectInspector } from '../info/project-inspector.js';
|
|
2
|
+
import { Toolchain } from '../toolchain/toolchain.js';
|
|
3
|
+
import { BuildCommand } from './build-command.js';
|
|
4
|
+
import { CellCli } from './cell-cli.js';
|
|
5
|
+
import { Command, type CommandContext } from './command.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `cell info`: what `cell build` with the same flags would use: preset and where it came from, modes,
|
|
9
|
+
* targets, components, DI modules, hooks and the state of the output. Read-only: hooks are listed,
|
|
10
|
+
* never run, and nothing is built.
|
|
11
|
+
*/
|
|
12
|
+
export class InfoCommand extends Command {
|
|
13
|
+
readonly name = 'info';
|
|
14
|
+
readonly description = 'Describe the project: preset, modes, targets, components, hooks, output';
|
|
15
|
+
override readonly options = { ...BuildCommand.OPTIONS, 'app-config': { type: 'boolean' } } as const;
|
|
16
|
+
override readonly usage = [...BuildCommand.USAGE, '--app-config include the merged cell.yml of each target'];
|
|
17
|
+
|
|
18
|
+
async run({ values, reporter, env }: CommandContext): Promise<number> {
|
|
19
|
+
const toolchain = await Toolchain.create({
|
|
20
|
+
root: values.root as string | undefined,
|
|
21
|
+
command: 'info',
|
|
22
|
+
flags: BuildCommand.flags(values),
|
|
23
|
+
env,
|
|
24
|
+
quiet: reporter.json,
|
|
25
|
+
runHooks: false,
|
|
26
|
+
logger: reporter,
|
|
27
|
+
});
|
|
28
|
+
const inspector = new ProjectInspector(toolchain.config, toolchain.preset, toolchain.presets.names, {
|
|
29
|
+
projectOptions: toolchain.projectOptions(),
|
|
30
|
+
modules: toolchain.modules.loaded,
|
|
31
|
+
});
|
|
32
|
+
const info = inspector.inspect({ appConfig: values['app-config'] === true, cellVersion: CellCli.version, env });
|
|
33
|
+
await toolchain.close();
|
|
34
|
+
for (const warning of inspector.warnings) {
|
|
35
|
+
reporter.warn(warning);
|
|
36
|
+
}
|
|
37
|
+
reporter.result('info', { ...info }, ProjectInspector.format(info));
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { CellError } from '@celljs/kit';
|
|
2
|
+
import { ProjectInitializer } from '../init/project-initializer.js';
|
|
3
|
+
import { Command, type CommandContext } from './command.js';
|
|
4
|
+
|
|
5
|
+
/** `cell init <template> [dir]`: a new project from a template. Never prompts; without arguments it lists the templates. */
|
|
6
|
+
export class InitCommand extends Command {
|
|
7
|
+
readonly name = 'init';
|
|
8
|
+
readonly description = 'Create a project from a template (cell init to list them)';
|
|
9
|
+
override readonly arguments = '[template] [dir]';
|
|
10
|
+
override readonly options = { name: { type: 'string' }, force: { type: 'boolean' } } as const;
|
|
11
|
+
override readonly usage = [
|
|
12
|
+
'--name <name> package name (default: the directory name)',
|
|
13
|
+
'--force write into a directory that is not empty',
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
constructor(protected readonly version: () => string) {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async run({ values, positionals, reporter }: CommandContext): Promise<number> {
|
|
21
|
+
const [template, dir, ...rest] = positionals;
|
|
22
|
+
if (rest.length > 0) {
|
|
23
|
+
throw new CellError({
|
|
24
|
+
code: 'CELL_ARGUMENT_INVALID',
|
|
25
|
+
message: 'cell init takes a template and a directory.',
|
|
26
|
+
hint: 'For example: cell init backend my-app',
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (!template) {
|
|
30
|
+
const templates = ProjectInitializer.templates();
|
|
31
|
+
const width = Math.max(...templates.map(t => t.name.length)) + 2;
|
|
32
|
+
reporter.result(
|
|
33
|
+
'init',
|
|
34
|
+
{ templates },
|
|
35
|
+
['Templates:', ...templates.map(t => ` ${t.name.padEnd(width)}${t.description}`), '', 'Create a project: cell init <template> <dir>'].join(
|
|
36
|
+
'\n',
|
|
37
|
+
),
|
|
38
|
+
);
|
|
39
|
+
return 0;
|
|
40
|
+
}
|
|
41
|
+
const result = new ProjectInitializer(this.version()).init(template, dir ?? template, {
|
|
42
|
+
name: values.name as string | undefined,
|
|
43
|
+
force: values.force === true,
|
|
44
|
+
cwd: values.root ? String(values.root) : undefined,
|
|
45
|
+
});
|
|
46
|
+
reporter.result(
|
|
47
|
+
'init',
|
|
48
|
+
{ ...result },
|
|
49
|
+
[`Created ${result.name} from the ${template} template in ${result.dir}`, '', 'Next:', ...result.next.map(c => ` ${c}`)].join('\n'),
|
|
50
|
+
);
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/src/cli/main.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { createInterface } from 'node:readline';
|
|
3
|
+
import type { Readable } from 'node:stream';
|
|
4
|
+
import { McpServer } from '../mcp/mcp-server.js';
|
|
5
|
+
import { type CellRunner, ProjectMcpTools } from '../mcp/project-mcp-tools.js';
|
|
6
|
+
import { Command, type CommandContext } from './command.js';
|
|
7
|
+
import type { Writable } from './reporter.js';
|
|
8
|
+
|
|
9
|
+
export interface McpIo {
|
|
10
|
+
input: Readable;
|
|
11
|
+
/** Where protocol messages go; nothing else is written to it. */
|
|
12
|
+
output: Writable;
|
|
13
|
+
/** Logs of the server and of the commands it runs. */
|
|
14
|
+
log: Writable;
|
|
15
|
+
/** Undoes what the IO changed when the server stops. */
|
|
16
|
+
restore?(): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* `cell mcp`: an MCP server on stdio (newline-delimited JSON-RPC) with the project tools of
|
|
21
|
+
* docs/design/agent-first.md R8 and those of toolchain modules. Runs until stdin closes. stdout
|
|
22
|
+
* carries protocol messages only: console output of anything else goes to stderr.
|
|
23
|
+
*/
|
|
24
|
+
export class McpCommand extends Command {
|
|
25
|
+
readonly name = 'mcp';
|
|
26
|
+
readonly description = 'Serve the project tools to coding agents over MCP (stdio)';
|
|
27
|
+
|
|
28
|
+
constructor(
|
|
29
|
+
protected readonly runner: CellRunner,
|
|
30
|
+
protected readonly io?: McpIo,
|
|
31
|
+
) {
|
|
32
|
+
super();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async run({ values, env }: CommandContext): Promise<number> {
|
|
36
|
+
const root = resolve((values.root as string | undefined) ?? process.cwd());
|
|
37
|
+
const io = this.io ?? McpCommand.processIo();
|
|
38
|
+
const log = (message: string): void => {
|
|
39
|
+
io.log.write(`${message}\n`);
|
|
40
|
+
};
|
|
41
|
+
const tools = new ProjectMcpTools(root, this.runner, env, log);
|
|
42
|
+
const { CellCli } = await import('./cell-cli.js');
|
|
43
|
+
const server = new McpServer({
|
|
44
|
+
name: 'cell',
|
|
45
|
+
version: CellCli.version,
|
|
46
|
+
instructions: [
|
|
47
|
+
`Tools for the Cell project at ${root}.`,
|
|
48
|
+
'Start with info (the project model); run check after changing code or configuration; config_get tells where a configuration value comes from; docs_search finds docs of the installed component versions.',
|
|
49
|
+
'While cell dev runs, the running application has its own MCP endpoint at <dev url>/_cell/mcp (errors, routes, DI bindings, logs).',
|
|
50
|
+
].join(' '),
|
|
51
|
+
tools: () => tools.tools(),
|
|
52
|
+
});
|
|
53
|
+
const pending = new Set<Promise<void>>();
|
|
54
|
+
const lines = createInterface({ input: io.input, crlfDelay: Number.POSITIVE_INFINITY });
|
|
55
|
+
try {
|
|
56
|
+
for await (const line of lines) {
|
|
57
|
+
if (!line.trim()) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
const task = server
|
|
61
|
+
.handleText(line)
|
|
62
|
+
.then(response => {
|
|
63
|
+
if (response !== undefined) {
|
|
64
|
+
io.output.write(`${response}\n`);
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
.catch(error => log(`cell mcp: ${(error as Error)?.stack ?? error}`))
|
|
68
|
+
.finally(() => pending.delete(task));
|
|
69
|
+
pending.add(task);
|
|
70
|
+
}
|
|
71
|
+
await Promise.all(pending);
|
|
72
|
+
} finally {
|
|
73
|
+
await tools.close();
|
|
74
|
+
io.restore?.();
|
|
75
|
+
}
|
|
76
|
+
return 0;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* stdin/stdout of the process, with stdout kept for protocol messages: `process.stdout.write` and
|
|
81
|
+
* `console.log`/`info`/`debug` of modules, hooks and Vite go to stderr while the server runs.
|
|
82
|
+
*/
|
|
83
|
+
static processIo(): McpIo & { restore(): void } {
|
|
84
|
+
const write = process.stdout.write.bind(process.stdout);
|
|
85
|
+
const { log, info, debug } = console;
|
|
86
|
+
process.stdout.write = process.stderr.write.bind(process.stderr) as typeof process.stdout.write;
|
|
87
|
+
console.log = console.info = console.debug = (...args: unknown[]) => console.error(...args);
|
|
88
|
+
return {
|
|
89
|
+
input: process.stdin,
|
|
90
|
+
output: { write: (chunk: string) => write(chunk) },
|
|
91
|
+
log: process.stderr,
|
|
92
|
+
restore: () => {
|
|
93
|
+
process.stdout.write = write as typeof process.stdout.write;
|
|
94
|
+
Object.assign(console, { log, info, debug });
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { type ChildProcess, spawn } from 'node:child_process';
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import { join, resolve } from 'node:path';
|
|
4
|
+
import { CellError, type OutputManifest, type Preset } from '@celljs/kit';
|
|
5
|
+
import { ConfigResolver } from '../config/config-resolver.js';
|
|
6
|
+
import { BUILTIN_PRESETS } from '../preset/builtin-presets.js';
|
|
7
|
+
import { PresetOutput } from '../preset/preset-output.js';
|
|
8
|
+
import { PresetRegistry } from '../preset/preset-registry.js';
|
|
9
|
+
import { Command, type CommandContext } from './command.js';
|
|
10
|
+
|
|
11
|
+
/** `cell preview`: run the built output as described by `manifest.json`, without rebuilding. */
|
|
12
|
+
export class PreviewCommand extends Command {
|
|
13
|
+
readonly name = 'preview';
|
|
14
|
+
readonly description = 'Run the built application from .cell/output';
|
|
15
|
+
override readonly options = {
|
|
16
|
+
port: { type: 'string', short: 'p' },
|
|
17
|
+
'out-dir': { type: 'string' },
|
|
18
|
+
} as const;
|
|
19
|
+
override readonly usage = [
|
|
20
|
+
'-p, --port <port> port to listen on (default: cell.server.port; 8787 for cloudflare)',
|
|
21
|
+
'--out-dir <dir> output directory (default: .cell/output)',
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
async run({ values, reporter, env }: CommandContext): Promise<number> {
|
|
25
|
+
const root = realpathSync(resolve((values.root as string | undefined) ?? process.cwd()));
|
|
26
|
+
const outDir = resolve(root, (values['out-dir'] as string | undefined) ?? ConfigResolver.DEFAULT_OUT_DIR);
|
|
27
|
+
const manifest = PresetOutput.read(outDir);
|
|
28
|
+
const port = values.port as string | undefined;
|
|
29
|
+
if (port !== undefined && !/^\d+$/.test(port)) {
|
|
30
|
+
throw new CellError({ code: 'CELL_ARGUMENT_INVALID', message: `Invalid --port '${port}'.`, hint: 'Pass a port number, e.g. --port 3000.' });
|
|
31
|
+
}
|
|
32
|
+
const stdio = ['inherit', reporter.json ? 2 : 'inherit', 'inherit'] as const;
|
|
33
|
+
const preset = this.preset(manifest);
|
|
34
|
+
if (preset?.preview) {
|
|
35
|
+
const preview = await preset.preview({ root, outDir, manifest, port: port ? Number(port) : undefined, env });
|
|
36
|
+
const command = [preview.command, ...preview.args];
|
|
37
|
+
const child = spawn(preview.command, preview.args, { cwd: preview.cwd ?? root, env: { ...env, ...preview.env }, stdio: [...stdio] });
|
|
38
|
+
reporter.result(
|
|
39
|
+
'preview',
|
|
40
|
+
{ command, pid: child.pid, port: port ? Number(port) : undefined, preset: manifest.preset },
|
|
41
|
+
`Running ${command.join(' ')}`,
|
|
42
|
+
);
|
|
43
|
+
return this.wait(child);
|
|
44
|
+
}
|
|
45
|
+
if (manifest.executable) {
|
|
46
|
+
const app = join(outDir, manifest.executable.file);
|
|
47
|
+
const child = spawn(app, [], {
|
|
48
|
+
cwd: root,
|
|
49
|
+
env: { ...env, NODE_ENV: env.NODE_ENV ?? 'production', ...(port ? { CELL_BACKEND__SERVER__PORT: port } : {}) },
|
|
50
|
+
stdio: [...stdio],
|
|
51
|
+
});
|
|
52
|
+
reporter.result('preview', { executable: app, pid: child.pid, port: port ? Number(port) : undefined, preset: manifest.preset }, `Running ${app}`);
|
|
53
|
+
return this.wait(child);
|
|
54
|
+
}
|
|
55
|
+
if (!manifest.server) {
|
|
56
|
+
throw new CellError({
|
|
57
|
+
code: 'CELL_PREVIEW_NO_SERVER',
|
|
58
|
+
message: `The output in ${outDir} has no server (targets: ${manifest.targets.join(', ')}).`,
|
|
59
|
+
file: join(outDir, PresetOutput.MANIFEST),
|
|
60
|
+
hint: 'Serve the public directory with any static file server, or build a backend target.',
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const server = join(outDir, manifest.server);
|
|
64
|
+
const child = spawn(process.execPath.includes('bun') ? 'node' : process.execPath, [server], {
|
|
65
|
+
cwd: root,
|
|
66
|
+
env: { ...env, NODE_ENV: env.NODE_ENV ?? 'production', ...(port ? { CELL_BACKEND__SERVER__PORT: port } : {}) },
|
|
67
|
+
stdio: [...stdio],
|
|
68
|
+
});
|
|
69
|
+
reporter.result('preview', { server, pid: child.pid, port: port ? Number(port) : undefined, preset: manifest.preset }, `Running ${server}`);
|
|
70
|
+
return this.wait(child);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** The built-in preset that built the output, if any; presets of toolchain modules preview with Node.js. */
|
|
74
|
+
protected preset(manifest: OutputManifest): Preset | undefined {
|
|
75
|
+
const presets = new PresetRegistry();
|
|
76
|
+
for (const preset of BUILTIN_PRESETS) {
|
|
77
|
+
presets.register(preset);
|
|
78
|
+
}
|
|
79
|
+
return manifest.preset && presets.names.includes(manifest.preset) ? presets.resolve(manifest.preset) : undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Forwards Ctrl+C and termination to the server and exits with its code. */
|
|
83
|
+
protected wait(child: ChildProcess): Promise<number> {
|
|
84
|
+
const forward = (signal: NodeJS.Signals) => () => child.kill(signal);
|
|
85
|
+
const onInt = forward('SIGINT');
|
|
86
|
+
const onTerm = forward('SIGTERM');
|
|
87
|
+
process.on('SIGINT', onInt);
|
|
88
|
+
process.on('SIGTERM', onTerm);
|
|
89
|
+
return new Promise((resolvePromise, reject) => {
|
|
90
|
+
child.on('error', reject);
|
|
91
|
+
child.on('exit', (code, signal) => {
|
|
92
|
+
process.off('SIGINT', onInt);
|
|
93
|
+
process.off('SIGTERM', onTerm);
|
|
94
|
+
resolvePromise(code ?? (signal === 'SIGINT' || signal === 'SIGTERM' ? 0 : 1));
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { CellError } from '@celljs/kit';
|
|
2
|
+
|
|
3
|
+
export interface Writable {
|
|
4
|
+
write(chunk: string): unknown;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Prints command results. Human output is short text; with `--json` stdout carries exactly one JSON
|
|
9
|
+
* document with `schemaVersion` (docs/design/agent-first.md R6), and everything else goes to stderr.
|
|
10
|
+
*/
|
|
11
|
+
export class Reporter {
|
|
12
|
+
static readonly SCHEMA_VERSION = 1;
|
|
13
|
+
|
|
14
|
+
readonly warnings: string[] = [];
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
readonly json: boolean,
|
|
18
|
+
protected readonly stdout: Writable = process.stdout,
|
|
19
|
+
protected readonly stderr: Writable = process.stderr,
|
|
20
|
+
) {}
|
|
21
|
+
|
|
22
|
+
/** Progress and incidental messages: never on stdout in JSON mode. */
|
|
23
|
+
info(message: string): void {
|
|
24
|
+
(this.json ? this.stderr : this.stdout).write(`${message}\n`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
warn(message: string): void {
|
|
28
|
+
this.warnings.push(message);
|
|
29
|
+
this.stderr.write(`warning: ${message}\n`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** Output of a child process: `stderr` stays stderr, `stdout` moves to stderr in JSON mode. */
|
|
33
|
+
relay(chunk: string, stream: 'stdout' | 'stderr'): void {
|
|
34
|
+
(this.json || stream === 'stderr' ? this.stderr : this.stdout).write(chunk);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
result(command: string, data: Record<string, unknown>, human: string): void {
|
|
38
|
+
if (this.json) {
|
|
39
|
+
this.stdout.write(`${JSON.stringify({ schemaVersion: Reporter.SCHEMA_VERSION, command, ok: true, ...data, warnings: this.warnings })}\n`);
|
|
40
|
+
} else {
|
|
41
|
+
this.stdout.write(`${human}\n`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
error(command: string | undefined, error: CellError): void {
|
|
46
|
+
if (this.json) {
|
|
47
|
+
this.stdout.write(
|
|
48
|
+
`${JSON.stringify({ schemaVersion: Reporter.SCHEMA_VERSION, command, ok: false, error: error.toJSON(), warnings: this.warnings })}\n`,
|
|
49
|
+
);
|
|
50
|
+
} else {
|
|
51
|
+
this.stderr.write(`${error.format()}\n`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Anything that is not a CellError is a bug in Cell or a module: say so instead of dumping a stack. */
|
|
56
|
+
static toCellError(error: unknown): CellError {
|
|
57
|
+
if (CellError.is(error)) {
|
|
58
|
+
return error;
|
|
59
|
+
}
|
|
60
|
+
return new CellError({
|
|
61
|
+
code: 'CELL_INTERNAL_ERROR',
|
|
62
|
+
message: (error as Error)?.message ?? String(error),
|
|
63
|
+
hint: 'This is a bug in Cell or one of its modules; rerun with CELL_DEBUG=1 for the stack trace and report it.',
|
|
64
|
+
cause: error,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|