Skip to content

Commit 08d6090

Browse files
authored
chore: re-pin select packages after 'lerna version' (gatsbyjs#35725)
1 parent 2fc7732 commit 08d6090

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

packages/gatsby-parcel-config/package.json

+3
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,8 @@
5151
},
5252
"peerDependencies": {
5353
"@parcel/core": "2.5.0"
54+
},
55+
"scripts": {
56+
"version": "node ../../scripts/pin-version.js"
5457
}
5558
}

packages/gatsby/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@
270270
"postinstall": "node scripts/postinstall.js",
271271
"prepare": "cross-env NODE_ENV=production npm run build",
272272
"watch": "rimraf dist && mkdir dist && npm run build:internal-plugins && npm run build:rawfiles && npm run build:src -- --watch",
273+
"version": "node ../../scripts/pin-version.js",
273274
"typecheck": "tsc --noEmit"
274275
},
275276
"types": "index.d.ts",

scripts/pin-version.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const fs = require(`fs-extra`)
2+
const path = require(`path`)
3+
4+
const packagesToPin = [
5+
`@gatsbyjs/parcel-namer-relative-to-cwd`,
6+
`gatsby-parcel-config`,
7+
]
8+
9+
function adjustDeps(packageDirectoryPath) {
10+
const packageJsonPath = path.join(packageDirectoryPath, `package.json`)
11+
const packageJsonString = fs.readFileSync(packageJsonPath, `utf-8`)
12+
13+
let updatedPackageJson = packageJsonString
14+
15+
for (const packageToPin of packagesToPin) {
16+
const regexp = new RegExp(`"${packageToPin}": "\\^([^"]+)"`, `g`)
17+
18+
updatedPackageJson = updatedPackageJson.replace(
19+
regexp,
20+
`"${packageToPin}": "$1"`
21+
)
22+
}
23+
24+
if (updatedPackageJson !== packageJsonString) {
25+
fs.writeFileSync(packageJsonPath, updatedPackageJson)
26+
}
27+
}
28+
29+
adjustDeps(process.cwd())

0 commit comments

Comments
 (0)