@celljs/cli 3.8.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +442 -1
- package/agent/guide.md +39 -0
- package/bin/cell.js +2 -0
- package/lib/agent/agent-guide.d.ts +39 -0
- package/lib/agent/agent-guide.d.ts.map +1 -0
- package/lib/agent/agent-guide.js +67 -0
- package/lib/agent/agent-guide.js.map +1 -0
- package/lib/build/executable-compiler.d.ts +44 -0
- package/lib/build/executable-compiler.d.ts.map +1 -0
- package/lib/build/executable-compiler.js +145 -0
- package/lib/build/executable-compiler.js.map +1 -0
- package/lib/build/executable-compiler.spec.d.ts +2 -0
- package/lib/build/executable-compiler.spec.d.ts.map +1 -0
- package/lib/build/executable-compiler.spec.js +71 -0
- package/lib/build/executable-compiler.spec.js.map +1 -0
- package/lib/build/single-compile.spec.d.ts +2 -0
- package/lib/build/single-compile.spec.d.ts.map +1 -0
- package/lib/build/single-compile.spec.js +135 -0
- package/lib/build/single-compile.spec.js.map +1 -0
- package/lib/check/project-checker.d.ts +85 -0
- package/lib/check/project-checker.d.ts.map +1 -0
- package/lib/check/project-checker.js +332 -0
- package/lib/check/project-checker.js.map +1 -0
- package/lib/check/project-checker.spec.d.ts +2 -0
- package/lib/check/project-checker.spec.d.ts.map +1 -0
- package/lib/check/project-checker.spec.js +147 -0
- package/lib/check/project-checker.spec.js.map +1 -0
- package/lib/cli/agent-command.d.ts +15 -0
- package/lib/cli/agent-command.d.ts.map +1 -0
- package/lib/cli/agent-command.js +42 -0
- package/lib/cli/agent-command.js.map +1 -0
- package/lib/cli/build-command.d.ts +84 -0
- package/lib/cli/build-command.d.ts.map +1 -0
- package/lib/cli/build-command.js +170 -0
- package/lib/cli/build-command.js.map +1 -0
- package/lib/cli/cell-cli.d.ts +35 -0
- package/lib/cli/cell-cli.d.ts.map +1 -0
- package/lib/cli/cell-cli.js +159 -0
- package/lib/cli/cell-cli.js.map +1 -0
- package/lib/cli/cell-cli.spec.d.ts +2 -0
- package/lib/cli/cell-cli.spec.d.ts.map +1 -0
- package/lib/cli/cell-cli.spec.js +195 -0
- package/lib/cli/cell-cli.spec.js.map +1 -0
- package/lib/cli/check-command.d.ts +31 -0
- package/lib/cli/check-command.d.ts.map +1 -0
- package/lib/cli/check-command.js +67 -0
- package/lib/cli/check-command.js.map +1 -0
- package/lib/cli/command.d.ts +24 -0
- package/lib/cli/command.d.ts.map +1 -0
- package/lib/cli/command.js +10 -0
- package/lib/cli/command.js.map +1 -0
- package/lib/cli/config-command.d.ts +29 -0
- package/lib/cli/config-command.d.ts.map +1 -0
- package/lib/cli/config-command.js +71 -0
- package/lib/cli/config-command.js.map +1 -0
- package/lib/cli/config-command.spec.d.ts +2 -0
- package/lib/cli/config-command.spec.d.ts.map +1 -0
- package/lib/cli/config-command.spec.js +79 -0
- package/lib/cli/config-command.spec.js.map +1 -0
- package/lib/cli/deploy-command.d.ts +41 -0
- package/lib/cli/deploy-command.d.ts.map +1 -0
- package/lib/cli/deploy-command.js +114 -0
- package/lib/cli/deploy-command.js.map +1 -0
- package/lib/cli/dev-command.d.ts +47 -0
- package/lib/cli/dev-command.d.ts.map +1 -0
- package/lib/cli/dev-command.js +219 -0
- package/lib/cli/dev-command.js.map +1 -0
- package/lib/cli/dev-command.spec.d.ts +2 -0
- package/lib/cli/dev-command.spec.d.ts.map +1 -0
- package/lib/cli/dev-command.spec.js +149 -0
- package/lib/cli/dev-command.spec.js.map +1 -0
- package/lib/cli/docs-command.d.ts +19 -0
- package/lib/cli/docs-command.d.ts.map +1 -0
- package/lib/cli/docs-command.js +47 -0
- package/lib/cli/docs-command.js.map +1 -0
- package/lib/cli/info-command.d.ts +44 -0
- package/lib/cli/info-command.d.ts.map +1 -0
- package/lib/cli/info-command.js +39 -0
- package/lib/cli/info-command.js.map +1 -0
- package/lib/cli/info-command.spec.d.ts +2 -0
- package/lib/cli/info-command.spec.d.ts.map +1 -0
- package/lib/cli/info-command.spec.js +236 -0
- package/lib/cli/info-command.spec.js.map +1 -0
- package/lib/cli/init-command.d.ts +20 -0
- package/lib/cli/init-command.d.ts.map +1 -0
- package/lib/cli/init-command.js +43 -0
- package/lib/cli/init-command.js.map +1 -0
- package/lib/cli/main.d.ts +2 -0
- package/lib/cli/main.d.ts.map +1 -0
- package/lib/cli/main.js +3 -0
- package/lib/cli/main.js.map +1 -0
- package/lib/cli/mcp-command.d.ts +34 -0
- package/lib/cli/mcp-command.d.ts.map +1 -0
- package/lib/cli/mcp-command.js +85 -0
- package/lib/cli/mcp-command.js.map +1 -0
- package/lib/cli/mcp-command.spec.d.ts +2 -0
- package/lib/cli/mcp-command.spec.d.ts.map +1 -0
- package/lib/cli/mcp-command.spec.js +132 -0
- package/lib/cli/mcp-command.spec.js.map +1 -0
- package/lib/cli/preview-command.d.ts +24 -0
- package/lib/cli/preview-command.d.ts.map +1 -0
- package/lib/cli/preview-command.js +91 -0
- package/lib/cli/preview-command.js.map +1 -0
- package/lib/cli/reporter.d.ts +26 -0
- package/lib/cli/reporter.d.ts.map +1 -0
- package/lib/cli/reporter.js +58 -0
- package/lib/cli/reporter.js.map +1 -0
- package/lib/config/config-build.spec.d.ts +2 -0
- package/lib/config/config-build.spec.d.ts.map +1 -0
- package/lib/config/config-build.spec.js +111 -0
- package/lib/config/config-build.spec.js.map +1 -0
- package/lib/config/config-explainer.d.ts +48 -0
- package/lib/config/config-explainer.d.ts.map +1 -0
- package/lib/config/config-explainer.js +130 -0
- package/lib/config/config-explainer.js.map +1 -0
- package/lib/config/config-file-loader.d.ts +22 -0
- package/lib/config/config-file-loader.d.ts.map +1 -0
- package/lib/config/config-file-loader.js +63 -0
- package/lib/config/config-file-loader.js.map +1 -0
- package/lib/config/config-resolver.d.ts +111 -0
- package/lib/config/config-resolver.d.ts.map +1 -0
- package/lib/config/config-resolver.js +215 -0
- package/lib/config/config-resolver.js.map +1 -0
- package/lib/config/config-resolver.spec.d.ts +2 -0
- package/lib/config/config-resolver.spec.d.ts.map +1 -0
- package/lib/config/config-resolver.spec.js +159 -0
- package/lib/config/config-resolver.spec.js.map +1 -0
- package/lib/config/config-validator.d.ts +35 -0
- package/lib/config/config-validator.d.ts.map +1 -0
- package/lib/config/config-validator.js +160 -0
- package/lib/config/config-validator.js.map +1 -0
- package/lib/config/config-validator.spec.d.ts +2 -0
- package/lib/config/config-validator.spec.d.ts.map +1 -0
- package/lib/config/config-validator.spec.js +77 -0
- package/lib/config/config-validator.spec.js.map +1 -0
- package/lib/config/define-config.d.ts +4 -0
- package/lib/config/define-config.d.ts.map +1 -0
- package/lib/config/define-config.js +5 -0
- package/lib/config/define-config.js.map +1 -0
- package/lib/config/types.d.ts +53 -0
- package/lib/config/types.d.ts.map +1 -0
- package/lib/config/types.js +2 -0
- package/lib/config/types.js.map +1 -0
- package/lib/deploy/cloud-api.d.ts +58 -0
- package/lib/deploy/cloud-api.d.ts.map +1 -0
- package/lib/deploy/cloud-api.js +189 -0
- package/lib/deploy/cloud-api.js.map +1 -0
- package/lib/deploy/code-package.d.ts +15 -0
- package/lib/deploy/code-package.d.ts.map +1 -0
- package/lib/deploy/code-package.js +40 -0
- package/lib/deploy/code-package.js.map +1 -0
- package/lib/deploy/deploy-utils.spec.d.ts +2 -0
- package/lib/deploy/deploy-utils.spec.d.ts.map +1 -0
- package/lib/deploy/deploy-utils.spec.js +56 -0
- package/lib/deploy/deploy-utils.spec.js.map +1 -0
- package/lib/deploy/deployer-registry.d.ts +11 -0
- package/lib/deploy/deployer-registry.d.ts.map +1 -0
- package/lib/deploy/deployer-registry.js +40 -0
- package/lib/deploy/deployer-registry.js.map +1 -0
- package/lib/deploy/request-signer.d.ts +51 -0
- package/lib/deploy/request-signer.d.ts.map +1 -0
- package/lib/deploy/request-signer.js +109 -0
- package/lib/deploy/request-signer.js.map +1 -0
- package/lib/deploy/zip-writer.d.ts +32 -0
- package/lib/deploy/zip-writer.d.ts.map +1 -0
- package/lib/deploy/zip-writer.js +114 -0
- package/lib/deploy/zip-writer.js.map +1 -0
- package/lib/docs/docs-index.d.ts +54 -0
- package/lib/docs/docs-index.d.ts.map +1 -0
- package/lib/docs/docs-index.js +140 -0
- package/lib/docs/docs-index.js.map +1 -0
- package/lib/docs/docs-index.spec.d.ts +2 -0
- package/lib/docs/docs-index.spec.d.ts.map +1 -0
- package/lib/docs/docs-index.spec.js +52 -0
- package/lib/docs/docs-index.spec.js.map +1 -0
- package/lib/events/event-bus.d.ts +30 -0
- package/lib/events/event-bus.d.ts.map +1 -0
- package/lib/events/event-bus.js +81 -0
- package/lib/events/event-bus.js.map +1 -0
- package/lib/events/event-bus.spec.d.ts +2 -0
- package/lib/events/event-bus.spec.d.ts.map +1 -0
- package/lib/events/event-bus.spec.js +69 -0
- package/lib/events/event-bus.spec.js.map +1 -0
- package/lib/events/hook-runner.d.ts +27 -0
- package/lib/events/hook-runner.d.ts.map +1 -0
- package/lib/events/hook-runner.js +65 -0
- package/lib/events/hook-runner.js.map +1 -0
- package/lib/events/hook-runner.spec.d.ts +2 -0
- package/lib/events/hook-runner.spec.d.ts.map +1 -0
- package/lib/events/hook-runner.spec.js +36 -0
- package/lib/events/hook-runner.spec.js.map +1 -0
- package/lib/index.d.ts +57 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +57 -2
- package/lib/index.js.map +1 -1
- package/lib/info/project-inspector.d.ts +143 -0
- package/lib/info/project-inspector.d.ts.map +1 -0
- package/lib/info/project-inspector.js +244 -0
- package/lib/info/project-inspector.js.map +1 -0
- package/lib/init/project-initializer.d.ts +44 -0
- package/lib/init/project-initializer.d.ts.map +1 -0
- package/lib/init/project-initializer.js +90 -0
- package/lib/init/project-initializer.js.map +1 -0
- package/lib/init/project-initializer.spec.d.ts +2 -0
- package/lib/init/project-initializer.spec.d.ts.map +1 -0
- package/lib/init/project-initializer.spec.js +88 -0
- package/lib/init/project-initializer.spec.js.map +1 -0
- package/lib/mcp/dev-activity.d.ts +34 -0
- package/lib/mcp/dev-activity.d.ts.map +1 -0
- package/lib/mcp/dev-activity.js +46 -0
- package/lib/mcp/dev-activity.js.map +1 -0
- package/lib/mcp/dev-mcp-endpoint.d.ts +62 -0
- package/lib/mcp/dev-mcp-endpoint.d.ts.map +1 -0
- package/lib/mcp/dev-mcp-endpoint.js +280 -0
- package/lib/mcp/dev-mcp-endpoint.js.map +1 -0
- package/lib/mcp/dev-mcp-endpoint.spec.d.ts +2 -0
- package/lib/mcp/dev-mcp-endpoint.spec.d.ts.map +1 -0
- package/lib/mcp/dev-mcp-endpoint.spec.js +143 -0
- package/lib/mcp/dev-mcp-endpoint.spec.js.map +1 -0
- package/lib/mcp/mcp-server.d.ts +64 -0
- package/lib/mcp/mcp-server.d.ts.map +1 -0
- package/lib/mcp/mcp-server.js +201 -0
- package/lib/mcp/mcp-server.js.map +1 -0
- package/lib/mcp/mcp-server.spec.d.ts +2 -0
- package/lib/mcp/mcp-server.spec.d.ts.map +1 -0
- package/lib/mcp/mcp-server.spec.js +136 -0
- package/lib/mcp/mcp-server.spec.js.map +1 -0
- package/lib/mcp/project-mcp-tools.d.ts +35 -0
- package/lib/mcp/project-mcp-tools.d.ts.map +1 -0
- package/lib/mcp/project-mcp-tools.js +199 -0
- package/lib/mcp/project-mcp-tools.js.map +1 -0
- package/lib/modules/module-host.d.ts +118 -0
- package/lib/modules/module-host.d.ts.map +1 -0
- package/lib/modules/module-host.js +405 -0
- package/lib/modules/module-host.js.map +1 -0
- package/lib/modules/module-host.spec.d.ts +2 -0
- package/lib/modules/module-host.spec.d.ts.map +1 -0
- package/lib/modules/module-host.spec.js +220 -0
- package/lib/modules/module-host.spec.js.map +1 -0
- package/lib/preset/builtin-presets.d.ts +9 -0
- package/lib/preset/builtin-presets.d.ts.map +1 -0
- package/lib/preset/builtin-presets.js +24 -0
- package/lib/preset/builtin-presets.js.map +1 -0
- package/lib/preset/cloudflare/cloudflare-deployer.d.ts +26 -0
- package/lib/preset/cloudflare/cloudflare-deployer.d.ts.map +1 -0
- package/lib/preset/cloudflare/cloudflare-deployer.js +116 -0
- package/lib/preset/cloudflare/cloudflare-deployer.js.map +1 -0
- package/lib/preset/cloudflare/cloudflare-preset.d.ts +16 -0
- package/lib/preset/cloudflare/cloudflare-preset.d.ts.map +1 -0
- package/lib/preset/cloudflare/cloudflare-preset.js +97 -0
- package/lib/preset/cloudflare/cloudflare-preset.js.map +1 -0
- package/lib/preset/cloudflare/cloudflare.spec.d.ts +2 -0
- package/lib/preset/cloudflare/cloudflare.spec.d.ts.map +1 -0
- package/lib/preset/cloudflare/cloudflare.spec.js +212 -0
- package/lib/preset/cloudflare/cloudflare.spec.js.map +1 -0
- package/lib/preset/cloudflare/wrangler-config.d.ts +50 -0
- package/lib/preset/cloudflare/wrangler-config.d.ts.map +1 -0
- package/lib/preset/cloudflare/wrangler-config.js +160 -0
- package/lib/preset/cloudflare/wrangler-config.js.map +1 -0
- package/lib/preset/cloudflare/wrangler-config.spec.d.ts +2 -0
- package/lib/preset/cloudflare/wrangler-config.spec.d.ts.map +1 -0
- package/lib/preset/cloudflare/wrangler-config.spec.js +112 -0
- package/lib/preset/cloudflare/wrangler-config.spec.js.map +1 -0
- package/lib/preset/cloudflare/wrangler.d.ts +38 -0
- package/lib/preset/cloudflare/wrangler.d.ts.map +1 -0
- package/lib/preset/cloudflare/wrangler.js +90 -0
- package/lib/preset/cloudflare/wrangler.js.map +1 -0
- package/lib/preset/cloudflare/wrangler.spec.d.ts +2 -0
- package/lib/preset/cloudflare/wrangler.spec.d.ts.map +1 -0
- package/lib/preset/cloudflare/wrangler.spec.js +64 -0
- package/lib/preset/cloudflare/wrangler.spec.js.map +1 -0
- package/lib/preset/fc/fc-deployer.d.ts +50 -0
- package/lib/preset/fc/fc-deployer.d.ts.map +1 -0
- package/lib/preset/fc/fc-deployer.js +209 -0
- package/lib/preset/fc/fc-deployer.js.map +1 -0
- package/lib/preset/fc/fc-preset.d.ts +20 -0
- package/lib/preset/fc/fc-preset.d.ts.map +1 -0
- package/lib/preset/fc/fc-preset.js +46 -0
- package/lib/preset/fc/fc-preset.js.map +1 -0
- package/lib/preset/lambda/lambda-deployer.d.ts +50 -0
- package/lib/preset/lambda/lambda-deployer.d.ts.map +1 -0
- package/lib/preset/lambda/lambda-deployer.js +274 -0
- package/lib/preset/lambda/lambda-deployer.js.map +1 -0
- package/lib/preset/lambda/lambda-preset.d.ts +14 -0
- package/lib/preset/lambda/lambda-preset.d.ts.map +1 -0
- package/lib/preset/lambda/lambda-preset.js +44 -0
- package/lib/preset/lambda/lambda-preset.js.map +1 -0
- package/lib/preset/preset-output.d.ts +19 -0
- package/lib/preset/preset-output.d.ts.map +1 -0
- package/lib/preset/preset-output.js +45 -0
- package/lib/preset/preset-output.js.map +1 -0
- package/lib/preset/preset-registry.d.ts +16 -0
- package/lib/preset/preset-registry.d.ts.map +1 -0
- package/lib/preset/preset-registry.js +58 -0
- package/lib/preset/preset-registry.js.map +1 -0
- package/lib/preset/preset-registry.spec.d.ts +2 -0
- package/lib/preset/preset-registry.spec.d.ts.map +1 -0
- package/lib/preset/preset-registry.spec.js +28 -0
- package/lib/preset/preset-registry.spec.js.map +1 -0
- package/lib/preset/scf/scf-deployer.d.ts +54 -0
- package/lib/preset/scf/scf-deployer.d.ts.map +1 -0
- package/lib/preset/scf/scf-deployer.js +202 -0
- package/lib/preset/scf/scf-deployer.js.map +1 -0
- package/lib/preset/scf/scf-preset.d.ts +19 -0
- package/lib/preset/scf/scf-preset.d.ts.map +1 -0
- package/lib/preset/scf/scf-preset.js +43 -0
- package/lib/preset/scf/scf-preset.js.map +1 -0
- package/lib/preset/serverless-deployers.spec.d.ts +2 -0
- package/lib/preset/serverless-deployers.spec.d.ts.map +1 -0
- package/lib/preset/serverless-deployers.spec.js +307 -0
- package/lib/preset/serverless-deployers.spec.js.map +1 -0
- package/lib/preset/serverless-presets.spec.d.ts +2 -0
- package/lib/preset/serverless-presets.spec.d.ts.map +1 -0
- package/lib/preset/serverless-presets.spec.js +280 -0
- package/lib/preset/serverless-presets.spec.js.map +1 -0
- package/lib/preset/serverless-scripts.d.ts +29 -0
- package/lib/preset/serverless-scripts.d.ts.map +1 -0
- package/lib/preset/serverless-scripts.js +120 -0
- package/lib/preset/serverless-scripts.js.map +1 -0
- package/lib/preset/vercel/vercel-deployer.d.ts +38 -0
- package/lib/preset/vercel/vercel-deployer.d.ts.map +1 -0
- package/lib/preset/vercel/vercel-deployer.js +160 -0
- package/lib/preset/vercel/vercel-deployer.js.map +1 -0
- package/lib/preset/vercel/vercel-preset.d.ts +19 -0
- package/lib/preset/vercel/vercel-preset.d.ts.map +1 -0
- package/lib/preset/vercel/vercel-preset.js +102 -0
- package/lib/preset/vercel/vercel-preset.js.map +1 -0
- package/lib/test/fixture-project.d.ts +17 -0
- package/lib/test/fixture-project.d.ts.map +1 -0
- package/lib/test/fixture-project.js +43 -0
- package/lib/test/fixture-project.js.map +1 -0
- package/lib/testing/create-test-app.d.ts +27 -0
- package/lib/testing/create-test-app.d.ts.map +1 -0
- package/lib/testing/create-test-app.js +54 -0
- package/lib/testing/create-test-app.js.map +1 -0
- package/lib/testing/create-test-app.spec.d.ts +2 -0
- package/lib/testing/create-test-app.spec.d.ts.map +1 -0
- package/lib/testing/create-test-app.spec.js +66 -0
- package/lib/testing/create-test-app.spec.js.map +1 -0
- package/lib/toolchain/toolchain.d.ts +49 -0
- package/lib/toolchain/toolchain.d.ts.map +1 -0
- package/lib/toolchain/toolchain.js +100 -0
- package/lib/toolchain/toolchain.js.map +1 -0
- package/lib/utils/json-util.d.ts +11 -0
- package/lib/utils/json-util.d.ts.map +1 -0
- package/lib/utils/json-util.js +73 -0
- package/lib/utils/json-util.js.map +1 -0
- package/lib/utils/json-util.spec.d.ts +2 -0
- package/lib/utils/json-util.spec.d.ts.map +1 -0
- package/lib/utils/json-util.spec.js +18 -0
- package/lib/utils/json-util.spec.js.map +1 -0
- package/lib/utils/text-util.d.ts +19 -0
- package/lib/utils/text-util.d.ts.map +1 -0
- package/lib/utils/text-util.js +66 -0
- package/lib/utils/text-util.js.map +1 -0
- package/lib/utils/text-util.spec.d.ts +2 -0
- package/lib/utils/text-util.spec.d.ts.map +1 -0
- package/lib/utils/text-util.spec.js +22 -0
- package/lib/utils/text-util.spec.js.map +1 -0
- package/package.json +28 -30
- package/src/agent/agent-guide.ts +90 -0
- package/src/build/executable-compiler.ts +179 -0
- package/src/check/project-checker.ts +365 -0
- package/src/cli/agent-command.ts +46 -0
- package/src/cli/build-command.ts +189 -0
- package/src/cli/cell-cli.ts +174 -0
- package/src/cli/check-command.ts +74 -0
- package/src/cli/command.ts +29 -0
- package/src/cli/config-command.ts +73 -0
- package/src/cli/deploy-command.ts +122 -0
- package/src/cli/dev-command.ts +232 -0
- package/src/cli/docs-command.ts +53 -0
- package/src/cli/info-command.ts +40 -0
- package/src/cli/init-command.ts +53 -0
- package/src/cli/main.ts +3 -0
- package/src/cli/mcp-command.ts +98 -0
- package/src/cli/preview-command.ts +98 -0
- package/src/cli/reporter.ts +67 -0
- package/src/config/config-explainer.ts +158 -0
- package/src/config/config-file-loader.ts +76 -0
- package/src/config/config-resolver.ts +300 -0
- package/src/config/config-validator.ts +208 -0
- package/src/config/define-config.ts +6 -0
- package/src/config/types.ts +57 -0
- package/src/deploy/cloud-api.ts +194 -0
- package/src/deploy/code-package.ts +44 -0
- package/src/deploy/deployer-registry.ts +44 -0
- package/src/deploy/request-signer.ts +155 -0
- package/src/deploy/zip-writer.ts +132 -0
- package/src/docs/docs-index.ts +174 -0
- package/src/events/event-bus.ts +94 -0
- package/src/events/hook-runner.ts +78 -0
- package/src/index.ts +57 -0
- package/src/info/project-inspector.ts +352 -0
- package/src/init/project-initializer.ts +111 -0
- package/src/mcp/dev-activity.ts +71 -0
- package/src/mcp/dev-mcp-endpoint.ts +323 -0
- package/src/mcp/mcp-server.ts +251 -0
- package/src/mcp/project-mcp-tools.ts +216 -0
- package/src/modules/module-host.ts +489 -0
- package/src/preset/builtin-presets.ts +26 -0
- package/src/preset/cloudflare/cloudflare-deployer.ts +126 -0
- package/src/preset/cloudflare/cloudflare-preset.ts +97 -0
- package/src/preset/cloudflare/wrangler-config.ts +173 -0
- package/src/preset/cloudflare/wrangler.ts +113 -0
- package/src/preset/fc/fc-deployer.ts +237 -0
- package/src/preset/fc/fc-preset.ts +51 -0
- package/src/preset/lambda/lambda-deployer.ts +317 -0
- package/src/preset/lambda/lambda-preset.ts +45 -0
- package/src/preset/preset-output.ts +55 -0
- package/src/preset/preset-registry.ts +65 -0
- package/src/preset/scf/scf-deployer.ts +232 -0
- package/src/preset/scf/scf-preset.ts +45 -0
- package/src/preset/serverless-scripts.ts +132 -0
- package/src/preset/vercel/vercel-deployer.ts +168 -0
- package/src/preset/vercel/vercel-preset.ts +111 -0
- package/src/test/fixture-project.ts +50 -0
- package/src/testing/create-test-app.ts +73 -0
- package/src/toolchain/toolchain.ts +121 -0
- package/src/utils/json-util.ts +67 -0
- package/src/utils/text-util.ts +68 -0
- package/templates/backend/README.md +13 -0
- package/templates/backend/_gitignore +5 -0
- package/templates/backend/cell.yml +3 -0
- package/templates/backend/package.json +23 -0
- package/templates/{file-service/src → backend/src/node}/home-controller.ts +5 -2
- package/templates/{file-service/src → backend/src/node}/module.ts +0 -1
- package/templates/backend/template.json +3 -0
- package/templates/backend/test/app.spec.ts +19 -0
- package/templates/backend/tsconfig.json +25 -0
- package/templates/fullstack/README.md +13 -0
- package/templates/fullstack/_gitignore +5 -0
- package/templates/fullstack/cell.yml +6 -0
- package/templates/fullstack/package.json +27 -0
- package/templates/fullstack/src/browser/home.view.tsx +19 -0
- package/templates/{cell-component/src → fullstack/src/browser}/module.ts +1 -1
- package/templates/fullstack/src/common/greeting-protocol.ts +5 -0
- package/templates/fullstack/src/node/greeting-server.ts +13 -0
- package/templates/{admin-app/src/browser → fullstack/src/node}/module.ts +2 -1
- package/templates/fullstack/template.json +3 -0
- package/templates/fullstack/test/app.spec.ts +18 -0
- package/templates/fullstack/tsconfig.json +27 -0
- package/bin/cell +0 -2
- package/lib/build/build-manager.d.ts +0 -9
- package/lib/build/build-manager.d.ts.map +0 -1
- package/lib/build/build-manager.js +0 -41
- package/lib/build/build-manager.js.map +0 -1
- package/lib/build/build.d.ts +0 -6
- package/lib/build/build.d.ts.map +0 -1
- package/lib/build/build.js +0 -16
- package/lib/build/build.js.map +0 -1
- package/lib/cell-main.d.ts +0 -2
- package/lib/cell-main.d.ts.map +0 -1
- package/lib/cell-main.js +0 -110
- package/lib/cell-main.js.map +0 -1
- package/lib/cell.d.ts +0 -2
- package/lib/cell.d.ts.map +0 -1
- package/lib/cell.js +0 -194
- package/lib/cell.js.map +0 -1
- package/lib/config/config.d.ts +0 -12
- package/lib/config/config.d.ts.map +0 -1
- package/lib/config/config.js +0 -48
- package/lib/config/config.js.map +0 -1
- package/lib/deploy/deploy.d.ts +0 -7
- package/lib/deploy/deploy.d.ts.map +0 -1
- package/lib/deploy/deploy.js +0 -30
- package/lib/deploy/deploy.js.map +0 -1
- package/lib/info/info.d.ts +0 -6
- package/lib/info/info.d.ts.map +0 -1
- package/lib/info/info.js +0 -21
- package/lib/info/info.js.map +0 -1
- package/lib/init/init-manager.d.ts +0 -33
- package/lib/init/init-manager.d.ts.map +0 -1
- package/lib/init/init-manager.js +0 -141
- package/lib/init/init-manager.js.map +0 -1
- package/lib/init/init.d.ts +0 -4
- package/lib/init/init.d.ts.map +0 -1
- package/lib/init/init.js +0 -17
- package/lib/init/init.js.map +0 -1
- package/lib/init/templates.d.ts +0 -2
- package/lib/init/templates.d.ts.map +0 -1
- package/lib/init/templates.js +0 -23
- package/lib/init/templates.js.map +0 -1
- package/lib/package.spec.d.ts +0 -2
- package/lib/package.spec.d.ts.map +0 -1
- package/lib/package.spec.js +0 -7
- package/lib/package.spec.js.map +0 -1
- package/lib/props/props.d.ts +0 -9
- package/lib/props/props.d.ts.map +0 -1
- package/lib/props/props.js +0 -49
- package/lib/props/props.js.map +0 -1
- package/lib/serve/serve-manager.d.ts +0 -8
- package/lib/serve/serve-manager.d.ts.map +0 -1
- package/lib/serve/serve-manager.js +0 -44
- package/lib/serve/serve-manager.js.map +0 -1
- package/lib/serve/serve.d.ts +0 -8
- package/lib/serve/serve.d.ts.map +0 -1
- package/lib/serve/serve.js +0 -25
- package/lib/serve/serve.js.map +0 -1
- package/lib/update/update.d.ts +0 -9
- package/lib/update/update.d.ts.map +0 -1
- package/lib/update/update.js +0 -56
- package/lib/update/update.js.map +0 -1
- package/lib/utils/banner-util.d.ts +0 -6
- package/lib/utils/banner-util.d.ts.map +0 -1
- package/lib/utils/banner-util.js +0 -44
- package/lib/utils/banner-util.js.map +0 -1
- package/lib/utils/index.d.ts +0 -2
- package/lib/utils/index.d.ts.map +0 -1
- package/lib/utils/index.js +0 -18
- package/lib/utils/index.js.map +0 -1
- package/src/build/build-manager.ts +0 -50
- package/src/build/build.ts +0 -17
- package/src/cell-main.ts +0 -125
- package/src/cell.ts +0 -215
- package/src/config/config.ts +0 -56
- package/src/deploy/deploy.ts +0 -31
- package/src/info/info.ts +0 -23
- package/src/init/init-manager.ts +0 -163
- package/src/init/init.ts +0 -15
- package/src/init/templates.ts +0 -19
- package/src/package.spec.ts +0 -5
- package/src/props/props.ts +0 -48
- package/src/serve/serve-manager.ts +0 -51
- package/src/serve/serve.ts +0 -29
- package/src/update/update.ts +0 -61
- package/src/utils/banner-util.ts +0 -41
- package/src/utils/index.ts +0 -1
- package/templates/accounts/README.md +0 -92
- package/templates/accounts/cell-database.yml +0 -17
- package/templates/accounts/cell-locale.yml +0 -17
- package/templates/accounts/cell-oauth2.0.yml +0 -8
- package/templates/accounts/cell-theme.yml +0 -9
- package/templates/accounts/cell.yml +0 -10
- package/templates/accounts/favicon.ico +0 -0
- package/templates/accounts/package.json +0 -48
- package/templates/accounts/src/browser/home.view.tsx +0 -86
- package/templates/accounts/src/browser/index.ts +0 -3
- package/templates/accounts/src/browser/login.view.tsx +0 -78
- package/templates/accounts/src/browser/module.ts +0 -3
- package/templates/accounts/src/common/entity-protocol.ts +0 -7
- package/templates/accounts/src/common/index.ts +0 -1
- package/templates/accounts/src/node/authentication/authentication-success-handler.ts +0 -69
- package/templates/accounts/src/node/authentication/index.ts +0 -1
- package/templates/accounts/src/node/entity/base-entity.ts +0 -13
- package/templates/accounts/src/node/entity/connection.ts +0 -52
- package/templates/accounts/src/node/entity/index.ts +0 -1
- package/templates/accounts/src/node/entity/user.ts +0 -73
- package/templates/accounts/src/node/error/error.ts +0 -14
- package/templates/accounts/src/node/error/index.ts +0 -1
- package/templates/accounts/src/node/index.ts +0 -2
- package/templates/accounts/src/node/module.ts +0 -9
- package/templates/accounts/src/node/user/index.ts +0 -4
- package/templates/accounts/src/node/user/user-protocol.ts +0 -19
- package/templates/accounts/src/node/user/user-repository.ts +0 -72
- package/templates/accounts/src/node/user/user-service.ts +0 -36
- package/templates/accounts/tsconfig.json +0 -32
- package/templates/admin-app/.github/workflows/deploy.yml +0 -25
- package/templates/admin-app/.vscode/launch.json +0 -23
- package/templates/admin-app/README.md +0 -92
- package/templates/admin-app/cell-database.yml +0 -7
- package/templates/admin-app/cell.yml +0 -93
- package/templates/admin-app/package.json +0 -37
- package/templates/admin-app/src/browser/user.view.tsx +0 -40
- package/templates/admin-app/src/common/index.ts +0 -1
- package/templates/admin-app/src/common/user-protocol.ts +0 -23
- package/templates/admin-app/src/node/entity/index.ts +0 -1
- package/templates/admin-app/src/node/entity/user.ts +0 -15
- package/templates/admin-app/src/node/module.ts +0 -8
- package/templates/admin-app/src/node/user-service.ts +0 -41
- package/templates/admin-app/tsconfig.json +0 -32
- package/templates/backend-app/.github/workflows/deploy.yml +0 -25
- package/templates/backend-app/.vscode/launch.json +0 -23
- package/templates/backend-app/README.md +0 -92
- package/templates/backend-app/cell.yml +0 -0
- package/templates/backend-app/package.json +0 -33
- package/templates/backend-app/src/home-controller.ts +0 -11
- package/templates/backend-app/src/module.ts +0 -4
- package/templates/backend-app/src/user-controller.ts +0 -48
- package/templates/backend-app/test/home-controller.spec.ts +0 -19
- package/templates/backend-app/tsconfig.json +0 -32
- package/templates/cell-component/README.md +0 -27
- package/templates/cell-component/cell.yml +0 -0
- package/templates/cell-component/package.json +0 -29
- package/templates/cell-component/src/echo-service.ts +0 -16
- package/templates/cell-component/src/index.ts +0 -1
- package/templates/cell-component/src/package.spec.ts +0 -5
- package/templates/cell-component/tsconfig.json +0 -37
- package/templates/database-app/.github/workflows/deploy.yml +0 -25
- package/templates/database-app/.vscode/launch.json +0 -23
- package/templates/database-app/README.md +0 -92
- package/templates/database-app/cell.yml +0 -17
- package/templates/database-app/package.json +0 -31
- package/templates/database-app/src/entity/index.ts +0 -1
- package/templates/database-app/src/entity/user.ts +0 -13
- package/templates/database-app/src/home-controller.ts +0 -11
- package/templates/database-app/src/module.ts +0 -8
- package/templates/database-app/src/user-controller.ts +0 -43
- package/templates/database-app/tsconfig.json +0 -32
- package/templates/docker-app/.github/workflows/deploy.yml +0 -25
- package/templates/docker-app/.vscode/launch.json +0 -23
- package/templates/docker-app/Dockerfile +0 -27
- package/templates/docker-app/README.md +0 -93
- package/templates/docker-app/cell.yml +0 -0
- package/templates/docker-app/package.json +0 -31
- package/templates/docker-app/src/browser/assets/logo.png +0 -0
- package/templates/docker-app/src/browser/css-shims.d.ts +0 -30
- package/templates/docker-app/src/browser/hello.view.tsx +0 -31
- package/templates/docker-app/src/browser/module.ts +0 -3
- package/templates/docker-app/src/browser/style/hello.module.scss +0 -4
- package/templates/docker-app/src/common/welcome-protocol.ts +0 -5
- package/templates/docker-app/src/node/module.ts +0 -3
- package/templates/docker-app/src/node/welcome-server.ts +0 -9
- package/templates/docker-app/tsconfig.json +0 -33
- package/templates/file-service/.github/workflows/deploy.yml +0 -25
- package/templates/file-service/.vscode/launch.json +0 -23
- package/templates/file-service/README.md +0 -92
- package/templates/file-service/cell.yml +0 -12
- package/templates/file-service/package.json +0 -34
- package/templates/file-service/src/file-controller.ts +0 -47
- package/templates/file-service/tsconfig.json +0 -32
- package/templates/jwt-app/.github/workflows/deploy.yml +0 -25
- package/templates/jwt-app/.vscode/launch.json +0 -23
- package/templates/jwt-app/README.md +0 -92
- package/templates/jwt-app/cell.yml +0 -4
- package/templates/jwt-app/package.json +0 -36
- package/templates/jwt-app/src/context.ts +0 -16
- package/templates/jwt-app/src/error-handler.ts +0 -30
- package/templates/jwt-app/src/error.ts +0 -4
- package/templates/jwt-app/src/home-controller.ts +0 -23
- package/templates/jwt-app/src/index.ts +0 -5
- package/templates/jwt-app/src/jwt-middleware.ts +0 -36
- package/templates/jwt-app/src/module.ts +0 -3
- package/templates/jwt-app/test/home-controller.spec.ts +0 -19
- package/templates/jwt-app/tsconfig.json +0 -32
- package/templates/koa-app/app.js +0 -8
- package/templates/koa-app/package.json +0 -9
- package/templates/microservice/.github/workflows/deploy.yml +0 -28
- package/templates/microservice/.vscode/launch.json +0 -24
- package/templates/microservice/README.md +0 -92
- package/templates/microservice/examples/backend-app/README.md +0 -92
- package/templates/microservice/examples/backend-app/cell-remote.yml +0 -4
- package/templates/microservice/examples/backend-app/cell.yml +0 -3
- package/templates/microservice/examples/backend-app/package.json +0 -32
- package/templates/microservice/examples/backend-app/src/api-controller.ts +0 -31
- package/templates/microservice/examples/backend-app/src/module.ts +0 -3
- package/templates/microservice/examples/backend-app/tsconfig.json +0 -32
- package/templates/microservice/package.json +0 -20
- package/templates/microservice/packages/api/README.md +0 -92
- package/templates/microservice/packages/api/cell.yml +0 -0
- package/templates/microservice/packages/api/package.json +0 -25
- package/templates/microservice/packages/api/src/common/api-protocol.ts +0 -10
- package/templates/microservice/packages/api/src/common/index.ts +0 -1
- package/templates/microservice/packages/api/tsconfig.json +0 -30
- package/templates/microservice/packages/serviceA/.vscode/launch.json +0 -23
- package/templates/microservice/packages/serviceA/README.md +0 -92
- package/templates/microservice/packages/serviceA/cell.yml +0 -6
- package/templates/microservice/packages/serviceA/package.json +0 -29
- package/templates/microservice/packages/serviceA/src/node/module.ts +0 -3
- package/templates/microservice/packages/serviceA/src/node/service-a.ts +0 -9
- package/templates/microservice/packages/serviceA/tsconfig.json +0 -30
- package/templates/microservice/packages/serviceB/README.md +0 -92
- package/templates/microservice/packages/serviceB/cell.yml +0 -5
- package/templates/microservice/packages/serviceB/package.json +0 -29
- package/templates/microservice/packages/serviceB/src/node/module.ts +0 -3
- package/templates/microservice/packages/serviceB/src/node/service-b.ts +0 -9
- package/templates/microservice/packages/serviceB/tsconfig.json +0 -30
- package/templates/microservice/tsconfig.json +0 -32
- package/templates/mycli/.vscode/launch.json +0 -33
- package/templates/mycli/bin/mycli +0 -2
- package/templates/mycli/bin/mycli-deploy +0 -2
- package/templates/mycli/bin/mycli-init +0 -2
- package/templates/mycli/package.json +0 -33
- package/templates/mycli/src/bootstrap.ts +0 -7
- package/templates/mycli/src/constants.ts +0 -1
- package/templates/mycli/src/deploy/deploy-manager.ts +0 -12
- package/templates/mycli/src/deploy/deploy.ts +0 -16
- package/templates/mycli/src/deploy/index.ts +0 -1
- package/templates/mycli/src/index.ts +0 -2
- package/templates/mycli/src/init/index.ts +0 -1
- package/templates/mycli/src/init/init-manager.ts +0 -85
- package/templates/mycli/src/init/init.ts +0 -25
- package/templates/mycli/src/init/templates.ts +0 -3
- package/templates/mycli/src/module.ts +0 -3
- package/templates/mycli/src/mycli.ts +0 -13
- package/templates/mycli/templates/application-template/README.md +0 -0
- package/templates/mycli/tsconfig.json +0 -32
- package/templates/nest-app/.eslintrc.js +0 -25
- package/templates/nest-app/.prettierrc +0 -4
- package/templates/nest-app/README.md +0 -73
- package/templates/nest-app/nest-cli.json +0 -8
- package/templates/nest-app/package.json +0 -69
- package/templates/nest-app/src/app.controller.spec.ts +0 -22
- package/templates/nest-app/src/app.controller.ts +0 -12
- package/templates/nest-app/src/app.module.ts +0 -10
- package/templates/nest-app/src/app.service.ts +0 -8
- package/templates/nest-app/src/main.ts +0 -8
- package/templates/nest-app/test/app.e2e-spec.ts +0 -24
- package/templates/nest-app/test/jest-e2e.json +0 -9
- package/templates/nest-app/tsconfig.build.json +0 -12
- package/templates/nest-app/tsconfig.json +0 -25
- package/templates/nextjs-app/.eslintrc.json +0 -3
- package/templates/nextjs-app/README.md +0 -34
- package/templates/nextjs-app/next.config.js +0 -6
- package/templates/nextjs-app/package.json +0 -20
- package/templates/nextjs-app/pages/_app.js +0 -7
- package/templates/nextjs-app/pages/api/hello.js +0 -5
- package/templates/nextjs-app/pages/index.js +0 -69
- package/templates/nextjs-app/public/favicon.ico +0 -0
- package/templates/nextjs-app/public/vercel.svg +0 -4
- package/templates/nextjs-app/styles/Home.module.css +0 -116
- package/templates/nextjs-app/styles/globals.css +0 -16
- package/templates/sample-app/.github/workflows/deploy.yml +0 -25
- package/templates/sample-app/.vscode/launch.json +0 -23
- package/templates/sample-app/README.md +0 -92
- package/templates/sample-app/cell.yml +0 -0
- package/templates/sample-app/package.json +0 -31
- package/templates/sample-app/src/browser/assets/logo.png +0 -0
- package/templates/sample-app/src/browser/css-shims.d.ts +0 -30
- package/templates/sample-app/src/browser/hello.view.tsx +0 -31
- package/templates/sample-app/src/browser/module.ts +0 -3
- package/templates/sample-app/src/browser/style/hello.module.scss +0 -4
- package/templates/sample-app/src/common/welcome-protocol.ts +0 -5
- package/templates/sample-app/src/node/module.ts +0 -3
- package/templates/sample-app/src/node/welcome-server.ts +0 -9
- package/templates/sample-app/tsconfig.json +0 -32
- package/templates/schedule/.github/workflows/deploy.yml +0 -25
- package/templates/schedule/.vscode/launch.json +0 -23
- package/templates/schedule/README.md +0 -92
- package/templates/schedule/cell.yml +0 -1
- package/templates/schedule/package.json +0 -29
- package/templates/schedule/src/module.ts +0 -3
- package/templates/schedule/src/scheduler.ts +0 -10
- package/templates/schedule/tsconfig.json +0 -32
- package/templates/standalone-app/package.json +0 -17
- package/templates/standalone-app/src/app.service.ts +0 -10
- package/templates/standalone-app/src/main.ts +0 -14
- package/templates/standalone-app/src/module.ts +0 -3
- package/templates/standalone-app/tsconfig.json +0 -30
- package/templates/vue-app/.github/workflows/deploy.yml +0 -25
- package/templates/vue-app/.vscode/launch.json +0 -23
- package/templates/vue-app/README.md +0 -92
- package/templates/vue-app/cell.yml +0 -0
- package/templates/vue-app/package.json +0 -32
- package/templates/vue-app/src/browser/App.vue +0 -32
- package/templates/vue-app/src/browser/app.ts +0 -7
- package/templates/vue-app/src/browser/components/HelloWorld.vue +0 -42
- package/templates/vue-app/src/browser/declare.d.ts +0 -7
- package/templates/vue-app/src/browser/images/logo.png +0 -0
- package/templates/vue-app/src/browser/module.ts +0 -3
- package/templates/vue-app/src/browser/router.ts +0 -13
- package/templates/vue-app/src/browser/shims-vue.d.ts +0 -5
- package/templates/vue-app/src/browser/views/About.vue +0 -5
- package/templates/vue-app/src/browser/views/Root.vue +0 -37
- package/templates/vue-app/src/common/welcome-protocol.ts +0 -5
- package/templates/vue-app/src/node/module.ts +0 -3
- package/templates/vue-app/src/node/welcome-server.ts +0 -9
- package/templates/vue-app/tsconfig.json +0 -32
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { chmodSync, copyFileSync, existsSync, mkdtempSync, readdirSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { tmpdir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { CellError, type OutputManifest } from '@celljs/kit';
|
|
6
|
+
import type { CompileTarget } from '../config/types.js';
|
|
7
|
+
|
|
8
|
+
export interface CompileOptions {
|
|
9
|
+
/** Absolute output directory with the single-file server bundle. */
|
|
10
|
+
outDir: string;
|
|
11
|
+
manifest: OutputManifest;
|
|
12
|
+
compiler: CompileTarget;
|
|
13
|
+
/** Cross-compilation target of the compiler (`bun-linux-x64`, `x86_64-unknown-linux-gnu`). */
|
|
14
|
+
target?: string;
|
|
15
|
+
env: NodeJS.ProcessEnv;
|
|
16
|
+
info(message: string): void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
type Run = (
|
|
20
|
+
command: string,
|
|
21
|
+
args: string[],
|
|
22
|
+
options?: { cwd?: string; env?: NodeJS.ProcessEnv },
|
|
23
|
+
) => { status: number | null; stdout: string; stderr: string; error?: Error };
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* `cell build --compile [bun|node|deno]` (docs/design/architecture.md L3): turns the single-file server
|
|
27
|
+
* bundle, with the frontend inside, into one executable `app` in the output directory. Bun and Deno
|
|
28
|
+
* compile it themselves; Node.js uses a single executable application (SEA: a CommonJS bundle
|
|
29
|
+
* injected into a copy of node with postject).
|
|
30
|
+
*/
|
|
31
|
+
export class ExecutableCompiler {
|
|
32
|
+
static readonly SEA_FUSE = 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2';
|
|
33
|
+
static readonly POSTJECT = 'postject@1.0.0-alpha.6';
|
|
34
|
+
|
|
35
|
+
constructor(
|
|
36
|
+
protected readonly options: CompileOptions,
|
|
37
|
+
protected readonly run: Run = ExecutableCompiler.spawn,
|
|
38
|
+
) {}
|
|
39
|
+
|
|
40
|
+
static spawn: Run = (command, args, options = {}) => {
|
|
41
|
+
const result = spawnSync(command, args, { cwd: options.cwd, env: options.env, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
|
|
42
|
+
return { status: result.status, stdout: result.stdout ?? '', stderr: result.stderr ?? '', error: result.error };
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
get file(): string {
|
|
46
|
+
const windows = this.options.target ? /windows|win32|msvc/.test(this.options.target) : process.platform === 'win32';
|
|
47
|
+
return windows ? 'app.exe' : 'app';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
compile(): OutputManifest {
|
|
51
|
+
const { outDir, manifest, compiler, target } = this.options;
|
|
52
|
+
if (!manifest.server) {
|
|
53
|
+
throw new CellError({
|
|
54
|
+
code: 'CELL_COMPILE_NO_SERVER',
|
|
55
|
+
message: 'There is no server to compile: the project builds no backend.',
|
|
56
|
+
hint: 'Build without --compile, or add a backend to the project.',
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
this.checkNoExternals();
|
|
60
|
+
const output = join(outDir, this.file);
|
|
61
|
+
rmSync(output, { force: true });
|
|
62
|
+
this.options.info(`Compiling ${manifest.server} into ${this.file} with ${compiler}${target ? ` (${target})` : ''}…`);
|
|
63
|
+
switch (compiler) {
|
|
64
|
+
case 'bun':
|
|
65
|
+
this.exec(
|
|
66
|
+
'bun',
|
|
67
|
+
['build', join(outDir, manifest.server), '--compile', '--outfile', output, ...(target ? ['--target', target] : [])],
|
|
68
|
+
'https://bun.sh',
|
|
69
|
+
);
|
|
70
|
+
break;
|
|
71
|
+
case 'deno':
|
|
72
|
+
this.exec(
|
|
73
|
+
'deno',
|
|
74
|
+
['compile', '--allow-all', '--no-check', '--output', output, ...(target ? ['--target', target] : []), join(outDir, manifest.server)],
|
|
75
|
+
'https://deno.com',
|
|
76
|
+
);
|
|
77
|
+
break;
|
|
78
|
+
case 'node':
|
|
79
|
+
this.node(join(outDir, manifest.server), output);
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
if (!existsSync(output)) {
|
|
83
|
+
throw new CellError({
|
|
84
|
+
code: 'CELL_COMPILE_FAILED',
|
|
85
|
+
message: `${compiler} finished without writing ${output}.`,
|
|
86
|
+
hint: 'Rerun with CELL_DEBUG=1 and report it.',
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return { ...manifest, executable: { file: this.file, compiler, ...(target ? { target } : {}) } };
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Packages copied next to the bundle (native modules, `build.external`) cannot go into the executable. */
|
|
93
|
+
protected checkNoExternals(): void {
|
|
94
|
+
const dir = join(this.options.outDir, 'server', 'node_modules');
|
|
95
|
+
if (!existsSync(dir)) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const names = readdirSync(dir)
|
|
99
|
+
.filter(name => !name.startsWith('.'))
|
|
100
|
+
.flatMap(name => (name.startsWith('@') ? readdirSync(join(dir, name)).map(sub => `${name}/${sub}`) : [name]));
|
|
101
|
+
if (names.length > 0) {
|
|
102
|
+
throw new CellError({
|
|
103
|
+
code: 'CELL_COMPILE_EXTERNALS',
|
|
104
|
+
message: `The executable cannot contain the packages that stay outside the server bundle: ${names.join(', ')}.`,
|
|
105
|
+
hint: 'Remove them from build.external (and from the optionalDependencies of components) so they are bundled, or ship .cell/output without --compile.',
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Node.js SEA: the blob of the CommonJS bundle, injected into a copy of the node executable. */
|
|
111
|
+
protected node(server: string, output: string): void {
|
|
112
|
+
if (this.options.manifest.format !== 'cjs') {
|
|
113
|
+
throw new CellError({
|
|
114
|
+
code: 'CELL_CONFIG_CONFLICT',
|
|
115
|
+
message: 'A Node.js executable needs a CommonJS server bundle.',
|
|
116
|
+
hint: 'Build with --compile node and without --format esm.',
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
if (this.options.target) {
|
|
120
|
+
throw new CellError({
|
|
121
|
+
code: 'CELL_ARGUMENT_INVALID',
|
|
122
|
+
message: 'Node.js executables cannot be cross-compiled: --compile-target is for bun and deno.',
|
|
123
|
+
hint: 'Build on the platform you target, or use --compile bun --compile-target <target>.',
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const work = mkdtempSync(join(tmpdir(), 'cell-sea-'));
|
|
127
|
+
try {
|
|
128
|
+
const blob = join(work, 'sea-prep.blob');
|
|
129
|
+
writeFileSync(join(work, 'sea-config.json'), JSON.stringify({ main: server, output: blob, disableExperimentalSEAWarning: true }));
|
|
130
|
+
this.exec('node', ['--experimental-sea-config', join(work, 'sea-config.json')], 'https://nodejs.org', work);
|
|
131
|
+
const node = this.exec('node', ['-p', 'process.execPath'], 'https://nodejs.org').trim();
|
|
132
|
+
copyFileSync(node, output);
|
|
133
|
+
chmodSync(output, 0o755);
|
|
134
|
+
const mac = process.platform === 'darwin';
|
|
135
|
+
if (mac) {
|
|
136
|
+
this.exec('codesign', ['--remove-signature', output], 'Xcode command line tools');
|
|
137
|
+
}
|
|
138
|
+
this.exec(
|
|
139
|
+
'npx',
|
|
140
|
+
[
|
|
141
|
+
'--yes',
|
|
142
|
+
ExecutableCompiler.POSTJECT,
|
|
143
|
+
output,
|
|
144
|
+
'NODE_SEA_BLOB',
|
|
145
|
+
blob,
|
|
146
|
+
'--sentinel-fuse',
|
|
147
|
+
ExecutableCompiler.SEA_FUSE,
|
|
148
|
+
...(mac ? ['--macho-segment-name', 'NODE_SEA'] : []),
|
|
149
|
+
],
|
|
150
|
+
'npm',
|
|
151
|
+
);
|
|
152
|
+
if (mac) {
|
|
153
|
+
this.exec('codesign', ['--sign', '-', output], 'Xcode command line tools');
|
|
154
|
+
}
|
|
155
|
+
} finally {
|
|
156
|
+
rmSync(work, { recursive: true, force: true });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
protected exec(command: string, args: string[], install: string, cwd?: string): string {
|
|
161
|
+
const result = this.run(command, args, { cwd, env: this.options.env });
|
|
162
|
+
if (result.error && (result.error as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
163
|
+
throw new CellError({
|
|
164
|
+
code: 'CELL_COMPILE_TOOL_MISSING',
|
|
165
|
+
message: `${command} is not installed, and --compile ${this.options.compiler} needs it.`,
|
|
166
|
+
hint: `Install it (${install}) or compile with another tool: --compile bun, --compile node or --compile deno.`,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
if (result.status !== 0) {
|
|
170
|
+
const output = `${result.stderr}\n${result.stdout}`.trim().split('\n').slice(-15).join('\n');
|
|
171
|
+
throw new CellError({
|
|
172
|
+
code: 'CELL_COMPILE_FAILED',
|
|
173
|
+
message: `${command} ${args[0]} failed with exit code ${result.status}: ${output || 'no output'}`,
|
|
174
|
+
hint: 'Fix what the compiler reports; the single-file bundle it compiled is in the output directory.',
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
return result.stdout;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
5
|
+
import { CellError, type CheckIssue } from '@celljs/kit';
|
|
6
|
+
import { CellDevServer, ProjectLoader } from '@celljs/vite';
|
|
7
|
+
import { ProjectInspector } from '../info/project-inspector.js';
|
|
8
|
+
import type { Toolchain } from '../toolchain/toolchain.js';
|
|
9
|
+
|
|
10
|
+
/** The outcome of one check. */
|
|
11
|
+
export interface CheckReport {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
/** Module that registered the check; absent for the built-in ones. */
|
|
15
|
+
source?: string;
|
|
16
|
+
durationMs: number;
|
|
17
|
+
issues: CheckIssue[];
|
|
18
|
+
/** Why the check did not run. */
|
|
19
|
+
skipped?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Check {
|
|
23
|
+
name: string;
|
|
24
|
+
description: string;
|
|
25
|
+
source?: string;
|
|
26
|
+
run(): Promise<CheckIssue[] | { skipped: string }>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Shapes of inversify errors and the codes `cell check` gives them (docs/design/agent-first.md R5). */
|
|
30
|
+
const DI_ERRORS: [RegExp, string, string][] = [
|
|
31
|
+
[
|
|
32
|
+
/^No matching bindings found for serviceIdentifier: (.+)/,
|
|
33
|
+
'CELL_DI_NO_BINDING',
|
|
34
|
+
'Bind the identifier in a DI module (@Component), or mark the injection @Optional().',
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
/^Ambiguous match found for serviceIdentifier: (.+)/,
|
|
38
|
+
'CELL_DI_AMBIGUOUS',
|
|
39
|
+
'Inject all of them with @Autowired(...) on an array, give one rebind: true, or name them.',
|
|
40
|
+
],
|
|
41
|
+
[/^Circular dependency found: (.+)/, 'CELL_DI_CIRCULAR', 'Break the cycle: inject lazily, or move the shared part into another component.'],
|
|
42
|
+
[/^Missing required @inject or @multiInject annotation/, 'CELL_DI_MISSING_INJECT', 'Add @Autowired(...) to the constructor parameter or property.'],
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `cell check` (docs/design/agent-first.md R4): the checks that tell before running whether the
|
|
47
|
+
* project works: configuration, TypeScript types, decorator settings, DI bindings of the backend,
|
|
48
|
+
* and the checks of toolchain modules. Every finding is a CheckIssue with a stable code.
|
|
49
|
+
*/
|
|
50
|
+
export class ProjectChecker {
|
|
51
|
+
static readonly BUILTIN = ['config', 'types', 'decorators', 'di'];
|
|
52
|
+
|
|
53
|
+
constructor(
|
|
54
|
+
protected readonly toolchain: Toolchain,
|
|
55
|
+
protected readonly options: { env?: NodeJS.ProcessEnv; skip?: string[] } = {},
|
|
56
|
+
) {}
|
|
57
|
+
|
|
58
|
+
get root(): string {
|
|
59
|
+
return this.toolchain.config.root;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Names of the checks that `--skip` accepts. */
|
|
63
|
+
get names(): string[] {
|
|
64
|
+
return this.checks().map(check => check.name);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async run(): Promise<CheckReport[]> {
|
|
68
|
+
const skip = new Set(this.options.skip ?? []);
|
|
69
|
+
const unknown = [...skip].filter(name => !this.names.includes(name));
|
|
70
|
+
if (unknown.length > 0) {
|
|
71
|
+
throw new CellError({
|
|
72
|
+
code: 'CELL_ARGUMENT_INVALID',
|
|
73
|
+
message: `Unknown check '${unknown[0]}'. Checks: ${this.names.join(', ')}.`,
|
|
74
|
+
hint: 'Pass a check name to --skip.',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
const reports: CheckReport[] = [];
|
|
78
|
+
for (const check of this.checks()) {
|
|
79
|
+
const started = performance.now();
|
|
80
|
+
const base = { name: check.name, description: check.description, ...(check.source ? { source: check.source } : {}) };
|
|
81
|
+
if (skip.has(check.name)) {
|
|
82
|
+
reports.push({ ...base, durationMs: 0, issues: [], skipped: '--skip' });
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
let outcome: CheckIssue[] | { skipped: string };
|
|
86
|
+
try {
|
|
87
|
+
outcome = await check.run();
|
|
88
|
+
} catch (error) {
|
|
89
|
+
const failure = CellError.is(error) ? error : undefined;
|
|
90
|
+
outcome = [
|
|
91
|
+
{
|
|
92
|
+
level: 'error',
|
|
93
|
+
code: failure?.code ?? 'CELL_CHECK_FAILED',
|
|
94
|
+
message: failure?.message ?? `The ${check.name} check failed: ${(error as Error)?.message ?? String(error)}`,
|
|
95
|
+
...(failure?.file ? { file: failure.file } : {}),
|
|
96
|
+
...(failure?.line ? { line: failure.line } : {}),
|
|
97
|
+
...(failure?.hint ? { hint: failure.hint } : {}),
|
|
98
|
+
},
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
const durationMs = Math.round(performance.now() - started);
|
|
102
|
+
reports.push(Array.isArray(outcome) ? { ...base, durationMs, issues: outcome } : { ...base, durationMs, issues: [], skipped: outcome.skipped });
|
|
103
|
+
}
|
|
104
|
+
return reports;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
protected checks(): Check[] {
|
|
108
|
+
const builtin: Check[] = [
|
|
109
|
+
{ name: 'config', description: 'cell.config.ts, cell*.yml, modes, entries and environment overrides', run: async () => this.config() },
|
|
110
|
+
{ name: 'types', description: 'TypeScript types (tsc --noEmit)', run: () => this.types() },
|
|
111
|
+
{ name: 'decorators', description: 'tsconfig settings the DI decorators need', run: async () => this.decorators() },
|
|
112
|
+
{ name: 'di', description: 'every DI binding of the backend resolves', run: () => this.di() },
|
|
113
|
+
];
|
|
114
|
+
const modules = this.toolchain.modules.checks.map(({ source, value }) => ({
|
|
115
|
+
name: value.name,
|
|
116
|
+
description: value.description,
|
|
117
|
+
source,
|
|
118
|
+
run: async () => value.run({ root: this.root, mode: this.toolchain.config.mode, project: this.project() }),
|
|
119
|
+
}));
|
|
120
|
+
return [...builtin, ...modules];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
protected project() {
|
|
124
|
+
return new ProjectLoader({ ...this.toolchain.projectOptions(), env: this.options.env }).load();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
protected config(): CheckIssue[] {
|
|
128
|
+
const { config, preset, presets, modules } = this.toolchain;
|
|
129
|
+
const inspector = new ProjectInspector(config, preset, presets.names, { projectOptions: this.toolchain.projectOptions(), modules: modules.loaded });
|
|
130
|
+
inspector.inspect({ env: this.options.env });
|
|
131
|
+
return inspector.issues;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** The nearest tsconfig.json of the project, with `extends` of relative files merged. */
|
|
135
|
+
protected tsconfig(): { file: string; compilerOptions: Record<string, unknown> } | undefined {
|
|
136
|
+
const file = join(this.root, 'tsconfig.json');
|
|
137
|
+
if (!existsSync(file)) {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
const read = (path: string, seen: Set<string>): Record<string, unknown> => {
|
|
141
|
+
const json = ProjectChecker.parseJsonc(readFileSync(path, 'utf8')) as { extends?: string | string[]; compilerOptions?: Record<string, unknown> };
|
|
142
|
+
const bases = [json.extends ?? []].flat().filter(base => base.startsWith('.') || isAbsolute(base));
|
|
143
|
+
let options: Record<string, unknown> = {};
|
|
144
|
+
for (const base of bases) {
|
|
145
|
+
const target = resolve(dirname(path), base.endsWith('.json') ? base : `${base}.json`);
|
|
146
|
+
if (existsSync(target) && !seen.has(target)) {
|
|
147
|
+
seen.add(target);
|
|
148
|
+
options = { ...options, ...read(target, seen) };
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return { ...options, ...(json.compilerOptions ?? {}) };
|
|
152
|
+
};
|
|
153
|
+
return { file, compilerOptions: read(file, new Set([file])) };
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
protected decorators(): CheckIssue[] | { skipped: string } {
|
|
157
|
+
const tsconfig = this.tsconfig();
|
|
158
|
+
if (!tsconfig) {
|
|
159
|
+
return { skipped: 'no tsconfig.json' };
|
|
160
|
+
}
|
|
161
|
+
const missing = ['experimentalDecorators', 'emitDecoratorMetadata'].filter(option => tsconfig.compilerOptions[option] !== true);
|
|
162
|
+
return missing.map(option => ({
|
|
163
|
+
level: 'warning' as const,
|
|
164
|
+
code: 'CELL_TSCONFIG_DECORATORS',
|
|
165
|
+
message: `tsconfig.json does not set ${option}: true. Cell builds with legacy decorators and their metadata, so tsc and editors check a different program.`,
|
|
166
|
+
file: tsconfig.file,
|
|
167
|
+
hint: `Set "${option}": true in compilerOptions.`,
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
protected async types(): Promise<CheckIssue[] | { skipped: string }> {
|
|
172
|
+
const tsconfig = this.tsconfig();
|
|
173
|
+
if (!tsconfig) {
|
|
174
|
+
return { skipped: 'no tsconfig.json' };
|
|
175
|
+
}
|
|
176
|
+
let tsc: string;
|
|
177
|
+
try {
|
|
178
|
+
const require = createRequire(join(this.root, 'package.json'));
|
|
179
|
+
const manifest = require.resolve('typescript/package.json');
|
|
180
|
+
const bin = (JSON.parse(readFileSync(manifest, 'utf8')) as { bin?: Record<string, string> }).bin?.tsc;
|
|
181
|
+
if (!bin) {
|
|
182
|
+
return { skipped: 'the installed typescript has no tsc' };
|
|
183
|
+
}
|
|
184
|
+
tsc = join(dirname(manifest), bin);
|
|
185
|
+
} catch {
|
|
186
|
+
return { skipped: 'typescript is not installed' };
|
|
187
|
+
}
|
|
188
|
+
const output = await new Promise<string>((resolvePromise, reject) => {
|
|
189
|
+
const child = spawn(process.execPath.includes('bun') ? 'node' : process.execPath, [tsc, '--noEmit', '--pretty', 'false', '-p', tsconfig.file], {
|
|
190
|
+
cwd: this.root,
|
|
191
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
192
|
+
});
|
|
193
|
+
let text = '';
|
|
194
|
+
child.stdout.on('data', chunk => {
|
|
195
|
+
text += chunk;
|
|
196
|
+
});
|
|
197
|
+
child.stderr.on('data', chunk => {
|
|
198
|
+
text += chunk;
|
|
199
|
+
});
|
|
200
|
+
child.on('error', reject);
|
|
201
|
+
child.on('close', () => resolvePromise(text));
|
|
202
|
+
});
|
|
203
|
+
return ProjectChecker.parseTsc(output, this.root);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** `file(line,col): error TS1234: message`, with indented continuation lines. */
|
|
207
|
+
static parseTsc(output: string, root: string): CheckIssue[] {
|
|
208
|
+
const issues: CheckIssue[] = [];
|
|
209
|
+
for (const line of output.split(/\r?\n/)) {
|
|
210
|
+
const match = /^(.+?)\((\d+),(\d+)\): (error|warning) (TS\d+): (.*)$/.exec(line);
|
|
211
|
+
if (match) {
|
|
212
|
+
issues.push({
|
|
213
|
+
level: match[4] === 'error' ? 'error' : 'warning',
|
|
214
|
+
code: match[5],
|
|
215
|
+
message: match[6],
|
|
216
|
+
file: resolve(root, match[1]),
|
|
217
|
+
line: Number(match[2]),
|
|
218
|
+
column: Number(match[3]),
|
|
219
|
+
});
|
|
220
|
+
} else if (/^\s+\S/.test(line) && issues.length > 0) {
|
|
221
|
+
issues[issues.length - 1].message += `\n${line.trim()}`;
|
|
222
|
+
} else if (/^error (TS\d+): (.*)$/.test(line)) {
|
|
223
|
+
const [, tsCode, message] = /^error (TS\d+): (.*)$/.exec(line) ?? [];
|
|
224
|
+
issues.push({ level: 'error', code: tsCode, message });
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return issues;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
/** Loads the backend's container (not the application) and resolves every binding. */
|
|
231
|
+
protected async di(): Promise<CheckIssue[] | { skipped: string }> {
|
|
232
|
+
const options = this.toolchain.projectOptions();
|
|
233
|
+
const server = new CellDevServer({
|
|
234
|
+
...options,
|
|
235
|
+
mode: this.toolchain.config.mode,
|
|
236
|
+
env: this.options.env,
|
|
237
|
+
vite: this.toolchain.config.vite,
|
|
238
|
+
plugins: this.toolchain.modules.vitePlugins(),
|
|
239
|
+
listen: false,
|
|
240
|
+
backend: false,
|
|
241
|
+
logLevel: 'silent',
|
|
242
|
+
});
|
|
243
|
+
await server.start();
|
|
244
|
+
try {
|
|
245
|
+
if (!server.project.backend) {
|
|
246
|
+
return { skipped: 'no backend target' };
|
|
247
|
+
}
|
|
248
|
+
let container: InversifyContainer;
|
|
249
|
+
try {
|
|
250
|
+
container = await (await server.import<{ container: Promise<InversifyContainer> }>('@celljs/core/lib/common/container/dynamic-container'))
|
|
251
|
+
.container;
|
|
252
|
+
// Components look the container up through ContainerProvider, as the entry sets it.
|
|
253
|
+
const { ContainerProvider } = await server.import<{ ContainerProvider: { set(c: unknown): void } }>(
|
|
254
|
+
'@celljs/core/lib/common/container/container-provider',
|
|
255
|
+
);
|
|
256
|
+
ContainerProvider.set(container);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
throw CellDevServer.toCellError(error, 'CELL_DI_MODULE_FAILED');
|
|
259
|
+
}
|
|
260
|
+
return ProjectChecker.resolveAll(container);
|
|
261
|
+
} finally {
|
|
262
|
+
await server.close();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Resolves every binding. One cause (a missing binding, a cycle) breaks every binding that depends
|
|
268
|
+
* on it: it is reported once, from the binding that needs it, with the count of the others.
|
|
269
|
+
*/
|
|
270
|
+
static async resolveAll(container: InversifyContainer): Promise<CheckIssue[]> {
|
|
271
|
+
const causes = new Map<string, { issue: CheckIssue; requester?: string; count: number }>();
|
|
272
|
+
for (const id of container._bindingDictionary.getMap().keys()) {
|
|
273
|
+
try {
|
|
274
|
+
await container.getAllAsync(id);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
const issue = ProjectChecker.diIssue(id, error);
|
|
277
|
+
const { cause, requester } = ProjectChecker.diCause(error);
|
|
278
|
+
const found = causes.get(cause);
|
|
279
|
+
if (!found) {
|
|
280
|
+
causes.set(cause, { issue, requester, count: 1 });
|
|
281
|
+
} else {
|
|
282
|
+
found.count++;
|
|
283
|
+
if (requester && ProjectChecker.identifierName(id) === requester) {
|
|
284
|
+
found.issue = issue;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return [...causes.values()].map(({ issue, count }) =>
|
|
290
|
+
count === 1 ? issue : { ...issue, message: `${issue.message}; ${count - 1} other binding${count === 2 ? '' : 's'} fail because of it` },
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** What failed, without the binding it was resolved from; and the binding that needs it. */
|
|
295
|
+
protected static diCause(error: unknown): { cause: string; requester?: string } {
|
|
296
|
+
const text = String((error as Error)?.message ?? error);
|
|
297
|
+
const path = /Trying to resolve bindings for "([^"]+)"/.exec(text)?.[1];
|
|
298
|
+
return { cause: `${text.split('\n')[0].trim()}\0${path ?? ''}`, requester: path?.split(' --> ').pop()?.trim() };
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
static identifierName(id: unknown): string {
|
|
302
|
+
if (typeof id === 'symbol') {
|
|
303
|
+
return id.description ?? id.toString();
|
|
304
|
+
}
|
|
305
|
+
if (typeof id === 'function') {
|
|
306
|
+
return id.name || '(anonymous class)';
|
|
307
|
+
}
|
|
308
|
+
return String(id);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
static diIssue(id: unknown, error: unknown): CheckIssue {
|
|
312
|
+
const text = String((error as Error)?.message ?? error);
|
|
313
|
+
const first = text.split('\n')[0];
|
|
314
|
+
const known = DI_ERRORS.find(([pattern]) => pattern.test(first));
|
|
315
|
+
// inversify appends "Trying to resolve bindings for 'A --> B'" and the registered bindings.
|
|
316
|
+
const path = /Trying to resolve bindings for "([^"]+)"/.exec(text)?.[1];
|
|
317
|
+
const message = `Resolving ${ProjectChecker.identifierName(id)}: ${first.trim()}${path ? ` (${path})` : ''}`;
|
|
318
|
+
return known
|
|
319
|
+
? { level: 'error', code: known[1], message, hint: known[2] }
|
|
320
|
+
: {
|
|
321
|
+
// Bindings made for an injection point (`@Value`) or a request cannot be created on their own; not a finding.
|
|
322
|
+
level: 'info',
|
|
323
|
+
code: 'CELL_DI_CONSTRUCT_FAILED',
|
|
324
|
+
message,
|
|
325
|
+
hint: 'Creating it on its own failed; that is expected for bindings that need an injection point, a request or a started application.',
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/** JSON with comments and trailing commas, as tsconfig.json allows. */
|
|
330
|
+
static parseJsonc(text: string): unknown {
|
|
331
|
+
let out = '';
|
|
332
|
+
let inString = false;
|
|
333
|
+
for (let i = 0; i < text.length; i++) {
|
|
334
|
+
const char = text[i];
|
|
335
|
+
if (inString) {
|
|
336
|
+
out += char;
|
|
337
|
+
if (char === '\\') {
|
|
338
|
+
out += text[++i] ?? '';
|
|
339
|
+
} else if (char === '"') {
|
|
340
|
+
inString = false;
|
|
341
|
+
}
|
|
342
|
+
} else if (char === '"') {
|
|
343
|
+
inString = true;
|
|
344
|
+
out += char;
|
|
345
|
+
} else if (char === '/' && text[i + 1] === '/') {
|
|
346
|
+
while (i < text.length && text[i] !== '\n') {
|
|
347
|
+
i++;
|
|
348
|
+
}
|
|
349
|
+
out += '\n';
|
|
350
|
+
} else if (char === '/' && text[i + 1] === '*') {
|
|
351
|
+
i = text.indexOf('*/', i + 2);
|
|
352
|
+
i = i < 0 ? text.length : i + 1;
|
|
353
|
+
} else {
|
|
354
|
+
out += char;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
return JSON.parse(out.replace(/,(\s*[}\]])/g, '$1'));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** The part of an inversify Container that the DI check uses. */
|
|
362
|
+
interface InversifyContainer {
|
|
363
|
+
_bindingDictionary: { getMap(): Map<unknown, unknown[]> };
|
|
364
|
+
getAllAsync(id: unknown): Promise<unknown[]>;
|
|
365
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { CellError } from '@celljs/kit';
|
|
2
|
+
import { AgentGuide } from '../agent/agent-guide.js';
|
|
3
|
+
import { Toolchain } from '../toolchain/toolchain.js';
|
|
4
|
+
import { Command, type CommandContext } from './command.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `cell agent sync`: writes the agent guide of the installed versions into AGENTS.md (between
|
|
8
|
+
* markers) and `.agents/skills/cell/SKILL.md`: the Cell guide of this CLI and the AGENTS.md of
|
|
9
|
+
* every component and toolchain module (docs/design/agent-first.md R7).
|
|
10
|
+
*/
|
|
11
|
+
export class AgentCommand extends Command {
|
|
12
|
+
readonly name = 'agent';
|
|
13
|
+
readonly description = 'Write AGENTS.md and the cell skill for the installed versions';
|
|
14
|
+
override readonly arguments = 'sync';
|
|
15
|
+
|
|
16
|
+
constructor(protected readonly version: () => string) {
|
|
17
|
+
super();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async run({ values, positionals, reporter, env }: CommandContext): Promise<number> {
|
|
21
|
+
if (positionals.length !== 1 || positionals[0] !== 'sync') {
|
|
22
|
+
throw new CellError({
|
|
23
|
+
code: 'CELL_ARGUMENT_INVALID',
|
|
24
|
+
message: `Unknown agent action '${positionals.join(' ')}'.`,
|
|
25
|
+
hint: 'Use cell agent sync.',
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const toolchain = await Toolchain.create({
|
|
29
|
+
root: values.root as string | undefined,
|
|
30
|
+
command: 'info',
|
|
31
|
+
env,
|
|
32
|
+
quiet: reporter.json,
|
|
33
|
+
runHooks: false,
|
|
34
|
+
logger: reporter,
|
|
35
|
+
});
|
|
36
|
+
await toolchain.close();
|
|
37
|
+
const snippets = AgentGuide.snippets(toolchain.modules.components, toolchain.modules.docs);
|
|
38
|
+
const result = new AgentGuide(toolchain.config.root, this.version()).sync(snippets);
|
|
39
|
+
reporter.result(
|
|
40
|
+
'agent',
|
|
41
|
+
{ root: toolchain.config.root, ...result },
|
|
42
|
+
`Wrote ${result.files.join(', ')}${result.snippets.length > 0 ? ` with the guides of ${result.snippets.join(', ')}` : ''}`,
|
|
43
|
+
);
|
|
44
|
+
return 0;
|
|
45
|
+
}
|
|
46
|
+
}
|