-
Notifications
You must be signed in to change notification settings - Fork 20
/
ship.config.cjs
26 lines (23 loc) · 804 Bytes
/
ship.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const fs = require('fs');
const path = require('path');
module.exports = {
monorepo: { mainVersionFile: 'lerna.json', packagesToBump: ['packages/*'], packagesToPublish: ['packages/*'] },
publishCommand: () => 'npm publish --tag latest --access public',
buildCommand: () => 'npm run build',
versionUpdated: ({ version, dir }) => {
// update lerna.json
updateJson(dir, 'lerna.json', (json) => {
json.version = version;
});
// update package.json
updateJson(dir, 'package.json', (json) => {
json.version = version;
});
},
};
const updateJson = (dir, fileName, fn) => {
const filePath = path.resolve(dir, fileName);
const json = JSON.parse(fs.readFileSync(filePath).toString());
fn(json);
fs.writeFileSync(filePath, JSON.stringify(json, null, 2));
};