@tarsilla/commit-wizard 1.2.3 → 1.3.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 +3 -1
- package/lib/semantic-release/brew/index.mjs +2 -0
- package/lib/semantic-release/brew/index.mjs.map +1 -0
- package/lib/semantic-release/node/index.mjs.map +1 -0
- package/package.json +10 -5
- package/src/semantic-release/brew/index.ts +170 -0
- package/src/semantic-release/{index.ts → node/index.ts} +1 -21
- package/src/semantic-release/types.ts +23 -0
- package/lib/semantic-release/index.mjs.map +0 -1
- /package/lib/semantic-release/{index.mjs → node/index.mjs} +0 -0
package/README.md
CHANGED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{execSync as e}from"child_process";import t from"fs";import{analyzeCommits as a}from"@semantic-release/commit-analyzer";import{prepare as s,verifyConditions as r}from"@semantic-release/git";import{generateNotes as n}from"@semantic-release/release-notes-generator";const o={preset:"conventionalcommits",parserOpts:{headerPattern:RegExp("^(?<type>\\w+)(?<exclamation1>!?)(?:\\((?<scope>[^)]+)\\)(?<exclamation2>!?))?: (?<subject>.+)$"),headerCorrespondence:["type","exclamation1","scope","exclamation2","subject"]},releaseRules:[{type:"feat",exclamation1:"!",release:"major"},{type:"feat",exclamation2:"!",release:"major"},{type:"feat",release:"minor"},{type:"fix",release:"patch"},{type:"docs",release:"patch"},{type:"style",release:"patch"},{type:"refactor",release:"patch"},{type:"perf",release:"patch"},{type:"test",release:"patch"},{type:"build",release:"patch"},{type:"ci",release:"patch"},{type:"chore",release:"patch"},{type:"revert",release:"patch"}]};let i=!1;function c(e,t){const a=new URL(t).pathname,s=(a.startsWith("/")?a.slice(1):a).split("/").pop();return e.tap??`${s}.rb`}async function l(e,t){if(r){const{options:a}=t,s=c(e,a.repositoryUrl);await r({assets:[s],message:"chore(release): ${nextRelease.version}"},t)}i=!0}const p={addChannel:async function(e,t){},verifyConditions:l,analyzeCommits:async function(e,t){return i||(await l(e,t),i=!0),a(o,t)},generateNotes:async function(e,t){return i||(await l(e,t),i=!0),n({},t)},prepare:async function(a,r){if(i||(await l(a,r),i=!0),s){const{options:n}=r,o=c(a,n.repositoryUrl);await async function(a,s){const{nextRelease:r,logger:n,options:o}=s;if(!r?.version)throw new Error("Next release version is not available.");const i=r.version,l=o.repositoryUrl,p=`${l}/archive/refs/tags/${i}.tar.gz`,m=e(`curl -L ${p} | sha256sum | awk '{print $1}'`).toString().trim(),y=c(a,l);let f=t.readFileSync(y,"utf8");f=f.replace(/url ".*"/,`url "${p}"`),f=f.replace(/sha256 ".*"/,`sha256 "${m}"`),t.writeFileSync(y,f),n.log(`Updated formula with version ${i}, URL ${p}, and SHA256 ${m}`)}(a,r),await s({assets:[o],message:"chore(release): ${nextRelease.version}"},r)}},publish:async function(e,t){return null},success:async function(e,t){},fail:async function(e,t){}};export{p as default};
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/semantic-release/brew/index.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport fs from 'fs';\n\n//@ts-ignore\nimport { analyzeCommits as commitAnalyzerAnalyzeCommits } from '@semantic-release/commit-analyzer';\nimport {\n prepare as gitPrepare,\n verifyConditions as gitVerifyConditions,\n //@ts-ignore\n} from '@semantic-release/git';\n//@ts-ignore\nimport { generateNotes as notesGeneratorGenerateNotes } from '@semantic-release/release-notes-generator';\nimport {\n AddChannelContext,\n AnalyzeCommitsContext,\n FailContext,\n GenerateNotesContext,\n PrepareContext,\n PublishContext,\n SuccessContext,\n VerifyConditionsContext,\n} from 'semantic-release';\n\nimport { SemanticReleasePlugin } from '../types.js';\n\nconst analyzerConfig = {\n preset: 'conventionalcommits',\n parserOpts: {\n headerPattern: /^(?<type>\\w+)(?<exclamation1>!?)(?:\\((?<scope>[^)]+)\\)(?<exclamation2>!?))?: (?<subject>.+)$/,\n headerCorrespondence: ['type', 'exclamation1', 'scope', 'exclamation2', 'subject'],\n },\n releaseRules: [\n { type: 'feat', exclamation1: '!', release: 'major' },\n { type: 'feat', exclamation2: '!', release: 'major' },\n { type: 'feat', release: 'minor' },\n { type: 'fix', release: 'patch' },\n { type: 'docs', release: 'patch' },\n { type: 'style', release: 'patch' },\n { type: 'refactor', release: 'patch' },\n { type: 'perf', release: 'patch' },\n { type: 'test', release: 'patch' },\n { type: 'build', release: 'patch' },\n { type: 'ci', release: 'patch' },\n { type: 'chore', release: 'patch' },\n { type: 'revert', release: 'patch' },\n ],\n};\n\ntype PluginConfig = { tap?: string };\n\nlet verified = false;\n\nfunction getFormulaFile(pluginConfig: PluginConfig, repositoryUrl: string): string {\n const url = new URL(repositoryUrl);\n const repositoryPath = url.pathname;\n const repository = repositoryPath.startsWith('/') ? repositoryPath.slice(1) : repositoryPath;\n const project = repository.split('/').pop();\n\n return pluginConfig.tap ?? `${project}.rb`;\n}\n\nasync function updateFormulaFile(pluginConfig: PluginConfig, context: PrepareContext): Promise<void> {\n const { nextRelease, logger, options } = context;\n\n if (!nextRelease?.version) {\n throw new Error('Next release version is not available.');\n }\n\n const version = nextRelease.version;\n\n const repositoryUrl = options.repositoryUrl!; // Guaranteed to be defined by semantic-release\n\n const tarUrl = `${repositoryUrl}/archive/refs/tags/${version}.tar.gz`;\n const sha256 = execSync(`curl -L ${tarUrl} | sha256sum | awk '{print $1}'`).toString().trim();\n const formulaFile = getFormulaFile(pluginConfig, repositoryUrl);\n\n let formulaContent = fs.readFileSync(formulaFile, 'utf8');\n formulaContent = formulaContent.replace(/url \".*\"/, `url \"${tarUrl}\"`);\n formulaContent = formulaContent.replace(/sha256 \".*\"/, `sha256 \"${sha256}\"`);\n fs.writeFileSync(formulaFile, formulaContent);\n\n logger.log(`Updated formula with version ${version}, URL ${tarUrl}, and SHA256 ${sha256}`);\n}\n\nasync function addChannel(_pluginConfig: PluginConfig, _context: AddChannelContext): Promise<void> {\n //do nothing\n}\n\nasync function analyzeCommits(pluginConfig: PluginConfig, context: AnalyzeCommitsContext): Promise<string | false> {\n if (!verified) {\n await verifyConditions(pluginConfig, context);\n verified = true;\n }\n\n return commitAnalyzerAnalyzeCommits(analyzerConfig, context);\n}\n\nasync function fail(_pluginConfig: PluginConfig, _context: FailContext): Promise<void> {\n //do nothing\n}\n\nasync function generateNotes(pluginConfig: PluginConfig, context: GenerateNotesContext): Promise<string> {\n if (!verified) {\n await verifyConditions(pluginConfig, context);\n verified = true;\n }\n\n return notesGeneratorGenerateNotes({}, context);\n}\n\nasync function prepare(pluginConfig: PluginConfig, context: PrepareContext): Promise<void> {\n if (!verified) {\n await verifyConditions(pluginConfig, context);\n verified = true;\n }\n\n if (gitPrepare) {\n const { options } = context;\n const repositoryUrl = options.repositoryUrl!; // Guaranteed to be defined by semantic-release\n const formulaFile = getFormulaFile(pluginConfig, repositoryUrl);\n\n await updateFormulaFile(pluginConfig, context);\n\n await gitPrepare(\n {\n assets: [formulaFile],\n message: 'chore(release): ${nextRelease.version}',\n },\n context,\n );\n }\n}\n\nasync function publish(_pluginConfig: PluginConfig, _context: PublishContext): Promise<unknown> {\n //do nothing\n return null;\n}\n\nasync function success(_pluginConfig: PluginConfig, _context: SuccessContext): Promise<void> {\n //do nothing\n}\n\nasync function verifyConditions(pluginConfig: PluginConfig, context: VerifyConditionsContext): Promise<void> {\n if (gitVerifyConditions) {\n const { options } = context;\n const repositoryUrl = options.repositoryUrl!; // Guaranteed to be defined by semantic-release\n const formulaFile = getFormulaFile(pluginConfig, repositoryUrl);\n await gitVerifyConditions(\n {\n assets: [formulaFile],\n message: 'chore(release): ${nextRelease.version}',\n },\n context,\n );\n }\n verified = true;\n}\n\nconst plugin: SemanticReleasePlugin<{ tap: string }> = {\n addChannel,\n verifyConditions,\n analyzeCommits,\n generateNotes,\n prepare,\n publish,\n success,\n fail,\n};\n\nexport default plugin;\n"],"names":["analyzerConfig","preset","parserOpts","headerPattern","RegExp","headerCorrespondence","releaseRules","type","exclamation1","release","exclamation2","verified","getFormulaFile","pluginConfig","repositoryUrl","repositoryPath","URL","pathname","project","startsWith","slice","split","pop","tap","async","verifyConditions","context","gitVerifyConditions","options","formulaFile","assets","message","plugin","addChannel","_pluginConfig","_context","analyzeCommits","commitAnalyzerAnalyzeCommits","generateNotes","notesGeneratorGenerateNotes","prepare","gitPrepare","nextRelease","logger","version","Error","tarUrl","sha256","execSync","toString","trim","formulaContent","fs","readFileSync","replace","writeFileSync","log","updateFormulaFile","publish","success","fail"],"mappings":"8QAyBA,MAAMA,EAAiB,CACrBC,OAAQ,sBACRC,WAAY,CACVC,cAAeC,OAAA,mGACfC,qBAAsB,CAAC,OAAQ,eAAgB,QAAS,eAAgB,YAE1EC,aAAc,CACZ,CAAEC,KAAM,OAAQC,aAAc,IAAKC,QAAS,SAC5C,CAAEF,KAAM,OAAQG,aAAc,IAAKD,QAAS,SAC5C,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,MAAOE,QAAS,SACxB,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,QAASE,QAAS,SAC1B,CAAEF,KAAM,WAAYE,QAAS,SAC7B,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,QAASE,QAAS,SAC1B,CAAEF,KAAM,KAAME,QAAS,SACvB,CAAEF,KAAM,QAASE,QAAS,SAC1B,CAAEF,KAAM,SAAUE,QAAS,WAM/B,IAAIE,GAAW,EAEf,SAASC,EAAeC,EAA4BC,GAClD,MACMC,EADM,IAAIC,IAAIF,GACOG,SAErBC,GADaH,EAAeI,WAAW,KAAOJ,EAAeK,MAAM,GAAKL,GACnDM,MAAM,KAAKC,MAEtC,OAAOT,EAAaU,KAAO,GAAGL,MAChC,CAmFAM,eAAeC,EAAiBZ,EAA4Ba,GAC1D,GAAIC,EAAqB,CACvB,MAAMC,QAAEA,GAAYF,EAEdG,EAAcjB,EAAeC,EADbe,EAAQd,qBAExBa,EACJ,CACEG,OAAQ,CAACD,GACTE,QAAS,0CAEXL,EAEJ,CACAf,GAAW,CACb,CAEA,MAAMqB,EAAiD,CACrDC,WA3EFT,eAA0BU,EAA6BC,GAEvD,EA0EEV,mBACAW,eAzEFZ,eAA8BX,EAA4Ba,GAMxD,OALKf,UACGc,EAAiBZ,EAAca,GACrCf,GAAW,GAGN0B,EAA6BrC,EAAgB0B,EACtD,EAmEEY,cA7DFd,eAA6BX,EAA4Ba,GAMvD,OALKf,UACGc,EAAiBZ,EAAca,GACrCf,GAAW,GAGN4B,EAA4B,CAAIb,EAAAA,EACzC,EAuDEc,QArDFhB,eAAuBX,EAA4Ba,GAMjD,GALKf,UACGc,EAAiBZ,EAAca,GACrCf,GAAW,GAGT8B,EAAY,CACd,MAAMb,QAAEA,GAAYF,EAEdG,EAAcjB,EAAeC,EADbe,EAAQd,qBAzDlCU,eAAiCX,EAA4Ba,GAC3D,MAAMgB,YAAEA,EAAWC,OAAEA,EAAMf,QAAEA,GAAYF,EAEzC,IAAKgB,GAAaE,QAChB,MAAM,IAAIC,MAAM,0CAGlB,MAAMD,EAAUF,EAAYE,QAEtB9B,EAAgBc,EAAQd,cAExBgC,EAAS,GAAGhC,uBAAmC8B,WAC/CG,EAASC,EAAS,WAAWF,oCAAyCG,WAAWC,OACjFrB,EAAcjB,EAAeC,EAAcC,GAEjD,IAAIqC,EAAiBC,EAAGC,aAAaxB,EAAa,QAClDsB,EAAiBA,EAAeG,QAAQ,WAAY,QAAQR,MAC5DK,EAAiBA,EAAeG,QAAQ,cAAe,WAAWP,MAClEK,EAAGG,cAAc1B,EAAasB,GAE9BR,EAAOa,IAAI,gCAAgCZ,UAAgBE,iBAAsBC,IACnF,CAuCUU,CAAkB5C,EAAca,SAEhCe,EACJ,CACEX,OAAQ,CAACD,GACTE,QAAS,0CAEXL,EAEJ,CACF,EAiCEgC,QA/BFlC,eAAuBU,EAA6BC,GAElD,OAAO,IACT,EA6BEwB,QA3BFnC,eAAuBU,EAA6BC,GAEpD,EA0BEyB,KArEFpC,eAAoBU,EAA6BC,GAEjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/semantic-release/node/index.ts"],"sourcesContent":["//@ts-ignore\nimport { analyzeCommits } from '@semantic-release/commit-analyzer';\nimport {\n prepare as gitPrepare,\n verifyConditions as gitVerifyConditions,\n //@ts-ignore\n} from '@semantic-release/git';\nimport {\n addChannel as npmAddChannel,\n prepare as npmPrepare,\n publish as npmPublish,\n verifyConditions as npmVerifyConditions,\n //@ts-ignore\n} from '@semantic-release/npm';\n//@ts-ignore\nimport { generateNotes } from '@semantic-release/release-notes-generator';\n\nimport { SemanticReleasePlugin } from '../types.js';\n\nconst analyzerConfig = {\n preset: 'conventionalcommits',\n parserOpts: {\n headerPattern: /^(?<type>\\w+)(?<exclamation1>!?)(?:\\((?<scope>[^)]+)\\)(?<exclamation2>!?))?: (?<subject>.+)$/,\n headerCorrespondence: ['type', 'exclamation1', 'scope', 'exclamation2', 'subject'],\n },\n releaseRules: [\n { type: 'feat', exclamation1: '!', release: 'major' },\n { type: 'feat', exclamation2: '!', release: 'major' },\n { type: 'feat', release: 'minor' },\n { type: 'fix', release: 'patch' },\n { type: 'docs', release: 'patch' },\n { type: 'style', release: 'patch' },\n { type: 'refactor', release: 'patch' },\n { type: 'perf', release: 'patch' },\n { type: 'test', release: 'patch' },\n { type: 'build', release: 'patch' },\n { type: 'ci', release: 'patch' },\n { type: 'chore', release: 'patch' },\n { type: 'revert', release: 'patch' },\n ],\n};\n\nconst npmConfig = {\n tag: 'latest',\n npmPublish: true,\n optional: false,\n};\n\nconst gitConfig = {\n assets: ['package.json', 'package-lock.json'],\n message: 'chore(release): ${nextRelease.version}',\n};\n\nconst plugin: SemanticReleasePlugin = {\n addChannel: async (_pluginConfig, context) => {\n if (npmAddChannel) {\n await npmAddChannel(npmConfig, context);\n }\n },\n verifyConditions: async (_pluginConfig, context) => {\n if (npmVerifyConditions) {\n await npmVerifyConditions(npmConfig, context);\n }\n if (gitVerifyConditions) {\n await gitVerifyConditions(gitConfig, context);\n }\n },\n\n analyzeCommits: async (_pluginConfig, context) => {\n return analyzeCommits(analyzerConfig, context);\n },\n\n generateNotes: async (_pluginConfig, context) => {\n return generateNotes({}, context);\n },\n\n prepare: async (_pluginConfig, context) => {\n if (npmPrepare) {\n await npmPrepare(npmConfig, context);\n }\n if (gitPrepare) {\n await gitPrepare(gitConfig, context);\n }\n },\n\n publish: async (_pluginConfig, context) => {\n if (npmPublish) {\n await npmPublish(npmConfig, context);\n }\n /*if (gitPublish) {\n await gitPublish(gitConfig, context);\n }*/\n },\n\n success: async (_pluginConfig, _context) => {\n /*if (gitSuccess) {\n await gitSuccess(gitConfig, context);\n }*/\n },\n\n fail: async (_pluginConfig, _context) => {\n /*if (gitFail) {\n await gitFail(gitConfig, context);\n }*/\n },\n};\n\nexport default plugin;\n"],"names":["analyzerConfig","preset","parserOpts","headerPattern","RegExp","headerCorrespondence","releaseRules","type","exclamation1","release","exclamation2","npmConfig","tag","npmPublish","optional","gitConfig","assets","message","plugin","addChannel","async","_pluginConfig","context","npmAddChannel","verifyConditions","npmVerifyConditions","gitVerifyConditions","analyzeCommits","generateNotes","prepare","npmPrepare","gitPrepare","publish","success","_context","fail"],"mappings":"sTAmBA,MAAMA,EAAiB,CACrBC,OAAQ,sBACRC,WAAY,CACVC,cAAeC,OAAA,mGACfC,qBAAsB,CAAC,OAAQ,eAAgB,QAAS,eAAgB,YAE1EC,aAAc,CACZ,CAAEC,KAAM,OAAQC,aAAc,IAAKC,QAAS,SAC5C,CAAEF,KAAM,OAAQG,aAAc,IAAKD,QAAS,SAC5C,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,MAAOE,QAAS,SACxB,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,QAASE,QAAS,SAC1B,CAAEF,KAAM,WAAYE,QAAS,SAC7B,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,QAASE,QAAS,SAC1B,CAAEF,KAAM,KAAME,QAAS,SACvB,CAAEF,KAAM,QAASE,QAAS,SAC1B,CAAEF,KAAM,SAAUE,QAAS,WAIzBE,EAAY,CAChBC,IAAK,SACLC,YAAY,EACZC,UAAU,GAGNC,EAAY,CAChBC,OAAQ,CAAC,eAAgB,qBACzBC,QAAS,0CAGLC,EAAgC,CACpCC,WAAYC,MAAOC,EAAeC,KAC5BC,SACIA,EAAcZ,EAAWW,EACjC,EAEFE,iBAAkBJ,MAAOC,EAAeC,KAClCG,SACIA,EAAoBd,EAAWW,GAEnCI,SACIA,EAAoBX,EAAWO,EACvC,EAGFK,eAAgBP,MAAOC,EAAeC,IAC7BK,EAAe3B,EAAgBsB,GAGxCM,cAAeR,MAAOC,EAAeC,IAC5BM,EAAc,CAAIN,EAAAA,GAG3BO,QAAST,MAAOC,EAAeC,KACzBQ,SACIA,EAAWnB,EAAWW,GAE1BS,SACIA,EAAWhB,EAAWO,EAC9B,EAGFU,QAASZ,MAAOC,EAAeC,KACzBT,SACIA,EAAWF,EAAWW,EAC9B,EAMFW,QAASb,MAAOC,EAAea,KAAtBd,EAMTe,KAAMf,MAAOC,EAAea,KAAtBd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarsilla/commit-wizard",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -18,10 +18,15 @@
|
|
|
18
18
|
"import": "./lib/commitlint/index.mjs",
|
|
19
19
|
"default": "./lib/commitlint/index.mjs"
|
|
20
20
|
},
|
|
21
|
-
"./semantic-release": {
|
|
22
|
-
"require": "./lib/semantic-release/index.mjs",
|
|
23
|
-
"import": "./lib/semantic-release/index.mjs",
|
|
24
|
-
"default": "./lib/semantic-release/index.mjs"
|
|
21
|
+
"./semantic-release/brew": {
|
|
22
|
+
"require": "./lib/semantic-release/brew/index.mjs",
|
|
23
|
+
"import": "./lib/semantic-release/brew/index.mjs",
|
|
24
|
+
"default": "./lib/semantic-release/brew/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./semantic-release/node": {
|
|
27
|
+
"require": "./lib/semantic-release/node/index.mjs",
|
|
28
|
+
"import": "./lib/semantic-release/node/index.mjs",
|
|
29
|
+
"default": "./lib/semantic-release/node/index.mjs"
|
|
25
30
|
},
|
|
26
31
|
"./package.json": "./package.json"
|
|
27
32
|
},
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
//@ts-ignore
|
|
5
|
+
import { analyzeCommits as commitAnalyzerAnalyzeCommits } from '@semantic-release/commit-analyzer';
|
|
6
|
+
import {
|
|
7
|
+
prepare as gitPrepare,
|
|
8
|
+
verifyConditions as gitVerifyConditions,
|
|
9
|
+
//@ts-ignore
|
|
10
|
+
} from '@semantic-release/git';
|
|
11
|
+
//@ts-ignore
|
|
12
|
+
import { generateNotes as notesGeneratorGenerateNotes } from '@semantic-release/release-notes-generator';
|
|
13
|
+
import {
|
|
14
|
+
AddChannelContext,
|
|
15
|
+
AnalyzeCommitsContext,
|
|
16
|
+
FailContext,
|
|
17
|
+
GenerateNotesContext,
|
|
18
|
+
PrepareContext,
|
|
19
|
+
PublishContext,
|
|
20
|
+
SuccessContext,
|
|
21
|
+
VerifyConditionsContext,
|
|
22
|
+
} from 'semantic-release';
|
|
23
|
+
|
|
24
|
+
import { SemanticReleasePlugin } from '../types.js';
|
|
25
|
+
|
|
26
|
+
const analyzerConfig = {
|
|
27
|
+
preset: 'conventionalcommits',
|
|
28
|
+
parserOpts: {
|
|
29
|
+
headerPattern: /^(?<type>\w+)(?<exclamation1>!?)(?:\((?<scope>[^)]+)\)(?<exclamation2>!?))?: (?<subject>.+)$/,
|
|
30
|
+
headerCorrespondence: ['type', 'exclamation1', 'scope', 'exclamation2', 'subject'],
|
|
31
|
+
},
|
|
32
|
+
releaseRules: [
|
|
33
|
+
{ type: 'feat', exclamation1: '!', release: 'major' },
|
|
34
|
+
{ type: 'feat', exclamation2: '!', release: 'major' },
|
|
35
|
+
{ type: 'feat', release: 'minor' },
|
|
36
|
+
{ type: 'fix', release: 'patch' },
|
|
37
|
+
{ type: 'docs', release: 'patch' },
|
|
38
|
+
{ type: 'style', release: 'patch' },
|
|
39
|
+
{ type: 'refactor', release: 'patch' },
|
|
40
|
+
{ type: 'perf', release: 'patch' },
|
|
41
|
+
{ type: 'test', release: 'patch' },
|
|
42
|
+
{ type: 'build', release: 'patch' },
|
|
43
|
+
{ type: 'ci', release: 'patch' },
|
|
44
|
+
{ type: 'chore', release: 'patch' },
|
|
45
|
+
{ type: 'revert', release: 'patch' },
|
|
46
|
+
],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type PluginConfig = { tap?: string };
|
|
50
|
+
|
|
51
|
+
let verified = false;
|
|
52
|
+
|
|
53
|
+
function getFormulaFile(pluginConfig: PluginConfig, repositoryUrl: string): string {
|
|
54
|
+
const url = new URL(repositoryUrl);
|
|
55
|
+
const repositoryPath = url.pathname;
|
|
56
|
+
const repository = repositoryPath.startsWith('/') ? repositoryPath.slice(1) : repositoryPath;
|
|
57
|
+
const project = repository.split('/').pop();
|
|
58
|
+
|
|
59
|
+
return pluginConfig.tap ?? `${project}.rb`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function updateFormulaFile(pluginConfig: PluginConfig, context: PrepareContext): Promise<void> {
|
|
63
|
+
const { nextRelease, logger, options } = context;
|
|
64
|
+
|
|
65
|
+
if (!nextRelease?.version) {
|
|
66
|
+
throw new Error('Next release version is not available.');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const version = nextRelease.version;
|
|
70
|
+
|
|
71
|
+
const repositoryUrl = options.repositoryUrl!; // Guaranteed to be defined by semantic-release
|
|
72
|
+
|
|
73
|
+
const tarUrl = `${repositoryUrl}/archive/refs/tags/${version}.tar.gz`;
|
|
74
|
+
const sha256 = execSync(`curl -L ${tarUrl} | sha256sum | awk '{print $1}'`).toString().trim();
|
|
75
|
+
const formulaFile = getFormulaFile(pluginConfig, repositoryUrl);
|
|
76
|
+
|
|
77
|
+
let formulaContent = fs.readFileSync(formulaFile, 'utf8');
|
|
78
|
+
formulaContent = formulaContent.replace(/url ".*"/, `url "${tarUrl}"`);
|
|
79
|
+
formulaContent = formulaContent.replace(/sha256 ".*"/, `sha256 "${sha256}"`);
|
|
80
|
+
fs.writeFileSync(formulaFile, formulaContent);
|
|
81
|
+
|
|
82
|
+
logger.log(`Updated formula with version ${version}, URL ${tarUrl}, and SHA256 ${sha256}`);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async function addChannel(_pluginConfig: PluginConfig, _context: AddChannelContext): Promise<void> {
|
|
86
|
+
//do nothing
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function analyzeCommits(pluginConfig: PluginConfig, context: AnalyzeCommitsContext): Promise<string | false> {
|
|
90
|
+
if (!verified) {
|
|
91
|
+
await verifyConditions(pluginConfig, context);
|
|
92
|
+
verified = true;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return commitAnalyzerAnalyzeCommits(analyzerConfig, context);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function fail(_pluginConfig: PluginConfig, _context: FailContext): Promise<void> {
|
|
99
|
+
//do nothing
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function generateNotes(pluginConfig: PluginConfig, context: GenerateNotesContext): Promise<string> {
|
|
103
|
+
if (!verified) {
|
|
104
|
+
await verifyConditions(pluginConfig, context);
|
|
105
|
+
verified = true;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return notesGeneratorGenerateNotes({}, context);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async function prepare(pluginConfig: PluginConfig, context: PrepareContext): Promise<void> {
|
|
112
|
+
if (!verified) {
|
|
113
|
+
await verifyConditions(pluginConfig, context);
|
|
114
|
+
verified = true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (gitPrepare) {
|
|
118
|
+
const { options } = context;
|
|
119
|
+
const repositoryUrl = options.repositoryUrl!; // Guaranteed to be defined by semantic-release
|
|
120
|
+
const formulaFile = getFormulaFile(pluginConfig, repositoryUrl);
|
|
121
|
+
|
|
122
|
+
await updateFormulaFile(pluginConfig, context);
|
|
123
|
+
|
|
124
|
+
await gitPrepare(
|
|
125
|
+
{
|
|
126
|
+
assets: [formulaFile],
|
|
127
|
+
message: 'chore(release): ${nextRelease.version}',
|
|
128
|
+
},
|
|
129
|
+
context,
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async function publish(_pluginConfig: PluginConfig, _context: PublishContext): Promise<unknown> {
|
|
135
|
+
//do nothing
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async function success(_pluginConfig: PluginConfig, _context: SuccessContext): Promise<void> {
|
|
140
|
+
//do nothing
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function verifyConditions(pluginConfig: PluginConfig, context: VerifyConditionsContext): Promise<void> {
|
|
144
|
+
if (gitVerifyConditions) {
|
|
145
|
+
const { options } = context;
|
|
146
|
+
const repositoryUrl = options.repositoryUrl!; // Guaranteed to be defined by semantic-release
|
|
147
|
+
const formulaFile = getFormulaFile(pluginConfig, repositoryUrl);
|
|
148
|
+
await gitVerifyConditions(
|
|
149
|
+
{
|
|
150
|
+
assets: [formulaFile],
|
|
151
|
+
message: 'chore(release): ${nextRelease.version}',
|
|
152
|
+
},
|
|
153
|
+
context,
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
verified = true;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const plugin: SemanticReleasePlugin<{ tap: string }> = {
|
|
160
|
+
addChannel,
|
|
161
|
+
verifyConditions,
|
|
162
|
+
analyzeCommits,
|
|
163
|
+
generateNotes,
|
|
164
|
+
prepare,
|
|
165
|
+
publish,
|
|
166
|
+
success,
|
|
167
|
+
fail,
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export default plugin;
|
|
@@ -14,28 +14,8 @@ import {
|
|
|
14
14
|
} from '@semantic-release/npm';
|
|
15
15
|
//@ts-ignore
|
|
16
16
|
import { generateNotes } from '@semantic-release/release-notes-generator';
|
|
17
|
-
import {
|
|
18
|
-
AddChannelContext,
|
|
19
|
-
AnalyzeCommitsContext,
|
|
20
|
-
FailContext,
|
|
21
|
-
GenerateNotesContext,
|
|
22
|
-
PrepareContext,
|
|
23
|
-
PublishContext,
|
|
24
|
-
SuccessContext,
|
|
25
|
-
VerifyConditionsContext,
|
|
26
|
-
} from 'semantic-release';
|
|
27
17
|
|
|
28
|
-
|
|
29
|
-
export type SemanticReleasePlugin = {
|
|
30
|
-
addChannel?(pluginConfig: unknown, context: AddChannelContext): Promise<void>;
|
|
31
|
-
analyzeCommits?(pluginConfig: unknown, context: AnalyzeCommitsContext): Promise<string | false>;
|
|
32
|
-
fail?(pluginConfig: unknown, context: FailContext): Promise<void>;
|
|
33
|
-
generateNotes?(pluginConfig: unknown, context: GenerateNotesContext): Promise<string>;
|
|
34
|
-
prepare?(pluginConfig: unknown, context: PrepareContext): Promise<void>;
|
|
35
|
-
publish?(pluginConfig: unknown, context: PublishContext): Promise<unknown>;
|
|
36
|
-
success?(pluginConfig: unknown, context: SuccessContext): Promise<void>;
|
|
37
|
-
verifyConditions?(pluginConfig: unknown, context: VerifyConditionsContext): Promise<void>;
|
|
38
|
-
};
|
|
18
|
+
import { SemanticReleasePlugin } from '../types.js';
|
|
39
19
|
|
|
40
20
|
const analyzerConfig = {
|
|
41
21
|
preset: 'conventionalcommits',
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AddChannelContext,
|
|
3
|
+
AnalyzeCommitsContext,
|
|
4
|
+
FailContext,
|
|
5
|
+
GenerateNotesContext,
|
|
6
|
+
PrepareContext,
|
|
7
|
+
PublishContext,
|
|
8
|
+
SuccessContext,
|
|
9
|
+
VerifyConditionsContext,
|
|
10
|
+
} from 'semantic-release';
|
|
11
|
+
|
|
12
|
+
type SemanticReleasePlugin<T = unknown> = {
|
|
13
|
+
addChannel?(pluginConfig: T, context: AddChannelContext): Promise<void>;
|
|
14
|
+
analyzeCommits?(pluginConfig: T, context: AnalyzeCommitsContext): Promise<string | false>;
|
|
15
|
+
fail?(pluginConfig: T, context: FailContext): Promise<void>;
|
|
16
|
+
generateNotes?(pluginConfig: T, context: GenerateNotesContext): Promise<string>;
|
|
17
|
+
prepare?(pluginConfig: T, context: PrepareContext): Promise<void>;
|
|
18
|
+
publish?(pluginConfig: T, context: PublishContext): Promise<unknown>;
|
|
19
|
+
success?(pluginConfig: T, context: SuccessContext): Promise<void>;
|
|
20
|
+
verifyConditions?(pluginConfig: T, context: VerifyConditionsContext): Promise<void>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { type SemanticReleasePlugin };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/semantic-release/index.ts"],"sourcesContent":["//@ts-ignore\nimport { analyzeCommits } from '@semantic-release/commit-analyzer';\nimport {\n prepare as gitPrepare,\n verifyConditions as gitVerifyConditions,\n //@ts-ignore\n} from '@semantic-release/git';\nimport {\n addChannel as npmAddChannel,\n prepare as npmPrepare,\n publish as npmPublish,\n verifyConditions as npmVerifyConditions,\n //@ts-ignore\n} from '@semantic-release/npm';\n//@ts-ignore\nimport { generateNotes } from '@semantic-release/release-notes-generator';\nimport {\n AddChannelContext,\n AnalyzeCommitsContext,\n FailContext,\n GenerateNotesContext,\n PrepareContext,\n PublishContext,\n SuccessContext,\n VerifyConditionsContext,\n} from 'semantic-release';\n\n// This interface describes the hooks exposed by a semantic-release plugin.\nexport type SemanticReleasePlugin = {\n addChannel?(pluginConfig: unknown, context: AddChannelContext): Promise<void>;\n analyzeCommits?(pluginConfig: unknown, context: AnalyzeCommitsContext): Promise<string | false>;\n fail?(pluginConfig: unknown, context: FailContext): Promise<void>;\n generateNotes?(pluginConfig: unknown, context: GenerateNotesContext): Promise<string>;\n prepare?(pluginConfig: unknown, context: PrepareContext): Promise<void>;\n publish?(pluginConfig: unknown, context: PublishContext): Promise<unknown>;\n success?(pluginConfig: unknown, context: SuccessContext): Promise<void>;\n verifyConditions?(pluginConfig: unknown, context: VerifyConditionsContext): Promise<void>;\n};\n\nconst analyzerConfig = {\n preset: 'conventionalcommits',\n parserOpts: {\n headerPattern: /^(?<type>\\w+)(?<exclamation1>!?)(?:\\((?<scope>[^)]+)\\)(?<exclamation2>!?))?: (?<subject>.+)$/,\n headerCorrespondence: ['type', 'exclamation1', 'scope', 'exclamation2', 'subject'],\n },\n releaseRules: [\n { type: 'feat', exclamation1: '!', release: 'major' },\n { type: 'feat', exclamation2: '!', release: 'major' },\n { type: 'feat', release: 'minor' },\n { type: 'fix', release: 'patch' },\n { type: 'docs', release: 'patch' },\n { type: 'style', release: 'patch' },\n { type: 'refactor', release: 'patch' },\n { type: 'perf', release: 'patch' },\n { type: 'test', release: 'patch' },\n { type: 'build', release: 'patch' },\n { type: 'ci', release: 'patch' },\n { type: 'chore', release: 'patch' },\n { type: 'revert', release: 'patch' },\n ],\n};\n\nconst npmConfig = {\n tag: 'latest',\n npmPublish: true,\n optional: false,\n};\n\nconst gitConfig = {\n assets: ['package.json', 'package-lock.json'],\n message: 'chore(release): ${nextRelease.version}',\n};\n\nconst plugin: SemanticReleasePlugin = {\n addChannel: async (_pluginConfig, context) => {\n if (npmAddChannel) {\n await npmAddChannel(npmConfig, context);\n }\n },\n verifyConditions: async (_pluginConfig, context) => {\n if (npmVerifyConditions) {\n await npmVerifyConditions(npmConfig, context);\n }\n if (gitVerifyConditions) {\n await gitVerifyConditions(gitConfig, context);\n }\n },\n\n analyzeCommits: async (_pluginConfig, context) => {\n return analyzeCommits(analyzerConfig, context);\n },\n\n generateNotes: async (_pluginConfig, context) => {\n return generateNotes({}, context);\n },\n\n prepare: async (_pluginConfig, context) => {\n if (npmPrepare) {\n await npmPrepare(npmConfig, context);\n }\n if (gitPrepare) {\n await gitPrepare(gitConfig, context);\n }\n },\n\n publish: async (_pluginConfig, context) => {\n if (npmPublish) {\n await npmPublish(npmConfig, context);\n }\n /*if (gitPublish) {\n await gitPublish(gitConfig, context);\n }*/\n },\n\n success: async (_pluginConfig, _context) => {\n /*if (gitSuccess) {\n await gitSuccess(gitConfig, context);\n }*/\n },\n\n fail: async (_pluginConfig, _context) => {\n /*if (gitFail) {\n await gitFail(gitConfig, context);\n }*/\n },\n};\n\nexport default plugin;\n"],"names":["analyzerConfig","preset","parserOpts","headerPattern","RegExp","headerCorrespondence","releaseRules","type","exclamation1","release","exclamation2","npmConfig","tag","npmPublish","optional","gitConfig","assets","message","plugin","addChannel","async","_pluginConfig","context","npmAddChannel","verifyConditions","npmVerifyConditions","gitVerifyConditions","analyzeCommits","generateNotes","prepare","npmPrepare","gitPrepare","publish","success","_context","fail"],"mappings":"sTAuCA,MAAMA,EAAiB,CACrBC,OAAQ,sBACRC,WAAY,CACVC,cAAeC,OAAA,mGACfC,qBAAsB,CAAC,OAAQ,eAAgB,QAAS,eAAgB,YAE1EC,aAAc,CACZ,CAAEC,KAAM,OAAQC,aAAc,IAAKC,QAAS,SAC5C,CAAEF,KAAM,OAAQG,aAAc,IAAKD,QAAS,SAC5C,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,MAAOE,QAAS,SACxB,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,QAASE,QAAS,SAC1B,CAAEF,KAAM,WAAYE,QAAS,SAC7B,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,OAAQE,QAAS,SACzB,CAAEF,KAAM,QAASE,QAAS,SAC1B,CAAEF,KAAM,KAAME,QAAS,SACvB,CAAEF,KAAM,QAASE,QAAS,SAC1B,CAAEF,KAAM,SAAUE,QAAS,WAIzBE,EAAY,CAChBC,IAAK,SACLC,YAAY,EACZC,UAAU,GAGNC,EAAY,CAChBC,OAAQ,CAAC,eAAgB,qBACzBC,QAAS,0CAGLC,EAAgC,CACpCC,WAAYC,MAAOC,EAAeC,KAC5BC,SACIA,EAAcZ,EAAWW,EACjC,EAEFE,iBAAkBJ,MAAOC,EAAeC,KAClCG,SACIA,EAAoBd,EAAWW,GAEnCI,SACIA,EAAoBX,EAAWO,EACvC,EAGFK,eAAgBP,MAAOC,EAAeC,IAC7BK,EAAe3B,EAAgBsB,GAGxCM,cAAeR,MAAOC,EAAeC,IAC5BM,EAAc,CAAIN,EAAAA,GAG3BO,QAAST,MAAOC,EAAeC,KACzBQ,SACIA,EAAWnB,EAAWW,GAE1BS,SACIA,EAAWhB,EAAWO,EAC9B,EAGFU,QAASZ,MAAOC,EAAeC,KACzBT,SACIA,EAAWF,EAAWW,EAC9B,EAMFW,QAASb,MAAOC,EAAea,KAAtBd,EAMTe,KAAMf,MAAOC,EAAea,KAAtBd"}
|
|
File without changes
|