@celljs/cli 4.6.1 → 4.7.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.en.md +452 -0
- package/docs/deployment.md +1 -1
- package/docs/frontend.md +2 -0
- package/package.json +8 -8
package/README.en.md
ADDED
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
# @celljs/cli
|
|
2
|
+
|
|
3
|
+
The Cell 4 command-line tool. Reads `cell.config.ts`, builds applications according to presets, runs the built application, and deploys build artifacts. For getting started and usage guides, see the [guide](https://cell.cellbang.com/guide/getting-started) (distributed with this package in `docs/`, searchable with `cell docs`). For architecture details, see [docs/design/architecture.md](https://github.com/cellbang/cell/blob/main/docs/design/architecture.md); for migrating from 3.x, see [docs/migration-4.md](https://github.com/cellbang/cell/blob/main/docs/migration-4.md).
|
|
4
|
+
|
|
5
|
+
Requires Node.js `^20.19.0 || >=22.12.0`. Install in your project:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -D @celljs/cli
|
|
9
|
+
npx cell build
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Commands
|
|
13
|
+
|
|
14
|
+
| Command | Purpose |
|
|
15
|
+
| --- | --- |
|
|
16
|
+
| `cell init [template] [dir]` | Create a project from a template (`backend`, `fullstack`), with AGENTS.md, cell skill, and `.mcp.json` included; lists templates when invoked without arguments |
|
|
17
|
+
| `cell dev` | Development: frontend and backend on the same port, HMR for frontend, automatic backend reload on file changes, auto-restart on config changes |
|
|
18
|
+
| `cell build` | Build to `.cell/output`: `server/index.mjs` (single file with inlined dependencies), `public/` (frontend), `manifest.json` |
|
|
19
|
+
| `cell info` | Describe the project: preset and its source, mode, targets, components, DI modules, hooks, and build status. Read-only; does not build or execute hooks |
|
|
20
|
+
| `cell check` | Perform config, TypeScript types, decorator setup, backend DI binding, and module registration checks; exits with code 1 on error |
|
|
21
|
+
| `cell preview` | Run build artifacts according to `manifest.json` without rebuilding |
|
|
22
|
+
| `cell deploy` | Build with the selected preset, then publish via its deployer; use `--dry-run` to show the plan only |
|
|
23
|
+
| `cell config get <key>` | Get the merged value of a config key; use `--why` to see which files and environment variables set it |
|
|
24
|
+
| `cell docs <query>` | Search the documentation shipped with installed components and modules, plus guides and this document from `@celljs/cli` (matching the project's Cell version) |
|
|
25
|
+
| `cell mcp` | MCP server on stdio that exposes `info`, `check`, `config_get`, `docs_search`, `build`, `deploy_plan`, and tools registered by modules to coding agents |
|
|
26
|
+
| `cell agent sync` | Rewrite the parts of AGENTS.md managed by Cell and `.agents/skills/cell/SKILL.md` according to installed versions |
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
## Presets
|
|
30
|
+
|
|
31
|
+
| preset | Artifact | Run / preview | Deployer |
|
|
32
|
+
| --- | --- | --- | --- |
|
|
33
|
+
| `node` (default) | Node.js HTTP server: `node .cell/output/server/index.mjs` | `cell preview` runs the application with Node.js | None; deploy artifacts manually |
|
|
34
|
+
| `cloudflare` | Cloudflare Workers: `server/worker.mjs` + `wrangler.json`, frontend as static assets | `cell preview` runs via `wrangler dev` in local workerd | `cloudflare` (Wrangler) |
|
|
35
|
+
| `cli` | Node.js CLI program: `node .cell/output/server/index.mjs` starts the application without listening on a port; components (e.g., `ApplicationLifecycle`) perform the work. Does not require `@celljs/express-adapter` or report missing entry | `cell preview` runs with Node.js, inherits the current terminal | None |
|
|
36
|
+
| `fc` | Alibaba Cloud Functions (3.0) custom runtime: artifact with `bootstrap` startup script, frontend served from `public/` by the server | Run with Node.js | `fc` (Functions API) |
|
|
37
|
+
| `scf` | Tencent Cloud SCF Web functions: artifact with `scf_bootstrap` | Run with Node.js | `scf` (Cloud Functions API) |
|
|
38
|
+
| `lambda` | AWS Lambda + function URL: artifact with `server/lambda.mjs` handler | Run with Node.js | `lambda` (AWS API) |
|
|
39
|
+
| `vercel` | Vercel Build Output API: `.vercel/output`, frontend on CDN, backend as a single function | Run the function bundle with Node.js; frontend served from `static/` | `vercel` (Vercel CLI) |
|
|
40
|
+
|
|
41
|
+
Options for each preset are written in `cell.config.ts` in fields matching the preset name (e.g., `fc: { region: 'cn-shanghai' }`), validated against the preset's schema, and unknown options raise `CELL_CONFIG_INVALID`. Switching presets preserves other preset fields without error.
|
|
42
|
+
|
|
43
|
+
### cloudflare
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
cell build --preset cloudflare # Build to .cell/output
|
|
47
|
+
cell preview # wrangler dev runs in workerd (Cloudflare runtime), default port 8787
|
|
48
|
+
cell deploy --preset cloudflare --dry-run # Build and run wrangler deploy --dry-run, show plan, do not upload
|
|
49
|
+
cell deploy --preset cloudflare # Build and deploy, output workers.dev address
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
- **Runtime**: The Cell backend runs on Workers' `node:http` server (requires `nodejs_compat`), provided by `@celljs/express-adapter`'s `http` entry—same as the `node` preset. Cloudflare serves the frontend (`public/`) as static assets; only requests that don't match static files enter the Worker. Artifacts support ESM only; `--format cjs` raises `CELL_CONFIG_CONFLICT`.
|
|
53
|
+
- **Startup timing**: Workers allow code generation only during module loading phase (`new Function`, which some dependencies use), and I/O only during request handling. Application modules load when the Worker starts; `Application.start()` and `onStart` execute on the first request (`ApplicationHost.beforeStart`). Module load failures cause Worker startup to fail; `wrangler dev` / `wrangler deploy` report the error directly.
|
|
54
|
+
- **Cloudflare configuration**: Write configuration in `wrangler.jsonc` or `wrangler.json` at the project root (optional, following Cloudflare's format): `name`, `compatibility_date`, `vars`, KV / D1 / R2 bindings, `routes`, etc. go here. During build, Cell generates `.cell/output/wrangler.json` from this as a base and sets: `main` (ignored with a warning if you specified it), `assets.directory` if a frontend exists, and `nodejs_compat` in `compatibility_flags`. Without a config file, `name` defaults to the package name from package.json (e.g., `@acme/shop` → `acme-shop`), and `compatibility_date` defaults to `2026-03-17`, the earliest allowed date (`node:http` server and `node:tty` have been available by default since then). `wrangler.toml` is not supported; convert to `wrangler.jsonc`.
|
|
55
|
+
- **Single-page applications**: With a frontend, `assets.not_found_handling: "single-page-application"` is set by default. When the browser navigates to a nonexistent path, Cloudflare returns `index.html` (same as `@celljs/serve-static`'s `spa`); other requests like API calls still enter the Worker. If you specify `not_found_handling` in `wrangler.jsonc`, your project setting takes precedence. Without frontend files in the Worker, `@celljs/serve-static` detects the missing frontend directory and passes through; unknown paths return a normal 404.
|
|
56
|
+
- **Custom domains**: If your domain's DNS is hosted on Cloudflare, add `"routes": [{ "pattern": "app.example.com", "custom_domain": true }]` to `wrangler.jsonc`. Cloudflare automatically creates DNS records and certificates on deploy, and `deployment.url` reports the domain. Networks that cannot reach `*.workers.dev` require a custom domain for access.
|
|
57
|
+
- **Application config**: `vars` and secrets (set via `wrangler secret put`) enter `process.env`, so `${env.X}` and `CELL_*` variables in `cell.yml` work as expected.
|
|
58
|
+
- **Wrangler**: Not a Cell dependency. If Wrangler is installed in your project, Cell uses it; otherwise, `npx --yes wrangler@4` installs it on first use (cached by npm). Wrangler manages credentials: set `CLOUDFLARE_API_TOKEN` (and optionally `CLOUDFLARE_ACCOUNT_ID`), or run `npx wrangler login` once. Alternatively, skip `cell deploy` and run `npx wrangler deploy --config .cell/output/wrangler.json` directly.
|
|
59
|
+
- **Workers Builds** (Cloudflare's CI; set `WORKERS_CI=1`): automatically selects the `cloudflare` preset, build command `npx cell build`, and deploy command `npx cell deploy --skip-build`.
|
|
60
|
+
- `wrangler dev` creates `.wrangler/` in the project root; add it to `.gitignore`.
|
|
61
|
+
|
|
62
|
+
### fc, scf, lambda
|
|
63
|
+
|
|
64
|
+
These three function platforms use the same approach. The Cell server runs unchanged; the artifact directory is zipped as function code. The deployer calls cloud APIs directly (Cell implements request signing: Alibaba Cloud ACS3, Tencent Cloud TC3, AWS SigV4); no cloud SDK or CLI is needed. Function name defaults to the package name (`@acme/shop` → `shop`), or specify with `name`. Environment variables are written to the function (also includes `NODE_ENV=production`), and `${env.X}` and `CELL_*` in `cell.yml` work as expected.
|
|
65
|
+
|
|
66
|
+
| preset | Runtime | Options | Credentials (environment variables) | Deploy result |
|
|
67
|
+
| --- | --- | --- | --- | --- |
|
|
68
|
+
| `fc` | `custom.debian10` runtime; `bootstrap` uses Node.js 20 from the image runtime (`node: '18'` optional) on port 9000 (`FC_SERVER_PORT`) | `name`, `region` (defaults to `ALIBABA_CLOUD_REGION_ID` or `cn-hangzhou`), `node`, `memory` (MB, default 1024), `cpu` (default based on 2 GB/core), `timeout` (default 60), `concurrency` (single instance, default 20), `env` | `ALIBABA_CLOUD_ACCESS_KEY_ID`, `ALIBABA_CLOUD_ACCESS_KEY_SECRET` (optionally `ALIBABA_CLOUD_SECURITY_TOKEN`) | Create or update function; create an anonymous HTTP trigger `http` if none exists (existing triggers are unchanged); return the `fcapp.run` address |
|
|
69
|
+
| `scf` | Web functions (`Type: HTTP`); `scf_bootstrap` uses Node.js 18 from the runtime (`runtime: 'Nodejs16.13'` optional) on port 9000; only `/tmp` is writable | `name`, `region` (defaults to `TENCENTCLOUD_REGION` or `ap-guangzhou`), `namespace` (default `default`), `runtime`, `memory` (default 512), `timeout` (default 60), `env` | `TENCENTCLOUD_SECRET_ID`, `TENCENTCLOUD_SECRET_KEY` (optionally `TENCENTCLOUD_SESSION_TOKEN`) | Create or update function (deploy code first, then config, wait for Active state); create a public, unauthenticated function URL if none exists |
|
|
70
|
+
| `lambda` | `nodejs22.x`; initialize on loopback port; `server/lambda.handler` converts function URL / HTTP API (payload v2) events to requests; responses are returned as base64, with multiple cookies in `cookies` | `name`, `region` (defaults to `AWS_REGION` or `us-east-1`), `runtime`, `architecture` (`x86_64` / `arm64`), `memory` (default 1024), `timeout` (default 30), `role`, `env` | `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` (optionally `AWS_SESSION_TOKEN`), or `AWS_PROFILE` / default from `~/.aws/credentials` | Create or reuse execution role `cell-lambda-execution` (log permissions only) if `role` is not specified; create or update function; create an `AuthType: NONE` function URL and its two public invoke permissions if none exists |
|
|
71
|
+
|
|
72
|
+
- Code packages are uploaded directly with requests. Size limits: FC 100 MB, SCF 20 MB, Lambda 50 MB (after zipping). Oversized packages raise `CELL_DEPLOY_PACKAGE_TOO_LARGE`. Large sizes usually come from packages left in `server/node_modules` by `build.external`.
|
|
73
|
+
- Without credentials, `--dry-run` still shows a plan (action is `deploy`, with a warning that the function's existence is unknown). With credentials, the cloud is queried and the action is `create` or `update`. Deployment without credentials raises `CELL_DEPLOY_CREDENTIALS_MISSING`; cloud API errors raise `CELL_DEPLOY_API_ERROR` / `CELL_DEPLOY_UNAUTHORIZED` with the cloud provider's error code and request ID.
|
|
74
|
+
- The default domain `fcapp.run` causes browsers to download HTML pages. Web applications should bind a custom domain; APIs are unaffected.
|
|
75
|
+
- Runtimes include older Node.js versions (FC 20.10, SCF 18.15). Server bundles include patches for `import.meta.dirname` / `filename`.
|
|
76
|
+
|
|
77
|
+
### vercel
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
cell build --preset vercel # .vercel/output (Build Output API v3)
|
|
81
|
+
cell preview # Run function bundle with Node.js, frontend served from .vercel/output/static
|
|
82
|
+
cell deploy --preset vercel # vercel deploy --prebuilt, no rebuild on Vercel
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- The frontend is placed in `static/` and returned by Vercel CDN (`/assets/*` with one-year immutable cache headers). Other requests enter function `functions/index.func` (`nodejs22.x`), where the Cell server handles APIs and serves `public/index.html` for single-page fallback. Files in `.vercel/output` are cleared during build.
|
|
86
|
+
- Options: `project` (defaults to package name), `scope` (team), `environment` (`production` default or `preview`), `runtime`, `memory`, `maxDuration`, `regions` (comma-separated). Output directory is fixed at `.vercel/output`; deploying with `--out-dir` elsewhere raises `CELL_DEPLOY_OUTPUT_MISMATCH`. `--single` / `--compile` are not accepted.
|
|
87
|
+
- Vercel CLI is not a dependency. If installed in your project, Cell uses it; otherwise `npx --yes vercel@65` is used. Credentials: `VERCEL_TOKEN`, or run `npx vercel login` once. The project is auto-created if it doesn't exist (`--create-if-missing`).
|
|
88
|
+
- In Vercel's build environment (`VERCEL=1`), the `vercel` preset is automatically selected. Add `.vercel/` to `.gitignore`
|
|
89
|
+
|
|
90
|
+
### cell dev
|
|
91
|
+
|
|
92
|
+
| Option | Description |
|
|
93
|
+
| --- | --- |
|
|
94
|
+
| `--preset <name>` | Which preset's entry to use for running the backend; default is `node` |
|
|
95
|
+
| `-m, --mode <mode>` | Additional mode(s), repeatable; `development` is always added automatically |
|
|
96
|
+
| `-p, --port <port>` | Port, defaults to `server.port` (considering `CELL_SERVER__PORT`), otherwise 3000; `0` means random port |
|
|
97
|
+
| `--host <host>` | Listen address, defaults to `server.host`, otherwise `127.0.0.1` |
|
|
98
|
+
|
|
99
|
+
- Single port: Vite provides frontend pages and modules (HMR), `/favicon.ico`, and component `assets`. Files in `public/` match their location in the build output, and remaining requests go to the backend.
|
|
100
|
+
- The backend is not bundled. In Vite's server environment, it loads via module runner: Cell packages and project source pass through the Cell plugin (generated DI container and config written to `.cell/generated/`); other dependencies load directly via Node. The entry passes the request handler function to `cell dev` via `ApplicationHost` (`@celljs/core`), not listening on a port itself.
|
|
101
|
+
- When backend files change, the old application stops (triggering `onStop`), then restarts from new modules and triggers `dev:reload`. On startup failure, requests return 500 with `CellError` (`CELL_DEV_BACKEND_FAILED`) and retry automatically after saving.
|
|
102
|
+
- When project or component `cell*.yml`, `package.json`, or `cell.config.*` changes, the toolchain is re-parsed and restarts on the same port, triggering `dev:ready` again. Config errors are reported; the process waits for the next change.
|
|
103
|
+
- `require()` in source code and CommonJS files in the project (e.g., generated Prisma client) work normally.
|
|
104
|
+
- `POST /_cell/mcp`: MCP endpoint of the running application (Streamable HTTP, JSON response). Tools include `get_errors` (backend startup errors, failed reloads, 5xx requests, error logs), `list_routes`, `list_bindings`, `get_config` (`${...}` already evaluated), `recent_requests`, and `logs`. Only accepts local requests (no `Origin` or loopback address); returns 403 for others.
|
|
105
|
+
- `--json`: outputs one-line result on stdout when ready (`url`, `port`, `mode`, `targets`, `mcp`, or `backendError` if backend failed). Application and Vite output go to stderr. On SIGINT / SIGTERM, stops the application and exits with 0.
|
|
106
|
+
- React Fast Refresh and other framework plugins are provided by the component's toolchain module (after the module host is complete). Before that, frontend changes trigger a full page refresh and CSS hot replacement.
|
|
107
|
+
|
|
108
|
+
### cell build
|
|
109
|
+
|
|
110
|
+
| Option | Description |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| `--preset <name>` | Build output format: `node` (default), `cloudflare`, `cli`, `fc`, `scf`, `lambda`, `vercel` |
|
|
113
|
+
| `-m, --mode <mode>` | Additional mode(s), reads `cell.<mode>.yml`, repeatable; `production` is always added automatically |
|
|
114
|
+
| `--format <esm\|cjs>` | Server bundle format, defaults by preset (`node` uses `esm`) |
|
|
115
|
+
| `--single` | Embed frontend into `server/index.mjs`: run the whole app from one file (see below) |
|
|
116
|
+
| `--compile [bun\|node\|deno]` | Compile into an executable `.cell/output/app`, default bun (see below) |
|
|
117
|
+
| `--compile-target <target>` | Cross-compile, passed to bun (e.g., `bun-linux-x64`) or deno (e.g., `x86_64-unknown-linux-gnu`) |
|
|
118
|
+
| `--sourcemap` | Generate source maps |
|
|
119
|
+
| `--out-dir <dir>` | Output directory, default `.cell/output` |
|
|
120
|
+
|
|
121
|
+
**Frontend static files**: After building the frontend, copy files into `public/` without overwriting build artifacts. Include: `favicon.ico` from the project root; files from each component's (including the project itself) `public/` or `src/browser/public/` directories, placed as-is at the site root (web app manifest, Service Worker, `robots.txt`, etc.); project files take priority on conflict. If no favicon exists, Cell's favicon is used. Files from each component's `assets/`, `src/assets/`, or `src/browser/assets/` directories are placed under `/assets/`.
|
|
122
|
+
|
|
123
|
+
**Single file (`--single`)**: Build the frontend first, then encode all files in `public/` (pages, scripts, favicon, component assets) as base64 and embed them in the server bundle. At startup, register them to `Symbol.for('@celljs/serve-static/assets')`; `@celljs/serve-static` serves them from memory (Content-Type, ETag / 304, and Cache-Control match disk serving; single-page apps fall back to `index.html`). Artifacts contain only `server/index.mjs` and `manifest.json` (`single: true`, no `public`). Copy this one file to any directory and run with `node index.mjs`. If the project has only a backend, behavior is the same as without `--single` (a message appears); packages left in `server/node_modules` by `build.external` must still be placed beside it. Alternatively, write `build: { single: true }` in `cell.config.ts`.
|
|
124
|
+
|
|
125
|
+
**Executable (`--compile`)**: Compile the single-file bundle into `.cell/output/app` (Windows: `app.exe`). The result runs on machines without Node.js or node_modules. `manifest.json` records `executable`, and `cell preview` runs it directly.
|
|
126
|
+
|
|
127
|
+
| Tool | Method | Requires |
|
|
128
|
+
| --- | --- | --- |
|
|
129
|
+
| `bun` (default) | `bun build --compile` | Bun installed locally |
|
|
130
|
+
| `deno` | `deno compile --allow-all` | Deno installed locally |
|
|
131
|
+
| `node` | Node.js Single Executable Application (SEA): the CommonJS bundle generates a blob, injected into node's copy via `npx postject`, and re-signed on macOS | Output format auto-switches to `cjs`; npx downloads postject on first use; cross-compilation is not supported |
|
|
132
|
+
|
|
133
|
+
Packages left outside the bundle (`build.external`, component `optionalDependencies`, usually native modules) cannot be included in the executable; `CELL_COMPILE_EXTERNALS` is raised, listing them. `cloudflare` and `vercel` presets have frontends managed by platforms and do not accept `--single` / `--compile`.
|
|
134
|
+
|
|
135
|
+
### cell info
|
|
136
|
+
|
|
137
|
+
Accepts the same `--preset`, `-m`, `--format`, and `--out-dir` options as `cell build`, describing what `cell build` would use with the same parameters. Additionally:
|
|
138
|
+
|
|
139
|
+
| Option | Description |
|
|
140
|
+
| --- | --- |
|
|
141
|
+
| `--app-config` | Also output the application config for each target (`cell.yml`): backend has all keys with `${...}` preserved (evaluated at runtime); frontend has only public keys, already evaluated |
|
|
142
|
+
|
|
143
|
+
Reads only package.json, `cell*.yml`, `cell.config.ts`, and `manifest.json`. Does not run project code or execute `hooks`. Key fields in `--json` result:
|
|
144
|
+
|
|
145
|
+
| Field | Content |
|
|
146
|
+
| --- | --- |
|
|
147
|
+
| `name`, `version`, `cellVersion`, `configFile` | Project and CLI versions, `cell.config` file (relative to root) |
|
|
148
|
+
| `preset` | `name`, `source` (`flag` / `config` / `env` / `ci` / `default`), `entry`, `format`, `runtime` (Cloudflare Workers use `workerd`), `deployer`, `available` |
|
|
149
|
+
| `mode`, `targets`, `targetSources` | Active modes; build targets and their sources (`cell.config.ts`, `default`, or declaring component) |
|
|
150
|
+
| `build` | Active `format`, `outDir`, `external`, `sourcemap`, `single`, `compile` |
|
|
151
|
+
| `components` | In load order; `dir` and `configFiles` relative to root; `targets`, `entries`, `toolchain`, and `optionalDependencies` are shown only when declared by the component |
|
|
152
|
+
| `frontend`, `backend` | `entry`, `entryComponent` providing it, `staticModules` / `modules` (DI modules, in load order), and `config` (only with `--app-config`). If the frontend has pages, also includes `routes` (`path`, `file`, `layouts` from `src/browser/pages`, plus `error` if an `_error` file exists) |
|
|
153
|
+
| `hooks`, `modules`, `moduleOptions` | Hooks in `cell.config.ts`, `modules` entries, toolchain module option keys |
|
|
154
|
+
| `output` | `dir`, `built`, and manifest fields (`preset`, `format`, `targets`, `server`, `public`) if outdated |
|
|
155
|
+
| `frontend.envOverrides`, `backend.envOverrides` | `CELL_*` variables in the current environment: `applied` (variable → config path) and `problems` (key not found or type mismatch). Only present if such variables exist; values are not output |
|
|
156
|
+
|
|
157
|
+
`warnings` point out settings that won't take effect or cause `cell build` to fail: no component provides the preset's entry, `-m` specifies a mode with no `cell.<mode>.yml` (with spelling suggestions), or non-working `CELL_*` variables.
|
|
158
|
+
|
|
159
|
+
### cell check
|
|
160
|
+
|
|
161
|
+
| Option | Description |
|
|
162
|
+
| --- | --- |
|
|
163
|
+
| `--preset <name>`, `-m, --mode <mode>` | Same as `cell build` |
|
|
164
|
+
| `--skip <check>` | Skip a specific check (repeatable); unknown names raise `CELL_ARGUMENT_INVALID` and list available checks |
|
|
165
|
+
|
|
166
|
+
| Check | Content |
|
|
167
|
+
| --- | --- |
|
|
168
|
+
| `config` | Same as `cell info` warnings: missing entry (`CELL_ENTRY_MISSING`), invalid mode (`CELL_MODE_UNKNOWN`), or ineffective or shadowed environment variables (`CELL_ENV_OVERRIDE_IGNORED` / `CELL_ENV_OVERRIDE_SHADOWS`) |
|
|
169
|
+
| `types` | Run `tsc --noEmit -p tsconfig.json` with the project's TypeScript. Each diagnostic includes file, line/column, and `TSxxxx` code. Skipped if no tsconfig.json or TypeScript is not installed |
|
|
170
|
+
| `decorators` | tsconfig must enable `experimentalDecorators` and `emitDecoratorMetadata` (`CELL_TSCONFIG_DECORATORS`) to match build-time decorator semantics |
|
|
171
|
+
| `di` | Load the backend DI container the same way `cell dev` does (without starting the application), then resolve each binding. Container errors (`CELL_DI_NO_BINDING`, `CELL_DI_AMBIGUOUS`, `CELL_DI_CIRCULAR`, `CELL_DI_MISSING_INJECT`, `CELL_DI_INCOMPLETE_BINDING`) are reported as errors with resolution chain and fix suggestions; each cause is reported once. Bindings that can only be created at injection point or request time are info |
|
|
172
|
+
| `security` | Settings reported by the backend `SecurityCheck` component as unsafe for production. All are warnings (do not fail the check), the same set handled at production startup by `securityChecks`: `CELL_SECURITY_DEFAULT_COOKIE_KEYS`, `CELL_SECURITY_COOKIE_KEYS_MISSING`, `CELL_SECURITY_WEAK_COOKIE_KEYS` (`@celljs/web`), and `CELL_SECURITY_WEAK_JWT_SECRET` (`@celljs/jwt`). Reads config for the selected mode. Shares one backend load with `di` |
|
|
173
|
+
| Module-registered checks | Registered by toolchain modules via `addCheck`, named like `typeorm:entities` |
|
|
174
|
+
|
|
175
|
+
`--json` result: `passed`, `summary` (errors / warnings / info counts), `issues` (each with `check`, `level`, `code`, `message`, and possibly `file`, `line`, `column`, `hint`), and `checks` (duration, problem counts, skip reason for each). Without `--json`, output is in compiler format `src/a.ts:3:5 error TS2322 …`; info is not shown.
|
|
176
|
+
|
|
177
|
+
### cell init
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
npx @celljs/cli init backend my-app # or fullstack: React frontend + backend communicating via RPC
|
|
181
|
+
cd my-app && npm install && npx cell agent sync && npx cell dev
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
| Option | Description |
|
|
185
|
+
| --- | --- |
|
|
186
|
+
| `--name <name>` | Package name, defaults to directory name (lowercased, spaces removed) |
|
|
187
|
+
| `--force` | Allow writing to non-empty directory (same-name files overwritten) |
|
|
188
|
+
|
|
189
|
+
Never prompts. Raises `CELL_INIT_NOT_EMPTY` if the directory is non-empty, or `CELL_TEMPLATE_NOT_FOUND` if the template doesn't exist (with spelling suggestions). Project dependencies on `@celljs/*` are set to `^<cli version>`; tests use `bun test` + `createTestApp()`. Generates for coding agents: `AGENTS.md` (Cell guide matching version), `.agents/skills/cell/SKILL.md`, `CLAUDE.md` (`@AGENTS.md`), and `.mcp.json` (`npx cell mcp`).
|
|
190
|
+
|
|
191
|
+
### cell agent sync
|
|
192
|
+
|
|
193
|
+
Writes the Cell guide from `@celljs/cli` and `AGENTS.md` fragments from installed components and toolchain modules (`addDocs` directories) into the `<!-- cell:begin -->` … `<!-- cell:end -->` region of `AGENTS.md` (other content unchanged; if no markers exist, appends to the end). Also rewrites `.agents/skills/cell/SKILL.md`. Run once after upgrading Cell or changing components.
|
|
194
|
+
|
|
195
|
+
### cell config get
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
cell config get server.port --why
|
|
199
|
+
# server.port (backend) = 8080
|
|
200
|
+
# server-only, owned by @celljs/web
|
|
201
|
+
# Port the server listens on. Override with CELL_SERVER__PORT.
|
|
202
|
+
# node_modules/@celljs/web/cell.yml: 3000
|
|
203
|
+
# cell.yml: 8080
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
| Option | Description |
|
|
207
|
+
| --- | --- |
|
|
208
|
+
| `-m, --mode <mode>` | Additional mode(s), repeatable |
|
|
209
|
+
| `--target <target>` | `backend` or `frontend` (only public keys), default is `backend` if present |
|
|
210
|
+
| `--why` | List the key's owning component, whether it reaches frontend, description, and files and environment variables that set it in merge order |
|
|
211
|
+
|
|
212
|
+
Keys can be written as `a.b.c` or `items[0].name`. `--json` result has `value`, `owners` (components declaring this key in `cell.schema.json`), `public` (whether frontend sees it), `description`, `layers` (`file`, `component`, `value`), `env` (variables setting this key or ancestors), and `expressions` (backend value contains `${...}`, evaluated at server startup). Raises `CELL_CONFIG_KEY_NOT_FOUND` if the key doesn't exist (with nearest keys). Querying server-only keys with `--target frontend` indicates they are server-only.
|
|
213
|
+
|
|
214
|
+
### cell docs
|
|
215
|
+
|
|
216
|
+
`cell docs <query> [--limit n]`: Search by title sections in each component's `README.md`, `docs/`, module `addDocs()` directories, and `@celljs/cli`'s included docs and guide (`docs/`: getting started, config, dependency injection, HTTP, RPC, testing, deploy, coding agent, component directory; English). Returns the best-matching sections and `file:line` (`source` is `@celljs/cli` for CLI docs).
|
|
217
|
+
|
|
218
|
+
### cell mcp
|
|
219
|
+
|
|
220
|
+
Run an MCP server on stdio (one JSON-RPC message per line) until stdin closes. Tools correspond to same-named commands' `--json` results:
|
|
221
|
+
|
|
222
|
+
| Tool | Corresponding command | Side effects |
|
|
223
|
+
| --- | --- | --- |
|
|
224
|
+
| `info` | `cell info` | Read-only |
|
|
225
|
+
| `check` | `cell check` | Read-only |
|
|
226
|
+
| `config_get` | `cell config get` | Read-only |
|
|
227
|
+
| `docs_search` | `cell docs` | Read-only |
|
|
228
|
+
| `build` | `cell build` | Write output directory |
|
|
229
|
+
| `deploy_plan` | `cell deploy --dry-run` | Write output directory, deployer may access network; does not deploy |
|
|
230
|
+
|
|
231
|
+
Deployment tools are not provided. Actual deployment is done by running `cell deploy`.
|
|
232
|
+
|
|
233
|
+
Tools registered by toolchain modules via `addMcpTool` are also included (tools with the same name as built-ins are ignored with a warning); automatically reloaded after `cell.config.*`, package.json, or module files change. Each tool is marked with `readOnlyHint` / `openWorldHint`; parameters are validated against `inputSchema`, raising `isError` and `CellError` on failure. stdout contains only protocol messages; module and hook output goes to stderr.
|
|
234
|
+
|
|
235
|
+
Configure in an agent (run from project root):
|
|
236
|
+
|
|
237
|
+
```jsonc
|
|
238
|
+
// Claude Code / Cursor / CodeBuddy: .mcp.json or .cursor/mcp.json
|
|
239
|
+
{ "mcpServers": { "cell": { "command": "npx", "args": ["cell", "mcp"] } } }
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
```toml
|
|
243
|
+
# Codex: ~/.codex/config.toml
|
|
244
|
+
[mcp_servers.cell]
|
|
245
|
+
command = "npx"
|
|
246
|
+
args = ["cell", "mcp"]
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
While `cell dev` is running, you can also configure `http://127.0.0.1:<port>/_cell/mcp` as an HTTP MCP server to inspect the running application.
|
|
250
|
+
|
|
251
|
+
### cell preview
|
|
252
|
+
|
|
253
|
+
| Option | Description |
|
|
254
|
+
| --- | --- |
|
|
255
|
+
| `-p, --port <port>` | Listen port, defaults to `server.port` (3000); equivalent to setting `CELL_SERVER__PORT`. For `cloudflare` artifacts, passed to `wrangler dev --port`, default 8787 |
|
|
256
|
+
| `--out-dir <dir>` | Artifact directory, default `.cell/output` |
|
|
257
|
+
|
|
258
|
+
The artifact runs according to which preset built it: `node`, `cli`, `fc`, `scf`, `lambda` run `server/index.mjs` with Node.js (stdin/stdout inherited from the current terminal); `cloudflare` runs `wrangler dev`; `vercel` runs the function bundle with Node.js and serves the frontend from `static/`.
|
|
259
|
+
|
|
260
|
+
### cell deploy
|
|
261
|
+
|
|
262
|
+
| Option | Description |
|
|
263
|
+
| --- | --- |
|
|
264
|
+
| `--preset <name>` | Deploy to which platform: `cloudflare`, `fc`, `scf`, `lambda`, `vercel`; `node`, `cli` have no deployers and raise `CELL_DEPLOY_UNSUPPORTED` (checked before build) |
|
|
265
|
+
| `--dry-run` | Build and plan without uploading (`cloudflare`: `wrangler deploy --dry-run`; `fc` / `scf` / `lambda`: zip and check if function exists; `vercel`: list functions and static files) |
|
|
266
|
+
| `--skip-build` | Deploy existing artifacts in `--out-dir`. Raises `CELL_DEPLOY_OUTPUT_MISMATCH` if the artifact preset doesn't match `--preset` |
|
|
267
|
+
| `-m, --mode <mode>`, `--sourcemap`, `--out-dir <dir>` | Same as `cell build` |
|
|
268
|
+
|
|
269
|
+
Plan first, then apply. The plan lists resources to deploy (`resources`, each with `type`, `name`, `action`, `details`); `--dry-run` stops here. Then fire `deploy:before` (gate; command failures in hooks cancel deploy), `deploy:plan`, and `deploy:done` events. Deploy tool output (Wrangler, Vercel CLI) goes to stderr on `--json`. `--json` result: `preset`, `deployer`, `dryRun`, `plan`, and on actual deploy also `deployment` (`url` and `details.versionId`).
|
|
270
|
+
|
|
271
|
+
### Common options
|
|
272
|
+
|
|
273
|
+
| Option | Description |
|
|
274
|
+
| --- | --- |
|
|
275
|
+
| `--root <dir>` | Project root (default: current directory) |
|
|
276
|
+
| `--json` | stdout outputs one-line JSON result; other output (progress, hook command output) goes to stderr |
|
|
277
|
+
| `-h, --help` / `-v, --version` | Help or version |
|
|
278
|
+
|
|
279
|
+
Commands never prompt interactively. Exit codes: success 0, execution failure 1, usage error (unknown command, option, or value) 2.
|
|
280
|
+
|
|
281
|
+
## --json output
|
|
282
|
+
|
|
283
|
+
```json
|
|
284
|
+
{"schemaVersion":1,"command":"build","ok":true,"root":"/app","preset":"node","format":"esm","mode":["production"],"targets":["backend"],"outDir":".cell/output","entry":"@celljs/express-adapter/lib/node/http-application-entry","durationMs":480,"warnings":[]}
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
On failure:
|
|
288
|
+
|
|
289
|
+
```json
|
|
290
|
+
{"schemaVersion":1,"command":"build","ok":false,"error":{"code":"CELL_PRESET_NOT_FOUND","message":"Unknown preset 'nod'. Available: node.","hint":"Did you mean 'node'?","docs":"https://cell.cellbang.com/errors/cell-preset-not-found"},"warnings":[]}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
`schemaVersion` remains constant; fields only grow and never change.
|
|
294
|
+
|
|
295
|
+
## cell.config.ts
|
|
296
|
+
|
|
297
|
+
Optional. Contains toolchain configuration only; application config (read by `@Value`) goes in `cell.yml`.
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
import { defineConfig } from '@celljs/cli';
|
|
301
|
+
|
|
302
|
+
export default defineConfig({
|
|
303
|
+
preset: 'node',
|
|
304
|
+
targets: ['frontend', 'backend'],
|
|
305
|
+
modules: ['!@celljs/serve-static', { source: '@x/ui', runtime: false }],
|
|
306
|
+
build: { format: 'esm', external: ['sharp'], sourcemap: false, outDir: '.cell/output' },
|
|
307
|
+
vite: {},
|
|
308
|
+
hooks: { 'build:before': 'prisma generate' },
|
|
309
|
+
});
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
| Field | Description |
|
|
313
|
+
| --- | --- |
|
|
314
|
+
| `preset` | Build output format. Priority: `--preset` → this field → `CELL_PRESET` → CI environment detection → `node` |
|
|
315
|
+
| `targets` | Build targets. Default is `backend` plus targets declared by components (installing `@celljs/react` adds `frontend` via `@celljs/widget`). Specifying this field overrides the default completely |
|
|
316
|
+
| `modules` | `'!package-name'` excludes a component (and dependencies only imported via it); `{ source, runtime: false }` excludes its DI module but keeps config; `{ source, toolchain: false }` excludes its toolchain module; local paths or package names specify additional toolchain modules (see below) |
|
|
317
|
+
| `build.format` | `esm` or `cjs` |
|
|
318
|
+
| `build.external` | Packages not to inline; copied to `server/node_modules` in dependency order |
|
|
319
|
+
| `build.sourcemap`, `build.outDir` | Same as command-line options |
|
|
320
|
+
| `build.single`, `build.compile` | Same as `--single` / `--compile` (`compile` can be `true`, `bun`, `node`, or `deno`) |
|
|
321
|
+
| `vite` | Merged into Vite config for each environment |
|
|
322
|
+
| `hooks` | Shell commands executed on toolchain events (see below) |
|
|
323
|
+
|
|
324
|
+
Other top-level fields are options for toolchain modules and must be objects. The file supports `.ts`, `.mts`, `.cts`, `.js`, `.mjs`, and `.cjs` extensions; multiple files raise `CELL_CONFIG_AMBIGUOUS`. Command-line arguments take priority over the config file.
|
|
325
|
+
|
|
326
|
+
## Override configuration with environment variables
|
|
327
|
+
|
|
328
|
+
Any key already in `cell.yml` can be overridden with environment variables without editing:
|
|
329
|
+
|
|
330
|
+
```bash
|
|
331
|
+
CELL_SERVER__PORT=8080 cell preview # Applied at server startup: server.port
|
|
332
|
+
CELL_APP__PUBLIC__API_BASE=/api cell build # Applied at build time, reaches frontend: app.public.apiBase
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
After the `CELL_` prefix, use one underscore, then `__` between levels (e.g., `CELL_SERVER__PORT`). `CELL_PRESET`, `CELL_MODE`, `CELL_EVENT`, `CELL_OUT_DIR`, and `CELL_DEBUG` are toolchain variables, not treated as config. Single-segment variables that don't match top-level keys (like another tool's `CELL_REGION`) are ignored. Variables with `__` that don't match keys report an error; using the old `CELL__…` / `CELL_BACKEND__…` format suggests the correct format. `__` separates levels; one key can only be set by one variable. Variables are case-insensitive, and `_` / `-` are ignored. Values are converted by schema type or original value type (limited numbers in JSON notation, `true` / `false`, and objects/arrays as JSON). Values that are a single `${...}` are preserved until evaluation (e.g., `CELL_SERVER__PORT='${env.PORT}'`), taking effect before `${...}` evaluation. Only existing keys can be overridden. Non-existent or mistyped variables don't apply and warn: the server prints during startup; `cell build` and `cell info` also check. See [docs/design/config.md](https://github.com/cellbang/cell/blob/main/docs/design/config.md) for full rules.
|
|
336
|
+
|
|
337
|
+
## hooks
|
|
338
|
+
|
|
339
|
+
```ts
|
|
340
|
+
hooks: {
|
|
341
|
+
'build:before': 'prisma generate',
|
|
342
|
+
'output:done': 'cp extra/* "$CELL_OUT_DIR/server/"',
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
- Commands run in the shell from the project root and do not read stdin. PATH has project and parent `node_modules/.bin` at the front.
|
|
347
|
+
- Environment variables: `CELL_EVENT`, `CELL_PRESET`, `CELL_MODE` (comma-separated), and `CELL_OUT_DIR` (absolute output directory path).
|
|
348
|
+
- `cell dev` fires `modules:done` → `config:resolved` → `dev:ready`, then `dev:reload` on backend reload, and repeats after `close` on restart.
|
|
349
|
+
- `cell build` fires in order: `modules:done` → `config:resolved` → `build:before` → build → `output:done` → `close`.
|
|
350
|
+
- `build:before` is a gate event: non-zero exit cancels the build (`CELL_BUILD_CANCELLED`). Non-zero exit in other events raises `CELL_HOOK_FAILED`.
|
|
351
|
+
- Only string commands are accepted. Extensions requiring code or event modification (like `build:done` or `deploy:plan`) should be written as toolchain modules.
|
|
352
|
+
|
|
353
|
+
## toolchain modules
|
|
354
|
+
|
|
355
|
+
Write extensions that require code as toolchain modules: export a factory function that, given `cell`, registers capabilities (see [docs/design/modules.md](https://github.com/cellbang/cell/blob/main/docs/design/modules.md) for design details).
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
// modules/audit.ts, write modules: ['./modules/audit'], audit: { url: '...' } in cell.config.ts
|
|
359
|
+
import type { CellAPI } from '@celljs/kit';
|
|
360
|
+
|
|
361
|
+
export default function (cell: CellAPI) {
|
|
362
|
+
const { url } = cell.options('audit', { url: 'http://localhost:9000' });
|
|
363
|
+
cell.addVitePlugin({ name: 'audit', transform: code => code }, { env: 'server' });
|
|
364
|
+
cell.on('build:done', event => {
|
|
365
|
+
event.files['audit.json'] = JSON.stringify({ url, targets: event.project.targets });
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
- Load order is fixed: components in dependencies (package.json's `cell.toolchain`, by dependency order) → `cell.config.ts` `modules` (local paths or package names, in order). `{ source, toolchain: false }` disables a component's module; `'!package-name'` removes the component too.
|
|
371
|
+
- The factory only registers; it doesn't start processes, ports, listeners, or timers. `cell info` also executes the factory.
|
|
372
|
+
- Top-level fields in `cell.config.ts` besides `preset`, `targets`, `modules`, `build`, `vite`, and `hooks` are module options and must be objects. Each must be claimed by some module via `options()` or `addConfigSchema()`, raising `CELL_CONFIG_UNKNOWN_OPTION` (with spelling suggestions) if not. `addConfigSchema` accepts Standard Schema (zod, valibot, etc.); invalid schemas raise `CELL_CONFIG_INVALID`.
|
|
373
|
+
- Factory errors raise `CELL_MODULE_ERROR` (with module name); non-function default export raises `CELL_MODULE_INVALID`. Notification-type event handlers that error in `cell dev` report without interrupting; any handler that fails in `cell build` stops the build.
|
|
374
|
+
- Each module's registrations are listed in `cell info --json` under `toolchainModules`.
|
|
375
|
+
|
|
376
|
+
| API | Purpose |
|
|
377
|
+
| --- | --- |
|
|
378
|
+
| `command`, `mode`, `dev`, `ci`, `root`, `preset`, `components`, `logger` | Read-only info. `preset` is the name from command-line / config / environment; resolved preset is in the `config:resolved` event |
|
|
379
|
+
| `options(key, defaults)`, `addConfigSchema(key, schema)` | Read and claim `key` from `cell.config.ts` (only callable synchronously in the factory) |
|
|
380
|
+
| `updateConfig({ build: { external }, vite })` | Append external packages; merge Vite config below the project's config (project takes priority). Application config remains in the component's `cell.yml` |
|
|
381
|
+
| `addVitePlugin(plugin, { env })` | Add a Vite plugin. `env` as `client` / `server` applies only to frontend / backend |
|
|
382
|
+
| `addRuntimeModule(path, { target, static })`, `addVirtualModule(id, code)`, `setEntry(target, path)` | Append a DI module, provide a virtual module, or specify entry |
|
|
383
|
+
| `addDevHandler(path, handler)`, `addWatchFile(path)` | In `cell dev`, handle a path before the backend; restart on file changes |
|
|
384
|
+
| `addPreset(preset)`, `addOutputFile(path, content)` | Register a preset (participates in `--preset` and CI detection); write a file to the output directory after build (`build:done` `event.files` can add/remove/modify) |
|
|
385
|
+
| `addCheck(def)`, `addMcpTool(def)`, `addDocs(dir)` | Supply tools for `cell check`, `cell mcp`, and `cell docs` |
|
|
386
|
+
| `on(event, handler)`, `events` | Subscribe to toolchain events (composition rules in modules.md §3.2); event bus for inter-module communication |
|
|
387
|
+
| `exec(cmd, args, opts)`, `resolve(spec)` | Run commands without shell; resolve modules from the project root |
|
|
388
|
+
|
|
389
|
+
## Error codes
|
|
390
|
+
|
|
391
|
+
All failures output as `CellError { code, message, file?, line?, hint, docs }`, with `code` stable within 4.x.
|
|
392
|
+
|
|
393
|
+
| Error code | Meaning |
|
|
394
|
+
| --- | --- |
|
|
395
|
+
| `CELL_ARGUMENT_INVALID` | Unknown command, option, or value (exit code 2) |
|
|
396
|
+
| `CELL_PROJECT_NOT_FOUND`, `CELL_PACKAGE_JSON_INVALID` | No package.json in root, or a package.json cannot be read |
|
|
397
|
+
| `CELL_CONFIG_LOAD`, `CELL_CONFIG_AMBIGUOUS` | `cell.config.ts` load or execution failure, multiple config files exist |
|
|
398
|
+
| `CELL_CONFIG_INVALID`, `CELL_CONFIG_CONFLICT` | Config field error (with field path and suggestions), option conflicts |
|
|
399
|
+
| `CELL_CONFIG_PARSE`, `CELL_CONFIG_NOT_OBJECT`, `CELL_CONFIG_EXPRESSION` | `cell.yml` not valid YAML, top level not a mapping, `${...}` expression error |
|
|
400
|
+
| `CELL_CONFIG_INVALID` (cell.yml) | Top-level key with no owner, option not in component, type mismatch; with file, line, suggestions; put custom config under `app` |
|
|
401
|
+
| `CELL_CONFIG_KEY_CONFLICT`, `CELL_CONFIG_SCHEMA_INVALID` | Two components' `cell.schema.json` declare same key, schema uses unsupported keywords, or project schema declares keys outside `app` |
|
|
402
|
+
| `CELL_COMPONENT_NOT_FOUND`, `CELL_LOCAL_MODULE_NOT_FOUND` | Component or local module in `modules` not found |
|
|
403
|
+
| `CELL_MODULE_NOT_FOUND`, `CELL_CORE_NOT_FOUND` | DI module declared by component cannot resolve, project doesn't depend on `@celljs/core` |
|
|
404
|
+
| `CELL_ROUTE_CONFLICT`, `CELL_ROUTE_INVALID` | Two files in `src/browser/pages` map to same path (`about.tsx` and `about/index.tsx`), filename not valid path segment |
|
|
405
|
+
| `CELL_CORE_EL_MISSING` | Project's `@celljs/core` predates 4.1.0, missing `@celljs/core/el` entry for build-time config evaluation |
|
|
406
|
+
| `CELL_PRESET_NOT_FOUND`, `CELL_PRESET_DUPLICATE`, `CELL_PRESET_CYCLE` | Preset not found, duplicate name, `extends` cycles |
|
|
407
|
+
| `CELL_BUILD_FAILED` | Build failed, with error file and location |
|
|
408
|
+
| `CELL_BUILD_CANCELLED`, `CELL_HOOK_FAILED` | Hook or module cancelled build, hook command failed |
|
|
409
|
+
| `CELL_MODULE_ERROR`, `CELL_MODULE_INVALID` | Toolchain module factory or handler error, default export not a factory |
|
|
410
|
+
| `CELL_CHECK_FAILED`, `CELL_DI_MODULE_FAILED` | A check had internal error, `cell check` failed loading backend DI module |
|
|
411
|
+
| `CELL_SECURITY_*`, `CELL_SECURITY_CHECK_FAILED` | Unsafe production settings (reported as warnings by `cell check` `security`); production startup refuses with `securityChecks: fail` |
|
|
412
|
+
| `CELL_CONFIG_UNKNOWN_OPTION` | `cell.config.ts` has option fields unclaimed by any module |
|
|
413
|
+
| `CELL_DEV_FAILED`, `CELL_DEV_BACKEND_FAILED`, `CELL_DEV_START_TIMEOUT` | `cell dev` cannot start (port, etc.), backend startup failed, backend entry timeout without ready |
|
|
414
|
+
| `CELL_DEV_BACKEND_NOT_RUNNING` | dev MCP tool requires running backend, but backend failed or not started |
|
|
415
|
+
| `CELL_CONFIG_KEY_NOT_FOUND` | `cell config get` / `get_config` key doesn't exist |
|
|
416
|
+
| `CELL_COMPILE_TOOL_MISSING`, `CELL_COMPILE_FAILED` | `--compile` requires bun / deno / node not found, compiler error (last few lines of output) |
|
|
417
|
+
| `CELL_COMPILE_EXTERNALS`, `CELL_COMPILE_NO_SERVER` | Packages left outside bundle, project has no backend to compile |
|
|
418
|
+
| `CELL_TEMPLATE_NOT_FOUND`, `CELL_INIT_NOT_EMPTY` | `cell init` template not found, target directory non-empty |
|
|
419
|
+
| `CELL_UNSUPPORTED` | Using a feature not yet available |
|
|
420
|
+
| `CELL_OUTPUT_NOT_FOUND`, `CELL_PREVIEW_NO_SERVER` | No build before `cell preview` / `cell deploy --skip-build`, output has no server |
|
|
421
|
+
| `CELL_DEPLOY_UNSUPPORTED`, `CELL_DEPLOY_OUTPUT_MISMATCH`, `CELL_DEPLOYER_NOT_FOUND` | Preset has no deployer, existing artifact not from this preset, deployer not found |
|
|
422
|
+
| `CELL_DEPLOY_PLAN_FAILED`, `CELL_DEPLOY_FAILED`, `CELL_DEPLOY_CANCELLED` | Plan failed (e.g., build failed), deploy failed (hint shows how to set credentials), hook or module cancelled deploy |
|
|
423
|
+
| `CELL_DEPLOY_CREDENTIALS_MISSING`, `CELL_DEPLOY_UNAUTHORIZED` | No cloud credentials, credentials invalid or insufficient permissions |
|
|
424
|
+
| `CELL_DEPLOY_API_ERROR`, `CELL_DEPLOY_NETWORK`, `CELL_DEPLOY_TIMEOUT`, `CELL_DEPLOY_PACKAGE_TOO_LARGE` | Cloud API error (with cloud error code and request ID), cannot reach cloud API, function timeout, code package exceeds direct upload limit |
|
|
425
|
+
| `CELL_CLOUDFLARE_CONFIG_INVALID`, `CELL_CLOUDFLARE_CONFIG_UNSUPPORTED`, `CELL_CLOUDFLARE_COMPATIBILITY_DATE` | `wrangler.json(c)` not valid JSON or field type wrong, using `wrangler.toml`, `compatibility_date` before `2026-03-17` |
|
|
426
|
+
| `CELL_INTERNAL_ERROR` | Cell or module defect; set `CELL_DEBUG=1` to see stack trace |
|
|
427
|
+
|
|
428
|
+
## Testing: createTestApp
|
|
429
|
+
|
|
430
|
+
```ts
|
|
431
|
+
import { createTestApp } from '@celljs/cli';
|
|
432
|
+
|
|
433
|
+
const app = await createTestApp({ root, mode: ['extra'] }); // mode always has test in front
|
|
434
|
+
const res = await app.fetch('/users', { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}' });
|
|
435
|
+
const { UserService } = await app.import('/src/user-service.ts'); // the backend-loaded module
|
|
436
|
+
app.get(UserService); // object from DI container
|
|
437
|
+
await app.close(); // stop application (onStop)
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
In `app.get(X)`, importing a class or `Symbol('X')` from project source gives a different module instance than the app uses (app runs in Vite's module runner), matched by class name or symbol description; raises `CELL_DI_NO_BINDING` / `CELL_DI_AMBIGUOUS` if missing or duplicate. To get the app's version (on duplicates, or to use other exports from the module), use `app.import()`: project files as `/src/...`, packages as package name. Classes with `@Value` / `@Autowired` must come from `app.import()`: importing these in the test file, then resolving by name, fails (raises `CELL_DI_NO_BINDING`).
|
|
441
|
+
|
|
442
|
+
In the test process, backend loads from source like `cell dev` does, no build or port listening; requests go through the complete HTTP handler chain via in-memory req/res objects, `fetch` returns standard `Response`. Startup failure throws `CellError` (like `CELL_DEV_BACKEND_FAILED`, with error file); backend without HTTP entry raises `CELL_TEST_APP_NO_HTTP` on `fetch`.
|
|
443
|
+
|
|
444
|
+
## Programming interface
|
|
445
|
+
|
|
446
|
+
```ts
|
|
447
|
+
import { CellCli } from '@celljs/cli';
|
|
448
|
+
|
|
449
|
+
const code = await new CellCli({ stdout, stderr, env }).run(['build', '--json']);
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
Also exports `defineConfig`, `ConfigResolver`, `PresetRegistry`, `DeployerRegistry`, `EventBus`, `HookRunner`, etc., for testing and tool writing.
|
package/docs/deployment.md
CHANGED
|
@@ -93,7 +93,7 @@ export default defineConfig({
|
|
|
93
93
|
|
|
94
94
|
The function platforms (`fc`, `scf`, `lambda`) call the cloud APIs directly: no vendor SDK or CLI is installed. Wrangler and the Vercel CLI are used from the project when installed, otherwise through `npx`. Every failure has a code: `CELL_DEPLOY_CREDENTIALS_MISSING`, `CELL_DEPLOY_UNAUTHORIZED`, `CELL_DEPLOY_PACKAGE_TOO_LARGE`, ...
|
|
95
95
|
|
|
96
|
-
Platform details (custom domains, runtimes, package size limits, what each deployer creates) are in the [CLI reference](../README.md#
|
|
96
|
+
Platform details (custom domains, runtimes, package size limits, what each deployer creates) are in the [CLI reference](../README.en.md#presets).
|
|
97
97
|
|
|
98
98
|
## Hooks
|
|
99
99
|
|
package/docs/frontend.md
CHANGED
|
@@ -72,6 +72,8 @@ function Header() {
|
|
|
72
72
|
|
|
73
73
|
The shell provides the application's container through `ContainerContext`. To test a component, render it inside `<ContainerContext.Provider value={container}>` with a container of your own. Keep pages, layouts and contexts plain React components; what they use comes from the container.
|
|
74
74
|
|
|
75
|
+
`useRpc(id)` gives a backend service (next section) and `useLocale()` gives `[locale, setLocale]`: the language the user selected among `widget.locales`, kept in `localStorage`. For translated messages, install react-intl and import `@celljs/react/lib/browser/intl` once in `src/browser/module.ts`; `useIntl()` and `<FormattedMessage>` then follow the selected locale. The hooks are listed in the [README of @celljs/react](https://cell.cellbang.com/packages/react).
|
|
76
|
+
|
|
75
77
|
## Calling the backend: RPC
|
|
76
78
|
|
|
77
79
|
Instead of writing HTTP endpoints and fetch calls for your own frontend, share an interface and call it like a local object.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "The Cell command-line interface: cell.config.ts, toolchain modules, presets and the `cell` command.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/cellbang/cell",
|
|
@@ -43,16 +43,16 @@
|
|
|
43
43
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@celljs/kit": "4.
|
|
47
|
-
"@celljs/vite": "4.
|
|
46
|
+
"@celljs/kit": "4.7.0",
|
|
47
|
+
"@celljs/vite": "4.7.0",
|
|
48
48
|
"vite": "^8.3.6"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@celljs/core": "4.
|
|
52
|
-
"@celljs/express-adapter": "4.
|
|
53
|
-
"@celljs/http": "4.
|
|
54
|
-
"@celljs/mvc": "4.
|
|
55
|
-
"@celljs/web": "4.
|
|
51
|
+
"@celljs/core": "4.7.0",
|
|
52
|
+
"@celljs/express-adapter": "4.7.0",
|
|
53
|
+
"@celljs/http": "4.7.0",
|
|
54
|
+
"@celljs/mvc": "4.7.0",
|
|
55
|
+
"@celljs/web": "4.7.0"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|