@zigordev/dev 0.0.0 → 1.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.
Files changed (94) hide show
  1. package/README.md +215 -1
  2. package/bin/zigordev.js +29 -0
  3. package/biome.json +49 -0
  4. package/commitlint.js +16 -0
  5. package/dist/cli.d.ts +13 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +168 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/commits.d.ts +3 -0
  10. package/dist/commits.d.ts.map +1 -0
  11. package/dist/commits.js +15 -0
  12. package/dist/commits.js.map +1 -0
  13. package/dist/files.d.ts +3 -0
  14. package/dist/files.d.ts.map +1 -0
  15. package/dist/files.js +38 -0
  16. package/dist/files.js.map +1 -0
  17. package/dist/first-publish.d.ts +16 -0
  18. package/dist/first-publish.d.ts.map +1 -0
  19. package/dist/first-publish.js +126 -0
  20. package/dist/first-publish.js.map +1 -0
  21. package/dist/release.d.ts +21 -0
  22. package/dist/release.d.ts.map +1 -0
  23. package/dist/release.js +73 -0
  24. package/dist/release.js.map +1 -0
  25. package/dist/rule.d.ts +17 -0
  26. package/dist/rule.d.ts.map +1 -0
  27. package/dist/rule.js +2 -0
  28. package/dist/rule.js.map +1 -0
  29. package/dist/rules/actions.d.ts +3 -0
  30. package/dist/rules/actions.d.ts.map +1 -0
  31. package/dist/rules/actions.js +57 -0
  32. package/dist/rules/actions.js.map +1 -0
  33. package/dist/rules/attribution.d.ts +3 -0
  34. package/dist/rules/attribution.d.ts.map +1 -0
  35. package/dist/rules/attribution.js +37 -0
  36. package/dist/rules/attribution.js.map +1 -0
  37. package/dist/rules/comments.d.ts +3 -0
  38. package/dist/rules/comments.d.ts.map +1 -0
  39. package/dist/rules/comments.js +368 -0
  40. package/dist/rules/comments.js.map +1 -0
  41. package/dist/rules/docs.d.ts +3 -0
  42. package/dist/rules/docs.d.ts.map +1 -0
  43. package/dist/rules/docs.js +32 -0
  44. package/dist/rules/docs.js.map +1 -0
  45. package/dist/rules/identity.d.ts +4 -0
  46. package/dist/rules/identity.d.ts.map +1 -0
  47. package/dist/rules/identity.js +64 -0
  48. package/dist/rules/identity.js.map +1 -0
  49. package/dist/rules/index.d.ts +3 -0
  50. package/dist/rules/index.d.ts.map +1 -0
  51. package/dist/rules/index.js +12 -0
  52. package/dist/rules/index.js.map +1 -0
  53. package/dist/rules/links.d.ts +3 -0
  54. package/dist/rules/links.d.ts.map +1 -0
  55. package/dist/rules/links.js +52 -0
  56. package/dist/rules/links.js.map +1 -0
  57. package/dist/rules/scripts.d.ts +3 -0
  58. package/dist/rules/scripts.d.ts.map +1 -0
  59. package/dist/rules/scripts.js +50 -0
  60. package/dist/rules/scripts.js.map +1 -0
  61. package/dist/rules/shared.d.ts +3 -0
  62. package/dist/rules/shared.d.ts.map +1 -0
  63. package/dist/rules/shared.js +26 -0
  64. package/dist/rules/shared.js.map +1 -0
  65. package/dist/shared.d.ts +5 -0
  66. package/dist/shared.d.ts.map +1 -0
  67. package/dist/shared.js +33 -0
  68. package/dist/shared.js.map +1 -0
  69. package/lefthook.yml +36 -0
  70. package/package.json +54 -4
  71. package/semantic-release.js +22 -0
  72. package/shared/.claude/hooks/guard.mjs +785 -0
  73. package/shared/.claude/hooks/guard.sh +7 -0
  74. package/shared/.claude/rules/api.md +48 -0
  75. package/shared/.claude/rules/core.md +71 -0
  76. package/shared/.claude/rules/data.md +43 -0
  77. package/shared/.claude/rules/docs.md +49 -0
  78. package/shared/.claude/rules/infra.md +49 -0
  79. package/shared/.claude/rules/tests.md +40 -0
  80. package/shared/.claude/rules/web.md +42 -0
  81. package/shared/.claude/rules/workflows.md +19 -0
  82. package/shared/.claude/settings.json +84 -0
  83. package/shared/.claude/skills/finish-work/SKILL.md +20 -0
  84. package/shared/.claude/skills/start-work/SKILL.md +16 -0
  85. package/shared/.claude/skills/write-decision-record/SKILL.md +20 -0
  86. package/shared/.claude/skills/write-decision-record/template.md +21 -0
  87. package/shared/.commitlintrc.json +3 -0
  88. package/shared/.github/pull_request_template.md +23 -0
  89. package/shared/.markdownlint-cli2.jsonc +8 -0
  90. package/shared/lefthook.yml +2 -0
  91. package/shared/renovate.json +5 -0
  92. package/tsconfig/base.json +20 -0
  93. package/tsconfig/library.json +9 -0
  94. package/tsconfig/node.json +11 -0
package/README.md CHANGED
@@ -1,3 +1,217 @@
1
1
  # @zigordev/dev
2
2
 
3
- This is the first, empty version of this package. The pipeline of [zigordev/toolkit](https://github.com/zigordev/toolkit) publishes every later one.
3
+ The developer setup that every zigordev repo shares: the `zigordev` command, one Biome config, the TypeScript bases, one set of git hooks, one set of commit rules, and the rules that every Claude Code session works under.
4
+
5
+ ## What it is
6
+
7
+ One command and a handful of files that a repo refers to instead of writing its own.
8
+
9
+ | Part | What it holds | A repo refers to it as |
10
+ | ----------------------- | -------------------------------------------------------------------------------- | ----------------------------------------- |
11
+ | `zigordev` | The command that checks a repo against the standards and copies the shared files | `pnpm exec zigordev` |
12
+ | `shared/` | The files that are the same in every repo | Copied into the repo by `zigordev sync` |
13
+ | `biome.json` | The lint and format rules | `@zigordev/dev/biome` |
14
+ | `tsconfig/base.json` | The strict TypeScript options | `@zigordev/dev/tsconfig/base.json` |
15
+ | `tsconfig/node.json` | The base, for code that Node.js runs from `src` | `@zigordev/dev/tsconfig/node.json` |
16
+ | `tsconfig/library.json` | The same, for a package that is compiled before it ships | `@zigordev/dev/tsconfig/library.json` |
17
+ | `lefthook.yml` | The git hooks | `node_modules/@zigordev/dev/lefthook.yml` |
18
+ | `commitlint.js` | The commit rules | `@zigordev/dev/commitlint` |
19
+ | `semantic-release.js` | The release settings, for a repo that publishes packages | `@zigordev/dev/semantic-release` |
20
+
21
+ ## Why we have it
22
+
23
+ Without it, each repo would keep its own copy of these files, and a rule fixed in one repo would stay broken in the others. With it, a rule changes in one place and reaches every repo as a version update, so the same mistake is caught the same way everywhere.
24
+
25
+ The command exists for the rules that no ready-made tool checks. A rule that only lives in a document gets broken sooner or later, so each of them is a check with a test.
26
+
27
+ ## How it works here
28
+
29
+ ### The command
30
+
31
+ `zigordev check` reads the repo and prints one line for each thing that breaks a rule. It ends with code 0 when it finds nothing and with code 1 when it finds something.
32
+
33
+ | Rule | What it checks |
34
+ | ------------- | --------------------------------------------------------------------------------------------------------------------------------- |
35
+ | `actions` | Every action in a workflow is pinned to a commit, with its exact version beside it |
36
+ | `attribution` | No commit message, pull request title or pull request description carries an attribution line, such as a `Co-Authored-By` trailer |
37
+ | `comments` | No file holds a comment, in code, config, SQL, Dockerfiles, shell scripts or as a hidden note in Markdown |
38
+ | `docs` | The five standard docs exist: `README.md`, the three guides in `docs/` and at least one decision record in `docs/adr/` |
39
+ | `identity` | The repo is set up to commit as zigordev, and every commit that `main` on GitHub does not have yet was made as zigordev |
40
+ | `links` | Every link from one Markdown file to another file leads somewhere |
41
+ | `scripts` | `package.json` has the standard scripts, and the local stack scripts too when the repo has a `compose.yaml` |
42
+ | `shared` | Every shared file in the repo matches the copy in this package |
43
+
44
+ The `comments` rule allows the few lines a tool needs to work: the first line of a script that names its interpreter, the version beside a pinned action, a Dockerfile's `syntax` line, and suppressions such as `biome-ignore` and `@ts-expect-error`. It reads code with a small scanner of its own, which knows strings, template literals and regular expressions. It does not look inside the code blocks of a Markdown file.
45
+
46
+ The `identity` rule accepts two more names: Renovate as the author of its own updates, and GitHub as the committer of a merge it made.
47
+
48
+ `zigordev sync` copies the shared files from this package into the repo and says which ones it changed. They are the files that must read the same everywhere: `lefthook.yml`, `.commitlintrc.json`, `.markdownlint-cli2.jsonc`, `renovate.json`, the pull request template under `.github/` and the session rules under `.claude/`. When this package changes one of them, the `shared` rule fails in every repo until `zigordev sync` has run there, so no copy can fall behind unnoticed.
49
+
50
+ The root `biome.json` is not among them. Biome refuses a second root config anywhere in a repo, so this package cannot hold a copy of it.
51
+
52
+ ### The release command
53
+
54
+ A repo that publishes packages runs two more commands in its pipeline. They hold the one part of a release that no ready-made tool does for us: knowing which packages still have to be published.
55
+
56
+ `zigordev release plan` looks at three things: the packages of the workspace that are not marked private, the newest version tag in git, and npm. It prints each package that npm does not have at that version, and it tells the pipeline whether anything is left to publish.
57
+
58
+ `zigordev release pack <folder> <version>` writes that version into the manifest of every public package, and packs the missing ones as tarballs into the folder. pnpm does the packing, so a tarball holds exact versions where the repo says `catalog:` or `workspace:`.
59
+
60
+ Both ask npm through its own command. Any answer other than "found" or "not found" stops the release, so a network fault never looks like a missing package.
61
+
62
+ The plan starts from what npm lacks, not from what just changed. A release that failed halfway therefore finishes on the next run.
63
+
64
+ `semantic-release.js` holds the settings of semantic-release, the tool that works out the next version. It releases from `main` only, reads a title the way commitlint does, with `!` after the type as a breaking change, and writes the release notes on GitHub. It posts no comment, opens no issue and adds no label, because nothing here credits a tool. It does not publish: the pipeline does that with the two commands above.
65
+
66
+ `zigordev first-publish <package...>` is for the owner of the npm account, once for each new package. npm lets a pipeline publish a package only when the package exists and its name is tied to the repo, and a new tie expires unless the pipeline publishes through it within 2 days. The command does both steps: it publishes an empty version 0.0.0 from a throwaway folder, and it ties the name to this repo, to its `ci.yml` and to the environment named `release`. It works through the owner's own sign-in and second factor, so it refuses to run without a person at a terminal. With `--dry-run` it only says what it would do.
67
+
68
+ A repo's own `release.config.js` passes these settings on in one line. semantic-release then finds its own plugins, which it cannot do when the settings arrive through its `extends` option under pnpm.
69
+
70
+ ### The session rules
71
+
72
+ Claude Code does the building in every repo, and `shared/.claude/` holds what it works under. `zigordev sync` copies the folder into each repo, so a session finds the same rules everywhere, in a cloud session too.
73
+
74
+ | Part | What it holds | When a session reads it |
75
+ | -------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
76
+ | `rules/core.md` | The few rules that hold everywhere, and the check that enforces each one | Always |
77
+ | `rules/api.md`, `web.md`, `data.md`, `infra.md`, `workflows.md`, `docs.md`, `tests.md` | The standards of one area | Only when it reads or edits a file of that area, such as a migration for `data.md` |
78
+ | `skills/` | Procedures done the same way each time: `start-work`, `finish-work` and `write-decision-record` | Only when it uses one |
79
+ | `settings.json` | The permission rules and the two hooks | Always |
80
+ | `hooks/` | The guard: `guard.sh` and `guard.mjs` | Before every shell command, and after a file is written |
81
+
82
+ The permission rules are three plain lists. One lets the standard scripts run without a question, such as `pnpm check`. One asks the owner first: creating or changing a repo, a release, a label or a workflow run, applying infrastructure, and publishing a package. One refuses outright: setting or deleting a secret or a variable.
83
+
84
+ The guard answers what a list cannot, because it has to look at the repo or at the text of the command:
85
+
86
+ | The session tries to | The guard |
87
+ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------ |
88
+ | Commit under an identity other than zigordev | Refuses, and says how to set the identity |
89
+ | Commit, or send text with `gh`, with an attribution line in it | Refuses |
90
+ | Push to `main`, however the command spells it | Refuses |
91
+ | Push, or change something with `gh`, while `gh` acts as another account | Refuses, and names the command that switches |
92
+ | Approve a pull request or a deployment, or merge with `--admin` | Refuses |
93
+ | Skip the git hooks, force-push another branch, change a label, or change anything through GitHub's API | Asks the owner |
94
+ | Write a file that holds a comment | Lets it happen, then tells the session to remove the comment |
95
+
96
+ The guard applies the identity, push and account checks only in a zigordev repo, which it knows by the repo's remote or by the repo's own copy of the guard. The attribution check applies in every repo.
97
+
98
+ `guard.sh` is a launcher of seven lines. Starting Node.js takes between 110 and 190 ms on the laptop, and the hook runs before every shell command. So the launcher looks at the command first, and starts `guard.mjs` only when the command names `git` or `gh`, or when a file was written. Every other command gets its answer in under 10 ms.
99
+
100
+ `guard.mjs` has no dependency and runs on any Node.js from version 20, so it works before `pnpm install` and in a folder that pins no Node.js version. The check for comments after a write is the exception: it runs the installed `zigordev` command, and it is skipped while that is missing.
101
+
102
+ The hook is set to block when it fails. A session cannot commit or push while the guard is broken or Node.js is missing, and every other command still runs.
103
+
104
+ ### The git hooks
105
+
106
+ | When | What runs | What it does |
107
+ | ---------------------------------- | ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
108
+ | Before a commit | Biome | Lints and formats the staged TypeScript, JavaScript, JSON and CSS files, formats the staged YAML and Markdown, and stages what it fixed |
109
+ | Before a commit | markdownlint | Refuses staged Markdown that breaks a rule |
110
+ | Before a commit | gitleaks | Refuses a staged change that contains something shaped like a secret |
111
+ | Before a commit | `zigordev check comments` | Refuses a staged file that holds a comment |
112
+ | Before a commit | `zigordev check identity` | Refuses a commit that would not be made as zigordev |
113
+ | When the commit message is written | commitlint | Refuses a title that is not a Conventional Commit, and any attribution line |
114
+ | Before a push | A check on the target branch | Refuses a push to `main` |
115
+ | Before a push | `pnpm check:quick` | Runs the part of the check that needs no containers |
116
+
117
+ lefthook skips the push hooks when a push carries no changed file. Such a push to `main` is still refused by GitHub, where the rule on `main` cannot be bypassed.
118
+
119
+ The same files serve the laptop and the pipeline, and nothing here runs in production.
120
+
121
+ ### The pull request template
122
+
123
+ `shared/.github/pull_request_template.md` is the description that a pull request starts with when someone opens it on GitHub's site. It has six sections, and one line under each that says what belongs there:
124
+
125
+ | Section | What the author writes |
126
+ | ----------------- | --------------------------------------------------------------------------------------------------- |
127
+ | What | What the pull request changes |
128
+ | Why | Why the change is needed, and why it is done this way |
129
+ | How it was tested | What was run and what was seen, and what was not tested |
130
+ | Observability | How the change shows when it runs: its logs, metrics, traces and alerts. Or that nothing of it runs |
131
+ | Docs | Which docs changed with the behaviour, or why none had to |
132
+ | Follow-ups | What is left for later |
133
+
134
+ A squash merge turns the title and the description into the commit on `main`. So the author replaces each line with their own words, and every commit on `main` then reads the same way. The lines are plain text and not hidden notes: a hidden note is a comment, and it would land in the commit too.
135
+
136
+ The template fills in the form on GitHub's site, and nothing else. A session passes its own description to `gh`, with the same six sections, as the `finish-work` skill says. Renovate writes its own short description. A test holds the template and the skill to the same sections, in the same order.
137
+
138
+ markdownlint leaves the file out. A description starts with a second-level heading, and markdownlint expects a file to start with a top-level one.
139
+
140
+ ### The configs
141
+
142
+ Biome reads the YAML block at the top of a Markdown file as front matter, because every rule and skill file starts with one. The Biome rules are Biome's recommended set plus three: no `console`, type-only imports written as `import type`, and Node.js built-ins imported with the `node:` prefix. Code is formatted with two spaces, single quotes, semicolons and lines of up to 100 characters.
143
+
144
+ The TypeScript base turns on strict mode and three checks beyond it: a value read by index may be `undefined`, an override must be marked, and a `switch` case may not fall through. It also accepts only the syntax that Node.js can strip, because Node.js runs the `.ts` files directly.
145
+
146
+ ## How to use it
147
+
148
+ Add the package and the tools it drives as dev dependencies: `@zigordev/dev`, `@biomejs/biome`, `@commitlint/cli`, `lefthook`, `markdownlint-cli2` and `typescript`. gitleaks is not an npm package, so pin it in `mise.toml`.
149
+
150
+ Then let the command write the shared files:
151
+
152
+ ```bash
153
+ pnpm exec zigordev sync
154
+ ```
155
+
156
+ Two files stay yours to write, because each repo may add to them.
157
+
158
+ `biome.json`:
159
+
160
+ ```json
161
+ {
162
+ "root": true,
163
+ "extends": ["@zigordev/dev/biome"]
164
+ }
165
+ ```
166
+
167
+ `tsconfig.json`:
168
+
169
+ ```json
170
+ {
171
+ "extends": "@zigordev/dev/tsconfig/base.json",
172
+ "compilerOptions": {
173
+ "noEmit": true
174
+ }
175
+ }
176
+ ```
177
+
178
+ Last, two scripts in `package.json`. `"prepare": "lefthook install"` makes `pnpm install` install the hooks, and the lint script ends with `zigordev check`, so the pipeline runs every rule.
179
+
180
+ To run the command by hand:
181
+
182
+ ```bash
183
+ pnpm exec zigordev check
184
+ pnpm exec zigordev check comments links
185
+ pnpm exec zigordev check comments src/app.ts
186
+ pnpm exec zigordev sync
187
+ pnpm exec zigordev release plan
188
+ pnpm exec zigordev first-publish --dry-run @zigordev/dev
189
+ ```
190
+
191
+ The first line runs every rule. The second runs two of them. The third reads one file only. The fourth brings the shared files up to date. The fifth says which public packages npm lacks at the latest version, and it changes nothing. The sixth says what the first publish of a package would do, and changes nothing either.
192
+
193
+ ## How to check that it works
194
+
195
+ | Try this | What must happen |
196
+ | ----------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
197
+ | Stage a badly formatted `.ts` file and commit | The commit goes through with the file formatted |
198
+ | Stage a Markdown file with two top-level headings | The commit is refused, and markdownlint names the rule |
199
+ | Stage a file that holds something shaped like a secret | The commit is refused, and gitleaks reports one leak |
200
+ | Stage a file that holds a comment | The commit is refused, and `zigordev` names the file and the line |
201
+ | Commit with the message `added things` | The commit is refused, because the title has no type |
202
+ | Link to a file that does not exist, then run `pnpm check` | The check fails, and `zigordev` names the link |
203
+ | Change a line in `lefthook.yml`, then run `pnpm check` | The check fails and asks for `zigordev sync`, which puts the file back |
204
+ | Push a branch | `pnpm check:quick` runs first, and the push waits for it |
205
+ | Push a commit to `main` | The push is refused before it leaves the laptop |
206
+ | Push a branch and open a pull request for it on GitHub's site | The description starts with the six sections, from What to Follow-ups |
207
+ | Run `pnpm exec zigordev release plan` in a repo with no version tag | It says how many packages are public, and that no version is tagged yet |
208
+ | Run `pnpm exec zigordev first-publish --dry-run` with a package's name | It says whether the name is new on npm, and prints the command that would tie it |
209
+ | In a session, commit while the repo is set up to commit as someone else | The commit is refused before git runs, and the session is told how to set the identity |
210
+ | In a session, write a file that holds a comment | The file is written, and the session is told to remove the comment |
211
+ | In a session, read a migration, then run `/context` | `data.md` is among the loaded rules. Before that, it is not |
212
+
213
+ When a session reports that a hook failed and blocked a git command, Node.js is missing from its path or `.claude/hooks/` is incomplete: run `mise install`, then `pnpm exec zigordev sync`.
214
+
215
+ When a hook does not run at all, the hooks are not installed: run `pnpm install`, which ends with `sync hooks` and the three hook names. When gitleaks is reported as missing, run `mise install`.
216
+
217
+ When `zigordev` reports a comment where there is none, the scanner misread the file. It is a bug in this package, and the place to fix it is `src/rules/comments.ts`, with a test that shows the case.
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ import { spawnSync } from 'node:child_process';
3
+ import { existsSync } from 'node:fs';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ const source = new URL('../src/cli.ts', import.meta.url);
7
+ const entry = existsSync(fileURLToPath(source))
8
+ ? source
9
+ : new URL('../dist/cli.js', import.meta.url);
10
+ const { main } = await import(entry.href);
11
+
12
+ process.exitCode = main(process.argv.slice(2), {
13
+ cwd: process.cwd(),
14
+ env: process.env,
15
+ shared: fileURLToPath(new URL('../shared/', import.meta.url)),
16
+ run: (command, args, cwd) => {
17
+ const result = spawnSync(command, args, { cwd, encoding: 'utf8' });
18
+ return {
19
+ status: result.status ?? 1,
20
+ stdout: result.stdout ?? '',
21
+ stderr: result.stderr ?? result.error?.message ?? '',
22
+ };
23
+ },
24
+ interact: (command, args, cwd) => spawnSync(command, args, { cwd, stdio: 'inherit' }).status ?? 1,
25
+ atTerminal: process.stdin.isTTY === true && process.stdout.isTTY === true,
26
+ write: (text) => {
27
+ process.stdout.write(text);
28
+ },
29
+ });
package/biome.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "root": false,
3
+ "vcs": {
4
+ "enabled": true,
5
+ "clientKind": "git",
6
+ "useIgnoreFile": true
7
+ },
8
+ "files": {
9
+ "ignoreUnknown": true
10
+ },
11
+ "formatter": {
12
+ "enabled": true,
13
+ "indentStyle": "space",
14
+ "indentWidth": 2,
15
+ "lineWidth": 100
16
+ },
17
+ "javascript": {
18
+ "formatter": {
19
+ "quoteStyle": "single",
20
+ "semicolons": "always",
21
+ "trailingCommas": "es5"
22
+ }
23
+ },
24
+ "markdown": {
25
+ "parser": {
26
+ "frontmatter": true
27
+ }
28
+ },
29
+ "linter": {
30
+ "enabled": true,
31
+ "rules": {
32
+ "preset": "recommended",
33
+ "suspicious": {
34
+ "noConsole": "error"
35
+ },
36
+ "style": {
37
+ "useImportType": "error",
38
+ "useNodejsImportProtocol": "error"
39
+ }
40
+ }
41
+ },
42
+ "assist": {
43
+ "actions": {
44
+ "source": {
45
+ "organizeImports": "on"
46
+ }
47
+ }
48
+ }
49
+ }
package/commitlint.js ADDED
@@ -0,0 +1,16 @@
1
+ export const attribution = /co-authored-by:|generated with \[?claude|claude\.com\/claude-code|🤖/i;
2
+
3
+ function noAttribution(commit) {
4
+ return [
5
+ !attribution.test(commit.raw),
6
+ 'remove attribution lines such as Co-Authored-By trailers or lines crediting Claude',
7
+ ];
8
+ }
9
+
10
+ export default {
11
+ extends: ['@commitlint/config-conventional'],
12
+ plugins: [{ rules: { 'no-attribution': noAttribution } }],
13
+ rules: {
14
+ 'no-attribution': [2, 'always'],
15
+ },
16
+ };
package/dist/cli.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ import { type Interact } from './first-publish.ts';
2
+ import { type Run } from './release.ts';
3
+ export interface Io {
4
+ readonly cwd: string;
5
+ readonly env: Readonly<Record<string, string | undefined>>;
6
+ readonly shared: string;
7
+ readonly run: Run;
8
+ readonly interact: Interact;
9
+ readonly atTerminal: boolean;
10
+ readonly write: (text: string) => void;
11
+ }
12
+ export declare function main(argv: readonly string[], io: Io): number;
13
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAGA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAc,KAAK,GAAG,EAAE,MAAM,cAAc,CAAC;AAKpD,MAAM,WAAW,EAAE;IACjB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AA+JD,wBAAgB,IAAI,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,MAAM,CAuB5D"}
package/dist/cli.js ADDED
@@ -0,0 +1,168 @@
1
+ import { appendFileSync, existsSync, statSync } from 'node:fs';
2
+ import { basename, relative, resolve } from 'node:path';
3
+ import { repoFiles } from './files.js';
4
+ import { firstPublish } from './first-publish.js';
5
+ import { pack, plan } from './release.js';
6
+ import { rulesWith } from './rules/index.js';
7
+ import { sharedFiles, sync } from './shared.js';
8
+ function usage(rules) {
9
+ return [
10
+ 'Usage: zigordev check [rule...] [file...]',
11
+ ' zigordev sync',
12
+ ' zigordev release plan',
13
+ ' zigordev release pack <folder> <version>',
14
+ ' zigordev first-publish [--dry-run] <package...>',
15
+ '',
16
+ 'check With no rule, every rule runs. With files, the rules that read files read only those.',
17
+ 'sync Copies the shared files of @zigordev/dev into this repo.',
18
+ 'release plan says which public packages are missing on npm at the latest tagged version.',
19
+ ' pack writes the tarballs of the missing ones into a folder, at the version given.',
20
+ 'first-publish Puts an empty first version of a new package on npm and ties its name to this repo.',
21
+ ' Only the owner of the npm account runs it. With --dry-run it changes nothing.',
22
+ '',
23
+ 'Rules:',
24
+ ...rules.map((rule) => ` ${rule.name.padEnd(13)}${rule.summary}`),
25
+ '',
26
+ ].join('\n');
27
+ }
28
+ function place(finding) {
29
+ return finding.line === undefined ? finding.path : `${finding.path}:${finding.line}`;
30
+ }
31
+ function isFile(path) {
32
+ return existsSync(path) && statSync(path).isFile();
33
+ }
34
+ function check(args, rules, io) {
35
+ const names = new Set(rules.map((rule) => rule.name));
36
+ const chosen = args.filter((arg) => names.has(arg));
37
+ const paths = args.filter((arg) => !names.has(arg));
38
+ const unknown = paths.find((path) => !isFile(resolve(io.cwd, path)));
39
+ if (unknown !== undefined) {
40
+ io.write(`zigordev check: "${unknown}" is neither a rule nor a file\n\n${usage(rules)}`);
41
+ return 2;
42
+ }
43
+ const active = chosen.length === 0 ? rules : rules.filter((rule) => chosen.includes(rule.name));
44
+ const files = paths.length === 0
45
+ ? repoFiles(io.cwd)
46
+ : paths.map((path) => relative(io.cwd, resolve(io.cwd, path)));
47
+ const findings = active
48
+ .flatMap((rule) => rule.run({ root: io.cwd, files, env: io.env }))
49
+ .sort((left, right) => left.path.localeCompare(right.path) || (left.line ?? 0) - (right.line ?? 0));
50
+ const ran = active.map((rule) => rule.name).join(', ');
51
+ if (findings.length === 0) {
52
+ io.write(`zigordev check: no findings (${ran})\n`);
53
+ return 0;
54
+ }
55
+ for (const finding of findings) {
56
+ io.write(`${place(finding)} ${finding.rule} ${finding.message}\n`);
57
+ }
58
+ io.write(`zigordev check: ${findings.length} ${findings.length === 1 ? 'finding' : 'findings'} (${ran})\n`);
59
+ return 1;
60
+ }
61
+ function copy(io) {
62
+ if (sharedFiles(io.shared).length === 0) {
63
+ io.write(`zigordev sync: the package holds no shared files in ${io.shared}\n`);
64
+ return 1;
65
+ }
66
+ const written = sync(io.cwd, io.shared);
67
+ for (const path of written) {
68
+ io.write(`updated ${path}\n`);
69
+ }
70
+ io.write(written.length === 0
71
+ ? 'zigordev sync: every shared file is up to date\n'
72
+ : `zigordev sync: ${written.length} ${written.length === 1 ? 'file' : 'files'} updated\n`);
73
+ return 0;
74
+ }
75
+ function count(amount, noun) {
76
+ return `${amount} ${noun}${amount === 1 ? '' : 's'}`;
77
+ }
78
+ function planRelease(io) {
79
+ const { packages, version, missing } = plan(io.cwd, io.run);
80
+ if (io.env.GITHUB_OUTPUT !== undefined) {
81
+ appendFileSync(io.env.GITHUB_OUTPUT, `public=${packages.length}\nversion=${version ?? ''}\npublish=${missing.length > 0}\n`);
82
+ }
83
+ if (packages.length === 0) {
84
+ io.write('zigordev release: no package is public, so nothing is released\n');
85
+ }
86
+ else if (version === undefined) {
87
+ io.write(`zigordev release: ${count(packages.length, 'public package')}, and no version is tagged yet\n`);
88
+ }
89
+ else if (missing.length === 0) {
90
+ io.write(`zigordev release: every public package is on npm at ${version}\n`);
91
+ }
92
+ else {
93
+ for (const pkg of missing) {
94
+ io.write(`missing ${pkg.name}@${version}\n`);
95
+ }
96
+ io.write(`zigordev release: ${count(missing.length, 'package')} to publish at ${version}\n`);
97
+ }
98
+ return 0;
99
+ }
100
+ function packRelease(folder, version, io) {
101
+ const tarballs = pack(io.cwd, folder, version, io.run);
102
+ for (const tarball of tarballs) {
103
+ io.write(`packed ${basename(tarball)}\n`);
104
+ }
105
+ io.write(tarballs.length === 0
106
+ ? `zigordev release: every public package is on npm at ${version}, so nothing was packed\n`
107
+ : `zigordev release: ${count(tarballs.length, 'package')} packed into ${folder}\n`);
108
+ return 0;
109
+ }
110
+ function release(args, io) {
111
+ const [action, folder, version, ...rest] = args;
112
+ try {
113
+ if (action === 'plan' && folder === undefined) {
114
+ return planRelease(io);
115
+ }
116
+ if (action === 'pack' && folder !== undefined && version !== undefined && rest.length === 0) {
117
+ return packRelease(folder, version, io);
118
+ }
119
+ }
120
+ catch (error) {
121
+ io.write(`zigordev release: ${error instanceof Error ? error.message : String(error)}\n`);
122
+ return 1;
123
+ }
124
+ return undefined;
125
+ }
126
+ function publishFirst(args, io) {
127
+ const dryRun = args[0] === '--dry-run';
128
+ const names = dryRun ? args.slice(1) : args;
129
+ if (names.length === 0 || names.some((name) => name.startsWith('-'))) {
130
+ return undefined;
131
+ }
132
+ try {
133
+ firstPublish(io.cwd, names, dryRun, io);
134
+ }
135
+ catch (error) {
136
+ io.write(`zigordev first-publish: ${error instanceof Error ? error.message : String(error)}\n`);
137
+ return 1;
138
+ }
139
+ io.write(dryRun
140
+ ? 'zigordev first-publish: this was a dry run, so nothing was changed\n'
141
+ : `zigordev first-publish: ${count(names.length, 'package')} tied. The pipeline has to publish within 2 days, or the tie expires\n`);
142
+ return 0;
143
+ }
144
+ export function main(argv, io) {
145
+ const [command, ...rest] = argv;
146
+ const rules = rulesWith(io.shared);
147
+ if (command === 'check') {
148
+ return check(rest, rules, io);
149
+ }
150
+ if (command === 'sync' && rest.length === 0) {
151
+ return copy(io);
152
+ }
153
+ if (command === 'release') {
154
+ const code = release(rest, io);
155
+ if (code !== undefined) {
156
+ return code;
157
+ }
158
+ }
159
+ if (command === 'first-publish') {
160
+ const code = publishFirst(rest, io);
161
+ if (code !== undefined) {
162
+ return code;
163
+ }
164
+ }
165
+ io.write(usage(rules));
166
+ return command === undefined || command === 'help' || command === '--help' ? 0 : 2;
167
+ }
168
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,YAAY,EAAiB,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAY,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAYhD,SAAS,KAAK,CAAC,KAAsB;IACnC,OAAO;QACL,2CAA2C;QAC3C,sBAAsB;QACtB,8BAA8B;QAC9B,iDAAiD;QACjD,wDAAwD;QACxD,EAAE;QACF,sGAAsG;QACtG,yEAAyE;QACzE,iGAAiG;QACjG,kGAAkG;QAClG,oGAAoG;QACpG,8FAA8F;QAC9F,EAAE;QACF,QAAQ;QACR,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAClE,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAS,KAAK,CAAC,OAAgB;IAC7B,OAAO,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC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,EAAE,EAAE,CAAC,CAAC;QAC/B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,IAAI,OAAO,KAAK,eAAe,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACpC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACvB,OAAO,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function exists(root: string, revision: string): boolean;
2
+ export declare function selection(root: string, pullRequest: boolean): string[] | undefined;
3
+ //# sourceMappingURL=commits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commits.d.ts","sourceRoot":"","sources":["../src/commits.ts"],"names":[],"mappings":"AAEA,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAE9D;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,MAAM,EAAE,GAAG,SAAS,CAWlF"}
@@ -0,0 +1,15 @@
1
+ import { git } from './files.js';
2
+ export function exists(root, revision) {
3
+ return git(root, ['rev-parse', '--verify', '--quiet', `${revision}^{commit}`]) !== undefined;
4
+ }
5
+ export function selection(root, pullRequest) {
6
+ if (pullRequest) {
7
+ return exists(root, 'HEAD^2') ? ['HEAD^1..HEAD^2'] : undefined;
8
+ }
9
+ if (exists(root, 'origin/main') &&
10
+ git(root, ['rev-list', '--count', 'origin/main..HEAD']) !== '0') {
11
+ return ['origin/main..HEAD'];
12
+ }
13
+ return ['-1', 'HEAD'];
14
+ }
15
+ //# sourceMappingURL=commits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commits.js","sourceRoot":"","sources":["../src/commits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEjC,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,QAAgB;IACnD,OAAO,GAAG,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,QAAQ,WAAW,CAAC,CAAC,KAAK,SAAS,CAAC;AAC/F,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,WAAoB;IAC1D,IAAI,WAAW,EAAE,CAAC;QAChB,OAAO,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,CAAC;IACD,IACE,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC;QAC3B,GAAG,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,SAAS,EAAE,mBAAmB,CAAC,CAAC,KAAK,GAAG,EAC/D,CAAC;QACD,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC/B,CAAC;IACD,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACxB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function git(root: string, args: readonly string[]): string | undefined;
2
+ export declare function repoFiles(root: string): string[];
3
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAMA,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,SAAS,CAU7E;AAkBD,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAKhD"}
package/dist/files.js ADDED
@@ -0,0 +1,38 @@
1
+ import { execFileSync } from 'node:child_process';
2
+ import { existsSync, readdirSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ const skipped = new Set(['.git', 'node_modules', 'dist', 'coverage']);
5
+ export function git(root, args) {
6
+ try {
7
+ return execFileSync('git', args, {
8
+ cwd: root,
9
+ encoding: 'utf8',
10
+ stdio: ['ignore', 'pipe', 'ignore'],
11
+ }).trimEnd();
12
+ }
13
+ catch {
14
+ return undefined;
15
+ }
16
+ }
17
+ function walk(root, folder) {
18
+ const found = [];
19
+ for (const entry of readdirSync(join(root, folder), { withFileTypes: true })) {
20
+ if (skipped.has(entry.name)) {
21
+ continue;
22
+ }
23
+ const path = folder === '' ? entry.name : `${folder}/${entry.name}`;
24
+ if (entry.isDirectory()) {
25
+ found.push(...walk(root, path));
26
+ }
27
+ else if (entry.isFile()) {
28
+ found.push(path);
29
+ }
30
+ }
31
+ return found;
32
+ }
33
+ export function repoFiles(root) {
34
+ const listed = git(root, ['ls-files', '-z', '--cached', '--others', '--exclude-standard']);
35
+ const files = listed === undefined ? walk(root, '') : listed.split('\0').filter((path) => path !== '');
36
+ return files.filter((path) => existsSync(join(root, path))).sort();
37
+ }
38
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAEtE,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,IAAuB;IACvD,IAAI,CAAC;QACH,OAAO,YAAY,CAA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C,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;IAC3F,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AACrE,CAAC"}
@@ -0,0 +1,16 @@
1
+ import type { Run } from './release.ts';
2
+ export type Interact = (command: string, args: readonly string[], cwd: string) => number;
3
+ export interface Tools {
4
+ readonly run: Run;
5
+ readonly interact: Interact;
6
+ readonly atTerminal: boolean;
7
+ readonly write: (text: string) => void;
8
+ }
9
+ export declare const workflow = "ci.yml";
10
+ export declare const environment = "release";
11
+ export declare const firstVersion = "0.0.0";
12
+ export declare function repository(root: string, run: Run): string;
13
+ export declare function manifest(name: string, repo: string): Record<string, unknown>;
14
+ export declare function trustArguments(name: string, repo: string): string[];
15
+ export declare function firstPublish(root: string, names: readonly string[], dryRun: boolean, tools: Tools): void;
16
+ //# sourceMappingURL=first-publish.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"first-publish.d.ts","sourceRoot":"","sources":["../src/first-publish.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAExC,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;AAEzF,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAMD,eAAO,MAAM,QAAQ,WAAW,CAAC;AACjC,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,YAAY,UAAU,CAAC;AAIpC,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,GAAG,MAAM,CAOzD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQ5E;AA0ED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAcnE;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,KAAK,GACX,IAAI,CAkCN"}