pob 18.1.1 → 18.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/lib/generators/app/PobAppGenerator.js +22 -17
- package/lib/generators/common/format-lint/CommonLintGenerator.js +4 -2
- package/lib/generators/common/format-lint/updateEslintConfig.js +3 -1
- package/lib/generators/common/testing/CommonTestingGenerator.js +195 -156
- package/lib/generators/common/testing/templates/tsconfig.test.json.ejs +10 -0
- package/lib/generators/core/git/CoreGitGenerator.js +2 -2
- package/lib/generators/lib/PobLibGenerator.js +22 -18
- package/lib/generators/monorepo/PobMonorepoGenerator.js +14 -12
- package/lib/generators/monorepo/typescript/MonorepoTypescriptGenerator.js +24 -0
- package/lib/generators/monorepo/typescript/templates/tsconfig.json.ejs +1 -1
- package/lib/generators/pob/PobBaseGenerator.js +12 -12
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [18.2.0](https://github.com/christophehurpeau/pob/compare/pob@18.1.1...pob@18.2.0) (2023-12-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* initial work for monorepo node test runner ([c013532](https://github.com/christophehurpeau/pob/commit/c013532d6f204eb59861a95d946604f858cabe1a))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* monorepo test runner ([d0d443f](https://github.com/christophehurpeau/pob/commit/d0d443ff95c03671378bb1f7a2c947075b982a04))
|
|
17
|
+
* **pob:** fix test override existing detection ([a030544](https://github.com/christophehurpeau/pob/commit/a03054400ded303aa8129f271a5abf1ee0701355))
|
|
18
|
+
* **pob:** fix test override existing detection ([4c54e86](https://github.com/christophehurpeau/pob/commit/4c54e86ba53e0cdad4ffa784ee8d89b96a139a4f))
|
|
19
|
+
|
|
20
|
+
Version bump for dependency: yarn-workspace-utils
|
|
21
|
+
Version bump for dependency: root
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [18.1.1](https://github.com/christophehurpeau/pob/compare/pob@18.1.0...pob@18.1.1) (2023-12-29)
|
|
7
25
|
|
|
8
26
|
|
|
@@ -127,7 +127,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
127
127
|
this.config.save();
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
default() {
|
|
131
131
|
const srcDirectory =
|
|
132
132
|
this.appConfig.type === 'yarn-plugin' ? 'sources' : 'src';
|
|
133
133
|
const isAppLibrary = this.appConfig.type === 'node-library';
|
|
@@ -137,7 +137,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
137
137
|
this.appConfig.type === 'node-library' ||
|
|
138
138
|
this.appConfig.type === 'alp-node'
|
|
139
139
|
) {
|
|
140
|
-
|
|
140
|
+
this.composeWith('pob:common:babel', {
|
|
141
141
|
updateOnly: this.options.updateOnly,
|
|
142
142
|
onlyLatestLTS: true,
|
|
143
143
|
isApp: true,
|
|
@@ -148,7 +148,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
148
148
|
fromPob: this.options.fromPob,
|
|
149
149
|
buildDirectory: 'build',
|
|
150
150
|
});
|
|
151
|
-
|
|
151
|
+
this.composeWith('pob:common:transpiler', {
|
|
152
152
|
updateOnly: this.options.updateOnly,
|
|
153
153
|
onlyLatestLTS: true,
|
|
154
154
|
isApp: true,
|
|
@@ -165,7 +165,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
165
165
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'));
|
|
166
166
|
|
|
167
167
|
if (!inMonorepo || inMonorepo.root) {
|
|
168
|
-
|
|
168
|
+
this.composeWith('pob:common:husky', {});
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
const babelEnvs = (pkg.pob && pkg.pob.babelEnvs) || [];
|
|
@@ -190,7 +190,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
190
190
|
pkg,
|
|
191
191
|
).filter(Boolean);
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
this.composeWith('pob:common:typescript', {
|
|
194
194
|
enable: typescript,
|
|
195
195
|
isApp: true,
|
|
196
196
|
isAppLibrary,
|
|
@@ -235,17 +235,22 @@ export default class PobAppGenerator extends Generator {
|
|
|
235
235
|
})(),
|
|
236
236
|
});
|
|
237
237
|
|
|
238
|
-
|
|
238
|
+
this.composeWith('pob:common:remove-old-dependencies');
|
|
239
239
|
|
|
240
240
|
const enableReleasePlease =
|
|
241
241
|
!inMonorepo && this.appConfig.testing && this.appConfig.ci;
|
|
242
242
|
|
|
243
243
|
if (this.appConfig.type !== 'remix') {
|
|
244
|
-
|
|
244
|
+
this.composeWith('pob:common:testing', {
|
|
245
245
|
enable: this.appConfig.testing,
|
|
246
246
|
disableYarnGitCache: this.options.disableYarnGitCache,
|
|
247
247
|
enableReleasePlease,
|
|
248
248
|
testing: this.appConfig.testing,
|
|
249
|
+
runner: this.appConfig.testing
|
|
250
|
+
? (inMonorepo
|
|
251
|
+
? inMonorepo.pobMonorepoConfig.testRunner
|
|
252
|
+
: this.appConfig.testRunner) || 'jest'
|
|
253
|
+
: undefined,
|
|
249
254
|
e2eTesting: this.appConfig.e2e ? '.' : '',
|
|
250
255
|
typescript,
|
|
251
256
|
build: typescript && this.appConfig.type !== 'expo',
|
|
@@ -259,11 +264,11 @@ export default class PobAppGenerator extends Generator {
|
|
|
259
264
|
srcDirectory,
|
|
260
265
|
});
|
|
261
266
|
|
|
262
|
-
|
|
267
|
+
this.composeWith('pob:app:e2e-testing', {
|
|
263
268
|
enable: this.appConfig.e2e,
|
|
264
269
|
});
|
|
265
270
|
|
|
266
|
-
|
|
271
|
+
this.composeWith('pob:common:format-lint', {
|
|
267
272
|
isApp: true,
|
|
268
273
|
documentation: false,
|
|
269
274
|
testing: this.appConfig.testing,
|
|
@@ -281,7 +286,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
281
286
|
buildDirectory: this.appConfig.type === 'expo' ? '.expo' : 'build',
|
|
282
287
|
});
|
|
283
288
|
|
|
284
|
-
|
|
289
|
+
this.composeWith('pob:common:release', {
|
|
285
290
|
enable:
|
|
286
291
|
!inMonorepo &&
|
|
287
292
|
this.appConfig.testing &&
|
|
@@ -296,7 +301,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
296
301
|
});
|
|
297
302
|
}
|
|
298
303
|
|
|
299
|
-
|
|
304
|
+
this.composeWith('pob:core:vscode', {
|
|
300
305
|
root: !inMonorepo,
|
|
301
306
|
monorepo: false,
|
|
302
307
|
packageManager: this.options.packageManager,
|
|
@@ -310,7 +315,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
310
315
|
ignorePaths.push('/.env*', '!/.env.example');
|
|
311
316
|
}
|
|
312
317
|
|
|
313
|
-
|
|
318
|
+
this.composeWith('pob:core:gitignore', {
|
|
314
319
|
root: !inMonorepo || inMonorepo.root,
|
|
315
320
|
documentation: false,
|
|
316
321
|
testing: this.appConfig.testing,
|
|
@@ -319,16 +324,16 @@ export default class PobAppGenerator extends Generator {
|
|
|
319
324
|
buildInGit: false,
|
|
320
325
|
});
|
|
321
326
|
|
|
322
|
-
|
|
327
|
+
this.composeWith('pob:core:npm', { enable: false });
|
|
323
328
|
|
|
324
329
|
switch (this.appConfig.type) {
|
|
325
330
|
case 'next.js':
|
|
326
|
-
|
|
331
|
+
this.composeWith('pob:app:nextjs', {
|
|
327
332
|
export: this.appConfig.export,
|
|
328
333
|
});
|
|
329
334
|
break;
|
|
330
335
|
case 'remix':
|
|
331
|
-
|
|
336
|
+
this.composeWith('pob:app:remix', {});
|
|
332
337
|
break;
|
|
333
338
|
}
|
|
334
339
|
|
|
@@ -341,7 +346,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
341
346
|
}
|
|
342
347
|
}
|
|
343
348
|
|
|
344
|
-
|
|
349
|
+
writing() {
|
|
345
350
|
// Re-read the content at this point because a composed generator might modify it.
|
|
346
351
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'));
|
|
347
352
|
|
|
@@ -355,6 +360,6 @@ export default class PobAppGenerator extends Generator {
|
|
|
355
360
|
|
|
356
361
|
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
|
|
357
362
|
|
|
358
|
-
|
|
363
|
+
this.composeWith('pob:core:sort-package');
|
|
359
364
|
}
|
|
360
365
|
}
|
|
@@ -404,12 +404,14 @@ export default class CommonLintGenerator extends Generator {
|
|
|
404
404
|
? `{${pkg.type === 'commonjs' ? 'mjs' : 'cjs'},js}`
|
|
405
405
|
: `${hasReact ? '{ts,tsx}' : 'ts'}`;
|
|
406
406
|
|
|
407
|
+
const testRunner = globalTesting
|
|
408
|
+
? inMonorepo.pobConfig.monorepo.testRunner
|
|
409
|
+
: this.options.testRunner;
|
|
407
410
|
const testsOverride =
|
|
408
411
|
this.options.testing || globalTesting
|
|
409
412
|
? {
|
|
410
413
|
files: [`**/*.test.${ext}`, `__tests__/**/*.${ext}`],
|
|
411
|
-
...(
|
|
412
|
-
this.options.testRunner === 'jest'
|
|
414
|
+
...(testRunner == null || testRunner === 'jest'
|
|
413
415
|
? { env: { jest: true } }
|
|
414
416
|
: {}),
|
|
415
417
|
rules: {
|
|
@@ -6,7 +6,9 @@ function updateOverrides(config, testsOverride) {
|
|
|
6
6
|
: config.overrides.findIndex(
|
|
7
7
|
testsOverride.env?.jest
|
|
8
8
|
? (override) => override.env && override.env.jest
|
|
9
|
-
: (override) =>
|
|
9
|
+
: (override) =>
|
|
10
|
+
override?.env?.jest ||
|
|
11
|
+
override.extends?.includes(testsOverride.extends[0]),
|
|
10
12
|
);
|
|
11
13
|
if (!testsOverride) {
|
|
12
14
|
if (existingTestsOverrideIndex !== -1) {
|
|
@@ -115,9 +115,9 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
default() {
|
|
119
119
|
if (!inMonorepo || inMonorepo.root) {
|
|
120
|
-
|
|
120
|
+
this.composeWith('pob:core:ci', {
|
|
121
121
|
enable: this.options.ci,
|
|
122
122
|
enableReleasePlease: this.options.enableReleasePlease,
|
|
123
123
|
enableYarnVersion: this.options.enableYarnVersion,
|
|
@@ -135,7 +135,7 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
135
135
|
onlyLatestLTS: this.options.onlyLatestLTS,
|
|
136
136
|
});
|
|
137
137
|
} else {
|
|
138
|
-
|
|
138
|
+
this.composeWith('pob:core:ci', {
|
|
139
139
|
enable: false,
|
|
140
140
|
});
|
|
141
141
|
}
|
|
@@ -170,8 +170,21 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
170
170
|
(this.options.monorepo
|
|
171
171
|
? yoConfigPobMonorepo.react ?? packageUtils.hasReact(pkg)
|
|
172
172
|
: packageUtils.hasReact(pkg));
|
|
173
|
+
const testRunner = globalTesting
|
|
174
|
+
? inMonorepo.pobConfig.monorepo.testRunner || 'jest'
|
|
175
|
+
: this.options.runner;
|
|
173
176
|
|
|
174
|
-
const isJestRunner =
|
|
177
|
+
const isJestRunner = testRunner === 'jest';
|
|
178
|
+
|
|
179
|
+
const tsTestUtil = 'ts-node'; // : 'babel' | 'tsimp' | 'ts-node' | 'swc'
|
|
180
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
181
|
+
pkg,
|
|
182
|
+
this.options.enable &&
|
|
183
|
+
(!inMonorepo || inMonorepo.root) &&
|
|
184
|
+
testRunner === 'node' &&
|
|
185
|
+
this.options.typescript,
|
|
186
|
+
[tsTestUtil],
|
|
187
|
+
);
|
|
175
188
|
|
|
176
189
|
if (
|
|
177
190
|
!this.options.enable ||
|
|
@@ -187,7 +200,6 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
187
200
|
this.fs.delete(this.destinationPath('jest.config.json'));
|
|
188
201
|
}
|
|
189
202
|
|
|
190
|
-
const tsTestUtil = 'ts-node'; // : 'tsimp' | 'ts-node' | 'swc
|
|
191
203
|
const tsTestLoaderOption = (() => {
|
|
192
204
|
switch (tsTestUtil) {
|
|
193
205
|
case 'tsimp':
|
|
@@ -198,13 +210,6 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
198
210
|
return '--import=@swc-node/register/esm';
|
|
199
211
|
}
|
|
200
212
|
})();
|
|
201
|
-
packageUtils.addOrRemoveDevDependencies(
|
|
202
|
-
pkg,
|
|
203
|
-
this.options.enable &&
|
|
204
|
-
this.options.runner === 'node' &&
|
|
205
|
-
this.options.typescript,
|
|
206
|
-
[tsTestUtil],
|
|
207
|
-
);
|
|
208
213
|
|
|
209
214
|
const createTestCommand = ({
|
|
210
215
|
coverage,
|
|
@@ -212,8 +217,10 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
212
217
|
coverageJson,
|
|
213
218
|
watch,
|
|
214
219
|
shouldUseExperimentalVmModules,
|
|
220
|
+
workspacesPattern,
|
|
221
|
+
hasReact,
|
|
215
222
|
}) => {
|
|
216
|
-
switch (
|
|
223
|
+
switch (testRunner) {
|
|
217
224
|
case 'jest': {
|
|
218
225
|
return `${
|
|
219
226
|
shouldUseExperimentalVmModules
|
|
@@ -232,6 +239,9 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
232
239
|
}`;
|
|
233
240
|
}
|
|
234
241
|
case 'node': {
|
|
242
|
+
if (!workspacesPattern && this.options.monorepo) {
|
|
243
|
+
throw new Error('Invalid workspacesPattern');
|
|
244
|
+
}
|
|
235
245
|
return `${tsTestUtil === 'tsimp' ? 'TSIMP_DIAG=ignore ' : ''}${
|
|
236
246
|
tsTestUtil === 'ts-node'
|
|
237
247
|
? 'TS_NODE_PROJECT=tsconfig.test.json '
|
|
@@ -246,16 +256,25 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
246
256
|
: ''
|
|
247
257
|
}node ${
|
|
248
258
|
this.options.typescript ? `${tsTestLoaderOption} ` : ''
|
|
249
|
-
}--test ${
|
|
250
|
-
this.options.
|
|
251
|
-
|
|
259
|
+
}--test ${
|
|
260
|
+
this.options.monorepo
|
|
261
|
+
? workspacesPattern
|
|
262
|
+
: this.options.srcDirectory
|
|
263
|
+
}/${this.options.typescript ? '**/*.test.ts' : '**/*.test.js'}`;
|
|
252
264
|
}
|
|
253
265
|
default: {
|
|
254
|
-
throw new Error(
|
|
266
|
+
throw new Error(`Invalid runner: "${testRunner}"`);
|
|
255
267
|
}
|
|
256
268
|
}
|
|
257
269
|
};
|
|
258
270
|
|
|
271
|
+
const jestConfigPath = this.destinationPath('jest.config.json');
|
|
272
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
273
|
+
pkg,
|
|
274
|
+
(enableForMonorepo || !globalTesting) && testRunner === 'jest',
|
|
275
|
+
['jest', '@types/jest'],
|
|
276
|
+
);
|
|
277
|
+
|
|
259
278
|
if (!this.options.enable) {
|
|
260
279
|
// if (inMonorepo) {
|
|
261
280
|
// if (pkg.scripts.test === 'echo "No tests"') {
|
|
@@ -263,27 +282,32 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
263
282
|
// }
|
|
264
283
|
// delete pkg.scripts['generate:test-coverage'];
|
|
265
284
|
// }
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
285
|
+
packageUtils.removeScripts([
|
|
286
|
+
'test',
|
|
287
|
+
'test:coverage',
|
|
288
|
+
'generate:test-coverage',
|
|
289
|
+
'test:watch',
|
|
290
|
+
'test:coverage',
|
|
291
|
+
'test:coverage:json',
|
|
292
|
+
'test:coverage:lcov',
|
|
293
|
+
]);
|
|
274
294
|
|
|
275
295
|
writeAndFormatJson(this.fs, this.destinationPath('package.json'), pkg);
|
|
276
296
|
} else {
|
|
277
|
-
|
|
278
|
-
if (this.options.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
297
|
+
let workspacesPattern;
|
|
298
|
+
if (this.options.monorepo) {
|
|
299
|
+
const workspacesWithoutStar = pkg.workspaces.map((workspace) => {
|
|
300
|
+
if (!workspace.endsWith('/*')) {
|
|
301
|
+
throw new Error(`Invalid workspace format: ${workspace}`);
|
|
302
|
+
}
|
|
303
|
+
return workspace.slice(0, -2);
|
|
304
|
+
});
|
|
305
|
+
workspacesPattern =
|
|
306
|
+
workspacesWithoutStar.length === 1
|
|
307
|
+
? workspacesWithoutStar[0]
|
|
308
|
+
: `@(${workspacesWithoutStar.join('|')})`;
|
|
284
309
|
}
|
|
285
310
|
|
|
286
|
-
packageUtils.removeScripts(['test:coverage']);
|
|
287
311
|
if (this.options.monorepo && !globalTesting) {
|
|
288
312
|
packageUtils.addScripts(pkg, {
|
|
289
313
|
test: 'yarn workspaces foreach --parallel -Av run test',
|
|
@@ -292,36 +316,33 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
292
316
|
const shouldUseExperimentalVmModules = pkg.type === 'module';
|
|
293
317
|
|
|
294
318
|
packageUtils.addScripts(pkg, {
|
|
295
|
-
test: createTestCommand({
|
|
319
|
+
test: createTestCommand({
|
|
320
|
+
workspacesPattern,
|
|
321
|
+
shouldUseExperimentalVmModules,
|
|
322
|
+
}),
|
|
296
323
|
'test:watch': createTestCommand({
|
|
324
|
+
workspacesPattern,
|
|
297
325
|
shouldUseExperimentalVmModules,
|
|
298
326
|
watch: true,
|
|
299
327
|
}),
|
|
300
328
|
'test:coverage': createTestCommand({
|
|
329
|
+
workspacesPattern,
|
|
301
330
|
shouldUseExperimentalVmModules,
|
|
302
331
|
coverage: true,
|
|
303
332
|
}),
|
|
304
333
|
'test:coverage:lcov': createTestCommand({
|
|
334
|
+
workspacesPattern,
|
|
305
335
|
shouldUseExperimentalVmModules,
|
|
306
336
|
coverageLcov: true,
|
|
307
337
|
}),
|
|
308
338
|
'test:coverage:json': createTestCommand({
|
|
339
|
+
workspacesPattern,
|
|
309
340
|
shouldUseExperimentalVmModules,
|
|
310
341
|
coverageJson: true,
|
|
311
342
|
}),
|
|
312
343
|
});
|
|
313
344
|
|
|
314
345
|
if (isJestRunner) {
|
|
315
|
-
const workspacesWithoutStar = pkg.workspaces.map((workspace) => {
|
|
316
|
-
if (!workspace.endsWith('/*')) {
|
|
317
|
-
throw new Error(`Invalid workspace format: ${workspace}`);
|
|
318
|
-
}
|
|
319
|
-
return workspace.slice(0, -2);
|
|
320
|
-
});
|
|
321
|
-
const workspacesPattern =
|
|
322
|
-
workspacesWithoutStar.length === 1
|
|
323
|
-
? workspacesWithoutStar[0]
|
|
324
|
-
: `@(${workspacesWithoutStar.join('|')})`;
|
|
325
346
|
hasReact = yoConfigPobMonorepo.packageNames.some((pkgName) =>
|
|
326
347
|
pkgName.startsWith('react-'),
|
|
327
348
|
);
|
|
@@ -353,133 +374,151 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
353
374
|
}
|
|
354
375
|
writeAndFormatJson(this.fs, jestConfigPath, jestConfig);
|
|
355
376
|
}
|
|
356
|
-
} else if (globalTesting) {
|
|
357
|
-
if (pkg.scripts) {
|
|
358
|
-
delete pkg.scripts['generate:test-coverage'];
|
|
359
|
-
delete pkg.scripts['test:watch'];
|
|
360
|
-
delete pkg.scripts['test:coverage'];
|
|
361
|
-
}
|
|
362
|
-
packageUtils.addScripts(pkg, {
|
|
363
|
-
test: `yarn ../../ run test -- ${path
|
|
364
|
-
.relative('../..', '.')
|
|
365
|
-
.replace('\\', '/')}`,
|
|
366
|
-
});
|
|
367
377
|
} else {
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
shouldUseExperimentalVmModules,
|
|
383
|
-
coverage: true,
|
|
384
|
-
}),
|
|
385
|
-
'test:coverage:lcov': createTestCommand({
|
|
386
|
-
shouldUseExperimentalVmModules,
|
|
387
|
-
coverageLcov: true,
|
|
388
|
-
}),
|
|
389
|
-
'test:coverage:json': createTestCommand({
|
|
390
|
-
shouldUseExperimentalVmModules,
|
|
391
|
-
coverageJson: true,
|
|
392
|
-
}),
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
if (this.options.runner === 'jest') {
|
|
396
|
-
const srcDirectory =
|
|
397
|
-
transpileWithBabel || withTypescript
|
|
398
|
-
? this.options.srcDirectory
|
|
399
|
-
: 'lib';
|
|
378
|
+
const tsconfigTestPath = this.destinationPath('tsconfig.test.json');
|
|
379
|
+
if (testRunner === 'node' && withTypescript) {
|
|
380
|
+
const nodeVersion = this.options.onlyLatestLTS ? '20' : '18';
|
|
381
|
+
copyAndFormatTpl(
|
|
382
|
+
this.fs,
|
|
383
|
+
this.templatePath('tsconfig.test.json.ejs'),
|
|
384
|
+
tsconfigTestPath,
|
|
385
|
+
{
|
|
386
|
+
nodeVersion,
|
|
387
|
+
},
|
|
388
|
+
);
|
|
389
|
+
} else {
|
|
390
|
+
this.fs.delete(tsconfigTestPath);
|
|
391
|
+
}
|
|
400
392
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}${hasReact ? '?(x)' : ''}`,
|
|
412
|
-
],
|
|
413
|
-
collectCoverageFrom: [
|
|
414
|
-
`${srcDirectory}/**/*.${withTypescript ? 'ts' : '?(m)js'}${
|
|
415
|
-
hasReact ? '?(x)' : ''
|
|
416
|
-
}`,
|
|
417
|
-
],
|
|
418
|
-
moduleFileExtensions: [
|
|
419
|
-
withTypescript && 'ts',
|
|
420
|
-
withTypescript && hasReact && 'tsx',
|
|
421
|
-
'js',
|
|
422
|
-
// 'jsx',
|
|
423
|
-
'json',
|
|
424
|
-
].filter(Boolean),
|
|
425
|
-
// transform: {
|
|
426
|
-
// [`^.+\\.ts${hasReact ? 'x?' : ''}$`]: 'babel-jest',
|
|
427
|
-
// },
|
|
393
|
+
if (globalTesting) {
|
|
394
|
+
if (pkg.scripts) {
|
|
395
|
+
delete pkg.scripts['generate:test-coverage'];
|
|
396
|
+
delete pkg.scripts['test:watch'];
|
|
397
|
+
delete pkg.scripts['test:coverage'];
|
|
398
|
+
}
|
|
399
|
+
packageUtils.addScripts(pkg, {
|
|
400
|
+
test: `yarn ../../ run test -- ${path
|
|
401
|
+
.relative('../..', '.')
|
|
402
|
+
.replace('\\', '/')}`,
|
|
428
403
|
});
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
404
|
+
} else {
|
|
405
|
+
const babelEnvs = pkg.pob?.babelEnvs || [];
|
|
406
|
+
const transpileWithBabel = packageUtils.transpileWithBabel(pkg);
|
|
407
|
+
const withTypescript = babelEnvs.length > 0 || pkg.pob?.typescript;
|
|
408
|
+
|
|
409
|
+
const shouldUseExperimentalVmModules =
|
|
410
|
+
pkg.type === 'module' && !inMonorepo;
|
|
411
|
+
|
|
412
|
+
packageUtils.addScripts(pkg, {
|
|
413
|
+
test: createTestCommand({ shouldUseExperimentalVmModules }),
|
|
414
|
+
'test:watch': createTestCommand({
|
|
415
|
+
shouldUseExperimentalVmModules,
|
|
416
|
+
watch: true,
|
|
417
|
+
}),
|
|
418
|
+
'test:coverage': createTestCommand({
|
|
419
|
+
shouldUseExperimentalVmModules,
|
|
420
|
+
coverage: true,
|
|
421
|
+
}),
|
|
422
|
+
'test:coverage:lcov': createTestCommand({
|
|
423
|
+
shouldUseExperimentalVmModules,
|
|
424
|
+
coverageLcov: true,
|
|
425
|
+
}),
|
|
426
|
+
'test:coverage:json': createTestCommand({
|
|
427
|
+
shouldUseExperimentalVmModules,
|
|
428
|
+
coverageJson: true,
|
|
429
|
+
}),
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
if (testRunner === 'jest') {
|
|
433
|
+
const srcDirectory =
|
|
434
|
+
transpileWithBabel || withTypescript
|
|
435
|
+
? this.options.srcDirectory
|
|
436
|
+
: 'lib';
|
|
437
|
+
|
|
438
|
+
const jestConfig = this.fs.readJSON(jestConfigPath, pkg.jest ?? {});
|
|
439
|
+
delete pkg.jest;
|
|
440
|
+
Object.assign(jestConfig, {
|
|
441
|
+
cacheDirectory: './node_modules/.cache/jest',
|
|
442
|
+
testMatch: [
|
|
443
|
+
`<rootDir>/${srcDirectory}/**/__tests__/**/*.${
|
|
444
|
+
withTypescript ? 'ts' : '?(m)js'
|
|
445
|
+
}${hasReact ? '?(x)' : ''}`,
|
|
446
|
+
`<rootDir>/${srcDirectory}/**/*.test.${
|
|
447
|
+
withTypescript ? 'ts' : '?(m)js'
|
|
448
|
+
}${hasReact ? '?(x)' : ''}`,
|
|
436
449
|
],
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
450
|
+
collectCoverageFrom: [
|
|
451
|
+
`${srcDirectory}/**/*.${withTypescript ? 'ts' : '?(m)js'}${
|
|
452
|
+
hasReact ? '?(x)' : ''
|
|
453
|
+
}`,
|
|
454
|
+
],
|
|
455
|
+
moduleFileExtensions: [
|
|
456
|
+
withTypescript && 'ts',
|
|
457
|
+
withTypescript && hasReact && 'tsx',
|
|
458
|
+
'js',
|
|
459
|
+
// 'jsx',
|
|
460
|
+
'json',
|
|
461
|
+
].filter(Boolean),
|
|
462
|
+
// transform: {
|
|
463
|
+
// [`^.+\\.ts${hasReact ? 'x?' : ''}$`]: 'babel-jest',
|
|
464
|
+
// },
|
|
465
|
+
});
|
|
466
|
+
if (transpileWithEsbuild) {
|
|
467
|
+
jestConfig.transform = {
|
|
468
|
+
[hasReact ? '^.+\\.tsx?$' : '^.+\\.ts$']: [
|
|
469
|
+
'jest-esbuild',
|
|
470
|
+
{
|
|
471
|
+
format: shouldUseExperimentalVmModules ? 'esm' : 'cjs',
|
|
472
|
+
},
|
|
473
|
+
],
|
|
474
|
+
};
|
|
475
|
+
} else if (!transpileWithBabel) {
|
|
452
476
|
delete jestConfig.transform;
|
|
477
|
+
} else if (jestConfig.transform) {
|
|
478
|
+
jestConfig.transform = Object.fromEntries(
|
|
479
|
+
Object.entries(jestConfig.transform).filter(
|
|
480
|
+
([key, value]) =>
|
|
481
|
+
!(
|
|
482
|
+
value &&
|
|
483
|
+
Array.isArray(value) &&
|
|
484
|
+
value[0] === 'jest-esbuild'
|
|
485
|
+
),
|
|
486
|
+
),
|
|
487
|
+
);
|
|
488
|
+
if (Object.keys(jestConfig.transform).length === 0) {
|
|
489
|
+
delete jestConfig.transform;
|
|
490
|
+
}
|
|
453
491
|
}
|
|
454
|
-
}
|
|
455
492
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
493
|
+
if (shouldUseExperimentalVmModules) {
|
|
494
|
+
jestConfig.extensionsToTreatAsEsm = [
|
|
495
|
+
withTypescript && '.ts',
|
|
496
|
+
withTypescript && hasReact && '.tsx',
|
|
497
|
+
].filter(Boolean);
|
|
498
|
+
} else {
|
|
499
|
+
delete jestConfig.extensionsToTreatAsEsm;
|
|
500
|
+
}
|
|
464
501
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
502
|
+
if (
|
|
503
|
+
babelEnvs.length === 0 ||
|
|
504
|
+
babelEnvs.some((env) => env.target === 'node')
|
|
505
|
+
) {
|
|
506
|
+
// jestConfig.testEnvironment = 'node'; this is the default now
|
|
507
|
+
delete jestConfig.testEnvironment;
|
|
508
|
+
} else {
|
|
509
|
+
delete jestConfig.testEnvironment;
|
|
510
|
+
}
|
|
474
511
|
|
|
475
|
-
|
|
512
|
+
writeAndFormatJson(this.fs, jestConfigPath, jestConfig);
|
|
513
|
+
}
|
|
476
514
|
}
|
|
477
515
|
}
|
|
478
516
|
}
|
|
479
517
|
|
|
480
518
|
if (
|
|
481
519
|
transpileWithBabel &&
|
|
482
|
-
((this.options.monorepo && globalTesting) || !globalTesting)
|
|
520
|
+
((this.options.monorepo && globalTesting) || !globalTesting) &&
|
|
521
|
+
testRunner === 'jest'
|
|
483
522
|
) {
|
|
484
523
|
// cjs for jest compat
|
|
485
524
|
copyAndFormatTpl(
|
|
@@ -99,9 +99,9 @@ export default class CoreGitGenerator extends Generator {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
default() {
|
|
103
103
|
if (this.gitHost === 'github') {
|
|
104
|
-
|
|
104
|
+
this.composeWith('pob:core:git:github', {
|
|
105
105
|
shouldCreate: !this.originUrl,
|
|
106
106
|
gitHostAccount: this.gitHostAccount,
|
|
107
107
|
repoName: this.repoName,
|
|
@@ -229,14 +229,14 @@ export default class PobLibGenerator extends Generator {
|
|
|
229
229
|
|
|
230
230
|
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
this.composeWith('pob:common:babel', {
|
|
233
233
|
updateOnly: this.options.updateOnly,
|
|
234
234
|
testing: !!this.pobjson.testing,
|
|
235
235
|
documentation: !!this.pobjson.documentation,
|
|
236
236
|
fromPob: this.options.fromPob,
|
|
237
237
|
onlyLatestLTS: false,
|
|
238
238
|
});
|
|
239
|
-
|
|
239
|
+
this.composeWith('pob:common:transpiler', {
|
|
240
240
|
updateOnly: this.options.updateOnly,
|
|
241
241
|
testing: !!this.pobjson.testing,
|
|
242
242
|
documentation: !!this.pobjson.documentation,
|
|
@@ -245,7 +245,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
245
245
|
});
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
default() {
|
|
249
249
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'));
|
|
250
250
|
const babelEnvs = pkg.pob.babelEnvs || [];
|
|
251
251
|
|
|
@@ -255,7 +255,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
255
255
|
const browser =
|
|
256
256
|
withBabel && babelEnvs.some((env) => env.target === 'browser');
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
this.composeWith('pob:common:typescript', {
|
|
259
259
|
enable: withTypescript,
|
|
260
260
|
isApp: false,
|
|
261
261
|
dom: browser,
|
|
@@ -266,21 +266,23 @@ export default class PobLibGenerator extends Generator {
|
|
|
266
266
|
onlyLatestLTS: false,
|
|
267
267
|
});
|
|
268
268
|
|
|
269
|
-
|
|
269
|
+
this.composeWith('pob:common:husky', {});
|
|
270
270
|
|
|
271
|
-
|
|
271
|
+
this.composeWith('pob:common:remove-old-dependencies');
|
|
272
272
|
|
|
273
273
|
const enableReleasePlease =
|
|
274
274
|
!inMonorepo && this.pobjson.testing && this.pobjson.testing.ci;
|
|
275
275
|
|
|
276
|
-
|
|
276
|
+
this.composeWith('pob:common:testing', {
|
|
277
277
|
enable: this.pobjson.testing,
|
|
278
278
|
disableYarnGitCache: this.options.disableYarnGitCache,
|
|
279
279
|
enableReleasePlease,
|
|
280
280
|
testing: this.pobjson.testing,
|
|
281
281
|
e2eTesting: false,
|
|
282
282
|
runner: this.pobjson.testing
|
|
283
|
-
?
|
|
283
|
+
? (inMonorepo
|
|
284
|
+
? inMonorepo.pobMonorepoConfig.testRunner
|
|
285
|
+
: this.pobjson.testing.runner) || 'jest'
|
|
284
286
|
: undefined,
|
|
285
287
|
build: withBabel || withTypescript,
|
|
286
288
|
typescript: withTypescript,
|
|
@@ -293,32 +295,34 @@ export default class PobLibGenerator extends Generator {
|
|
|
293
295
|
});
|
|
294
296
|
|
|
295
297
|
// must be after testing
|
|
296
|
-
|
|
298
|
+
this.composeWith('pob:common:format-lint', {
|
|
297
299
|
typescript: withTypescript,
|
|
298
300
|
documentation:
|
|
299
301
|
!!this.pobjson.documentation ||
|
|
300
302
|
!!(this.pobjson.testing && this.pobjson.testing.codecov),
|
|
301
303
|
testing: !!this.pobjson.testing,
|
|
302
|
-
testRunner:
|
|
304
|
+
testRunner: inMonorepo
|
|
305
|
+
? inMonorepo.pobMonorepoConfig.testRunner
|
|
306
|
+
: this.pobjson.testing?.runner,
|
|
303
307
|
packageManager: this.options.packageManager,
|
|
304
308
|
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
305
309
|
ignorePaths: withBabel || withTypescript ? '/dist' : '',
|
|
306
310
|
});
|
|
307
311
|
|
|
308
|
-
|
|
312
|
+
this.composeWith('pob:lib:doc', {
|
|
309
313
|
enabled: this.pobjson.documentation,
|
|
310
314
|
testing: this.pobjson.testing,
|
|
311
315
|
});
|
|
312
316
|
|
|
313
317
|
// must be after doc, testing
|
|
314
|
-
|
|
318
|
+
this.composeWith('pob:lib:readme', {
|
|
315
319
|
documentation: !!this.pobjson.documentation,
|
|
316
320
|
testing: !!this.pobjson.testing,
|
|
317
321
|
ci: this.pobjson.testing && this.pobjson.testing.ci,
|
|
318
322
|
codecov: this.pobjson.testing && this.pobjson.testing.codecov,
|
|
319
323
|
});
|
|
320
324
|
|
|
321
|
-
|
|
325
|
+
this.composeWith('pob:common:release', {
|
|
322
326
|
enable: !inMonorepo && this.pobjson.testing,
|
|
323
327
|
enablePublish: true,
|
|
324
328
|
withBabel,
|
|
@@ -330,7 +334,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
330
334
|
updateOnly: this.options.updateOnly,
|
|
331
335
|
});
|
|
332
336
|
|
|
333
|
-
|
|
337
|
+
this.composeWith('pob:core:vscode', {
|
|
334
338
|
root: !inMonorepo,
|
|
335
339
|
monorepo: false,
|
|
336
340
|
packageManager: this.options.packageManager,
|
|
@@ -340,7 +344,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
340
344
|
});
|
|
341
345
|
|
|
342
346
|
// must be after doc, testing
|
|
343
|
-
|
|
347
|
+
this.composeWith('pob:core:gitignore', {
|
|
344
348
|
root: !inMonorepo,
|
|
345
349
|
withBabel: babelEnvs.length > 0,
|
|
346
350
|
typescript: withTypescript,
|
|
@@ -348,14 +352,14 @@ export default class PobLibGenerator extends Generator {
|
|
|
348
352
|
testing: !!this.pobjson.testing,
|
|
349
353
|
});
|
|
350
354
|
|
|
351
|
-
|
|
355
|
+
this.composeWith('pob:core:npm', {
|
|
352
356
|
enable: !pkg.private,
|
|
353
357
|
srcDirectory: withBabel || withTypescript ? 'src' : 'lib',
|
|
354
358
|
distDirectory: withBabel || withTypescript ? 'dist' : '',
|
|
355
359
|
});
|
|
356
360
|
}
|
|
357
361
|
|
|
358
|
-
|
|
362
|
+
writing() {
|
|
359
363
|
// Re-read the content at this point because a composed generator might modify it.
|
|
360
364
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'));
|
|
361
365
|
|
|
@@ -420,6 +424,6 @@ export default class PobLibGenerator extends Generator {
|
|
|
420
424
|
this.config.set('lib', pobjson);
|
|
421
425
|
this.config.save();
|
|
422
426
|
|
|
423
|
-
|
|
427
|
+
this.composeWith('pob:core:sort-package');
|
|
424
428
|
}
|
|
425
429
|
}
|
|
@@ -201,7 +201,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
201
201
|
this.config.delete('pob-config');
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
|
|
204
|
+
default() {
|
|
205
205
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
|
|
206
206
|
|
|
207
207
|
const packageNames = this.packageNames;
|
|
@@ -216,15 +216,16 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
216
216
|
throw new Error('packages should not be empty');
|
|
217
217
|
}
|
|
218
218
|
|
|
219
|
-
|
|
219
|
+
this.composeWith('pob:common:husky', {});
|
|
220
220
|
|
|
221
221
|
const isYarnVersionEnabled = this.pobLernaConfig.ci;
|
|
222
222
|
|
|
223
223
|
const splitCIJobs = this.packageNames.length > 8;
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
this.composeWith('pob:common:testing', {
|
|
226
226
|
monorepo: true,
|
|
227
227
|
enable: this.pobLernaConfig.testing,
|
|
228
|
+
runner: this.pobLernaConfig.testRunner || 'jest',
|
|
228
229
|
disableYarnGitCache: this.options.disableYarnGitCache,
|
|
229
230
|
enableReleasePlease: false,
|
|
230
231
|
enableYarnVersion: isYarnVersionEnabled,
|
|
@@ -241,7 +242,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
241
242
|
splitCIJobs,
|
|
242
243
|
});
|
|
243
244
|
|
|
244
|
-
|
|
245
|
+
this.composeWith('pob:common:format-lint', {
|
|
245
246
|
monorepo: true,
|
|
246
247
|
documentation: this.pobLernaConfig.documentation,
|
|
247
248
|
typescript: this.pobLernaConfig.typescript,
|
|
@@ -259,7 +260,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
259
260
|
rootIgnorePaths: [],
|
|
260
261
|
});
|
|
261
262
|
|
|
262
|
-
|
|
263
|
+
this.composeWith('pob:lib:doc', {
|
|
263
264
|
enabled: this.pobLernaConfig.documentation,
|
|
264
265
|
testing: this.pobLernaConfig.testing,
|
|
265
266
|
packageNames: JSON.stringify(packageNames),
|
|
@@ -267,7 +268,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
267
268
|
packageManager: this.options.packageManager,
|
|
268
269
|
});
|
|
269
270
|
|
|
270
|
-
|
|
271
|
+
this.composeWith('pob:core:vscode', {
|
|
271
272
|
root: true,
|
|
272
273
|
monorepo: true,
|
|
273
274
|
packageManager: this.options.packageManager,
|
|
@@ -279,16 +280,16 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
279
280
|
});
|
|
280
281
|
|
|
281
282
|
// Always add a gitignore, because npm publish uses it.
|
|
282
|
-
|
|
283
|
+
this.composeWith('pob:core:gitignore', {
|
|
283
284
|
root: true,
|
|
284
285
|
typescript: this.pobLernaConfig.typescript,
|
|
285
286
|
documentation: this.pobLernaConfig.documentation,
|
|
286
287
|
testing: this.pobLernaConfig.testing,
|
|
287
288
|
});
|
|
288
289
|
|
|
289
|
-
|
|
290
|
+
this.composeWith('pob:common:remove-old-dependencies');
|
|
290
291
|
|
|
291
|
-
|
|
292
|
+
this.composeWith('pob:common:release', {
|
|
292
293
|
enable: true,
|
|
293
294
|
enablePublish: !this.options.isAppProject,
|
|
294
295
|
withBabel: this.pobLernaConfig.typescript,
|
|
@@ -299,11 +300,12 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
299
300
|
updateOnly: this.options.updateOnly,
|
|
300
301
|
});
|
|
301
302
|
|
|
302
|
-
|
|
303
|
+
this.composeWith('pob:monorepo:typescript', {
|
|
303
304
|
enable: this.pobLernaConfig.typescript,
|
|
304
305
|
isAppProject: this.options.isAppProject,
|
|
305
306
|
packageNames: JSON.stringify(packageNames),
|
|
306
307
|
packagePaths: JSON.stringify(packagePaths),
|
|
308
|
+
testRunner: this.pobLernaConfig.testRunner,
|
|
307
309
|
});
|
|
308
310
|
|
|
309
311
|
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
|
|
@@ -315,7 +317,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
315
317
|
}
|
|
316
318
|
}
|
|
317
319
|
|
|
318
|
-
|
|
320
|
+
writing() {
|
|
319
321
|
if (!this.options.isAppProject) {
|
|
320
322
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
|
|
321
323
|
|
|
@@ -354,7 +356,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
354
356
|
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
|
|
355
357
|
}
|
|
356
358
|
|
|
357
|
-
|
|
359
|
+
this.composeWith('pob:core:sort-package');
|
|
358
360
|
}
|
|
359
361
|
|
|
360
362
|
end() {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
1
2
|
import Generator from 'yeoman-generator';
|
|
2
3
|
import * as packageUtils from '../../../utils/package.js';
|
|
3
4
|
import { copyAndFormatTpl } from '../../../utils/writeAndFormat.js';
|
|
@@ -27,6 +28,12 @@ export default class MonorepoTypescriptGenerator extends Generator {
|
|
|
27
28
|
type: String,
|
|
28
29
|
required: true,
|
|
29
30
|
});
|
|
31
|
+
|
|
32
|
+
this.option('testRunner', {
|
|
33
|
+
type: String,
|
|
34
|
+
required: false,
|
|
35
|
+
default: 'jest',
|
|
36
|
+
});
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
writing() {
|
|
@@ -85,11 +92,13 @@ export default class MonorepoTypescriptGenerator extends Generator {
|
|
|
85
92
|
const tsconfigPath = this.destinationPath('tsconfig.json');
|
|
86
93
|
const tsconfigCheckPath = this.destinationPath('tsconfig.check.json');
|
|
87
94
|
const tsconfigBuildPath = this.destinationPath('tsconfig.build.json');
|
|
95
|
+
const tsconfigTestPath = this.destinationPath('tsconfig.test.json');
|
|
88
96
|
|
|
89
97
|
if (!this.options.enable) {
|
|
90
98
|
this.fs.delete(tsconfigPath);
|
|
91
99
|
this.fs.delete(tsconfigCheckPath);
|
|
92
100
|
this.fs.delete(tsconfigBuildPath);
|
|
101
|
+
this.fs.delete(tsconfigTestPath);
|
|
93
102
|
} else {
|
|
94
103
|
const packagePaths = JSON.parse(this.options.packagePaths);
|
|
95
104
|
|
|
@@ -99,9 +108,24 @@ export default class MonorepoTypescriptGenerator extends Generator {
|
|
|
99
108
|
tsconfigPath,
|
|
100
109
|
{
|
|
101
110
|
packagePaths,
|
|
111
|
+
tsConfigSuffix: false,
|
|
102
112
|
},
|
|
103
113
|
);
|
|
104
114
|
|
|
115
|
+
if (this.options.testRunner === 'node') {
|
|
116
|
+
copyAndFormatTpl(
|
|
117
|
+
this.fs,
|
|
118
|
+
this.templatePath('tsconfig.json.ejs'),
|
|
119
|
+
tsconfigTestPath,
|
|
120
|
+
{
|
|
121
|
+
packagePaths: packagePaths.filter((packagePath) =>
|
|
122
|
+
existsSync(`${packagePath}/tsconfig.test.json`),
|
|
123
|
+
),
|
|
124
|
+
tsConfigSuffix: 'test',
|
|
125
|
+
},
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
105
129
|
this.fs.delete(tsconfigCheckPath);
|
|
106
130
|
this.fs.delete(tsconfigBuildPath);
|
|
107
131
|
// if (this.options.isAppProject) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"files": [],
|
|
3
3
|
"references": [
|
|
4
4
|
<% packagePaths.forEach((packagePath, index) => { -%>
|
|
5
|
-
{ "path": "<%= packagePath %>/tsconfig
|
|
5
|
+
{ "path": "<%= packagePath %>/tsconfig<%= tsConfigSuffix ? `.${tsConfigSuffix}` : '' %>.json" }<%= index === packagePaths.length -1 ? '' : ',' %>
|
|
6
6
|
<% }) -%>
|
|
7
7
|
]
|
|
8
8
|
}
|
|
@@ -113,15 +113,15 @@ export default class PobBaseGenerator extends Generator {
|
|
|
113
113
|
this.config.set('project', this.projectConfig);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
default() {
|
|
117
|
+
this.composeWith('pob:core:yarn', {
|
|
118
118
|
type: this.projectConfig.type,
|
|
119
119
|
enable: this.isRoot && this.projectConfig.packageManager === 'yarn',
|
|
120
120
|
yarnNodeLinker: this.projectConfig.yarnNodeLinker,
|
|
121
121
|
disableYarnGitCache: this.projectConfig.disableYarnGitCache,
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
this.composeWith('pob:core:package', {
|
|
125
125
|
updateOnly: this.options.updateOnly,
|
|
126
126
|
private: this.isMonorepo,
|
|
127
127
|
isMonorepo: this.isMonorepo,
|
|
@@ -130,13 +130,13 @@ export default class PobBaseGenerator extends Generator {
|
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
if (this.isMonorepo) {
|
|
133
|
-
|
|
133
|
+
this.composeWith('pob:monorepo:workspaces', {
|
|
134
134
|
force: this.options.force,
|
|
135
135
|
isAppProject: this.projectConfig.type === 'app',
|
|
136
136
|
packageManager: this.projectConfig.packageManager,
|
|
137
137
|
disableYarnGitCache: this.projectConfig.disableYarnGitCache,
|
|
138
138
|
});
|
|
139
|
-
|
|
139
|
+
this.composeWith('pob:monorepo:lerna', {
|
|
140
140
|
force: this.options.force,
|
|
141
141
|
isAppProject: this.projectConfig.type === 'app',
|
|
142
142
|
packageManager: this.projectConfig.packageManager,
|
|
@@ -147,13 +147,13 @@ export default class PobBaseGenerator extends Generator {
|
|
|
147
147
|
this.fs.delete('Makefile');
|
|
148
148
|
this.fs.delete(this.destinationPath('.commitrc.js'));
|
|
149
149
|
|
|
150
|
-
|
|
150
|
+
this.composeWith('pob:core:editorconfig');
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
this.composeWith('pob:core:clean', {
|
|
153
153
|
root: this.isRoot,
|
|
154
154
|
});
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
this.composeWith('pob:core:renovate', {
|
|
157
157
|
updateOnly: this.options.updateOnly,
|
|
158
158
|
app: this.projectConfig.type === 'app',
|
|
159
159
|
});
|
|
@@ -167,7 +167,7 @@ export default class PobBaseGenerator extends Generator {
|
|
|
167
167
|
if (!this.hasAncestor) {
|
|
168
168
|
const splitCIJobs =
|
|
169
169
|
inMonorepo && inMonorepo.pobMonorepoConfig?.packageNames.length > 8;
|
|
170
|
-
|
|
170
|
+
this.composeWith('pob:core:git', {
|
|
171
171
|
onlyLatestLTS,
|
|
172
172
|
splitCIJobs,
|
|
173
173
|
});
|
|
@@ -192,7 +192,7 @@ export default class PobBaseGenerator extends Generator {
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
if (this.isMonorepo) {
|
|
195
|
-
|
|
195
|
+
this.composeWith(
|
|
196
196
|
// pob:monorepo <= for searching PobMonorepoGenerator.js
|
|
197
197
|
fileURLToPath(
|
|
198
198
|
new URL('../monorepo/PobMonorepoGenerator.js', import.meta.url),
|
|
@@ -209,7 +209,7 @@ export default class PobBaseGenerator extends Generator {
|
|
|
209
209
|
} else {
|
|
210
210
|
switch (this.projectConfig.type) {
|
|
211
211
|
case 'lib':
|
|
212
|
-
|
|
212
|
+
this.composeWith('pob:lib', {
|
|
213
213
|
monorepo: this.isMonorepo,
|
|
214
214
|
isRoot: this.isRoot,
|
|
215
215
|
disableYarnGitCache: this.projectConfig.disableYarnGitCache,
|
|
@@ -220,7 +220,7 @@ export default class PobBaseGenerator extends Generator {
|
|
|
220
220
|
});
|
|
221
221
|
break;
|
|
222
222
|
case 'app':
|
|
223
|
-
|
|
223
|
+
this.composeWith('pob:app', {
|
|
224
224
|
monorepo: this.isMonorepo,
|
|
225
225
|
isRoot: this.isRoot,
|
|
226
226
|
disableYarnGitCache: this.projectConfig.disableYarnGitCache,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pob",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.2.0",
|
|
4
4
|
"description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"skeleton"
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
"mem-fs-editor": "11.0.0",
|
|
63
63
|
"minimist": "1.2.8",
|
|
64
64
|
"parse-author": "2.0.0",
|
|
65
|
-
"pob-dependencies": "11.0.
|
|
65
|
+
"pob-dependencies": "11.0.1",
|
|
66
66
|
"prettier": "2.8.8",
|
|
67
67
|
"semver": "7.5.4",
|
|
68
68
|
"validate-npm-package-name": "^5.0.0",
|
|
69
|
-
"yarn-workspace-utils": "3.1.
|
|
69
|
+
"yarn-workspace-utils": "3.1.2",
|
|
70
70
|
"yeoman-environment": "4.1.3",
|
|
71
71
|
"yeoman-generator": "7.1.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@pob/root": "9.
|
|
74
|
+
"@pob/root": "9.1.0"
|
|
75
75
|
}
|
|
76
76
|
}
|