Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions scripts/bump-version/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const sh = require('shelljs')
const path = require('path')
const program = require('commander')
const {saveJSONToFile, setPackageVersion} = require('../utils')
const {saveJSONToFile, setPackageVersion, getLatestVersion} = require('../utils')

// Exit upon error
sh.set('-e')
Expand Down Expand Up @@ -68,11 +68,20 @@ const main = (program) => {
// update versions for root package and root package lock
setPackageVersion(newMonorepoVersion, {cwd: rootPath})

const notices = []
independentPackages.forEach((pkg) => {
const {location, version: oldVersion} = pkg
const {name, location, version: repoVersion} = pkg
let restoreVersion = repoVersion
if (name === '@salesforce/pwa-kit-mcp') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumb question: Instead of restoring a version back, can't we update the bump-version script to skip this package when updating versions ?

Or do we not have control over that since it's lerna driven ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, our script piggy backs on Lerna. So we had to restore the version like that afterwards.

restoreVersion = getLatestVersion(name)
notices.push(
`⚠️ Restoring ${name} to its latest published npm version (${restoreVersion}) instead of the repo's dev version (${repoVersion}).\n` +
` This package is released independently and excluded from the monorepo SDK version bump to avoid publishing an unreleased dev version to npm.`
)
}
// Restore to the original version
// TODO: is it possible to _not_ trigger the lifecycle scripts? See commerce-sdk-react/CHANGELOG.md
setPackageVersion(oldVersion, {cwd: location})
setPackageVersion(restoreVersion, {cwd: location})
})

// Now that all of the package version updates are done,
Expand All @@ -91,6 +100,8 @@ const main = (program) => {
sh.exec('npm install')

listAllVersions()

notices.forEach((msg) => console.log(`\n${msg}`))
}

const updatePeerDeps = (pkgJson, newMonorepoVersion) => {
Expand Down
6 changes: 1 addition & 5 deletions scripts/bump-version/pwa-kit-deps-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const sh = require('shelljs')
const path = require('path')
const {saveJSONToFile} = require('../utils')
const {saveJSONToFile, getLatestVersion} = require('../utils')

// Exit upon error
sh.set('-e')
Expand Down Expand Up @@ -51,8 +51,4 @@ const main = () => {
saveJSONToFile(pkgJson, pathToPackageJson)
}

const getLatestVersion = (pkgName) => {
return sh.exec(`npm info ${pkgName}@latest version`, {silent: true}).trim()
}

main()
7 changes: 6 additions & 1 deletion scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ const setPackageVersion = (version, shellOptions = {}) => {
sh.exec(`npm version --no-git-tag ${version}`, {silent: true, ...shellOptions})
}

const getLatestVersion = (pkgName) => {
return sh.exec(`npm info ${pkgName}@latest version`, {silent: true}).trim()
}

module.exports = {
saveJSONToFile,
setPackageVersion
setPackageVersion,
getLatestVersion
}
Loading