@r5n/sisyphus 0.11.0 → 0.12.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 (3) hide show
  1. package/README.md +36 -288
  2. package/dist/cli.js +1 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,313 +1,61 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/r5n-labs/clis/develop/packages/sisyphus/assets/logo.svg" width="128" alt="Sisyphus logo — a boulder resting on a slope">
2
+ <img src="https://raw.githubusercontent.com/r5n-labs/clis/develop/packages/sisyphus/assets/logo.svg" width="128" alt="Sisyphus logo — a figure pushing a boulder uphill">
3
3
  </p>
4
4
 
5
5
  # Sisyphus
6
6
 
7
- Monorepo versioning and release tool. Pending changes are recorded as "stones" (JSON files in `.sisyphus/stones/`, in the spirit of changesets); rolling them bumps versions, writes changelogs, tags, publishes, and pushes in one step.
7
+ **Small change records. One release.**
8
8
 
9
- [![npm](https://img.shields.io/npm/v/@r5n/sisyphus.svg)](https://www.npmjs.com/package/@r5n/sisyphus) [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
10
-
11
- The binary is `sisyphus`, with `sis` as a short alias. Sisyphus runs on [Bun](https://bun.sh) and discovers packages from the `workspaces` globs in your root `package.json`.
12
-
13
- ## Install
9
+ Record pending package changes as **stones**: reviewable JSON files in `.sisyphus/stones/`. Roll them together to bump versions, write changelogs and create a release commit. Enable tags, pushes, npm publication and provider releases when you need them.
14
10
 
15
- ```bash
16
- bun add -g @r5n/sisyphus
17
- ```
11
+ [![npm](https://img.shields.io/npm/v/@r5n/sisyphus.svg)](https://www.npmjs.com/package/@r5n/sisyphus) [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](./LICENSE)
18
12
 
19
- Or add it as a dev dependency and run it with `bunx @r5n/sisyphus`.
13
+ Runs on [Bun](https://bun.sh). The command is `sisyphus`, or `sis` for short. Packages are discovered from your root `package.json` workspaces.
20
14
 
21
15
  ## Quick start
22
16
 
23
- ```bash
24
- sisyphus init
25
- sisyphus version
26
- sisyphus check
27
- sisyphus roll
28
- ```
29
-
30
- `init` writes `.sisyphus/config.json` (flag-driven; an interactive form lives in the `sis -i` menu). `version` with no arguments prompts you to pick packages per bump type and enter a message, then writes a stone. `check` shows workspace packages and what each pending stone will release. `roll` merges all pending stones, applies the version bumps, and deletes the stones.
31
-
32
- By default `roll` only updates files and creates the release commit. Publishing, tagging, pushing, and provider releases are opt-in via flags or the `release` section of the config.
33
-
34
- ## Commands
35
-
36
- ### `sisyphus version`
37
-
38
- Create a stone. Interactive when run without positionals; non-interactive with a message and package lists:
39
-
40
- ```bash
41
- # Interactive
42
- sisyphus version
43
-
44
- # Apply one bump to every filtered package without prompts
45
- sisyphus version --bump minor --all --filter @org/core --message "feat: update core" --yes
46
-
47
- # Assign packages to bump groups without prompts
48
- sisyphus version --minor @org/core,@org/api --patch @org/utils --message "feat: update workspace" --yes
49
-
50
- # Generate stones from conventional commits
51
- sisyphus version --fromCommits --filter @org/core --dryRun
52
-
53
- # Create a tagged prerelease stone
54
- sisyphus version --bump patch --all --filter @org/core --message "fix: beta repair" --tag beta --yes
55
- ```
56
-
57
- **Options:**
58
- - `-a, --all` — Select every filtered package (requires `--bump`)
59
- - `-b, --bump` — Apply `major`, `minor`, or `patch` to every selected package
60
- - `-d, --dryRun` — Preview without writing stones
61
- - `-f, --filter` — Constrain interactive choices, explicit package lists, or commit analysis by package name
62
- - `--fromCommits` — Generate stones from conventional commits instead of manual selections
63
- - `-M, --major` — Comma-separated packages receiving a major bump
64
- - `--message` — Stone message; required for non-interactive manual selection
65
- - `-m, --minor` — Comma-separated packages receiving a minor bump
66
- - `-p, --patch` — Comma-separated packages receiving a patch bump
67
- - `-t, --tag` — Prerelease tag (alpha, beta, rc, etc.)
68
- - `-y, --yes` — Skip confirmation
69
-
70
- Packages that depend on the bumped ones are picked up automatically and get a dependency (patch-level) bump.
71
-
72
- The message and optional description can also be supplied as positional arguments. Do not combine a positional message
73
- with `--message`.
74
-
75
- ### `sisyphus check`
76
-
77
- Show the root package, workspace packages, and pending stones with the versions they will produce. `--json` for machine-readable output (used in CI), `-c, --config` to include the resolved config.
78
-
79
- ### `sisyphus stone`
80
-
81
- Manage pending stones: `list` (`-j`, `-v`), `show <id>` (`-j`), `edit <id> -m "new message"`, `merge <id...> -m "message"` (`-d` deletes the originals; conflicting bumps resolve to the highest), `delete <id>`. Subcommands prompt for a stone when no id is given.
82
-
83
- ### `sisyphus roll`
84
-
85
- Execute a release from all pending stones: bump versions, generate changelogs, delete the stones, commit, then optionally tag, push, publish, and create provider releases. Failures before an external operation roll back the commit, tags, file changes, and stones. Once an external operation starts, local state and a durable release ledger are preserved so the release can be reconciled and resumed.
86
-
87
- ```bash
88
- sisyphus roll --dryRun
89
- sisyphus roll -n -t -p -y
90
- sisyphus roll --resume
91
- ```
92
-
93
- - `-c, --changelog` — generate changelogs (default from `changelog.generate`)
94
- - `-n, --npm` — publish to npm (default from `release.npm`)
95
- - `-t, --tags` — create `name@version` git tags (default from `release.tags`)
96
- - `-p, --push` — push commits and tags (default from `release.push`)
97
- - `-r, --createRelease` — create a release on the git provider (default from `release.createRelease`)
98
- - `--noCommit` — skip the release commit (also disables tags, push, and provider release)
99
- - `--preview` — write changelogs, list their paths, then offer to revert; `--yes`, `--json` and non-interactive runs automatically restore the original files
100
- - `--publishOnly` — publish from `currentRelease` recorded by `actions release-pr`, without touching files
101
- - `-j, --json` — print a machine-readable release report on stdout instead of the interactive output; the report carries a required `warnings` string array listing ignore exclusions, cycle-order caveats, and channel problems
102
- - `--resume` — reconcile and continue the active incomplete release
103
- - `--abort` — abandon the incomplete release if nothing external has started; releases with external progress must use `--resume`
104
- - `-d, --dryRun`, `-y, --yes`
105
-
106
- Provider releases require tags to be pushed to the same repository first, so normal releases must enable `--tags --push --createRelease`; publish-only releases require `--tags --createRelease` and push those exact tags before creating releases.
107
-
108
- Publishing builds each public package, rewrites its `package.json` to a clean publish manifest, and packs an immutable tarball before any package is uploaded. `workspace:` specifiers are resolved against actual workspace versions (`workspace:*` pins the exact version and `workspace:^`/`workspace:~` become ranges), `catalog:` specifiers are resolved from the root `catalog`/`catalogs`, and `devDependencies` are stripped. The source manifest is restored after packing, even if preparation fails. Private packages (`"private": true`) are skipped.
109
-
110
- Publication defaults to public access and honours `publishConfig.access: "restricted"` from the immutable package manifest. Invalid access values fail before publication.
111
-
112
- For releases with external operations, Sisyphus stores the plan, immutable artifacts, exact Git refs, and per-operation progress below Git's worktree-specific administrative directory. `--resume` verifies an ambiguous npm upload by SHA-512 integrity, verifies an ambiguous push from exact remote refs, and verifies provider releases by tag, title, and notes. If the external system cannot confirm the expected state, resume stops rather than repeating the operation.
113
-
114
- Npm publication requires a release commit, so it cannot be combined with `--noCommit`. Publish-only releases verify the source hash recorded by `actions release-pr`, the exact package versions, and the complete archived-stone set before creating tags or artifacts.
115
-
116
- ### `sisyphus pr`
117
-
118
- Create a stone from a pull or merge request (GitHub via authenticated `gh`; GitLab via `GITLAB_TOKEN` or `glab`). Reads title, body, labels, commits, and changed files; the bump type comes from labels via `pr.labelMapping`, the title, `-b/--bump`, or a prompt. Explicit `--bump` accepts `major`, `minor`, or `patch`. PRs matching `pr.skip` (labels, authors, title patterns) are ignored.
119
-
120
- Provider file analysis preserves both sides of renames. It stops before writing a stone when it cannot establish a complete file list, including GitHub's [3,000-file response limit](https://docs.github.com/en/rest/pulls/pulls#list-pull-requests-files) and [GitLab overflow responses](https://docs.gitlab.com/api/merge_requests/#retrieve-merge-request-changes).
121
-
122
- ```bash
123
- sisyphus pr -u https://github.com/org/repo/pull/123 -y
124
- ```
125
-
126
- ### `sisyphus migrate`
127
-
128
- Convert an existing `.changeset/` directory to stones and map supported changeset config (`ignore`, `commit`, `access`, `changelog`) onto the Sisyphus config. `-d, --dryRun` previews without writing; non-interactive migration requires `-y, --yes`.
129
-
130
- ### `sisyphus actions`
131
-
132
- CI integration. `actions init` detects your provider (GitHub Actions or GitLab CI) and installs workflow templates: a create-stone workflow that turns merged PRs into stones and maintains a release PR, and a release workflow that publishes when the release PR merges (`--all`, `--createStone`, `--release`, `-d`, `-y`). `actions release-pr` creates or updates the `sisyphus/release` branch and PR from pending stones, archives the stones to `.sisyphus/released/<timestamp>/`, and records `currentRelease` in the config for a later `roll --publishOnly`.
133
-
134
- Run `actions release-pr` from a clean working tree; commit or stash local changes first. It restores the original branch or detached checkout after preparing or previewing the release PR. `--dryRun` previews the fetched base without creating or resetting the local release branch.
135
-
136
- The generated GitLab workflows require `GITLAB_TOKEN` with API access and repository write permission; `SIS_PUSH_TOKEN` can supply a separate repository write credential. They configure a credential-free origin URL and a credential helper for both stone and release-branch pushes. Automatic MR detection expects GitLab's standard merge commit title and `See merge request <project>!<number>` footer. Use merge commits for release merge requests; squash, rebase and custom commit messages require adapting the rules or running the release job manually.
137
-
138
- ### `sisyphus init`
139
-
140
- Create or edit `.sisyphus/config.json`. Flag-driven when invoked directly (the interactive form lives in the `sis -i` menu); every form field has a matching flag (`--single`, `--tag`, `--npm`, `--tags`, `--push`, `--createRelease`, `--changelog`, `--rootChangelog`, `--commitAuthor`, `--commitEmail`, `--commitMessage`). `--default` resets to defaults, `--force` overwrites non-interactively. Also records the current HEAD as `lastStone`, the baseline for `version --fromCommits`.
141
-
142
- ## Configuration
143
-
144
- `.sisyphus/config.json`, created by `init` (trimmed excerpt — `init` writes the full default set, including an extended `pr.labelMapping` and commit-skip patterns):
145
-
146
- ```json
147
- {
148
- "$schema": "https://raw.githubusercontent.com/r5n-labs/clis/refs/heads/develop/packages/sisyphus/schema.json",
149
- "single": false,
150
- "tag": "latest",
151
- "commit": {
152
- "author": "r5n-bot",
153
- "email": "r5n-bot@users.noreply.github.com",
154
- "message": "chore(release): {message}"
155
- },
156
- "changelog": {
157
- "generate": true,
158
- "root": false,
159
- "append": true,
160
- "filename": "CHANGELOG.md",
161
- "packageHeader": "{emoji} {version} ({date})",
162
- "rootHeader": "{date} - {packages}"
163
- },
164
- "release": {
165
- "npm": false,
166
- "tags": false,
167
- "push": false,
168
- "createRelease": false
169
- },
170
- "commits": {
171
- "skip": {
172
- "authors": ["r5n-bot[bot]"],
173
- "messagePatterns": ["^chore\\(release\\):"]
174
- }
175
- },
176
- "pr": {
177
- "labelMapping": { "breaking": "major", "feature": "minor", "fix": "patch" },
178
- "skip": {
179
- "labels": ["sisyphus-release", "skip-stone"],
180
- "authors": ["r5n-bot[bot]"],
181
- "titlePatterns": ["^chore\\(release\\):"]
182
- }
183
- }
184
- }
185
- ```
186
-
187
- - `single` — version the root package instead of workspace packages
188
- - `tag` — npm dist-tag used when publishing
189
- - `commit` — release commit author/email and message template; `{message}` and `{packages}` are substituted; a valid `email` is required whenever `author` is set
190
- - `changelog` — `sections` maps conventional commit types (`feat`, `fix`, `breaking`, ...) to headings; `root` adds a combined root changelog; `packageHeader`/`rootHeader` support `{emoji}`, `{version}`, `{date}`, `{packages}`
191
- - `commits.skip` / `pr.skip` — filters for `version --fromCommits` and `pr`
192
- - `release` — defaults for the corresponding `roll` flags, plus `release.build` (see below)
193
- - `dependents` — which manifest sections pull a dependent into a release (`kinds`) and whether dependents are always released or only when their published range no longer admits the new version (`updateInternal`)
194
- - `ignore` — package names or globs that are never released; they are skipped when selecting packages, never pulled in as dependents, and never traversed through
195
- - `sisyphusDir` / `stonesPath` — relocate the config directory or stone storage
196
- - `lastStone`, `stones`, `currentRelease` — managed by the CLI; don't edit by hand
197
-
198
- ## Stones
199
-
200
- Each stone is a JSON file at `.sisyphus/stones/<id>.json`, safe to commit and review:
201
-
202
- ```json
203
- {
204
- "id": "0001-741d2bed",
205
- "message": "feat: add auth",
206
- "description": "Optional longer notes",
207
- "minor": ["@org/auth"],
208
- "patch": ["@org/api"],
209
- "dependency": ["@org/app"]
210
- }
211
- ```
212
-
213
- Stones may also carry a `tag` (prerelease) and the `commits` they were generated from. `roll` merges every pending stone, keeping the highest bump per package. Every pending stone must agree on the prerelease tag, and a package cannot be both a snapshot and a normal release in one roll.
214
-
215
- ## Dependents
216
-
217
- Selecting a package pulls in everything that depends on it, transitively, as a `dependency` bump. Propagation follows only `workspace:` protocol specifiers — a dependency declared with a plain version range is never treated as an internal edge, even when its name matches a workspace package. Edges come from the manifest sections listed in `dependents.kinds`; the default includes `devDependencies` because bundled packages inline their workspace dependencies at build time. Drop it when only the published manifest matters:
218
-
219
- ```json
220
- {
221
- "dependents": {
222
- "kinds": ["dependencies", "optionalDependencies", "peerDependencies"],
223
- "updateInternal": "always"
224
- }
225
- }
226
- ```
227
-
228
- `updateInternal: "outOfRange"` releases a dependent only when its published range would no longer admit the new version — `workspace:*` is always invalidated, `workspace:^` survives a minor bump above 0.x, `workspace:~` survives a patch, and a literal `workspace:<range>` is never rewritten so it never triggers a release. Releases are ordered so a dependency is tagged and published before the dependent that pins it. Publication order follows runtime, optional and peer dependencies; development dependencies are removed from the published manifest and do not constrain that order.
229
-
230
- When an untagged release graduates a prerelease package, selected prerelease dependents connected through the sections in `dependents.kinds` graduate with it. Excluded sections cannot cause a dependent to leave its prerelease channel.
231
-
232
- ## Prereleases
233
-
234
- Pass `--tag` to `version` to open a prerelease channel. The base version is bumped first, so the prerelease always sorts above the last stable release:
235
-
236
- | current | stone | result |
237
- | --- | --- | --- |
238
- | `1.0.0` | minor + `--tag beta` | `1.1.0-beta.0` |
239
- | `1.1.0-beta.0` | patch + `--tag beta` | `1.1.0-beta.1` |
240
- | `1.1.0-beta.1` | major + `--tag beta` | `2.0.0-beta.0` |
241
- | `1.1.0-beta.1` | patch, no tag | `1.1.0` |
242
-
243
- Omitting `--tag` leaves the channel and lands on the accumulated stable target. The npm dist-tag follows the channel, so prereleases never publish as `latest`. A single roll cannot publish stable and prerelease packages to npm together — the dist-tag applies to the whole release — so such a mix fails closed before anything is published. In practice, graduate the prerelease packages first or roll the two channels separately.
244
-
245
- ## Build
246
-
247
- `roll` builds each package before packing it. By default that is `bun run build` in the package directory:
248
-
249
- ```json
250
- {
251
- "release": {
252
- "build": {
253
- "command": ["bun", "run", "build"],
254
- "root": [["bun", "run", "build:dts"]],
255
- "outputs": ["packages/*/dist/**"]
256
- }
257
- }
258
- }
17
+ ```sh
18
+ bun add -g @r5n/sisyphus
19
+ sis init
20
+ sis version
21
+ sis check
22
+ sis roll
259
23
  ```
260
24
 
261
- `root` runs once at the repository root before the first package is packed — for declarations or bundles generated centrally. `command: []` disables the per-package build. `outputs` declares the gitignored paths the build writes: they are removed before the build and exempted from the guards that otherwise reject untracked and ignored files, while everything else stays rejected. A declared output that Git tracks is refused before any build runs. Commands are executed directly, never through a shell.
25
+ `init` creates the configuration. `version` prompts for package bumps and a message, then saves a stone. `check` previews the release. `roll` applies the pending stones and creates a release commit.
262
26
 
263
- ## GitHub Actions
27
+ **Publishing is opt-in.** By default, `roll` updates local files and creates the commit. Review the [release options](https://github.com/r5n-labs/clis/blob/develop/packages/sisyphus/docs/commands.md#sisyphus-roll) before enabling external operations.
264
28
 
265
- A push-based release job, modeled on this repo's own workflow: roll whenever pending stones land on the main branch. Uses npm trusted publishing (OIDC), which needs `id-token: write` and npm >= 11.5.1, plus each package configured for trusted publishing on npmjs.com. If you don't use OIDC, `roll` publishes with plain `npm publish`, so a granular token in `~/.npmrc` (via `NPM_TOKEN`) works too.
29
+ ## Everyday commands
266
30
 
267
- ```yaml
268
- name: Release
31
+ | Task | Command |
32
+ | --- | --- |
33
+ | Create a stone interactively | `sis version` |
34
+ | Preview stones from conventional commits | `sis version --fromCommits --dryRun` |
35
+ | Inspect pending changes | `sis check` |
36
+ | Edit or combine stones | `sis stone` |
37
+ | Preview a release | `sis roll --dryRun` |
38
+ | Resume an interrupted release | `sis roll --resume` |
39
+ | Create a stone from a pull request | `sis pr -u <url>` |
40
+ | Install CI workflows | `sis actions init` |
269
41
 
270
- on:
271
- push:
272
- branches: [main]
42
+ Use `sis -i` for the interactive menu and `sis <command> --help` for options. Sisyphus follows workspace dependencies, supports prerelease channels and keeps a durable ledger so interrupted external operations can be reconciled before resuming.
273
43
 
274
- permissions:
275
- contents: write
276
- id-token: write
44
+ ## Guides
277
45
 
278
- jobs:
279
- release:
280
- runs-on: ubuntu-latest
281
- if: "!startsWith(github.event.head_commit.message, 'chore(release):')"
282
- steps:
283
- - uses: actions/checkout@v7
284
- with:
285
- fetch-depth: 0
286
- - uses: oven-sh/setup-bun@v2
287
- - run: bun install
288
- - run: npm install -g npm@11
289
- - name: Check for pending stones
290
- run: |
291
- COUNT=$(bunx @r5n/sisyphus check --json | jq '.stones | length')
292
- echo "STONES_COUNT=$COUNT" >> "$GITHUB_ENV"
293
- - name: Roll release
294
- if: env.STONES_COUNT != '0'
295
- run: |
296
- git config user.name "github-actions[bot]"
297
- git config user.email "github-actions[bot]@users.noreply.github.com"
298
- bunx @r5n/sisyphus roll --yes
299
- env:
300
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
301
- ```
46
+ | Guide | Covers |
47
+ | --- | --- |
48
+ | [Command reference](https://github.com/r5n-labs/clis/blob/develop/packages/sisyphus/docs/commands.md) | Versioning, releases, stones, pull requests, migration and CI commands |
49
+ | [Configuration and release model](https://github.com/r5n-labs/clis/blob/develop/packages/sisyphus/docs/configuration.md) | Config fields, stone format, dependency propagation, prereleases and builds |
50
+ | [GitHub Actions](https://github.com/r5n-labs/clis/blob/develop/packages/sisyphus/docs/github-actions.md) | Push-based releases, trusted publishing and generated workflows |
302
51
 
303
- On self-hosted runners, set `NPM_CONFIG_PROVENANCE: "false"` on the roll step; provenance generation only works on GitHub-hosted runners. For the PR-driven flow (stone per merged PR, rolling release PR, publish on merge), run `sisyphus actions init` and commit the generated workflows instead.
52
+ Configuration has an [editor schema](https://github.com/r5n-labs/clis/blob/develop/packages/sisyphus/schema.json).
304
53
 
305
54
  ## Requirements
306
55
 
307
- - Bun (the CLI is a Bun executable)
308
- - git, with a `workspaces` field in the root `package.json` (unless `single`)
309
- - `gh` CLI, authenticated, for GitHub PR and release operations (`pr`, `actions release-pr`, `roll --createRelease`); GitLab is supported via `GITLAB_TOKEN` or `glab`
56
+ - Bun and Git; a root `workspaces` field unless using `single` mode.
57
+ - Authenticated `gh` for GitHub pull requests and releases. GitLab operations use `GITLAB_TOKEN` or `glab`.
310
58
 
311
- ## License
59
+ ## Licence
312
60
 
313
- Apache 2.0 — see [LICENSE](./LICENSE)
61
+ [Apache 2.0](LICENSE).
package/dist/cli.js CHANGED
@@ -91,7 +91,7 @@ Run "${this.commandPath} --help" for usage.`),process.exit(1);let o=this.command
91
91
  `))});return`${h?"[":"{"}${S}${B.join(L)}${k}${h?"]":"}"}`}function c(l,p,g){if(!g)return Xs(l,o);let h=e.lastIndexOf(`
92
92
  `,p-1)+1,f=e.slice(h,p).match(/^[\t ]*/)?.[0]??"";return JSON.stringify(l,null,n).replaceAll(`
93
93
  `,i+f)}return e.slice(0,s.start)+a(s,r)+e.slice(s.end)}function Xs(e,t){if(Array.isArray(e))return`[${e.map((n)=>Xs(n,t)).join(`,${t}`)}]`;if(e===null||typeof e!=="object")return JSON.stringify(e);let r=Object.entries(e);if(r.length===0)return"{}";let s=r.map(([n,i])=>`${JSON.stringify(n)}:${t}${Xs(i,t)}`);return`{${t}${s.join(`,${t}`)}${t}}`}function fu(e){let t=e.matchAll(/"(?:[^"\\]|\\.)*"|[^\s{}[\],:]+|[{}[\],:]/g),r=t.next().value;function s(){if(!r)throw Error("Unexpected end of JSON");let i=r;return r=t.next().value,i}function n(){let i=s(),o=[],a=i[0]==="{";if(!a&&i[0]!=="[")return{end:i.index+i[0].length,entries:o,start:i.index,value:JSON.parse(i[0])};let c=a?"}":"]";while(r&&r[0]!==c){let p=r.index,g=a?JSON.parse(s()[0]):String(o.length);if(a)s();if(o.push({key:g,node:n(),start:p}),r?.[0]===",")s()}let l=s().index+1;return{end:l,entries:o,start:i.index,value:JSON.parse(e.slice(i.index,l))}}return n()}var yu=2,wu=ht(Object);class Zs{config;configPath;defaultConfig;loadError;constructor(e,t){this.configPath=Co.resolve(e),this.defaultConfig=t,this.config=this.loadConfig()}get path(){return this.configPath}get(e){return this.config[e]}set(e,t){this.config={...this.config,[e]:t},this.save()}delete(e){delete this.config[e],this.save()}exists(){return me.existsSync(this.configPath)}getAll(){return structuredClone(this.config)}save(e){if(this.loadError)throw Error(`Cannot overwrite unreadable config at ${this.configPath}; repair the file and try again`,{cause:this.loadError});if(e)this.config={...e};this.ensureDirectoryExists();let t=this.exists()?me.realpathSync(this.configPath):this.configPath,r=`${t}.${crypto.randomUUID()}.tmp`;try{let s=this.exists()?me.statSync(this.configPath).mode:void 0,n=this.exists()?Vt(me.readFileSync(this.configPath,"utf-8"),this.config):`${JSON.stringify(this.config,null,yu)}
94
- `;if(me.writeFileSync(r,n,{flag:"wx",mode:s}),s!==void 0)me.chmodSync(r,s);me.renameSync(r,t)}catch(s){throw Error(`Failed to save config to ${this.configPath}`,{cause:s})}finally{me.rmSync(r,{force:!0})}}ensureDirectoryExists(){let e=Co.dirname(this.configPath);if(!me.existsSync(e))try{me.mkdirSync(e,{recursive:!0})}catch(t){throw Error(`Failed to create config directory at ${e}`,{cause:t})}}loadConfig(){if(!me.existsSync(this.configPath))return structuredClone(this.defaultConfig);try{let e=me.readFileSync(this.configPath,"utf-8"),t=JSON.parse(e);if(Array.isArray(t))throw Error("Config must be an object");let r=wu(t);return dt(structuredClone(this.defaultConfig),r)}catch(e){return this.loadError=e,console.warn(`Config file corrupted at ${this.configPath}. Using defaults.`),structuredClone(this.defaultConfig)}}}var ko="0.11.0";class j extends Ft{}import{existsSync as Nu}from"fs";import{mkdir as ju,writeFile as Fu}from"fs/promises";import{dirname as Bu}from"path";class Ue{owner;repo;constructor(e){this.owner=e.owner,this.repo=e.repo}}class Or extends Ue{name="bitbucket";notImplemented(){throw new u("Bitbucket is not supported yet","Bitbucket support is coming soon")}async ensureAvailable(){this.notImplemented()}async getDefaultBranch(){this.notImplemented()}async findPr(e){this.notImplemented()}async createPr(e){this.notImplemented()}async updatePr(e,t){this.notImplemented()}async getPr(e){this.notImplemented()}async getPrFromCurrentBranch(){this.notImplemented()}async getPrCommits(e){this.notImplemented()}async getPrFiles(e){this.notImplemented()}async ensureLabelExists(e,t){this.notImplemented()}async getRelease(e){this.notImplemented()}async createRelease(e){this.notImplemented()}async deleteRelease(e){this.notImplemented()}}var F="sis",Qs="\uD83E\uDEA8",Ve="other",ft={build:23,chore:25,ci:24,docs:20,feat:10,"feat!":0,fix:11,"fix!":1,perf:12,refactor:13,style:21,test:22,["other"]:100},yt=50,wt=".sisyphus",xo="stones",To="released",_r=7,Eo="unknown",Gt="unknown",Io="0.0.0",he="latest",en=["bun","run","build"],Ee="main",Ao=4,Oo=8,Mr="config.json";var Ge={$schema:"https://raw.githubusercontent.com/r5n-labs/clis/refs/heads/develop/packages/sisyphus/schema.json",changelog:{append:!0,filename:"CHANGELOG.md",generate:!0,packageHeader:"{emoji} {version} ({date})",root:!1,rootHeader:"{date} - {packages}",sections:{breaking:"Breaking changes",build:"Build",chore:"Chores",ci:"CI",dependencies:"Dependency updates",docs:"Documentation",feat:"Features",fix:"Bug fixes",other:"Other changes",perf:"Performance",refactor:"Refactoring",style:"Styling",test:"Tests"}},commit:{author:"r5n-bot",email:"r5n-bot@users.noreply.github.com",message:"chore(release): {message}"},commits:{skip:{authors:["r5n-bot[bot]"],messagePatterns:["^chore\\(release\\):","^chore: add stone"]}},dependents:{kinds:["dependencies","devDependencies","optionalDependencies","peerDependencies"],updateInternal:"always"},ignore:[],lastStone:{commit:"",date:""},plugins:[],pr:{labelMapping:{breaking:"major","breaking-change":"major",bug:"patch",chore:"patch",docs:"patch",enhancement:"minor",feature:"minor",fix:"patch"},skip:{authors:["r5n-bot[bot]"],labels:["sisyphus-release","skip-stone"],titlePatterns:["^chore\\(release\\):"]}},release:{build:{command:[...en],outputs:[],root:[]},createRelease:!1,npm:!1,push:!1,tags:!1},scripts:{post:{},pre:{}},single:!1,sisyphusDir:".sisyphus",stones:[],tag:"latest"};var vu=200,$u=404,Pu=10,Ru=3000,_o=ve().map((e)=>e.length>0?e:ge()),Su=Qe(Qe(Ut({filename:_o,previous_filename:_o.or(Bt()),status:ve()}).map((e)=>e.status==="renamed"&&e.previous_filename===void 0?ge():e)));function Cu(e){if(typeof e!=="object"||e===null)return!1;let t=e;return typeof t.tag_name==="string"&&typeof t.draft==="boolean"&&(typeof t.name==="string"||t.name===null)&&(typeof t.body==="string"||t.body===null)}class Lr extends Ue{name="github";get apiPath(){return`repos/${encodeURIComponent(this.owner)}/${encodeURIComponent(this.repo)}`}async ensureAvailable(){try{await Bun.$`which gh`.quiet()}catch{throw new u("GitHub CLI (gh) is not installed","Install from https://cli.github.com and run: gh auth login")}try{await Bun.$`gh auth status`.quiet()}catch{throw new u("GitHub CLI (gh) is not authenticated","Run: gh auth login")}}async getDefaultBranch(){try{return(await Bun.$`gh repo view --json defaultBranchRef --jq .defaultBranchRef.name`.quiet()).stdout.toString().trim()||Ee}catch{return Ee}}async findPr(e){try{let t=[];if(e.head)t.push("--head",e.head);if(e.label)t.push("--label",e.label);let r=await Bun.$`gh pr list --json number,url,title,body,labels,author,headRefName,baseRefName,mergeCommit,state --limit 1 ${t}`.quiet(),s=JSON.parse(r.stdout.toString());if(!s[0])return null;return this.mapPrResponse(s[0])}catch{return null}}async createPr(e){let t=await Bun.$`gh api ${this.apiPath}/pulls --method POST -f head=${e.head} -f base=${e.base} -f title=${e.title} -f body=${e.body}`,s=JSON.parse(t.stdout.toString()).number;if(e.labels&&e.labels.length>0){let n=e.labels.flatMap((i)=>["-f",`labels[]=${i}`]);await Bun.$`gh api ${this.apiPath}/issues/${s}/labels --method POST ${n}`}return this.getPr(s)}async updatePr(e,t){let r=[];if(t.title)r.push("--title",t.title);if(t.body)r.push("--body",t.body);await Bun.$`gh pr edit ${e} ${r}`}async getPr(e){try{let t=await Bun.$`gh api ${this.apiPath}/pulls/${e}`.quiet(),r=JSON.parse(t.stdout.toString());return this.mapRestApiResponse(r)}catch{throw new u(`Failed to fetch PR #${e}`,"Make sure the PR exists and you have access")}}async getPrFromCurrentBranch(){try{let e=await Bun.$`gh pr view --json number,title,body,labels,author,headRefName,baseRefName,url,mergeCommit,state`.quiet(),t=JSON.parse(e.stdout.toString());return this.mapPrResponse(t)}catch{throw new u("No PR found for current branch","Make sure you have an open PR or provide a URL with --url")}}async getPrCommits(e){try{return(await Bun.$`gh api ${this.apiPath}/pulls/${e}/commits --jq '.[].sha'`.quiet()).stdout.toString().trim().split(`
94
+ `;if(me.writeFileSync(r,n,{flag:"wx",mode:s}),s!==void 0)me.chmodSync(r,s);me.renameSync(r,t)}catch(s){throw Error(`Failed to save config to ${this.configPath}`,{cause:s})}finally{me.rmSync(r,{force:!0})}}ensureDirectoryExists(){let e=Co.dirname(this.configPath);if(!me.existsSync(e))try{me.mkdirSync(e,{recursive:!0})}catch(t){throw Error(`Failed to create config directory at ${e}`,{cause:t})}}loadConfig(){if(!me.existsSync(this.configPath))return structuredClone(this.defaultConfig);try{let e=me.readFileSync(this.configPath,"utf-8"),t=JSON.parse(e);if(Array.isArray(t))throw Error("Config must be an object");let r=wu(t);return dt(structuredClone(this.defaultConfig),r)}catch(e){return this.loadError=e,console.warn(`Config file corrupted at ${this.configPath}. Using defaults.`),structuredClone(this.defaultConfig)}}}var ko="0.12.0";class j extends Ft{}import{existsSync as Nu}from"fs";import{mkdir as ju,writeFile as Fu}from"fs/promises";import{dirname as Bu}from"path";class Ue{owner;repo;constructor(e){this.owner=e.owner,this.repo=e.repo}}class Or extends Ue{name="bitbucket";notImplemented(){throw new u("Bitbucket is not supported yet","Bitbucket support is coming soon")}async ensureAvailable(){this.notImplemented()}async getDefaultBranch(){this.notImplemented()}async findPr(e){this.notImplemented()}async createPr(e){this.notImplemented()}async updatePr(e,t){this.notImplemented()}async getPr(e){this.notImplemented()}async getPrFromCurrentBranch(){this.notImplemented()}async getPrCommits(e){this.notImplemented()}async getPrFiles(e){this.notImplemented()}async ensureLabelExists(e,t){this.notImplemented()}async getRelease(e){this.notImplemented()}async createRelease(e){this.notImplemented()}async deleteRelease(e){this.notImplemented()}}var F="sis",Qs="\uD83E\uDEA8",Ve="other",ft={build:23,chore:25,ci:24,docs:20,feat:10,"feat!":0,fix:11,"fix!":1,perf:12,refactor:13,style:21,test:22,["other"]:100},yt=50,wt=".sisyphus",xo="stones",To="released",_r=7,Eo="unknown",Gt="unknown",Io="0.0.0",he="latest",en=["bun","run","build"],Ee="main",Ao=4,Oo=8,Mr="config.json";var Ge={$schema:"https://raw.githubusercontent.com/r5n-labs/clis/refs/heads/develop/packages/sisyphus/schema.json",changelog:{append:!0,filename:"CHANGELOG.md",generate:!0,packageHeader:"{emoji} {version} ({date})",root:!1,rootHeader:"{date} - {packages}",sections:{breaking:"Breaking changes",build:"Build",chore:"Chores",ci:"CI",dependencies:"Dependency updates",docs:"Documentation",feat:"Features",fix:"Bug fixes",other:"Other changes",perf:"Performance",refactor:"Refactoring",style:"Styling",test:"Tests"}},commit:{author:"r5n-bot",email:"r5n-bot@users.noreply.github.com",message:"chore(release): {message}"},commits:{skip:{authors:["r5n-bot[bot]"],messagePatterns:["^chore\\(release\\):","^chore: add stone"]}},dependents:{kinds:["dependencies","devDependencies","optionalDependencies","peerDependencies"],updateInternal:"always"},ignore:[],lastStone:{commit:"",date:""},plugins:[],pr:{labelMapping:{breaking:"major","breaking-change":"major",bug:"patch",chore:"patch",docs:"patch",enhancement:"minor",feature:"minor",fix:"patch"},skip:{authors:["r5n-bot[bot]"],labels:["sisyphus-release","skip-stone"],titlePatterns:["^chore\\(release\\):"]}},release:{build:{command:[...en],outputs:[],root:[]},createRelease:!1,npm:!1,push:!1,tags:!1},scripts:{post:{},pre:{}},single:!1,sisyphusDir:".sisyphus",stones:[],tag:"latest"};var vu=200,$u=404,Pu=10,Ru=3000,_o=ve().map((e)=>e.length>0?e:ge()),Su=Qe(Qe(Ut({filename:_o,previous_filename:_o.or(Bt()),status:ve()}).map((e)=>e.status==="renamed"&&e.previous_filename===void 0?ge():e)));function Cu(e){if(typeof e!=="object"||e===null)return!1;let t=e;return typeof t.tag_name==="string"&&typeof t.draft==="boolean"&&(typeof t.name==="string"||t.name===null)&&(typeof t.body==="string"||t.body===null)}class Lr extends Ue{name="github";get apiPath(){return`repos/${encodeURIComponent(this.owner)}/${encodeURIComponent(this.repo)}`}async ensureAvailable(){try{await Bun.$`which gh`.quiet()}catch{throw new u("GitHub CLI (gh) is not installed","Install from https://cli.github.com and run: gh auth login")}try{await Bun.$`gh auth status`.quiet()}catch{throw new u("GitHub CLI (gh) is not authenticated","Run: gh auth login")}}async getDefaultBranch(){try{return(await Bun.$`gh repo view --json defaultBranchRef --jq .defaultBranchRef.name`.quiet()).stdout.toString().trim()||Ee}catch{return Ee}}async findPr(e){try{let t=[];if(e.head)t.push("--head",e.head);if(e.label)t.push("--label",e.label);let r=await Bun.$`gh pr list --json number,url,title,body,labels,author,headRefName,baseRefName,mergeCommit,state --limit 1 ${t}`.quiet(),s=JSON.parse(r.stdout.toString());if(!s[0])return null;return this.mapPrResponse(s[0])}catch{return null}}async createPr(e){let t=await Bun.$`gh api ${this.apiPath}/pulls --method POST -f head=${e.head} -f base=${e.base} -f title=${e.title} -f body=${e.body}`,s=JSON.parse(t.stdout.toString()).number;if(e.labels&&e.labels.length>0){let n=e.labels.flatMap((i)=>["-f",`labels[]=${i}`]);await Bun.$`gh api ${this.apiPath}/issues/${s}/labels --method POST ${n}`}return this.getPr(s)}async updatePr(e,t){let r=[];if(t.title)r.push("--title",t.title);if(t.body)r.push("--body",t.body);await Bun.$`gh pr edit ${e} ${r}`}async getPr(e){try{let t=await Bun.$`gh api ${this.apiPath}/pulls/${e}`.quiet(),r=JSON.parse(t.stdout.toString());return this.mapRestApiResponse(r)}catch{throw new u(`Failed to fetch PR #${e}`,"Make sure the PR exists and you have access")}}async getPrFromCurrentBranch(){try{let e=await Bun.$`gh pr view --json number,title,body,labels,author,headRefName,baseRefName,url,mergeCommit,state`.quiet(),t=JSON.parse(e.stdout.toString());return this.mapPrResponse(t)}catch{throw new u("No PR found for current branch","Make sure you have an open PR or provide a URL with --url")}}async getPrCommits(e){try{return(await Bun.$`gh api ${this.apiPath}/pulls/${e}/commits --jq '.[].sha'`.quiet()).stdout.toString().trim().split(`
95
95
  `).filter(Boolean)}catch{return[]}}async getPrFiles(e){try{let t=await Bun.$`gh api ${this.apiPath}/pulls/${e}/files --paginate --slurp`.quiet(),r=Su(JSON.parse(t.stdout.toString())).flat();if(r.length>=Ru)throw new u(`PR #${e} reaches the GitHub file limit`,"The complete changed file list cannot be established; create the stone from a complete local checkout");return[...new Set(r.flatMap((s)=>s.status==="renamed"&&s.previous_filename!==void 0?[s.previous_filename,s.filename]:[s.filename]))]}catch(t){if(t instanceof u)throw t;throw new u(`Failed to fetch PR #${e} files`,"Check GitHub access and retry the analysis")}}async ensureLabelExists(e,t){try{let r=t?.description??"",s=t?.color?["--color",t.color]:[];await Bun.$`gh label create ${e} --description ${r} ${s} --force`.quiet()}catch{}}async getRelease(e){let t=`${this.apiPath}/releases/tags/${encodeURIComponent(e)}`,r=await Bun.$`gh api ${t} --include`.quiet().nothrow(),s=r.stdout.toString().replaceAll(`\r
96
96
  `,`
97
97
  `),[n="",...i]=s.split(`
package/package.json CHANGED
@@ -31,5 +31,5 @@
31
31
  },
32
32
  "type": "module",
33
33
  "types": "src/cli.ts",
34
- "version": "0.11.0"
34
+ "version": "0.12.0"
35
35
  }