pob 15.0.3 → 15.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 +45 -0
- package/lib/generators/app/PobAppGenerator.js +50 -19
- package/lib/generators/app/e2e-testing/AppE2ETestingGenerator.js +45 -0
- package/lib/generators/common/babel/CommonBabelGenerator.js +18 -311
- package/lib/generators/common/format-lint/CommonLintGenerator.js +15 -15
- package/lib/generators/common/release/CommonReleaseGenerator.js +8 -1
- package/lib/generators/common/testing/CommonTestingGenerator.js +24 -14
- package/lib/generators/common/transpiler/CommonTranspilerGenerator.js +491 -0
- package/lib/generators/common/transpiler/templates/app.rollup.config.mjs.ejs +26 -0
- package/lib/generators/common/transpiler/templates/lib.rollup.config.mjs.ejs +8 -0
- package/lib/generators/common/typescript/CommonTypescriptGenerator.js +44 -1
- package/lib/generators/common/typescript/templates/tsconfig.json.ejs +17 -19
- package/lib/generators/core/ci/CoreCIGenerator.js +7 -0
- package/lib/generators/core/ci/templates/github-action-push-workflow-split.yml.ejs +29 -0
- package/lib/generators/core/ci/templates/github-action-push-workflow.yml.ejs +5 -0
- package/lib/generators/core/git/CoreGitGenerator.js +2 -2
- package/lib/generators/core/package/CorePackageGenerator.js +19 -10
- package/lib/generators/core/package/askName.js +59 -0
- package/lib/generators/core/yarn/CoreYarnGenerator.js +2 -1
- package/lib/generators/lib/PobLibGenerator.js +39 -35
- package/lib/generators/monorepo/PobMonorepoGenerator.js +13 -12
- package/lib/generators/pob/PobBaseGenerator.js +12 -12
- package/lib/pob.js +12 -0
- package/lib/utils/templateUtils.js +6 -0
- package/package.json +20 -21
|
@@ -116,11 +116,13 @@ export default class CommonLintGenerator extends Generator {
|
|
|
116
116
|
writing() {
|
|
117
117
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'));
|
|
118
118
|
const babelEnvs = (pkg.pob && pkg.pob.babelEnvs) || [];
|
|
119
|
+
// const typescriptTargets = (pkg.pob && pkg.pob.typescriptTargets) || [];
|
|
119
120
|
const useBabel =
|
|
120
121
|
this.options.babel !== 'undefined'
|
|
121
122
|
? this.options.babel === 'true'
|
|
122
123
|
: babelEnvs.length > 0;
|
|
123
|
-
const
|
|
124
|
+
const useTypescript = useBabel || pkg.pob?.typescript;
|
|
125
|
+
const hasReact = useTypescript && packageUtils.hasReact(pkg);
|
|
124
126
|
const useNode = !useBabel || babelEnvs.some((env) => env.target === 'node');
|
|
125
127
|
const useNodeOnly =
|
|
126
128
|
!useBabel ||
|
|
@@ -310,12 +312,12 @@ export default class CommonLintGenerator extends Generator {
|
|
|
310
312
|
['@typescript-eslint/eslint-plugin', '@typescript-eslint/parser'],
|
|
311
313
|
);
|
|
312
314
|
} else {
|
|
313
|
-
packageUtils.addOrRemoveDevDependencies(pkg,
|
|
315
|
+
packageUtils.addOrRemoveDevDependencies(pkg, useTypescript, [
|
|
314
316
|
'@pob/eslint-config-typescript',
|
|
315
317
|
]);
|
|
316
318
|
packageUtils.addOrRemoveDevDependencies(
|
|
317
319
|
pkg,
|
|
318
|
-
|
|
320
|
+
useTypescript && shouldHavePluginsDependencies,
|
|
319
321
|
['@typescript-eslint/eslint-plugin', '@typescript-eslint/parser'],
|
|
320
322
|
);
|
|
321
323
|
|
|
@@ -363,10 +365,13 @@ export default class CommonLintGenerator extends Generator {
|
|
|
363
365
|
];
|
|
364
366
|
}
|
|
365
367
|
|
|
366
|
-
if (
|
|
368
|
+
if (useTypescript) {
|
|
367
369
|
return [
|
|
368
370
|
'@pob/eslint-config-typescript',
|
|
369
371
|
useNodeOnly && '@pob/eslint-config-typescript/node',
|
|
372
|
+
// useTypescript &&
|
|
373
|
+
// pkg.pob?.rollup === false &&
|
|
374
|
+
// '@pob/eslint-config-typescript/tsc-emit',
|
|
370
375
|
this.options.isApp && '@pob/eslint-config-typescript/app',
|
|
371
376
|
hasReact &&
|
|
372
377
|
`@pob/eslint-config-typescript-react${
|
|
@@ -382,7 +387,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
382
387
|
];
|
|
383
388
|
})();
|
|
384
389
|
|
|
385
|
-
const ext = !
|
|
390
|
+
const ext = !useTypescript
|
|
386
391
|
? `{${pkg.type === 'commonjs' ? 'mjs' : 'cjs'},js}`
|
|
387
392
|
: `${hasReact ? '{ts,tsx}' : 'ts'}`;
|
|
388
393
|
|
|
@@ -405,7 +410,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
405
410
|
// testsOverride.extends = ['pob/babel'];
|
|
406
411
|
// }
|
|
407
412
|
|
|
408
|
-
if (
|
|
413
|
+
if (useTypescript) {
|
|
409
414
|
testsOverride.extends = ['@pob/eslint-config-typescript/test'];
|
|
410
415
|
}
|
|
411
416
|
}
|
|
@@ -423,19 +428,14 @@ export default class CommonLintGenerator extends Generator {
|
|
|
423
428
|
? this.destinationPath('.eslintrc.json')
|
|
424
429
|
: this.destinationPath(
|
|
425
430
|
`${
|
|
426
|
-
|
|
431
|
+
useTypescript ? `${this.options.srcDirectory}/` : 'lib/'
|
|
427
432
|
}.eslintrc.json`,
|
|
428
433
|
);
|
|
429
434
|
|
|
430
|
-
const useTypescript = useBabel;
|
|
431
435
|
const getRootIgnorePatterns = () => {
|
|
432
436
|
const ignorePatterns = new Set();
|
|
433
437
|
|
|
434
|
-
if (
|
|
435
|
-
inMonorepo &&
|
|
436
|
-
!inMonorepo.root &&
|
|
437
|
-
(this.options.typescript || pkg.types)
|
|
438
|
-
) {
|
|
438
|
+
if (inMonorepo && !inMonorepo.root && (useTypescript || pkg.types)) {
|
|
439
439
|
ignorePatterns.add('*.d.ts');
|
|
440
440
|
}
|
|
441
441
|
|
|
@@ -443,7 +443,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
443
443
|
ignorePatterns.add('/docs');
|
|
444
444
|
}
|
|
445
445
|
|
|
446
|
-
if ((!inMonorepo || !inMonorepo.root) &&
|
|
446
|
+
if ((!inMonorepo || !inMonorepo.root) && useTypescript) {
|
|
447
447
|
const buildPath = `/${this.options.buildDirectory}`;
|
|
448
448
|
if (
|
|
449
449
|
!this.options.rootIgnorePaths ||
|
|
@@ -517,7 +517,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
517
517
|
{
|
|
518
518
|
extendsConfig: extendsConfigSrc,
|
|
519
519
|
testsOverride,
|
|
520
|
-
useTypescript
|
|
520
|
+
useTypescript,
|
|
521
521
|
globalEslint,
|
|
522
522
|
ignorePatterns:
|
|
523
523
|
ignorePatterns.size === 0 ? undefined : [...ignorePatterns],
|
|
@@ -24,6 +24,12 @@ export default class CommonReleaseGenerator extends Generator {
|
|
|
24
24
|
desc: 'Babel enabled.',
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
this.option('withTypescript', {
|
|
28
|
+
type: Boolean,
|
|
29
|
+
required: false,
|
|
30
|
+
default: undefined,
|
|
31
|
+
desc: 'Typescript enabled.',
|
|
32
|
+
});
|
|
27
33
|
this.option('isMonorepo', {
|
|
28
34
|
type: Boolean,
|
|
29
35
|
default: false,
|
|
@@ -100,7 +106,8 @@ export default class CommonReleaseGenerator extends Generator {
|
|
|
100
106
|
packageUtils.addScripts(pkg, {
|
|
101
107
|
preversion: [
|
|
102
108
|
'yarn run lint',
|
|
103
|
-
this.options.withBabel
|
|
109
|
+
this.options.withBabel ||
|
|
110
|
+
(this.options.withTypescript && 'yarn run build'),
|
|
104
111
|
'repository-check-dirty',
|
|
105
112
|
]
|
|
106
113
|
.filter(Boolean)
|
|
@@ -83,6 +83,12 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
83
83
|
desc: 'is app',
|
|
84
84
|
});
|
|
85
85
|
|
|
86
|
+
this.option('e2eTesting', {
|
|
87
|
+
type: String,
|
|
88
|
+
default: '',
|
|
89
|
+
desc: 'e2e testing package path',
|
|
90
|
+
});
|
|
91
|
+
|
|
86
92
|
this.option('splitCIJobs', {
|
|
87
93
|
type: Boolean,
|
|
88
94
|
required: true,
|
|
@@ -109,14 +115,15 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
109
115
|
});
|
|
110
116
|
}
|
|
111
117
|
|
|
112
|
-
default() {
|
|
118
|
+
async default() {
|
|
113
119
|
if (!inMonorepo || inMonorepo.root) {
|
|
114
|
-
this.composeWith('pob:core:ci', {
|
|
120
|
+
await this.composeWith('pob:core:ci', {
|
|
115
121
|
enable: this.options.ci,
|
|
116
122
|
enableReleasePlease: this.options.enableReleasePlease,
|
|
117
123
|
enableYarnVersion: this.options.enableYarnVersion,
|
|
118
124
|
disableYarnGitCache: this.options.disableYarnGitCache,
|
|
119
125
|
testing: this.options.enable,
|
|
126
|
+
e2eTesting: this.options.e2eTesting,
|
|
120
127
|
build: this.options.build,
|
|
121
128
|
typescript: this.options.typescript,
|
|
122
129
|
documentation: this.options.documentation,
|
|
@@ -127,7 +134,7 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
127
134
|
onlyLatestLTS: this.options.onlyLatestLTS,
|
|
128
135
|
});
|
|
129
136
|
} else {
|
|
130
|
-
this.composeWith('pob:core:ci', {
|
|
137
|
+
await this.composeWith('pob:core:ci', {
|
|
131
138
|
enable: false,
|
|
132
139
|
});
|
|
133
140
|
}
|
|
@@ -156,8 +163,9 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
156
163
|
this.options.monorepo
|
|
157
164
|
? yoConfigPobMonorepo.typescript
|
|
158
165
|
: packageUtils.transpileWithBabel(pkg);
|
|
166
|
+
const withTypescript = transpileWithBabel || pkg.pob?.typescript;
|
|
159
167
|
let hasReact =
|
|
160
|
-
|
|
168
|
+
withTypescript &&
|
|
161
169
|
(this.options.monorepo
|
|
162
170
|
? yoConfigPobMonorepo.react ?? packageUtils.hasReact(pkg)
|
|
163
171
|
: packageUtils.hasReact(pkg));
|
|
@@ -285,6 +293,7 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
285
293
|
} else {
|
|
286
294
|
const babelEnvs = pkg.pob?.babelEnvs || [];
|
|
287
295
|
const transpileWithBabel = packageUtils.transpileWithBabel(pkg);
|
|
296
|
+
const withTypescript = babelEnvs.length > 0 || pkg.pob?.typescript;
|
|
288
297
|
|
|
289
298
|
const shouldUseExperimentalVmModules =
|
|
290
299
|
pkg.type === 'module' && !inMonorepo;
|
|
@@ -308,9 +317,10 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
308
317
|
});
|
|
309
318
|
|
|
310
319
|
if (this.options.runner === 'jest') {
|
|
311
|
-
const srcDirectory =
|
|
312
|
-
|
|
313
|
-
|
|
320
|
+
const srcDirectory =
|
|
321
|
+
transpileWithBabel || withTypescript
|
|
322
|
+
? this.options.srcDirectory
|
|
323
|
+
: 'lib';
|
|
314
324
|
|
|
315
325
|
const jestConfig = this.fs.readJSON(jestConfigPath, pkg.jest ?? {});
|
|
316
326
|
delete pkg.jest;
|
|
@@ -318,20 +328,20 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
318
328
|
cacheDirectory: './node_modules/.cache/jest',
|
|
319
329
|
testMatch: [
|
|
320
330
|
`<rootDir>/${srcDirectory}/**/__tests__/**/*.${
|
|
321
|
-
|
|
331
|
+
withTypescript ? 'ts' : '?(m)js'
|
|
322
332
|
}${hasReact ? '?(x)' : ''}`,
|
|
323
333
|
`<rootDir>/${srcDirectory}/**/*.test.${
|
|
324
|
-
|
|
334
|
+
withTypescript ? 'ts' : '?(m)js'
|
|
325
335
|
}${hasReact ? '?(x)' : ''}`,
|
|
326
336
|
],
|
|
327
337
|
collectCoverageFrom: [
|
|
328
|
-
`${srcDirectory}/**/*.${
|
|
338
|
+
`${srcDirectory}/**/*.${withTypescript ? 'ts' : '?(m)js'}${
|
|
329
339
|
hasReact ? '?(x)' : ''
|
|
330
340
|
}`,
|
|
331
341
|
],
|
|
332
342
|
moduleFileExtensions: [
|
|
333
|
-
|
|
334
|
-
|
|
343
|
+
withTypescript && 'ts',
|
|
344
|
+
withTypescript && hasReact && 'tsx',
|
|
335
345
|
'js',
|
|
336
346
|
// 'jsx',
|
|
337
347
|
'json',
|
|
@@ -369,8 +379,8 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
369
379
|
|
|
370
380
|
if (shouldUseExperimentalVmModules) {
|
|
371
381
|
jestConfig.extensionsToTreatAsEsm = [
|
|
372
|
-
|
|
373
|
-
|
|
382
|
+
withTypescript && '.ts',
|
|
383
|
+
withTypescript && hasReact && '.tsx',
|
|
374
384
|
].filter(Boolean);
|
|
375
385
|
} else {
|
|
376
386
|
delete jestConfig.extensionsToTreatAsEsm;
|