relion 0.42.0 → 0.43.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.
- package/README.md +26 -110
- package/dist/cli.js +12 -14
- package/package.json +5 -7
- package/dist/index.d.ts +0 -62
- package/dist/index.js +0 -4
package/README.md
CHANGED
|
@@ -5,144 +5,61 @@
|
|
|
5
5
|
</picture>
|
|
6
6
|
<br>
|
|
7
7
|
<a href="https://www.npmjs.com/package/relion"><img src="https://img.shields.io/npm/v/relion?label=npm&logo=npm&style=flat-square&color=B2BFFF&labelColor=303145" alt="npm version"/></a>
|
|
8
|
-
<a href="https://www.npmjs.com/package/relion"><img src="https://img.badgesize.io/https:/unpkg.com/relion/dist/
|
|
8
|
+
<a href="https://www.npmjs.com/package/relion"><img src="https://img.badgesize.io/https:/unpkg.com/relion/dist/cli.js?label=Size&logo=hackthebox&logoColor=c97026&style=flat-square&color=B2BFFF&labelColor=303145" alt="runtime size"/></a>
|
|
9
9
|
<a href="https://github.com/kh4f/relion/blob/master/LICENSE"><img src="https://img.shields.io/github/license/kh4f/relion?style=flat-square&label=%F0%9F%9B%A1%EF%B8%8F%20License&color=B2BFFF&labelColor=303145" alt="license"></a>
|
|
10
10
|
<a href="https://github.com/kh4f/relion/issues?q=is%3Aissue+is%3Aopen+label%3Abug"><img src="https://img.shields.io/github/issues/kh4f/relion/bug?label=%F0%9F%90%9B%20Bugs&style=flat-square&color=B2BFFF&labelColor=303145" alt="open bugs"></a>
|
|
11
11
|
<br><br>
|
|
12
12
|
<b>A minimal npm library for automating release workflow:<br></b> version bumping, release commit & tag creation, and AI‑assisted changelog generation
|
|
13
13
|
<br><br>
|
|
14
14
|
<p><b>
|
|
15
|
-
<a href="
|
|
16
|
-
<a href="#%EF%B8%8F-cli-usage">CLI</a> •
|
|
17
|
-
<a href="#-api-usage">API</a> •
|
|
15
|
+
<a href="#%EF%B8%8F-usage">Usage</a> •
|
|
18
16
|
<a href="#%EF%B8%8F-workflow-steps">Workflow Steps</a> •
|
|
19
17
|
<a href="#-changelog-generation">Changelog Generation</a>
|
|
20
18
|
</b></p>
|
|
21
19
|
<br>
|
|
22
20
|
</div>
|
|
23
21
|
|
|
24
|
-
##
|
|
22
|
+
## 🕹️ Usage
|
|
25
23
|
|
|
26
24
|
```bash
|
|
27
|
-
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## 🕹️ CLI Usage
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
$ pnpm relion -h
|
|
25
|
+
$ bunx relion -h
|
|
34
26
|
|
|
35
27
|
Usage: relion [options]
|
|
36
28
|
|
|
37
29
|
Options:
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-v <version> Set the new version explicitly
|
|
43
|
-
-m <file> Specify manifest file
|
|
44
|
-
-d Run in dry run mode
|
|
45
|
-
-h Show the help message
|
|
30
|
+
-b <files> Files to bump version in (def: ['package.json']; package.json is always included if exists)
|
|
31
|
+
-v <version> Release version (def: calculated from commits)
|
|
32
|
+
-t <prefix> Tag prefix (def: 'v')
|
|
33
|
+
-d Dry run (def: false)
|
|
46
34
|
|
|
47
35
|
Examples:
|
|
48
|
-
- `
|
|
49
|
-
- `
|
|
50
|
-
- `pnpm relion -m Cargo.toml` — use Cargo.toml as manifest
|
|
51
|
-
- `pnpm relion` — run all release steps
|
|
36
|
+
- `bunx relion -b src/manifest.json`
|
|
37
|
+
- `bunx relion -d -v 1.2.3`
|
|
52
38
|
```
|
|
53
39
|
|
|
54
|
-
<details><summary>Example output of running <code>
|
|
40
|
+
<details><summary>Example output of running <code>bunx relion</code>:</summary>
|
|
55
41
|
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
Current
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
New
|
|
63
|
-
|
|
64
|
-
Repo URL: https://github.com/kh4f/relion
|
|
42
|
+
```
|
|
43
|
+
Project: relion
|
|
44
|
+
Repo: github.com/kh4f/relion
|
|
45
|
+
Current tag: v0.42.1
|
|
46
|
+
Current version: 0.42.1
|
|
47
|
+
Parsed commits: 26
|
|
48
|
+
New version: 0.43.0
|
|
49
|
+
New tag: v0.43.0
|
|
65
50
|
------------------------------
|
|
66
51
|
|
|
52
|
+
('' to continue / 's' to skip)
|
|
67
53
|
About to write context to 'RELEASE.md'
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
About to
|
|
71
|
-
Press Enter to continue ('s' to skip):
|
|
72
|
-
|
|
73
|
-
About to commit changes: 'git commit -m "chore(release): v0.37.0"'
|
|
74
|
-
Press Enter to continue ('s' to skip):
|
|
75
|
-
|
|
76
|
-
About to create a tag: 'git tag v0.37.0 -m "chore(release): v0.37.0"'
|
|
77
|
-
Press Enter to continue ('s' to skip):
|
|
54
|
+
About to bump version in files: package.json
|
|
55
|
+
About to commit changes: 'git commit -m "chore(release): v0.43.0"'
|
|
56
|
+
About to create a tag: 'git tag v0.43.0 -m "chore(release): v0.43.0"'
|
|
78
57
|
```
|
|
79
58
|
</details>
|
|
80
59
|
|
|
81
|
-
## 🧩 API Usage
|
|
82
|
-
|
|
83
|
-
```ts
|
|
84
|
-
import relion from 'relion';
|
|
85
|
-
|
|
86
|
-
relion({
|
|
87
|
-
flow: ['context', 'bump', 'commit', 'tag'],
|
|
88
|
-
newVersion: '1.2.3',
|
|
89
|
-
bump: [
|
|
90
|
-
'package.json', // uses default bumper
|
|
91
|
-
// custom bumper (equivalent to the default bumper implementation)
|
|
92
|
-
{
|
|
93
|
-
file: 'manifest.json',
|
|
94
|
-
pattern: /("version": )".*"/,
|
|
95
|
-
replacement: '$1"{{newVersion}}"'
|
|
96
|
-
}
|
|
97
|
-
],
|
|
98
|
-
contextFile: 'RELEASE.md',
|
|
99
|
-
commitMessage: 'chore(release): {{tag}}',
|
|
100
|
-
tagPrefix: 'v',
|
|
101
|
-
dryRun: false,
|
|
102
|
-
});
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Options
|
|
106
|
-
|
|
107
|
-
- `manifest`: manifest file (default: auto-detects `package.json` or `Cargo.toml`)
|
|
108
|
-
- `flow`: release workflow steps (`'context' | 'bump' | 'commit' | 'tag'`) (default: all steps)
|
|
109
|
-
- `newVersion`: set the new version explicitly
|
|
110
|
-
- `bump`: files or custom bumpers for version update (default: [`'package.json', 'Cargo.toml'`])
|
|
111
|
-
- `contextFile`: path to release context output file (default: `'RELEASE.md'`)
|
|
112
|
-
- `commitMessage`: release commit message template (default: `'chore(release): {{tag}}'`)
|
|
113
|
-
- `tagPrefix`: release tag prefix (default: `'v'`)
|
|
114
|
-
- `dryRun`: run in dry mode (no modifications)
|
|
115
|
-
|
|
116
|
-
> For detailed option descriptions, see [src/types.d.ts](src/types.d.ts).
|
|
117
|
-
|
|
118
|
-
### Configuration via `package.json`
|
|
119
|
-
|
|
120
|
-
Relion can also be configured via `relion` field in `package.json`:
|
|
121
|
-
|
|
122
|
-
```jsonc
|
|
123
|
-
{
|
|
124
|
-
// ...
|
|
125
|
-
"relion": {
|
|
126
|
-
"commitMessage": "release(relion): {{tag}}",
|
|
127
|
-
"tagPrefix": "",
|
|
128
|
-
"bump": ["package.json",
|
|
129
|
-
{
|
|
130
|
-
"file": "manifest.json",
|
|
131
|
-
"pattern": "/(\"version\": )\".*\"/",
|
|
132
|
-
"replacement": "$1\"{{newVersion}}\""
|
|
133
|
-
}
|
|
134
|
-
],
|
|
135
|
-
// ...
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
> [!NOTE]
|
|
141
|
-
> CLI flags override `package.json` configuration.
|
|
142
|
-
|
|
143
60
|
## ♻️ Workflow Steps
|
|
144
61
|
|
|
145
|
-
- **Context**: generates a file with upcoming release metadata and commit log
|
|
62
|
+
- **Context**: generates a `RELEASE.md` file with upcoming release metadata and commit log
|
|
146
63
|
- **Bump**: updates version in specified files
|
|
147
64
|
- **Commit**: creates a release commit
|
|
148
65
|
- **Tag**: creates an annotated release tag
|
|
@@ -154,7 +71,7 @@ Relion can also be configured via `relion` field in `package.json`:
|
|
|
154
71
|
tag: v0.33.0
|
|
155
72
|
prevTag: v0.32.1
|
|
156
73
|
date: Jan 10, 2026
|
|
157
|
-
repoURL:
|
|
74
|
+
repoURL: github.com/kh4f/relion
|
|
158
75
|
---
|
|
159
76
|
|
|
160
77
|
## Commit Log
|
|
@@ -167,7 +84,6 @@ Previously, if commits contained both features and breaking changes, features wo
|
|
|
167
84
|
|
|
168
85
|
- Implement `mergeConfigs` to support merging config profiles in `config-merger.ts`
|
|
169
86
|
- Export `mergeConfigs` from `src/index.ts`
|
|
170
|
-
------------------------------
|
|
171
87
|
```
|
|
172
88
|
</details>
|
|
173
89
|
|
|
@@ -180,7 +96,7 @@ Recommended workflow:
|
|
|
180
96
|
1. Set up GitHub Copilot instruction and prompt:
|
|
181
97
|
- [.github/instructions/changelog-format.instructions.md](.github/instructions/changelog-format.instructions.md)
|
|
182
98
|
- [.github/prompts/generate-changelog.prompt.md](.github/prompts/generate-changelog.prompt.md)
|
|
183
|
-
2. Run
|
|
99
|
+
2. Run Relion to generate `RELEASE.md` with the release context
|
|
184
100
|
3. Review the release context, adjust as needed
|
|
185
101
|
4. Run the prompt in VSCode Copilot chat: `/generate-changelog`
|
|
186
102
|
5. Copilot produces a polished changelog entry based on the release context
|
package/dist/cli.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import e from"
|
|
2
|
+
import{execSync as e,spawnSync as t}from"node:child_process";import{existsSync as n,readFileSync as r,writeFileSync as i}from"node:fs";import{createInterface as a}from"node:readline";import o from"semver";const s=()=>{let t=e(`git config --get remote.origin.url`,{encoding:`utf8`}).trim(),n=/(github\.com.*?)(\.git)?$/.exec(t)?.[1]??``;return{url:n,name:n.split(`/`).at(-1)??``}},c=t=>e(`git log ${t?`${t}..`:``} --format="%h %B---" .`,{encoding:`utf8`}).trim().split(`---`).filter(Boolean).map(e=>/^(.+?) (.+)/s.exec(e.trim())).map(e=>({hash:e?.[1]??``,message:e?.[2].trim()??``})),l=(e,t)=>{let n=e.some(e=>e.message.includes(`BREAKING CHANGE`))?t.startsWith(`0.`)?`minor`:`major`:e.some(e=>/feat(\(.*?\))?:/.test(e.message))?`minor`:`patch`;return o.inc(t,n)??(()=>{throw Error(`Failed to increment version '${t}' with release type '${n}'`)})()},u=async e=>{let t=a({input:process.stdin,output:process.stdout});return await new Promise(n=>{t.question(e,e=>{t.close(),n(e.trim()!==`s`)})})},d=async(e,t,n,r,a)=>{if(!await u(`About to write context to 'RELEASE.md'`)||e.dryRun)return;let o=``,s=`---\ntag: ${r}\nprevTag: ${n}\ndate: ${new Date().toLocaleString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}\nrepoURL: ${a}
|
|
3
|
+
---
|
|
4
|
+
`;o+=s+`
|
|
5
|
+
`;let c=t.map(e=>`[${e.hash}] ${e.message}`).join(`\n${`-`.repeat(30)}\n`);o+=`## Commit Log\n\n\`\`\`\n${c}\n\`\`\``,i(`RELEASE.md`,o,`utf8`)},f=async e=>{let t=e.bump.filter(n);await u(`About to bump version in files: ${t.join(`, `)}`)&&t.forEach(t=>{let n=r(t,`utf8`).replace(/(\bversion\b.*?)\d[\w.+-]*/,`$1${e.newVersion}`);e.dryRun||i(t,n,`utf8`)})},p=async(t,n)=>{let r=`git commit -m "${n}"`;await u(`About to commit changes: '${r}'`)&&(t.dryRun||e(r,{stdio:`inherit`}))},m=async(t,n,r)=>{let i=`git tag ${n} -m "${r}"`;await u(`About to create a tag: '${i}'`)&&(t.dryRun||e(i,{stdio:`inherit`}))},h={bump:[`package.json`],newVersion:``,tagPrefix:`v`,dryRun:!1},g=async e=>{let n=s();console.log(`Project: ${n.name}`),console.log(`Repo: ${n.url}`);let r={...h,...e,bump:[...h.bump,...e.bump??[]]},i=t(`git`,[`describe`,`--match`,`${r.tagPrefix}[0-9]*.[0-9]*.[0-9]*`,`--abbrev=0`],{encoding:`utf8`}).stdout.trim();console.log(`Current tag: ${i}`);let a=/\d+\.\d+\.\d+.*/.exec(i)?.[0]??`0.0.0`;console.log(`Current version: ${a}`);let o=c(i);console.log(`Parsed commits: ${o.length}`),r.newVersion||=l(o,a),console.log(`New version: ${r.newVersion}`);let u=`${r.tagPrefix}${r.newVersion}`;console.log(`New tag: ${u}`);let g=`chore(release): ${u}`;console.log(`Commit message: '${g}'`),console.log(`-`.repeat(30)),console.log(`
|
|
6
|
+
('' to continue / 's' to skip)`),await d(r,o,i,u,n.url),await f(r),await p(r,g),await m(r,u,g)},_=process.argv.slice(2).join(` `);_.includes(`-h`)&&(console.log(`Usage: relion [options]
|
|
3
7
|
|
|
4
8
|
Options:
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-v <version> Set the new version explicitly
|
|
10
|
-
-m <file> Specify manifest file
|
|
11
|
-
-d Run in dry run mode
|
|
12
|
-
-h Show the help message
|
|
9
|
+
-b <files> Files to bump version in (def: ['package.json']; package.json is always included if exists)
|
|
10
|
+
-v <version> Release version (def: calculated from commits)
|
|
11
|
+
-t <prefix> Tag prefix (def: 'v')
|
|
12
|
+
-d Dry run (def: false)
|
|
13
13
|
|
|
14
14
|
Examples:
|
|
15
|
-
- \`
|
|
16
|
-
- \`
|
|
17
|
-
|
|
18
|
-
- \`pnpm relion\` — run all release steps
|
|
19
|
-
`),process.exit(0));let n=[/-\w*f/.test(t)&&`context`,/-\w*b/.test(t)&&`bump`,/-\w*c/.test(t)&&`commit`,/-\w*t/.test(t)&&`tag`].filter(Boolean);n.length||(n=[`context`,`bump`,`commit`,`tag`]);const r=/-v (\S+)/.exec(t)?.[1],i=/-m (\S+)/.exec(t)?.[1],a=/-\w*d/.test(t);e({flow:n,...r&&{newVersion:r},...i&&{manifest:i},...a&&{dryRun:a}}).catch(e=>{console.error(e),process.exit(1)});export{};
|
|
15
|
+
- \`bunx relion -b src/manifest.json\`
|
|
16
|
+
- \`bunx relion -d -v 1.2.3\`
|
|
17
|
+
`),process.exit(0));const v=/-b (.+?)( -|$)/.exec(_)?.[1].split(` `),y=/-v (\S+)/.exec(_)?.[1],b=/-t (\S+)/.exec(_)?.[1],x=/-\w*d/.test(_);g({...v&&{bump:v},...y&&{newVersion:y},...b&&{tagPrefix:b},...x&&{dryRun:x}}).catch(e=>{console.error(e),process.exit(1)});export{};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "relion",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "🏷️
|
|
3
|
+
"version": "0.43.0",
|
|
4
|
+
"description": "🏷️ Release Workflow Helper",
|
|
5
5
|
"author": "kh4f <kh4f.dev@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": "https://github.com/kh4f/relion",
|
|
@@ -10,9 +10,7 @@
|
|
|
10
10
|
"keywords": ["relion", "release", "release-automation", "release-workflow", "release-helper", "release-workflow-helper"],
|
|
11
11
|
"files": ["dist"],
|
|
12
12
|
"type": "module",
|
|
13
|
-
"main": "dist/index.js",
|
|
14
13
|
"bin": "dist/cli.js",
|
|
15
|
-
"types": "dist/index.d.ts",
|
|
16
14
|
"scripts": {
|
|
17
15
|
"build": "tsdown",
|
|
18
16
|
"build:watch": "tsdown --watch",
|
|
@@ -24,12 +22,12 @@
|
|
|
24
22
|
"devDependencies": {
|
|
25
23
|
"@eslint/js": "^10.0.1",
|
|
26
24
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
27
|
-
"@types/node": "^25.
|
|
25
|
+
"@types/node": "^25.4.0",
|
|
28
26
|
"@types/semver": "^7.7.1",
|
|
29
27
|
"eslint": "^10.0.3",
|
|
30
28
|
"jiti": "^2.6.1",
|
|
31
|
-
"tsdown": "^0.21.
|
|
29
|
+
"tsdown": "^0.21.1",
|
|
32
30
|
"typescript": "^5.9.3",
|
|
33
|
-
"typescript-eslint": "^8.
|
|
31
|
+
"typescript-eslint": "^8.57.0"
|
|
34
32
|
}
|
|
35
33
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
|
-
interface Config {
|
|
3
|
-
/** Manifest file path. Auto-detects `package.json` or `Cargo.toml` if omitted. */
|
|
4
|
-
manifest?: string;
|
|
5
|
-
/**
|
|
6
|
-
* Release workflow steps to execute (e.g. bump, context, commit, tag)
|
|
7
|
-
* @default []
|
|
8
|
-
*/
|
|
9
|
-
flow?: Step[];
|
|
10
|
-
/**
|
|
11
|
-
* Explicitly set the version for the upcoming release. If not provided, the version will be determined automatically based on conventional commit messages.
|
|
12
|
-
* @default ''
|
|
13
|
-
*/
|
|
14
|
-
newVersion?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Files or bumpers for version update. Each item is either:
|
|
17
|
-
* - a Bumper object specifying `file`, `pattern`, and `replacement`
|
|
18
|
-
* - a file name for which a default bumper exists (currently only 'package.json', 'Cargo.toml')
|
|
19
|
-
*
|
|
20
|
-
* If a file doesn't exist, it will be skipped silently.
|
|
21
|
-
*
|
|
22
|
-
* @default ['package.json', 'Cargo.toml']
|
|
23
|
-
*/
|
|
24
|
-
bump?: (Bumper | string)[];
|
|
25
|
-
/**
|
|
26
|
-
* Path to the release context output file
|
|
27
|
-
* @default 'RELEASE.md'
|
|
28
|
-
*/
|
|
29
|
-
contextFile?: string;
|
|
30
|
-
/**
|
|
31
|
-
* Release commit message template
|
|
32
|
-
* @default 'chore(release): {{tag}}'
|
|
33
|
-
*/
|
|
34
|
-
commitMessage?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Release tag prefix
|
|
37
|
-
* @default 'v'
|
|
38
|
-
*/
|
|
39
|
-
tagPrefix?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Run in dry mode without making any changes
|
|
42
|
-
* @default false
|
|
43
|
-
*/
|
|
44
|
-
dryRun?: boolean;
|
|
45
|
-
}
|
|
46
|
-
type Step = 'bump' | 'context' | 'commit' | 'tag';
|
|
47
|
-
interface Bumper {
|
|
48
|
-
/** Path or array of paths to the file(s) to bump version in */
|
|
49
|
-
file: string | string[];
|
|
50
|
-
/** Pattern to locate the version string (RegExp or a stringified RegExp) */
|
|
51
|
-
pattern: RegExp | string;
|
|
52
|
-
/** Replacement string for the version (use `{{newVersion}}` as a placeholder) */
|
|
53
|
-
replacement: string;
|
|
54
|
-
}
|
|
55
|
-
//#endregion
|
|
56
|
-
//#region src/relion.d.ts
|
|
57
|
-
declare function relion(userCfg?: Config): Promise<void>;
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/index.d.ts
|
|
60
|
-
declare const defineConfig: (config: Config) => Config;
|
|
61
|
-
//#endregion
|
|
62
|
-
export { relion as default, defineConfig };
|
package/dist/index.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as t,writeFileSync as n}from"node:fs";import{execSync as r,spawnSync as i}from"node:child_process";import{createInterface as a}from"node:readline";import o from"semver";const s=()=>{let e=r(`git config --get remote.origin.url`,{encoding:`utf8`}).trim(),t=/(github\.com.*?)(\.git)?$/.exec(e)?.[1]??``;return{url:t,name:t.split(`/`).at(-1)??``}},c=e=>{let n=t(e,`utf8`),r=/name.*"(.*?)"/.exec(n)?.[1];if(!r)throw Error(`Manifest is missing 'name' field`);let i=/repository.*"(.*?)"/.exec(n)?.[1];if(!i)throw Error(`Manifest is missing 'repository' field`);let a=e.endsWith(`.json`)?/relion.*({.*?})/s.exec(n)?.[1]:void 0;return{name:r,url:i,relion:a?JSON.parse(a):void 0}},l=e=>r(`git log ${e?`${e}..`:``} --format="%h %B---" .`,{encoding:`utf8`}).trim().split(`---`).filter(Boolean).map(e=>/^(.+?) (.+)/s.exec(e.trim())).map(e=>({hash:e?.[1]??``,message:e?.[2].trim()??``})),u=(e,t)=>{let n=e.some(e=>e.message.includes(`BREAKING CHANGE`))?t.startsWith(`0.`)?`minor`:`major`:e.some(e=>/feat(\(.*?\))?:/.test(e.message))?`minor`:`patch`;return o.inc(t,n)??(()=>{throw Error(`Failed to increment version '${t}' with release type '${n}'`)})()},d=async()=>{let e=a({input:process.stdin,output:process.stdout});return await new Promise(t=>{e.question(`Press Enter to continue ('s' to skip): `,n=>{e.close(),t(n.trim()!==`s`)})})},f=e=>{let t=/^\/(.+)\/(\w*)$/.exec(e);return t?new RegExp(t[1],t[2]):new RegExp(e)},p=[`context`,`bump`,`commit`,`tag`],m={file:[`package.json`,`Cargo.toml`],pattern:/(\bversion\b.*?)\d[\w.+-]*/,replacement:`$1{{newVersion}}`},h=[`package.json`,`Cargo.toml`],g={flow:p,newVersion:``,bump:h,contextFile:`RELEASE.md`,commitMessage:`chore(release): {{tag}}`,tagPrefix:`v`,dryRun:!1},_=async(e,t,r,i,a)=>{if(console.log(`\nAbout to write context to '${e.contextFile}'`),!await d()||e.dryRun)return;let o=``,s=`---\ntag: ${i}\nprevTag: ${r}\ndate: ${new Date().toLocaleString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`})}\nrepoURL: ${a}
|
|
2
|
-
---
|
|
3
|
-
`;o+=s+`
|
|
4
|
-
`;let c=t.map(e=>`[${e.hash}] ${e.message}`).join(`\n${`-`.repeat(30)}\n`);o+=`## Commit Log\n\n\`\`\`\n${c}\n\`\`\``,n(e.contextFile,o,`utf8`)},v=async r=>{let i=r.bump.map(e=>typeof e==`string`?{...m,file:e}:e).filter(t=>[t.file].flat().every(t=>e(t)));console.log(`\nAbout to bump versions in files: ${i.map(e=>[e.file].flat()).flat().join(`, `)}`),await d()&&i.forEach(e=>{typeof e.pattern==`string`&&(e.pattern=f(e.pattern)),[e.file].flat().forEach(i=>{let a=t(i,`utf8`).replace(e.pattern,e.replacement.replace(`{{newVersion}}`,r.newVersion));r.dryRun||n(i,a,`utf8`)})})},y=async e=>{let t=`git commit -m "${e.commitMessage}"`;console.log(`\nAbout to commit changes: '${t}'`),await d()&&(e.dryRun||r(t,{stdio:`inherit`}))},b=async(e,t,n)=>{let i=`git tag ${n} -m "${e.commitMessage}"`;console.log(`\nAbout to create a tag: '${i}'`),await d()&&(e.dryRun||r(i,{stdio:`inherit`}))};async function x(t){let n;if(t?.manifest&&!e(t.manifest))throw Error(`Specified manifest file '${t.manifest}' does not exist`);let r=t?.manifest??h.find(e);r?(console.log(`Manifest file: ${r}`),n=c(r)):(console.log(`No manifest file found, using repository info`),n=s()),console.log(`Project: ${n.name}`),console.log(`Repo: ${n.url}`),t={...n.relion,...t};let a={...g,...t};!t.tagPrefix&&n.name.startsWith(`@`)&&(a.tagPrefix=`${n.name}@`);let o=i(`git`,[`describe`,`--match`,`${a.tagPrefix}[0-9]*.[0-9]*.[0-9]*`,`--abbrev=0`],{encoding:`utf8`}).stdout.trim();console.log(`Current tag: ${o}`);let d=/\d+\.\d+\.\d+.*/.exec(o)?.[0]??`0.0.0`;console.log(`Current version: ${d}`);let f=l(o);console.log(`Parsed commits: ${f.length}`),a.newVersion||=u(f,d),console.log(`New version: ${a.newVersion}`);let m=`${a.tagPrefix}${a.newVersion}`;console.log(`New tag: ${m}`),a.commitMessage=a.commitMessage.replace(`{{tag}}`,m),console.log(`Commit message: '${a.commitMessage}'`),console.log(`-`.repeat(30));for(let e of p.filter(e=>a.flow.includes(e)))await{context:()=>_(a,f,o,m,n.url),bump:()=>v(a),commit:()=>y(a),tag:()=>b(a,o,m)}[e]()}const S=e=>e;export{x as default,S as defineConfig};
|