@tarsilla/commit-wizard 1.4.7 → 1.4.9
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e from"crypto";import t from"fs";import{
|
|
1
|
+
import{execSync as e}from"child_process";import a from"crypto";import t from"fs";import{analyzeCommits as s}from"@semantic-release/commit-analyzer";import{prepare as r,verifyConditions as n}from"@semantic-release/git";import{addChannel as i,fail as o,publish as c,success as l,verifyConditions as p}from"@semantic-release/github";import{generateNotes as m}from"@semantic-release/release-notes-generator";const f="nextTag-stable.tar.gz",y={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 u=!1;function h(e,a){const{options:t}=a,s=t.repositoryUrl,r=new URL(s).pathname,n=(r.startsWith("/")?r.slice(1):r).split("/").pop();return e.tap??`${n}.rb`}async function w(e,s){const{nextRelease:r,options:n}=s,i=`v${r.version}`,o=n.repositoryUrl,c=new URL(o).pathname,l=`https://github.com/${c.startsWith("/")?c.slice(1):c}/releases/download/${i}/${f.replace("nextTag",i)}`,p=function(e,s){const{nextRelease:r}=s,n=`v${r.version}`,i=f.replace("nextTag",n),o=t.readFileSync(i),c=a.createHash("sha256");return c.update(o),c.digest("hex")}(0,s),m=h(e,s);let y=t.readFileSync(m,"utf8");y=y.replace(/url ".*"/,`url "${l}"`),y=y.replace(/sha256 ".*"/,`sha256 "${p}"`),t.writeFileSync(m,y)}async function x(e,a){p&&await p(e,a),n&&await n(e,a),u=!0}const d={addChannel:async function(e,a){u||(await x(e,a),u=!0),i&&await i(e,a)},verifyConditions:x,analyzeCommits:async function(e,a){return u||(await x(e,a),u=!0),s(y,a)},generateNotes:async function(e,a){return u||(await x(e,a),u=!0),m({},a)},prepare:async function(a,t){if(u||(await x(a,t),u=!0),r){const{nextRelease:s}=t;if(!s?.version)throw new Error("Next release version is not available.");const n=h(a,t);!function(a,t){const{nextRelease:s}=t,r=`v${s.version}`,n=f.replace("nextTag",r);e(`git archive --format=tar.gz --output=${n} HEAD`)}(0,t),await w(a,t),await r({assets:[n],message:"chore(release): ${nextRelease.version}"},t)}},publish:async function(e,a){if(u||(await x(e,a),u=!0),c){const{nextRelease:t}=a,s=`v${t.version}`,r=f.replace("nextTag",s),n={...e,assets:[{path:r,label:`Homebrew Tarball (${s})`}]};await c(n,a)}return null},success:async function(e,a){u||(await x(e,a),u=!0),l&&await l(e,a)},fail:async function(e,a){o&&await r(e,a)}};export{d as default};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../../src/semantic-release/brew/index.ts"],"sourcesContent":["import crypto from 'crypto';\nimport fs from 'fs';\n\nimport { Octokit } from '@octokit/rest';\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\nasync function createTag(_pluginConfig: PluginConfig, context: PrepareContext): Promise<void> {\n if (!process.env.GITHUB_TOKEN) {\n throw new Error('GITHUB_TOKEN is not set in the environment.');\n }\n\n const { nextRelease, logger, options } = context;\n\n const tagName = `v${nextRelease.version}`;\n\n const repositoryUrl = options.repositoryUrl!; // Guaranteed to be defined by semantic-release\n const [owner, repo] = new URL(repositoryUrl).pathname.slice(1).split('/');\n\n logger.log(`Creating tag ${tagName} using GitHub API...`);\n\n const octokit = new Octokit({\n auth: process.env.GITHUB_TOKEN, // Ensure GITHUB_TOKEN is available in the environment\n });\n\n try {\n const branchName = options.branch ?? 'main';\n logger.log(`Branch name: ${branchName}`);\n\n // Get the latest commit SHA from the default branch\n const { data: branch } = await octokit.repos.getBranch({\n owner,\n repo,\n branch: branchName,\n });\n\n const commitSha = branch.commit.sha;\n logger.log(`Latest commit SHA: ${commitSha}`);\n\n // Create the tag object\n logger.log(`Creating tag object for ${tagName}...`);\n await octokit.git.createTag({\n owner,\n repo,\n tag: tagName,\n message: `Release ${tagName}`,\n object: commitSha,\n type: 'commit',\n });\n\n // Create the reference for the tag\n logger.log(`Creating reference for tag ${tagName}...`);\n await octokit.git.createRef({\n owner,\n repo,\n ref: `refs/tags/${tagName}`,\n sha: commitSha,\n });\n\n logger.log(`Tag ${tagName} created successfully.`);\n } catch (error) {\n logger.error(`Failed to create tag ${tagName}: ${(error as Error).message}`);\n throw error;\n }\n}\n\nasync function calculateSha256(url: string, context: PrepareContext): Promise<string> {\n const { logger } = context;\n\n logger.log(`Calculating SHA256 for URL: ${url}`);\n\n const response = await fetch(url);\n\n if (!response.ok) {\n throw new Error(`Failed to fetch file. Status Code: ${response.status}`);\n }\n\n if (!response.body) {\n throw new Error('Response body is null.');\n }\n\n const hash = crypto.createHash('sha256');\n const reader = response.body.getReader();\n\n return new Promise((resolve, reject) => {\n function read() {\n reader\n .read()\n .then(({ done, value }) => {\n if (done) {\n resolve(hash.digest('hex'));\n return;\n }\n if (value) {\n hash.update(value);\n }\n read();\n })\n .catch(reject);\n }\n read();\n });\n}\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 tagName = `v${nextRelease.version}`;\n\n const repositoryUrl = options.repositoryUrl!; // Guaranteed to be defined by semantic-release\n const url = new URL(repositoryUrl);\n const repositoryPath = url.pathname;\n const repository = repositoryPath.startsWith('/') ? repositoryPath.slice(1) : repositoryPath;\n\n const tarUrl = `https://codeload.github.com/${repository}/tar.gz/refs/tags/${tagName}`;\n const sha256 = await calculateSha256(tarUrl, context);\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 ${tagName}, 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 createTag(pluginConfig, context);\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","updateFormulaFile","context","nextRelease","logger","options","version","Error","tagName","tarUrl","sha256","url","log","response","fetch","ok","status","body","hash","crypto","createHash","reader","getReader","Promise","resolve","reject","read","then","done","value","digest","update","catch","calculateSha256","formulaFile","formulaContent","fs","readFileSync","replace","writeFileSync","verifyConditions","gitVerifyConditions","assets","message","plugin","addChannel","_pluginConfig","_context","analyzeCommits","commitAnalyzerAnalyzeCommits","generateNotes","notesGeneratorGenerateNotes","prepare","gitPrepare","process","env","GITHUB_TOKEN","owner","repo","octokit","Octokit","auth","branchName","branch","data","repos","getBranch","commitSha","commit","sha","git","createTag","tag","object","createRef","ref","error","publish","success","fail"],"mappings":"mSA0BA,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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AIC,eAGpB,IACE,MAAMM,EAAazD,EAAQ0D,QAAU,OACrC3D,EAAOQ,IAAI,gBAAgBkD,KAG3B,MAAQE,KAAMD,SAAiBJ,EAAQM,MAAMC,UAAU,CACrDT,QACAC,OACAK,OAAQD,IAGJK,EAAYJ,EAAOK,OAAOC,IAChCjE,EAAOQ,IAAI,sBAAsBuD,KAGjC/D,EAAOQ,IAAI,2BAA2BJ,cAChCmD,EAAQW,IAAIC,UAAU,CAC1Bd,QACAC,OACAc,IAAKhE,EACLmC,QAAS,WAAWnC,IACpBiE,OAAQN,EACRpF,KAAM,WAIRqB,EAAOQ,IAAI,8BAA8BJ,cACnCmD,EAAQW,IAAII,UAAU,CAC1BjB,QACAC,OACAiB,IAAK,aAAanE,IAClB6D,IAAKF,IAGP/D,EAAOQ,IAAI,OAAOJ,0BACpB,CAAE,MAAOoE,GAEP,MADAxE,EAAOwE,MAAM,wBAAwBpE,MAAaoE,EAAgBjC,WAC5DiC,CACR,CACF,CAgHUL,CAAUlF,EAAca,SAExBD,EAAkBZ,EAAca,SAEhCmD,EACJ,CACEX,OAAQ,CAACR,GACTS,QAAS,0CAEXzC,EAEJ,CACF,EAiCE2E,QA/BF7E,eAAuB8C,EAA6BC,GAElD,OAAO,IACT,EA6BE+B,QA3BF9E,eAAuB8C,EAA6BC,GAEpD,EA0BEgC,KAvEF/E,eAAoB8C,EAA6BC,GAEjD"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../../src/semantic-release/brew/index.ts"],"sourcesContent":["import { execSync } from 'child_process';\nimport crypto from 'crypto';\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';\nimport {\n addChannel as gitHubAddChanel,\n fail as gitHubFail,\n publish as gitHubPublish,\n success as gitHubSuccess,\n verifyConditions as gitHubVerifyConditions,\n //@ts-ignore\n} from '@semantic-release/github';\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 tarballFile = 'nextTag-stable.tar.gz';\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, context: PrepareContext): string {\n const { options } = context;\n const repositoryUrl = options.repositoryUrl!;\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\nfunction generateTarball(_pluginConfig: PluginConfig, context: PrepareContext) {\n const { nextRelease } = context;\n\n const nextTag = `v${nextRelease.version}`;\n const tarFilePath = tarballFile.replace('nextTag', nextTag);\n\n execSync(`git archive --format=tar.gz --output=${tarFilePath} HEAD`);\n}\n\nfunction calculateSha256(_pluginConfig: PluginConfig, context: PrepareContext) {\n const { nextRelease } = context;\n\n const nextTag = `v${nextRelease.version}`;\n const tarFilePath = tarballFile.replace('nextTag', nextTag);\n\n const fileBuffer = fs.readFileSync(tarFilePath);\n const hash = crypto.createHash('sha256');\n hash.update(fileBuffer);\n\n return hash.digest('hex');\n}\n\nasync function updateFormulaFile(pluginConfig: PluginConfig, context: PrepareContext): Promise<void> {\n const { nextRelease, options } = context;\n\n const nextTag = `v${nextRelease.version}`;\n\n const repositoryUrl = options.repositoryUrl!;\n const url = new URL(repositoryUrl);\n const repositoryPath = url.pathname;\n const repository = repositoryPath.startsWith('/') ? repositoryPath.slice(1) : repositoryPath;\n const tarFilePath = tarballFile.replace('nextTag', nextTag);\n\n const tarUrl = `https://github.com/${repository}/releases/download/${nextTag}/${tarFilePath}`;\n //const tarUrl = `https://codeload.github.com/${repository}/tar.gz/refs/tags/${tarFilePath}`;\n\n const sha256 = calculateSha256(pluginConfig, context);\n const formulaFile = getFormulaFile(pluginConfig, context);\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\nasync function addChannel(pluginConfig: PluginConfig, context: AddChannelContext): Promise<void> {\n if (!verified) {\n await verifyConditions(pluginConfig, context);\n verified = true;\n }\n\n if (gitHubAddChanel) {\n await gitHubAddChanel(pluginConfig, context);\n }\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 if (gitHubFail) {\n await gitPrepare(pluginConfig, context);\n }\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 { nextRelease } = context;\n if (!nextRelease?.version) {\n throw new Error('Next release version is not available.');\n }\n\n const formulaFile = getFormulaFile(pluginConfig, context);\n\n generateTarball(pluginConfig, context);\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 if (!verified) {\n await verifyConditions(pluginConfig, context);\n verified = true;\n }\n\n if (gitHubPublish) {\n const { nextRelease } = context;\n const nextTag = `v${nextRelease.version}`;\n const tarFilePath = tarballFile.replace('nextTag', nextTag);\n\n const customPluginConfig = {\n ...pluginConfig,\n assets: [\n {\n path: tarFilePath,\n label: `Homebrew Tarball (${nextTag})`,\n },\n ],\n };\n await gitHubPublish(customPluginConfig, context);\n }\n //await updateFormulaFile(pluginConfig, context);\n\n //await commitFormulaFile(pluginConfig, context);\n\n return null;\n}\n\nasync function success(pluginConfig: PluginConfig, context: SuccessContext): Promise<void> {\n if (!verified) {\n await verifyConditions(pluginConfig, context);\n verified = true;\n }\n\n if (gitHubSuccess) {\n await gitHubSuccess(pluginConfig, context);\n }\n}\n\nasync function verifyConditions(pluginConfig: PluginConfig, context: VerifyConditionsContext): Promise<void> {\n if (gitHubVerifyConditions) {\n await gitHubVerifyConditions(pluginConfig, context);\n }\n if (gitVerifyConditions) {\n await gitVerifyConditions(pluginConfig, context);\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":["tarballFile","analyzerConfig","preset","parserOpts","headerPattern","RegExp","headerCorrespondence","releaseRules","type","exclamation1","release","exclamation2","verified","getFormulaFile","pluginConfig","context","options","repositoryUrl","repositoryPath","URL","pathname","project","startsWith","slice","split","pop","tap","async","updateFormulaFile","nextRelease","nextTag","version","tarUrl","replace","sha256","_pluginConfig","tarFilePath","fileBuffer","fs","readFileSync","hash","crypto","createHash","update","digest","calculateSha256","formulaFile","formulaContent","writeFileSync","verifyConditions","gitHubVerifyConditions","gitVerifyConditions","plugin","addChannel","gitHubAddChanel","analyzeCommits","commitAnalyzerAnalyzeCommits","generateNotes","notesGeneratorGenerateNotes","prepare","gitPrepare","Error","execSync","generateTarball","assets","message","publish","gitHubPublish","customPluginConfig","path","label","success","gitHubSuccess","fail","gitHubFail"],"mappings":"oZAkCA,MAAMA,EAAc,wBAEdC,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,MAAMC,QAAEA,GAAYD,EACdE,EAAgBD,EAAQC,cAEx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
"name": "@tarsilla/commit-wizard",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.9",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
62
|
"@octokit/rest": "^21.1.1",
|
|
63
|
+
"@semantic-release/github": "^11.0.1",
|
|
63
64
|
"chokidar": "^4.0.3",
|
|
64
65
|
"inquirer": "^8.2.6"
|
|
65
66
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { execSync } from 'child_process';
|
|
1
2
|
import crypto from 'crypto';
|
|
2
3
|
import fs from 'fs';
|
|
3
4
|
|
|
4
|
-
import { Octokit } from '@octokit/rest';
|
|
5
5
|
//@ts-ignore
|
|
6
6
|
import { analyzeCommits as commitAnalyzerAnalyzeCommits } from '@semantic-release/commit-analyzer';
|
|
7
7
|
import {
|
|
@@ -9,6 +9,14 @@ import {
|
|
|
9
9
|
verifyConditions as gitVerifyConditions,
|
|
10
10
|
//@ts-ignore
|
|
11
11
|
} from '@semantic-release/git';
|
|
12
|
+
import {
|
|
13
|
+
addChannel as gitHubAddChanel,
|
|
14
|
+
fail as gitHubFail,
|
|
15
|
+
publish as gitHubPublish,
|
|
16
|
+
success as gitHubSuccess,
|
|
17
|
+
verifyConditions as gitHubVerifyConditions,
|
|
18
|
+
//@ts-ignore
|
|
19
|
+
} from '@semantic-release/github';
|
|
12
20
|
//@ts-ignore
|
|
13
21
|
import { generateNotes as notesGeneratorGenerateNotes } from '@semantic-release/release-notes-generator';
|
|
14
22
|
import {
|
|
@@ -24,6 +32,8 @@ import {
|
|
|
24
32
|
|
|
25
33
|
import { SemanticReleasePlugin } from '../types.js';
|
|
26
34
|
|
|
35
|
+
const tarballFile = 'nextTag-stable.tar.gz';
|
|
36
|
+
|
|
27
37
|
const analyzerConfig = {
|
|
28
38
|
preset: 'conventionalcommits',
|
|
29
39
|
parserOpts: {
|
|
@@ -51,140 +61,71 @@ type PluginConfig = { tap?: string };
|
|
|
51
61
|
|
|
52
62
|
let verified = false;
|
|
53
63
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
function getFormulaFile(pluginConfig: PluginConfig, context: PrepareContext): string {
|
|
65
|
+
const { options } = context;
|
|
66
|
+
const repositoryUrl = options.repositoryUrl!;
|
|
67
|
+
const url = new URL(repositoryUrl);
|
|
68
|
+
const repositoryPath = url.pathname;
|
|
69
|
+
const repository = repositoryPath.startsWith('/') ? repositoryPath.slice(1) : repositoryPath;
|
|
70
|
+
const project = repository.split('/').pop();
|
|
58
71
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const tagName = `v${nextRelease.version}`;
|
|
62
|
-
|
|
63
|
-
const repositoryUrl = options.repositoryUrl!; // Guaranteed to be defined by semantic-release
|
|
64
|
-
const [owner, repo] = new URL(repositoryUrl).pathname.slice(1).split('/');
|
|
65
|
-
|
|
66
|
-
logger.log(`Creating tag ${tagName} using GitHub API...`);
|
|
67
|
-
|
|
68
|
-
const octokit = new Octokit({
|
|
69
|
-
auth: process.env.GITHUB_TOKEN, // Ensure GITHUB_TOKEN is available in the environment
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
const branchName = options.branch ?? 'main';
|
|
74
|
-
logger.log(`Branch name: ${branchName}`);
|
|
75
|
-
|
|
76
|
-
// Get the latest commit SHA from the default branch
|
|
77
|
-
const { data: branch } = await octokit.repos.getBranch({
|
|
78
|
-
owner,
|
|
79
|
-
repo,
|
|
80
|
-
branch: branchName,
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
const commitSha = branch.commit.sha;
|
|
84
|
-
logger.log(`Latest commit SHA: ${commitSha}`);
|
|
85
|
-
|
|
86
|
-
// Create the tag object
|
|
87
|
-
logger.log(`Creating tag object for ${tagName}...`);
|
|
88
|
-
await octokit.git.createTag({
|
|
89
|
-
owner,
|
|
90
|
-
repo,
|
|
91
|
-
tag: tagName,
|
|
92
|
-
message: `Release ${tagName}`,
|
|
93
|
-
object: commitSha,
|
|
94
|
-
type: 'commit',
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// Create the reference for the tag
|
|
98
|
-
logger.log(`Creating reference for tag ${tagName}...`);
|
|
99
|
-
await octokit.git.createRef({
|
|
100
|
-
owner,
|
|
101
|
-
repo,
|
|
102
|
-
ref: `refs/tags/${tagName}`,
|
|
103
|
-
sha: commitSha,
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
logger.log(`Tag ${tagName} created successfully.`);
|
|
107
|
-
} catch (error) {
|
|
108
|
-
logger.error(`Failed to create tag ${tagName}: ${(error as Error).message}`);
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
72
|
+
return pluginConfig.tap ?? `${project}.rb`;
|
|
111
73
|
}
|
|
112
74
|
|
|
113
|
-
|
|
114
|
-
const {
|
|
75
|
+
function generateTarball(_pluginConfig: PluginConfig, context: PrepareContext) {
|
|
76
|
+
const { nextRelease } = context;
|
|
115
77
|
|
|
116
|
-
|
|
78
|
+
const nextTag = `v${nextRelease.version}`;
|
|
79
|
+
const tarFilePath = tarballFile.replace('nextTag', nextTag);
|
|
117
80
|
|
|
118
|
-
|
|
81
|
+
execSync(`git archive --format=tar.gz --output=${tarFilePath} HEAD`);
|
|
82
|
+
}
|
|
119
83
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
}
|
|
84
|
+
function calculateSha256(_pluginConfig: PluginConfig, context: PrepareContext) {
|
|
85
|
+
const { nextRelease } = context;
|
|
123
86
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
87
|
+
const nextTag = `v${nextRelease.version}`;
|
|
88
|
+
const tarFilePath = tarballFile.replace('nextTag', nextTag);
|
|
127
89
|
|
|
90
|
+
const fileBuffer = fs.readFileSync(tarFilePath);
|
|
128
91
|
const hash = crypto.createHash('sha256');
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return new Promise((resolve, reject) => {
|
|
132
|
-
function read() {
|
|
133
|
-
reader
|
|
134
|
-
.read()
|
|
135
|
-
.then(({ done, value }) => {
|
|
136
|
-
if (done) {
|
|
137
|
-
resolve(hash.digest('hex'));
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (value) {
|
|
141
|
-
hash.update(value);
|
|
142
|
-
}
|
|
143
|
-
read();
|
|
144
|
-
})
|
|
145
|
-
.catch(reject);
|
|
146
|
-
}
|
|
147
|
-
read();
|
|
148
|
-
});
|
|
149
|
-
}
|
|
92
|
+
hash.update(fileBuffer);
|
|
150
93
|
|
|
151
|
-
|
|
152
|
-
const url = new URL(repositoryUrl);
|
|
153
|
-
const repositoryPath = url.pathname;
|
|
154
|
-
const repository = repositoryPath.startsWith('/') ? repositoryPath.slice(1) : repositoryPath;
|
|
155
|
-
const project = repository.split('/').pop();
|
|
156
|
-
|
|
157
|
-
return pluginConfig.tap ?? `${project}.rb`;
|
|
94
|
+
return hash.digest('hex');
|
|
158
95
|
}
|
|
159
96
|
|
|
160
97
|
async function updateFormulaFile(pluginConfig: PluginConfig, context: PrepareContext): Promise<void> {
|
|
161
|
-
const { nextRelease,
|
|
98
|
+
const { nextRelease, options } = context;
|
|
162
99
|
|
|
163
|
-
|
|
164
|
-
throw new Error('Next release version is not available.');
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const tagName = `v${nextRelease.version}`;
|
|
100
|
+
const nextTag = `v${nextRelease.version}`;
|
|
168
101
|
|
|
169
|
-
const repositoryUrl = options.repositoryUrl!;
|
|
102
|
+
const repositoryUrl = options.repositoryUrl!;
|
|
170
103
|
const url = new URL(repositoryUrl);
|
|
171
104
|
const repositoryPath = url.pathname;
|
|
172
105
|
const repository = repositoryPath.startsWith('/') ? repositoryPath.slice(1) : repositoryPath;
|
|
106
|
+
const tarFilePath = tarballFile.replace('nextTag', nextTag);
|
|
173
107
|
|
|
174
|
-
const tarUrl = `https://
|
|
175
|
-
const
|
|
176
|
-
|
|
108
|
+
const tarUrl = `https://github.com/${repository}/releases/download/${nextTag}/${tarFilePath}`;
|
|
109
|
+
//const tarUrl = `https://codeload.github.com/${repository}/tar.gz/refs/tags/${tarFilePath}`;
|
|
110
|
+
|
|
111
|
+
const sha256 = calculateSha256(pluginConfig, context);
|
|
112
|
+
const formulaFile = getFormulaFile(pluginConfig, context);
|
|
177
113
|
|
|
178
114
|
let formulaContent = fs.readFileSync(formulaFile, 'utf8');
|
|
179
115
|
formulaContent = formulaContent.replace(/url ".*"/, `url "${tarUrl}"`);
|
|
180
116
|
formulaContent = formulaContent.replace(/sha256 ".*"/, `sha256 "${sha256}"`);
|
|
181
117
|
fs.writeFileSync(formulaFile, formulaContent);
|
|
182
|
-
|
|
183
|
-
logger.log(`Updated formula with version ${tagName}, URL ${tarUrl}, and SHA256 ${sha256}`);
|
|
184
118
|
}
|
|
185
119
|
|
|
186
|
-
async function addChannel(
|
|
187
|
-
|
|
120
|
+
async function addChannel(pluginConfig: PluginConfig, context: AddChannelContext): Promise<void> {
|
|
121
|
+
if (!verified) {
|
|
122
|
+
await verifyConditions(pluginConfig, context);
|
|
123
|
+
verified = true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (gitHubAddChanel) {
|
|
127
|
+
await gitHubAddChanel(pluginConfig, context);
|
|
128
|
+
}
|
|
188
129
|
}
|
|
189
130
|
|
|
190
131
|
async function analyzeCommits(pluginConfig: PluginConfig, context: AnalyzeCommitsContext): Promise<string | false> {
|
|
@@ -196,8 +137,10 @@ async function analyzeCommits(pluginConfig: PluginConfig, context: AnalyzeCommit
|
|
|
196
137
|
return commitAnalyzerAnalyzeCommits(analyzerConfig, context);
|
|
197
138
|
}
|
|
198
139
|
|
|
199
|
-
async function fail(
|
|
200
|
-
|
|
140
|
+
async function fail(pluginConfig: PluginConfig, context: FailContext): Promise<void> {
|
|
141
|
+
if (gitHubFail) {
|
|
142
|
+
await gitPrepare(pluginConfig, context);
|
|
143
|
+
}
|
|
201
144
|
}
|
|
202
145
|
|
|
203
146
|
async function generateNotes(pluginConfig: PluginConfig, context: GenerateNotesContext): Promise<string> {
|
|
@@ -216,11 +159,14 @@ async function prepare(pluginConfig: PluginConfig, context: PrepareContext): Pro
|
|
|
216
159
|
}
|
|
217
160
|
|
|
218
161
|
if (gitPrepare) {
|
|
219
|
-
const {
|
|
220
|
-
|
|
221
|
-
|
|
162
|
+
const { nextRelease } = context;
|
|
163
|
+
if (!nextRelease?.version) {
|
|
164
|
+
throw new Error('Next release version is not available.');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const formulaFile = getFormulaFile(pluginConfig, context);
|
|
222
168
|
|
|
223
|
-
|
|
169
|
+
generateTarball(pluginConfig, context);
|
|
224
170
|
|
|
225
171
|
await updateFormulaFile(pluginConfig, context);
|
|
226
172
|
|
|
@@ -234,27 +180,52 @@ async function prepare(pluginConfig: PluginConfig, context: PrepareContext): Pro
|
|
|
234
180
|
}
|
|
235
181
|
}
|
|
236
182
|
|
|
237
|
-
async function publish(
|
|
238
|
-
|
|
183
|
+
async function publish(pluginConfig: PluginConfig, context: PublishContext): Promise<unknown> {
|
|
184
|
+
if (!verified) {
|
|
185
|
+
await verifyConditions(pluginConfig, context);
|
|
186
|
+
verified = true;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (gitHubPublish) {
|
|
190
|
+
const { nextRelease } = context;
|
|
191
|
+
const nextTag = `v${nextRelease.version}`;
|
|
192
|
+
const tarFilePath = tarballFile.replace('nextTag', nextTag);
|
|
193
|
+
|
|
194
|
+
const customPluginConfig = {
|
|
195
|
+
...pluginConfig,
|
|
196
|
+
assets: [
|
|
197
|
+
{
|
|
198
|
+
path: tarFilePath,
|
|
199
|
+
label: `Homebrew Tarball (${nextTag})`,
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
};
|
|
203
|
+
await gitHubPublish(customPluginConfig, context);
|
|
204
|
+
}
|
|
205
|
+
//await updateFormulaFile(pluginConfig, context);
|
|
206
|
+
|
|
207
|
+
//await commitFormulaFile(pluginConfig, context);
|
|
208
|
+
|
|
239
209
|
return null;
|
|
240
210
|
}
|
|
241
211
|
|
|
242
|
-
async function success(
|
|
243
|
-
|
|
212
|
+
async function success(pluginConfig: PluginConfig, context: SuccessContext): Promise<void> {
|
|
213
|
+
if (!verified) {
|
|
214
|
+
await verifyConditions(pluginConfig, context);
|
|
215
|
+
verified = true;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (gitHubSuccess) {
|
|
219
|
+
await gitHubSuccess(pluginConfig, context);
|
|
220
|
+
}
|
|
244
221
|
}
|
|
245
222
|
|
|
246
223
|
async function verifyConditions(pluginConfig: PluginConfig, context: VerifyConditionsContext): Promise<void> {
|
|
224
|
+
if (gitHubVerifyConditions) {
|
|
225
|
+
await gitHubVerifyConditions(pluginConfig, context);
|
|
226
|
+
}
|
|
247
227
|
if (gitVerifyConditions) {
|
|
248
|
-
|
|
249
|
-
const repositoryUrl = options.repositoryUrl!; // Guaranteed to be defined by semantic-release
|
|
250
|
-
const formulaFile = getFormulaFile(pluginConfig, repositoryUrl);
|
|
251
|
-
await gitVerifyConditions(
|
|
252
|
-
{
|
|
253
|
-
assets: [formulaFile],
|
|
254
|
-
message: 'chore(release): ${nextRelease.version}',
|
|
255
|
-
},
|
|
256
|
-
context,
|
|
257
|
-
);
|
|
228
|
+
await gitVerifyConditions(pluginConfig, context);
|
|
258
229
|
}
|
|
259
230
|
verified = true;
|
|
260
231
|
}
|