Skip to content

Commit 53794b1

Browse files
authored
Add Prettier formatting checks
Pin Prettier and establish a repository-wide formatting baseline. Enforce format checks in CI, release validation, and prepublish checks. Preserve the bilingual Markdown wrapping rules. Signed-off-by: Lu Zhang <lu@wdl.dev>
1 parent 4158dd3 commit 53794b1

84 files changed

Lines changed: 5104 additions & 4008 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/skills/wdl-deploy/SKILL.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,30 @@ enable flags, `legacy_error_serialization`, and
5353
(`wrangler.json`, then `wrangler.jsonc`, then `wrangler.toml`). Both JSON
5454
filenames use Wrangler's JSONC syntax, including comments and trailing commas.
5555
The control plane is canonical for unsupported runtime shapes such as
56-
unsupported workerd compatibility flags and WDL-reserved injected module
57-
names. The CLI still fails fast for cheap local cases such as Python Workers
58-
modules, unmapped top-level or selected-env Wrangler runtime/deploy keys
59-
(`[site]`, `pages_build_output_dir`, `observability`, `limits`,
60-
`placement`, etc.), and ambiguous runtime `env` name collisions between
61-
`[vars]`, explicit bindings, and the implicit `ASSETS` binding.
62-
For an operator-enabled routed Worker, explicit `workers_dev = false` keeps its
63-
pattern routes active while disabling the default platform-domain URL; it
64-
requires at least one `route` / `routes` pattern and is not inferred.
65-
The deploy summary prints every active route-pattern URL hint, preserving the
66-
trailing `*` on prefix patterns, and includes the platform-domain URL only while
67-
it is enabled. Cloudflare's separate `preview_urls` field is unsupported and
68-
rejected by the CLI.
69-
WDL-only `[[exports]]`, `[[platform_bindings]]`, `[[triggers.schedules]]`, and
56+
unsupported workerd compatibility flags and WDL-reserved injected module names.
57+
The CLI still fails fast for cheap local cases such as Python Workers modules,
58+
unmapped top-level or selected-env Wrangler runtime/deploy keys (`[site]`,
59+
`pages_build_output_dir`, `observability`, `limits`, `placement`, etc.), and
60+
ambiguous runtime `env` name collisions between `[vars]`, explicit bindings, and
61+
the implicit `ASSETS` binding. For an operator-enabled routed Worker, explicit
62+
`workers_dev = false` keeps its pattern routes active while disabling the
63+
default platform-domain URL; it requires at least one `route` / `routes` pattern
64+
and is not inferred. The deploy summary prints every active route-pattern URL
65+
hint, preserving the trailing `*` on prefix patterns, and includes the
66+
platform-domain URL only while it is enabled. Cloudflare's separate
67+
`preview_urls` field is unsupported and rejected by the CLI. WDL-only
68+
`[[exports]]`, `[[platform_bindings]]`, `[[triggers.schedules]]`, and
7069
`[[services]].ns` are parsed by the CLI and removed from Wrangler's temporary
71-
bundle config; other fields retain their existing Wrangler passthrough
72-
behavior. Wrangler's object-shaped declarative `exports` config is unsupported.
73-
The dry-run child hides Wrangler's banner (and its normal update check) and
74-
disables anonymous telemetry. Wrangler may still consult the configured npm
75-
registry when reporting an unknown configuration field; project build hooks
76-
retain their normal network access.
77-
For `[[services]]` and `[[exports]]`, read `docs/deploy.md`: tenant JSRPC may
78-
delegate service or Durable Object class stubs as opaque capabilities, but the
79-
receiver cannot rewrite their host-authored caller properties. Keep delegated
80-
stubs in memory; long-term irrevocable stub storage is unsupported.
70+
bundle config; other fields retain their existing Wrangler passthrough behavior.
71+
Wrangler's object-shaped declarative `exports` config is unsupported. The
72+
dry-run child hides Wrangler's banner (and its normal update check) and disables
73+
anonymous telemetry. Wrangler may still consult the configured npm registry when
74+
reporting an unknown configuration field; project build hooks retain their
75+
normal network access. For `[[services]]` and `[[exports]]`, read
76+
`docs/deploy.md`: tenant JSRPC may delegate service or Durable Object class
77+
stubs as opaque capabilities, but the receiver cannot rewrite their
78+
host-authored caller properties. Keep delegated stubs in memory; long-term
79+
irrevocable stub storage is unsupported.
8180

8281
Never recommend setting `CONTROL_CONNECT_HOST` outside local development: it
8382
overrides the TCP target the admin token connects to (Host header + TLS SNI

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030

3131
- run: npm ci
3232
- run: npm audit --audit-level=moderate
33+
- run: npm run format:check
3334
- run: npm run lint
3435
- run: npm run typecheck
3536
- run: npm test

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525

2626
- run: npm ci
2727
- run: npm audit --audit-level=moderate
28+
- run: npm run format:check
2829
- run: npm run lint
2930
- run: npm run typecheck
3031
- run: npm test

.prettierrc.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"embeddedLanguageFormatting": "off",
3+
"printWidth": 120,
4+
"proseWrap": "always",
5+
"quoteProps": "preserve",
6+
"trailingComma": "es5",
7+
"overrides": [
8+
{
9+
"files": "**/*.md",
10+
"options": {
11+
"printWidth": 80
12+
}
13+
},
14+
{
15+
"files": "**/*-zh.md",
16+
"options": {
17+
"printWidth": 80,
18+
"proseWrap": "never"
19+
}
20+
}
21+
]
22+
}

AGENTS.md

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ newer target.
1919

2020
- `npm install`: install dependencies from `package-lock.json`.
2121
- `npm link`: expose the local `wdl` binary for manual testing.
22+
- `npm run format`: format supported source and documentation files.
23+
- `npm run format:check`: verify formatting without modifying files.
2224
- `npm run lint`: run ESLint over the CLI, docs helpers, and examples.
2325
- `npm run typecheck`: run TypeScript's JavaScript-aware `tsc --noEmit` check.
2426
- `npm test`: run Node's built-in test runner against
@@ -31,9 +33,9 @@ newer target.
3133
configured — the CLI has no default endpoint.
3234

3335
Use Node.js 22 or newer for local work. The GitHub Actions workflow uses Node
34-
22, runs `npm ci`, `npm audit --audit-level=moderate`, `npm run lint`,
35-
`npm run typecheck`, `npm test`, and `npm pack --dry-run`, then checks workflow
36-
syntax with actionlint.
36+
22, runs `npm ci`, `npm audit --audit-level=moderate`, `npm run format:check`,
37+
`npm run lint`, `npm run typecheck`, `npm test`, and `npm pack --dry-run`, then
38+
checks workflow syntax with actionlint.
3739

3840
## Coding Style & Naming Conventions
3941

@@ -47,14 +49,14 @@ dependency injection for testable command behavior, as seen in
4749
types rather than `any`, and use `unknown` plus narrowing for values validated
4850
at runtime.
4951

50-
Markdown wrapping is bilingual by design, normalized with Prettier
51-
(`--embedded-language-formatting=off`; code blocks are hand-formatted) and kept
52-
by editing habit rather than a linter: English prose hard-wraps at 80 columns
53-
(`--prose-wrap always`), while Chinese prose never hard-wraps inside a sentence
54-
(`--prose-wrap never`, one line per paragraph) because CommonMark renders a soft
55-
break as a space and CJK text would pick up spurious mid-sentence spaces.
56-
Tables, code blocks, and long URLs are exempt; there is no line-length lint,
57-
since table rows would trip it.
52+
Prettier formats supported files with a 120-column source width. Markdown
53+
wrapping is bilingual by design (`--embedded-language-formatting=off`; code
54+
blocks are hand-formatted): English prose hard-wraps at 80 columns
55+
(`--prose-wrap always`), while Chinese `*-zh.md` prose never hard-wraps inside a
56+
sentence (`--prose-wrap never`, one line per paragraph) because CommonMark
57+
renders a soft break as a space and CJK text would pick up spurious mid-sentence
58+
spaces. Tables, code blocks, and long URLs are exempt; run
59+
`npm run format:check` to enforce the repository configuration.
5860

5961
## Testing Guidelines
6062

@@ -75,26 +77,27 @@ defaults change. The per-feature docs are bilingual pairs — `docs/<name>.md`
7577
(English) and `docs/<name>-zh.md` (Chinese) — and both languages are
7678
authoritative: update the pair in the same change. Agent-facing references
7779
(`templates/AGENTS.md`, the wdl-deploy skill, generated projects) point only at
78-
the English set. Before packaging, re-run the audit, test, and `npm pack
79-
--dry-run` checks from Build, Test, and Development Commands.
80+
the English set. Before packaging, re-run the audit, test, and
81+
`npm pack --dry-run` checks from Build, Test, and Development Commands.
8082

8183
## Release
8284

83-
Releases are tag-driven. `.github/workflows/release.yml` re-runs audit, lint,
84-
typecheck, and tests, verifies the tag matches `version` in `package.json`, and
85-
runs `npm pack --dry-run` — all before any publish, so a broken release fails the
86-
tag's check job and never publishes. It then publishes `@wdl-dev/cli` to npmjs
87-
(with provenance) and to GitHub Packages (authenticated with the workflow's own
88-
`GITHUB_TOKEN`), and creates a GitHub Release for the tag: final releases take
89-
their notes from the matching `CHANGELOG.md` section, pre-releases fall back to
90-
generated notes and are marked Pre-release. Do not run `npm publish` by hand.
85+
Releases are tag-driven. `.github/workflows/release.yml` re-runs formatting,
86+
audit, lint, typecheck, and tests, verifies the tag matches `version` in
87+
`package.json`, and runs `npm pack --dry-run` — all before any publish, so a
88+
broken release fails the tag's check job and never publishes. It then publishes
89+
`@wdl-dev/cli` to npmjs (with provenance) and to GitHub Packages (authenticated
90+
with the workflow's own `GITHUB_TOKEN`), and creates a GitHub Release for the
91+
tag: final releases take their notes from the matching `CHANGELOG.md` section,
92+
pre-releases fall back to generated notes and are marked Pre-release. Do not run
93+
`npm publish` by hand.
9194

9295
Published npm versions are immutable (no reuse; unpublish only within 72 hours),
9396
but the check job gates every publish, so most releases tag the final version
9497
directly. This project ships documented breaking removals in 1.x minors (called
9598
out in the CHANGELOG) — do not hold or re-version a release for generic SemVer
9699
reasons. Stage a pre-release only for the narrower risk an RC actually guards:
97-
the *published artifact* differing from what the check job validated — packaging
100+
the _published artifact_ differing from what the check job validated — packaging
98101
changes (the `files` allowlist, entry points, the bundle/publish pipeline) or a
99102
large release you want to smoke-test as a real `@next` install. For an RC, set
100103
`version` to e.g. `2.0.0-rc.1`, write the CHANGELOG entry, commit, and tag
@@ -128,15 +131,15 @@ drops a `.env`-supplied endpoint when the effective token is not from the same
128131
`.env`), then the global token store (`~/.config/wdl/credentials`, managed by
129132
`wdl token`). The store is trusted (home directory, same-source token +
130133
endpoint) and not subject to the guard; a project `.env` is not. The namespace
131-
itself follows the same shape — `--ns > shell WDL_NS > project .env WDL_NS >
132-
store default (base WDL_NS)` — so the store's default namespace is the lowest
133-
selector, materialized into `env.WDL_NS` before the per-key gap-fill. Keep that
134-
ordering and the guard intact when touching `loadCliControlEnv` or
135-
`lib/token-store.js`; `--no-token-store` / `WDL_TOKEN_STORE=off` (via
136-
`tokenStoreReader`, read from the process env, not a project `.env`) must keep
137-
opting the store out of resolution entirely. Do not commit tenant tokens or
138-
generated secrets; read credentials from the environment and keep example
139-
configuration generic.
134+
itself follows the same shape —
135+
`--ns > shell WDL_NS > project .env WDL_NS > store default (base WDL_NS)` — so
136+
the store's default namespace is the lowest selector, materialized into
137+
`env.WDL_NS` before the per-key gap-fill. Keep that ordering and the guard
138+
intact when touching `loadCliControlEnv` or `lib/token-store.js`;
139+
`--no-token-store` / `WDL_TOKEN_STORE=off` (via `tokenStoreReader`, read from
140+
the process env, not a project `.env`) must keep opting the store out of
141+
resolution entirely. Do not commit tenant tokens or generated secrets; read
142+
credentials from the environment and keep example configuration generic.
140143

141144
### Deploy runs project code as you
142145

CHANGELOG.md

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
### Added
88

9-
- Routed Workers with at least one custom route can set `workers_dev = false`
10-
to disable their platform-domain URL. Deploy summaries print the active
11-
platform URL and route-pattern URL hints, omitting the disabled URL.
9+
- Routed Workers with at least one custom route can set `workers_dev = false` to
10+
disable their platform-domain URL. Deploy summaries print the active platform
11+
URL and route-pattern URL hints, omitting the disabled URL.
1212

1313
## 1.5.1
1414

1515
### Security
1616

17-
- Bump the bundled `wrangler` to 4.114.0, which vendors a patched sharp
18-
(0.35.2) and clears a high-severity libvips advisory (GHSA-f88m-g3jw-g9cj)
19-
reachable only through the miniflare dev server, which the CLI never runs.
17+
- Bump the bundled `wrangler` to 4.114.0, which vendors a patched sharp (0.35.2)
18+
and clears a high-severity libvips advisory (GHSA-f88m-g3jw-g9cj) reachable
19+
only through the miniflare dev server, which the CLI never runs.
2020

2121
## 1.5.0
2222

@@ -41,11 +41,10 @@
4141

4242
### Fixed
4343

44-
- `wdl deploy` no longer passes WDL-only `[[exports]]`,
45-
`[[platform_bindings]]`, `[[triggers.schedules]]`, or `[[services]].ns` to
46-
Wrangler's temporary bundle config. This avoids the `exports` schema
47-
collision in Wrangler 4.107+ while preserving the fields in the WDL deploy
48-
manifest.
44+
- `wdl deploy` no longer passes WDL-only `[[exports]]`, `[[platform_bindings]]`,
45+
`[[triggers.schedules]]`, or `[[services]].ns` to Wrangler's temporary bundle
46+
config. This avoids the `exports` schema collision in Wrangler 4.107+ while
47+
preserving the fields in the WDL deploy manifest.
4948

5049
## 1.4.0
5150

@@ -54,8 +53,8 @@
5453
- `wdl deploy` now selects `wrangler.json`, then `wrangler.jsonc`, then
5554
`wrangler.toml`, parses both JSON filenames as JSONC, and resolves Wrangler
5655
from explicit/project/package/`PATH` sources (`npx` remains opt-in). It
57-
rejects Python modules, unmapped runtime fields, and binding collisions
58-
before upload; runtime/workerd bundle policy remains canonical in control.
56+
rejects Python modules, unmapped runtime fields, and binding collisions before
57+
upload; runtime/workerd bundle policy remains canonical in control.
5958
- New projects use `compatibility_date = "2026-06-17"` unless a feature requires
6059
newer behavior.
6160
- Control requests now identify the CLI version, cap buffered JSON responses at
@@ -73,17 +72,17 @@
7372

7473
### Fixed
7574

76-
- Control connection failures, invalid 2xx JSON, unreadable project `.env` or
77-
D1 input files, and unexpected arguments now use escaped CLI diagnostics
78-
instead of raw Node errors or silently ignored input.
75+
- Control connection failures, invalid 2xx JSON, unreadable project `.env` or D1
76+
input files, and unexpected arguments now use escaped CLI diagnostics instead
77+
of raw Node errors or silently ignored input.
7978
- Deploy failures now retain control warnings and actionable secret,
8079
environment-budget, and caller-secret guidance.
8180
- D1 migrations reject symlinked SQL files, invalid `.assetsignore` patterns
8281
identify the offending rule, and project `.env` parsing tolerates unrelated
8382
dotenv extensions.
84-
- Secret mutation failures explain environment-budget, contention, and
85-
envelope errors, including when no mutation was written; token list safely
86-
renders stored labels and endpoints.
83+
- Secret mutation failures explain environment-budget, contention, and envelope
84+
errors, including when no mutation was written; token list safely renders
85+
stored labels and endpoints.
8786

8887
### Security
8988

@@ -103,14 +102,14 @@
103102

104103
### Changed
105104

106-
- `wdl d1 execute` now requires exactly one SQL source (`--sql` or `--file`)
107-
and rejects empty SQL locally before contacting control. Even `--sql ""`
108-
conflicts with `--file`.
105+
- `wdl d1 execute` now requires exactly one SQL source (`--sql` or `--file`) and
106+
rejects empty SQL locally before contacting control. Even `--sql ""` conflicts
107+
with `--file`.
109108
- `wdl deploy` now rejects more malformed Wrangler config locally instead of
110109
silently dropping invalid input: non-array `kv_namespaces`, malformed KV
111110
entries, present-but-non-table `[assets]`, and several validated fields that
112-
previously reached the manifest with loose types. Wrangler local-dev KV
113-
fields `preview_id` and `remote` remain allowed but are ignored by deploy.
111+
previously reached the manifest with loose types. Wrangler local-dev KV fields
112+
`preview_id` and `remote` remain allowed but are ignored by deploy.
114113

115114
## 1.2.2
116115

@@ -120,8 +119,8 @@
120119
world-writable store directory: a 0600 file there can still be deleted,
121120
replaced, or symlink-swapped by another user, so the write fails with a
122121
`chmod 700` hint instead. POSIX only.
123-
- `wdl r2 object head --json` parses custom metadata without prototype
124-
pollution — an `x-amz-meta-__proto__` header stays an own key, and an empty
122+
- `wdl r2 object head --json` parses custom metadata without prototype pollution
123+
— an `x-amz-meta-__proto__` header stays an own key, and an empty
125124
`x-amz-meta-` header is dropped.
126125

127126
### Changed
@@ -140,8 +139,8 @@
140139
dropped.
141140
- A local deploy prints a direct `http://<ns>.<domain>:8080/<worker>/` URL
142141
instead of a `curl -H 'Host: ...'` hint, and a control plane reached via a
143-
`.test` / `.local` host is recognized as local (previously only
144-
localhost / 127.0.0.1).
142+
`.test` / `.local` host is recognized as local (previously only localhost /
143+
127.0.0.1).
145144
- KV docs (GUIDE and `docs/kv.md`) describe the 512-byte key / list-prefix cap
146145
the platform now enforces; they previously said it was not checked. Documented
147146
that `wdl d1 execute --mode exec` takes no `--params`.
@@ -182,9 +181,9 @@
182181
values already were. A malicious or compromised control plane could put
183182
terminal control bytes (ESC / OSC / C1) in a JSON error property name and have
184183
them written unescaped to stderr (OSC 52 clipboard writes, display spoofing).
185-
- Control-plane responses now abort the connection when the body exceeds the
186-
10 MiB cap, instead of rejecting the result while continuing to read the
187-
stream — the cap bounds resource use, not just the returned value.
184+
- Control-plane responses now abort the connection when the body exceeds the 10
185+
MiB cap, instead of rejecting the result while continuing to read the stream —
186+
the cap bounds resource use, not just the returned value.
188187
- The trusted-publishing release job pins the npm CLI to an exact reviewed
189188
version instead of installing `npm@latest`, so a compromised npm release can't
190189
run in the job that holds the npm OIDC token and publish a tampered,
@@ -225,8 +224,8 @@
225224

226225
### Changed
227226

228-
- `wdl init`'s `--ns` is now optional. With `--ns`, the scaffolded `npm run
229-
deploy` keeps `wdl deploy . --ns <ns>`; without it the script is
227+
- `wdl init`'s `--ns` is now optional. With `--ns`, the scaffolded
228+
`npm run deploy` keeps `wdl deploy . --ns <ns>`; without it the script is
230229
`wdl deploy .` and the namespace is resolved at deploy time (`--ns` / `WDL_NS`
231230
/ project `.env` / a `wdl token` default). `init` also no longer autoloads
232231
control credentials, so a corrupt token store cannot block scaffolding.
@@ -244,9 +243,9 @@
244243
- `wdl secret put` no longer echoes the typed secret on a TTY: input is read in
245244
raw mode (hidden), and fails closed — it errors rather than echo if the
246245
terminal cannot hide input.
247-
- `.env` values containing literal backslash escape sequences (e.g. a token
248-
with a backslash followed by `n`) now round-trip correctly instead of being
249-
decoded as control characters.
246+
- `.env` values containing literal backslash escape sequences (e.g. a token with
247+
a backslash followed by `n`) now round-trip correctly instead of being decoded
248+
as control characters.
250249

251250
### Security
252251

CONTRIBUTING.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@ reaching the terminal**.
5858

5959
## Checks
6060

61-
All of these run in CI on every pull request and must pass:
61+
Run `npm run format` to apply the repository formatting rules. The following
62+
checks run in CI on every pull request and must pass:
6263

6364
```bash
65+
npm run format:check
6466
npm run lint
6567
npm run typecheck
6668
npm test

0 commit comments

Comments
 (0)