Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 7e188f2

Browse files
authored
fix: run the update example deps script in master and not in ci (#3515)
Do the work all in the js script, not half in js and half in the npm script.
1 parent ba240fd commit 7e188f2

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"release:post:remove-hoisted-modules": "json -I -f ./lerna.json -e \"delete this.command.bootstrap.nohoist\"",
4747
"release:post:remove-examples": "json -I -f ./lerna.json -e \"this.packages = this.packages.filter(p => !p.includes('examples'))\"",
4848
"release:post:revert-ignore-changes-to-lerna-config": "git update-index --no-assume-unchanged ./lerna.json",
49-
"release:post:update-example-dependencies": "node scripts/update-example-deps.js && git add examples && git commit -m 'chore: updated example dependencies' && git push",
49+
"release:post:update-example-dependencies": "node scripts/update-example-deps.js",
5050
"release:rc": "run-s release:pre:* release:canary release:post:*",
5151
"release:canary": "lerna publish --canary --preid rc --dist-tag next --force-publish --yes",
5252
"docker:rc": "run-s docker:rc:*",
@@ -57,6 +57,7 @@
5757
"docker:rc:push-rc": "docker push ipfs/js-ipfs:v`npm show ipfs@next version -q`"
5858
},
5959
"devDependencies": {
60+
"execa": "^5.0.0",
6061
"json": "^10.0.0",
6162
"lerna": "^3.22.0",
6263
"npm-run-all": "^4.1.5",

scripts/update-example-deps.js

+35-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const path = require('path')
44
const fs = require('fs')
5+
const execa = require('execa')
56

67
// Where an example depends on `"ipfs": "^0.51.0"` and we've just released `[email protected]`,
78
// go through all of the examples and update the version to `"ipfs": "^0.52.0"` - do
@@ -12,6 +13,22 @@ const EXAMPLES_DIR = path.resolve(__dirname, '../examples')
1213
const DEP_TYPES = ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']
1314

1415
async function main () {
16+
const {
17+
stdout: branch
18+
} = await execa('git', ['rev-parse', '--abbrev-ref', 'HEAD'])
19+
20+
if (branch !== 'master') {
21+
console.info(`Not running on branch ${branch}`)
22+
return
23+
}
24+
25+
if (process.env.CI) {
26+
console.info('Not running in CI')
27+
return
28+
}
29+
30+
console.info('Running on branch', branch)
31+
1532
for (const dir of fs.readdirSync(PACKAGES_DIR)) {
1633
const projectPkgPath = path.resolve(PACKAGES_DIR, dir, 'package.json')
1734

@@ -45,9 +62,26 @@ async function main () {
4562
}
4663
}
4764
}
65+
66+
await execa('git', ['add', 'examples'])
67+
68+
const {
69+
stdout: updated
70+
} = await execa('git', ['status', '--porcelain'])
71+
72+
console.info(updated)
73+
74+
if (!updated.match(/^M\s+examples/g)) {
75+
console.info('No examples were updated')
76+
return
77+
}
78+
79+
console.info('Pushing updated dependencies')
80+
await execa('git', ['commit', '-m', '"chore: updated example dependencies"'])
81+
await execa('git', ['push'])
4882
}
4983

5084
main().catch(err => {
5185
console.error(err)
5286
process.exit(1)
53-
})
87+
})

0 commit comments

Comments
 (0)