@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,317 @@
|
|
|
1
|
+
import { CellError, type DeployContext, type Deployment, type DeployPlan, type DeployResource, defineDeployer } from '@celljs/kit';
|
|
2
|
+
import { CloudApi, CloudApiError, CloudCredentials, type CloudIo, CloudNames, DEFAULT_IO } from '../../deploy/cloud-api.js';
|
|
3
|
+
import { CodePackage } from '../../deploy/code-package.js';
|
|
4
|
+
import { RequestSigner } from '../../deploy/request-signer.js';
|
|
5
|
+
import { LambdaPreset } from './lambda-preset.js';
|
|
6
|
+
|
|
7
|
+
type Credentials = NonNullable<ReturnType<typeof CloudCredentials.aws>>;
|
|
8
|
+
|
|
9
|
+
/** The Lambda REST API and the IAM query API, signed with SigV4. */
|
|
10
|
+
export class AwsClient {
|
|
11
|
+
constructor(
|
|
12
|
+
readonly region: string,
|
|
13
|
+
protected readonly credentials: Credentials,
|
|
14
|
+
protected readonly io: CloudIo = DEFAULT_IO,
|
|
15
|
+
) {}
|
|
16
|
+
|
|
17
|
+
async lambda<T = Record<string, any>>(method: string, path: string, body?: unknown): Promise<T> {
|
|
18
|
+
const host = `lambda.${this.region}.amazonaws.com`;
|
|
19
|
+
const text = body === undefined ? '' : JSON.stringify(body);
|
|
20
|
+
const headers = RequestSigner.sigv4(
|
|
21
|
+
{ method, host, path, service: 'lambda', region: this.region, body: text, headers: text ? { 'content-type': 'application/json' } : {} },
|
|
22
|
+
this.credentials,
|
|
23
|
+
this.io.now(),
|
|
24
|
+
);
|
|
25
|
+
const response = await CloudApi.send(this.io, `https://${host}${path}`, { method, headers, body: text || undefined }, 'AWS Lambda');
|
|
26
|
+
const raw = await response.text();
|
|
27
|
+
const json = raw ? (JSON.parse(raw) as Record<string, any>) : {};
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
const type = (response.headers.get('x-amzn-errortype') ?? json.Type ?? json.__type ?? String(response.status)).split(':')[0];
|
|
30
|
+
throw new CloudApiError(response.status, type, json.message ?? json.Message ?? raw, response.headers.get('x-amzn-requestid') ?? undefined);
|
|
31
|
+
}
|
|
32
|
+
return json as T;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** An IAM query API action; returns the XML response. IAM is global, signed in us-east-1. */
|
|
36
|
+
async iam(params: Record<string, string>): Promise<string> {
|
|
37
|
+
const host = 'iam.amazonaws.com';
|
|
38
|
+
const body = new URLSearchParams({ ...params, Version: '2010-05-08' }).toString();
|
|
39
|
+
const headers = RequestSigner.sigv4(
|
|
40
|
+
{
|
|
41
|
+
method: 'POST',
|
|
42
|
+
host,
|
|
43
|
+
path: '/',
|
|
44
|
+
service: 'iam',
|
|
45
|
+
region: 'us-east-1',
|
|
46
|
+
body,
|
|
47
|
+
headers: { 'content-type': 'application/x-www-form-urlencoded; charset=utf-8' },
|
|
48
|
+
},
|
|
49
|
+
this.credentials,
|
|
50
|
+
this.io.now(),
|
|
51
|
+
);
|
|
52
|
+
const response = await CloudApi.send(this.io, `https://${host}/`, { method: 'POST', headers, body }, 'AWS IAM');
|
|
53
|
+
const xml = await response.text();
|
|
54
|
+
if (!response.ok) {
|
|
55
|
+
throw new CloudApiError(
|
|
56
|
+
response.status,
|
|
57
|
+
AwsClient.tag(xml, 'Code') ?? String(response.status),
|
|
58
|
+
AwsClient.tag(xml, 'Message') ?? xml,
|
|
59
|
+
AwsClient.tag(xml, 'RequestId'),
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return xml;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static tag(xml: string, name: string): string | undefined {
|
|
66
|
+
return new RegExp(`<${name}>([^<]*)</${name}>`).exec(xml)?.[1];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Deploys the output of the lambda preset: the output directory as the code of a Node.js function,
|
|
72
|
+
* a function URL without authentication and the permissions it needs, and, when `lambda.role` is
|
|
73
|
+
* not set, the execution role `cell-lambda-execution` (logs only). Credentials: AWS_ACCESS_KEY_ID /
|
|
74
|
+
* AWS_SECRET_ACCESS_KEY (/ AWS_SESSION_TOKEN), or a profile of ~/.aws/credentials.
|
|
75
|
+
*/
|
|
76
|
+
export class LambdaDeployment {
|
|
77
|
+
/** A zip uploaded in the request (base64 in JSON). */
|
|
78
|
+
static readonly MAX_PACKAGE = 50 * 1024 * 1024;
|
|
79
|
+
static readonly ROLE = 'cell-lambda-execution';
|
|
80
|
+
static readonly CREDENTIALS = 'AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY';
|
|
81
|
+
static readonly ASSUME_ROLE = JSON.stringify({
|
|
82
|
+
Version: '2012-10-17',
|
|
83
|
+
Statement: [{ Effect: 'Allow', Principal: { Service: 'lambda.amazonaws.com' }, Action: 'sts:AssumeRole' }],
|
|
84
|
+
});
|
|
85
|
+
static readonly BASIC_EXECUTION = 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole';
|
|
86
|
+
|
|
87
|
+
readonly name: string;
|
|
88
|
+
readonly region: string;
|
|
89
|
+
protected readonly credentials?: Credentials;
|
|
90
|
+
|
|
91
|
+
constructor(
|
|
92
|
+
protected readonly context: DeployContext,
|
|
93
|
+
protected readonly io: CloudIo = DEFAULT_IO,
|
|
94
|
+
) {
|
|
95
|
+
const { options, env, root } = context;
|
|
96
|
+
this.name = CloudNames.functionName(root, options.name, 64);
|
|
97
|
+
this.region = (options.region as string | undefined) ?? env.AWS_REGION ?? env.AWS_DEFAULT_REGION ?? 'us-east-1';
|
|
98
|
+
this.credentials = CloudCredentials.aws(env);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
get configuration(): Record<string, unknown> {
|
|
102
|
+
const { options } = this.context;
|
|
103
|
+
return {
|
|
104
|
+
Runtime: (options.runtime as string | undefined) ?? LambdaPreset.RUNTIMES[0],
|
|
105
|
+
Handler: LambdaPreset.HANDLER,
|
|
106
|
+
MemorySize: (options.memory as number | undefined) ?? 1024,
|
|
107
|
+
Timeout: (options.timeout as number | undefined) ?? 30,
|
|
108
|
+
Environment: { Variables: { NODE_ENV: 'production', ...((options.env as Record<string, string> | undefined) ?? {}) } },
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async plan(): Promise<DeployPlan> {
|
|
113
|
+
this.checkOutput();
|
|
114
|
+
const code = CodePackage.of(this.context.outDir);
|
|
115
|
+
let fn: boolean | undefined;
|
|
116
|
+
let url: boolean | undefined;
|
|
117
|
+
if (this.credentials) {
|
|
118
|
+
const client = new AwsClient(this.region, this.credentials, this.io);
|
|
119
|
+
fn = Boolean(await this.optional(() => client.lambda('GET', `/2015-03-31/functions/${this.name}`), 'GetFunction'));
|
|
120
|
+
url = fn && Boolean(await this.optional(() => client.lambda('GET', `/2021-10-31/functions/${this.name}/url`), 'GetFunctionUrlConfig'));
|
|
121
|
+
} else {
|
|
122
|
+
this.context.warn(
|
|
123
|
+
`No AWS credentials (${LambdaDeployment.CREDENTIALS}, or ~/.aws/credentials): the plan does not say whether the function exists.`,
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
const action = (found?: boolean): DeployResource['action'] => (found === undefined ? 'deploy' : found ? 'update' : 'create');
|
|
127
|
+
const { Environment: _env, ...settings } = this.configuration;
|
|
128
|
+
return {
|
|
129
|
+
deployer: 'lambda',
|
|
130
|
+
resources: [
|
|
131
|
+
...(this.context.options.role
|
|
132
|
+
? []
|
|
133
|
+
: [
|
|
134
|
+
{
|
|
135
|
+
type: 'iam-role',
|
|
136
|
+
name: LambdaDeployment.ROLE,
|
|
137
|
+
action: 'deploy',
|
|
138
|
+
details: { policy: 'AWSLambdaBasicExecutionRole' },
|
|
139
|
+
} satisfies DeployResource,
|
|
140
|
+
]),
|
|
141
|
+
{ type: 'function', name: this.name, action: action(fn), details: { region: this.region, ...settings, package: code.describe() } },
|
|
142
|
+
...(url ? [] : [{ type: 'function-url', name: this.name, action: action(url), details: { authType: 'NONE' } } satisfies DeployResource]),
|
|
143
|
+
],
|
|
144
|
+
details: { region: this.region, credentials: this.credentials ? 'AWS' : 'missing' },
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async apply(): Promise<Deployment> {
|
|
149
|
+
this.checkOutput();
|
|
150
|
+
if (!this.credentials) {
|
|
151
|
+
throw CloudCredentials.missing('AWS', LambdaDeployment.CREDENTIALS, ', or a profile in ~/.aws/credentials (AWS_PROFILE)');
|
|
152
|
+
}
|
|
153
|
+
const client = new AwsClient(this.region, this.credentials, this.io);
|
|
154
|
+
const code = CodePackage.of(this.context.outDir);
|
|
155
|
+
code.checkSize(LambdaDeployment.MAX_PACKAGE, 'Lambda', 'Keep large packages out of the server bundle and the output directory.');
|
|
156
|
+
const path = `/2015-03-31/functions/${this.name}`;
|
|
157
|
+
if (await this.optional(() => client.lambda('GET', path), 'GetFunction')) {
|
|
158
|
+
this.context.info(`Updating function ${this.name} in ${this.region} (${code.describe()})…`);
|
|
159
|
+
await this.waitReady(client);
|
|
160
|
+
await this.step('UpdateFunctionCode', () => client.lambda('PUT', `${path}/code`, { ZipFile: code.base64 }));
|
|
161
|
+
await this.waitReady(client);
|
|
162
|
+
await this.step('UpdateFunctionConfiguration', () => client.lambda('PUT', `${path}/configuration`, this.configuration));
|
|
163
|
+
} else {
|
|
164
|
+
const role = (this.context.options.role as string | undefined) ?? (await this.executionRole(client));
|
|
165
|
+
this.context.info(`Creating function ${this.name} in ${this.region} (${code.describe()})…`);
|
|
166
|
+
await this.createFunction(client, {
|
|
167
|
+
FunctionName: this.name,
|
|
168
|
+
Role: role,
|
|
169
|
+
Code: { ZipFile: code.base64 },
|
|
170
|
+
...this.configuration,
|
|
171
|
+
...this.architecture,
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
await this.waitReady(client);
|
|
175
|
+
let url = (await this.optional(() => client.lambda('GET', `/2021-10-31/functions/${this.name}/url`), 'GetFunctionUrlConfig'))?.FunctionUrl as
|
|
176
|
+
| string
|
|
177
|
+
| undefined;
|
|
178
|
+
if (!url) {
|
|
179
|
+
this.context.info('Creating the function URL…');
|
|
180
|
+
url = (await this.step('CreateFunctionUrlConfig', () => client.lambda('POST', `/2021-10-31/functions/${this.name}/url`, { AuthType: 'NONE' })))
|
|
181
|
+
.FunctionUrl;
|
|
182
|
+
// Public function URLs need both permissions (since October 2025).
|
|
183
|
+
await this.permission(client, {
|
|
184
|
+
StatementId: 'cell-function-url',
|
|
185
|
+
Action: 'lambda:InvokeFunctionUrl',
|
|
186
|
+
Principal: '*',
|
|
187
|
+
FunctionUrlAuthType: 'NONE',
|
|
188
|
+
});
|
|
189
|
+
await this.permission(client, {
|
|
190
|
+
StatementId: 'cell-function-url-invoke',
|
|
191
|
+
Action: 'lambda:InvokeFunction',
|
|
192
|
+
Principal: '*',
|
|
193
|
+
InvokedViaFunctionUrl: true,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return { url, details: { region: this.region, function: this.name } };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
protected get architecture(): Record<string, unknown> {
|
|
200
|
+
const architecture = this.context.options.architecture as string | undefined;
|
|
201
|
+
return architecture ? { Architectures: [architecture] } : {};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** The role Lambda runs the function with: `cell-lambda-execution`, created with the basic execution policy if missing. */
|
|
205
|
+
protected async executionRole(client: AwsClient): Promise<string> {
|
|
206
|
+
try {
|
|
207
|
+
return AwsClient.tag(await client.iam({ Action: 'GetRole', RoleName: LambdaDeployment.ROLE }), 'Arn') as string;
|
|
208
|
+
} catch (error) {
|
|
209
|
+
if (!(error instanceof CloudApiError) || error.code !== 'NoSuchEntity') {
|
|
210
|
+
throw error instanceof CloudApiError
|
|
211
|
+
? CloudApi.failure(
|
|
212
|
+
'IAM',
|
|
213
|
+
'GetRole',
|
|
214
|
+
error,
|
|
215
|
+
'Allow the credentials iam:GetRole, iam:CreateRole and iam:AttachRolePolicy, or set lambda.role in cell.config.ts to an existing role ARN.',
|
|
216
|
+
)
|
|
217
|
+
: error;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
this.context.info(`Creating IAM role ${LambdaDeployment.ROLE}…`);
|
|
221
|
+
const arn = await this.step('CreateRole', async () =>
|
|
222
|
+
AwsClient.tag(
|
|
223
|
+
await client.iam({
|
|
224
|
+
Action: 'CreateRole',
|
|
225
|
+
RoleName: LambdaDeployment.ROLE,
|
|
226
|
+
AssumeRolePolicyDocument: LambdaDeployment.ASSUME_ROLE,
|
|
227
|
+
Description: 'Created by Cell for Lambda functions',
|
|
228
|
+
}),
|
|
229
|
+
'Arn',
|
|
230
|
+
),
|
|
231
|
+
);
|
|
232
|
+
await this.step('AttachRolePolicy', () =>
|
|
233
|
+
client.iam({ Action: 'AttachRolePolicy', RoleName: LambdaDeployment.ROLE, PolicyArn: LambdaDeployment.BASIC_EXECUTION }),
|
|
234
|
+
);
|
|
235
|
+
return arn as string;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** A new role takes a few seconds before Lambda may assume it. */
|
|
239
|
+
protected async createFunction(client: AwsClient, body: Record<string, unknown>): Promise<void> {
|
|
240
|
+
for (let attempt = 1; ; attempt++) {
|
|
241
|
+
try {
|
|
242
|
+
await client.lambda('POST', '/2015-03-31/functions', body);
|
|
243
|
+
return;
|
|
244
|
+
} catch (error) {
|
|
245
|
+
const roleNotReady = error instanceof CloudApiError && error.code === 'InvalidParameterValueException' && /role/i.test(error.message);
|
|
246
|
+
if (!roleNotReady || attempt >= 10) {
|
|
247
|
+
throw error instanceof CloudApiError ? CloudApi.failure('Lambda', 'CreateFunction', error) : error;
|
|
248
|
+
}
|
|
249
|
+
await this.io.sleep(3000);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
protected async permission(client: AwsClient, statement: Record<string, unknown>): Promise<void> {
|
|
255
|
+
try {
|
|
256
|
+
await client.lambda('POST', `/2015-03-31/functions/${this.name}/policy`, statement);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
if (!(error instanceof CloudApiError && error.code === 'ResourceConflictException')) {
|
|
259
|
+
throw error instanceof CloudApiError ? CloudApi.failure('Lambda', 'AddPermission', error) : error;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
protected async waitReady(client: AwsClient): Promise<void> {
|
|
265
|
+
const config = await CloudApi.poll(
|
|
266
|
+
this.io,
|
|
267
|
+
() => this.step('GetFunctionConfiguration', () => client.lambda('GET', `/2015-03-31/functions/${this.name}/configuration`)),
|
|
268
|
+
c => c.State !== 'Pending' && c.LastUpdateStatus !== 'InProgress',
|
|
269
|
+
`function ${this.name} to become active`,
|
|
270
|
+
);
|
|
271
|
+
if (config.State === 'Failed' || config.LastUpdateStatus === 'Failed') {
|
|
272
|
+
throw new CellError({
|
|
273
|
+
code: 'CELL_DEPLOY_FAILED',
|
|
274
|
+
message: `Function ${this.name} failed: ${config.StateReason ?? config.LastUpdateStatusReason ?? 'no reason given'}`,
|
|
275
|
+
hint: 'Look at the function in the Lambda console; fix the reported problem and deploy again.',
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
protected async optional(call: () => Promise<Record<string, any>>, step: string): Promise<Record<string, any> | undefined> {
|
|
281
|
+
try {
|
|
282
|
+
return await call();
|
|
283
|
+
} catch (error) {
|
|
284
|
+
if (error instanceof CloudApiError && error.status === 404) {
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
throw error instanceof CloudApiError ? CloudApi.failure('Lambda', step, error) : error;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
protected checkOutput(): void {
|
|
292
|
+
if (this.context.manifest.preset !== 'lambda') {
|
|
293
|
+
throw new CellError({
|
|
294
|
+
code: 'CELL_DEPLOY_OUTPUT_MISMATCH',
|
|
295
|
+
message: `${this.context.outDir} has no output of the lambda preset (built with: ${this.context.manifest.preset ?? 'no preset'}).`,
|
|
296
|
+
hint: 'Run cell deploy --preset lambda without --skip-build, or cell build --preset lambda first.',
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
protected async step<T>(name: string, call: () => Promise<T>): Promise<T> {
|
|
302
|
+
try {
|
|
303
|
+
return await call();
|
|
304
|
+
} catch (error) {
|
|
305
|
+
throw error instanceof CloudApiError
|
|
306
|
+
? CloudApi.failure(name === 'CreateRole' || name === 'AttachRolePolicy' ? 'IAM' : 'Lambda', name, error)
|
|
307
|
+
: error;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export const lambdaDeployer = defineDeployer({
|
|
313
|
+
name: 'lambda',
|
|
314
|
+
description: 'AWS Lambda with a function URL through the AWS API (AWS_ACCESS_KEY_ID / ~/.aws/credentials)',
|
|
315
|
+
plan: context => new LambdaDeployment(context).plan(),
|
|
316
|
+
apply: context => new LambdaDeployment(context).apply(),
|
|
317
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { definePreset, type PresetOutputContext } from '@celljs/kit';
|
|
2
|
+
import { PresetOptionsSchema } from '../../deploy/cloud-api.js';
|
|
3
|
+
import { ServerlessScripts } from '../serverless-scripts.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AWS Lambda (Node.js runtime) behind a function URL: `server/lambda.mjs` starts the Cell server
|
|
7
|
+
* during the init phase and turns each HTTP event into a request to it.
|
|
8
|
+
*/
|
|
9
|
+
export namespace LambdaPreset {
|
|
10
|
+
export const HANDLER_FILE = 'server/lambda.mjs';
|
|
11
|
+
export const HANDLER = 'server/lambda.handler';
|
|
12
|
+
export const RUNTIMES = ['nodejs22.x', 'nodejs20.x'] as const;
|
|
13
|
+
|
|
14
|
+
export const OPTIONS = PresetOptionsSchema.of({
|
|
15
|
+
name: 'string',
|
|
16
|
+
region: 'string',
|
|
17
|
+
runtime: RUNTIMES,
|
|
18
|
+
architecture: ['x86_64', 'arm64'],
|
|
19
|
+
memory: 'number',
|
|
20
|
+
timeout: 'number',
|
|
21
|
+
role: 'string',
|
|
22
|
+
env: 'env',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export function output(context: PresetOutputContext): void {
|
|
26
|
+
if (!context.manifest.server) {
|
|
27
|
+
context.warn('The lambda preset deploys a server, but the project builds no backend.');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (context.manifest.server !== 'server/index.mjs') {
|
|
31
|
+
context.warn(`The lambda handler imports server/index.mjs, but the server bundle is ${context.manifest.server}.`);
|
|
32
|
+
}
|
|
33
|
+
context.write(HANDLER_FILE, ServerlessScripts.LAMBDA_HANDLER);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const lambdaPreset = definePreset({
|
|
38
|
+
name: 'lambda',
|
|
39
|
+
description: 'AWS Lambda with a function URL',
|
|
40
|
+
entry: 'http',
|
|
41
|
+
format: 'esm',
|
|
42
|
+
options: LambdaPreset.OPTIONS,
|
|
43
|
+
output: context => LambdaPreset.output(context),
|
|
44
|
+
deployer: 'lambda',
|
|
45
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { CellError, type OutputManifest, type Preset, type ProjectModel } from '@celljs/kit';
|
|
4
|
+
|
|
5
|
+
export interface PresetOutputOptions {
|
|
6
|
+
root: string;
|
|
7
|
+
/** Absolute output directory. */
|
|
8
|
+
outDir: string;
|
|
9
|
+
project: ProjectModel;
|
|
10
|
+
env: NodeJS.ProcessEnv;
|
|
11
|
+
/** The preset's field of cell.config.ts. */
|
|
12
|
+
options?: Record<string, unknown>;
|
|
13
|
+
warn(message: string): void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Reads and writes `manifest.json` of an output, and lets the preset add its files around the bundles. */
|
|
17
|
+
export namespace PresetOutput {
|
|
18
|
+
export const MANIFEST = 'manifest.json';
|
|
19
|
+
|
|
20
|
+
export function read(outDir: string): OutputManifest {
|
|
21
|
+
const file = join(outDir, MANIFEST);
|
|
22
|
+
if (!existsSync(file)) {
|
|
23
|
+
throw new CellError({ code: 'CELL_OUTPUT_NOT_FOUND', message: `No build output in ${outDir}.`, file, hint: 'Run `cell build` first.' });
|
|
24
|
+
}
|
|
25
|
+
return JSON.parse(readFileSync(file, 'utf8')) as OutputManifest;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Runs `preset.output` on a fresh build; files it writes are listed in `manifest.files`. */
|
|
29
|
+
export async function write(preset: Preset, options: PresetOutputOptions): Promise<OutputManifest> {
|
|
30
|
+
const manifest = read(options.outDir);
|
|
31
|
+
if (!preset.output) {
|
|
32
|
+
return manifest;
|
|
33
|
+
}
|
|
34
|
+
const files = new Set(manifest.files ?? []);
|
|
35
|
+
await preset.output({
|
|
36
|
+
...options,
|
|
37
|
+
options: options.options ?? {},
|
|
38
|
+
manifest,
|
|
39
|
+
write: (path, content, mode) => {
|
|
40
|
+
const file = join(options.outDir, path);
|
|
41
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
42
|
+
writeFileSync(file, content);
|
|
43
|
+
if (mode !== undefined) {
|
|
44
|
+
chmodSync(file, mode);
|
|
45
|
+
}
|
|
46
|
+
files.add(path.replace(/\\/g, '/'));
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (files.size > 0) {
|
|
50
|
+
manifest.files = [...files].sort();
|
|
51
|
+
}
|
|
52
|
+
writeFileSync(join(options.outDir, MANIFEST), `${JSON.stringify(manifest, null, 2)}\n`);
|
|
53
|
+
return manifest;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CellError, type Preset } from '@celljs/kit';
|
|
2
|
+
import type { PresetDetector } from '../config/config-resolver.js';
|
|
3
|
+
import { TextUtil } from '../utils/text-util.js';
|
|
4
|
+
|
|
5
|
+
/** Presets by name. Built-in ones are registered first; toolchain modules may add more. */
|
|
6
|
+
export class PresetRegistry {
|
|
7
|
+
protected readonly presets = new Map<string, Preset>();
|
|
8
|
+
|
|
9
|
+
register(preset: Preset): this {
|
|
10
|
+
if (this.presets.has(preset.name)) {
|
|
11
|
+
throw new CellError({
|
|
12
|
+
code: 'CELL_PRESET_DUPLICATE',
|
|
13
|
+
message: `Preset '${preset.name}' is registered twice.`,
|
|
14
|
+
hint: 'Give the preset another name, or extend the existing one with `extends`.',
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
this.presets.set(preset.name, preset);
|
|
18
|
+
return this;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get names(): string[] {
|
|
22
|
+
return [...this.presets.keys()];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Every registered preset, as registered (without its `extends` chain). */
|
|
26
|
+
get all(): Preset[] {
|
|
27
|
+
return [...this.presets.values()];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Presets that recognise a CI platform, for {@link ConfigResolver}. */
|
|
31
|
+
get detectors(): PresetDetector[] {
|
|
32
|
+
return [...this.presets.values()].flatMap(({ name, detect }) => (detect ? [{ name, detect }] : []));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** The preset with the fields of its `extends` chain filled in. */
|
|
36
|
+
resolve(name: string, file?: string): Preset {
|
|
37
|
+
const chain: Preset[] = [];
|
|
38
|
+
for (let current: string | undefined = name; current !== undefined; current = chain[chain.length - 1].extends) {
|
|
39
|
+
const preset = this.presets.get(current);
|
|
40
|
+
if (!preset) {
|
|
41
|
+
throw this.notFound(current, file);
|
|
42
|
+
}
|
|
43
|
+
if (chain.includes(preset)) {
|
|
44
|
+
throw new CellError({
|
|
45
|
+
code: 'CELL_PRESET_CYCLE',
|
|
46
|
+
message: `Preset '${name}' extends itself: ${[...chain.map(p => p.name), current].join(' → ')}.`,
|
|
47
|
+
hint: 'Remove the cycle from the `extends` fields.',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
chain.push(preset);
|
|
51
|
+
}
|
|
52
|
+
const { detect: _detect, extends: _extends, ...merged } = Object.assign({}, ...chain.reverse()) as Preset;
|
|
53
|
+
return { ...merged, name };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
protected notFound(name: string, file?: string): CellError {
|
|
57
|
+
const suggestion = TextUtil.closest(name, this.names);
|
|
58
|
+
return new CellError({
|
|
59
|
+
code: 'CELL_PRESET_NOT_FOUND',
|
|
60
|
+
message: `Unknown preset '${name}'. Available: ${this.names.join(', ')}.`,
|
|
61
|
+
file,
|
|
62
|
+
hint: suggestion ? `Did you mean '${suggestion}'?` : 'Use one of the available presets, or add the module that provides it.',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|