Skip to content

Commit

Permalink
feat!: all manually update version in package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Feb 20, 2024
1 parent 881a3e9 commit 01c9ea1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "release-it-pnpm",
"type": "module",
"version": "1.3.4",
"version": "2.0.0",
"packageManager": "pnpm@8.15.3",
"description": "Run release-it with pnpm workspace",
"author": "Stephen Zhou <hi@hyoban.cc>",
Expand Down Expand Up @@ -48,6 +48,7 @@
"conventional-changelog": "^5.1.0",
"conventional-recommended-bump": "^9.0.0",
"fast-glob": "^3.3.2",
"git-semver-tags": "^7.0.1",
"semver": "^7.6.0",
"should-semantic-release": "^0.3.0",
"yaml": "^2.3.4"
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 17 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'node:path'

import conventionalRecommendedBump from 'conventional-recommended-bump'
import fg from 'fast-glob'
import gitSemverTags from 'git-semver-tags'
import { Plugin } from 'release-it'
import semver from 'semver'
import { shouldSemanticRelease } from 'should-semantic-release'
Expand Down Expand Up @@ -60,18 +61,10 @@ class ReleaseItPnpmPlugin extends Plugin {
}

async init() {
const rootPkg = readJSON(path.resolve(MANIFEST_PATH))
const name = rootPkg.name
this.setContext({ name })
const { name, version } = readJSON(path.resolve(MANIFEST_PATH))
this.setContext({ name, latestVersion: version })

const updates = []

updates.push({
entry: MANIFEST_PATH,
name: rootPkg.name,
version: rootPkg.version,
isRoot: true,
})
const updates = [{ entry: MANIFEST_PATH, name, version, isRoot: true }]

if (hasAccess(MANIFEST_WORKSPACE_PATH)) {
const content = fs.readFileSync(path.resolve(MANIFEST_WORKSPACE_PATH), 'utf8')
Expand Down Expand Up @@ -153,7 +146,7 @@ class ReleaseItPnpmPlugin extends Plugin {
const result = await conventionalRecommendedBump({
preset: {
name: 'conventionalcommits',
preMajor: this.options.preMajor ?? semver.lt(latestVersion, '1.0.0'),
preMajor: semver.lt(latestVersion, '1.0.0'),
},
})
this.debug({ result })
Expand Down Expand Up @@ -187,7 +180,18 @@ class ReleaseItPnpmPlugin extends Plugin {
}
}

getIncrementedVersion(options) {
async getIncrementedVersion(options) {
const tags = await gitSemverTags()
const latestTagVersion = tags[0]
const { latestVersion } = this.getContext()
if (
typeof latestVersion === 'string'
&& semver.valid(latestVersion)
&& typeof latestTagVersion === 'string'
&& semver.gt(latestVersion, latestTagVersion)
) {
return semver.valid(latestVersion)
}
return this.getRecommendedVersion(options)
}

Expand Down

0 comments on commit 01c9ea1

Please sign in to comment.