release-it
Advanced tools
Comparing version 15.3.0 to 15.4.0
@@ -42,3 +42,4 @@ import { EOL } from 'node:os'; | ||
if (this.options.push && !this.remoteUrl) { | ||
const remoteUrl = this.getContext('remoteUrl'); | ||
if (this.options.push && !remoteUrl) { | ||
throw e(`Could not get remote Git url.${EOL}Please add a remote repository.`, docs); | ||
@@ -52,3 +53,2 @@ } | ||
} | ||
this.config.setContext({ repo: this.getContext('repo') }); | ||
} | ||
@@ -55,0 +55,0 @@ |
@@ -10,12 +10,14 @@ import { EOL } from 'node:os'; | ||
async init() { | ||
this.remoteUrl = await this.getRemoteUrl(); | ||
await this.fetch(); | ||
const remoteUrl = await this.getRemoteUrl(); | ||
await this.fetch(remoteUrl); | ||
const branchName = await this.getBranchName(); | ||
this.setContext({ branchName }); | ||
const repo = parseGitUrl(this.remoteUrl); | ||
const latestTag = await this.getLatestTagName(repo); | ||
const repo = parseGitUrl(remoteUrl); | ||
this.setContext({ remoteUrl, branchName, repo }); | ||
this.config.setContext({ remoteUrl, branchName, repo }); | ||
const latestTag = await this.getLatestTagName(); | ||
const secondLatestTag = !this.config.isIncrement ? await this.getSecondLatestTagName(latestTag) : null; | ||
const tagTemplate = this.options.tagName || ((latestTag || '').match(/^v/) ? 'v${version}' : '${version}'); | ||
this.setContext({ repo }); | ||
this.config.setContext({ tagTemplate, latestTag, secondLatestTag, branchName }); | ||
this.config.setContext({ latestTag, secondLatestTag, tagTemplate }); | ||
} | ||
@@ -85,11 +87,11 @@ | ||
fetch() { | ||
fetch(remoteUrl) { | ||
return this.exec('git fetch').catch(err => { | ||
this.debug(err); | ||
throw new Error(`Unable to fetch from ${this.remoteUrl}${EOL}${err.message}`); | ||
throw new Error(`Unable to fetch from ${remoteUrl}${EOL}${err.message}`); | ||
}); | ||
} | ||
getLatestTagName(repo) { | ||
const context = Object.assign({ repo }, this.getContext(), { version: '*' }); | ||
getLatestTagName() { | ||
const context = Object.assign({}, this.config.getContext(), { version: '*' }); | ||
const match = format(this.options.tagMatch || this.options.tagName || '${version}', context); | ||
@@ -96,0 +98,0 @@ return this.exec(`git describe --tags --match=${match} --abbrev=0`, { options }).then( |
@@ -32,2 +32,3 @@ import path from 'node:path'; | ||
this.setContext({ name, latestVersion, private: isPrivate, publishConfig }); | ||
this.config.setContext({ npm: { name } }); | ||
@@ -34,0 +35,0 @@ const { publish, skipChecks } = this.options; |
{ | ||
"name": "release-it", | ||
"version": "15.3.0", | ||
"version": "15.4.0", | ||
"description": "Generic CLI tool to automate versioning and package publishing related tasks.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -197,3 +197,3 @@ import path from 'node:path'; | ||
gitAdd(`{"name":"${pkgName}","version":"1.0.0"}`, 'package.json', 'Add package.json'); | ||
sh.exec(`git tag ${branchName}-1.0.0`); | ||
sh.exec(`git tag ${pkgName}-${branchName}-1.0.0`); | ||
const sha = gitAdd('line', 'file', 'More file'); | ||
@@ -204,7 +204,12 @@ | ||
project, | ||
body: { tag_name: `${branchName}-1.0.1`, name: 'Release 1.0.1', body: `* More file (${sha})`, prerelease: false } | ||
body: { | ||
tag_name: `${pkgName}-${branchName}-1.0.1`, | ||
name: 'Release 1.0.1', | ||
body: `* More file (${sha})`, | ||
prerelease: false | ||
} | ||
}); | ||
const container = getContainer({ | ||
git: { tagName: '${branchName}-${version}' }, | ||
git: { tagName: '${npm.name}-${branchName}-${version}' }, | ||
github: { release: true, skipChecks: true, pushRepo: `https://github.com/${owner}/${project}` } | ||
@@ -219,5 +224,7 @@ }); | ||
t.true(gitArgs.includes(`git tag --annotate --message Release 1.0.1 ${branchName}-1.0.1`)); | ||
t.true(gitArgs.includes(`git tag --annotate --message Release 1.0.1 ${pkgName}-${branchName}-1.0.1`)); | ||
t.true( | ||
log.log.secondCall.args[0].endsWith(`https://github.com/${owner}/${project}/releases/tag/${branchName}-1.0.1`) | ||
log.log.secondCall.args[0].endsWith( | ||
`https://github.com/${owner}/${project}/releases/tag/${pkgName}-${branchName}-1.0.1` | ||
) | ||
); | ||
@@ -224,0 +231,0 @@ |
219080
5264