@anolilab/multi-semantic-release 2.0.6 → 3.0.0-alpha.2
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/CHANGELOG.md +34 -0
- package/README.md +1 -1
- package/dist/bin/cli.js +2 -0
- package/dist/multi-semantic-release.d.ts +122 -0
- package/dist/multi-semantic-release.js +1 -0
- package/dist/packem_shared/multi-semantic-release-CD0fW8rP.js +4 -0
- package/package.json +13 -9
- package/bin/cli.js +0 -108
- package/lib/create-inline-plugin-creator.js +0 -268
- package/lib/get-commits-filtered.js +0 -85
- package/lib/get-config-multi-semrel.js +0 -78
- package/lib/get-config-semantic.js +0 -38
- package/lib/get-config.js +0 -33
- package/lib/get-manifest.js +0 -89
- package/lib/logger.js +0 -80
- package/lib/multi-semantic-release.js +0 -291
- package/lib/rescoped-stream.js +0 -31
- package/lib/update-deps.js +0 -351
- package/lib/utils/blork.js +0 -23
- package/lib/utils/clean-path.js +0 -23
- package/lib/utils/get-version.js +0 -38
- package/lib/utils/merge-config.js +0 -21
- package/lib/utils/recognize-format.js +0 -24
- package/lib/utils/stream-to-array.js +0 -76
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
## @anolilab/multi-semantic-release [3.0.0-alpha.2](https://github.com/anolilab/semantic-release/compare/@anolilab/multi-semantic-release@3.0.0-alpha.1...@anolilab/multi-semantic-release@3.0.0-alpha.2) (2025-10-21)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* add yargs types and update multi-semantic-release configurations ([263f552](https://github.com/anolilab/semantic-release/commit/263f5528b88c34f02cd8f4c8cf435bc617b106f1))
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
* update package manager and dependencies across multiple configurations ([07a4e0b](https://github.com/anolilab/semantic-release/commit/07a4e0be0c8ba0b8fc79f5d922bb62f60db38350))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Dependencies
|
|
13
|
+
|
|
14
|
+
* **@anolilab/semantic-release-clean-package-json:** upgraded to 4.0.0-alpha.2
|
|
15
|
+
* **@anolilab/semantic-release-pnpm:** upgraded to 3.0.0-alpha.2
|
|
16
|
+
|
|
17
|
+
## @anolilab/multi-semantic-release [3.0.0-alpha.1](https://github.com/anolilab/semantic-release/compare/@anolilab/multi-semantic-release@2.0.6...@anolilab/multi-semantic-release@3.0.0-alpha.1) (2025-10-14)
|
|
18
|
+
|
|
19
|
+
### ⚠ BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* - node-versions: the minimum node version for the v24 range is now v24.10.0
|
|
22
|
+
- deps: a minimum of node v22.14 is now required
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* update dependencies and node version across multiple packages ([3cea078](https://github.com/anolilab/semantic-release/commit/3cea078f8aa27d0873e082bc54c4c5117e5105bf))
|
|
27
|
+
* update Node.js version and dependencies across workflows and lock files ([4871a7d](https://github.com/anolilab/semantic-release/commit/4871a7d7282d69e5612ab4d01ef9696dd94cab85))
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
### Dependencies
|
|
31
|
+
|
|
32
|
+
* **@anolilab/semantic-release-clean-package-json:** upgraded to 4.0.0-alpha.1
|
|
33
|
+
* **@anolilab/semantic-release-pnpm:** upgraded to 3.0.0-alpha.1
|
|
34
|
+
|
|
1
35
|
## @anolilab/multi-semantic-release [2.0.6](https://github.com/anolilab/semantic-release/compare/@anolilab/multi-semantic-release@2.0.5...@anolilab/multi-semantic-release@2.0.6) (2025-10-07)
|
|
2
36
|
|
|
3
37
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ multi-semantic-release
|
|
|
67
67
|
|
|
68
68
|
## Requirements
|
|
69
69
|
|
|
70
|
-
- Node.js >=
|
|
70
|
+
- Node.js ^22.14.0 || >=24.10.0
|
|
71
71
|
- [git-notes enabled](https://github.com/semantic-release/semantic-release/blob/2e4b901c4f412980a425469fae49cfaef500d47a/docs/support/troubleshooting.md#release-not-found-release-branch-after-git-push---force)
|
|
72
72
|
|
|
73
73
|
### yarn / npm (v7+)
|
package/dist/bin/cli.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var b=Object.defineProperty;var r=(e,t)=>b(e,"name",{value:t,configurable:!0});import{createRequire as f}from"node:module";import j from"yargs";import{hideBin as k}from"yargs/helpers";import{B as x,d as a}from"../packem_shared/multi-semantic-release-CD0fW8rP.js";const n=f(import.meta.url),c=r(e=>{if(process.versions?.node){const[t,o]=process.versions.node.split(".").map(Number);if(t>22||t===22&&o>=3||t===20&&o>=16)return process.getBuiltinModule(e)}return n(e)},"__cjs_getBuiltinModule"),m=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{existsSync:g,lstatSync:y}=c("node:fs"),{Writable:h}=c("node:stream"),{checker:v,add:l}=n("blork"),{WritableStreamBuffer:_}=n("stream-buffers"),{exit:s}=m,S=v("absolute");l("directory",e=>S(e)&&g(e)&&y(e).isDirectory(),"directory that exists in the filesystem");l("stream",e=>e instanceof h||e instanceof _,"instance of stream.Writable or WritableStreamBuffer");var O=Object.defineProperty,B=r((e,t)=>O(e,"name",{value:t,configurable:!0}),"n");const p={array:!0,coerce:B(e=>e.length===1&&e[0].trim()==="false"?[]:e.reduce((t,o)=>t.concat(o.split(",").map(i=>i.trim())),[]),"coerce"),type:"string"};await(async()=>{const e=j(k(process.argv)).usage("$0 [args]").scriptName("multi-semantic-release").option("d",{alias:"dry-run",describe:"Skip publishing",group:"Options",type:"boolean"}).option("h",{alias:"help",group:"Options"}).option("debug",{describe:"Output debugging information.",type:"boolean"}).option("silent",{describe:"Do not print configuration information.",type:"boolean"}).option("sequential-init",{describe:"Avoid hypothetical concurrent initialization collisions.",type:"boolean"}).option("sequential-prepare",{describe:"Avoid hypothetical concurrent preparation collisions. Do not use if your project have cyclic dependencies.",type:"boolean"}).option("first-parent",{describe:"Apply commit filtering to current branch only.",type:"boolean"}).option("deps.bump",{describe:"Define deps version updating rule. Allowed: override, satisfy, inherit.",type:"string"}).option("deps.release",{describe:"Define release type for dependent package if any of its deps changes. Supported values: patch, minor, major, inherit.",type:"string"}).option("deps.prefix",{describe:"Optional prefix to be attached to the next dep version if '--deps.bump' set to 'override'. Supported values: '^' | '~' | '' (empty string as default).",type:"string"}).option("b",{alias:"branches",describe:"Git branches to release from",...p,group:"Options"}).option("ci",{describe:"Toggle CI verifications",group:"Options",type:"boolean"}).option("ignore-packages",{...p,describe:"Packages list to be ignored on bumping process"}).option("ignore-private",{describe:"Exclude private packages. Enabled by default, pass 'no-ignore-private' to disable.",type:"boolean"}).option("tag-format",{describe:'Format to use for creating tag names. Should include "name" and "version" vars. Default: "${name}@${version}" generates "package-name@1.0.0"',type:"string"}).strict(!1).exitProcess(!1);try{const{_:t,help:o,version:i,...d}=e.parse(process.argv.slice(2));if(o||i)return 0;x(null,{},{},d).then(()=>{s(0)},u=>{a.error("[multi-semantic-release]:",u),s(1)})}catch(t){a.error("[multi-semantic-release]:",t),s(1)}})();
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Writable } from 'node:stream';
|
|
2
|
+
|
|
3
|
+
interface PackageManifest {
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
dependencies?: Record<string, string>;
|
|
6
|
+
devDependencies?: Record<string, string>;
|
|
7
|
+
name: string;
|
|
8
|
+
optionalDependencies?: Record<string, string>;
|
|
9
|
+
peerDependencies?: Record<string, string>;
|
|
10
|
+
private?: boolean;
|
|
11
|
+
version: string;
|
|
12
|
+
}
|
|
13
|
+
interface Commit {
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
committerDate: Date;
|
|
16
|
+
gitTags: string;
|
|
17
|
+
hash: string;
|
|
18
|
+
message: string;
|
|
19
|
+
subject: string;
|
|
20
|
+
}
|
|
21
|
+
interface Package {
|
|
22
|
+
_analyzed?: boolean;
|
|
23
|
+
_branch?: string;
|
|
24
|
+
_depsUpdated?: boolean;
|
|
25
|
+
_lastRelease?: Release;
|
|
26
|
+
_nextRelease?: Release;
|
|
27
|
+
_nextType?: string | null;
|
|
28
|
+
_prepared?: boolean;
|
|
29
|
+
_preRelease?: string | null;
|
|
30
|
+
_published?: boolean;
|
|
31
|
+
_ready?: boolean;
|
|
32
|
+
deps: string[];
|
|
33
|
+
dir: string;
|
|
34
|
+
fakeLogger: {
|
|
35
|
+
error: () => void;
|
|
36
|
+
log: () => void;
|
|
37
|
+
};
|
|
38
|
+
localDeps: Package[];
|
|
39
|
+
manifest: PackageManifest;
|
|
40
|
+
name: string;
|
|
41
|
+
options: Record<string, unknown>;
|
|
42
|
+
path: string;
|
|
43
|
+
plugins: PluginFunctions;
|
|
44
|
+
result?: ReleaseResult | false | undefined;
|
|
45
|
+
}
|
|
46
|
+
interface Release {
|
|
47
|
+
[key: string]: unknown;
|
|
48
|
+
channel?: string;
|
|
49
|
+
gitHead?: string;
|
|
50
|
+
gitTag?: string;
|
|
51
|
+
notes?: string;
|
|
52
|
+
version: string;
|
|
53
|
+
}
|
|
54
|
+
interface ReleaseResult {
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
commits?: Commit[];
|
|
57
|
+
lastRelease?: Release;
|
|
58
|
+
nextRelease?: Release;
|
|
59
|
+
releases?: Release[];
|
|
60
|
+
}
|
|
61
|
+
interface PluginFunctions {
|
|
62
|
+
analyzeCommits?: (pluginOptions: Record<string, unknown>, context: SemanticReleaseContext) => Promise<string | null | undefined>;
|
|
63
|
+
generateNotes?: (pluginOptions: Record<string, unknown>, context: SemanticReleaseContext) => Promise<string>;
|
|
64
|
+
prepare?: (pluginOptions: Record<string, unknown>, context: SemanticReleaseContext) => Promise<void>;
|
|
65
|
+
publish?: (pluginOptions: Record<string, unknown>, context: SemanticReleaseContext) => Promise<unknown>;
|
|
66
|
+
verifyConditions?: (pluginOptions: Record<string, unknown>, context: SemanticReleaseContext) => Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
interface SemanticReleaseContext {
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
branch?: Branch;
|
|
71
|
+
commits?: Commit[];
|
|
72
|
+
cwd: string;
|
|
73
|
+
env: Record<string, string>;
|
|
74
|
+
lastRelease?: Release;
|
|
75
|
+
logger?: Record<string, unknown>;
|
|
76
|
+
nextRelease?: Release;
|
|
77
|
+
options: Record<string, unknown> & {
|
|
78
|
+
_pkgOptions?: Record<string, unknown>;
|
|
79
|
+
};
|
|
80
|
+
stderr: Writable;
|
|
81
|
+
stdout: Writable;
|
|
82
|
+
}
|
|
83
|
+
interface Branch {
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
name: string;
|
|
86
|
+
prerelease?: string | null;
|
|
87
|
+
}
|
|
88
|
+
interface MultiReleaseConfig {
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
branches?: string[] | string;
|
|
91
|
+
ci?: boolean;
|
|
92
|
+
debug?: boolean;
|
|
93
|
+
deps?: {
|
|
94
|
+
bump?: "override" | "satisfy" | "inherit";
|
|
95
|
+
prefix?: string;
|
|
96
|
+
release?: "patch" | "minor" | "major" | "inherit";
|
|
97
|
+
};
|
|
98
|
+
dryRun?: boolean;
|
|
99
|
+
firstParent?: boolean;
|
|
100
|
+
ignorePackages?: string[];
|
|
101
|
+
ignorePrivate?: boolean;
|
|
102
|
+
sequentialInit?: boolean;
|
|
103
|
+
sequentialPrepare?: boolean;
|
|
104
|
+
silent?: boolean;
|
|
105
|
+
tagFormat?: string;
|
|
106
|
+
}
|
|
107
|
+
interface InputOptions {
|
|
108
|
+
[key: string]: unknown;
|
|
109
|
+
}
|
|
110
|
+
interface Flags extends MultiReleaseConfig {
|
|
111
|
+
[key: string]: unknown;
|
|
112
|
+
logLevel?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
declare const multiSemanticRelease: (paths?: string[] | null, inputOptions?: InputOptions, { cwd, env: environment, stderr, stdout, }?: {
|
|
116
|
+
cwd?: string;
|
|
117
|
+
env?: NodeJS.ProcessEnv;
|
|
118
|
+
stderr?: NodeJS.WriteStream;
|
|
119
|
+
stdout?: NodeJS.WriteStream;
|
|
120
|
+
}, _flags?: Flags) => Promise<Package[]>;
|
|
121
|
+
|
|
122
|
+
export { multiSemanticRelease as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{createRequire as e}from"node:module";import"@semrel-extra/topo";import"lodash-es";import"semantic-release";import"semantic-release/package.json"with{type:"json"};import{B as _}from"./packem_shared/multi-semantic-release-CD0fW8rP.js";const o=e(import.meta.url);const i=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process;o("blork");export{_ as default};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var ie=Object.defineProperty;var f=(e,t)=>ie(e,"name",{value:t,configurable:!0});import{createRequire as ce}from"node:module";import{topo as me}from"@semrel-extra/topo";import{transform as fe,isEqual as ve,isObject as I,pickBy as J,castArray as H,sortBy as be,template as he}from"lodash-es";import ye from"semantic-release";import $e from"semantic-release/package.json"with{type:"json"};import{getTagHead as we}from"semantic-release/lib/git.js";import{execa as Re}from"execa";import Oe from"detect-indent";import{detectNewline as De}from"detect-newline";import Ee from"semantic-release/lib/get-config.js";const R=ce(import.meta.url),V=f(e=>{if(process.versions?.node){const[t,r]=process.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return process.getBuiltinModule(e)}return R(e)},"__cjs_getBuiltinModule"),Ct=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,{normalize:le,join:de,isAbsolute:pe,relative:ue,dirname:ge}=V("node:path"),{existsSync:F,lstatSync:z,readFileSync:_e,writeFileSync:je}=V("node:fs"),G=R("git-log-parser"),E=R("debug"),Y=R("signale"),{check:h,ValueError:C}=R("blork"),j=R("semver"),{gt:Pe,prerelease:xe,rcompare:ke}=j,{cosmiconfig:Z}=R("cosmiconfig"),{createRequire:Te}=V("node:module"),Se=R("resolve-from"),{WritableStreamBuffer:Ce}=R("stream-buffers"),{Writable:Ne}=V("node:stream"),He="3.0.0-alpha.1",Le={version:He};var Ve=Object.defineProperty,Me=f((e,t)=>Ve(e,"name",{value:t,configurable:!0}),"i$4");const{Signale:qe}=Y,W=["error","warn","info","debug","trace"],M=Me((e,t)=>W.indexOf(e)<=W.indexOf(t),"assertLevel"),Q={complete:"info",failure:"error",log:"info",success:"info"},b={config:{_level:"info",_signale:{},_stderr:process.stderr,_stdout:process.stdout,set level(e){e&&(M(e,"debug")&&E.enable("msr:"),M(e,"trace")&&E.enable("semantic-release:"),this._level=e)},get level(){return this._level},set stdio([e,t]){this._stdout=t,this._stderr=e,this._signale=new qe({config:{displayLabel:!1,displayTimestamp:!0},stream:t,types:{complete:{badge:"🎉",color:"green",label:"",stream:[t]},error:{color:"red",label:"",stream:[e]},log:{badge:"•",color:"magenta",label:"",stream:[t]},success:{color:"green",label:"",stream:[t]}}})},get stdio(){return[this._stderr,this._stdout]}},prefix:"msr:",withScope(e){return{...this,debug:E(e||this.prefix),prefix:e}},...[...W,...Object.keys(Q)].reduce((e,t)=>(e[t]=function(...r){M(Q[t]||t,this.config.level)&&(this.config._signale[t]||console[t]||(()=>{}))(this.prefix,...r)},e),{}),debug:E("msr:")};var Be=Object.defineProperty,Fe=f((e,t)=>Be(e,"name",{value:t,configurable:!0}),"o$4");const S=Fe((e,t=process.cwd())=>(h(e,"path: path"),h(t,"cwd: absolute"),le(pe(e)?e:de(t,e)).replace(/[/\\]+$/u,"")),"cleanPath");var ze=Object.defineProperty,T=f((e,t)=>ze(e,"name",{value:t,configurable:!0}),"o$3");const We=T(e=>e.readable?new Promise((t,r)=>{if(!e.readable){t([]);return}let n=[];const s=T(()=>{n=[],e.removeListener("data",o),e.removeListener("end",c),e.removeListener("error",i),e.removeListener("close",d)},"cleanup"),o=T(u=>{n.push(u)},"onData"),c=T(()=>{t(n),s()},"onEnd"),i=T(u=>{r(u),s()},"onError"),d=T(()=>{t(n),s()},"onClose");e.on("data",o),e.on("end",c),e.on("error",i),e.on("close",d)}):Promise.resolve([]),"default");var Ae=Object.defineProperty,Ie=f((e,t)=>Ae(e,"name",{value:t,configurable:!0}),"f");const{debug:U}=b.withScope("msr:commitsFilter"),q=Ie(async(e,t,r,n,s)=>{if(h(e,"cwd: directory"),!F(e)||!z(e).isDirectory())throw new C("cwd: Must be an absolute path to an existing directory",e);if(h(t,"dir: path"),t=S(t,e),!F(t)||!z(t).isDirectory())throw new C("dir: Must be a path to an existing directory",t);if(e=S(e),t=S(t,e),h(t,"dir: directory"),h(r,"lastRelease: alphanumeric{40}?"),h(n,"nextRelease: alphanumeric{40}?"),t.indexOf(e)!==0)throw new C("dir: Must be inside cwd",t);if(t===e)throw new C("dir: Must not be equal to cwd",t);const o=await Re("git",["rev-parse","--show-toplevel"],{cwd:e});Object.assign(G.fields,{committerDate:{key:"ci",type:Date},gitTags:"d",hash:"H",message:"B"});const c=ue(o.stdout,t),i=s?["--first-parent",s]:[],d=(r?`${r}..`:"")+(n||"HEAD"),u=[...i,d,"--",c],m=G.parse({_:u},{cwd:e,env:process.env}),a=await We(m);return a.forEach(l=>{l.message=l.message.trim(),l.gitTags=l.gitTags.trim()}),U("git log filter query: %o",u),U("filtered commits: %O",a),a},"getCommitsFiltered");var Je=Object.defineProperty,A=f((e,t)=>Je(e,"name",{value:t,configurable:!0}),"r$2");const Ge=A(e=>{if(!F(e))throw new ReferenceError(`package.json file not found: "${e}"`);let t;try{t=z(e)}catch{throw new ReferenceError(`package.json cannot be read: "${e}"`)}if(!t.isFile())throw new ReferenceError(`package.json is not a file: "${e}"`);try{return _e(e,"utf8")}catch{throw new ReferenceError(`package.json cannot be read: "${e}"`)}},"readManifest"),ee=A(e=>{const t=Ge(e);let r;try{r=JSON.parse(t)}catch{throw new SyntaxError(`package.json could not be parsed: "${e}"`)}if(typeof r!="object"||r===null)throw new SyntaxError(`package.json was not an object: "${e}"`);if(typeof r.name!="string"||r.name.length===0)throw new SyntaxError(`Package name must be non-empty string: "${e}"`);const n=A(s=>{if(r.hasOwnProperty(s)&&typeof r[s]!="object")throw new SyntaxError(`Package ${s} must be object: "${e}"`)},"checkDeps");return n("dependencies"),n("devDependencies"),n("peerDependencies"),n("optionalDependencies"),Object.defineProperty(r,"__contents__",{enumerable:!1,value:t}),r},"default");var Qe=Object.defineProperty,te=f((e,t)=>Qe(e,"name",{value:t,configurable:!0}),"r$1");const Ue=te((e,t,r)=>e&&t&&r?e(t,r)?t:r:t||r,"_selectVersionBy"),Ke=Ue.bind(null,Pe),Xe=te((e,t)=>e.filter(r=>t||!xe(r)).sort(ke)[0],"getLatestVersion");var Ye=Object.defineProperty,Ze=f((e,t)=>Ye(e,"name",{value:t,configurable:!0}),"e$1");const et=Ze(e=>({indent:Oe(e).indent,trailingWhitespace:De(e)||""}),"recognizeFormat");var tt=Object.defineProperty,y=f((e,t)=>tt(e,"name",{value:t,configurable:!0}),"o$2");const{debug:B}=b.withScope("msr:updateDeps"),rt=y((e,t,r)=>{const n=e?j.inc(e,"prerelease",r):null,s=j.inc(t,"prerelease",r);return n?Ke(s,n):s},"_nextPreHighestVersion"),st=y((e,t,r,n)=>{if(!j.prerelease(t)){const o=j.parse(t);if(!o)return;const{major:c,minor:i,patch:d}=o;return`${j.inc(`${c}.${i}.${d}`,r||"patch")}-${n}.1`}const s=Xe(e,!0);return rt(s,t,n)},"_nextPreVersionCases"),at=y((e,t,r,n,s)=>{const o=["patch","minor","major"],{localDeps:c,manifest:i={}}=e,d=e._lastRelease?.version,{dependencies:u={},devDependencies:m={},optionalDependencies:a={},peerDependencies:l={}}=i,$=[u,m,l,a],P=y((p,g,v)=>{const x=p[g];if(!v||!x)return!1;const k=dt(x,v,t,s);return x!==k?(p[g]=k,!0):!1},"bumpDependency");return c.filter(p=>!n.includes(p)).reduce((p,g)=>{const v=se(g,t,r,[...n,e],s),x=v?g._preRelease?lt(g):it(g):g._lastRelease?.version;return $.reduce((k,oe)=>P(oe,g.name,x)||k,!d)&&o.indexOf(v)>o.indexOf(p)?v:p},void 0)},"getDependentRelease"),nt=y((e,t)=>{if(e.startsWith("workspace:")){const r=/^workspace:(([\^~*])?.*)$/u.exec(e);if(!r)return e;const[,n,s]=r;return s===n?s==="*"?t:s+t:n}return e},"substituteWorkspaceVersion"),re=y((e,t)=>fe(e,(r,n,s)=>{ve(n,t[s])||(r[s]=I(n)&&I(t[s])?re(n,t[s]):`${t[s]} → ${n}`)}),"difference"),ot=y((e,t)=>{const r=`[${e.name}]`,n=ee(t),s=["dependencies","devDependencies","peerDependencies","optionalDependencies"].reduce((o,c)=>{const i=re(e[c],n[c]);return Object.keys(i).length>0&&(o[c]=i),o},{});return B(r,"package.json path=",t),Object.keys(s).length>0?(B(r,"changes=",s),!0):(B(r,"no deps changes"),!1)},"auditManifestChanges"),it=y(e=>{const t=e._lastRelease?.version;return t&&typeof e._nextType=="string"?j.inc(t,e._nextType):t||"1.0.0"},"getNextVersion"),ct=y(e=>{const t=j.parse(e);return t&&t.prerelease[0]||null},"getPreReleaseTag"),lt=y(e=>{const t=e._lastRelease?.version,r=ct(t||"");return r!==null&&r!==e._preRelease||!t?`1.0.0-${e._preRelease}.1`:st([],t||"",e._nextType||"patch",e._preRelease||"")},"getNextPreVersion"),se=y((e,t="override",r="patch",n=[],s="")=>{const o=at(e,t,r,n,s);if(e._nextType)return e._nextType;if(o)return e._nextType=r==="inherit"?o:r,e._nextType},"resolveReleaseType"),dt=y((e,t,r="override",n="")=>{if(e=nt(e,t),r==="ignore"||e===t||(r==="satisfy"||r==="inherit")&&j.satisfies(t,e))return e;if(r==="inherit"){const s=t.split(".");return e.split(".").map((o,c)=>s[c]?o.replace(/\d+/u,s[c]):o).join(".")}return n+t},"resolveNextVersion"),pt=y(e=>{const{manifest:t,path:r}=e,{indent:n,trailingWhitespace:s}=et(t.__contents__);t.version=e._nextRelease.version||t.version,e.localDeps.forEach(o=>{const c=o._nextRelease||o._lastRelease;if(!c||!c.version)throw new Error(`Cannot release ${e.name} because dependency ${o.name} has not been released yet`)}),ot(t,r)&&je(r,JSON.stringify(t,null,n)+s)},"updateManifestDeps");var ut=Object.defineProperty,O=f((e,t)=>ut(e,"name",{value:t,configurable:!0}),"i$1");const{debug:D}=b.withScope("msr:inlinePlugin"),gt=O((e,t,r)=>{const{cwd:n}=t;return O(s=>{const{dir:o,name:c,plugins:i}=s,d=`[${c}]`,u={analyzeCommits:O(async(m,a)=>{s._preRelease=a.branch.prerelease||null,s._branch=a.branch.name;const l=r.firstParent?a.branch.name:void 0;return a.commits=await q(n,o,a.lastRelease?a.lastRelease.gitHead:void 0,a.nextRelease?a.nextRelease.gitHead:void 0,l),s._lastRelease=a.lastRelease,s._nextType=await i.analyzeCommits(a),s._analyzed=!0,s._nextType=se(s,r.deps.bump,r.deps.release,[],r.deps.prefix),D(d,"commits analyzed"),D(d,`release type: ${s._nextType}`),s._nextType},"analyzeCommits"),generateNotes:O(async(m,a)=>{s._nextRelease=a.nextRelease;const l=[];a.lastRelease&&a.lastRelease.gitTag&&(!a.lastRelease.gitHead||a.lastRelease.gitHead===a.lastRelease.gitTag)&&(a.lastRelease.gitHead=we(a.lastRelease.gitTag,{cwd:a.cwd,env:a.env}));const $=r.firstParent?a.branch.name:void 0;a.commits=await q(n,o,a.lastRelease?a.lastRelease.gitHead:void 0,a.nextRelease?a.nextRelease.gitHead:void 0,$);const P=await i.generateNotes(a);P&&l.push(P.replace(/^(#+) (\[?\d+\.\d+\.\d+\]?)/u,`$1 ${c} $2`));const p=s.localDeps.filter(g=>g._nextRelease);if(p.length>0){l.push("### Dependencies");const g=p.map(v=>`* **${v.name}:** upgraded to ${v._nextRelease.version}`);l.push(g.join(`
|
|
2
|
+
`))}return D(d,"notes generated"),l.join(`
|
|
3
|
+
|
|
4
|
+
`)},"generateNotes"),prepare:O(async(m,a)=>{pt(s),s._depsUpdated=!0;const l=r.firstParent?a.branch.name:void 0;a.commits=await q(n,o,a.lastRelease?a.lastRelease.gitHead:void 0,a.nextRelease?a.nextRelease.gitHead:void 0,l);const $=await i.prepare(a);return s._prepared=!0,D(d,"prepared"),$},"prepare"),publish:O(async(m,a)=>{const l=await i.publish(a);return s._published=!0,D(d,"published"),l.length>0?l[0]:{}},"publish"),verifyConditions:O(async(m,a)=>{Object.assign(a.options,a.options._pkgOptions),Object.assign(s.fakeLogger,a.logger);const l=await i.verifyConditions(a);return s._ready=!0,D(d,"verified conditions"),l},"verifyConditions")};return Object.keys(u).forEach(m=>Reflect.defineProperty(u[m],"pluginName",{enumerable:!0,value:"Inline plugin",writable:!1})),D(d,"inlinePlugin created"),u},"createInlinePlugin")},"createInlinePluginCreator");var mt=Object.defineProperty,ft=f((e,t)=>mt(e,"name",{value:t,configurable:!0}),"n$1");const w="release",vt=["package.json",`.${w}rc`,`.${w}rc.json`,`.${w}rc.yaml`,`.${w}rc.yml`,`.${w}rc.js`,`.${w}rc.cjs`,`.${w}rc.mjs`,`${w}.config.js`,`${w}.config.cjs`,`${w}.config.mjs`],ae=ft(async e=>(await Z(w,{mergeSearchPlaces:!1,searchPlaces:vt}).search(e))?.config??{},"default");var bt=Object.defineProperty,ne=f((e,t)=>bt(e,"name",{value:t,configurable:!0}),"r");const K=ne(e=>e==null,"isNil"),N=ne((e={},t={})=>({...e,...J(t,r=>!K(r)),deps:{...e.deps,...J(t.deps,r=>!K(r))},ignorePackages:[...new Set([...H(e.ignorePackages||[]),...H(t.ignorePackages||[])])]}),"mergeConfig");var ht=Object.defineProperty,yt=f((e,t)=>ht(e,"name",{value:t,configurable:!0}),"o");const _="multi-release",$t=["package.json",`.${_}rc`,`.${_}rc.json`,`.${_}rc.yaml`,`.${_}rc.yml`,`.${_}rc.js`,`.${_}rc.cjs`,`.${_}rc.mjs`,`${_}.config.js`,`${_}.config.cjs`,`${_}.config.mjs`],wt=yt(async(e,t)=>{const{config:r}=await Z(_,{searchPlaces:$t}).search(e)||{},{extends:n,...s}={...r};let o=s;if(n){const c=Te(import.meta.url),i=H(n).reduce((d,u)=>{const m=c(Se(e,u));return N(d,m)},{});o=N(o,i)}return o=N({branches:void 0,ci:void 0,debug:!1,deps:{bump:"override",prefix:"",release:"patch"},dryRun:void 0,firstParent:!1,ignorePackages:[],ignorePrivate:!0,sequentialInit:!1,sequentialPrepare:!0,silent:!1,tagFormat:"${name}@${version}"},o),N(o,t)},"default");var _t=Object.defineProperty,jt=f((e,t)=>_t(e,"name",{value:t,configurable:!0}),"n");const{Signale:Rt}=Y,Pt=jt(async({cwd:e,env:t,stderr:r,stdout:n},s)=>{try{const o=new Rt({stream:new Ce});return await Ee({cwd:e,env:t,logger:o,stderr:r,stdout:n},s)}catch(o){throw b.failure("Error in semantic-release getConfig(): %0",o),o}},"getConfigSemantic");var xt=Object.defineProperty,kt=f((e,t)=>xt(e,"name",{value:t,configurable:!0}),"i");class X extends Ne{static{f(this,"m")}static{kt(this,"RescopedStream")}_stream;_scope;constructor(t,r){super(),h(r,"scope: string"),h(t,"stream: stream"),this._stream=t,this._scope=r}write(t){h(t,"msg: string"),this._stream.write(t.replace("[semantic-release]",`[${this._scope}]`))}}var Ot=Object.defineProperty,L=f((e,t)=>Ot(e,"name",{value:t,configurable:!0}),"v");const Dt=L(async(e,{cwd:t,env:r,globalOptions:n,inputOptions:s,stderr:o,stdout:c})=>{e=S(e,t);const i=ge(e),d=ee(e),{name:u}=d,m=Object.keys({...d.dependencies,...d.devDependencies,...d.peerDependencies,...d.optionalDependencies}),a=await ae(i),l={...n,...a,...s},$={error(){},log(){}},{options:P,plugins:p}=await Pt({cwd:i,env:r,stderr:o,stdout:c},l);return{deps:m,dir:i,fakeLogger:$,manifest:d,name:u,options:P,path:e,plugins:p}},"getPackage"),Tt=L(async(e,t,r,n)=>{const{dir:s,name:o,options:c}=e,{env:i,stderr:d,stdout:u}=r,m=t(e),a={...c,...m},l={name:o,version:"${version}"},$="${name}@${version}";return a.tagFormat=he(n.tagFormat||$)(l),a.debug=n.debug,a.dryRun=n.dryRun===void 0?a.dryRun:n.dryRun,a.ci=n.ci===void 0?a.ci:n.ci,a.branches=n.branches?H(n.branches):a.branches,a._pkgOptions=c,e.result=await ye(a,{cwd:s,env:i,stderr:new X(d,o),stdout:new X(u,o)}),e},"releasePackage"),Wt=L(async(e,t={},{cwd:r=process.cwd(),env:n=process.env,stderr:s=process.stderr,stdout:o=process.stdout}={},c={})=>{e&&h(e,"paths: string[]"),h(r,"cwd: directory"),h(n,"env: objectlike"),h(o,"stdout: stream"),h(s,"stderr: stream"),r=S(r);const i={deps:{},...await wt(r,c)};b.config.stdio=[s,o],b.config.level=i.logLevel,i.silent&&(b.config.level="silent"),i.debug&&(b.config.level="debug"),b.info(`multi-semantic-release version: ${Le.version}`),b.info(`semantic-release version: ${$e.version}`),i.debug&&b.info(`flags: ${JSON.stringify(i,null,2)}`);const d=await ae(r),u={cwd:r,env:n,globalOptions:d,inputOptions:t,stderr:s,stdout:o},{packages:m,queue:a}=await me({cwd:r,filter:L(({manifest:p,manifestAbsPath:g,manifestRelPath:v})=>(!i.ignorePrivate||!p.private)&&(e?e.includes(g)||e.includes(v):!0),"filter"),workspacesExtra:Array.isArray(i.ignorePackages)?i.ignorePackages.map(p=>`!${p}`):[]});e=e||Object.values(m).map(p=>p.manifestPath),b.complete(`Started multirelease! Loading ${e.length} packages...`);const l=await Promise.all(e.map(p=>Dt(p,u)));l.forEach(p=>{p.localDeps=[...new Set(p.deps.map(g=>l.find(v=>g===v.name)).filter(Boolean))],b.success(`Loaded package ${p.name}`)}),b.complete(`Queued ${a.length} packages! Starting release...`);const $=gt(l,u,i),P=await a.reduce(async(p,g)=>{const v=await p,x=l.find(({name:k})=>k===g);if(x){const{result:k}=await Tt(x,$,u,i);if(k)return v+1}return v},Promise.resolve(0));return b.complete(`Released ${P} of ${a.length} packages, semantically!`),be(l,({name:p})=>a.indexOf(p))},"multiSemanticRelease");export{Wt as B,b as d};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anolilab/multi-semantic-release",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
4
4
|
"description": "A multi semantic release tool for a monorepo.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,20 +9,24 @@
|
|
|
9
9
|
},
|
|
10
10
|
"license": "0BSD",
|
|
11
11
|
"author": "Dave Houlbrooke <dave@shax.com>",
|
|
12
|
+
"sideEffects": [
|
|
13
|
+
"src/utils/blork.ts"
|
|
14
|
+
],
|
|
12
15
|
"type": "module",
|
|
13
16
|
"exports": {
|
|
14
|
-
".":
|
|
15
|
-
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/multi-semantic-release.d.ts",
|
|
19
|
+
"import": "./dist/multi-semantic-release.js"
|
|
20
|
+
},
|
|
16
21
|
"./package.json": "./package.json"
|
|
17
22
|
},
|
|
18
23
|
"bin": {
|
|
19
|
-
"multi-semantic-release": "./bin/cli.js"
|
|
24
|
+
"multi-semantic-release": "./dist/bin/cli.js"
|
|
20
25
|
},
|
|
21
26
|
"files": [
|
|
22
27
|
"CHANGELOG.md",
|
|
23
28
|
"README.md",
|
|
24
|
-
"
|
|
25
|
-
"lib"
|
|
29
|
+
"dist"
|
|
26
30
|
],
|
|
27
31
|
"dependencies": {
|
|
28
32
|
"@semrel-extra/topo": "^1.14.1",
|
|
@@ -35,16 +39,16 @@
|
|
|
35
39
|
"git-log-parser": "^1.2.1",
|
|
36
40
|
"lodash-es": "^4.17.21",
|
|
37
41
|
"resolve-from": "^5.0.0",
|
|
38
|
-
"semver": "^7.7.
|
|
42
|
+
"semver": "^7.7.3",
|
|
39
43
|
"signale": "^1.4.0",
|
|
40
44
|
"stream-buffers": "^3.0.3",
|
|
41
45
|
"yargs": "18.0.0"
|
|
42
46
|
},
|
|
43
47
|
"peerDependencies": {
|
|
44
|
-
"semantic-release": ">=
|
|
48
|
+
"semantic-release": ">=24"
|
|
45
49
|
},
|
|
46
50
|
"engines": {
|
|
47
|
-
"node": ">=
|
|
51
|
+
"node": "^22.14.0 || >=24.10.0"
|
|
48
52
|
},
|
|
49
53
|
"os": [
|
|
50
54
|
"darwin",
|
package/bin/cli.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import { exit } from "node:process";
|
|
4
|
-
|
|
5
|
-
import yargs from "yargs";
|
|
6
|
-
import { hideBin } from "yargs/helpers";
|
|
7
|
-
|
|
8
|
-
import logger from "../lib/logger.js";
|
|
9
|
-
|
|
10
|
-
const stringList = {
|
|
11
|
-
array: true,
|
|
12
|
-
coerce: function coerce(values) {
|
|
13
|
-
// eslint-disable-next-line unicorn/no-array-reduce,unicorn/prefer-spread
|
|
14
|
-
return values.length === 1 && values[0].trim() === "false" ? [] : values.reduce((v, value) => v.concat(value.split(",").map((x) => x.trim())), []);
|
|
15
|
-
},
|
|
16
|
-
type: "string",
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line consistent-return
|
|
20
|
-
await (async () => {
|
|
21
|
-
const cli = yargs(hideBin(process.argv))
|
|
22
|
-
.usage("$0 [args]")
|
|
23
|
-
.scriptName("multi-semantic-release")
|
|
24
|
-
.option("d", { alias: "dry-run", describe: "Skip publishing", group: "Options", type: "boolean" })
|
|
25
|
-
.option("h", { alias: "help", group: "Options" })
|
|
26
|
-
.option("debug", {
|
|
27
|
-
describe: "Output debugging information.",
|
|
28
|
-
type: "boolean",
|
|
29
|
-
})
|
|
30
|
-
.option("silent", {
|
|
31
|
-
describe: "Do not print configuration information.",
|
|
32
|
-
type: "boolean",
|
|
33
|
-
})
|
|
34
|
-
.option("sequential-init", {
|
|
35
|
-
describe: "Avoid hypothetical concurrent initialization collisions.",
|
|
36
|
-
type: "boolean",
|
|
37
|
-
})
|
|
38
|
-
.option("sequential-prepare", {
|
|
39
|
-
describe: "Avoid hypothetical concurrent preparation collisions. Do not use if your project have cyclic dependencies.",
|
|
40
|
-
type: "boolean",
|
|
41
|
-
})
|
|
42
|
-
.option("first-parent", {
|
|
43
|
-
describe: "Apply commit filtering to current branch only.",
|
|
44
|
-
type: "boolean",
|
|
45
|
-
})
|
|
46
|
-
.option("deps.bump", {
|
|
47
|
-
describe: "Define deps version updating rule. Allowed: override, satisfy, inherit.",
|
|
48
|
-
type: "string",
|
|
49
|
-
})
|
|
50
|
-
.option("deps.release", {
|
|
51
|
-
describe: "Define release type for dependent package if any of its deps changes. Supported values: patch, minor, major, inherit.",
|
|
52
|
-
type: "string",
|
|
53
|
-
})
|
|
54
|
-
.option("deps.prefix", {
|
|
55
|
-
describe:
|
|
56
|
-
"Optional prefix to be attached to the next dep version if '--deps.bump' set to 'override'. Supported values: '^' | '~' | '' (empty string as default).",
|
|
57
|
-
type: "string",
|
|
58
|
-
})
|
|
59
|
-
.option("b", { alias: "branches", describe: "Git branches to release from", ...stringList, group: "Options" })
|
|
60
|
-
.option("ci", { describe: "Toggle CI verifications", group: "Options", type: "boolean" })
|
|
61
|
-
.option("ignore-packages", {
|
|
62
|
-
...stringList,
|
|
63
|
-
describe: "Packages list to be ignored on bumping process",
|
|
64
|
-
})
|
|
65
|
-
.option("ignore-private", {
|
|
66
|
-
describe: "Exclude private packages. Enabled by default, pass 'no-ignore-private' to disable.",
|
|
67
|
-
type: "boolean",
|
|
68
|
-
})
|
|
69
|
-
.option("tag-format", {
|
|
70
|
-
describe:
|
|
71
|
-
// eslint-disable-next-line no-template-curly-in-string
|
|
72
|
-
"Format to use for creating tag names. Should include \"name\" and \"version\" vars. Default: \"${name}@${version}\" generates \"package-name@1.0.0\"",
|
|
73
|
-
type: "string",
|
|
74
|
-
})
|
|
75
|
-
.strict(false)
|
|
76
|
-
.exitProcess(false);
|
|
77
|
-
|
|
78
|
-
try {
|
|
79
|
-
const { _, help, version, ...options } = cli.parse(process.argv.slice(2));
|
|
80
|
-
|
|
81
|
-
if (Boolean(help) || Boolean(version)) {
|
|
82
|
-
return 0;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Imports.
|
|
86
|
-
// eslint-disable-next-line unicorn/no-await-expression-member
|
|
87
|
-
const multiSemanticRelease = (await import("../lib/multi-semantic-release.js")).default;
|
|
88
|
-
|
|
89
|
-
// Do multirelease (log out any errors).
|
|
90
|
-
// eslint-disable-next-line promise/catch-or-return
|
|
91
|
-
multiSemanticRelease(null, {}, {}, options).then(
|
|
92
|
-
// eslint-disable-next-line promise/always-return
|
|
93
|
-
() => {
|
|
94
|
-
// Success.
|
|
95
|
-
exit(0);
|
|
96
|
-
},
|
|
97
|
-
(error) => {
|
|
98
|
-
// Log out errors.
|
|
99
|
-
logger.error(`[multi-semantic-release]:`, error);
|
|
100
|
-
exit(1);
|
|
101
|
-
},
|
|
102
|
-
);
|
|
103
|
-
} catch (error) {
|
|
104
|
-
// Log out errors.
|
|
105
|
-
logger.error(`[multi-semantic-release]:`, error);
|
|
106
|
-
exit(1);
|
|
107
|
-
}
|
|
108
|
-
})();
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
import { getTagHead } from "semantic-release/lib/git.js";
|
|
2
|
-
|
|
3
|
-
import getCommitsFiltered from "./get-commits-filtered.js";
|
|
4
|
-
import logger from "./logger.js";
|
|
5
|
-
import { resolveReleaseType, updateManifestDeps } from "./update-deps.js";
|
|
6
|
-
|
|
7
|
-
const { debug } = logger.withScope("msr:inlinePlugin");
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Create an inline plugin creator for a multirelease.
|
|
11
|
-
* This is caused once per multirelease and returns a function which should be called once per package within the release.
|
|
12
|
-
* @param {Package[]} packages The multi-semantic-release context.
|
|
13
|
-
* @param {MultiContext} multiContext The multi-semantic-release context.
|
|
14
|
-
* @param {object} flags argv options
|
|
15
|
-
* @returns {Function} A function that creates an inline package.
|
|
16
|
-
* @internal
|
|
17
|
-
*/
|
|
18
|
-
function createInlinePluginCreator(packages, multiContext, flags) {
|
|
19
|
-
// Vars.
|
|
20
|
-
const { cwd } = multiContext;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Create an inline plugin for an individual package in a multirelease.
|
|
24
|
-
* This is called once per package and returns the inline plugin used for semanticRelease()
|
|
25
|
-
* @param {Package} package_ The package this function is being called on.
|
|
26
|
-
* @returns {object} A semantic-release inline plugin containing plugin step functions.
|
|
27
|
-
* @internal
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
*
|
|
32
|
-
* @param package_
|
|
33
|
-
*/
|
|
34
|
-
function createInlinePlugin(package_) {
|
|
35
|
-
// Vars.
|
|
36
|
-
const { dir, name, plugins } = package_;
|
|
37
|
-
const debugPrefix = `[${name}]`;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @param {object} pluginOptions Options to configure this plugin.
|
|
41
|
-
* @param {object} context The semantic-release context.
|
|
42
|
-
* @returns {Promise<void>} void
|
|
43
|
-
* @internal
|
|
44
|
-
*/
|
|
45
|
-
const verifyConditions = async (pluginOptions, context) => {
|
|
46
|
-
// Restore context for plugins that does not rely on parsed opts.
|
|
47
|
-
Object.assign(context.options, context.options._pkgOptions);
|
|
48
|
-
|
|
49
|
-
// And bind the actual logger.
|
|
50
|
-
Object.assign(package_.fakeLogger, context.logger);
|
|
51
|
-
|
|
52
|
-
const result = await plugins.verifyConditions(context);
|
|
53
|
-
|
|
54
|
-
// eslint-disable-next-line no-param-reassign
|
|
55
|
-
package_._ready = true;
|
|
56
|
-
|
|
57
|
-
debug(debugPrefix, "verified conditions");
|
|
58
|
-
|
|
59
|
-
return result;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Analyze commits step.
|
|
64
|
-
* Responsible for determining the type of the next release (major, minor or patch). If multiple plugins with a analyzeCommits step are defined, the release type will be the highest one among plugins output.
|
|
65
|
-
*
|
|
66
|
-
* In multirelease: Returns "patch" if the package contains references to other local packages that have changed, or null if this package references no local packages or they have not changed.
|
|
67
|
-
* Also updates the `context.commits` setting with one returned from `getCommitsFiltered()` (which is filtered by package directory).
|
|
68
|
-
* @param {object} pluginOptions Options to configure this plugin.
|
|
69
|
-
* @param {object} context The semantic-release context.
|
|
70
|
-
* @returns {Promise<void>} Promise that resolves when done.
|
|
71
|
-
* @internal
|
|
72
|
-
*/
|
|
73
|
-
const analyzeCommits = async (pluginOptions, context) => {
|
|
74
|
-
// eslint-disable-next-line no-param-reassign
|
|
75
|
-
package_._preRelease = context.branch.prerelease || null;
|
|
76
|
-
// eslint-disable-next-line no-param-reassign
|
|
77
|
-
package_._branch = context.branch.name;
|
|
78
|
-
|
|
79
|
-
// Filter commits by directory.
|
|
80
|
-
const firstParentBranch = flags.firstParent ? context.branch.name : undefined;
|
|
81
|
-
|
|
82
|
-
// Set context.commits so analyzeCommits does correct analysis.
|
|
83
|
-
|
|
84
|
-
context.commits = await getCommitsFiltered(
|
|
85
|
-
cwd,
|
|
86
|
-
dir,
|
|
87
|
-
context.lastRelease ? context.lastRelease.gitHead : undefined,
|
|
88
|
-
context.nextRelease ? context.nextRelease.gitHead : undefined,
|
|
89
|
-
firstParentBranch,
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
// Set lastRelease for package from context.
|
|
93
|
-
// eslint-disable-next-line no-param-reassign
|
|
94
|
-
package_._lastRelease = context.lastRelease;
|
|
95
|
-
|
|
96
|
-
// Set nextType for package from plugins.
|
|
97
|
-
// eslint-disable-next-line no-param-reassign
|
|
98
|
-
package_._nextType = await plugins.analyzeCommits(context);
|
|
99
|
-
|
|
100
|
-
// eslint-disable-next-line no-param-reassign
|
|
101
|
-
package_._analyzed = true;
|
|
102
|
-
|
|
103
|
-
// Make sure type is "patch" if the package has any deps that have been changed.
|
|
104
|
-
// eslint-disable-next-line no-param-reassign
|
|
105
|
-
package_._nextType = resolveReleaseType(package_, flags.deps.bump, flags.deps.release, [], flags.deps.prefix);
|
|
106
|
-
|
|
107
|
-
debug(debugPrefix, "commits analyzed");
|
|
108
|
-
debug(debugPrefix, `release type: ${package_._nextType}`);
|
|
109
|
-
|
|
110
|
-
// Return type.
|
|
111
|
-
return package_._nextType;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Generate notes step (after).
|
|
116
|
-
* Responsible for generating the content of the release note. If multiple plugins with a generateNotes step are defined, the release notes will be the result of the concatenation of each plugin output.
|
|
117
|
-
*
|
|
118
|
-
* In multirelease: Edit the H2 to insert the package name and add an upgrades section to the note.
|
|
119
|
-
* We want this at the _end_ of the release note which is why it's stored in steps-after.
|
|
120
|
-
*
|
|
121
|
-
* Should look like:
|
|
122
|
-
*
|
|
123
|
-
* ## my-amazing-package [9.2.1](github.com/etc) 2018-12-01
|
|
124
|
-
*
|
|
125
|
-
* ### Features
|
|
126
|
-
*
|
|
127
|
-
* etc
|
|
128
|
-
*
|
|
129
|
-
* ### Dependencies
|
|
130
|
-
*
|
|
131
|
-
* **my-amazing-plugin:** upgraded to 1.2.3
|
|
132
|
-
* **my-other-plugin:** upgraded to 4.9.6
|
|
133
|
-
* @param {object} pluginOptions Options to configure this plugin.
|
|
134
|
-
* @param {object} context The semantic-release context.
|
|
135
|
-
* @returns {Promise<void>} Promise that resolves to the string
|
|
136
|
-
* @internal
|
|
137
|
-
*/
|
|
138
|
-
const generateNotes = async (pluginOptions, context) => {
|
|
139
|
-
// Set nextRelease for package.
|
|
140
|
-
// eslint-disable-next-line no-param-reassign
|
|
141
|
-
package_._nextRelease = context.nextRelease;
|
|
142
|
-
|
|
143
|
-
// Wait until all todo packages are ready to generate notes.
|
|
144
|
-
// await waitForAll("_nextRelease", (p) => p._nextType);
|
|
145
|
-
|
|
146
|
-
// Vars.
|
|
147
|
-
const notes = [];
|
|
148
|
-
|
|
149
|
-
// get SHA of lastRelease if not already there (should have been done by Semantic Release...)
|
|
150
|
-
if (
|
|
151
|
-
context.lastRelease
|
|
152
|
-
&& context.lastRelease.gitTag
|
|
153
|
-
&& (!context.lastRelease.gitHead || context.lastRelease.gitHead === context.lastRelease.gitTag)
|
|
154
|
-
) {
|
|
155
|
-
context.lastRelease.gitHead = getTagHead(context.lastRelease.gitTag, {
|
|
156
|
-
cwd: context.cwd,
|
|
157
|
-
env: context.env,
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// Filter commits by directory (and release range)
|
|
162
|
-
const firstParentBranch = flags.firstParent ? context.branch.name : undefined;
|
|
163
|
-
|
|
164
|
-
// Set context.commits so generateNotes does correct analysis.
|
|
165
|
-
|
|
166
|
-
context.commits = await getCommitsFiltered(
|
|
167
|
-
cwd,
|
|
168
|
-
dir,
|
|
169
|
-
context.lastRelease ? context.lastRelease.gitHead : undefined,
|
|
170
|
-
context.nextRelease ? context.nextRelease.gitHead : undefined,
|
|
171
|
-
firstParentBranch,
|
|
172
|
-
);
|
|
173
|
-
|
|
174
|
-
// Get subnotes and add to list.
|
|
175
|
-
// Inject pkg name into title if it matches e.g. `# 1.0.0` or `## [1.0.1]` (as generate-release-notes does).
|
|
176
|
-
const subs = await plugins.generateNotes(context);
|
|
177
|
-
|
|
178
|
-
// istanbul ignore else (unnecessary to __tests__)
|
|
179
|
-
if (subs) {
|
|
180
|
-
notes.push(subs.replace(/^(#+) (\[?\d+\.\d+\.\d+\]?)/u, `$1 ${name} $2`));
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
// If it has upgrades add an upgrades section.
|
|
184
|
-
const upgrades = package_.localDeps.filter((d) => d._nextRelease);
|
|
185
|
-
|
|
186
|
-
if (upgrades.length > 0) {
|
|
187
|
-
notes.push(`### Dependencies`);
|
|
188
|
-
|
|
189
|
-
const bullets = upgrades.map((d) => `* **${d.name}:** upgraded to ${d._nextRelease.version}`);
|
|
190
|
-
|
|
191
|
-
notes.push(bullets.join("\n"));
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
debug(debugPrefix, "notes generated");
|
|
195
|
-
|
|
196
|
-
// Return the notes.
|
|
197
|
-
return notes.join("\n\n");
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
const prepare = async (pluginOptions, context) => {
|
|
201
|
-
updateManifestDeps(package_);
|
|
202
|
-
|
|
203
|
-
// eslint-disable-next-line no-param-reassign
|
|
204
|
-
package_._depsUpdated = true;
|
|
205
|
-
|
|
206
|
-
// Filter commits by directory.
|
|
207
|
-
const firstParentBranch = flags.firstParent ? context.branch.name : undefined;
|
|
208
|
-
|
|
209
|
-
// Set context.commits so analyzeCommits does correct analysis.
|
|
210
|
-
|
|
211
|
-
context.commits = await getCommitsFiltered(
|
|
212
|
-
cwd,
|
|
213
|
-
dir,
|
|
214
|
-
context.lastRelease ? context.lastRelease.gitHead : undefined,
|
|
215
|
-
context.nextRelease ? context.nextRelease.gitHead : undefined,
|
|
216
|
-
firstParentBranch,
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
const result = await plugins.prepare(context);
|
|
220
|
-
|
|
221
|
-
// eslint-disable-next-line no-param-reassign
|
|
222
|
-
package_._prepared = true;
|
|
223
|
-
|
|
224
|
-
debug(debugPrefix, "prepared");
|
|
225
|
-
|
|
226
|
-
return result;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
const publish = async (pluginOptions, context) => {
|
|
230
|
-
const result = await plugins.publish(context);
|
|
231
|
-
|
|
232
|
-
// eslint-disable-next-line no-param-reassign
|
|
233
|
-
package_._published = true;
|
|
234
|
-
|
|
235
|
-
debug(debugPrefix, "published");
|
|
236
|
-
|
|
237
|
-
// istanbul ignore next
|
|
238
|
-
return result.length > 0 ? result[0] : {};
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
const inlinePlugin = {
|
|
242
|
-
analyzeCommits,
|
|
243
|
-
generateNotes,
|
|
244
|
-
prepare,
|
|
245
|
-
publish,
|
|
246
|
-
verifyConditions,
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
// Add labels for logs.
|
|
250
|
-
Object.keys(inlinePlugin).forEach((type) =>
|
|
251
|
-
Reflect.defineProperty(inlinePlugin[type], "pluginName", {
|
|
252
|
-
enumerable: true,
|
|
253
|
-
value: "Inline plugin",
|
|
254
|
-
writable: false,
|
|
255
|
-
}),
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
debug(debugPrefix, "inlinePlugin created");
|
|
259
|
-
|
|
260
|
-
return inlinePlugin;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Return creator function.
|
|
264
|
-
return createInlinePlugin;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Exports.
|
|
268
|
-
export default createInlinePluginCreator;
|