relion 0.11.0 → 0.13.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/dist/index.d.ts +27 -12
- package/dist/index.js +9 -9
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ interface UserConfig {
|
|
|
9
9
|
tag?: boolean | TagOptions;
|
|
10
10
|
newTagFormat?: string;
|
|
11
11
|
versionSourceFile?: string | VersionedFile;
|
|
12
|
-
releaseVersion?: string;
|
|
13
12
|
releaseType?: ReleaseType;
|
|
14
13
|
zeroMajorBreakingIsMinor?: boolean;
|
|
15
14
|
context?: Context;
|
|
@@ -20,7 +19,7 @@ interface UserConfig {
|
|
|
20
19
|
silent?: boolean;
|
|
21
20
|
[profile: `_${string}`]: UserConfig | undefined;
|
|
22
21
|
}
|
|
23
|
-
type OptionalKeys = '
|
|
22
|
+
type OptionalKeys = 'releaseType' | 'context' | 'profile';
|
|
24
23
|
interface MergedConfig extends Omit<Required<UserConfig>, OptionalKeys>, Pick<UserConfig, OptionalKeys> {
|
|
25
24
|
changelog: FalseOrComplete<ChangelogOptions>;
|
|
26
25
|
commit: FalseOrComplete<CommitOptions>;
|
|
@@ -32,10 +31,9 @@ interface TransformedConfig extends Omit<MergedConfig, 'changelog'> {
|
|
|
32
31
|
bump: FalseOrComplete<VersionedFile[]>;
|
|
33
32
|
changelog: false | ResolvedChangelogOptions;
|
|
34
33
|
}
|
|
35
|
-
interface
|
|
34
|
+
interface ResolvedConfig extends TransformedConfig {
|
|
36
35
|
context: ResolvedContext;
|
|
37
36
|
}
|
|
38
|
-
type ResolvedConfig = ContextualConfig;
|
|
39
37
|
type BumpFiles = (string | VersionedFile)[];
|
|
40
38
|
interface ChangelogOptions {
|
|
41
39
|
output?: 'stdout' | (string & {});
|
|
@@ -55,7 +53,7 @@ interface CommitOptions {
|
|
|
55
53
|
signOff?: boolean;
|
|
56
54
|
gpgSign?: boolean;
|
|
57
55
|
stageAll?: boolean;
|
|
58
|
-
extraArgs?: string;
|
|
56
|
+
extraArgs?: string | null;
|
|
59
57
|
}
|
|
60
58
|
type CompleteCommitOptions = Required<CommitOptions>;
|
|
61
59
|
interface TagOptions {
|
|
@@ -63,7 +61,7 @@ interface TagOptions {
|
|
|
63
61
|
message?: string;
|
|
64
62
|
gpgSign?: boolean;
|
|
65
63
|
force?: boolean;
|
|
66
|
-
extraArgs?: string;
|
|
64
|
+
extraArgs?: string | null;
|
|
67
65
|
}
|
|
68
66
|
type CompleteTagOptions = Required<TagOptions>;
|
|
69
67
|
interface CommitsParser {
|
|
@@ -131,7 +129,7 @@ declare enum RefType {
|
|
|
131
129
|
}
|
|
132
130
|
//#endregion
|
|
133
131
|
//#region src/types/commit.d.ts
|
|
134
|
-
type RawCommit =
|
|
132
|
+
type RawCommit = string | {
|
|
135
133
|
hash?: string;
|
|
136
134
|
message: string;
|
|
137
135
|
tagRefs?: string;
|
|
@@ -169,7 +167,6 @@ interface CommitMessage {
|
|
|
169
167
|
breakingChanges?: string | string[];
|
|
170
168
|
footer?: string;
|
|
171
169
|
}
|
|
172
|
-
type CommitMessageString = string;
|
|
173
170
|
interface Reference {
|
|
174
171
|
action: string;
|
|
175
172
|
type?: RefType;
|
|
@@ -284,8 +281,7 @@ interface ReleaseWithTypeGroups extends Omit<ReleaseWithFlatCommits, 'commits'>
|
|
|
284
281
|
commitTypeGroups: FilledTypeGroupMap;
|
|
285
282
|
}
|
|
286
283
|
interface ReleaseContext extends ReleaseWithTypeGroups, ResolvedContext {
|
|
287
|
-
|
|
288
|
-
prevVersion?: string;
|
|
284
|
+
prevRelease: Partial<ReleaseWithTypeGroups>;
|
|
289
285
|
}
|
|
290
286
|
type DefaultChangelogSections = typeof defaultChangelogSections;
|
|
291
287
|
interface ChangelogSectionsSelector extends DefaultChangelogSections {
|
|
@@ -293,11 +289,30 @@ interface ChangelogSectionsSelector extends DefaultChangelogSections {
|
|
|
293
289
|
omit(...keys: (keyof DefaultChangelogSections)[]): Partial<DefaultChangelogSections>;
|
|
294
290
|
}
|
|
295
291
|
//#endregion
|
|
292
|
+
//#region src/types/result.d.ts
|
|
293
|
+
interface RelionResult {
|
|
294
|
+
resolvedConfig: ResolvedConfig;
|
|
295
|
+
generatedChangelog: string | null;
|
|
296
|
+
commitCommand?: string;
|
|
297
|
+
tagCommand?: string;
|
|
298
|
+
bumpResults?: BumpResult[];
|
|
299
|
+
}
|
|
300
|
+
interface BumpResult extends VersionedFile {
|
|
301
|
+
oldVersion: string | null;
|
|
302
|
+
newVersion: string;
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
296
305
|
//#region src/relion.d.ts
|
|
297
|
-
declare function relion(userConfig: UserConfig): Promise<
|
|
306
|
+
declare function relion(userConfig: UserConfig): Promise<{
|
|
307
|
+
resolvedConfig: ResolvedConfig;
|
|
308
|
+
generatedChangelog: string | null;
|
|
309
|
+
commitCommand: string | null;
|
|
310
|
+
tagCommand: string | null;
|
|
311
|
+
bumpResults: BumpResult[] | null;
|
|
312
|
+
}>;
|
|
298
313
|
declare const defineConfig: (config: UserConfig) => UserConfig;
|
|
299
314
|
//#endregion
|
|
300
315
|
//#region src/utils/sections-selector.d.ts
|
|
301
316
|
declare const changelogSectionsSelector: ChangelogSectionsSelector;
|
|
302
317
|
//#endregion
|
|
303
|
-
export { BumpFiles, ChangelogOptions, ChangelogSectionsSelector, CommitMessage, CommitOptions, CommitRange, CommitsParser, CompleteChangelogOptions, CompleteCommitOptions, CompleteCommitsParser, CompleteTagOptions, Context,
|
|
318
|
+
export { BumpFiles, BumpResult, ChangelogOptions, ChangelogSectionsSelector, CommitMessage, CommitOptions, CommitRange, CommitsParser, CompleteChangelogOptions, CompleteCommitOptions, CompleteCommitsParser, CompleteTagOptions, Context, Contributor, DefaultChangelogSections, DefaultVersionedFile, FalseOrComplete, FilledTypeGroup, FilledTypeGroupMap, GithubUserInfo, GpgSig, GpgSigCode, MergedConfig, ParsedCommit, RawCommit, RawReference, RefLabel, Reference, ReleaseContext, ReleaseType, ReleaseWithFlatCommits, ReleaseWithTypeGroups, RelionResult, RepoInfo, ResolvedChangelogOptions, ResolvedCommit, ResolvedConfig, ResolvedContext, TagOptions, TransformedConfig, TypeGroupDefinition, TypeGroupsMap, UserConfig, VersionedFile, changelogSectionsSelector, relion as default, defineConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as t,writeFileSync as n}from"node:fs";import r from"
|
|
1
|
+
import{existsSync as e,readFileSync as t,writeFileSync as n}from"node:fs";import r from"semver";import{createHash as i}from"node:crypto";import{execSync as a}from"node:child_process";import o from"handlebars";const s={bump:!1,changelog:!1,commit:!1,tag:!1,versionSourceFile:`./package.json`,newTagFormat:`v{{version}}`,prevReleaseTagPattern:/^v?(?<version>\d+\.\d+\.\d+)/,zeroMajorBreakingIsMinor:!0,dryRun:!1,silent:!1,context:{commitHyperlink:!0,refHyperlink:!0},commitsParser:{headerPattern:/^(?<type>\w+)(?:\((?<scope>.+)\))?(?<bang>!)?: (?<subject>.+)/s,breakingChangesPattern:/BREAKING CHANGES?:\s*(?<content>.+)/s,breakingChangeListPattern:/- (.+)/g,tagPattern:/tag: (?<tag>.*?)[,)]/g,coAuthorPattern:/Co-authored-by: (?<name>.+?) <(?<email>.+)>/g,signerPattern:/Signed-off-by: (?<name>.+?) <(?<email>.+)>/g,ghEmailPattern:/^(?:\d+\+)?(?<username>.+)@users\.noreply\.github\.com$/,remoteUrlPattern:/^(https:\/\/|git@)(?<host>[^/:]+)[/:](?<owner>.+?)\/(?<name>.+?)(?:\..*)?$/,refPattern:/^(?<action>.+?) (?<labels>.+)$/gm,refLabelPattern:/(?:(?<owner>\S+?)\/(?<repo>\S+?))?#(?<number>\d+)/g,refActionPattern:/Fixes|Closes|Refs/i,dateSource:`authorDate`,dateFormat:`US`,revertCommitBodyPattern:/^This reverts commit (?<hash>.{7})/m}},c={breaking:{title:`⚠️ BREAKING CHANGES`,commitType:`breaking`},feat:{title:`✨ Features`,commitType:`feat`},fix:{title:`🩹 Fixes`,commitType:`fix`},perf:{title:`⚡ Performance`,commitType:`perf`},refactor:{title:`🚜 Refactoring`,commitType:`refactor`},docs:{title:`📚 Documentation`,commitType:`docs`},style:{title:`🎨 Style`,commitType:`style`},build:{title:`📦 Build`,commitType:`build`},ci:{title:`🚀 CI`,commitType:`ci`},revert:{title:`♻️ Reverts`,commitType:`revert`},types:{title:`🏷️ Types`,commitType:`types`},deps:{title:`🧩 Dependencies`,commitType:`chore`,filter:e=>!!e.scope?.includes(`deps`)},chore:{title:`🛠️ Chores`,commitType:`chore`},test:{title:`🧪 Tests`,commitType:`test`},misc:{title:`⚙️ Miscellaneous`,commitType:`*`,filter:e=>e.type!==`release`}},l={output:`CHANGELOG.md`,commitRange:`unreleased`,sections:c,header:`# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
`,prevReleaseHeaderPattern:/^##.*?\d+\.\d+\.\d+/m,helpers:{eq:(e,t)=>e===t,repeat:(e,t)=>e.repeat(t),isArray:e=>Array.isArray(e),isBreakingCommitInOtherTypeGroup:(e,t)=>Object.entries(t.data.root.commitTypeGroups).filter(([,{commitType:e}])=>e!==`breaking`).some(([,t])=>t.commits.includes(e))},partials:{}},u={message:`release({{repo.name}}): {{newTag}}`,signOff:!1,gpgSign:!1,stageAll:!0,extraArgs
|
|
4
|
+
`,prevReleaseHeaderPattern:/^##.*?\d+\.\d+\.\d+/m,helpers:{eq:(e,t)=>e===t,repeat:(e,t)=>e.repeat(t),isArray:e=>Array.isArray(e),isBreakingCommitInOtherTypeGroup:(e,t)=>Object.entries(t.data.root.commitTypeGroups).filter(([,{commitType:e}])=>e!==`breaking`).some(([,t])=>t.commits.includes(e))},partials:{}},u={message:`release({{repo.name}}): {{newTag}}`,signOff:!1,gpgSign:!1,stageAll:!0,extraArgs:null},d={name:`{{newTag}}`,message:`release({{repo.name}}): {{newTag}}`,gpgSign:!1,force:!1,extraArgs:null},f=[{filePathRegex:/package\.json$/,versionPattern:/(^.*?"version".*?")(.*?)(")/s},{filePathRegex:/package-lock\.json$/,versionPattern:/(^.*?"version".*?"|"packages".*?"".*"version".*?")(.*?)(")/gs}],p=async e=>{let t=m(e),n=h(t),r=g(n),i=await _(r),a=x(i);return a},m=e=>{let t=e.profile;if(!t)return e;let n=e[`_${t}`];if(!n)throw Error(`Profile "${t}" not found in configuration.`);let r=(t,...r)=>{let i=e=>Object.prototype.toString.call(e)===`[object Object]`,a=(e,t)=>{let n=i(e),r=i(t);if(n&&r)return{...e,...t};if(!n&&r)return t;if(n&&!r)return e},o=e[t],s=n[t],c=a(o,s);if(c!==void 0)return r.forEach(e=>{c[e]=a(o?.[e],s?.[e])}),c};return{...e,...n,commitsParser:r(`commitsParser`),changelog:r(`changelog`,`partials`,`helpers`),commit:r(`commit`),tag:r(`tag`),context:r(`context`)}},h=e=>{let t=(e,t,n,...r)=>{if(t==null||t===!1)return!1;if(t===!0)return n;if(typeof t!=`object`)throw Error(`Invalid value for ${e}. It should be a boolean or an object.`);let i={...n,...t};return r.forEach(e=>i[e]={...n[e],...t[e]}),i};return{...s,...e,commitsParser:{...s.commitsParser,...e.commitsParser},changelog:t(`changelog`,e.changelog,l,`partials`,`helpers`),commit:t(`commit`,e.commit,u),tag:t(`tag`,e.tag,d)}},g=e=>{let t=e=>{let t=f.find(t=>t.filePathRegex.test(e));if(t)return{filePath:e,versionPattern:t.versionPattern};throw Error(`File ${e} doesn't match any default versioned files. Please provide a custom version pattern for this file.`)},n=e=>{if(e===!1)return!1;if(e===!0)return[r];if(Array.isArray(e))return[r,...e.map(e=>typeof e==`string`?t(e):e)];throw Error(`Invalid value for bump. It should be a boolean or an array.`)},r=typeof e.versionSourceFile==`string`?t(e.versionSourceFile):e.versionSourceFile;return{...e,versionSourceFile:r,bump:n(e.bump),changelog:e.changelog===!1?!1:{...e.changelog,compiledPartials:J(e.changelog.partials)}}},_=async e=>{let t=e.context??{},n=z(e.commitsParser.remoteUrlPattern),r=t.currentVersion??S(e.versionSourceFile),i=t.currentTag??H(e.prevReleaseTagPattern)[0],a=t.newVersion??await w(e,r),o=t.newTag??e.newTagFormat.replace(`{{version}}`,a),s=e.changelog?e.changelog.commitRange:`unreleased`,c=t.commits?(await Promise.all(t.commits.map(async t=>typeof t==`object`&&`message`in t||typeof t==`string`?await j(t,e.commitsParser,e.prevReleaseTagPattern):t))).filter(e=>e!=null):await A(s,e.commitsParser,e.prevReleaseTagPattern),l=v(c,o,e.commitsParser.revertCommitBodyPattern),u=e.changelog?y(l,e.changelog.sections,e.prevReleaseTagPattern):null,{commits:d,...f}=t;return{...e,context:{currentVersion:r,currentTag:i,newVersion:a,newTag:o,commits:l,releases:u,...f,repo:{...n,...e.context?.repo}}}},v=(e,t,n)=>{let r=0;return e.map(i=>{let a=null,o=e.find(e=>e.type===`revert`&&n.exec(e.body??``)?.groups?.hash===i.hash);return o&&(a=o.associatedReleaseTag===i.associatedReleaseTag?`inTheSameRelease`:`inOtherRelease`),{...i,associatedReleaseTag:i.associatedReleaseTag??t,isReverted:i.isReverted??a,breakingChangeIndex:i.breakingChanges?++r:void 0}})},y=(e,t,n)=>{let r={};return e.forEach(e=>{let t=e.associatedReleaseTag;t in r?r[t].commits.push(e):r[t]={tag:t,version:C(t,n),date:e.date,commits:[e]}}),Object.values(r).map(({commits:e,...n})=>({...n,commitTypeGroups:b(e,t)})).filter(e=>Object.keys(e.commitTypeGroups).length)},b=(e,t)=>{let n=Object.fromEntries(Object.entries(t).map(([e,{filter:t,...n}])=>[e,{...n,commits:[]}]));return e.forEach(e=>{let r=!!e.breakingChanges,i=!1,a=!1;for(let o in t){if(t[o].filter&&!t[o].filter(e))continue;let s=[t[o].commitType].flat();if(r&&!a&&s.includes(`breaking`)){n[o].commits.push(e),a=!0;continue}if(!i&&(s.includes(e.type)||s.includes(`*`))&&(n[o].commits.push(e),i=!0),i&&(!r||a))return}}),Object.fromEntries(Object.entries(n).filter(([e,t])=>t.commits.length))},x=e=>({...e,commit:e.commit?{...e.commit,message:q(e.commit.message,e.context)}:e.commit,tag:e.tag?{...e.tag,name:q(e.tag.name,e.context),message:q(e.tag.message,e.context)}:e.tag}),S=e=>{let n=t(e.filePath,`utf8`),i=e.versionPattern.exec(n)?.[2];if(!i)throw Error(`Version not found in '${e.filePath}' with pattern '${e.versionPattern}'`);if(!r.valid(i))throw Error(`Invalid version format in '${e.filePath}': '${i}'`);return G(`Current version from '${e.filePath}': '${i}'`),i},C=(e,t)=>t.exec(e)?.groups?.version,w=async(e,t)=>{if(e.context?.newVersion){if(!r.valid(e.context.newVersion))throw Error(`Invalid release version format: '${e.context.newVersion}'`);return e.context.newVersion}let n;if(e.releaseType)n=e.releaseType;else{let i=await A(`unreleased`,e.commitsParser,e.prevReleaseTagPattern);n=T(i),e.zeroMajorBreakingIsMinor&&r.major(t)===0&&n===`major`&&(n=`minor`)}let i=E(t,n);return G(`Determined new version: '${i}' (release type: '${n}')`),i},T=e=>{let t=e.some(e=>e.breakingChanges);if(t)return`major`;let n=e.some(e=>e.type===`feat`);return n?`minor`:`patch`},E=(e,t)=>r.inc(e,t)??(()=>{throw Error(`Failed to calculate new version from '${e}' with release type '${t}'`)})();let D=function(e){return e.G=`valid`,e.B=`bad`,e.U=`valid, unknown validity`,e.X=`valid, expired`,e.Y=`valid, made by expired key`,e.R=`valid, made by revoked key`,e.E=`cannot check (missing key)`,e.N=`no signature`,e}({});const O={};let k;const A=async(e,t,n)=>{let r=Array.isArray(e)?e:B(e,n),i=t,a=(await Promise.all(r.map(async e=>j(e,i,n)))).filter(e=>e!==null);return k=void 0,a},j=async(e,t,n)=>{typeof e==`string`&&(e={message:e});let{tagRefs:r,hash:i=M(e.message)}=e;if(i in O)return O[i];let a=e.message.trim();if(!a)throw Error(`Message is missing for commit: ${JSON.stringify(e)}`);let o;try{o=N(a,t)}catch(e){return console.warn(`Error parsing commit '${i}':`,e.message),null}let{type:s,scope:c,subject:l,body:u,breakingChanges:d,footer:f}=o,p=r?[...r.matchAll(t.tagPattern)].map(e=>e.groups?.tag??``):[],m=f?[...f.matchAll(t.signerPattern)].map(e=>e.groups):[],h=[],g=e=>{h.some(t=>t.email===e.email)||h.push(e)},_=e.authorName&&e.authorEmail?F({name:e.authorName,email:e.authorEmail},m):void 0;_&&g(_);let v=e.committerName&&e.committerEmail?F({name:e.committerName,email:e.committerEmail},m):void 0;v&&g(v);let y=f?[...f.matchAll(t.coAuthorPattern)].map(e=>e.groups).map(e=>F(e,m)):[];y.forEach(e=>g(e));let b=await I(f??``,t),x=e.gpgSigCode?{code:e.gpgSigCode,label:D[e.gpgSigCode],keyId:e.gpgSigKeyId}:void 0,S=e[t.dateSource===`committerDate`?`committerTs`:`authorTs`];typeof S==`string`&&(S=L(new Date(S*1e3),t.dateFormat));let C=p.find(e=>n.exec(e)),w=C??k;w&&(k=w);let T={hash:i,type:s,scope:c,subject:l,body:u,breakingChanges:d,footer:f,committer:v,gpgSig:x,date:S,releaseTag:C,associatedReleaseTag:w,tags:p.length?p:void 0,authors:h.length?h:void 0,refs:b.length?b:void 0};return i&&!(i in O)&&(O[i]=T),T},M=e=>`fake_`+i(`sha256`).update(e,`utf8`).digest(`hex`).slice(0,7),N=(e,t)=>{let[n,...r]=e.split(`
|
|
5
5
|
|
|
6
|
-
`),i=t.headerPattern.exec(n);if(!i?.groups)throw Error(`Commit header '${n}' doesn't match expected format`);let{type:a,scope:o,bang:s,subject:c}=i.groups,l,u=r.find(e=>t.breakingChangesPattern.test(e));u?(l=
|
|
6
|
+
`),i=t.headerPattern.exec(n);if(!i?.groups)throw Error(`Commit header '${n}' doesn't match expected format`);let{type:a,scope:o,bang:s,subject:c}=i.groups,l,u=r.find(e=>t.breakingChangesPattern.test(e));u?(l=P(u,t),r.splice(r.indexOf(u),1)):s&&(l=c);let d=r.findIndex(e=>e.match(t.refActionPattern)??e.match(t.coAuthorPattern)??e.match(t.signerPattern)),[f,p]=d===-1?[r.join(`
|
|
7
7
|
|
|
8
8
|
`),``]:[r.slice(0,d).join(`
|
|
9
9
|
|
|
10
10
|
`),r.slice(d).join(`
|
|
11
11
|
|
|
12
|
-
`)];return{type:a,scope:o||void 0,subject:c,body:f||void 0,breakingChanges:l,footer:p||void 0}},
|
|
13
|
-
`).filter(t=>e.test(t))};let
|
|
14
|
-
##   [\` 📦 {{tag}} \`]({{repo.homepage}}/{{#if
|
|
12
|
+
`)];return{type:a,scope:o||void 0,subject:c,body:f||void 0,breakingChanges:l,footer:p||void 0}},P=(e,t)=>{let n=t.breakingChangesPattern.exec(e)?.groups?.content;if(!n)throw Error(`Failed to extract breaking changes content from '${e}' using pattern "${t.breakingChangesPattern}"`);let r=[...n.matchAll(t.breakingChangeListPattern)];return r.length?r.map(e=>e[1]):n},F=(e,t)=>{let n=t.some(t=>t.email===e.email&&t.name===e.name);return{...e,hasSignedOff:n,ghLogin:e.name,ghUrl:`https://github.com/${e.name}`}},I=async(e,t)=>await Promise.all([...e.matchAll(t.refPattern)].map(e=>e.groups).filter(e=>t.refActionPattern.test(e.action)).flatMap(e=>[...e.labels.matchAll(t.refLabelPattern)].map(e=>e.groups).filter(e=>!!e.number).map(t=>({action:e.action,owner:t.owner,repo:t.repo,number:t.number})))),L=(e,t)=>{let n=e=>e.toString().padStart(2,`0`);if(t===`US`)return e.toLocaleString(`en-US`,{month:`short`,day:`numeric`,year:`numeric`});if(t===`ISO`)return e.toISOString().split(`T`)[0];let r={YYYY:e.getUTCFullYear().toString(),MM:n(e.getUTCMonth()+1),DD:n(e.getUTCDate()),HH:n(e.getUTCHours()),mm:n(e.getUTCMinutes()),ss:n(e.getUTCSeconds())};return t.replace(/YYYY|MM|DD|HH|mm|ss/g,e=>r[e])},R=/##COMMIT##\n#HASH# (?<hash>.+)?\n#MSG# (?<message>[\s\S]*?)\n#REFS#\s+(?<tagRefs>.+)?\n#AUTHOR-NAME# (?<authorName>.+)?\n#AUTHOR-EMAIL# (?<authorEmail>.+)?\n#AUTHOR-DATE# (?<authorTs>.+)?\n#COMMITTER-NAME# (?<committerName>.+)?\n#COMMITTER-EMAIL# (?<committerEmail>.+)?\n#COMMITTER-DATE# (?<committerTs>.+)?\n#GPGSIG-CODE# (?<gpgSigCode>.+)?\n#GPGSIG-KEYID# (?<gpgSigKeyId>.+)?/g,z=e=>{let t=a(`git remote get-url origin`,{encoding:`utf8`}).trim(),n=e.exec(t);if(!n?.groups)throw Error(`Couldn't parse remote URL: `+t);let{host:r,owner:i,name:o}=n.groups,s=`https://${r}/${i}/${o}`;return{host:r,owner:i,name:o,homepage:s}},B=(e,t)=>{let n=V(),r=H(t),i=``,o=``,s=``;if(e===`all`)i=`{{firstCommit}}`,o=`HEAD`;else if(e===`unreleased`)i=r[0]??`{{firstCommit}}`,o=`HEAD`;else if(e===`latest-release`)i=r[1]??`{{firstCommit}}`,o=r[0]??`HEAD`;else if(typeof e==`object`){let t=r.indexOf(e.versionTag);if(t===-1)throw Error(`Version tag '${e.versionTag}' not found`);i=r[t+1]??`{{firstCommit}}`,o=r[t]}else s=e;i&&o&&(s=i===`{{firstCommit}}`?`"${i}^!" ${o}`:`"${i}..${o}"`),s=s.replace(`{{firstCommit}}`,n);let c=a(`git log ${s} --pretty="##COMMIT##%n#HASH# %h%n#MSG# %B%n#REFS# %d%n#AUTHOR-NAME# %an%n#AUTHOR-EMAIL# %ae%n#AUTHOR-DATE# %at%n#COMMITTER-NAME# %cn%n#COMMITTER-EMAIL# %ce%n#COMMITTER-DATE# %ct%n#GPGSIG-CODE# %G?%n#GPGSIG-KEYID# %GK%n"`,{encoding:`utf8`});return[...c.matchAll(R)].map(e=>e.groups)},V=()=>a(`git rev-list --max-parents=0 HEAD`,{encoding:`utf8`}).trim(),H=e=>{let t=a(`git tag --sort=-creatordate`,{encoding:`utf8`});return t.split(`
|
|
13
|
+
`).filter(t=>e.test(t))};let U=!1;const W=e=>U=e,G=(...e)=>{U||console.log(...e)},K={...c,pick(...e){return Object.fromEntries(e.map(e=>[e,this[e]]))},omit(...e){let t=new Set(e);return Object.fromEntries(Object.entries(this).filter(([e])=>!t.has(e)))}},q=(e,t)=>o.compile(e)(t),J=e=>Object.fromEntries(Object.entries(e).map(([e,t])=>[e,o.compile(t)])),Y=e=>{if(!e.bump)return null;let r=e.bump,i=e.context.newVersion;return r.map(r=>{let a=t(r.filePath,`utf8`),o=r.versionPattern.exec(a)?.[2]??null,s=a.replace(r.versionPattern,`$1${i}$3`);return e.dryRun||n(r.filePath,s,`utf8`),G(`Updated version in '${r.filePath}' to '${i}'`),{...r,oldVersion:o,newVersion:i}})};var X=`{{#>header~}}
|
|
14
|
+
##   [\` 📦 {{tag}} \`]({{repo.homepage}}/{{#if prevRelease.tag}}compare/{{prevRelease.tag}}...{{tag}}{{else}}commits/{{tag}}{{/if}})
|
|
15
15
|
|
|
16
16
|
{{/header}}
|
|
17
17
|
|
|
@@ -45,12 +45,12 @@ import{existsSync as e,readFileSync as t,writeFileSync as n}from"node:fs";import
|
|
|
45
45
|
|
|
46
46
|
{{~#>footer~}}
|
|
47
47
|
#####    [_All Release Commits_]
|
|
48
|
-
{{~#if
|
|
49
|
-
({{repo.homepage}}/compare/{{
|
|
48
|
+
{{~#if prevRelease.tag~}}
|
|
49
|
+
({{repo.homepage}}/compare/{{prevRelease.tag}}...{{tag}})
|
|
50
50
|
{{~else~}}
|
|
51
51
|
({{repo.homepage}}/commits/{{tag}})
|
|
52
52
|
{{~/if~}}
|
|
53
53
|
{{" "}}  •  _{{date}}_
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
{{/footer}}`;const
|
|
56
|
+
{{/footer}}`;const Z=e=>{if(!e.changelog)return null;let t=e.changelog,n=e.context.releases;if(!n)return null;let r=H(e.prevReleaseTagPattern);o.registerPartial(t.compiledPartials),o.registerHelper(t.helpers);let i=t.header;return n.forEach((t,a)=>{let o=n[a+1];if(!o){let n=r.indexOf(t.tag);if(n!==-1){let t=r[n+1];o={tag:t,version:t&&C(t,e.prevReleaseTagPattern)}}else o={tag:e.context.currentTag,version:e.context.currentVersion}}let s={...t,...e.context,prevRelease:o},c=q(X,s);i+=c}),t.output===`stdout`?(G(`Generated changelog:`),console.log(i)):(G(`Writing changelog to file '${t.output}'`),e.dryRun||Q(t.output,i,t.prevReleaseHeaderPattern)),i},Q=(r,i,a)=>{let o=e(r)?t(r,{encoding:`utf8`}):``,s=o.search(a),c=o.slice(s),l=i+c;n(r,l,{encoding:`utf8`})},$=e=>{if(!e.commit)return null;let t=e.commit,n=[t.stageAll&&`git add -A &&`,`git commit -m "${t.message}"`,t.signOff&&`-s`,t.gpgSign&&`-S`,t.extraArgs].filter(Boolean).join(` `);return G(`Committing with command: '${n}'`),e.dryRun||a(n,{stdio:`inherit`}),n},ee=e=>{if(!e.tag)return null;let t=e.tag,n=[`git tag -a ${t.name}`,`-m "${t.message}"`,t.gpgSign&&`-s`,t.force&&`-f`,t.extraArgs].filter(Boolean).join(` `);return G(`Tagging with command: '${n}'`),e.dryRun||a(n,{stdio:`inherit`}),n};async function te(e){W(!!e.silent||!!e.profile&&!!e[`_${e.profile}`]?.silent);let t=await p(e),n=Y(t),r=Z(t),i=$(t),a=ee(t);return{resolvedConfig:t,generatedChangelog:r,commitCommand:i,tagCommand:a,bumpResults:n}}const ne=e=>e;export{K as changelogSectionsSelector,te as default,ne as defineConfig};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "relion",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Release workflow helper for Node.js projects.",
|
|
5
5
|
"author": "Kh4f <kh4f.dev@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsdown",
|
|
58
|
-
"lint": "eslint",
|
|
59
|
-
"test": "vitest run index",
|
|
60
58
|
"build:watch": "tsdown --watch",
|
|
61
59
|
"build:prod": "tsdown --production",
|
|
62
|
-
"
|
|
60
|
+
"lint": "eslint",
|
|
63
61
|
"lint:fix": "eslint --fix",
|
|
62
|
+
"test": "vitest run index",
|
|
63
|
+
"test:watch": "vitest index",
|
|
64
64
|
"release": "node dist/cli.js -blct",
|
|
65
65
|
"release:github": "node dist/cli.js -l -p github -L"
|
|
66
66
|
}
|