genbumppush 0.0.1 → 0.0.3
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 +310 -8
- package/dist/bin.d.mts +1 -0
- package/dist/bin.mjs +110 -0
- package/dist/index.d.mts +81 -3
- package/dist/index.mjs +2 -6
- package/dist/release-CVQ5WSKG.mjs +881 -0
- package/package.json +21 -2
package/README.md
CHANGED
|
@@ -1,23 +1,325 @@
|
|
|
1
|
-
#
|
|
1
|
+
# genbumppush
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/xcvzmoon/genbumppush/actions/workflows/ci.yml)
|
|
4
|
+
[](https://github.com/xcvzmoon/genbumppush/actions/workflows/release.yml)
|
|
5
|
+
[](https://www.npmjs.com/package/genbumppush)
|
|
6
|
+
[](https://www.npmjs.com/package/genbumppush)
|
|
4
7
|
|
|
5
|
-
|
|
8
|
+
`genbumppush` handles the repetitive parts of releasing a Conventional Commit repository. It picks the next semantic version, updates the files you choose, writes the changelog, commits, tags, and can push the branch and tag together.
|
|
6
9
|
|
|
7
|
-
-
|
|
10
|
+
It supports Node packages, web applications (React, Vue, Solid, Svelte, Astro, Next, Nuxt, etc.), fixed-version monorepos, Tauri applications, and tag-driven publication/deployment. It does not publish packages or create provider releases itself; GitHub Actions or GitLab CI should handle those after the tag is pushed.
|
|
8
11
|
|
|
9
12
|
```bash
|
|
10
|
-
|
|
13
|
+
npm install --save-dev genbumppush
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```json
|
|
17
|
+
{ "scripts": { "release": "genbumppush" } }
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The package exports `defineConfig`, `loadReleaseConfig`, `runRelease`, and release types. The `genbumppush` binary is also available directly.
|
|
21
|
+
|
|
22
|
+
## Release lifecycle
|
|
23
|
+
|
|
24
|
+
The command loads C12 configuration, validates the Git worktree, detects the release type, and previews or confirms the release. It then calculates the version, checks local/remote tag collisions, runs `before` hooks, validates every version file, writes versions and the changelog, commits, tags, atomically pushes, and runs `after` hooks.
|
|
25
|
+
|
|
26
|
+
Version-file and commit-preparation failures restore files and the index. A failed tag or network push leaves the release commit locally for inspection and retry. If no releasable commit exists, it exits successfully without mutation.
|
|
27
|
+
|
|
28
|
+
## CLI
|
|
29
|
+
|
|
30
|
+
```text
|
|
31
|
+
genbumppush [release] [options]
|
|
11
32
|
```
|
|
12
33
|
|
|
13
|
-
|
|
34
|
+
| Type | Result from `1.2.3` |
|
|
35
|
+
| ------------ | ------------------- |
|
|
36
|
+
| `major` | `2.0.0` |
|
|
37
|
+
| `minor` | `1.3.0` |
|
|
38
|
+
| `patch` | `1.2.4` |
|
|
39
|
+
| `premajor` | `2.0.0-beta.0` |
|
|
40
|
+
| `preminor` | `1.3.0-beta.0` |
|
|
41
|
+
| `prepatch` | `1.2.4-beta.0` |
|
|
42
|
+
| `prerelease` | `1.2.4-beta.0` |
|
|
14
43
|
|
|
15
44
|
```bash
|
|
16
|
-
|
|
45
|
+
npm run release # detect from Conventional Commits
|
|
46
|
+
npm run release patch # force a release type
|
|
47
|
+
npm run release preminor --preid beta # start a prerelease channel
|
|
48
|
+
npm run release prerelease --preid beta
|
|
49
|
+
npm run release --dry-run # preview without mutation
|
|
50
|
+
npm run release patch --no-push # local commit and tag only
|
|
51
|
+
npm run release patch --yes # non-interactive
|
|
52
|
+
genbumppush --cwd ../app --config release.config.ts patch
|
|
53
|
+
genbumppush --retry-gitlab v1.2.4 # retry provider release after a successful Git push
|
|
17
54
|
```
|
|
18
55
|
|
|
19
|
-
|
|
56
|
+
| Option | Meaning |
|
|
57
|
+
| ---------------------- | -------------------------------------------------------- |
|
|
58
|
+
| positional release | One supported release type |
|
|
59
|
+
| `--cwd <path>` | Repository directory; defaults to the current directory |
|
|
60
|
+
| `--config <path>` | Explicit C12 config file |
|
|
61
|
+
| `--preid <id>` | Identifier containing letters, numbers, and hyphens |
|
|
62
|
+
| `--retry-gitlab <tag>` | Retry GitLab release creation for an existing remote tag |
|
|
63
|
+
| `--retry-github <tag>` | Retry GitHub release creation for an existing remote tag |
|
|
64
|
+
| `--dry-run` | Preview without changing files, Git, or remotes |
|
|
65
|
+
| `--no-push` | Keep commit and tag local |
|
|
66
|
+
| `--yes`, `-y` | Skip confirmation |
|
|
67
|
+
| `--help`, `-h` | Print help |
|
|
68
|
+
|
|
69
|
+
Values are resolved in this order: CLI, config file, the `genbumppush` key in `package.json`, then defaults. A CLI flag such as `--no-push` overrides the config file.
|
|
70
|
+
|
|
71
|
+
## Commit detection
|
|
72
|
+
|
|
73
|
+
Automatic detection uses `changelogen`:
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
feat: add an adapter -> minor
|
|
77
|
+
fix: handle empty input -> patch
|
|
78
|
+
feat!: remove old API -> major
|
|
79
|
+
refactor(api)!: change API -> major
|
|
80
|
+
chore(deps): update vite -> excluded by default
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
`BREAKING CHANGE:` footers are supported. Set `release` to force a type. Non-breaking `chore(deps)` commits are excluded by default; set `excludeDependencyCommits: false` to include them.
|
|
84
|
+
|
|
85
|
+
## Configuration
|
|
86
|
+
|
|
87
|
+
Create `genbumppush.config.ts`:
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
import { defineConfig } from 'genbumppush';
|
|
91
|
+
|
|
92
|
+
export default defineConfig({
|
|
93
|
+
// release: 'patch', // omit for automatic detection
|
|
94
|
+
preid: 'beta',
|
|
95
|
+
changelog: 'CHANGELOG.md',
|
|
96
|
+
excludeDependencyCommits: true,
|
|
97
|
+
recursive: false,
|
|
98
|
+
files: ['package.json'],
|
|
99
|
+
git: {
|
|
100
|
+
remote: 'origin',
|
|
101
|
+
push: true,
|
|
102
|
+
sign: false,
|
|
103
|
+
requireClean: true,
|
|
104
|
+
requireUpstream: true,
|
|
105
|
+
commitMessage: 'chore(release): v{{version}}',
|
|
106
|
+
tagName: 'v{{version}}',
|
|
107
|
+
tagMessage: 'v{{version}}',
|
|
108
|
+
},
|
|
109
|
+
hooks: {
|
|
110
|
+
before: ['vp check', 'vp test'],
|
|
111
|
+
after: 'echo Release complete',
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
The same object can live under `"genbumppush"` in `package.json`. JavaScript and TypeScript C12 files are supported; use `--config` for another location.
|
|
117
|
+
|
|
118
|
+
| Key | Type | Default | Behavior |
|
|
119
|
+
| -------------------------- | ------------------------- | ------------------------------ | -------------------------------------- |
|
|
120
|
+
| `release` | release type | detected | Force release type |
|
|
121
|
+
| `preid` | string | `beta` | Prerelease channel |
|
|
122
|
+
| `changelog` | `false \| true \| string` | `CHANGELOG.md` | Disable, default, or custom path |
|
|
123
|
+
| `excludeDependencyCommits` | boolean | `true` | Ignore non-breaking dependency commits |
|
|
124
|
+
| `files` | string[] | `['package.json']` | Version files |
|
|
125
|
+
| `recursive` | boolean | `false` | Discover nested manifests |
|
|
126
|
+
| `git.remote` | string | `origin` | Remote for checks and push |
|
|
127
|
+
| `git.push` | boolean | `true` | Push branch and tag |
|
|
128
|
+
| `git.sign` | boolean | `false` | Sign commit and tag |
|
|
129
|
+
| `git.requireClean` | boolean | `true` | Reject uncommitted changes |
|
|
130
|
+
| `git.requireUpstream` | boolean | `true` | Require upstream before pushing |
|
|
131
|
+
| `git.commitMessage` | string | `chore(release): v{{version}}` | Commit template |
|
|
132
|
+
| `git.tagName` | string | `v{{version}}` | Tag template |
|
|
133
|
+
| `git.tagMessage` | string | `v{{version}}` | Annotated tag template |
|
|
134
|
+
| `hooks.before` | string or string[] | unset | Commands before file changes |
|
|
135
|
+
| `hooks.after` | string or string[] | unset | Commands after tag/push |
|
|
136
|
+
| `github.enabled` | boolean | `false` | Create a GitHub release after push |
|
|
137
|
+
| `github.host` | string | `github.com` | github.com or GHES host |
|
|
138
|
+
| `github.repo` | string | `GITHUB_REPOSITORY` / remote | `owner/name` |
|
|
139
|
+
| `github.tokenEnv` | string | `GITHUB_TOKEN` | Token environment variable |
|
|
140
|
+
| `github.releaseName` | string | tag | Release title template |
|
|
141
|
+
| `gitlab.enabled` | boolean | `false` | Create a GitLab release after push |
|
|
142
|
+
|
|
143
|
+
`{{version}}` is replaced in commit and tag templates. Hooks run through the shell in the repository directory; only use trusted configuration.
|
|
144
|
+
|
|
145
|
+
## Version-file adapters
|
|
146
|
+
|
|
147
|
+
Every configured file is validated before writes begin. Structured files must agree with the root version; mismatches fail without partial updates.
|
|
148
|
+
|
|
149
|
+
Supported adapters:
|
|
150
|
+
|
|
151
|
+
- `package.json`: top-level `version`
|
|
152
|
+
- `package-lock.json`: root `version` and `packages['']` version
|
|
153
|
+
- Explicit JSON such as `tauri.conf.json`: top-level `version`
|
|
154
|
+
- `Cargo.toml`: `version` in `[package]`
|
|
155
|
+
- `Cargo.lock`: only the package matching the adjacent Cargo manifest
|
|
156
|
+
|
|
157
|
+
Other files use exact text replacement: the current version must occur exactly once. This suits a `VERSION` file, but not arbitrary lockfiles. There is no general pnpm-lock.yaml adapter; configure it only when the current version occurs exactly once.
|
|
158
|
+
|
|
159
|
+
### Fixed-version monorepo
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
export default defineConfig({
|
|
163
|
+
recursive: true,
|
|
164
|
+
files: ['package.json', 'package-lock.json'],
|
|
165
|
+
});
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Discovery ignores `.git`, `node_modules`, `dist`, `target`, and `.output`. It assumes versioned workspaces share one version; independent-version packages need a separate strategy.
|
|
169
|
+
|
|
170
|
+
### Tauri
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
export default defineConfig({
|
|
174
|
+
files: [
|
|
175
|
+
'package.json',
|
|
176
|
+
'src-tauri/tauri.conf.json',
|
|
177
|
+
'src-tauri/Cargo.toml',
|
|
178
|
+
'src-tauri/Cargo.lock',
|
|
179
|
+
],
|
|
180
|
+
});
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Cargo dependency versions are not changed. Only the application package and matching lock entry are updated.
|
|
184
|
+
|
|
185
|
+
## Git safety and recovery
|
|
186
|
+
|
|
187
|
+
Defaults reject dirty worktrees, detached HEAD, missing upstreams, and existing local or remote tags. Branch and tag are sent with `git push --atomic`.
|
|
188
|
+
|
|
189
|
+
Use `--no-push` for a local rehearsal. If a push fails after commit/tag creation, inspect `git status`, `git log`, and `git show`, then retry the push or remove local artifacts deliberately. If GitLab release creation fails after the Git push succeeds, fix the provider or credentials and run `genbumppush --retry-gitlab <tag>`.
|
|
190
|
+
|
|
191
|
+
For deliberate exceptions, set `git.requireClean: false` or `git.requireUpstream: false`. These do not disable tag collision checks or version validation.
|
|
192
|
+
|
|
193
|
+
## GitHub Actions and npm
|
|
194
|
+
|
|
195
|
+
The included workflows split CI, release creation, and package publication into separate jobs:
|
|
196
|
+
|
|
197
|
+
- `ci.yml` runs `vp check`, `vp test`, and `vp pack` on pull requests and main pushes.
|
|
198
|
+
- `release.yml` reacts to `v*` tags and creates a GitHub Release from the changelog section.
|
|
199
|
+
- `publish.yml` reacts to `v*` tags, verifies `v${package.json.version}`, rebuilds, and publishes.
|
|
200
|
+
|
|
201
|
+
A release commit message alone does not trigger tag workflows. The tag must exist and be pushed:
|
|
202
|
+
|
|
203
|
+
```bash
|
|
204
|
+
git push origin main v0.0.1
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
For npm trusted publishing, configure the npm package trusted publisher to match the repository/workflow, keep `id-token: write`, and use a current npm. The included workflow enables provenance for public repositories. Private source repositories should set `NPM_CONFIG_PROVENANCE=false` because npm rejects private-source provenance bundles.
|
|
208
|
+
|
|
209
|
+
## GitHub and GitLab releases
|
|
210
|
+
|
|
211
|
+
GitHub Releases are supported as an opt-in provider after the Git branch and tag are pushed atomically. genbumppush uses the exact `git.tagName` string (so custom templates work) and creates or updates the release via the GitHub API (including GHES).
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
export default defineConfig({
|
|
215
|
+
git: { push: true },
|
|
216
|
+
github: {
|
|
217
|
+
enabled: true,
|
|
218
|
+
// host: 'github.com', // or a GHES host
|
|
219
|
+
// repo: 'group/project', // or GITHUB_REPOSITORY / package.json repository
|
|
220
|
+
tokenEnv: 'GITHUB_TOKEN', // also honors GH_TOKEN and CHANGELOGEN_TOKENS_GITHUB
|
|
221
|
+
releaseName: 'v{{version}}',
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
If GitHub release creation fails after the Git push succeeds, fix credentials and run `genbumppush --retry-github <tag>`.
|
|
227
|
+
|
|
228
|
+
GitLab release creation remains supported the same way. Configure a project path and provide an API token through the environment:
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
export default defineConfig({
|
|
232
|
+
git: { push: true },
|
|
233
|
+
gitlab: {
|
|
234
|
+
enabled: true,
|
|
235
|
+
host: 'https://gitlab.com',
|
|
236
|
+
project: 'group/project',
|
|
237
|
+
tokenEnv: 'GITLAB_TOKEN',
|
|
238
|
+
releaseName: 'v{{version}}',
|
|
239
|
+
},
|
|
240
|
+
});
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
`GITLAB_HOST` and `GITLAB_PROJECT` may be used as environment fallbacks. The token
|
|
244
|
+
must be available as the configured `tokenEnv` (default `GITLAB_TOKEN`). GitLab receives
|
|
245
|
+
the matching `CHANGELOG.md` section as the release description. If `git.push` is false,
|
|
246
|
+
the provider is rejected because GitLab cannot create a release for an unpublished tag.
|
|
247
|
+
|
|
248
|
+
```yaml
|
|
249
|
+
release:
|
|
250
|
+
image: node:20
|
|
251
|
+
rules:
|
|
252
|
+
- if: '$CI_COMMIT_TAG =~ /^v/'
|
|
253
|
+
script:
|
|
254
|
+
- npm ci
|
|
255
|
+
- npx genbumppush --dry-run --yes
|
|
256
|
+
- npm run build
|
|
257
|
+
release:
|
|
258
|
+
tag_name: '$CI_COMMIT_TAG'
|
|
259
|
+
name: 'Release $CI_COMMIT_TAG'
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Keep artifact publication and GitLab release creation in protected, tag-triggered jobs with their own credentials.
|
|
263
|
+
|
|
264
|
+
## Scenario guide
|
|
265
|
+
|
|
266
|
+
| Scenario | Recommended setup |
|
|
267
|
+
| ---------------------- | -------------------------------------------------- |
|
|
268
|
+
| Local release | `npm run release`, confirm interactively |
|
|
269
|
+
| CI release | `genbumppush --yes` with protected Git credentials |
|
|
270
|
+
| Preview only | `genbumppush --dry-run --yes` |
|
|
271
|
+
| Local commit/tag only | `genbumppush patch --no-push --yes` |
|
|
272
|
+
| Nuxt or Node package | Default `package.json` adapter |
|
|
273
|
+
| npm lockfile | Add `package-lock.json` explicitly |
|
|
274
|
+
| Fixed-version monorepo | `recursive: true` |
|
|
275
|
+
| Tauri | Explicit JSON, Cargo.toml, and Cargo.lock files |
|
|
276
|
+
| Custom VERSION file | Add only if the old version occurs once |
|
|
277
|
+
| GitHub/npm publication | Push `v*`; let workflows publish |
|
|
278
|
+
| GitLab release | Run downstream jobs on `$CI_COMMIT_TAG` |
|
|
279
|
+
|
|
280
|
+
## Troubleshooting
|
|
281
|
+
|
|
282
|
+
### Tag does not match package version
|
|
20
283
|
|
|
21
284
|
```bash
|
|
285
|
+
node -p "require('./package.json').version"
|
|
286
|
+
git describe --tags --exact-match HEAD
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
The publisher requires `v${package.json.version}`. Correct the release commit before creating or pushing a replacement tag.
|
|
290
|
+
|
|
291
|
+
### Dirty worktree, existing tag, or version mismatch
|
|
292
|
+
|
|
293
|
+
Run `git status --short` and inspect an existing tag with `git show <tag>`. Commit/stash changes, align every configured manifest with the root version, and never overwrite a published tag as a normal retry.
|
|
294
|
+
|
|
295
|
+
### `EBADDEVENGINES`
|
|
296
|
+
|
|
297
|
+
`devEngines.packageManager` is npm metadata. Run with the declared package manager or align the metadata with the manager used by CI; it is separate from release logic.
|
|
298
|
+
|
|
299
|
+
### Private-repository provenance failure
|
|
300
|
+
|
|
301
|
+
npm rejects provenance bundles identifying private GitHub source repositories. Set `NPM_CONFIG_PROVENANCE=false` in the publish workflow, or make the source public and keep provenance enabled.
|
|
302
|
+
|
|
303
|
+
### Workflow did not run
|
|
304
|
+
|
|
305
|
+
Verify the tag was pushed, matches `v*`, and the workflow exists on the pushed commit:
|
|
306
|
+
|
|
307
|
+
```bash
|
|
308
|
+
git ls-remote --tags origin
|
|
309
|
+
gh run list --workflow release.yml
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
## Development
|
|
313
|
+
|
|
314
|
+
```bash
|
|
315
|
+
vp install
|
|
316
|
+
vp check
|
|
317
|
+
vp test
|
|
22
318
|
vp pack
|
|
23
319
|
```
|
|
320
|
+
|
|
321
|
+
The test suite covers CLI parsing, C12 configuration, SemVer edges, JSON/npm/Cargo adapters, recursive workspaces, dry runs, rollback, hooks, tag collisions, detached HEAD, upstream checks, and a real atomic push to a temporary bare Git remote.
|
|
322
|
+
|
|
323
|
+
## License
|
|
324
|
+
|
|
325
|
+
MIT
|
package/dist/bin.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/bin.mjs
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { n as ReleaseError, t as runRelease } from "./release-CVQ5WSKG.mjs";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
//#region src/types.ts
|
|
5
|
+
const RELEASE_TYPES = [
|
|
6
|
+
"major",
|
|
7
|
+
"premajor",
|
|
8
|
+
"minor",
|
|
9
|
+
"preminor",
|
|
10
|
+
"patch",
|
|
11
|
+
"prepatch",
|
|
12
|
+
"prerelease"
|
|
13
|
+
];
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/cli.ts
|
|
16
|
+
const HELP_TEXT = `Usage: genbumppush [release] [options]\n\nGenerate a changelog, bump versions, create an annotated tag, and push atomically.\n\nArguments:\n release ${RELEASE_TYPES.join(" | ")}\n\nOptions:\n --cwd <path> Repository directory\n --config <path> Explicit C12 config file\n --preid <id> Prerelease identifier\n --retry-gitlab <tag> Retry GitLab release creation for a pushed tag\n --retry-github <tag> Retry GitHub release creation for a pushed tag\n --dry-run Preview without changes\n --no-push Keep commit and tag local\n --yes, -y Skip confirmation\n --help, -h Show help\n`;
|
|
17
|
+
function isType(value) {
|
|
18
|
+
return RELEASE_TYPES.some((item) => item === value);
|
|
19
|
+
}
|
|
20
|
+
function next(args, index, option) {
|
|
21
|
+
const value = args[index + 1];
|
|
22
|
+
if (value === void 0 || value.startsWith("-")) throw new ReleaseError("MISSING_OPTION_VALUE", `${option} requires a value.`);
|
|
23
|
+
return value;
|
|
24
|
+
}
|
|
25
|
+
function parseCliOptions(args) {
|
|
26
|
+
const result = {
|
|
27
|
+
cwd: process.cwd(),
|
|
28
|
+
dryRun: false,
|
|
29
|
+
yes: false,
|
|
30
|
+
help: false
|
|
31
|
+
};
|
|
32
|
+
for (let index = 0; index < args.length; index += 1) {
|
|
33
|
+
const arg = args[index];
|
|
34
|
+
if (arg === void 0) continue;
|
|
35
|
+
const equals = arg.indexOf("=");
|
|
36
|
+
const option = equals < 0 ? arg : arg.slice(0, equals);
|
|
37
|
+
const inlineValue = equals < 0 ? void 0 : arg.slice(equals + 1);
|
|
38
|
+
switch (option) {
|
|
39
|
+
case "--dry-run":
|
|
40
|
+
result.dryRun = true;
|
|
41
|
+
break;
|
|
42
|
+
case "--no-push":
|
|
43
|
+
result.push = false;
|
|
44
|
+
break;
|
|
45
|
+
case "--yes":
|
|
46
|
+
case "-y":
|
|
47
|
+
result.yes = true;
|
|
48
|
+
break;
|
|
49
|
+
case "--help":
|
|
50
|
+
case "-h":
|
|
51
|
+
result.help = true;
|
|
52
|
+
break;
|
|
53
|
+
case "--cwd": {
|
|
54
|
+
const value = inlineValue ?? next(args, index, "--cwd");
|
|
55
|
+
result.cwd = resolve(value);
|
|
56
|
+
if (inlineValue === void 0) index += 1;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
case "--config":
|
|
60
|
+
result.configFile = inlineValue ?? next(args, index, "--config");
|
|
61
|
+
if (inlineValue === void 0) index += 1;
|
|
62
|
+
break;
|
|
63
|
+
case "--preid": {
|
|
64
|
+
const value = inlineValue ?? next(args, index, "--preid");
|
|
65
|
+
if (!/^[0-9A-Za-z-]+$/.test(value)) throw new ReleaseError("INVALID_PREID", "--preid accepts letters, numbers, and hyphens.");
|
|
66
|
+
result.preid = value;
|
|
67
|
+
if (inlineValue === void 0) index += 1;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case "--retry-gitlab":
|
|
71
|
+
result.gitlabRetryTag = inlineValue ?? next(args, index, "--retry-gitlab");
|
|
72
|
+
if (inlineValue === void 0) index += 1;
|
|
73
|
+
break;
|
|
74
|
+
case "--retry-github":
|
|
75
|
+
result.githubRetryTag = inlineValue ?? next(args, index, "--retry-github");
|
|
76
|
+
if (inlineValue === void 0) index += 1;
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
if (isType(arg) && result.release === void 0) {
|
|
80
|
+
result.release = arg;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
throw new ReleaseError("UNKNOWN_ARGUMENT", `Unknown argument: ${arg}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (result.gitlabRetryTag !== void 0 && result.release !== void 0) throw new ReleaseError("CONFLICTING_ARGUMENTS", "--retry-gitlab cannot be combined with a release type.");
|
|
87
|
+
if (result.githubRetryTag !== void 0 && result.release !== void 0) throw new ReleaseError("CONFLICTING_ARGUMENTS", "--retry-github cannot be combined with a release type.");
|
|
88
|
+
if (result.gitlabRetryTag !== void 0 && result.githubRetryTag !== void 0) throw new ReleaseError("CONFLICTING_ARGUMENTS", "--retry-gitlab and --retry-github cannot be combined.");
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/bin.ts
|
|
93
|
+
try {
|
|
94
|
+
const options = parseCliOptions(process.argv.slice(2));
|
|
95
|
+
if (options.help) console.info(HELP_TEXT);
|
|
96
|
+
else {
|
|
97
|
+
const result = await runRelease(options);
|
|
98
|
+
if (result.githubReleaseCreated) console.info(`GitHub release ${result.tag ?? ""} created.`);
|
|
99
|
+
else if (result.gitlabReleaseCreated) console.info(`GitLab release ${result.tag ?? ""} created.`);
|
|
100
|
+
else if (result.releaseType === void 0) console.info("No releasable commits found.");
|
|
101
|
+
else if (result.dryRun) console.info(`Dry run: would create ${result.tag ?? result.releaseType} from ${result.currentVersion}${result.newVersion !== void 0 ? ` to v${result.newVersion}` : ""}.`);
|
|
102
|
+
else if (!result.dryRun) console.info(`${result.tag ?? result.releaseType} created${result.pushed ? " and pushed" : ""}.`);
|
|
103
|
+
}
|
|
104
|
+
} catch (error) {
|
|
105
|
+
if (error instanceof ReleaseError) console.error(`[${error.code}] ${error.message}`);
|
|
106
|
+
else console.error(error instanceof Error ? error.message : error);
|
|
107
|
+
process.exitCode = 1;
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
export {};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,81 @@
|
|
|
1
|
-
//#region src/
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
declare const RELEASE_TYPES: readonly ["major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease"];
|
|
3
|
+
type ReleaseType = (typeof RELEASE_TYPES)[number];
|
|
4
|
+
type GitOptions = {
|
|
5
|
+
remote?: string;
|
|
6
|
+
push?: boolean;
|
|
7
|
+
sign?: boolean;
|
|
8
|
+
requireClean?: boolean;
|
|
9
|
+
requireUpstream?: boolean;
|
|
10
|
+
commitMessage?: string;
|
|
11
|
+
tagName?: string;
|
|
12
|
+
tagMessage?: string;
|
|
13
|
+
};
|
|
14
|
+
type HookOptions = {
|
|
15
|
+
before?: string | string[];
|
|
16
|
+
after?: string | string[];
|
|
17
|
+
};
|
|
18
|
+
type GitLabOptions = {
|
|
19
|
+
enabled?: boolean;
|
|
20
|
+
host?: string;
|
|
21
|
+
project?: string;
|
|
22
|
+
tokenEnv?: string;
|
|
23
|
+
releaseName?: string;
|
|
24
|
+
};
|
|
25
|
+
type GitHubOptions = {
|
|
26
|
+
enabled?: boolean;
|
|
27
|
+
host?: string;
|
|
28
|
+
repo?: string;
|
|
29
|
+
tokenEnv?: string;
|
|
30
|
+
releaseName?: string;
|
|
31
|
+
};
|
|
32
|
+
type GenBumpPushConfig = {
|
|
33
|
+
release?: ReleaseType;
|
|
34
|
+
preid?: string;
|
|
35
|
+
files?: string[];
|
|
36
|
+
recursive?: boolean;
|
|
37
|
+
changelog?: boolean | string;
|
|
38
|
+
excludeDependencyCommits?: boolean;
|
|
39
|
+
git?: GitOptions;
|
|
40
|
+
gitlab?: GitLabOptions;
|
|
41
|
+
github?: GitHubOptions;
|
|
42
|
+
hooks?: HookOptions;
|
|
43
|
+
};
|
|
44
|
+
type CliOptions = {
|
|
45
|
+
cwd: string;
|
|
46
|
+
configFile?: string;
|
|
47
|
+
gitlabRetryTag?: string;
|
|
48
|
+
githubRetryTag?: string;
|
|
49
|
+
release?: ReleaseType;
|
|
50
|
+
preid?: string;
|
|
51
|
+
dryRun: boolean;
|
|
52
|
+
push?: boolean;
|
|
53
|
+
yes: boolean;
|
|
54
|
+
help: boolean;
|
|
55
|
+
};
|
|
56
|
+
type ReleaseResult = {
|
|
57
|
+
currentVersion: string;
|
|
58
|
+
newVersion?: string;
|
|
59
|
+
releaseType?: ReleaseType;
|
|
60
|
+
tag?: string;
|
|
61
|
+
pushed: boolean;
|
|
62
|
+
dryRun: boolean;
|
|
63
|
+
commitCount: number;
|
|
64
|
+
gitlabReleaseCreated?: boolean;
|
|
65
|
+
githubReleaseCreated?: boolean;
|
|
66
|
+
};
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/config.d.ts
|
|
69
|
+
export declare const defineConfig: import("c12").DefineConfig<GenBumpPushConfig, import("c12").ConfigLayerMeta>;
|
|
70
|
+
export declare function loadReleaseConfig(cwd: string, configFile?: string, overrides?: GenBumpPushConfig): Promise<GenBumpPushConfig>;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/error.d.ts
|
|
73
|
+
export declare class ReleaseError extends Error {
|
|
74
|
+
readonly code: string;
|
|
75
|
+
constructor(code: string, message: string, options?: ErrorOptions);
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/release.d.ts
|
|
79
|
+
export declare function runRelease(options: CliOptions): Promise<ReleaseResult>;
|
|
80
|
+
//#endregion
|
|
81
|
+
export type { CliOptions, GenBumpPushConfig, GitHubOptions, GitLabOptions, GitOptions, HookOptions, ReleaseResult, ReleaseType };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return "Hello, tsdown!";
|
|
4
|
-
}
|
|
5
|
-
//#endregion
|
|
6
|
-
export { fn };
|
|
1
|
+
import { i as loadReleaseConfig, n as ReleaseError, r as defineConfig, t as runRelease } from "./release-CVQ5WSKG.mjs";
|
|
2
|
+
export { ReleaseError, defineConfig, loadReleaseConfig, runRelease };
|