pob 13.3.0 → 13.5.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 +56 -0
- package/lib/generators/app/PobAppGenerator.js +8 -2
- package/lib/generators/app/ignorePaths.js +10 -7
- package/lib/generators/app/nextjs/AppNextjsGenerator.js +2 -1
- package/lib/generators/common/babel/CommonBabelGenerator.js +78 -20
- package/lib/generators/common/babel/templates/app.rollup.config.mjs.ejs +6 -1
- package/lib/generators/common/format-lint/CommonLintGenerator.js +19 -13
- package/lib/generators/common/format-lint/updateEslintConfig.js +13 -10
- package/lib/generators/common/release/CommonReleaseGenerator.js +2 -0
- package/lib/generators/common/testing/CommonTestingGenerator.js +74 -23
- package/lib/generators/common/testing/templates/babel.config.cjs.ejs +1 -1
- package/lib/generators/common/typescript/CommonTypescriptGenerator.js +13 -0
- package/lib/generators/common/typescript/templates/tsconfig.json.ejs +5 -1
- package/lib/generators/core/ci/CoreCIGenerator.js +9 -8
- package/lib/generators/core/ci/templates/github-action-push-workflow.yml.ejs +1 -1
- package/lib/generators/core/yarn/CoreYarnGenerator.js +39 -22
- package/lib/generators/lib/PobLibGenerator.js +2 -1
- package/lib/generators/monorepo/PobMonorepoGenerator.js +5 -8
- package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +15 -3
- package/lib/generators/monorepo/lerna/templates/workflow-publish.yml.ejs +39 -18
- package/lib/generators/pob/PobBaseGenerator.js +6 -6
- package/lib/utils/package.js +4 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,62 @@
|
|
|
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
|
+
## [13.5.0](https://github.com/christophehurpeau/pob/compare/pob@13.4.0...pob@13.5.0) (2023-09-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **deps:** update dependency eslint to v8.48.0 ([#1753](https://github.com/christophehurpeau/pob/issues/1753)) ([24cf09f](https://github.com/christophehurpeau/pob/commit/24cf09fab37d5897e8e7f8e4b57da225bac2eca7))
|
|
12
|
+
* **deps:** update dependency eslint to v8.49.0 ([#1766](https://github.com/christophehurpeau/pob/issues/1766)) ([061b3df](https://github.com/christophehurpeau/pob/commit/061b3dfb1aeb30cae10776d9c21c675ddeec740e))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* **deps:** update dependency yeoman-environment to v4.0.0-beta.4 ([#1768](https://github.com/christophehurpeau/pob/issues/1768)) ([9798aef](https://github.com/christophehurpeau/pob/commit/9798aef1a5ccb2d7c752fd5f13253bf614ea1e5f))
|
|
18
|
+
* **deps:** update dependency yeoman-generator to v6.0.0-rc.4 ([#1737](https://github.com/christophehurpeau/pob/issues/1737)) ([ec4b155](https://github.com/christophehurpeau/pob/commit/ec4b155b948e4474fa740661c0fe496b56f44616))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [13.4.0](https://github.com/christophehurpeau/pob/compare/pob@13.3.0...pob@13.4.0) (2023-08-14)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
* **deps:** update dependency eslint to v8.45.0 ([#1708](https://github.com/christophehurpeau/pob/issues/1708)) ([9113ab1](https://github.com/christophehurpeau/pob/commit/9113ab18fe809614382d9e2fbb8180892f31962e))
|
|
28
|
+
* **deps:** update dependency eslint to v8.46.0 ([#1717](https://github.com/christophehurpeau/pob/issues/1717)) ([e40f88b](https://github.com/christophehurpeau/pob/commit/e40f88b7db84e544e9a5992f654f79bfd0d1aaf8))
|
|
29
|
+
* **deps:** update dependency eslint to v8.47.0 ([#1732](https://github.com/christophehurpeau/pob/issues/1732)) ([333b820](https://github.com/christophehurpeau/pob/commit/333b820c07d500d6aba8f4af3e62125787ab8c22))
|
|
30
|
+
* improve jest config ([8243486](https://github.com/christophehurpeau/pob/commit/82434867b2ba54e1f6eb9faee0a56e38e218d4bf))
|
|
31
|
+
* **pob:** add name in publish job ([4a2bc0f](https://github.com/christophehurpeau/pob/commit/4a2bc0f44bd195425227bfe7e340b0a6169715f2))
|
|
32
|
+
* **pob:** ci plugin yarn version ([7ee583e](https://github.com/christophehurpeau/pob/commit/7ee583eba40a1a609c7c98e459f4e36b394d447e))
|
|
33
|
+
* **pob:** configure types in extraEntries ([10548e2](https://github.com/christophehurpeau/pob/commit/10548e2a55a51f1541412ce8149587c58391a9e7))
|
|
34
|
+
* **pob:** disable tsc cache for apps ([f7b3c46](https://github.com/christophehurpeau/pob/commit/f7b3c46640e68719cbf6c1c08d5b43393d6102f1))
|
|
35
|
+
* **pob:** improve config for app node-library ([3812f31](https://github.com/christophehurpeau/pob/commit/3812f31bd9ed48467f7f31a2d7e29ce1daa04074))
|
|
36
|
+
* **pob:** support esbuild ([a0ece75](https://github.com/christophehurpeau/pob/commit/a0ece756603ca84bcdf2f0c45dde3123ca9b90f7))
|
|
37
|
+
* support tamagui ([8a8e9d4](https://github.com/christophehurpeau/pob/commit/8a8e9d4b87ae5809120e42b04de10729c8a81d94))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
### Bug Fixes
|
|
41
|
+
|
|
42
|
+
* add early return if token is missing ([afeff46](https://github.com/christophehurpeau/pob/commit/afeff4685a6031fbb1aeaecc4e8a551f1ea3938d))
|
|
43
|
+
* configure types in exports for non babel libraries ([e1ed4cf](https://github.com/christophehurpeau/pob/commit/e1ed4cf8634daa5ecb69f64baf97af8bec8a7311))
|
|
44
|
+
* **deps:** update dependency semver to v7.5.4 ([#1703](https://github.com/christophehurpeau/pob/issues/1703)) ([0656af8](https://github.com/christophehurpeau/pob/commit/0656af8a33c72353bc94596478620cec1fff373d))
|
|
45
|
+
* **deps:** update dependency yeoman-generator to v6.0.0-rc.3 ([#1720](https://github.com/christophehurpeau/pob/issues/1720)) ([f397a89](https://github.com/christophehurpeau/pob/commit/f397a890efbe842d82721131f3812dfdc1ed22a3))
|
|
46
|
+
* fix ignore paths for apps ([be6b9c1](https://github.com/christophehurpeau/pob/commit/be6b9c19792a973cce2b77525fecabb56192d53d))
|
|
47
|
+
* fixes for publish workflow ([101ecdb](https://github.com/christophehurpeau/pob/commit/101ecdb32c60875f5b1bac9fa07cd2358485b42e))
|
|
48
|
+
* intialize yarn before getting cached package.json ([ef595bc](https://github.com/christophehurpeau/pob/commit/ef595bc01296ee5b119ec93e64cd89e5e87cfcdc))
|
|
49
|
+
* keep @babel/preset-react for rollup plugins ([f44881e](https://github.com/christophehurpeau/pob/commit/f44881e676afc4a23d7df19e798d293c7a476e98))
|
|
50
|
+
* **pob:** dont use yarn plugin for eslint-config as it is a monorepo with fixed version ([a93cb1f](https://github.com/christophehurpeau/pob/commit/a93cb1fbbed480280d83ffcd40d1ad2adbb17578))
|
|
51
|
+
* **pob:** export types for private package ([c0e78d1](https://github.com/christophehurpeau/pob/commit/c0e78d1d4c066d9c8e86c9d7aa8b7bfc613e15fc))
|
|
52
|
+
* **pob:** fix alp-dev check in dependencies ([4ebc6bb](https://github.com/christophehurpeau/pob/commit/4ebc6bb3eed9aaee8273e02022957824284d39c7))
|
|
53
|
+
* **pob:** fix publish with yarn ([d683add](https://github.com/christophehurpeau/pob/commit/d683addfb20ba95751f84bdd94dfeda0380ddf13))
|
|
54
|
+
* **pob:** fixes and enable yarn plugin version for eslint-configs ([396ffea](https://github.com/christophehurpeau/pob/commit/396ffea15749afe68be4de3d929d83327ff204ba))
|
|
55
|
+
* **pob:** keep incremental true even when cacheEnabled is false ([3e95d46](https://github.com/christophehurpeau/pob/commit/3e95d4664f90b087dcd42fbabea799e67a0d771d))
|
|
56
|
+
* **pob:** node 20 is not yet lts ([0cd5460](https://github.com/christophehurpeau/pob/commit/0cd54609acb348bc88edd985466bbf5b7b13cfce))
|
|
57
|
+
* **pob:** only enable incremental if cache is enabled ([f7c9d2a](https://github.com/christophehurpeau/pob/commit/f7c9d2af5dbc67a61261184410678546f26881e8))
|
|
58
|
+
* **pob:** remove noEmitOnError when noEmit is enabled ([7d9dfa2](https://github.com/christophehurpeau/pob/commit/7d9dfa2d6666577af4e93f96943ebfdb355fe2a5))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
6
62
|
## [13.3.0](https://github.com/christophehurpeau/pob/compare/pob@13.2.3...pob@13.3.0) (2023-07-05)
|
|
7
63
|
|
|
8
64
|
|
|
@@ -122,6 +122,8 @@ export default class PobAppGenerator extends Generator {
|
|
|
122
122
|
|
|
123
123
|
default() {
|
|
124
124
|
const srcDir = this.appConfig.type === 'yarn-plugin' ? 'sources' : 'src';
|
|
125
|
+
const isAppLibrary = this.appConfig.type === 'node-library';
|
|
126
|
+
|
|
125
127
|
if (
|
|
126
128
|
this.appConfig.type === 'node' ||
|
|
127
129
|
this.appConfig.type === 'node-library' ||
|
|
@@ -129,7 +131,8 @@ export default class PobAppGenerator extends Generator {
|
|
|
129
131
|
) {
|
|
130
132
|
this.composeWith('pob:common:babel', {
|
|
131
133
|
updateOnly: this.options.updateOnly,
|
|
132
|
-
isApp:
|
|
134
|
+
isApp: true,
|
|
135
|
+
isAppLibrary,
|
|
133
136
|
useAppConfig: this.appConfig.type === 'alp-node',
|
|
134
137
|
testing: this.appConfig.testing,
|
|
135
138
|
documentation: false,
|
|
@@ -160,10 +163,13 @@ export default class PobAppGenerator extends Generator {
|
|
|
160
163
|
|
|
161
164
|
const ignorePaths = appIgnorePaths[this.appConfig.type](
|
|
162
165
|
this.appConfig,
|
|
166
|
+
pkg,
|
|
163
167
|
).filter(Boolean);
|
|
164
168
|
|
|
165
169
|
this.composeWith('pob:common:typescript', {
|
|
166
170
|
enable: babel,
|
|
171
|
+
isApp: true,
|
|
172
|
+
isAppLibrary,
|
|
167
173
|
// nextjs now supports src
|
|
168
174
|
rootDir: this.appConfig.type === 'expo' ? '.' : srcDir,
|
|
169
175
|
srcDir,
|
|
@@ -224,7 +230,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
224
230
|
enableSrcResolver: true,
|
|
225
231
|
packageManager: this.options.packageManager,
|
|
226
232
|
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
227
|
-
|
|
233
|
+
rootIgnorePaths: ignorePaths.join('\n'),
|
|
228
234
|
buildDirectory: this.appConfig.type === 'expo' ? '.expo' : 'build',
|
|
229
235
|
});
|
|
230
236
|
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
export const appIgnorePaths = {
|
|
2
2
|
alp: (config) => ['# alp paths', '/build', '/public', '/data'],
|
|
3
|
-
'next.js': (config) =>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
'next.js': (config, pkg) =>
|
|
4
|
+
[
|
|
5
|
+
'# next.js paths',
|
|
6
|
+
'/.next',
|
|
7
|
+
'/out',
|
|
8
|
+
'/build',
|
|
9
|
+
'/.env.local',
|
|
10
|
+
pkg?.dependencies?.tamagui ? '# tamagui' : undefined,
|
|
11
|
+
pkg?.dependencies?.tamagui ? '/.tamagui' : undefined,
|
|
12
|
+
].filter(Boolean),
|
|
10
13
|
remix: (config) => ['# remix paths', '/.cache', '/build', '/public/build'],
|
|
11
14
|
pobpack: (config) => ['/build', '/public'],
|
|
12
15
|
node: (config) => ['/build'],
|
|
@@ -19,7 +19,8 @@ export default class AppNextjsGenerator extends Generator {
|
|
|
19
19
|
packageUtils.addScripts(pkg, {
|
|
20
20
|
start: 'next dev',
|
|
21
21
|
'start:prod': 'next start',
|
|
22
|
-
|
|
22
|
+
// NODE_ENV=production is for tamagui
|
|
23
|
+
build: 'NODE_ENV=production next build',
|
|
23
24
|
});
|
|
24
25
|
|
|
25
26
|
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
|
|
@@ -34,6 +34,12 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
34
34
|
default: false,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
this.option('isAppLibrary', {
|
|
38
|
+
type: Boolean,
|
|
39
|
+
required: false,
|
|
40
|
+
default: false,
|
|
41
|
+
});
|
|
42
|
+
|
|
37
43
|
this.option('useAppConfig', {
|
|
38
44
|
type: Boolean,
|
|
39
45
|
required: false,
|
|
@@ -355,9 +361,14 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
355
361
|
packageUtils.addDependencies(pkg, ['@babel/runtime'], '^');
|
|
356
362
|
}
|
|
357
363
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
364
|
+
const isLibraryRollupPlugin = pkg.name.includes('rollup-plugin');
|
|
365
|
+
|
|
366
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
367
|
+
pkg,
|
|
368
|
+
(useBabel && pkg.pob.jsx) ||
|
|
369
|
+
(pkg.devDependencies?.['@babel/preset-react'] && isLibraryRollupPlugin),
|
|
370
|
+
['@babel/preset-react'],
|
|
371
|
+
);
|
|
361
372
|
|
|
362
373
|
packageUtils.removeDevDependencies(pkg, [
|
|
363
374
|
'babel-preset-env', // now @babel/preset-env
|
|
@@ -371,8 +382,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
371
382
|
this.babelEnvs.find(
|
|
372
383
|
(env) => env.target === 'browser' && env.version === undefined,
|
|
373
384
|
) ||
|
|
374
|
-
(pkg.devDependencies?.['@babel/preset-env'] &&
|
|
375
|
-
pkg.name.includes('rollup-plugin')),
|
|
385
|
+
(pkg.devDependencies?.['@babel/preset-env'] && isLibraryRollupPlugin),
|
|
376
386
|
['@babel/preset-env'],
|
|
377
387
|
);
|
|
378
388
|
|
|
@@ -437,7 +447,11 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
437
447
|
// configured in babel preset
|
|
438
448
|
// modern: ['defaults and >1% and supports es6-module'],
|
|
439
449
|
};
|
|
440
|
-
} else if (
|
|
450
|
+
} else if (
|
|
451
|
+
this.options.isApp &&
|
|
452
|
+
!this.options.isAppLibrary &&
|
|
453
|
+
pkg.browserslist
|
|
454
|
+
) {
|
|
441
455
|
pkg.browserslist = {
|
|
442
456
|
...pkg.browserslist,
|
|
443
457
|
production: [
|
|
@@ -454,7 +468,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
454
468
|
|
|
455
469
|
/* side effects */
|
|
456
470
|
|
|
457
|
-
if (this.options.isApp) {
|
|
471
|
+
if (this.options.isApp && !this.options.isAppLibrary) {
|
|
458
472
|
delete pkg.sideEffects;
|
|
459
473
|
} else if (!('sideEffects' in pkg)) {
|
|
460
474
|
pkg.sideEffects = true;
|
|
@@ -553,7 +567,10 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
553
567
|
const exportName = entry === 'index' ? '.' : `./${entry}`;
|
|
554
568
|
|
|
555
569
|
const targets = {
|
|
556
|
-
types:
|
|
570
|
+
types:
|
|
571
|
+
pkg.private || this.options.isAppLibrary
|
|
572
|
+
? `./src/${entryDistName}.ts`
|
|
573
|
+
: `./${this.options.buildDirectory}/definitions/${entryDistName}.d.ts`,
|
|
557
574
|
};
|
|
558
575
|
|
|
559
576
|
const defaultNodeEnv = this.babelEnvs.find(
|
|
@@ -621,17 +638,44 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
621
638
|
});
|
|
622
639
|
|
|
623
640
|
if (pkg.pob.extraEntries) {
|
|
624
|
-
pkg.pob.extraEntries.forEach((
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
641
|
+
pkg.pob.extraEntries.forEach((extraEntryConfig) => {
|
|
642
|
+
if (typeof extraEntryConfig === 'string') {
|
|
643
|
+
extraEntryConfig = {
|
|
644
|
+
name: extraEntryConfig,
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
const calcExport = () => {
|
|
649
|
+
if (pkg.type === 'module') {
|
|
650
|
+
return extraEntryConfig.name.endsWith('.cjs') ||
|
|
651
|
+
extraEntryConfig.name.endsWith('.d.ts')
|
|
652
|
+
? `./${extraEntryConfig.name}`
|
|
653
|
+
: `./${extraEntryConfig.name}.js`;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
return {
|
|
657
|
+
import: `./${extraEntryConfig.name}.mjs`,
|
|
658
|
+
require: `./${extraEntryConfig.name}.js`,
|
|
659
|
+
};
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
let exportValue = calcExport();
|
|
663
|
+
|
|
664
|
+
if (extraEntryConfig.types) {
|
|
665
|
+
if (typeof exportValue === 'string') {
|
|
666
|
+
exportValue = {
|
|
667
|
+
types: `./${extraEntryConfig.types}`,
|
|
668
|
+
default: exportValue,
|
|
669
|
+
};
|
|
670
|
+
} else {
|
|
671
|
+
exportValue = {
|
|
672
|
+
types: `./${extraEntryConfig.types}`,
|
|
673
|
+
...exportValue,
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
pkg.exports[`./${extraEntryConfig.name}`] = exportValue;
|
|
635
679
|
});
|
|
636
680
|
}
|
|
637
681
|
} else if (!pkg.exports) {
|
|
@@ -645,6 +689,15 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
645
689
|
if (!pkg.exports['./package.json']) {
|
|
646
690
|
pkg.exports['./package.json'] = './package.json';
|
|
647
691
|
}
|
|
692
|
+
|
|
693
|
+
if (pkg.types && !pkg.exports['.'].types) {
|
|
694
|
+
if (typeof pkg.exports['.'] === 'string') {
|
|
695
|
+
pkg.exports['.'] = {
|
|
696
|
+
default: pkg.exports['.'],
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
pkg.exports['.'] = { types: pkg.types, ...pkg.exports['.'] };
|
|
700
|
+
}
|
|
648
701
|
}
|
|
649
702
|
|
|
650
703
|
Object.keys(pkg).forEach((key) => {
|
|
@@ -661,6 +714,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
661
714
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'));
|
|
662
715
|
|
|
663
716
|
const useBabel = this.babelEnvs && this.babelEnvs.length > 0;
|
|
717
|
+
const entries = pkg.pob.entries || ['index'];
|
|
664
718
|
|
|
665
719
|
/* pob-babel config */
|
|
666
720
|
|
|
@@ -668,7 +722,10 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
668
722
|
packageUtils.removeDependencies(pkg, ['alp-rollup-plugin-config']);
|
|
669
723
|
packageUtils.addOrRemoveDevDependencies(
|
|
670
724
|
pkg,
|
|
671
|
-
useBabel &&
|
|
725
|
+
useBabel &&
|
|
726
|
+
this.options.isApp &&
|
|
727
|
+
!this.options.isAppLibrary &&
|
|
728
|
+
this.options.useAppConfig,
|
|
672
729
|
['alp-rollup-plugin-config'],
|
|
673
730
|
);
|
|
674
731
|
|
|
@@ -682,6 +739,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
682
739
|
{
|
|
683
740
|
config: this.options.useAppConfig,
|
|
684
741
|
outDirectory: this.options.buildDirectory,
|
|
742
|
+
enableRun: !this.options.isAppLibrary && entries.includes('index'),
|
|
685
743
|
},
|
|
686
744
|
);
|
|
687
745
|
} else {
|
|
@@ -4,9 +4,11 @@ import { fileURLToPath } from 'node:url';
|
|
|
4
4
|
import config from 'alp-rollup-plugin-config';
|
|
5
5
|
<% } -%>
|
|
6
6
|
import createRollupConfig from 'pob-babel/createRollupConfig.js';
|
|
7
|
+
<% if (enableRun) { -%>
|
|
7
8
|
import run from 'pob-babel/plugin-run.cjs';
|
|
8
9
|
|
|
9
10
|
const watch = process.env.ROLLUP_WATCH === 'true';
|
|
11
|
+
<% } -%>
|
|
10
12
|
|
|
11
13
|
export default createRollupConfig({
|
|
12
14
|
cwd: dirname(fileURLToPath(import.meta.url)),
|
|
@@ -17,5 +19,8 @@ export default createRollupConfig({
|
|
|
17
19
|
targets: [{ src: 'src/config/**/*.yml' }],
|
|
18
20
|
}),
|
|
19
21
|
<% } -%>
|
|
20
|
-
|
|
22
|
+
<% if (enableRun) { -%>
|
|
23
|
+
watch && run({ execArgv: ['--enable-source-maps'] }),
|
|
24
|
+
<% } -%>
|
|
25
|
+
],
|
|
21
26
|
});
|
|
@@ -40,6 +40,12 @@ export default class CommonLintGenerator extends Generator {
|
|
|
40
40
|
desc: 'Documentation enabled',
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
+
this.option('testing', {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
required: true,
|
|
46
|
+
desc: 'Testing enabled',
|
|
47
|
+
});
|
|
48
|
+
|
|
43
49
|
this.option('typescript', {
|
|
44
50
|
type: Boolean,
|
|
45
51
|
required: false,
|
|
@@ -371,10 +377,9 @@ export default class CommonLintGenerator extends Generator {
|
|
|
371
377
|
? `{${pkg.type === 'commonjs' ? 'mjs' : 'cjs'},js}`
|
|
372
378
|
: `${hasReact ? '{ts,tsx}' : 'ts'}`;
|
|
373
379
|
|
|
374
|
-
const
|
|
375
|
-
|
|
376
|
-
?
|
|
377
|
-
: {
|
|
380
|
+
const testsOverride =
|
|
381
|
+
this.options.testing || globalTesting
|
|
382
|
+
? {
|
|
378
383
|
files: [`**/*.test.${ext}`, `__tests__/**/*.${ext}`],
|
|
379
384
|
env: { jest: true },
|
|
380
385
|
rules: {
|
|
@@ -383,15 +388,16 @@ export default class CommonLintGenerator extends Generator {
|
|
|
383
388
|
{ devDependencies: true },
|
|
384
389
|
],
|
|
385
390
|
},
|
|
386
|
-
}
|
|
391
|
+
}
|
|
392
|
+
: null;
|
|
387
393
|
|
|
388
|
-
if (
|
|
394
|
+
if (testsOverride) {
|
|
389
395
|
// if (!useBabel) {
|
|
390
|
-
//
|
|
396
|
+
// testsOverride.extends = ['pob/babel'];
|
|
391
397
|
// }
|
|
392
398
|
|
|
393
399
|
if (useBabel) {
|
|
394
|
-
|
|
400
|
+
testsOverride.extends = ['@pob/eslint-config-typescript/test'];
|
|
395
401
|
}
|
|
396
402
|
}
|
|
397
403
|
|
|
@@ -423,8 +429,8 @@ export default class CommonLintGenerator extends Generator {
|
|
|
423
429
|
if ((!inLerna || !inLerna.root) && useBabel) {
|
|
424
430
|
const buildPath = `/${this.options.buildDirectory}`;
|
|
425
431
|
if (
|
|
426
|
-
!this.options.
|
|
427
|
-
!this.options.
|
|
432
|
+
!this.options.rootIgnorePaths ||
|
|
433
|
+
!this.options.rootIgnorePaths.includes(buildPath)
|
|
428
434
|
) {
|
|
429
435
|
ignorePatterns.add(buildPath);
|
|
430
436
|
}
|
|
@@ -433,8 +439,8 @@ export default class CommonLintGenerator extends Generator {
|
|
|
433
439
|
ignorePatterns.add('/rollup.config.mjs');
|
|
434
440
|
}
|
|
435
441
|
|
|
436
|
-
if (this.options.
|
|
437
|
-
this.options.
|
|
442
|
+
if (this.options.rootIgnorePaths) {
|
|
443
|
+
this.options.rootIgnorePaths
|
|
438
444
|
.split('\n')
|
|
439
445
|
.filter(Boolean)
|
|
440
446
|
.forEach((ignorePath) => {
|
|
@@ -493,7 +499,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
493
499
|
this.fs.readJSON(srcEslintrcPath, {}),
|
|
494
500
|
{
|
|
495
501
|
extendsConfig: extendsConfigSrc,
|
|
496
|
-
|
|
502
|
+
testsOverride,
|
|
497
503
|
useTypescript: useBabel,
|
|
498
504
|
globalEslint,
|
|
499
505
|
ignorePatterns:
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import sortConfig from '@pob/sort-eslint-config';
|
|
2
2
|
|
|
3
|
-
function updateOverrides(config,
|
|
4
|
-
const
|
|
3
|
+
function updateOverrides(config, testsOverride) {
|
|
4
|
+
const existingTestsOverrideIndex = !config.overrides
|
|
5
5
|
? -1
|
|
6
6
|
: config.overrides.findIndex(
|
|
7
7
|
(override) => override.env && override.env.jest,
|
|
8
8
|
);
|
|
9
|
-
if (!
|
|
10
|
-
if (
|
|
11
|
-
config.overrides.splice(
|
|
9
|
+
if (!testsOverride) {
|
|
10
|
+
if (existingTestsOverrideIndex !== -1) {
|
|
11
|
+
config.overrides.splice(existingTestsOverrideIndex, 1);
|
|
12
12
|
if (config.overrides.length === 0) {
|
|
13
13
|
delete config.overrides;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
} else {
|
|
17
17
|
// eslint-disable-next-line no-lonely-if
|
|
18
|
-
if (
|
|
19
|
-
Object.assign(
|
|
18
|
+
if (existingTestsOverrideIndex !== -1) {
|
|
19
|
+
Object.assign(
|
|
20
|
+
config.overrides[existingTestsOverrideIndex],
|
|
21
|
+
testsOverride,
|
|
22
|
+
);
|
|
20
23
|
} else {
|
|
21
24
|
if (!config.overrides) config.overrides = [];
|
|
22
|
-
config.overrides.push(
|
|
25
|
+
config.overrides.push(testsOverride);
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
return config;
|
|
@@ -103,7 +106,7 @@ export default function updateEslintConfig(
|
|
|
103
106
|
config,
|
|
104
107
|
{
|
|
105
108
|
extendsConfig,
|
|
106
|
-
|
|
109
|
+
testsOverride,
|
|
107
110
|
useTypescript,
|
|
108
111
|
globalEslint,
|
|
109
112
|
settings,
|
|
@@ -128,7 +131,7 @@ export default function updateEslintConfig(
|
|
|
128
131
|
globalEslint,
|
|
129
132
|
relativePath,
|
|
130
133
|
);
|
|
131
|
-
config = updateOverrides(config,
|
|
134
|
+
config = updateOverrides(config, testsOverride);
|
|
132
135
|
if (settings) {
|
|
133
136
|
config = updateSettings(config, settings);
|
|
134
137
|
}
|
|
@@ -2,7 +2,10 @@ import path from 'node:path';
|
|
|
2
2
|
import Generator from 'yeoman-generator';
|
|
3
3
|
import inLerna from '../../../utils/inLerna.js';
|
|
4
4
|
import * as packageUtils from '../../../utils/package.js';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
copyAndFormatTpl,
|
|
7
|
+
writeAndFormatJson,
|
|
8
|
+
} from '../../../utils/writeAndFormat.js';
|
|
6
9
|
|
|
7
10
|
export default class CommonTestingGenerator extends Generator {
|
|
8
11
|
constructor(args, opts) {
|
|
@@ -32,6 +35,12 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
32
35
|
desc: 'enable release-please',
|
|
33
36
|
});
|
|
34
37
|
|
|
38
|
+
this.option('enableYarnVersion', {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: true,
|
|
41
|
+
desc: 'enable yarn version conventional commits',
|
|
42
|
+
});
|
|
43
|
+
|
|
35
44
|
this.option('ci', {
|
|
36
45
|
type: Boolean,
|
|
37
46
|
required: true,
|
|
@@ -98,6 +107,7 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
98
107
|
this.composeWith('pob:core:ci', {
|
|
99
108
|
enable: this.options.ci,
|
|
100
109
|
enableReleasePlease: this.options.enableReleasePlease,
|
|
110
|
+
enableYarnVersion: this.options.enableYarnVersion,
|
|
101
111
|
testing: this.options.enable,
|
|
102
112
|
build: this.options.build,
|
|
103
113
|
typescript: this.options.typescript,
|
|
@@ -131,19 +141,33 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
131
141
|
const yoConfigPobMonorepo = inLerna && inLerna.pobMonorepoConfig;
|
|
132
142
|
const globalTesting = yoConfigPobMonorepo && yoConfigPobMonorepo.testing;
|
|
133
143
|
const enableForMonorepo = this.options.monorepo && globalTesting;
|
|
134
|
-
const
|
|
144
|
+
const transpileWithEsbuild = packageUtils.transpileWithEsbuild(pkg);
|
|
145
|
+
const transpileWithBabel = transpileWithEsbuild
|
|
146
|
+
? false
|
|
147
|
+
: // eslint-disable-next-line unicorn/no-nested-ternary
|
|
148
|
+
this.options.monorepo
|
|
135
149
|
? yoConfigPobMonorepo.typescript
|
|
136
|
-
:
|
|
150
|
+
: packageUtils.transpileWithBabel(pkg);
|
|
137
151
|
let hasReact =
|
|
138
152
|
transpileWithBabel &&
|
|
139
153
|
(this.options.monorepo
|
|
140
154
|
? yoConfigPobMonorepo.react ?? packageUtils.hasReact(pkg)
|
|
141
155
|
: packageUtils.hasReact(pkg));
|
|
142
156
|
|
|
143
|
-
|
|
157
|
+
const isJestRunner = this.options.runner === 'jest';
|
|
158
|
+
|
|
159
|
+
if (
|
|
160
|
+
!this.options.enable ||
|
|
161
|
+
!isJestRunner ||
|
|
162
|
+
(globalTesting && !enableForMonorepo)
|
|
163
|
+
) {
|
|
144
164
|
packageUtils.removeDevDependencies(pkg, ['jest', '@types/jest']);
|
|
145
165
|
|
|
146
166
|
delete pkg.jest;
|
|
167
|
+
this.fs.delete(this.destinationPath('jest.config.js'));
|
|
168
|
+
this.fs.delete(this.destinationPath('jest.config.mjs'));
|
|
169
|
+
this.fs.delete(this.destinationPath('jest.config.cjs'));
|
|
170
|
+
this.fs.delete(this.destinationPath('jest.config.json'));
|
|
147
171
|
}
|
|
148
172
|
|
|
149
173
|
if (!this.options.enable) {
|
|
@@ -160,8 +184,9 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
160
184
|
delete pkg.scripts['test:coverage'];
|
|
161
185
|
}
|
|
162
186
|
|
|
163
|
-
this.fs
|
|
187
|
+
writeAndFormatJson(this.fs, this.destinationPath('package.json'), pkg);
|
|
164
188
|
} else {
|
|
189
|
+
const jestConfigPath = this.destinationPath('jest.config.json');
|
|
165
190
|
if (this.options.runner === 'jest') {
|
|
166
191
|
packageUtils.addOrRemoveDevDependencies(
|
|
167
192
|
pkg,
|
|
@@ -172,7 +197,6 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
172
197
|
|
|
173
198
|
packageUtils.removeScripts(['test:coverage']);
|
|
174
199
|
if (this.options.monorepo && !globalTesting) {
|
|
175
|
-
delete pkg.jest;
|
|
176
200
|
packageUtils.addScripts(pkg, {
|
|
177
201
|
test: 'yarn workspaces foreach --parallel -Av run test',
|
|
178
202
|
});
|
|
@@ -197,7 +221,7 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
197
221
|
: testCommand, // not yet configured
|
|
198
222
|
});
|
|
199
223
|
|
|
200
|
-
if (
|
|
224
|
+
if (isJestRunner) {
|
|
201
225
|
const workspacesWithoutStar = pkg.workspaces.map((workspace) => {
|
|
202
226
|
if (!workspace.endsWith('/*')) {
|
|
203
227
|
throw new Error(`Invalid workspace format: ${workspace}`);
|
|
@@ -212,9 +236,11 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
212
236
|
pkgName.startsWith('react-'),
|
|
213
237
|
);
|
|
214
238
|
|
|
215
|
-
|
|
239
|
+
const jestConfig = this.fs.readJSON(jestConfigPath, pkg.jest ?? {});
|
|
240
|
+
delete pkg.jest;
|
|
241
|
+
|
|
216
242
|
const srcDir = this.options.srcDir;
|
|
217
|
-
Object.assign(
|
|
243
|
+
Object.assign(jestConfig, {
|
|
218
244
|
cacheDirectory: './node_modules/.cache/jest',
|
|
219
245
|
testEnvironment: 'node',
|
|
220
246
|
testMatch: [
|
|
@@ -228,16 +254,16 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
228
254
|
});
|
|
229
255
|
|
|
230
256
|
if (shouldUseExperimentalVmModules) {
|
|
231
|
-
|
|
257
|
+
jestConfig.extensionsToTreatAsEsm = [
|
|
232
258
|
transpileWithBabel && '.ts',
|
|
233
259
|
transpileWithBabel && hasReact && '.tsx',
|
|
234
260
|
].filter(Boolean);
|
|
235
261
|
} else {
|
|
236
|
-
delete
|
|
262
|
+
delete jestConfig.extensionsToTreatAsEsm;
|
|
237
263
|
}
|
|
264
|
+
writeAndFormatJson(this.fs, jestConfigPath, jestConfig);
|
|
238
265
|
}
|
|
239
266
|
} else if (globalTesting) {
|
|
240
|
-
delete pkg.jest;
|
|
241
267
|
if (pkg.scripts) {
|
|
242
268
|
delete pkg.scripts['generate:test-coverage'];
|
|
243
269
|
delete pkg.scripts['test:watch'];
|
|
@@ -276,8 +302,9 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
276
302
|
if (this.options.runner === 'jest') {
|
|
277
303
|
const srcDirectory = transpileWithBabel ? this.options.srcDir : 'lib';
|
|
278
304
|
|
|
279
|
-
|
|
280
|
-
|
|
305
|
+
const jestConfig = this.fs.readJSON(jestConfigPath, pkg.jest ?? {});
|
|
306
|
+
delete pkg.jest;
|
|
307
|
+
Object.assign(jestConfig, {
|
|
281
308
|
cacheDirectory: './node_modules/.cache/jest',
|
|
282
309
|
testMatch: [
|
|
283
310
|
`<rootDir>/${srcDirectory}/**/__tests__/**/*.${
|
|
@@ -303,29 +330,53 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
303
330
|
// [`^.+\\.ts${hasReact ? 'x?' : ''}$`]: 'babel-jest',
|
|
304
331
|
// },
|
|
305
332
|
});
|
|
306
|
-
|
|
333
|
+
if (transpileWithEsbuild) {
|
|
334
|
+
jestConfig.transform = {
|
|
335
|
+
[hasReact ? '^.+\\.tsx?$' : '^.+\\.ts$']: [
|
|
336
|
+
'jest-esbuild',
|
|
337
|
+
{
|
|
338
|
+
format: shouldUseExperimentalVmModules ? 'esm' : 'cjs',
|
|
339
|
+
},
|
|
340
|
+
],
|
|
341
|
+
};
|
|
342
|
+
} else if (!transpileWithBabel) {
|
|
343
|
+
delete jestConfig.transform;
|
|
344
|
+
} else if (jestConfig.transform) {
|
|
345
|
+
jestConfig.transform = Object.fromEntries(
|
|
346
|
+
Object.entries(jestConfig.transform).filter(
|
|
347
|
+
([key, value]) =>
|
|
348
|
+
!(
|
|
349
|
+
value &&
|
|
350
|
+
Array.isArray(value) &&
|
|
351
|
+
value[0] === 'jest-esbuild'
|
|
352
|
+
),
|
|
353
|
+
),
|
|
354
|
+
);
|
|
355
|
+
if (Object.keys(jestConfig.transform).length === 0) {
|
|
356
|
+
delete jestConfig.transform;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
307
359
|
|
|
308
360
|
if (shouldUseExperimentalVmModules) {
|
|
309
|
-
|
|
361
|
+
jestConfig.extensionsToTreatAsEsm = [
|
|
310
362
|
transpileWithBabel && '.ts',
|
|
311
363
|
transpileWithBabel && hasReact && '.tsx',
|
|
312
364
|
].filter(Boolean);
|
|
313
365
|
} else {
|
|
314
|
-
delete
|
|
366
|
+
delete jestConfig.extensionsToTreatAsEsm;
|
|
315
367
|
}
|
|
316
368
|
|
|
317
369
|
if (
|
|
318
370
|
babelEnvs.length === 0 ||
|
|
319
371
|
babelEnvs.some((env) => env.target === 'node')
|
|
320
372
|
) {
|
|
321
|
-
|
|
373
|
+
// jestConfig.testEnvironment = 'node'; this is the default now
|
|
374
|
+
delete jestConfig.testEnvironment;
|
|
322
375
|
} else {
|
|
323
|
-
delete
|
|
376
|
+
delete jestConfig.testEnvironment;
|
|
324
377
|
}
|
|
325
378
|
|
|
326
|
-
|
|
327
|
-
} else {
|
|
328
|
-
delete pkg.jest;
|
|
379
|
+
writeAndFormatJson(this.fs, jestConfigPath, jestConfig);
|
|
329
380
|
}
|
|
330
381
|
}
|
|
331
382
|
}
|
|
@@ -360,6 +411,6 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
360
411
|
this.fs.delete('babel.config.cjs');
|
|
361
412
|
}
|
|
362
413
|
|
|
363
|
-
this.fs
|
|
414
|
+
writeAndFormatJson(this.fs, this.destinationPath('package.json'), pkg);
|
|
364
415
|
}
|
|
365
416
|
}
|
|
@@ -8,7 +8,7 @@ module.exports = function babelConfig(api) {
|
|
|
8
8
|
return {
|
|
9
9
|
only: [<%- only %>],
|
|
10
10
|
presets: [
|
|
11
|
-
['pob-babel/preset.js'
|
|
11
|
+
['pob-babel/preset.js', { modules: <%- jestExperimentalESM ? 'false' : "'commonjs'" %> }]
|
|
12
12
|
<% if (hasReact) { %>, [
|
|
13
13
|
'@babel/preset-react',
|
|
14
14
|
{
|
|
@@ -14,6 +14,18 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
14
14
|
desc: 'enable typescript',
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
+
this.option('isApp', {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
required: true,
|
|
20
|
+
desc: 'is app',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
this.option('isAppLibrary', {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
required: false,
|
|
26
|
+
default: false,
|
|
27
|
+
});
|
|
28
|
+
|
|
17
29
|
this.option('rootDir', {
|
|
18
30
|
type: String,
|
|
19
31
|
default: 'src',
|
|
@@ -189,6 +201,7 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
189
201
|
tsconfigPath,
|
|
190
202
|
{
|
|
191
203
|
emit: this.options.builddefs,
|
|
204
|
+
cacheEnabled: !this.options.isApp || this.options.isAppLibrary,
|
|
192
205
|
monorepoPackageSrcPaths,
|
|
193
206
|
monorepoPackageReferences,
|
|
194
207
|
rootDir: this.options.rootDir,
|
|
@@ -21,12 +21,16 @@
|
|
|
21
21
|
"tsBuildInfoFile": "dist/definitions/tsbuildinfo",
|
|
22
22
|
<% } -%>
|
|
23
23
|
<% } else if (composite) { -%>
|
|
24
|
+
<% if (cacheEnabled) { -%>
|
|
24
25
|
"outDir": "node_modules/.cache/tsc",
|
|
26
|
+
<% } else { -%>
|
|
27
|
+
"noEmit": true,
|
|
28
|
+
<% } -%>
|
|
25
29
|
"tsBuildInfoFile": "node_modules/.cache/tsc/tsbuildinfo",
|
|
26
30
|
<% } else { -%>
|
|
27
31
|
"noEmit": true,
|
|
28
32
|
<% } -%>
|
|
29
|
-
<% if (composite || emit) { -%>
|
|
33
|
+
<% if ((composite && cacheEnabled) || emit) { -%>
|
|
30
34
|
"noEmitOnError": true,
|
|
31
35
|
"declaration": true,
|
|
32
36
|
"declarationMap": true,
|
|
@@ -22,6 +22,12 @@ export default class CoreCIGenerator extends Generator {
|
|
|
22
22
|
desc: 'enable release-please',
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
+
this.option('enableYarnVersion', {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: true,
|
|
28
|
+
desc: 'enable yarn version conventional commits',
|
|
29
|
+
});
|
|
30
|
+
|
|
25
31
|
this.option('build', {
|
|
26
32
|
type: Boolean,
|
|
27
33
|
default: true,
|
|
@@ -88,12 +94,14 @@ export default class CoreCIGenerator extends Generator {
|
|
|
88
94
|
|
|
89
95
|
this.isReleasePleaseEnabled =
|
|
90
96
|
this.options.enableReleasePlease &&
|
|
97
|
+
!this.options.enableYarnVersion &&
|
|
91
98
|
!pkg.devDependencies?.['standard-version'];
|
|
92
99
|
|
|
93
100
|
if (
|
|
94
101
|
this.options.enableReleasePlease &&
|
|
95
102
|
!process.env.CI &&
|
|
96
|
-
!this.isReleasePleaseEnabled
|
|
103
|
+
!this.isReleasePleaseEnabled &&
|
|
104
|
+
!this.options.enableYarnVersion
|
|
97
105
|
) {
|
|
98
106
|
const { enableReleasePlease } = await this.prompt({
|
|
99
107
|
type: 'confirm',
|
|
@@ -194,14 +202,7 @@ export default class CoreCIGenerator extends Generator {
|
|
|
194
202
|
if (!this.options.enable) {
|
|
195
203
|
packageUtils.removeDevDependencies(pkg, ['jest-junit-reporter']);
|
|
196
204
|
} else {
|
|
197
|
-
// this.babelEnvs = JSON.parse(this.options.babelEnvs);
|
|
198
|
-
|
|
199
205
|
packageUtils.removeDevDependencies(pkg, ['jest-junit-reporter']);
|
|
200
|
-
// packageUtils.addOrRemoveDevDependencies(
|
|
201
|
-
// pkg,
|
|
202
|
-
// this.options.circleci && pkg.jest,
|
|
203
|
-
// ['jest-junit-reporter'],
|
|
204
|
-
// );
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
|
|
@@ -37,9 +37,9 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
37
37
|
if (!fs.existsSync('.yarnrc.yml')) {
|
|
38
38
|
// yarn 2 not yet installed
|
|
39
39
|
// https://yarnpkg.com/getting-started/install
|
|
40
|
-
this.
|
|
40
|
+
this.spawnSync('yarn', ['set', 'version', 'stable']);
|
|
41
41
|
} else {
|
|
42
|
-
this.
|
|
42
|
+
this.spawnSync('yarn', ['set', 'version', 'stable']);
|
|
43
43
|
ensureJsonFileFormatted(this.destinationPath('package.json'));
|
|
44
44
|
}
|
|
45
45
|
}
|
|
@@ -55,7 +55,7 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
55
55
|
{},
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
-
const { stdout } = this.
|
|
58
|
+
const { stdout } = this.spawnSync(
|
|
59
59
|
'yarn',
|
|
60
60
|
['plugin', 'runtime', '--json'],
|
|
61
61
|
{ stdio: 'pipe' },
|
|
@@ -66,31 +66,48 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
66
66
|
installedPlugins.some((plugin) => plugin.name === name);
|
|
67
67
|
|
|
68
68
|
const installPlugin = (nameOrUrl) => {
|
|
69
|
-
this.
|
|
69
|
+
this.spawnSync('yarn', ['plugin', 'import', nameOrUrl]);
|
|
70
70
|
};
|
|
71
71
|
const removePlugin = (name) => {
|
|
72
|
-
this.
|
|
72
|
+
this.spawnSync('yarn', ['plugin', 'remove', name]);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const installPluginIfNotInstalled = (name, nameOrUrl = name) => {
|
|
76
|
+
if (!isPluginInstalled(name)) {
|
|
77
|
+
installPlugin(nameOrUrl);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const removePluginIfInstalled = (name) => {
|
|
82
|
+
if (isPluginInstalled(name)) {
|
|
83
|
+
removePlugin(name);
|
|
84
|
+
}
|
|
73
85
|
};
|
|
74
86
|
|
|
75
87
|
const postinstallDevPluginName = '@yarnpkg/plugin-postinstall-dev';
|
|
76
88
|
const workspacesPluginName = '@yarnpkg/plugin-workspace-tools';
|
|
89
|
+
const versionPluginName = '@yarnpkg/plugin-conventional-version';
|
|
77
90
|
|
|
78
91
|
if (!inLerna && !pkg.private) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
removePlugin(postinstallDevPluginName);
|
|
92
|
+
installPluginIfNotInstalled(
|
|
93
|
+
postinstallDevPluginName,
|
|
94
|
+
'https://raw.githubusercontent.com/sachinraja/yarn-plugin-postinstall-dev/main/bundles/%40yarnpkg/plugin-postinstall-dev.js',
|
|
95
|
+
);
|
|
96
|
+
} else {
|
|
97
|
+
removePluginIfInstalled(postinstallDevPluginName);
|
|
86
98
|
}
|
|
87
99
|
|
|
88
100
|
if (pkg.workspaces) {
|
|
89
|
-
|
|
90
|
-
|
|
101
|
+
installPluginIfNotInstalled(workspacesPluginName);
|
|
102
|
+
if (!pkg.devDependencies?.['@pob/lerna-light']) {
|
|
103
|
+
installPluginIfNotInstalled(
|
|
104
|
+
versionPluginName,
|
|
105
|
+
'https://raw.githubusercontent.com/christophehurpeau/yarn-plugin-conventional-version/main/bundles/%40yarnpkg/plugin-conventional-version.cjs',
|
|
106
|
+
);
|
|
91
107
|
}
|
|
92
|
-
} else
|
|
93
|
-
|
|
108
|
+
} else {
|
|
109
|
+
removePluginIfInstalled(workspacesPluginName);
|
|
110
|
+
removePluginIfInstalled(versionPluginName);
|
|
94
111
|
}
|
|
95
112
|
|
|
96
113
|
// must be done after plugins installed
|
|
@@ -123,28 +140,28 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
123
140
|
this.fs.delete(this.destinationPath('.yarn/build-state.yml'));
|
|
124
141
|
if (this.options.enable) {
|
|
125
142
|
if (this.options.yarnNodeLinker === 'pnp') {
|
|
126
|
-
this.
|
|
143
|
+
this.spawnSync('yarn', ['dlx', '@yarnpkg/sdks', 'vscode']);
|
|
127
144
|
} else {
|
|
128
145
|
this.fs.delete('.yarn/sdks');
|
|
129
146
|
}
|
|
130
|
-
this.
|
|
147
|
+
this.spawnSync('yarn', ['install'], {
|
|
131
148
|
env: {
|
|
132
149
|
YARN_ENABLE_IMMUTABLE_INSTALLS: 'false',
|
|
133
150
|
},
|
|
134
151
|
});
|
|
135
|
-
this.
|
|
152
|
+
this.spawnSync('yarn', ['dedupe']);
|
|
136
153
|
|
|
137
|
-
this.
|
|
154
|
+
this.spawnSync('yarn', ['prettier', '--write', '.vscode']);
|
|
138
155
|
|
|
139
156
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'));
|
|
140
157
|
|
|
141
158
|
if (pkg.scripts.preversion) {
|
|
142
159
|
try {
|
|
143
|
-
this.
|
|
160
|
+
this.spawnSync('yarn', ['run', 'preversion']);
|
|
144
161
|
} catch {}
|
|
145
162
|
} else if (pkg.scripts.build) {
|
|
146
163
|
try {
|
|
147
|
-
this.
|
|
164
|
+
this.spawnSync('yarn', ['run', 'build']);
|
|
148
165
|
} catch {}
|
|
149
166
|
}
|
|
150
167
|
}
|
|
@@ -242,6 +242,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
242
242
|
|
|
243
243
|
this.composeWith('pob:common:typescript', {
|
|
244
244
|
enable: withBabel,
|
|
245
|
+
isApp: false,
|
|
245
246
|
dom: browser,
|
|
246
247
|
jsx,
|
|
247
248
|
updateOnly: this.options.updateOnly,
|
|
@@ -283,7 +284,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
283
284
|
documentation:
|
|
284
285
|
!!this.pobjson.documentation ||
|
|
285
286
|
!!(this.pobjson.testing && this.pobjson.testing.codecov),
|
|
286
|
-
testing: this.pobjson.testing,
|
|
287
|
+
testing: !!this.pobjson.testing,
|
|
287
288
|
packageManager: this.options.packageManager,
|
|
288
289
|
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
289
290
|
ignorePaths: withBabel ? '/dist' : '',
|
|
@@ -208,7 +208,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
208
208
|
|
|
209
209
|
this.composeWith('pob:common:husky', {});
|
|
210
210
|
|
|
211
|
-
const
|
|
211
|
+
const isYarnVersionEnabled =
|
|
212
212
|
this.pobLernaConfig.testing &&
|
|
213
213
|
this.pobLernaConfig.ci &&
|
|
214
214
|
!pkg.devDependencies?.['@pob/lerna-light'];
|
|
@@ -218,7 +218,8 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
218
218
|
this.composeWith('pob:common:testing', {
|
|
219
219
|
monorepo: true,
|
|
220
220
|
enable: this.pobLernaConfig.testing,
|
|
221
|
-
enableReleasePlease:
|
|
221
|
+
enableReleasePlease: false,
|
|
222
|
+
enableYarnVersion: isYarnVersionEnabled,
|
|
222
223
|
testing: this.pobLernaConfig.testing,
|
|
223
224
|
build: this.pobLernaConfig.typescript,
|
|
224
225
|
typescript: this.pobLernaConfig.typescript,
|
|
@@ -245,11 +246,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
245
246
|
]
|
|
246
247
|
.filter(Boolean)
|
|
247
248
|
.join('\n'),
|
|
248
|
-
rootIgnorePaths: [
|
|
249
|
-
isReleasePleaseEnabled && '/.release-please-manifest.json',
|
|
250
|
-
]
|
|
251
|
-
.filter(Boolean)
|
|
252
|
-
.join('\n'),
|
|
249
|
+
rootIgnorePaths: [],
|
|
253
250
|
});
|
|
254
251
|
|
|
255
252
|
this.composeWith('pob:lib:doc', {
|
|
@@ -283,7 +280,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
283
280
|
|
|
284
281
|
this.composeWith('pob:common:release', {
|
|
285
282
|
enable: this.pobLernaConfig.testing && this.pobLernaConfig.ci,
|
|
286
|
-
|
|
283
|
+
isYarnVersionEnabled,
|
|
287
284
|
withBabel: this.pobLernaConfig.typescript,
|
|
288
285
|
documentation: this.pobLernaConfig.documentation,
|
|
289
286
|
updateOnly: this.options.updateOnly,
|
|
@@ -137,10 +137,19 @@ export default class MonorepoLernaGenerator extends Generator {
|
|
|
137
137
|
|
|
138
138
|
if (pkg.name === 'pob-monorepo') {
|
|
139
139
|
pkg.devDependencies['@pob/lerna-light'] = 'workspace:*';
|
|
140
|
-
} else
|
|
141
|
-
packageUtils.
|
|
140
|
+
} else {
|
|
141
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
142
|
+
pkg,
|
|
143
|
+
pkg.name !== 'pob-monorepo-test-repository' &&
|
|
144
|
+
pkg.name !== 'use-react-intl-formatters-monorepo',
|
|
145
|
+
// pkg.name !== '@pob/eslint-config-monorepo'
|
|
146
|
+
['@pob/lerna-light'],
|
|
147
|
+
);
|
|
142
148
|
}
|
|
143
149
|
|
|
150
|
+
// TODO remove lerna completely
|
|
151
|
+
const isYarnVersionEnabled = !pkg.devDependencies?.['@pob/lerna-light'];
|
|
152
|
+
|
|
144
153
|
if (pkg.name !== 'pob-monorepo') {
|
|
145
154
|
packageUtils.addDevDependencies(pkg, ['repository-check-dirty']);
|
|
146
155
|
}
|
|
@@ -173,18 +182,21 @@ export default class MonorepoLernaGenerator extends Generator {
|
|
|
173
182
|
|
|
174
183
|
packageUtils.addOrRemoveScripts(
|
|
175
184
|
pkg,
|
|
176
|
-
this.options.packageManager === 'yarn',
|
|
185
|
+
this.options.packageManager === 'yarn' && !isYarnVersionEnabled,
|
|
177
186
|
{
|
|
178
187
|
version:
|
|
179
188
|
'YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn && git add yarn.lock',
|
|
180
189
|
},
|
|
181
190
|
);
|
|
182
191
|
|
|
192
|
+
// TODO rename release (release = version + publish)
|
|
183
193
|
this.fs.copyTpl(
|
|
184
194
|
this.templatePath('workflow-publish.yml.ejs'),
|
|
185
195
|
this.destinationPath('.github/workflows/publish.yml'),
|
|
186
196
|
{
|
|
187
197
|
publish: !this.options.isAppProject,
|
|
198
|
+
enableYarnVersion: isYarnVersionEnabled,
|
|
199
|
+
isIndependent: lernaConfig.version === 'independent',
|
|
188
200
|
},
|
|
189
201
|
);
|
|
190
202
|
|
|
@@ -3,9 +3,21 @@ on:
|
|
|
3
3
|
workflow_dispatch:
|
|
4
4
|
inputs:
|
|
5
5
|
dry-run:
|
|
6
|
-
description: "Dry run
|
|
6
|
+
description: "Dry run"
|
|
7
7
|
required: true
|
|
8
|
-
|
|
8
|
+
type: boolean
|
|
9
|
+
default: false
|
|
10
|
+
<% if (enableYarnVersion) { -%>
|
|
11
|
+
bump-dependents-highest-as:
|
|
12
|
+
description: "Bump dependents highest as"
|
|
13
|
+
required: false
|
|
14
|
+
type: choice
|
|
15
|
+
options:
|
|
16
|
+
- major
|
|
17
|
+
- minor
|
|
18
|
+
- patch
|
|
19
|
+
default: "major"
|
|
20
|
+
<% } -%>
|
|
9
21
|
|
|
10
22
|
jobs:
|
|
11
23
|
publish:
|
|
@@ -24,43 +36,52 @@ jobs:
|
|
|
24
36
|
run: yarn install --immutable --immutable-cache
|
|
25
37
|
|
|
26
38
|
- name: New version (dry run)
|
|
27
|
-
if:
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
if: github.ref == 'refs/heads/main' && inputs.dry-run
|
|
40
|
+
<% if (enableYarnVersion) { -%>
|
|
41
|
+
run: yarn version --dry-run
|
|
42
|
+
<% } else { -%>
|
|
30
43
|
run: yarn lerna version --yes --no-push --exact --conventional-commits --conventional-graduate --changelog-preset conventional-changelog-conventionalcommits --no-git-tag-version --loglevel=verbose
|
|
31
|
-
|
|
44
|
+
<% } -%>
|
|
32
45
|
- name: Configure Git user
|
|
33
|
-
if:
|
|
34
|
-
github.ref == 'refs/heads/main'
|
|
35
|
-
&& contains(github.event.inputs.dry-run, 'y') == false
|
|
46
|
+
if: github.ref == 'refs/heads/main' && !inputs.dry-run
|
|
36
47
|
run: |
|
|
37
48
|
git config --global user.name 'github-actions[bot]'
|
|
38
49
|
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
|
|
39
50
|
|
|
40
51
|
- name: New version
|
|
41
|
-
if:
|
|
42
|
-
github.ref == 'refs/heads/main'
|
|
43
|
-
&& contains(github.event.inputs.dry-run, 'y') == false
|
|
52
|
+
if: github.ref == 'refs/heads/main' && !inputs.dry-run
|
|
44
53
|
run: |
|
|
54
|
+
<% if (enableYarnVersion) { -%>
|
|
55
|
+
yarn version --create-release=github --bump-dependents-highest-as=${{ inputs.bump-dependents-highest-as }} -m 'chore: release <%- isIndependent ? '' : '%v ' %>[skip ci]<%- isIndependent ? '\\n\\n%t' : '' %>'
|
|
56
|
+
<% } else { -%>
|
|
45
57
|
yarn lerna version --yes --push --exact --conventional-commits --conventional-graduate --changelog-preset conventional-changelog-conventionalcommits --create-release=github -m 'chore: release [skip ci]'
|
|
58
|
+
<% } -%>
|
|
46
59
|
env:
|
|
47
60
|
HUSKY: 0
|
|
48
61
|
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
49
62
|
YARN_ENABLE_IMMUTABLE_INSTALLS: false
|
|
50
63
|
<% if (publish) { -%>
|
|
51
64
|
|
|
65
|
+
<% if (enableYarnVersion) { -%>
|
|
66
|
+
- name: Publish to npm
|
|
67
|
+
run: |
|
|
68
|
+
if [ -z "$NODE_AUTH_TOKEN" ]; then
|
|
69
|
+
echo "Missing env variable NODE_AUTH_TOKEN"
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
echo >> ./.yarnrc.yml
|
|
73
|
+
echo "npmAuthToken: $NODE_AUTH_TOKEN" >> ./.yarnrc.yml
|
|
74
|
+
yarn workspaces foreach --no-private npm publish --tolerate-republish
|
|
75
|
+
<% } else { -%>
|
|
52
76
|
- uses: actions/setup-node@v3
|
|
53
|
-
if:
|
|
54
|
-
github.ref == 'refs/heads/main'
|
|
55
|
-
&& contains(github.event.inputs.dry-run, 'y') == false
|
|
77
|
+
if: github.ref == 'refs/heads/main' && !inputs.dry-run
|
|
56
78
|
with:
|
|
57
79
|
node-version: 18
|
|
58
80
|
registry-url: "https://registry.npmjs.org"
|
|
59
81
|
|
|
60
82
|
- run: yarn lerna publish from-git --no-verify-access --yes
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
&& contains(github.event.inputs.dry-run, 'y') == false
|
|
83
|
+
<% } -%>
|
|
84
|
+
if: github.ref == 'refs/heads/main' && !inputs.dry-run
|
|
64
85
|
env:
|
|
65
86
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
66
87
|
<% } -%>
|
|
@@ -121,6 +121,12 @@ export default class PobBaseGenerator extends Generator {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
default() {
|
|
124
|
+
this.composeWith('pob:core:yarn', {
|
|
125
|
+
type: this.projectConfig.type,
|
|
126
|
+
enable: this.isRoot && this.projectConfig.packageManager === 'yarn',
|
|
127
|
+
yarnNodeLinker: this.projectConfig.yarnNodeLinker,
|
|
128
|
+
});
|
|
129
|
+
|
|
124
130
|
this.composeWith('pob:core:package', {
|
|
125
131
|
updateOnly: this.options.updateOnly,
|
|
126
132
|
private: this.useLerna,
|
|
@@ -150,12 +156,6 @@ export default class PobBaseGenerator extends Generator {
|
|
|
150
156
|
app: this.projectConfig.type === 'app',
|
|
151
157
|
});
|
|
152
158
|
|
|
153
|
-
this.composeWith('pob:core:yarn', {
|
|
154
|
-
type: this.projectConfig.type,
|
|
155
|
-
enable: this.isRoot && this.projectConfig.packageManager === 'yarn',
|
|
156
|
-
yarnNodeLinker: this.projectConfig.yarnNodeLinker,
|
|
157
|
-
});
|
|
158
|
-
|
|
159
159
|
const onlyLatestLTS =
|
|
160
160
|
this.projectConfig.type === 'app' ||
|
|
161
161
|
(inLerna &&
|
package/lib/utils/package.js
CHANGED
|
@@ -24,6 +24,9 @@ export const hasBabel = (pkg) =>
|
|
|
24
24
|
(pkg.devDependencies['pob-babel'] || pkg.devDependencies['@babel/core'])
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
+
export const transpileWithEsbuild = (pkg) =>
|
|
28
|
+
!!(pkg.devDependencies && pkg.devDependencies['jest-esbuild']);
|
|
29
|
+
|
|
27
30
|
export const transpileWithBabel = (pkg) =>
|
|
28
31
|
!!(
|
|
29
32
|
(pkg.devDependencies &&
|
|
@@ -35,7 +38,7 @@ export const transpileWithBabel = (pkg) =>
|
|
|
35
38
|
(pkg.dependencies &&
|
|
36
39
|
(pkg.dependencies['pob-babel'] ||
|
|
37
40
|
pkg.dependencies.next ||
|
|
38
|
-
pkg.
|
|
41
|
+
pkg.dependencies['alp-dev']))
|
|
39
42
|
);
|
|
40
43
|
|
|
41
44
|
export const hasReact = (pkg) =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pob",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.5.0",
|
|
4
4
|
"description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"skeleton"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@pob/sort-pkg": "6.0.1",
|
|
47
47
|
"@types/inquirer": "9.0.3",
|
|
48
48
|
"@yeoman/types": "1.0.1",
|
|
49
|
-
"eslint": "8.
|
|
49
|
+
"eslint": "8.49.0",
|
|
50
50
|
"findup-sync": "^5.0.0",
|
|
51
51
|
"git-remote-url": "^1.0.1",
|
|
52
52
|
"github-username": "^7.0.0",
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"mem-fs-editor": "10.0.2",
|
|
60
60
|
"minimist": "1.2.8",
|
|
61
61
|
"parse-author": "2.0.0",
|
|
62
|
-
"pob-dependencies": "8.
|
|
62
|
+
"pob-dependencies": "8.5.0",
|
|
63
63
|
"prettier": "2.8.8",
|
|
64
|
-
"semver": "7.5.
|
|
65
|
-
"yeoman-environment": "4.0.0-beta.
|
|
66
|
-
"yeoman-generator": "6.0.0-rc.
|
|
64
|
+
"semver": "7.5.4",
|
|
65
|
+
"yeoman-environment": "4.0.0-beta.4",
|
|
66
|
+
"yeoman-generator": "6.0.0-rc.4"
|
|
67
67
|
},
|
|
68
68
|
"devDependencies": {
|
|
69
|
-
"@pob/root": "8.
|
|
69
|
+
"@pob/root": "8.2.1"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "d0f03216f6a01951143697797f10b9ae101f13fe"
|
|
72
72
|
}
|