-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathship.config.js
73 lines (67 loc) · 2.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// Currently, ship.js does not support ignoring individual packages.
// The code below is adapted from shipjs-lib to ignore specific packages by prefixing their names with "!".
// Reference: https://github.com/algolia/shipjs/blob/main/packages/shipjs-lib/src/lib/util/expandPackageList.js
const { resolve, join, sep } = require("path");
const { statSync, readdirSync, existsSync } = require("fs");
const isDirectory = (dir) => statSync(dir).isDirectory();
const getDirectories = (dir) =>
readdirSync(dir)
.map((name) => join(dir, name))
.filter(isDirectory);
const hasPackageJson = (dir) => existsSync(`${dir}/package.json`);
const flatten = (arr) => arr.reduce((acc, item) => acc.concat(item), []);
function expandPackageList(list, dir = ".") {
const isPackageIgnored = (package) => {
return expandPackageList(list
.filter(value => value.startsWith("!"))
.map(item => item.slice(1))
).includes(package);
}
return flatten(
list.map((item) => {
if (item.startsWith("!")) {
return;
}
const partIndex = item
.split(sep)
.findIndex((part) => part.startsWith("@(") && part.endsWith(")"));
if (partIndex !== -1) {
const parts = item.split(sep);
const part = parts[partIndex];
const newList = part
.slice(2, part.length - 1)
.split("|")
.map((subPart) => {
const newParts = [...parts];
newParts[partIndex] = subPart;
return newParts.join(sep);
});
return expandPackageList(newList, dir);
}
if (item.endsWith("/*")) {
const basePath = resolve(dir, item.slice(0, item.length - 2));
return expandPackageList(getDirectories(basePath), dir);
} else {
return resolve(dir, item);
}
})
).filter((package) => !isPackageIgnored(package)).filter(hasPackageJson)
}
// ship.js config
module.exports = {
appName: "@dzangolab/fastify",
buildCommand: ({ isYarn, version }) => {
return "pnpm build";
},
installCommand: ({ isYarn }) => {
return "pnpm -r install";
},
monorepo: {
mainVersionFile: "package.json",
packagesToBump: expandPackageList(["packages/*", "!packages/mercurius"]),
packagesToPublish: expandPackageList(["packages/*", "!packages/mercurius"]),
},
publishCommand: ({ isYarn, tag, defaultCommand, dir }) => {
return "pnpm publish --access public";
},
};