-
Notifications
You must be signed in to change notification settings - Fork 526
/
Copy pathsync-pkgs-wireit-helpers.js
226 lines (221 loc) · 6.35 KB
/
sync-pkgs-wireit-helpers.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
function unique(arr) {
return [...new Set(arr)];
}
function concat(...arrays) {
return unique([].concat(...arrays));
}
function generateWireitConfig(pkg, rootPkg) {
const isVictoryPackage = (p) => p.startsWith("victory") && p !== pkg.name;
const deps = Object.keys(pkg.dependencies || {}).filter(isVictoryPackage);
const devDeps = Object.keys(pkg.devDependencies || {}).filter(
isVictoryPackage,
);
const rootDeps = Object.keys(rootPkg.devDependencies).filter(
isVictoryPackage,
);
// Lint require victory-vendor (if dependend) to be built
const lintDeps = [
// victory-vendor has nested path accesses, which means it needs
// to be built for lint to not error on it if a dependency.
...(deps.includes("victory-vendor") ? ["../victory-vendor:build"] : []),
...concat(deps, devDeps, rootDeps).map((dep) => `../${dep}:types:create`),
];
// We want this block to look like JSON, so disable prettier:
// prettier-ignore
return {
"scripts": {
"### THESE SCRIPTS ARE GENERATED ###": "true",
"### DO NOT MODIFY THESE MANUALLY ###": "true",
"build": "wireit",
"build:lib": "wireit",
"build:lib:esm": "wireit",
"build:lib:cjs": "wireit",
"build:dist": "wireit",
"build:dist:dev": "wireit",
"build:dist:min": "wireit",
"check": "wireit",
"types:check": "wireit",
"types:create": "wireit",
"lint": "wireit",
"lint:fix": "wireit",
"jest": "wireit",
},
"wireit": {
"### THESE WIREIT CONFIGS ARE GENERATED ####": {},
"### DO NOT MODIFY THESE MANUALLY ####": {},
"build": {
"dependencies": [
"build:lib",
"build:dist",
"types:create"
],
},
"build:lib": {
"dependencies": [
"build:lib:esm",
"build:lib:cjs"
],
},
"build:lib:esm": {
"command": "nps build:lib:esm",
"files": [
"src/**",
"!src/**/*.test.*",
"../../.babelrc.build.js",
"../../.babelrc.js",
"../../package-scripts.js",
],
"output": [
"es/**/*.js",
"es/**/*.js.map"
],
"dependencies": [
...deps.map((dep) => `../${dep}:build:lib:esm`)
],
"packageLocks": ["pnpm-lock.yaml"]
},
"build:lib:cjs": {
"command": "nps build:lib:cjs",
"files": [
"src/**",
"!src/**/*.test.*",
"../../.babelrc.build.js",
"../../.babelrc.js",
"../../package-scripts.js",
],
"output": [
"lib/**/*.js",
"lib/**/*.js.map"
],
"dependencies": [
...deps.map((dep) => `../${dep}:build:lib:cjs`)
],
"packageLocks": ["pnpm-lock.yaml"]
},
"build:dist": {
"dependencies": [
"build:dist:dev",
"build:dist:min"
],
},
"build:dist:dev": {
"command": "nps build:dist:dev",
"files": [
"src/**",
"!src/**/*.test.*",
"../../.babelrc.build.js",
"../../.babelrc.js",
"../../package-scripts.js",
"../../config/webpack.config.js",
"../../config/webpack.config.dev.js",
],
"output": [
"dist/victory*.js",
"!dist/victory*.min.js*",
],
// Webpack uses:
// 1. Source (`src`) of package being built.
// 2. The ESM version of dependencies specified in our
// `package.json:module` fields.
"dependencies": [
...deps.map((dep) => `../${dep}:build:lib:esm`)
],
"packageLocks": ["pnpm-lock.yaml"]
},
"build:dist:min": {
"command": "nps build:dist:min",
"files": [
"src/**",
"!src/**/*.test.*",
"../../.babelrc.build.js",
"../../.babelrc.js",
"../../package-scripts.js",
"../../config/webpack.config.js",
],
"output": [
"dist/victory*.min.js*"
],
"dependencies": [
...deps.map((dep) => `../${dep}:build:lib:esm`)
],
"packageLocks": ["pnpm-lock.yaml"]
},
"check": {
"dependencies": [
"types:check",
"jest",
"format",
"lint",
]
},
"types:check": {
"command": "nps types:pkg:check",
"files": [
"src/**/*.{ts,tsx}",
"../../tsconfig.base.json",
"tsconfig.json",
],
"dependencies": [
"types:create",
...concat(deps, devDeps, rootDeps)
.map((dep) => `../${dep}:types:create`),
],
"output": [],
"packageLocks": ["pnpm-lock.yaml"]
},
"types:create": {
"command": "nps types:pkg:create",
"files": [
"src/**",
"!src/**/*.test.*",
"../../tsconfig.base.json",
"tsconfig.build.json",
],
"output": [
"es/**/*.d.ts",
"es/**/*.d.ts.map",
"lib/**/*.d.ts",
"lib/**/*.d.ts.map",
],
"dependencies": [
...deps.map((dep) => `../${dep}:types:create`)
],
"packageLocks": ["pnpm-lock.yaml"]
},
// Same as above
...["lint", "lint:fix"].reduce((wireit, key) => {
wireit[key] = {
"command": key === "lint" ? "eslint src" : "eslint --fix src",
"files": [
"src/**",
],
"output": [],
"dependencies": [
...lintDeps,
],
"packageLocks": ["pnpm-lock.yaml"]
};
return wireit;
}, {}),
"jest": {
"command": "jest --passWithNoTests",
"files": [
"src/**/*.test.*",
"../../.babelrc.js",
"../../test/jest-config.js",
"../../test/jest-setup.ts",
],
"output": [],
// Jest uses:
// 1. Source (`src`) for actual test files within a package.
// 2. The CommonJS (`lib`) versions of library files (dependencies
// and the package at issue).
"dependencies": [
...concat(deps, devDeps, rootDeps).map((dep) => `../${dep}:build`),
],
"packageLocks": ["pnpm-lock.yaml"]
},
},
};
}
module.exports = { generateWireitConfig };