next-workers-kit 1.0.0 → 2.0.1
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 +8 -8
- package/dist/lib/doctor.js +0 -15
- package/dist/lib/files.js +0 -1
- package/package.json +3 -4
- package/templates/synced/lefthook.yml +5 -0
- package/dist/hooks/format.d.ts +0 -1
- package/dist/hooks/format.js +0 -26
- package/dist/hooks/typecheck.d.ts +0 -1
- package/dist/hooks/typecheck.js +0 -24
- package/templates/init/claude-settings.json +0 -25
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# next-workers-kit
|
|
2
2
|
|
|
3
|
-
One opinionated setup for Next.js on Cloudflare Workers with [OpenNext](https://opennext.js.org/cloudflare), enforced by a check that runs before every deploy. You get strict ESLint, TypeScript and Prettier configs, a feature-folder structure that lint enforces, security headers, Dependabot,
|
|
3
|
+
One opinionated setup for Next.js on Cloudflare Workers with [OpenNext](https://opennext.js.org/cloudflare), enforced by a check that runs before every deploy. You get strict ESLint, TypeScript and Prettier configs, a feature-folder structure that lint enforces, security headers, Dependabot, commit and push hooks, and `next-workers-kit doctor`, which fails the build when a project drifts from the setup.
|
|
4
4
|
|
|
5
5
|
It's built for teams and agents that run several Next.js sites on Workers and want them to stay identical, so the same change works in every repo and the checks catch mistakes.
|
|
6
6
|
|
|
@@ -99,13 +99,13 @@ Project-specific rules go after the spread, in the same `defineConfig` array.
|
|
|
99
99
|
|
|
100
100
|
`npm run check` starts with `next-workers-kit doctor`. Run it as your Workers Builds build command (`npm run check && npx opennextjs-cloudflare build`) and a project that drifts can't deploy.
|
|
101
101
|
|
|
102
|
-
| Kind | Files
|
|
103
|
-
| ------- |
|
|
104
|
-
| Synced | `CLAUDE.md`, `.editorconfig`, `.gitattributes`, `.npmrc`, `.nvmrc`, `lefthook.yml`, `.github/dependabot.yml`
|
|
105
|
-
| Starter | `.gitignore`, `.prettierignore`, `knip.json`, `.mcp.json`,
|
|
106
|
-
| Project | `package.json`, `next.config.ts`, `wrangler.jsonc`, `.dev.vars.example`
|
|
102
|
+
| Kind | Files | doctor checks |
|
|
103
|
+
| ------- | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------- |
|
|
104
|
+
| Synced | `CLAUDE.md`, `.editorconfig`, `.gitattributes`, `.npmrc`, `.nvmrc`, `lefthook.yml`, `.github/dependabot.yml` | Identical to the package copy |
|
|
105
|
+
| Starter | `.gitignore`, `.prettierignore`, `knip.json`, `.mcp.json`, ESLint, Prettier and TS configs | Still contain the baseline entries; add your own freely |
|
|
106
|
+
| Project | `package.json`, `next.config.ts`, `wrangler.jsonc`, `.dev.vars.example` | Baseline scripts, pins and settings; one `.dev.vars.example` line per required secret |
|
|
107
107
|
|
|
108
|
-
It also reports `.env*` files (OpenNext bundles them into the Worker; keep local secrets in `.dev.vars`)
|
|
108
|
+
It also reports `.env*` files (OpenNext bundles them into the Worker; keep local secrets in `.dev.vars`) and `src/middleware.ts` (use `proxy.ts`).
|
|
109
109
|
|
|
110
110
|
- `npx next-workers-kit sync` rewrites the synced files and sets `packageManager` to the latest npm. Run it after upgrading this package.
|
|
111
111
|
- `npx next-workers-kit init` runs `sync` and writes any missing starter files. It never overwrites your files.
|
|
@@ -122,7 +122,7 @@ It also reports `.env*` files (OpenNext bundles them into the Worker; keep local
|
|
|
122
122
|
|
|
123
123
|
**Staying current.** Dependabot checks daily and waits three days after each release. When it upgrades this package, run `npx next-workers-kit sync` on that branch.
|
|
124
124
|
|
|
125
|
-
**
|
|
125
|
+
**When checks run.** `lefthook` checks formatting and lint on staged files before a commit, runs `npm run check` before a push, and Workers Builds runs it again before every deploy. `CLAUDE.md` imports `AGENTS.md`, so Claude Code reads the same instructions as other agents.
|
|
126
126
|
|
|
127
127
|
## Develop
|
|
128
128
|
|
package/dist/lib/doctor.js
CHANGED
|
@@ -173,21 +173,6 @@ export function doctor(root) {
|
|
|
173
173
|
else if (!mcp.includes("next-devtools-mcp")) {
|
|
174
174
|
report(".mcp.json", "add the next-devtools-mcp server");
|
|
175
175
|
}
|
|
176
|
-
const settings = json(".claude/settings.json");
|
|
177
|
-
if (settings) {
|
|
178
|
-
// Agents may do everything; the hooks only format and typecheck.
|
|
179
|
-
for (const rule of ["deny", "ask"]) {
|
|
180
|
-
if (settings.permissions?.[rule]?.length) {
|
|
181
|
-
report(".claude/settings.json", `remove permissions.${rule}; agents are not restricted`);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
const hooks = JSON.stringify(settings.hooks ?? {});
|
|
185
|
-
for (const hook of ["format", "typecheck"]) {
|
|
186
|
-
if (!hooks.includes(`${packageName}/dist/hooks/${hook}.js`)) {
|
|
187
|
-
report(".claude/settings.json", `add the ${hook} hook`);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
176
|
for (const [file, needle] of [
|
|
192
177
|
["eslint.config.mjs", `${packageName}/eslint`],
|
|
193
178
|
["prettier.config.mjs", `${packageName}/prettier`],
|
package/dist/lib/files.js
CHANGED
|
@@ -21,7 +21,6 @@ export const starters = {
|
|
|
21
21
|
".prettierignore": join(templates, "init", "prettierignore"),
|
|
22
22
|
"knip.json": join(templates, "init", "knip.json"),
|
|
23
23
|
".mcp.json": join(templates, "init", "mcp.json"),
|
|
24
|
-
".claude/settings.json": join(templates, "init", "claude-settings.json"),
|
|
25
24
|
"eslint.config.mjs": join(templates, "init", "eslint.config.mjs"),
|
|
26
25
|
"prettier.config.mjs": join(templates, "init", "prettier.config.mjs"),
|
|
27
26
|
"tsconfig.json": join(templates, "init", "tsconfig.json"),
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-workers-kit",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Config, structure rules and drift checks for Next.js on Cloudflare Workers (OpenNext): ESLint, TypeScript, Prettier
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Config, structure rules and drift checks for Next.js on Cloudflare Workers (OpenNext): ESLint, TypeScript, Prettier and a project doctor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "pnilssson",
|
|
7
7
|
"type": "module",
|
|
@@ -73,8 +73,7 @@
|
|
|
73
73
|
"opennext",
|
|
74
74
|
"eslint-config",
|
|
75
75
|
"prettier-config",
|
|
76
|
-
"tsconfig"
|
|
77
|
-
"claude-code"
|
|
76
|
+
"tsconfig"
|
|
78
77
|
],
|
|
79
78
|
"homepage": "https://github.com/pnilssson/next-workers-kit#readme",
|
|
80
79
|
"bugs": {
|
package/dist/hooks/format.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/hooks/format.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Claude Code PostToolUse hook: fix lint and format the file an agent just edited.
|
|
2
|
-
import { execSync } from "node:child_process";
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
|
-
import { isAbsolute, relative, resolve } from "node:path";
|
|
5
|
-
const input = JSON.parse(readFileSync(0, "utf8"));
|
|
6
|
-
const file = input.tool_input?.file_path;
|
|
7
|
-
const root = process.env.CLAUDE_PROJECT_DIR ?? process.cwd();
|
|
8
|
-
const path = typeof file === "string" ? relative(root, resolve(root, file)) : "";
|
|
9
|
-
// Leave files outside the project alone, such as notes in another folder.
|
|
10
|
-
if (path && !path.startsWith("..") && !isAbsolute(path)) {
|
|
11
|
-
const run = (command) => {
|
|
12
|
-
try {
|
|
13
|
-
execSync(`npx --no-install ${command} ${JSON.stringify(path)}`, {
|
|
14
|
-
cwd: root,
|
|
15
|
-
stdio: "ignore",
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
// Lint errors the fix can't resolve surface in npm run check.
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
if (/\.[cm]?[jt]sx?$/.test(path)) {
|
|
23
|
-
run("eslint --fix --no-warn-ignored");
|
|
24
|
-
}
|
|
25
|
-
run("prettier --write --ignore-unknown");
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/hooks/typecheck.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Claude Code Stop hook: run the typecheck when TypeScript files changed, and
|
|
2
|
-
// hand any errors back to the agent instead of letting it stop.
|
|
3
|
-
import { execSync } from "node:child_process";
|
|
4
|
-
import { readFileSync } from "node:fs";
|
|
5
|
-
const input = JSON.parse(readFileSync(0, "utf8"));
|
|
6
|
-
if (input.stop_hook_active) {
|
|
7
|
-
process.exit(0);
|
|
8
|
-
}
|
|
9
|
-
const options = {
|
|
10
|
-
cwd: process.env.CLAUDE_PROJECT_DIR ?? process.cwd(),
|
|
11
|
-
encoding: "utf8",
|
|
12
|
-
stdio: "pipe",
|
|
13
|
-
};
|
|
14
|
-
if (!/\.(?:ts|tsx|mts)$/m.test(execSync("git status --porcelain", options))) {
|
|
15
|
-
process.exit(0);
|
|
16
|
-
}
|
|
17
|
-
try {
|
|
18
|
-
execSync("npm run typecheck", options);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
const { stdout = "", stderr = "" } = error;
|
|
22
|
-
process.stderr.write(`${stdout}${stderr}`);
|
|
23
|
-
process.exit(2);
|
|
24
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"hooks": {
|
|
3
|
-
"PostToolUse": [
|
|
4
|
-
{
|
|
5
|
-
"matcher": "Edit|Write",
|
|
6
|
-
"hooks": [
|
|
7
|
-
{
|
|
8
|
-
"type": "command",
|
|
9
|
-
"command": "node \"$CLAUDE_PROJECT_DIR/node_modules/{{package}}/dist/hooks/format.js\""
|
|
10
|
-
}
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
],
|
|
14
|
-
"Stop": [
|
|
15
|
-
{
|
|
16
|
-
"hooks": [
|
|
17
|
-
{
|
|
18
|
-
"type": "command",
|
|
19
|
-
"command": "node \"$CLAUDE_PROJECT_DIR/node_modules/{{package}}/dist/hooks/typecheck.js\""
|
|
20
|
-
}
|
|
21
|
-
]
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
}
|