@tarsilla/commit-wizard 1.4.3 → 1.4.5

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 a from"https";import{analyzeCommits as r}from"@semantic-release/commit-analyzer";import{prepare as s,verifyConditions as n}from"@semantic-release/git";import{generateNotes as o}from"@semantic-release/release-notes-generator";const i={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 c=!1;function l(e,t){const a=new URL(t).pathname,r=(a.startsWith("/")?a.slice(1):a).split("/").pop();return e.tap??`${r}.rb`}async function p(r,s){const{nextRelease:n,logger:o,options:i}=s;if(!n?.version)throw new Error("Next release version is not available.");const c=n.version,p=i.repositoryUrl,m=new URL(p).pathname,y=`https://codeload.github.com/${m.startsWith("/")?m.slice(1):m}/tar.gz/refs/tags/v${c}`,f=await async function(t){return new Promise(((r,s)=>{a.get(t,(t=>{const a=e.createHash("sha256");t.on("data",(e=>a.update(e))),t.on("end",(()=>{r(a.digest("hex"))}))})).on("error",(e=>{throw new Error("Error fetching the file:",{cause:e.message})}))}))}(y),h=l(r,p);let u=t.readFileSync(h,"utf8");u=u.replace(/url ".*"/,`url "${y}"`),u=u.replace(/sha256 ".*"/,`sha256 "${f}"`),t.writeFileSync(h,u),o.log(`Updated formula with version ${c}, URL ${y}, and SHA256 ${f}`)}async function m(e,t){if(n){const{options:a}=t,r=l(e,a.repositoryUrl);await n({assets:[r],message:"chore(release): ${nextRelease.version}"},t)}c=!0}const y={addChannel:async function(e,t){},verifyConditions:m,analyzeCommits:async function(e,t){return c||(await m(e,t),c=!0),r(i,t)},generateNotes:async function(e,t){return c||(await m(e,t),c=!0),o({},t)},prepare:async function(e,t){if(c||(await m(e,t),c=!0),s){const{options:a}=t,r=l(e,a.repositoryUrl);await p(e,t),await s({assets:[r],message:"chore(release): ${nextRelease.version}"},t)}},publish:async function(e,t){return null},success:async function(e,t){},fail:async function(e,t){}};export{y as default};
1
+ import e from"crypto";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 o}from"@semantic-release/release-notes-generator";const n={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(a,s){const{nextRelease:r,logger:o,options:n}=s;if(!r?.version)throw new Error("Next release version is not available.");const i=r.version,l=n.repositoryUrl,p=new URL(l).pathname,f=`https://codeload.github.com/${p.startsWith("/")?p.slice(1):p}/tar.gz/refs/tags/v${i}`,y=await async function(t,a){const{logger:s}=a;s.log(`Calculating SHA256 for URL: ${t}`);const r=await fetch(t);if(!r.ok)throw new Error(`Failed to fetch file. Status Code: ${r.status}`);if(!r.body)throw new Error("Response body is null.");const o=e.createHash("sha256"),n=r.body.getReader();return new Promise(((e,t)=>{!function a(){n.read().then((({done:t,value:s})=>{t?e(o.digest("hex")):(s&&o.update(s),a())})).catch(t)}()}))}(f,s),m=c(a,l);let h=t.readFileSync(m,"utf8");h=h.replace(/url ".*"/,`url "${f}"`),h=h.replace(/sha256 ".*"/,`sha256 "${y}"`),t.writeFileSync(m,h),o.log(`Updated formula with version ${i}, URL ${f}, and SHA256 ${y}`)}async function p(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 f={addChannel:async function(e,t){},verifyConditions:p,analyzeCommits:async function(e,t){return i||(await p(e,t),i=!0),a(n,t)},generateNotes:async function(e,t){return i||(await p(e,t),i=!0),o({},t)},prepare:async function(e,t){if(i||(await p(e,t),i=!0),s){const{options:a}=t,r=c(e,a.repositoryUrl);await l(e,t),await s({assets:[r],message:"chore(release): ${nextRelease.version}"},t)}},publish:async function(e,t){return null},success:async function(e,t){},fail:async function(e,t){}};export{f 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';\nimport https from 'https';\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\nasync function calculateSha256(url: string): Promise<string> {\n return new Promise((resolve, _reject) => {\n https\n .get(url, (res) => {\n const hash = crypto.createHash('sha256');\n res.on('data', (chunk) => hash.update(chunk));\n res.on('end', () => {\n resolve(hash.digest('hex'));\n });\n })\n .on('error', (err) => {\n throw new Error('Error fetching the file:', { cause: err.message });\n });\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 version = 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/v${version}`;\n const sha256 = await calculateSha256(tarUrl); //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","updateFormulaFile","context","nextRelease","logger","options","version","Error","tarUrl","sha256","url","Promise","resolve","_reject","https","get","res","hash","crypto","createHash","on","chunk","update","digest","err","cause","message","calculateSha256","formulaFile","formulaContent","fs","readFileSync","replace","writeFileSync","log","verifyConditions","gitVerifyConditions","assets","plugin","addChannel","_pluginConfig","_context","analyzeCommits","commitAnalyzerAnalyzeCommits","generateNotes","notesGeneratorGenerateNotes","prepare","gitPrepare","publish","success","fail"],"mappings":"gRA0BA,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,CAA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L,EAAaC,GAE9BzB,EAAO8B,IAAI,gCAAgC5B,UAAgBE,iBAAsBC,IACnF,CA4DAT,eAAemC,EAAiB9C,EAA4Ba,GAC1D,GAAIkC,EAAqB,CACvB,MAAM/B,QAAEA,GAAYH,EAEd0B,EAAcxC,EAAeC,EADbgB,EAAQf,qBAExB8C,EACJ,CACEC,OAAQ,CAACT,GACTF,QAAS,0CAEXxB,EAEJ,CACAf,GAAW,CACb,CAEA,MAAMmD,EAAiD,CACrDC,WA3EFvC,eAA0BwC,EAA6BC,GAEvD,EA0EEN,mBACAO,eAzEF1C,eAA8BX,EAA4Ba,GAMxD,OALKf,UACGgD,EAAiB9C,EAAca,GACrCf,GAAW,GAGNwD,EAA6BnE,EAAgB0B,EACtD,EAmEE0C,cA7DF5C,eAA6BX,EAA4Ba,GAMvD,OALKf,UACGgD,EAAiB9C,EAAca,GACrCf,GAAW,GAGN0D,EAA4B,CAAI3C,EAAAA,EACzC,EAuDE4C,QArDF9C,eAAuBX,EAA4Ba,GAMjD,GALKf,UACGgD,EAAiB9C,EAAca,GACrCf,GAAW,GAGT4D,EAAY,CACd,MAAM1C,QAAEA,GAAYH,EAEd0B,EAAcxC,EAAeC,EADbgB,EAAQf,qBAGxBW,EAAkBZ,EAAca,SAEhC6C,EACJ,CACEV,OAAQ,CAACT,GACTF,QAAS,0CAEXxB,EAEJ,CACF,EAiCE8C,QA/BFhD,eAAuBwC,EAA6BC,GAElD,OAAO,IACT,EA6BEQ,QA3BFjD,eAAuBwC,EAA6BC,GAEpD,EA0BES,KArEFlD,eAAoBwC,EAA6BC,GAEjD"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/semantic-release/brew/index.ts"],"sourcesContent":["import 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';\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 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 version = 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/v${version}`;\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 ${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","updateFormulaFile","context","nextRelease","logger","options","version","Error","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","publish","success","fail"],"mappings":"2PAyBA,MAAMA,EAAiB,CACrB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d,MAAM/C,QAAEA,GAAYH,EAEd+B,EAAc7C,EAAeC,EADbgB,EAAQf,qBAGxBW,EAAkBZ,EAAca,SAEhCkD,EACJ,CACEX,OAAQ,CAACR,GACTS,QAAS,0CAEXxC,EAEJ,CACF,EAiCEmD,QA/BFrD,eAAuB6C,EAA6BC,GAElD,OAAO,IACT,EA6BEQ,QA3BFtD,eAAuB6C,EAA6BC,GAEpD,EA0BES,KArEFvD,eAAoB6C,EAA6BC,GAEjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarsilla/commit-wizard",
3
- "version": "1.4.3",
3
+ "version": "1.4.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,6 +1,5 @@
1
1
  import crypto from 'crypto';
2
2
  import fs from 'fs';
3
- import https from 'https';
4
3
 
5
4
  //@ts-ignore
6
5
  import { analyzeCommits as commitAnalyzerAnalyzeCommits } from '@semantic-release/commit-analyzer';
@@ -51,19 +50,41 @@ type PluginConfig = { tap?: string };
51
50
 
52
51
  let verified = false;
53
52
 
54
- async function calculateSha256(url: string): Promise<string> {
55
- return new Promise((resolve, _reject) => {
56
- https
57
- .get(url, (res) => {
58
- const hash = crypto.createHash('sha256');
59
- res.on('data', (chunk) => hash.update(chunk));
60
- res.on('end', () => {
61
- resolve(hash.digest('hex'));
62
- });
63
- })
64
- .on('error', (err) => {
65
- throw new Error('Error fetching the file:', { cause: err.message });
66
- });
53
+ async function calculateSha256(url: string, context: PrepareContext): Promise<string> {
54
+ const { logger } = context;
55
+
56
+ logger.log(`Calculating SHA256 for URL: ${url}`);
57
+
58
+ const response = await fetch(url);
59
+
60
+ if (!response.ok) {
61
+ throw new Error(`Failed to fetch file. Status Code: ${response.status}`);
62
+ }
63
+
64
+ if (!response.body) {
65
+ throw new Error('Response body is null.');
66
+ }
67
+
68
+ const hash = crypto.createHash('sha256');
69
+ const reader = response.body.getReader();
70
+
71
+ return new Promise((resolve, reject) => {
72
+ function read() {
73
+ reader
74
+ .read()
75
+ .then(({ done, value }) => {
76
+ if (done) {
77
+ resolve(hash.digest('hex'));
78
+ return;
79
+ }
80
+ if (value) {
81
+ hash.update(value);
82
+ }
83
+ read();
84
+ })
85
+ .catch(reject);
86
+ }
87
+ read();
67
88
  });
68
89
  }
69
90
 
@@ -91,7 +112,7 @@ async function updateFormulaFile(pluginConfig: PluginConfig, context: PrepareCon
91
112
  const repository = repositoryPath.startsWith('/') ? repositoryPath.slice(1) : repositoryPath;
92
113
 
93
114
  const tarUrl = `https://codeload.github.com/${repository}/tar.gz/refs/tags/v${version}`;
94
- const sha256 = await calculateSha256(tarUrl); //execSync(`curl -L ${tarUrl} | sha256sum | awk '{print $1}'`).toString().trim();
115
+ const sha256 = await calculateSha256(tarUrl, context);
95
116
  const formulaFile = getFormulaFile(pluginConfig, repositoryUrl);
96
117
 
97
118
  let formulaContent = fs.readFileSync(formulaFile, 'utf8');