Skip to content

Commit 2855102

Browse files
authored
[release] Avoid accidentally releasing the mcp package (#3729)
* Restore MCP package to latest published npm version during SDK release During `--package sdk` bumps, lerna version bumps all packages including `@salesforce/pwa-kit-mcp`. The independent packages are then restored to their pre-bump versions, but MCP carries a dev version in the repo that should never appear in a released SDK. This change restores MCP to its latest published npm version (via `npm info @latest`) instead of the repo dev version, and moves `getLatestVersion` to shared utils so it can be reused. * Fix linting
1 parent 7221d94 commit 2855102

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

scripts/bump-version/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
const sh = require('shelljs')
1111
const path = require('path')
1212
const program = require('commander')
13-
const {saveJSONToFile, setPackageVersion} = require('../utils')
13+
const {saveJSONToFile, setPackageVersion, getLatestVersion} = require('../utils')
1414

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

71+
const notices = []
7172
independentPackages.forEach((pkg) => {
72-
const {location, version: oldVersion} = pkg
73+
const {name, location, version: repoVersion} = pkg
74+
let restoreVersion = repoVersion
75+
if (name === '@salesforce/pwa-kit-mcp') {
76+
restoreVersion = getLatestVersion(name)
77+
notices.push(
78+
`⚠️ Restoring ${name} to its latest published npm version (${restoreVersion}) instead of the repo's dev version (${repoVersion}).\n` +
79+
` This package is released independently and excluded from the monorepo SDK version bump to avoid publishing an unreleased dev version to npm.`
80+
)
81+
}
7382
// Restore to the original version
7483
// TODO: is it possible to _not_ trigger the lifecycle scripts? See commerce-sdk-react/CHANGELOG.md
75-
setPackageVersion(oldVersion, {cwd: location})
84+
setPackageVersion(restoreVersion, {cwd: location})
7685
})
7786

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

93102
listAllVersions()
103+
104+
notices.forEach((msg) => console.log(`\n${msg}`))
94105
}
95106

96107
const updatePeerDeps = (pkgJson, newMonorepoVersion) => {

scripts/bump-version/pwa-kit-deps-version.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/* eslint-disable @typescript-eslint/no-var-requires */
99
const sh = require('shelljs')
1010
const path = require('path')
11-
const {saveJSONToFile} = require('../utils')
11+
const {saveJSONToFile, getLatestVersion} = require('../utils')
1212

1313
// Exit upon error
1414
sh.set('-e')
@@ -51,8 +51,4 @@ const main = () => {
5151
saveJSONToFile(pkgJson, pathToPackageJson)
5252
}
5353

54-
const getLatestVersion = (pkgName) => {
55-
return sh.exec(`npm info ${pkgName}@latest version`, {silent: true}).trim()
56-
}
57-
5854
main()

scripts/utils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@ const setPackageVersion = (version, shellOptions = {}) => {
1616
sh.exec(`npm version --no-git-tag ${version}`, {silent: true, ...shellOptions})
1717
}
1818

19+
const getLatestVersion = (pkgName) => {
20+
return sh.exec(`npm info ${pkgName}@latest version`, {silent: true}).trim()
21+
}
22+
1923
module.exports = {
2024
saveJSONToFile,
21-
setPackageVersion
25+
setPackageVersion,
26+
getLatestVersion
2227
}

0 commit comments

Comments
 (0)