relion 0.25.0 → 0.26.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/cli.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/resolver.js +1 -0
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolve as e}from"node:path";import{pathToFileURL as t}from"node:url";import n from"./index.js";import{cli as r}from"cleye";import"
|
|
1
|
+
import{resolve as e}from"node:path";import{pathToFileURL as t}from"node:url";import n from"./index.js";import{cli as r}from"cleye";import{register as i}from"module";const a=async n=>{try{return(await import(t(e(process.cwd(),n)).href)).default}catch(e){throw Error(`Error loading config: ${e.message}`)}},o=e=>{if(e===`all`)return`all`;let t={b:`bump`,l:`changelog`,m:`commit`,t:`tag`};return e.split(``).map(e=>{if(!(e in t))throw Error(`Invalid lifecycle step alias: '${e}'`);return t[e]})};import.meta.main&&(i(`./resolver.js`,import.meta.url),await s());async function s(e,t){typeof e==`string`&&(e=e.split(` `)),e=e?[e].flat():process.argv.slice(2);let i=r({name:`relion`,flags:{lifecycle:{alias:`f`,type:String,description:`Lifecycle steps to run in order ((b)ump, change(l)og, co(m)mit, (t)ag, or "all").`},config:{alias:`c`,type:String,description:`Path to the config file`,default:`relion.config.ts`},profile:{alias:`p`,type:String,description:`Use config profile`},dry:{alias:`d`,type:Boolean,description:`Run without making any changes`},latest:{alias:`L`,type:Boolean,description:`Use the latest-release commit range in changelog`,default:!1}}},void 0,[...e]);if(!i)return;t=t?structuredClone(t):await a(i.flags.config);let s,c=i.flags.profile??t.profile;if(c){let e=t[`_${c}`];if(!e)throw Error(`Profile '${c}' not found in config`);t.profile=c,s=e}else s=t._default??={};return i.flags.lifecycle&&(s.lifecycle=o(i.flags.lifecycle)),i.flags.dry&&(s.dryRun=!0),i.flags.latest&&(s.changelog??={},s.changelog.commitRange=`latest-release`),{inputConfig:t,...await n(t)}}export{s as runCli};
|
package/dist/index.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ interface UserConfig {
|
|
|
7
7
|
changelog?: ChangelogOptions;
|
|
8
8
|
commit?: CommitOptions;
|
|
9
9
|
tag?: TagOptions;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
tagPrefix?: string;
|
|
11
|
+
tagFormat?: string;
|
|
12
12
|
versionSource?: 'manifestFile' | 'latest-release-tag';
|
|
13
13
|
manifestFile?: string | Bumper;
|
|
14
14
|
commitsScope?: string;
|
|
@@ -22,7 +22,7 @@ interface UserConfig {
|
|
|
22
22
|
logLevel?: 'info' | 'info-clean' | 'silent';
|
|
23
23
|
[profile: `_${string}`]: UserConfig | undefined;
|
|
24
24
|
}
|
|
25
|
-
type OptionalKeys = LifecycleStep | 'releaseType' | 'profile' | '
|
|
25
|
+
type OptionalKeys = LifecycleStep | 'releaseType' | 'profile' | 'tagPrefix';
|
|
26
26
|
interface MergedConfig extends Omit<Required<UserConfig>, OptionalKeys>, Pick<UserConfig, OptionalKeys> {
|
|
27
27
|
lifecycle: LifecycleStep[];
|
|
28
28
|
changelog?: CompleteChangelogOptions;
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import{existsSync as e,readFileSync as t,writeFileSync as n}from"node:fs";import
|
|
|
22
22
|
{{raw}}
|
|
23
23
|
{{~/if}}
|
|
24
24
|
{{~#if @last}}){{else}}, {{/if}}
|
|
25
|
-
{{~/each}}`,changelogUrl:`{{repo.homepage}}/blob/main/CHANGELOG.md#{{tagToUrlFragment tag}}`,breakingChangesIndicator:`<sup>[{{breakingChangeIndex}}]</sup>`}},u={message:`chore(release): {{newTag}}`,signOff:!1,gpgSign:!1,stageAll:!0,extraArgs:null},d={name:`{{newTag}}`,message:`{{commitMessage}}`,gpgSign:!1,force:!1,extraArgs:null},f=[...[{file:/package\.json$/,pattern:/(^.*?"name": "(?<name>.*?)".*"version": ")(?<version>.*?)(")/s,replacement:`$1{{newVersion}}$4`}],{file:/package-lock\.json$/,pattern:/(^.*?"version": "|"packages".*?"".*"version": ")(.*?)(")/gs,replacement:`$1{{newVersion}}$3`}],p={lifecycle:[`bump`,`changelog`,`commit`,`tag`],bump:[`package.json`],versionSource:`manifestFile`,manifestFile:`./package.json`,
|
|
25
|
+
{{~/each}}`,changelogUrl:`{{repo.homepage}}/blob/main/CHANGELOG.md#{{tagToUrlFragment tag}}`,breakingChangesIndicator:`<sup>[{{breakingChangeIndex}}]</sup>`}},u={message:`chore(release): {{newTag}}`,signOff:!1,gpgSign:!1,stageAll:!0,extraArgs:null},d={name:`{{newTag}}`,message:`{{commitMessage}}`,gpgSign:!1,force:!1,extraArgs:null},f=[...[{file:/package\.json$/,pattern:/(^.*?"name": "(?<name>.*?)".*"version": ")(?<version>.*?)(")/s,replacement:`$1{{newVersion}}$4`}],{file:/package-lock\.json$/,pattern:/(^.*?"version": "|"packages".*?"".*"version": ")(.*?)(")/gs,replacement:`$1{{newVersion}}$3`}],p={lifecycle:[`bump`,`changelog`,`commit`,`tag`],bump:[`package.json`],versionSource:`manifestFile`,manifestFile:`./package.json`,tagFormat:`v{{version}}`,commitsScope:`.`,prevReleaseTagPattern:/^v?(?<version>\d+\.\d+\.\d+)/,zeroMajorBreakingIsMinor:!0,dryRun:!1,logLevel:`info`,context:{commitRefLinks:!0,footerChangelogUrl:!1},commitsParser:{headerPattern:/^(?<type>\w+)(?:\((?<scope>.+)\))?(?<bang>!)?: (?<subject>.+)/s,breakingChangesPattern:/^BREAKING CHANGES?:\s*(?<content>.+)/ms,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}},m=e=>C(v(_(g(h(e))))),h=e=>{let t=e.profile??`default`,n=e[`_${t}`];if(!n){if(e.profile===void 0)return e;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);return n&&r?{...e,...t}:t??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`)}},g=e=>{let t=e.lifecycle??p.lifecycle;return t=t===`all`?[`bump`,`changelog`,`commit`,`tag`]:[...new Set(t)],{...p,...e,lifecycle:t,commitsParser:{...p.commitsParser,...e.commitsParser},bump:t.includes(`bump`)?e.bump??p.bump:void 0,changelog:t.includes(`changelog`)?{...l,...e.changelog,partials:{...l.partials,...e.changelog?.partials},helpers:{...l.helpers,...e.changelog?.helpers}}:void 0,commit:t.includes(`commit`)?{...u,...e.commit}:void 0,tag:t.includes(`tag`)?{...d,...e.tag}:void 0,context:{...p.context,...e.context}}},_=e=>{let t=e=>{if(typeof e==`object`)return e;let t=f.find(t=>t.file.test(e));if(t)return{...t,file:e};throw Error(`File ${e} doesn't match any default versioned files. Please provide a custom pattern for this file.`)},n=t(e.manifestFile),r=e.changelog?.releasePattern,i=e.tag?.message;return{...e,manifestFile:n,bump:e.lifecycle.includes(`bump`)?e.bump?e.bump.map(t):[n]:void 0,changelog:e.changelog?{...e.changelog,compiledPartials:Z(e.changelog,e.context),latestReleasePattern:new RegExp(r.source.replace(`{{version}}`,``),r.flags)}:void 0,tag:e.tag?{...e.tag,message:i===`{{commitMessage}}`?e.commit?.message??i:i}:void 0}},v=e=>{let n=e.context,r=V(e.commitsParser.remoteUrlPattern),i=e.manifestFile.pattern.exec(t(e.manifestFile.file,`utf-8`))?.groups,a=n.currentVersion??(e.versionSource===`latest-release-tag`?T(W(e.prevReleaseTagPattern)[0],e.prevReleaseTagPattern)??`0.0.0`:w(e.manifestFile));q(`Current version (from ${e.versionSource===`latest-release-tag`?`latest release tag`:`'${e.manifestFile.file}'`}): '${a}'`);let o=n.currentTag??W(e.prevReleaseTagPattern)[0],s=n.newVersion??ee(e,a,e.commitsScope),c=n.newTag??(e.tagPrefix===void 0?e.tagFormat.replace(`{{version}}`,s):e.tagPrefix+s),l=e.changelog?e.changelog.commitRange:`unreleased`,u=y(n.commits?n.commits.map(t=>typeof t==`object`&&`message`in t||typeof t==`string`?M(t,e.commitsParser,e.prevReleaseTagPattern):t).filter(e=>e!=null):j(l,e.commitsParser,e.prevReleaseTagPattern,e.commitsScope),c,e.commitsParser.revertCommitBodyPattern),d=e.changelog?b(u,e.changelog.sections,e.prevReleaseTagPattern,e.changelog.groupCommitsByScope,e.changelog.maxLinesPerRelease):null,{commits:f,...p}=n;return{...e,context:{currentVersion:a,currentTag:o,newVersion:s,newTag:c,commits:u,releases:d,commitRefLinks:n.commitRefLinks??!0,footerChangelogUrl:n.footerChangelogUrl??!1,...p,repo:{...r,...e.context.repo},package:{...i,...e.context.package}}}},y=(e,t,n)=>{let r=0,i=[];return e.map(a=>{let o=null,s=e.findIndex(e=>e.type===`revert`&&n.exec(e.body??``)?.groups?.hash===a.hash),c=s===-1?void 0:e[s];if(c&&(o=c.associatedReleaseTag===a.associatedReleaseTag?`inTheSameRelease`:`inOtherRelease`),o===`inTheSameRelease`){i.push(s);return}return{...a,associatedReleaseTag:a.associatedReleaseTag??t,isReverted:a.isReverted??o,breakingChangeIndex:a.breakingChanges?++r:void 0}}).filter((e,t)=>!!e&&!i.includes(t))},b=(e,t,n,r,i)=>{i??=l.maxLinesPerRelease;let a={};return e.forEach(e=>{let t=e.associatedReleaseTag;t in a?a[t].commits.push(e):a[t]={tag:t,version:T(t,n),date:e.date,commits:[e]}}),Object.values(a).map(({commits:e,...n})=>{let a=x(e,t,r);if(Object.keys(a).length===0)return;let o=0,s=!1,c={};for(let[e,t]of Object.entries(a))t.show??=`limit-or-breaking`,o+t.commits.length>i&&Object.keys(c).length&&(s=!0),t.show!==`never`&&(t.show===`only-breaking`||t.show===`limit-or-breaking`&&s?(t.commits=t.commits.filter(e=>!!e.breakingChanges),t.commits.length&&(t.scopeGroups=S(t.commits),c[e]=t,o+=t.commits.length)):(t.show===`always`||!s)&&(c[e]=t,o+=t.commits.length));return{...n,commitTypeGroups:c}}).filter(e=>!!e)},x=(e,t,n)=>{let r=Object.fromEntries(Object.entries(t).map(([e,{filter:t,...n}])=>[e,{...n,commits:[]}]));e.forEach(e=>{let n=!!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(n&&!a&&s.includes(`breaking`)){r[o].commits.push(e),a=!0;continue}if(!i&&(s.includes(e.type)||s.includes(`*`))&&(r[o].commits.push(e),i=!0),i&&(!n||a))return}});let i=Object.entries(r).filter(([e,t])=>t.commits.length);return Object.fromEntries(n?i.map(([e,t])=>[e,{...t,scopeGroups:S(t.commits)}]):i)},S=e=>{let t={};return e.forEach(e=>{let n=e.scope??``;t[n]??=[],t[n].push(e)}),Object.entries(t).map(([e,t])=>({scope:e,commits:t}))},C=e=>({...e,commit:e.commit?{...e.commit,message:r.compile(e.commit.message)(e.context)}:e.commit,tag:e.tag?{...e.tag,name:r.compile(e.tag.name)(e.context),message:r.compile(e.tag.message)(e.context)}:e.tag}),w=e=>{let n=t(e.file,`utf8`),r=e.pattern.exec(n)?.groups?.version;if(!r)throw Error(`Version not found in '${e.file}' with pattern '${e.pattern}'`);if(!i.valid(r))throw Error(`Invalid version format in '${e.file}': '${r}'`);return r},T=(e,t)=>t.exec(e)?.groups?.version,ee=(e,t,n)=>{if(e.context.newVersion){if(!i.valid(e.context.newVersion))throw Error(`Invalid release version format: '${e.context.newVersion}'`);return e.context.newVersion}let r;e.releaseType?r=e.releaseType:(r=E(j(`unreleased`,e.commitsParser,e.prevReleaseTagPattern,n)),e.zeroMajorBreakingIsMinor&&i.major(t)===0&&r===`major`&&(r=`minor`));let a=D(t,r);return q(`Determined new version: '${a}' (release type: '${r}')`),a},E=e=>e.some(e=>e.breakingChanges)?`major`:e.some(e=>e.type===`feat`)?`minor`:`patch`,D=(e,t)=>i.inc(e,t)??(()=>{throw Error(`Failed to calculate new version from '${e}' with release type '${t}'`)})();let O=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 k=new Map;let A;const j=(e,t,n,r)=>{n??=p.prevReleaseTagPattern;let i=Array.isArray(e)?e:H(e,n,r),a=t??p.commitsParser,o=i.map(e=>M(e,a,n)).filter(e=>e!==null);return A=void 0,o},M=(e,t,n)=>{t??=p.commitsParser,n??=p.prevReleaseTagPattern,typeof e==`string`&&(e={message:e});let{tagRefs:r,hash:i=N(e.message)}=e;if(k.has(i))return k.get(i)??null;let a=e.message.trim();if(!a)throw Error(`Message is missing for commit: ${JSON.stringify(e)}`);let o;try{o=P(a,t)}catch(e){return J(`Error parsing commit '${i}':`,e.message),null}let{type:s,scope:c,subject:l,body:u,breakingChanges:d,footer:f}=o,m=r?[...r.matchAll(t.tagPattern)].map(e=>e.groups?.tag??``):[],h=f?[...f.matchAll(t.signerPattern)].map(e=>e.groups):[],g=[],_=e=>{g.some(t=>t.email===e.email)||g.push(e)},v=e.authorName&&e.authorEmail?I({name:e.authorName,email:e.authorEmail},h):void 0;v&&_(v);let y=e.committerName&&e.committerEmail?I({name:e.committerName,email:e.committerEmail},h):void 0;y&&_(y),(f?[...f.matchAll(t.coAuthorPattern)].map(e=>e.groups).map(e=>I(e,h)):[]).forEach(e=>_(e));let b=L(f??``,t),x=e.gpgSigCode?{code:e.gpgSigCode,label:O[e.gpgSigCode],keyId:e.gpgSigKeyId}:void 0,S=e[t.dateSource===`committerDate`?`committerTs`:`authorTs`];typeof S==`string`&&(S=R(new Date(S*1e3),t.dateFormat));let C=m.find(e=>n.exec(e)),w=C??A;w&&(A=w);let T={hash:i,type:s,scope:c,subject:l,body:u,breakingChanges:d,footer:f,committer:y,gpgSig:x,date:S,releaseTag:C,associatedReleaseTag:w,tags:m.length?m:void 0,authors:g.length?g:void 0,refs:b.length?b:void 0};return i&&!k.has(i)&&k.set(i,T),T},N=e=>`fake_`+a(`sha256`).update(e,`utf8`).digest(`hex`).slice(0,7),P=(e,t)=>{let[n,...r]=e.split(`
|
|
26
26
|
|
|
27
27
|
`),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=F(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(`
|
|
28
28
|
|
package/dist/resolver.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{dirname as e,resolve as t}from"node:path";import{fileURLToPath as n,pathToFileURL as r}from"node:url";const i=(i,a,o)=>{if(!/^\.{1,2}\//.test(i)||!a.parentURL)return o(i,a);let s=r(t(e(n(a.parentURL)),i+`.ts`)).href;return o(s,a)};export{i as resolve};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "relion",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Release workflow helper.",
|
|
5
5
|
"author": "Kh4f <kh4f.dev@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,8 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"handlebars": "^4.7.8",
|
|
35
35
|
"semver": "^7.7.3",
|
|
36
|
-
"cleye": "^1.3.4"
|
|
37
|
-
"tsx": "^4.20.6"
|
|
36
|
+
"cleye": "^1.3.4"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
39
|
"@eslint/js": "^9.38.0",
|
|
@@ -45,10 +44,11 @@
|
|
|
45
44
|
"globals": "^16.4.0",
|
|
46
45
|
"lint-staged": "^16.2.4",
|
|
47
46
|
"simple-git-hooks": "^2.13.1",
|
|
48
|
-
"tsdown": "^0.15.
|
|
47
|
+
"tsdown": "^0.15.8",
|
|
49
48
|
"typescript": "^5.9.3",
|
|
49
|
+
"tsx": "^4.20.6",
|
|
50
50
|
"typescript-eslint": "^8.46.1",
|
|
51
|
-
"vitest": "^
|
|
51
|
+
"vitest": "^4.0.1"
|
|
52
52
|
},
|
|
53
53
|
"simple-git-hooks": {
|
|
54
54
|
"pre-commit": "pnpm lint-staged"
|