-
Notifications
You must be signed in to change notification settings - Fork 29
/
ship.config.js
48 lines (45 loc) · 1.39 KB
/
ship.config.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const fs = require("fs");
const path = require("path");
module.exports = {
monorepo: {
mainVersionFile: "package.json",
packagesToBump: ["packages/*"],
packagesToPublish: ["packages/*"],
},
versionUpdated: ({ version, dir, exec }) => {
// update lerna.json
updateJson(dir, "lerna.json", (json) => {
json.version = version;
});
// update `version.js`
fs.writeFileSync(
path.resolve(dir, "packages/shipjs/src/version.js"),
`export default '${version}';\n`
);
fs.writeFileSync(
path.resolve(dir, "packages/shipjs-lib/src/version.js"),
`export default '${version}';\n`
);
},
beforeCommitChanges: ({ exec }) => {
exec("./scripts/update-contributors-badge.js");
},
beforePublish: ({ exec }) => {
exec("cp README.md packages/shipjs/");
},
testCommandBeforeRelease: () => 'echo "No test before release"', // TODO: remove later
// skip preparation if the patch update contains no fix
shouldPrepare: ({ releaseType, commitNumbersPerType }) => {
const { fix = 0 } = commitNumbersPerType;
if (releaseType === "patch" && fix === 0) {
return false;
}
return true;
},
};
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));
};