pob 8.10.0 → 9.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 +70 -0
- package/lib/generators/app/PobAppGenerator.js +1 -0
- package/lib/generators/common/babel/CommonBabelGenerator.js +48 -54
- package/lib/generators/common/babel/templates/app.rollup.config.mjs.ejs +1 -1
- package/lib/generators/common/format-lint/CommonLintGenerator.js +22 -16
- package/lib/generators/common/husky/CommonHuskyGenerator.js +6 -2
- package/lib/generators/common/old-dependencies/CommonRemoveOldDependenciesGenerator.js +1 -0
- package/lib/generators/common/testing/CommonTestingGenerator.js +15 -14
- package/lib/generators/core/ci/templates/github-action-node-workflow.yml.ejs +8 -8
- package/lib/generators/core/git/generators/github/CoreGitGithubGenerator.js +35 -12
- package/lib/generators/core/package/CorePackageGenerator.js +34 -11
- package/lib/generators/core/yarn/CoreYarnGenerator.js +6 -2
- package/lib/generators/lib/PobLibGenerator.js +5 -4
- package/lib/generators/lib/release/LibReleaseGenerator.js +9 -3
- package/lib/generators/monorepo/PobMonorepoGenerator.js +1 -0
- package/lib/generators/pob/PobBaseGenerator.js +14 -1
- package/lib/pob.js +26 -23
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,76 @@
|
|
|
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
|
+
# [9.2.0](https://github.com/christophehurpeau/pob/compare/pob@9.1.0...pob@9.2.0) (2021-12-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **pob:** force global eslint and fix remove plugins on non monorepo ([9c04867](https://github.com/christophehurpeau/pob/commit/9c0486700355e27981f0e1a73d05663a6c1bb16b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [9.1.0](https://github.com/christophehurpeau/pob/compare/pob@9.0.0...pob@9.1.0) (2021-12-11)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* **pob:** replace devPlugins by plugins ([ddd0681](https://github.com/christophehurpeau/pob/commit/ddd0681284b5f5e9f851737beb2ec76bd69f01be))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* move @babel/core to pob-babel dependencies ([3d42287](https://github.com/christophehurpeau/pob/commit/3d422877476b443a2ea6789e0656ce676963451d))
|
|
28
|
+
* set rollup as dependencies ([8a3a87b](https://github.com/christophehurpeau/pob/commit/8a3a87bd7c541d92ce63bcf33043fedb2df98d01))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# [9.0.0](https://github.com/christophehurpeau/pob/compare/pob@8.10.1...pob@9.0.0) (2021-12-11)
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### Bug Fixes
|
|
38
|
+
|
|
39
|
+
* **pob:** add try/catch arround build and generate:docs commands ([561f87f](https://github.com/christophehurpeau/pob/commit/561f87f75f2ec90480403432ea4a70090d9962ce))
|
|
40
|
+
* **pob:** dont add postinstallDev scripts in monorepo packages ([f993c13](https://github.com/christophehurpeau/pob/commit/f993c13670b6c1a537b2e5731987b407a25c4eb6))
|
|
41
|
+
* **pob:** missing clean script when using monorepo ([4a4ac95](https://github.com/christophehurpeau/pob/commit/4a4ac9527af1681606d80e2bf963364ecccb4e81))
|
|
42
|
+
* **pob:** use fs.exists before fs.delete ([b2640d1](https://github.com/christophehurpeau/pob/commit/b2640d1545411ffecb90bacd2ad400e19ea815f0))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
### Features
|
|
46
|
+
|
|
47
|
+
* drop node 12 ([2f32308](https://github.com/christophehurpeau/pob/commit/2f32308b06ca74d0deb3355707e3082fa73e25dc))
|
|
48
|
+
* **pob:** configure jest to enable esm by default and remove direct dependency to babel-jest ([a789916](https://github.com/christophehurpeau/pob/commit/a78991696c6f7716cb1198ff8a6c36cc1acfa1a9))
|
|
49
|
+
* **pob-babel:** stop build dev specific and drop node 12 ([9cb8975](https://github.com/christophehurpeau/pob/commit/9cb897538df6b9c0e3ad3750abacb6ab96113862))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### BREAKING CHANGES
|
|
53
|
+
|
|
54
|
+
* requires node 14
|
|
55
|
+
* **pob-babel:** requires to delete dev exports and requires node 14
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
## [8.10.1](https://github.com/christophehurpeau/pob/compare/pob@8.10.0...pob@8.10.1) (2021-12-05)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### Bug Fixes
|
|
65
|
+
|
|
66
|
+
* **pob:** only install release workflow if ci is enabled ([8e2fc45](https://github.com/christophehurpeau/pob/commit/8e2fc45ec5435a149b4580b09ae4636e3dbc0fdf))
|
|
67
|
+
* **pob:** start script for apps ([623cfb5](https://github.com/christophehurpeau/pob/commit/623cfb5e5a9af9978b5533962ec7fb3b85035a3b))
|
|
68
|
+
* init new monorepo ([7a212de](https://github.com/christophehurpeau/pob/commit/7a212deb2feb480c19b5243a201f31a7b2ce45c3))
|
|
69
|
+
* monorepo add ([3ae8bfb](https://github.com/christophehurpeau/pob/commit/3ae8bfb487b8a88b62ad8692789ecdddf01ec376))
|
|
70
|
+
* **deps:** update dependency prettier to v2.5.1 ([#1122](https://github.com/christophehurpeau/pob/issues/1122)) ([ba903e3](https://github.com/christophehurpeau/pob/commit/ba903e3c63ff90eab7938d5aecbd9d37fac68293))
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
6
76
|
# [8.10.0](https://github.com/christophehurpeau/pob/compare/pob@8.9.0...pob@8.10.0) (2021-11-28)
|
|
7
77
|
|
|
8
78
|
|
|
@@ -41,24 +41,25 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
41
41
|
let babelEnvs = pkg.pob.babelEnvs;
|
|
42
42
|
if (
|
|
43
43
|
!babelEnvs.some(
|
|
44
|
-
(env) => env.target === 'node' && String(env.version) === '
|
|
44
|
+
(env) => env.target === 'node' && String(env.version) === '14',
|
|
45
45
|
) &&
|
|
46
46
|
babelEnvs.some(
|
|
47
47
|
(env) =>
|
|
48
48
|
env.target === 'node' &&
|
|
49
49
|
(String(env.version) === '8' ||
|
|
50
50
|
String(env.version) === '6' ||
|
|
51
|
-
String(env.version) === '10'
|
|
51
|
+
String(env.version) === '10' ||
|
|
52
|
+
String(env.version) === '12'),
|
|
52
53
|
)
|
|
53
54
|
) {
|
|
54
55
|
babelEnvs.unshift({
|
|
55
56
|
target: 'node',
|
|
56
|
-
version: '
|
|
57
|
+
version: '14',
|
|
57
58
|
formats: ['cjs', 'es'],
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
babelEnvs = babelEnvs.filter(
|
|
61
|
-
(env) => env.target !== 'node' || env.version >=
|
|
62
|
+
(env) => env.target !== 'node' || env.version >= 14,
|
|
62
63
|
);
|
|
63
64
|
|
|
64
65
|
pkg.pob.babelEnvs = babelEnvs;
|
|
@@ -125,9 +126,13 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
125
126
|
default: nodeVersions,
|
|
126
127
|
choices: [
|
|
127
128
|
{
|
|
128
|
-
name: '12 (
|
|
129
|
+
name: '12 (Maintenance LTS)',
|
|
129
130
|
value: '12',
|
|
130
131
|
},
|
|
132
|
+
{
|
|
133
|
+
name: '14 (Maintenance LTS)',
|
|
134
|
+
value: '14',
|
|
135
|
+
},
|
|
131
136
|
],
|
|
132
137
|
},
|
|
133
138
|
|
|
@@ -195,11 +200,11 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
195
200
|
...(babelConfig.nodeVersions || []).map((version) => ({
|
|
196
201
|
target: 'node',
|
|
197
202
|
version,
|
|
198
|
-
formats: babelConfig.formats.includes('
|
|
203
|
+
formats: babelConfig.formats.includes('cjs')
|
|
199
204
|
? // eslint-disable-next-line unicorn/no-nested-ternary
|
|
200
|
-
version === '
|
|
205
|
+
version === '14'
|
|
201
206
|
? babelConfig.formats
|
|
202
|
-
: ['
|
|
207
|
+
: ['es']
|
|
203
208
|
: babelConfig.formats,
|
|
204
209
|
})),
|
|
205
210
|
...(babelConfig.browserVersions || []).map((version) => ({
|
|
@@ -267,10 +272,19 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
267
272
|
|
|
268
273
|
/* scripts */
|
|
269
274
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
275
|
+
if (this.options.isApp) {
|
|
276
|
+
packageUtils.removeScripts(['watch']);
|
|
277
|
+
packageUtils.addOrRemoveScripts(pkg, useBabel, {
|
|
278
|
+
build: 'pob-build',
|
|
279
|
+
start: 'pob-watch',
|
|
280
|
+
});
|
|
281
|
+
} else {
|
|
282
|
+
packageUtils.removeScripts(['start']);
|
|
283
|
+
packageUtils.addOrRemoveScripts(pkg, useBabel, {
|
|
284
|
+
build: 'pob-build',
|
|
285
|
+
watch: 'pob-watch',
|
|
286
|
+
});
|
|
287
|
+
}
|
|
274
288
|
|
|
275
289
|
const shouldBuildDefinitions = !this.options.isApp && useBabel;
|
|
276
290
|
packageUtils.addOrRemoveScripts(pkg, shouldBuildDefinitions, {
|
|
@@ -307,11 +321,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
307
321
|
|
|
308
322
|
/* dependencies */
|
|
309
323
|
|
|
310
|
-
packageUtils.addOrRemoveDevDependencies(pkg, useBabel, [
|
|
311
|
-
'@babel/core',
|
|
312
|
-
'pob-babel',
|
|
313
|
-
'rollup',
|
|
314
|
-
]);
|
|
324
|
+
packageUtils.addOrRemoveDevDependencies(pkg, useBabel, ['pob-babel']);
|
|
315
325
|
|
|
316
326
|
if (pkg.dependencies && pkg.dependencies['pob-babel']) {
|
|
317
327
|
// update pob-babel in alp-dev
|
|
@@ -327,6 +337,8 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
327
337
|
]);
|
|
328
338
|
|
|
329
339
|
packageUtils.removeDevDependencies(pkg, [
|
|
340
|
+
'@babel/core',
|
|
341
|
+
'rollup',
|
|
330
342
|
'babel-preset-env', // now @babel/preset-env
|
|
331
343
|
'babel-preset-jsdoc',
|
|
332
344
|
'babel-plugin-add-jsdoc-annotations',
|
|
@@ -340,12 +352,6 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
340
352
|
['@babel/preset-env'],
|
|
341
353
|
);
|
|
342
354
|
|
|
343
|
-
packageUtils.addOrRemoveDevDependencies(
|
|
344
|
-
pkg,
|
|
345
|
-
this.babelEnvs.find((env) => env.target === 'node'),
|
|
346
|
-
['babel-preset-latest-node'],
|
|
347
|
-
);
|
|
348
|
-
|
|
349
355
|
packageUtils.addOrRemoveDevDependencies(
|
|
350
356
|
pkg,
|
|
351
357
|
this.babelEnvs.find(
|
|
@@ -366,8 +372,6 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
366
372
|
switch (String(minNodeVersion)) {
|
|
367
373
|
case '10':
|
|
368
374
|
case '12':
|
|
369
|
-
pkg.engines.node = '^12.20.0 || ^14.13.1 || >=16.0.0';
|
|
370
|
-
break;
|
|
371
375
|
case '14':
|
|
372
376
|
pkg.engines.node = '^14.13.1 || >=16.0.0';
|
|
373
377
|
break;
|
|
@@ -399,7 +403,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
399
403
|
if (Object.keys(pkg.engines).length === 0) delete pkg.engines;
|
|
400
404
|
} else {
|
|
401
405
|
// Supported LTS versions of node, that supports ESM modules.
|
|
402
|
-
pkg.engines.node = '^
|
|
406
|
+
pkg.engines.node = '^14.13.1 || >=16.0.0';
|
|
403
407
|
}
|
|
404
408
|
}
|
|
405
409
|
|
|
@@ -462,10 +466,11 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
462
466
|
!pkg.engines.node ||
|
|
463
467
|
semver.lt(
|
|
464
468
|
semver.minVersion(pkg.engines.node),
|
|
465
|
-
pkg.type === 'commonjs' ? '12.10.0' : '12.20.0',
|
|
469
|
+
// pkg.type === 'commonjs' ? '12.10.0' : '12.20.0',
|
|
470
|
+
'14.13.1',
|
|
466
471
|
)
|
|
467
472
|
) {
|
|
468
|
-
pkg.engines.node = '^
|
|
473
|
+
pkg.engines.node = '^14.13.1 || >=16.0.0';
|
|
469
474
|
}
|
|
470
475
|
}
|
|
471
476
|
|
|
@@ -490,35 +495,32 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
490
495
|
(env) => env.target === 'node' && env.formats.includes('es'),
|
|
491
496
|
);
|
|
492
497
|
|
|
498
|
+
// Legacy "dev" builds
|
|
499
|
+
delete pkg['module:browser'];
|
|
500
|
+
delete pkg['module:browser-dev'];
|
|
501
|
+
delete pkg['module:modern-browsers-dev'];
|
|
502
|
+
delete pkg['module:node-dev'];
|
|
503
|
+
|
|
493
504
|
/* webpack 4 */
|
|
494
505
|
if (esAllBrowserEnv) {
|
|
495
506
|
pkg.module = './dist/index-browser.es.js';
|
|
496
507
|
pkg.browser = './dist/index-browser.es.js';
|
|
497
|
-
pkg['module:browser'] = './dist/index-browser.es.js';
|
|
498
|
-
pkg['module:browser-dev'] = './dist/index-browser-dev.es.js';
|
|
499
508
|
} else {
|
|
500
509
|
delete pkg.module;
|
|
501
510
|
delete pkg.browser;
|
|
502
|
-
delete pkg['module:browser'];
|
|
503
|
-
delete pkg['module:browser-dev'];
|
|
504
511
|
}
|
|
505
512
|
|
|
506
513
|
if (esModernBrowserEnv) {
|
|
507
514
|
pkg['module:modern-browsers'] = './dist/index-browsermodern.es.js';
|
|
508
|
-
pkg['module:modern-browsers-dev'] =
|
|
509
|
-
'./dist/index-browsermodern-dev.es.js';
|
|
510
515
|
} else {
|
|
511
516
|
delete pkg['module:modern-browsers'];
|
|
512
|
-
delete pkg['module:modern-browsers-dev'];
|
|
513
517
|
}
|
|
514
518
|
|
|
515
519
|
if (esNodeEnv) {
|
|
520
|
+
// webpack 4 node
|
|
516
521
|
pkg[
|
|
517
522
|
'module:node'
|
|
518
523
|
] = `./dist/index-${esNodeEnv.target}${esNodeEnv.version}.mjs`;
|
|
519
|
-
pkg[
|
|
520
|
-
'module:node-dev'
|
|
521
|
-
] = `./dist/index-${esNodeEnv.target}${esNodeEnv.version}-dev.mjs`;
|
|
522
524
|
}
|
|
523
525
|
|
|
524
526
|
const aliases = (this.entries || []).filter((entry) => entry !== 'index');
|
|
@@ -539,7 +541,6 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
539
541
|
: aliases;
|
|
540
542
|
if (envAliases.length === 0) return;
|
|
541
543
|
pkg[`module:aliases-${key}`] = {};
|
|
542
|
-
pkg[`module:aliases-${key}-dev`] = {};
|
|
543
544
|
|
|
544
545
|
envAliases.forEach((aliasName) => {
|
|
545
546
|
const isBrowserOnly =
|
|
@@ -550,11 +551,6 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
550
551
|
] = `./dist/${aliasDistName}-${env.target}${
|
|
551
552
|
env.version || ''
|
|
552
553
|
}.es.js`;
|
|
553
|
-
pkg[`module:aliases-${key}-dev`][
|
|
554
|
-
`./${aliasName}.js`
|
|
555
|
-
] = `./dist/${aliasDistName}-${env.target}${
|
|
556
|
-
env.version || ''
|
|
557
|
-
}-dev.es.js`;
|
|
558
554
|
});
|
|
559
555
|
});
|
|
560
556
|
}
|
|
@@ -582,19 +578,16 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
582
578
|
this.babelEnvs.forEach(({ target, version, formats }) => {
|
|
583
579
|
if (target === 'node' && entry === 'browser') return;
|
|
584
580
|
|
|
585
|
-
const exportTarget = {
|
|
581
|
+
const exportTarget = {};
|
|
586
582
|
|
|
587
583
|
if (target === 'node') {
|
|
588
584
|
if (formats.includes('es')) {
|
|
589
|
-
exportTarget.development.import = `./dist/${entryDistName}-${target}${version}-dev.mjs`;
|
|
590
585
|
exportTarget.import = `./dist/${entryDistName}-${target}${version}.mjs`;
|
|
591
586
|
|
|
592
587
|
if (formats.includes('cjs')) {
|
|
593
|
-
exportTarget.development.require = `./dist/${entryDistName}-${target}${version}-dev.cjs.js`;
|
|
594
588
|
exportTarget.require = `./dist/${entryDistName}-${target}${version}.cjs.js`;
|
|
595
589
|
}
|
|
596
590
|
} else if (formats.includes('cjs')) {
|
|
597
|
-
exportTarget.development = `./dist/${entryDistName}-${target}${version}-dev.cjs.js`;
|
|
598
591
|
exportTarget.default = `./dist/${entryDistName}-${target}${version}.cjs.js`;
|
|
599
592
|
}
|
|
600
593
|
// eslint: https://github.com/benmosher/eslint-plugin-import/issues/2132
|
|
@@ -604,18 +597,12 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
604
597
|
}
|
|
605
598
|
} else if (target === 'browser') {
|
|
606
599
|
if (formats.includes('es')) {
|
|
607
|
-
exportTarget.development.import = `./dist/${entryDistName}-${target}${
|
|
608
|
-
version || ''
|
|
609
|
-
}-dev.es.js`;
|
|
610
600
|
exportTarget.import = `./dist/${entryDistName}-${target}${
|
|
611
601
|
version || ''
|
|
612
602
|
}.es.js`;
|
|
613
603
|
}
|
|
614
604
|
|
|
615
605
|
if (formats.includes('cjs')) {
|
|
616
|
-
exportTarget.development.require = `./dist/index-${target}${
|
|
617
|
-
version || ''
|
|
618
|
-
}-dev.cjs.js`;
|
|
619
606
|
exportTarget.require = `./dist/index-${target}${
|
|
620
607
|
version || ''
|
|
621
608
|
}.cjs.js`;
|
|
@@ -664,6 +651,13 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
664
651
|
|
|
665
652
|
Object.keys(pkg).forEach((key) => {
|
|
666
653
|
if (!key.startsWith('module:') && !key.startsWith('webpack:')) return;
|
|
654
|
+
|
|
655
|
+
// legacy
|
|
656
|
+
if (key.endsWith('-dev')) {
|
|
657
|
+
delete pkg[key];
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
|
|
667
661
|
if (key.startsWith('module:node') && esNodeEnv) return;
|
|
668
662
|
if (key.startsWith('module:browser') && esAllBrowserEnv) return;
|
|
669
663
|
if (key.startsWith('module:modern-browsers') && esModernBrowserEnv) {
|
|
@@ -4,5 +4,5 @@ import createRollupConfig from 'pob-babel/createRollupConfig.js';
|
|
|
4
4
|
const watch = process.env.ROLLUP_WATCH === 'true';
|
|
5
5
|
|
|
6
6
|
export default createRollupConfig({
|
|
7
|
-
|
|
7
|
+
plugins: [watch && run({ execArgv: ['--enable-source-maps'] })],
|
|
8
8
|
});
|
|
@@ -12,6 +12,13 @@ export default class CommonLintGenerator extends Generator {
|
|
|
12
12
|
constructor(args, opts) {
|
|
13
13
|
super(args, opts);
|
|
14
14
|
|
|
15
|
+
this.option('monorepo', {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
required: false,
|
|
18
|
+
defaults: false,
|
|
19
|
+
description: 'Is root monorepo',
|
|
20
|
+
});
|
|
21
|
+
|
|
15
22
|
this.option('babel', {
|
|
16
23
|
type: String,
|
|
17
24
|
required: false,
|
|
@@ -104,7 +111,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
104
111
|
arrowParens: 'always',
|
|
105
112
|
};
|
|
106
113
|
|
|
107
|
-
if (!inLerna || inLerna.root) {
|
|
114
|
+
if (!inLerna || inLerna.root || this.options.monorepo) {
|
|
108
115
|
const ignorePatterns = new Set(
|
|
109
116
|
this.options.ignorePaths.split('\n').filter(Boolean),
|
|
110
117
|
);
|
|
@@ -125,7 +132,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
125
132
|
this.templatePath('prettierignore.ejs'),
|
|
126
133
|
this.destinationPath('.prettierignore'),
|
|
127
134
|
{
|
|
128
|
-
inRoot: !inLerna || inLerna.root,
|
|
135
|
+
inRoot: !inLerna || inLerna.root || this.options.monorepo,
|
|
129
136
|
documentation: this.options.documentation,
|
|
130
137
|
packageManager: this.options.packageManager,
|
|
131
138
|
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
@@ -179,11 +186,11 @@ export default class CommonLintGenerator extends Generator {
|
|
|
179
186
|
inLerna.pobConfig.project &&
|
|
180
187
|
inLerna.pobConfig.project.type;
|
|
181
188
|
|
|
182
|
-
if (
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
) {
|
|
189
|
+
if (this.options.monorepo && !globalEslint) {
|
|
190
|
+
throw new Error('Please enable global eslint');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (globalEslint && !((inLerna && inLerna.root) || this.options.monorepo)) {
|
|
187
194
|
packageUtils.removeDevDependencies(
|
|
188
195
|
pkg,
|
|
189
196
|
[
|
|
@@ -205,23 +212,22 @@ export default class CommonLintGenerator extends Generator {
|
|
|
205
212
|
} else {
|
|
206
213
|
packageUtils.addOrRemoveDevDependencies(
|
|
207
214
|
pkg,
|
|
208
|
-
(inLerna && inLerna.root) || !globalEslint,
|
|
215
|
+
(inLerna && inLerna.root) || this.options.monorepo || !globalEslint,
|
|
209
216
|
['prettier'],
|
|
210
217
|
);
|
|
211
218
|
packageUtils.addOrRemoveDevDependencies(
|
|
212
219
|
pkg,
|
|
213
220
|
!globalEslint ||
|
|
214
221
|
(inLerna && inLerna.root) ||
|
|
222
|
+
this.options.monorepo ||
|
|
215
223
|
lernaProjectType === 'app' ||
|
|
216
|
-
rootPackageManager === 'yarn'
|
|
224
|
+
(rootPackageManager === 'yarn' &&
|
|
225
|
+
rootYarnNodeLinker !== 'node-modules') ||
|
|
217
226
|
!!(pkg.peerDependencies && pkg.peerDependencies.eslint),
|
|
218
227
|
['eslint'],
|
|
219
228
|
);
|
|
220
229
|
const shouldHavePluginsDependencies =
|
|
221
|
-
|
|
222
|
-
!inLerna ||
|
|
223
|
-
(rootPackageManager === 'yarn' &&
|
|
224
|
-
rootYarnNodeLinker !== 'node-modules');
|
|
230
|
+
rootPackageManager === 'yarn' && rootYarnNodeLinker !== 'node-modules';
|
|
225
231
|
|
|
226
232
|
if (
|
|
227
233
|
!pkg.name.startsWith('eslint-config') &&
|
|
@@ -241,7 +247,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
241
247
|
['eslint-plugin-node', 'eslint-import-resolver-node'],
|
|
242
248
|
);
|
|
243
249
|
|
|
244
|
-
if (inLerna && inLerna.root) {
|
|
250
|
+
if ((inLerna && inLerna.root) || this.options.monorepo) {
|
|
245
251
|
if (this.options.typescript) {
|
|
246
252
|
packageUtils.updateDevDependenciesIfPresent(pkg, [
|
|
247
253
|
'@pob/eslint-config-typescript',
|
|
@@ -410,7 +416,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
410
416
|
console.warn(`Could not parse/edit ${rootEslintrcPath}: `, err);
|
|
411
417
|
}
|
|
412
418
|
|
|
413
|
-
if (inLerna && inLerna.root) {
|
|
419
|
+
if ((inLerna && inLerna.root) || this.options.monorepo) {
|
|
414
420
|
if (this.fs.exists(srcEslintrcPath)) {
|
|
415
421
|
this.fs.delete(srcEslintrcPath);
|
|
416
422
|
}
|
|
@@ -448,7 +454,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
448
454
|
}
|
|
449
455
|
|
|
450
456
|
// see monorepo/lerna/index.js
|
|
451
|
-
if (!(inLerna && inLerna.root)) {
|
|
457
|
+
if (!(inLerna && inLerna.root) && !this.options.monorepo) {
|
|
452
458
|
const srcDirectory = useBabel ? 'src' : 'lib';
|
|
453
459
|
const lintRootJsFiles = (useBabel && useNode) || !inLerna;
|
|
454
460
|
|
|
@@ -42,8 +42,12 @@ export default class CommonHuskyGenerator extends Generator {
|
|
|
42
42
|
this.fs.delete('.git-hooks/pre-commit');
|
|
43
43
|
if (this.fs.exists('.git-hooks')) this.fs.delete('.git-hooks');
|
|
44
44
|
|
|
45
|
-
this.fs.
|
|
46
|
-
|
|
45
|
+
if (this.fs.exists(this.destinationPath('.huskyrc.js'))) {
|
|
46
|
+
this.fs.delete(this.destinationPath('.huskyrc.js'));
|
|
47
|
+
}
|
|
48
|
+
if (this.fs.exists(this.destinationPath('husky.config.js'))) {
|
|
49
|
+
this.fs.delete(this.destinationPath('husky.config.js'));
|
|
50
|
+
}
|
|
47
51
|
|
|
48
52
|
if (this.fs.exists(this.destinationPath('lint-staged.config.js'))) {
|
|
49
53
|
this.fs.move(
|
|
@@ -19,6 +19,7 @@ export default class CommonRemoveOldDependenciesGenerator extends Generator {
|
|
|
19
19
|
'babel-preset-es2015-node6',
|
|
20
20
|
'babel-preset-pob',
|
|
21
21
|
'babel-preset-latest',
|
|
22
|
+
'babel-preset-latest-node',
|
|
22
23
|
'babel-preset-stage-0',
|
|
23
24
|
'babel-preset-stage-1',
|
|
24
25
|
'babel-preset-modern-browsers-stage-1',
|
|
@@ -69,14 +69,11 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
69
69
|
'istanbul',
|
|
70
70
|
'babel-core',
|
|
71
71
|
'ts-jest',
|
|
72
|
+
'babel-jest',
|
|
72
73
|
]);
|
|
73
74
|
|
|
74
75
|
if (!this.options.enable) {
|
|
75
|
-
packageUtils.removeDevDependencies(pkg, [
|
|
76
|
-
'jest',
|
|
77
|
-
'@types/jest',
|
|
78
|
-
'babel-jest',
|
|
79
|
-
]);
|
|
76
|
+
packageUtils.removeDevDependencies(pkg, ['jest', '@types/jest']);
|
|
80
77
|
|
|
81
78
|
delete pkg.jest;
|
|
82
79
|
// if (inLerna) {
|
|
@@ -97,7 +94,7 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
97
94
|
const transpileWithBabel = packageUtils.transpileWithBabel(pkg);
|
|
98
95
|
|
|
99
96
|
const shouldUseExperimentalVmModules =
|
|
100
|
-
pkg.type === 'module'
|
|
97
|
+
pkg.type === 'module' || transpileWithBabel;
|
|
101
98
|
|
|
102
99
|
const jestCommand = `${
|
|
103
100
|
shouldUseExperimentalVmModules
|
|
@@ -125,10 +122,6 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
125
122
|
const hasReact = transpileWithBabel && packageUtils.hasReact(pkg);
|
|
126
123
|
const srcDirectory = transpileWithBabel ? 'src' : 'lib';
|
|
127
124
|
|
|
128
|
-
packageUtils.addOrRemoveDevDependencies(pkg, transpileWithBabel, [
|
|
129
|
-
'babel-jest',
|
|
130
|
-
]);
|
|
131
|
-
|
|
132
125
|
if (!pkg.jest) pkg.jest = {};
|
|
133
126
|
Object.assign(pkg.jest, {
|
|
134
127
|
cacheDirectory: './node_modules/.cache/jest',
|
|
@@ -152,12 +145,20 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
152
145
|
// 'jsx',
|
|
153
146
|
'json',
|
|
154
147
|
].filter(Boolean),
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
extensionsToTreatAsEsm: [
|
|
149
|
+
transpileWithBabel && '.ts',
|
|
150
|
+
transpileWithBabel && hasReact && '.tsx',
|
|
151
|
+
].filter(Boolean),
|
|
152
|
+
// transform: {
|
|
153
|
+
// [`^.+\\.ts${hasReact ? 'x?' : ''}$`]: 'babel-jest',
|
|
154
|
+
// },
|
|
158
155
|
});
|
|
156
|
+
delete pkg.jest.transform;
|
|
159
157
|
|
|
160
|
-
if (
|
|
158
|
+
if (
|
|
159
|
+
babelEnvs.length === 0 ||
|
|
160
|
+
babelEnvs.some((env) => env.target === 'node')
|
|
161
|
+
) {
|
|
161
162
|
pkg.jest.testEnvironment = 'node';
|
|
162
163
|
} else {
|
|
163
164
|
delete pkg.jest.testEnvironment;
|
|
@@ -8,7 +8,7 @@ jobs:
|
|
|
8
8
|
|
|
9
9
|
strategy:
|
|
10
10
|
matrix:
|
|
11
|
-
node-version: [
|
|
11
|
+
node-version: [14.x, 16.x]
|
|
12
12
|
|
|
13
13
|
steps:
|
|
14
14
|
- uses: actions/checkout@v2
|
|
@@ -57,16 +57,16 @@ jobs:
|
|
|
57
57
|
<% } -%>
|
|
58
58
|
- name: Prettier
|
|
59
59
|
run: <%= packageManager %> run lint:prettier
|
|
60
|
-
if: startsWith(matrix.node-version, '
|
|
60
|
+
if: startsWith(matrix.node-version, '16.')
|
|
61
61
|
|
|
62
62
|
- name: Eslint
|
|
63
63
|
run: <%= packageManager %> run lint:eslint
|
|
64
|
-
if: startsWith(matrix.node-version, '
|
|
64
|
+
if: startsWith(matrix.node-version, '16.')
|
|
65
65
|
<% if (typescript) { -%>
|
|
66
66
|
|
|
67
67
|
- name: Typescript
|
|
68
68
|
run: yarn run tsc
|
|
69
|
-
if: startsWith(matrix.node-version, '
|
|
69
|
+
if: startsWith(matrix.node-version, '16.')
|
|
70
70
|
<% } -%>
|
|
71
71
|
<% if (testing) { -%>
|
|
72
72
|
|
|
@@ -79,14 +79,14 @@ jobs:
|
|
|
79
79
|
|
|
80
80
|
- name: Documentation
|
|
81
81
|
run: <%= packageManager %> run generate:docs
|
|
82
|
-
if: startsWith(matrix.node-version, '
|
|
82
|
+
if: startsWith(matrix.node-version, '16.')
|
|
83
83
|
env:
|
|
84
84
|
CI: true
|
|
85
85
|
<% } else if (codecov) { -%>
|
|
86
86
|
|
|
87
87
|
- name: Generate Coverage doc
|
|
88
88
|
run: <%= packageManager %> run generate:test-coverage
|
|
89
|
-
if: startsWith(matrix.node-version, '
|
|
89
|
+
if: startsWith(matrix.node-version, '16.')
|
|
90
90
|
env:
|
|
91
91
|
CI: true
|
|
92
92
|
<% } -%>
|
|
@@ -96,11 +96,11 @@ jobs:
|
|
|
96
96
|
uses: codecov/codecov-action@v2
|
|
97
97
|
with:
|
|
98
98
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
99
|
-
if: startsWith(matrix.node-version, '
|
|
99
|
+
if: startsWith(matrix.node-version, '16.')
|
|
100
100
|
<% } -%>
|
|
101
101
|
<% if (true) { -%>
|
|
102
102
|
|
|
103
103
|
- name: Check nothing was forgotten before commit
|
|
104
|
-
if: startsWith(matrix.node-version, '
|
|
104
|
+
if: startsWith(matrix.node-version, '16.')
|
|
105
105
|
run: <%= packageManager === 'npm' ? 'npx' : 'yarn run' %> repository-check-dirty
|
|
106
106
|
<% } -%>
|
|
@@ -22,12 +22,7 @@ const configureProtectionRule = async (owner, repo) => {
|
|
|
22
22
|
json: {
|
|
23
23
|
required_status_checks: {
|
|
24
24
|
strict: false,
|
|
25
|
-
contexts: [
|
|
26
|
-
'build (12.x)',
|
|
27
|
-
'build (14.x)',
|
|
28
|
-
'build (16.x)',
|
|
29
|
-
'reviewflow',
|
|
30
|
-
],
|
|
25
|
+
contexts: ['build (14.x)', 'build (16.x)', 'reviewflow'],
|
|
31
26
|
},
|
|
32
27
|
enforce_admins: false, // true,
|
|
33
28
|
required_pull_request_reviews: null,
|
|
@@ -37,9 +32,14 @@ const configureProtectionRule = async (owner, repo) => {
|
|
|
37
32
|
allow_deletions: false,
|
|
38
33
|
},
|
|
39
34
|
});
|
|
35
|
+
if (branch === 'master') {
|
|
36
|
+
console.warn('You should rename your "master" branch to "main"');
|
|
37
|
+
}
|
|
40
38
|
} catch (err) {
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
if (branch === 'main') {
|
|
40
|
+
console.error(`Failed to configure ${branch} branch protection`);
|
|
41
|
+
console.error(err.stack || err.message || err);
|
|
42
|
+
}
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
};
|
|
@@ -79,14 +79,17 @@ export default class CoreGitGithubGenerator extends Generator {
|
|
|
79
79
|
const repo = this.options.repoName;
|
|
80
80
|
|
|
81
81
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
|
|
82
|
+
const name = pkg.name.endsWith('-monorepo')
|
|
83
|
+
? pkg.name.slice(0, -'-monorepo'.length)
|
|
84
|
+
: pkg.name;
|
|
82
85
|
|
|
83
86
|
if (this.options.shouldCreate) {
|
|
84
87
|
try {
|
|
85
88
|
if (this.options.shouldCreate) {
|
|
86
89
|
try {
|
|
87
|
-
await gh('user/repos', {
|
|
90
|
+
await gh.post('user/repos', {
|
|
88
91
|
json: {
|
|
89
|
-
name
|
|
92
|
+
name,
|
|
90
93
|
description: pkg.description,
|
|
91
94
|
homepage: null,
|
|
92
95
|
private: false,
|
|
@@ -103,13 +106,33 @@ export default class CoreGitGithubGenerator extends Generator {
|
|
|
103
106
|
}
|
|
104
107
|
|
|
105
108
|
const cwd = this.destinationPath();
|
|
106
|
-
|
|
109
|
+
try {
|
|
110
|
+
this.spawnCommandSync('git', ['add', '--all', '.'], { cwd });
|
|
111
|
+
} catch (err) {
|
|
112
|
+
this.spawnCommandSync('git', ['init'], { cwd });
|
|
113
|
+
this.spawnCommandSync('git', ['add', '--all', '.'], { cwd });
|
|
114
|
+
this.spawnCommandSync(
|
|
115
|
+
'git',
|
|
116
|
+
[
|
|
117
|
+
'remote',
|
|
118
|
+
'add',
|
|
119
|
+
'origin',
|
|
120
|
+
`git@github.com:christophehurpeau/${name}.git`,
|
|
121
|
+
],
|
|
122
|
+
{ cwd },
|
|
123
|
+
);
|
|
124
|
+
console.error('Failed to create repository');
|
|
125
|
+
console.error(err.stack || err.message || err);
|
|
126
|
+
}
|
|
107
127
|
this.spawnCommandSync(
|
|
108
128
|
'git',
|
|
109
129
|
['commit', '-m', 'chore: initial commit [skip ci]'],
|
|
110
130
|
{ cwd },
|
|
111
131
|
);
|
|
112
|
-
this.spawnCommandSync('git', ['
|
|
132
|
+
this.spawnCommandSync('git', ['branch', '-M', 'main'], {
|
|
133
|
+
cwd,
|
|
134
|
+
});
|
|
135
|
+
this.spawnCommandSync('git', ['push', '-u', 'origin', 'main'], {
|
|
113
136
|
cwd,
|
|
114
137
|
});
|
|
115
138
|
|
|
@@ -9,6 +9,20 @@ export default class CorePackageGenerator extends Generator {
|
|
|
9
9
|
constructor(args, opts) {
|
|
10
10
|
super(args, opts);
|
|
11
11
|
|
|
12
|
+
this.option('monorepo', {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
required: true,
|
|
15
|
+
defaults: false,
|
|
16
|
+
desc: 'is monorepo',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
this.option('isRoot', {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
required: true,
|
|
22
|
+
defaults: false,
|
|
23
|
+
desc: 'is root',
|
|
24
|
+
});
|
|
25
|
+
|
|
12
26
|
this.option('private', {
|
|
13
27
|
type: Boolean,
|
|
14
28
|
required: false,
|
|
@@ -23,13 +37,21 @@ export default class CorePackageGenerator extends Generator {
|
|
|
23
37
|
if (!pkg.engines) pkg.engines = {};
|
|
24
38
|
|
|
25
39
|
// dont override engines if set to latest
|
|
26
|
-
if (
|
|
40
|
+
if (
|
|
41
|
+
!pkg.engines.node ||
|
|
42
|
+
!(
|
|
43
|
+
pkg.engines.node.startsWith('>=14.') ||
|
|
44
|
+
pkg.engines.node.startsWith('>=16.')
|
|
45
|
+
)
|
|
46
|
+
) {
|
|
27
47
|
// this might be overridden by babel generator
|
|
28
|
-
pkg.engines.node = '>=
|
|
48
|
+
pkg.engines.node = '>=14.13.1';
|
|
29
49
|
}
|
|
30
50
|
|
|
31
51
|
if (!this.options.updateOnly) {
|
|
32
|
-
if (this.options.
|
|
52
|
+
if (this.options.monorepo && this.options.isRoot) {
|
|
53
|
+
pkg.private = true;
|
|
54
|
+
} else if (this.options.private) {
|
|
33
55
|
pkg.private = true;
|
|
34
56
|
} else {
|
|
35
57
|
const { isPrivate } = await this.prompt({
|
|
@@ -46,7 +68,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
46
68
|
}
|
|
47
69
|
}
|
|
48
70
|
|
|
49
|
-
if (
|
|
71
|
+
if (this.options.monorepo && this.options.isRoot) {
|
|
50
72
|
if (!pkg.name) {
|
|
51
73
|
const { name } = await this.prompt({
|
|
52
74
|
name: 'name',
|
|
@@ -77,7 +99,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
77
99
|
const props = await this.prompt(
|
|
78
100
|
[
|
|
79
101
|
!this.options.updateOnly &&
|
|
80
|
-
!(
|
|
102
|
+
!(this.options.monorepo && this.options.isRoot) && {
|
|
81
103
|
name: 'description',
|
|
82
104
|
message: 'Description',
|
|
83
105
|
default: pkg.description,
|
|
@@ -115,7 +137,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
115
137
|
? pkg.description
|
|
116
138
|
: props.description || pkg.description;
|
|
117
139
|
|
|
118
|
-
if (
|
|
140
|
+
if (this.options.monorepo && !this.options.isRoot) {
|
|
119
141
|
const rootMonorepoPkg = inLerna.rootMonorepoPkg;
|
|
120
142
|
const rootRepositoryUrl =
|
|
121
143
|
typeof rootMonorepoPkg.repository === 'string'
|
|
@@ -136,9 +158,9 @@ export default class CorePackageGenerator extends Generator {
|
|
|
136
158
|
fs.unlinkSync(this.destinationPath('yarn-error.log'));
|
|
137
159
|
}
|
|
138
160
|
|
|
139
|
-
if (
|
|
161
|
+
if (this.options.monorepo && !this.options.isRoot) {
|
|
140
162
|
packageUtils.removeScripts(pkg, ['checks']);
|
|
141
|
-
} else if (
|
|
163
|
+
} else if (this.options.monorepo && this.options.isRoot) {
|
|
142
164
|
const doesMjsCheckPackagesExists = this.fs.exists(
|
|
143
165
|
this.destinationPath('scripts/check-packages.mjs'),
|
|
144
166
|
);
|
|
@@ -206,6 +228,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
206
228
|
|
|
207
229
|
writing() {
|
|
208
230
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
|
|
231
|
+
if (!pkg.scripts) pkg.scripts = {};
|
|
209
232
|
|
|
210
233
|
const installPostinstallScript = (scriptName) => {
|
|
211
234
|
if (
|
|
@@ -217,7 +240,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
217
240
|
};
|
|
218
241
|
|
|
219
242
|
const uninstallPostinstallScript = (scriptName) => {
|
|
220
|
-
if (pkg.scripts[scriptName]) {
|
|
243
|
+
if (pkg.scripts && pkg.scripts[scriptName]) {
|
|
221
244
|
if (pkg.scripts[scriptName] === 'pob-root-postinstall') {
|
|
222
245
|
delete pkg.scripts[scriptName];
|
|
223
246
|
} else if (
|
|
@@ -231,9 +254,9 @@ export default class CorePackageGenerator extends Generator {
|
|
|
231
254
|
}
|
|
232
255
|
}
|
|
233
256
|
};
|
|
234
|
-
if (inLerna || pkg.private) {
|
|
257
|
+
if (this.options.monorepo || inLerna || pkg.private) {
|
|
235
258
|
uninstallPostinstallScript('postinstallDev');
|
|
236
|
-
if (
|
|
259
|
+
if (this.options.isRoot) {
|
|
237
260
|
installPostinstallScript('postinstall');
|
|
238
261
|
} else {
|
|
239
262
|
uninstallPostinstallScript('postinstall');
|
|
@@ -119,10 +119,14 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
119
119
|
} catch {}
|
|
120
120
|
} else {
|
|
121
121
|
if (pkg.scripts.build) {
|
|
122
|
-
|
|
122
|
+
try {
|
|
123
|
+
this.spawnCommandSync('yarn', ['run', 'build']);
|
|
124
|
+
} catch {}
|
|
123
125
|
}
|
|
124
126
|
if (pkg.scripts['generate:docs']) {
|
|
125
|
-
|
|
127
|
+
try {
|
|
128
|
+
this.spawnCommandSync('yarn', ['run', 'generate:docs']);
|
|
129
|
+
} catch {}
|
|
126
130
|
}
|
|
127
131
|
}
|
|
128
132
|
}
|
|
@@ -80,7 +80,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
80
80
|
case 'node10':
|
|
81
81
|
return {
|
|
82
82
|
target: 'node',
|
|
83
|
-
version:
|
|
83
|
+
version: 14,
|
|
84
84
|
formats: ['cjs'],
|
|
85
85
|
};
|
|
86
86
|
|
|
@@ -89,7 +89,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
89
89
|
case 'module-node8':
|
|
90
90
|
return {
|
|
91
91
|
target: 'node',
|
|
92
|
-
version:
|
|
92
|
+
version: 14,
|
|
93
93
|
formats: ['es'],
|
|
94
94
|
};
|
|
95
95
|
|
|
@@ -273,7 +273,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
273
273
|
});
|
|
274
274
|
|
|
275
275
|
this.composeWith('pob:lib:release', {
|
|
276
|
-
enable: !inLerna,
|
|
276
|
+
enable: !inLerna && this.pobjson.testing && this.pobjson.testing.ci,
|
|
277
277
|
withBabel: babelEnvs.length > 0,
|
|
278
278
|
documentation: !!this.pobjson.documentation,
|
|
279
279
|
});
|
|
@@ -316,7 +316,8 @@ export default class PobLibGenerator extends Generator {
|
|
|
316
316
|
delete pkg.scripts.release;
|
|
317
317
|
delete pkg.scripts.version;
|
|
318
318
|
}
|
|
319
|
-
}
|
|
319
|
+
}
|
|
320
|
+
if (withBabel && (!inLerna || !inLerna.root)) {
|
|
320
321
|
packageUtils.addScripts(pkg, {
|
|
321
322
|
clean: 'rm -Rf dist',
|
|
322
323
|
});
|
|
@@ -61,9 +61,15 @@ export default class LibReleaseGenerator extends Generator {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
if (!isReleasePleaseEnabled) {
|
|
64
|
-
|
|
65
|
-
this.
|
|
66
|
-
|
|
64
|
+
if (
|
|
65
|
+
this.fs.exists(
|
|
66
|
+
this.destinationPath('.github/workflows/release-please.yml'),
|
|
67
|
+
)
|
|
68
|
+
) {
|
|
69
|
+
this.fs.delete(
|
|
70
|
+
this.destinationPath('.github/workflows/release-please.yml'),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
67
73
|
} else {
|
|
68
74
|
this.fs.copyTpl(
|
|
69
75
|
this.templatePath('release-please.yml.ejs'),
|
|
@@ -207,6 +207,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
207
207
|
this.composeWith('pob:common:husky', {});
|
|
208
208
|
|
|
209
209
|
this.composeWith('pob:common:format-lint', {
|
|
210
|
+
monorepo: true,
|
|
210
211
|
documentation: this.pobLernaConfig.documentation,
|
|
211
212
|
typescript: this.pobLernaConfig.typescript,
|
|
212
213
|
testing: this.pobLernaConfig.testing,
|
|
@@ -7,12 +7,19 @@ export default class PobBaseGenerator extends Generator {
|
|
|
7
7
|
constructor(args, opts) {
|
|
8
8
|
super(args, opts, { customInstallTask: true });
|
|
9
9
|
|
|
10
|
+
/** @deprecated use monorepo option instead */
|
|
10
11
|
this.option('lerna', {
|
|
11
12
|
type: Boolean,
|
|
12
13
|
required: false,
|
|
13
14
|
desc: 'Lerna monorepo',
|
|
14
15
|
});
|
|
15
16
|
|
|
17
|
+
this.option('monorepo', {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
required: false,
|
|
20
|
+
desc: 'monorepo',
|
|
21
|
+
});
|
|
22
|
+
|
|
16
23
|
this.option('type', {
|
|
17
24
|
type: String,
|
|
18
25
|
required: true,
|
|
@@ -53,7 +60,7 @@ export default class PobBaseGenerator extends Generator {
|
|
|
53
60
|
// prettier package.json to ensure diff is correct
|
|
54
61
|
ensureJsonFileFormatted(this.destinationPath('package.json'));
|
|
55
62
|
|
|
56
|
-
if (this.options.lerna) {
|
|
63
|
+
if (this.options.monorepo || this.options.lerna) {
|
|
57
64
|
this.useLerna = true;
|
|
58
65
|
this.inLerna = false;
|
|
59
66
|
this.isRoot = true;
|
|
@@ -123,6 +130,8 @@ export default class PobBaseGenerator extends Generator {
|
|
|
123
130
|
this.composeWith('pob:core:package', {
|
|
124
131
|
updateOnly: this.options.updateOnly,
|
|
125
132
|
private: this.useLerna,
|
|
133
|
+
monorepo: this.useLerna,
|
|
134
|
+
isRoot: this.isRoot,
|
|
126
135
|
});
|
|
127
136
|
|
|
128
137
|
if (this.useLerna) {
|
|
@@ -207,6 +216,8 @@ export default class PobBaseGenerator extends Generator {
|
|
|
207
216
|
switch (this.projectConfig.type) {
|
|
208
217
|
case 'lib':
|
|
209
218
|
this.composeWith('pob:lib', {
|
|
219
|
+
monorepo: this.useLerna,
|
|
220
|
+
isRoot: this.isRoot,
|
|
210
221
|
updateOnly: this.options.updateOnly,
|
|
211
222
|
fromPob: this.options.fromPob,
|
|
212
223
|
packageManager: this.projectConfig.packageManager,
|
|
@@ -215,6 +226,8 @@ export default class PobBaseGenerator extends Generator {
|
|
|
215
226
|
break;
|
|
216
227
|
case 'app':
|
|
217
228
|
this.composeWith('pob:app', {
|
|
229
|
+
monorepo: this.useLerna,
|
|
230
|
+
isRoot: this.isRoot,
|
|
218
231
|
updateOnly: this.options.updateOnly,
|
|
219
232
|
fromPob: this.options.fromPob,
|
|
220
233
|
packageManager: this.projectConfig.packageManager,
|
package/lib/pob.js
CHANGED
|
@@ -37,9 +37,9 @@ import PobBaseGenerator from './generators/pob/PobBaseGenerator.js';
|
|
|
37
37
|
import { __dirname } from './pob-dirname.cjs';
|
|
38
38
|
|
|
39
39
|
const printUsage = () => {
|
|
40
|
-
console.error('Usage: pob [
|
|
41
|
-
console.error(' pob [
|
|
42
|
-
console.error(' pob
|
|
40
|
+
console.error('Usage: pob [monorepo] [lib|app|init]');
|
|
41
|
+
console.error(' pob [monorepo] update [--force]');
|
|
42
|
+
console.error(' pob monorepo convert-npm');
|
|
43
43
|
console.error(' pob add <packageName>');
|
|
44
44
|
};
|
|
45
45
|
|
|
@@ -209,32 +209,27 @@ env.registerStub(
|
|
|
209
209
|
`${__dirname}/generators/monorepo/typescript/MonorepoTypescriptGenerator.js`,
|
|
210
210
|
);
|
|
211
211
|
|
|
212
|
-
let
|
|
213
|
-
const action =
|
|
212
|
+
let monorepo = argv._[0] === 'lerna' || argv._[0] === 'monorepo';
|
|
213
|
+
const action = monorepo ? argv._[1] : argv._[0];
|
|
214
214
|
const projectPkg = readJson(path.resolve('./package.json'));
|
|
215
215
|
|
|
216
216
|
if (action === 'add') {
|
|
217
|
-
if (!
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
if (!projectPkg.workspaces) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
'Missing workspaces field in package.json: not a lerna repo',
|
|
220
|
+
);
|
|
220
221
|
}
|
|
221
222
|
|
|
222
|
-
const packageName = argv._[1];
|
|
223
|
+
const packageName = monorepo ? argv._[2] : argv._[1];
|
|
223
224
|
|
|
224
225
|
if (!packageName) {
|
|
225
226
|
console.error('Missing argument: packageName');
|
|
226
227
|
printUsage();
|
|
227
228
|
process.exit(1);
|
|
228
229
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
throw new Error(
|
|
233
|
-
'Missing workspaces field in package.json: not a lerna repo',
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const packagesPath = pkg.workspaces[0].replace(/\/\*$/, '');
|
|
230
|
+
const packagesPath = packageName.startsWith('@')
|
|
231
|
+
? packageName
|
|
232
|
+
: projectPkg.workspaces[0].replace(/\/\*$/, '');
|
|
238
233
|
|
|
239
234
|
fs.mkdirSync(`${packagesPath}/${packageName}`, { recursive: true });
|
|
240
235
|
writeFileSync(`${packagesPath}/${packageName}/.yo-rc.json`, '{}');
|
|
@@ -242,14 +237,20 @@ if (action === 'add') {
|
|
|
242
237
|
`${packagesPath}/${packageName}/package.json`,
|
|
243
238
|
JSON.stringify({ name: packageName, version: '1.0.0-pre' }, null, 2),
|
|
244
239
|
);
|
|
245
|
-
|
|
240
|
+
console.log('> Creating new Package');
|
|
241
|
+
spawnSync(process.argv[0], [process.argv[1]], {
|
|
246
242
|
cwd: `${packagesPath}/${packageName}`,
|
|
247
243
|
stdio: 'inherit',
|
|
248
244
|
});
|
|
245
|
+
|
|
246
|
+
console.log('> Updating monorepo');
|
|
247
|
+
spawnSync(process.argv[0], [process.argv[1], 'update'], {
|
|
248
|
+
stdio: 'inherit',
|
|
249
|
+
});
|
|
249
250
|
process.exit(0);
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
if (
|
|
253
|
+
if (monorepo && action === 'convert-npm') {
|
|
253
254
|
execSync('sed -i \'/"npmClient": "yarn",/d\' ./lerna.json', {
|
|
254
255
|
stdio: 'inherit',
|
|
255
256
|
});
|
|
@@ -260,7 +261,8 @@ if (lerna && action === 'convert-npm') {
|
|
|
260
261
|
}
|
|
261
262
|
|
|
262
263
|
const updateOnly = action === 'update';
|
|
263
|
-
const
|
|
264
|
+
const init = action === 'init';
|
|
265
|
+
const type = updateOnly || init ? null : action;
|
|
264
266
|
const fromPob = updateOnly && argv._[1] === 'from-pob';
|
|
265
267
|
|
|
266
268
|
if (!existsSync('.yo-rc.json')) {
|
|
@@ -272,13 +274,14 @@ if (!existsSync('.yo-rc.json')) {
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
if (existsSync('lerna.json') || (projectPkg && projectPkg.lerna)) {
|
|
275
|
-
|
|
277
|
+
monorepo = true;
|
|
276
278
|
}
|
|
277
279
|
|
|
278
280
|
const options = {
|
|
279
281
|
type,
|
|
282
|
+
init,
|
|
280
283
|
updateOnly,
|
|
281
|
-
|
|
284
|
+
monorepo,
|
|
282
285
|
fromPob,
|
|
283
286
|
force: argv.force,
|
|
284
287
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pob",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"skeleton"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": "^
|
|
21
|
+
"node": "^14.13.1 || >=16.0.0"
|
|
22
22
|
},
|
|
23
23
|
"main": "./lib/index.js",
|
|
24
24
|
"exports": {
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@lerna/package-graph": "^4.0.0",
|
|
49
49
|
"@lerna/project": "^4.0.0",
|
|
50
|
-
"@pob/sort-eslint-config": "^
|
|
51
|
-
"@pob/sort-object": "^
|
|
52
|
-
"@pob/sort-pkg": "^
|
|
50
|
+
"@pob/sort-eslint-config": "^3.0.0",
|
|
51
|
+
"@pob/sort-object": "^4.0.0",
|
|
52
|
+
"@pob/sort-pkg": "^4.0.0",
|
|
53
53
|
"@yarnpkg/parsers": "^2.2.0",
|
|
54
54
|
"findup-sync": "^5.0.0",
|
|
55
55
|
"generator-license": "^5.4.0",
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
"mem-fs-editor": "8.1.2",
|
|
64
64
|
"minimist-argv": "^1.1.0",
|
|
65
65
|
"parse-author": "^2.0.0",
|
|
66
|
-
"pob-dependencies": "^
|
|
67
|
-
"prettier": "2.5.
|
|
66
|
+
"pob-dependencies": "^6.0.2",
|
|
67
|
+
"prettier": "2.5.1",
|
|
68
68
|
"semver": "^7.3.4",
|
|
69
69
|
"update-notifier": "^5.0.1",
|
|
70
70
|
"yeoman-environment": "^3.5.1",
|
|
71
71
|
"yeoman-generator": "^5.4.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "e1a168b7559c8d9db408d70e745a59c83b4bfb2d"
|
|
74
74
|
}
|