pob 15.1.0 → 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 CHANGED
@@ -3,6 +3,38 @@
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
+ ## [15.2.0](https://github.com/christophehurpeau/pob/compare/pob@15.1.0...pob@15.2.0) (2023-12-10)
7
+
8
+
9
+ ### Features
10
+
11
+ * **deps:** update @pob/eslint-config ([#1878](https://github.com/christophehurpeau/pob/issues/1878)) ([f5c1f83](https://github.com/christophehurpeau/pob/commit/f5c1f835fcf98dc963213c7e4620ce02d325d8db))
12
+ * **deps:** update dependency eslint to v8.54.0 ([#1855](https://github.com/christophehurpeau/pob/issues/1855)) ([3baf9c6](https://github.com/christophehurpeau/pob/commit/3baf9c68b9b020f5d069021df8a501d97491250c))
13
+ * **deps:** update dependency eslint to v8.55.0 ([#1872](https://github.com/christophehurpeau/pob/issues/1872)) ([ebee64a](https://github.com/christophehurpeau/pob/commit/ebee64abd61d9e40bd7dd507cd97505861a2496a))
14
+ * **deps:** update dependency validate-npm-package-name to v5 ([#1844](https://github.com/christophehurpeau/pob/issues/1844)) ([6d66f31](https://github.com/christophehurpeau/pob/commit/6d66f317fb9ad82e6c41d190fb1c8dc35198ff3c))
15
+ * **deps:** update dependency yeoman-environment to v4.1.1 ([#1849](https://github.com/christophehurpeau/pob/issues/1849)) ([bf6b70e](https://github.com/christophehurpeau/pob/commit/bf6b70e2b8f345190c03469b5b11417a02a6acdd))
16
+ * experimental alternate ways to compile typescript without babel ([4391b03](https://github.com/christophehurpeau/pob/commit/4391b03c89d94ca00d2a54a4662d09a4b25c860d))
17
+ * make sure check-package-dependencies is up-to-date ([7493e27](https://github.com/christophehurpeau/pob/commit/7493e2709a0a1eae062e3223b3eb64d918db87af))
18
+ * support next ts plugin and latest next version ([095fcde](https://github.com/christophehurpeau/pob/commit/095fcde48d866ee146ac9550f04b8f3acea0e887))
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * add missing libc in supportedArchitectures ([514c66b](https://github.com/christophehurpeau/pob/commit/514c66bf11a36f503afb6df1a19198527328c6aa))
24
+ * **deps:** update dependency @yeoman/types to v1.1.2 ([#1847](https://github.com/christophehurpeau/pob/issues/1847)) ([7479fe6](https://github.com/christophehurpeau/pob/commit/7479fe6b0d8087dd7318c98918f63d95a4ce851d))
25
+ * **deps:** update dependency yeoman-environment to v4.1.2 ([#1850](https://github.com/christophehurpeau/pob/issues/1850)) ([02ed137](https://github.com/christophehurpeau/pob/commit/02ed13735fd697cfbbe1aee900396ec4b50d31f0))
26
+ * **deps:** update dependency yeoman-environment to v4.1.3 ([#1851](https://github.com/christophehurpeau/pob/issues/1851)) ([06f8cc2](https://github.com/christophehurpeau/pob/commit/06f8cc270be64899f55f99c3584a3b6519a99bbe))
27
+ * **deps:** update dependency yeoman-generator to v7.1.1 ([#1848](https://github.com/christophehurpeau/pob/issues/1848)) ([d176ea7](https://github.com/christophehurpeau/pob/commit/d176ea74f4ee6d885f7fd9c58664a7e2ef699932))
28
+ * **deps:** update yarn monorepo to v4.0.2 ([#1846](https://github.com/christophehurpeau/pob/issues/1846)) ([1a61fa5](https://github.com/christophehurpeau/pob/commit/1a61fa51058c3a320d3c9e603376b2e189271ddd))
29
+ * remove legacy lib inquirer-npm-name ([6aae255](https://github.com/christophehurpeau/pob/commit/6aae25583d5f88f61132144246f2031ccf001018))
30
+
31
+ Version bump for dependency: sort-eslint-config
32
+ Version bump for dependency: sort-object
33
+ Version bump for dependency: sort-pkg
34
+ Version bump for dependency: yarn-workspace-utils
35
+ Version bump for dependency: root
36
+
37
+
6
38
  ## [15.1.0](https://github.com/christophehurpeau/pob/compare/pob@15.0.3...pob@15.1.0) (2023-11-11)
7
39
 
8
40
 
@@ -148,6 +148,17 @@ export default class PobAppGenerator extends Generator {
148
148
  fromPob: this.options.fromPob,
149
149
  buildDirectory: 'build',
150
150
  });
151
+ await this.composeWith('pob:common:transpiler', {
152
+ updateOnly: this.options.updateOnly,
153
+ onlyLatestLTS: true,
154
+ isApp: true,
155
+ isAppLibrary,
156
+ useAppConfig: this.appConfig.type === 'alp-node',
157
+ testing: this.appConfig.testing,
158
+ documentation: false,
159
+ fromPob: this.options.fromPob,
160
+ buildDirectory: 'build',
161
+ });
151
162
  }
152
163
 
153
164
  const pkg = this.fs.readJSON(this.destinationPath('package.json'));
@@ -159,6 +170,7 @@ export default class PobAppGenerator extends Generator {
159
170
  const babelEnvs = (pkg.pob && pkg.pob.babelEnvs) || [];
160
171
  const babel =
161
172
  babelEnvs.length > 0 || appsWithTypescript.includes(this.appConfig.type);
173
+ const typescript = babel || pkg.pob?.typescript;
162
174
  const node = true;
163
175
  const browser = appsWithBrowser.includes(this.appConfig.type);
164
176
  const jsx =
@@ -176,7 +188,7 @@ export default class PobAppGenerator extends Generator {
176
188
  ).filter(Boolean);
177
189
 
178
190
  await this.composeWith('pob:common:typescript', {
179
- enable: babel,
191
+ enable: typescript,
180
192
  isApp: true,
181
193
  isAppLibrary,
182
194
  // nextjs now supports src
@@ -190,6 +202,7 @@ export default class PobAppGenerator extends Generator {
190
202
  forceAllowJs: this.appConfig.type === 'next.js',
191
203
  updateOnly: this.options.updateOnly,
192
204
  resolveJsonModule: true,
205
+ onlyLatestLTS: true,
193
206
  baseUrl: (() => {
194
207
  if (
195
208
  this.appConfig.type === 'alp' ||
@@ -204,6 +217,18 @@ export default class PobAppGenerator extends Generator {
204
217
  }
205
218
  return '';
206
219
  })(),
220
+ plugins: (() => {
221
+ if (this.appConfig.type === 'next.js') {
222
+ return 'next';
223
+ }
224
+ return '';
225
+ })(),
226
+ additionalIncludes: (() => {
227
+ if (this.appConfig.type === 'next.js') {
228
+ return '.next/types/**/*.ts';
229
+ }
230
+ return '';
231
+ })(),
207
232
  });
208
233
 
209
234
  await this.composeWith('pob:common:remove-old-dependencies');
@@ -217,8 +242,9 @@ export default class PobAppGenerator extends Generator {
217
242
  disableYarnGitCache: this.options.disableYarnGitCache,
218
243
  enableReleasePlease,
219
244
  testing: this.appConfig.testing,
220
- typescript: babel,
221
- build: babel && this.appConfig.type !== 'expo',
245
+ e2eTesting: this.appConfig.e2e ? '.' : '',
246
+ typescript,
247
+ build: typescript && this.appConfig.type !== 'expo',
222
248
  documentation: false,
223
249
  codecov: this.appConfig.codecov,
224
250
  ci: this.appConfig.ci,
@@ -229,11 +255,16 @@ export default class PobAppGenerator extends Generator {
229
255
  srcDirectory,
230
256
  });
231
257
 
258
+ await this.composeWith('pob:app:e2e-testing', {
259
+ enable: this.appConfig.e2e,
260
+ });
261
+
232
262
  await this.composeWith('pob:common:format-lint', {
233
263
  isApp: true,
234
264
  documentation: false,
235
265
  testing: this.appConfig.testing,
236
266
  babel,
267
+ typescript,
237
268
  node,
238
269
  browser,
239
270
  // nextjs now supports src rootAsSrc: this.appConfig.type === 'next.js',
@@ -265,7 +296,7 @@ export default class PobAppGenerator extends Generator {
265
296
  monorepo: false,
266
297
  packageManager: this.options.packageManager,
267
298
  yarnNodeLinker: this.options.yarnNodeLinker,
268
- typescript: babel,
299
+ typescript,
269
300
  testing: this.appConfig.testing,
270
301
  });
271
302
 
@@ -0,0 +1,45 @@
1
+ import Generator from 'yeoman-generator';
2
+ import * as packageUtils from '../../../utils/package.js';
3
+ // import * as templateUtils from '../../../utils/templateUtils.js';
4
+ import { writeAndFormatJson } from '../../../utils/writeAndFormat.js';
5
+
6
+ export default class AppE2ETestingGenerator extends Generator {
7
+ constructor(args, opts) {
8
+ super(args, opts);
9
+
10
+ this.option('enable', {
11
+ type: Boolean,
12
+ default: true,
13
+ desc: 'enable e2e testing',
14
+ });
15
+
16
+ this.option('ci', {
17
+ type: Boolean,
18
+ required: true,
19
+ desc: 'ci',
20
+ });
21
+ }
22
+
23
+ writing() {
24
+ const pkg = this.fs.readJSON(this.destinationPath('package.json'));
25
+
26
+ packageUtils.addOrRemoveDevDependencies(pkg, this.options.enable, [
27
+ '@playwright/test',
28
+ ]);
29
+
30
+ packageUtils.addOrRemoveScripts(pkg, this.options.enable, {
31
+ 'test:e2e': 'playwright test',
32
+ });
33
+
34
+ // templateUtils.addOrRemoveTemplate(
35
+ // this.fs,
36
+ // this.options.enable && this.options.ci,
37
+ // this.destinationPath('playwright.config.js'),
38
+ // );
39
+
40
+ if (this.options.enable) {
41
+ }
42
+
43
+ writeAndFormatJson(this.fs, this.destinationPath('package.json'), pkg);
44
+ }
45
+ }
@@ -1,4 +1,3 @@
1
- import fs from 'node:fs';
2
1
  import semver from 'semver';
3
2
  import Generator from 'yeoman-generator';
4
3
  import * as packageUtils from '../../../utils/package.js';
@@ -251,8 +250,10 @@ export default class CommonBabelGenerator extends Generator {
251
250
  delete pkg.pob.withReact;
252
251
  if (newBabelEnvs.length === 0) {
253
252
  delete pkg.pob.babelEnvs;
254
- delete pkg.pob.entries;
255
- delete pkg.pob.jsx;
253
+ if (!pkg.pob.typescript) {
254
+ delete pkg.pob.entries;
255
+ delete pkg.pob.jsx;
256
+ }
256
257
  } else {
257
258
  pkg.pob.babelEnvs = newBabelEnvs;
258
259
  pkg.pob.entries = pkg.pob.entries || ['index'];
@@ -271,10 +272,6 @@ export default class CommonBabelGenerator extends Generator {
271
272
  this.entries = pkg.pob.entries;
272
273
  this.babelEnvs = pkg.pob.babelEnvs || [];
273
274
 
274
- if (this.babelEnvs.length > 0) {
275
- fs.mkdirSync(this.destinationPath('src'), { recursive: true });
276
- }
277
-
278
275
  if (this.entries) {
279
276
  this.entries.forEach((entry) => {
280
277
  const entryDestPath = this.destinationPath(`${entry}.js`);
@@ -300,70 +297,16 @@ export default class CommonBabelGenerator extends Generator {
300
297
  }
301
298
 
302
299
  default() {
303
- const useBabel = this.babelEnvs && this.babelEnvs.length > 0;
304
300
  const pkg = this.fs.readJSON(this.destinationPath('package.json'));
305
- const hasTargetNode = this.babelEnvs.find((env) => env.target === 'node');
301
+ const useBabel = this.babelEnvs && this.babelEnvs.length > 0;
302
+ const useTypescript = useBabel || pkg.pob?.typescript;
303
+ const hasTargetNode = useBabel
304
+ ? this.babelEnvs.find((env) => env.target === 'node')
305
+ : useTypescript; // todo pkg.pob.typescriptTargets
306
306
  const hasTargetBrowser = this.babelEnvs.find(
307
307
  (env) => env.target === 'browser',
308
308
  );
309
309
 
310
- /* scripts */
311
-
312
- if (this.options.isApp) {
313
- packageUtils.removeScripts(['watch']);
314
- packageUtils.addOrRemoveScripts(pkg, useBabel, {
315
- 'clean:build': `pob-babel-clean-out ${this.options.buildDirectory}`,
316
- build: 'yarn clean:build && rollup --config rollup.config.mjs',
317
- start: 'yarn clean:build && rollup --config rollup.config.mjs --watch',
318
- clean: 'yarn clean:build',
319
- });
320
- } else {
321
- packageUtils.removeScripts(['start']);
322
- packageUtils.addScripts(pkg, {
323
- 'clean:build': useBabel
324
- ? `pob-babel-clean-out ${this.options.buildDirectory}`
325
- : 'true',
326
- });
327
- packageUtils.addOrRemoveScripts(pkg, useBabel, {
328
- build: 'yarn clean:build && rollup --config rollup.config.mjs',
329
- watch: 'yarn clean:build && rollup --config rollup.config.mjs --watch',
330
- clean: 'yarn clean:build',
331
- });
332
- }
333
-
334
- const shouldBuildDefinitions = !this.options.isApp && useBabel;
335
- packageUtils.addOrRemoveScripts(pkg, shouldBuildDefinitions, {
336
- 'build:definitions': 'tsc -p tsconfig.json',
337
- });
338
-
339
- if (shouldBuildDefinitions) {
340
- pkg.scripts.build += ' && yarn run build:definitions';
341
- } else if (!this.options.isApp && !useBabel) {
342
- // check definitions, but also force lerna to execute build:definitions in right order
343
- // example: nightingale-types depends on nightingale-levels
344
- if (this.fs.exists(this.destinationPath('lib/index.d.ts'))) {
345
- packageUtils.addScripts(pkg, {
346
- 'build:definitions':
347
- 'tsc --lib esnext --noEmit --skipLibCheck ./lib/index.d.ts',
348
- build: 'yarn run build:definitions',
349
- });
350
- }
351
-
352
- if (this.fs.exists(this.destinationPath('lib/index.ts'))) {
353
- packageUtils.addScripts(pkg, {
354
- 'build:definitions':
355
- 'tsc --lib esnext --noEmit --skipLibCheck ./lib/index.ts',
356
- build: 'yarn run build:definitions',
357
- });
358
- }
359
- }
360
-
361
- if (pkg.scripts) {
362
- delete pkg.scripts.postbuild;
363
- delete pkg.scripts['build:dev'];
364
- delete pkg.scripts['watch:dev'];
365
- }
366
-
367
310
  /* dependencies */
368
311
 
369
312
  packageUtils.addOrRemoveDevDependencies(
@@ -411,11 +354,14 @@ export default class CommonBabelGenerator extends Generator {
411
354
 
412
355
  if (hasTargetNode) {
413
356
  if (!pkg.engines) pkg.engines = {};
414
- const minNodeVersion = Math.min(
415
- ...this.babelEnvs
416
- .filter((env) => env.target === 'node')
417
- .map((env) => env.version),
418
- );
357
+ const minNodeVersion = useBabel
358
+ ? Math.min(
359
+ ...this.babelEnvs
360
+ .filter((env) => env.target === 'node')
361
+ .map((env) => env.version),
362
+ )
363
+ : // eslint-disable-next-line unicorn/no-unreadable-iife
364
+ (() => (this.options.onlyLatestLTS ? '20' : '18'))();
419
365
  switch (String(minNodeVersion)) {
420
366
  case '10':
421
367
  case '12':
@@ -492,245 +438,6 @@ export default class CommonBabelGenerator extends Generator {
492
438
  delete pkg.browserslist;
493
439
  }
494
440
 
495
- /* side effects */
496
-
497
- if (this.options.isApp && !this.options.isAppLibrary) {
498
- delete pkg.sideEffects;
499
- } else if (!('sideEffects' in pkg)) {
500
- pkg.sideEffects = true;
501
- console.warn('Setting pkg.sideEffects to true, as it was not defined');
502
- } else if (pkg.sideEffects) {
503
- console.warn(
504
- "pkg.sideEffects is true, are you sure you can't set it to false ?",
505
- );
506
- }
507
-
508
- /* main / aliases / typing */
509
-
510
- if (this.options.isApp) {
511
- delete pkg.types;
512
- delete pkg.typings;
513
- } else if (pkg.typings) {
514
- if (!pkg.types) pkg.types = pkg.typings;
515
- delete pkg.typings;
516
- }
517
-
518
- // if (!pkg.main || pkg.main.startsWith('./lib/')) {
519
- if (useBabel) {
520
- // see pkg.exports instead.
521
- delete pkg.main;
522
- if (!this.options.isApp) {
523
- pkg.types = `./${this.options.buildDirectory}/definitions/index.d.ts`;
524
- }
525
- } else {
526
- if (!pkg.main) {
527
- pkg.exports = './lib/index.js';
528
- }
529
- if (pkg.type === 'module' && this.fs.exists('./lib/index.cjs')) {
530
- pkg.main = './lib/index.cjs';
531
- } else {
532
- pkg.main = './lib/index.js';
533
- }
534
- if (!this.options.isApp) {
535
- if (this.fs.exists('./lib/index.ts')) {
536
- pkg.types = './lib/index.ts';
537
- } else if (this.fs.exists('./lib/index.d.ts') || pkg.types) {
538
- pkg.types = './lib/index.d.ts';
539
- }
540
- }
541
- if (!pkg.engines) pkg.engines = {};
542
- if (
543
- !pkg.engines.node ||
544
- semver.lt(
545
- semver.minVersion(pkg.engines.node),
546
- // pkg.type === 'commonjs' ? '12.10.0' : '12.20.0',
547
- '14.13.1',
548
- )
549
- ) {
550
- pkg.engines.node = '>=16.0.0';
551
- }
552
- }
553
-
554
- delete pkg['browser-dev'];
555
- delete pkg['module-dev'];
556
-
557
- const esAllBrowserEnv = this.babelEnvs.find(
558
- (env) =>
559
- env.target === 'browser' &&
560
- env.version === undefined &&
561
- (!env.formats || env.formats.includes('es')),
562
- );
563
-
564
- // Legacy "dev" builds
565
- delete pkg['module:browser'];
566
- delete pkg['module:browser-dev'];
567
- delete pkg['module:modern-browsers'];
568
- delete pkg['module:modern-browsers-dev'];
569
- delete pkg['module:node'];
570
- delete pkg['module:node-dev'];
571
-
572
- /* webpack 4 */
573
- if (esAllBrowserEnv) {
574
- pkg.module = `./${this.options.buildDirectory}/index-browser.es.js`;
575
- pkg.browser = `./${this.options.buildDirectory}/index-browser.es.js`;
576
- } else {
577
- delete pkg.module;
578
- delete pkg.browser;
579
- }
580
-
581
- /* webpack 5 and node with ESM support */
582
- if (useBabel) {
583
- pkg.exports = {
584
- './package.json': './package.json',
585
- };
586
-
587
- this.entries.forEach((entry) => {
588
- const isBrowserOnly =
589
- entry === 'browser' &&
590
- (this.babelEnvs.every((env) => env.target === 'browser') ||
591
- (this.entries.length === 2 && this.entries.includes('index')));
592
- const entryDistName = isBrowserOnly ? 'index' : entry;
593
- const exportName = entry === 'index' ? '.' : `./${entry}`;
594
-
595
- const targets = {
596
- types:
597
- pkg.private || this.options.isAppLibrary
598
- ? `./src/${entryDistName}.ts`
599
- : `./${this.options.buildDirectory}/definitions/${entryDistName}.d.ts`,
600
- };
601
-
602
- const defaultNodeEnv = this.babelEnvs.find(
603
- (env) => env.target === 'node',
604
- );
605
- const defaultNodeEnvVersion = defaultNodeEnv && defaultNodeEnv.version;
606
-
607
- this.babelEnvs.forEach(({ target, version, formats }) => {
608
- if (target === 'node' && entry === 'browser') return;
609
-
610
- const exportTarget = {};
611
-
612
- if (target === 'node') {
613
- const cjsExt = pkg.type === 'module' ? 'cjs' : 'cjs.js';
614
- if (!formats || formats.includes('es')) {
615
- exportTarget.import = `./${this.options.buildDirectory}/${entryDistName}-${target}${version}.mjs`;
616
-
617
- if (formats && formats.includes('cjs')) {
618
- exportTarget.require = `./${this.options.buildDirectory}/${entryDistName}-${target}${version}.${cjsExt}`;
619
- }
620
- } else if (formats && formats.includes('cjs')) {
621
- exportTarget.default = `./${this.options.buildDirectory}/${entryDistName}-${target}${version}.${cjsExt}`;
622
- }
623
- // eslint: https://github.com/benmosher/eslint-plugin-import/issues/2132
624
- // jest: https://github.com/facebook/jest/issues/9771
625
- if (!pkg.main && exportName === '.') {
626
- pkg.main =
627
- pkg.type === 'module'
628
- ? exportTarget.import
629
- : exportTarget.default ||
630
- exportTarget.require ||
631
- exportTarget.import;
632
- }
633
- } else if (target === 'browser') {
634
- if (!formats || formats.includes('es')) {
635
- exportTarget.import = `./${
636
- this.options.buildDirectory
637
- }/${entryDistName}-${target}${version || ''}.es.js`;
638
- }
639
-
640
- if (formats && formats.includes('cjs')) {
641
- exportTarget.require = `./${
642
- this.options.buildDirectory
643
- }/index-${target}${version || ''}.cjs.js`;
644
- }
645
- }
646
-
647
- if (
648
- !version ||
649
- (target === 'node' && version === defaultNodeEnvVersion)
650
- ) {
651
- targets[target] = {
652
- ...targets[target],
653
- ...exportTarget,
654
- };
655
- } else {
656
- targets[target] = {
657
- [`${target}:${version}`]: exportTarget,
658
- ...targets[target],
659
- };
660
- }
661
- });
662
-
663
- pkg.exports[exportName] = targets;
664
- });
665
-
666
- if (pkg.pob.extraEntries) {
667
- pkg.pob.extraEntries.forEach((extraEntryConfig) => {
668
- if (typeof extraEntryConfig === 'string') {
669
- extraEntryConfig = {
670
- name: extraEntryConfig,
671
- };
672
- }
673
-
674
- const calcExport = () => {
675
- if (pkg.type === 'module') {
676
- return extraEntryConfig.name.endsWith('.cjs') ||
677
- extraEntryConfig.name.endsWith('.d.ts')
678
- ? `./${extraEntryConfig.name}`
679
- : `./${extraEntryConfig.name}.js`;
680
- }
681
-
682
- return {
683
- import: `./${extraEntryConfig.name}.mjs`,
684
- require: `./${extraEntryConfig.name}.js`,
685
- };
686
- };
687
-
688
- let exportValue = calcExport();
689
-
690
- if (extraEntryConfig.types) {
691
- if (typeof exportValue === 'string') {
692
- exportValue = {
693
- types: `./${extraEntryConfig.types}`,
694
- default: exportValue,
695
- };
696
- } else {
697
- exportValue = {
698
- types: `./${extraEntryConfig.types}`,
699
- ...exportValue,
700
- };
701
- }
702
- }
703
-
704
- pkg.exports[`./${extraEntryConfig.name}`] = exportValue;
705
- });
706
- }
707
- } else if (!pkg.exports) {
708
- console.error('Please setup your package.exports manually.');
709
- } else {
710
- if (typeof pkg.exports === 'string') {
711
- pkg.exports = {
712
- '.': pkg.exports,
713
- };
714
- }
715
- if (!pkg.exports['./package.json']) {
716
- pkg.exports['./package.json'] = './package.json';
717
- }
718
-
719
- if (pkg.types && !pkg.exports['.'].types) {
720
- if (typeof pkg.exports['.'] === 'string') {
721
- pkg.exports['.'] = {
722
- default: pkg.exports['.'],
723
- };
724
- }
725
- pkg.exports['.'] = { types: pkg.types, ...pkg.exports['.'] };
726
- }
727
- }
728
-
729
- Object.keys(pkg).forEach((key) => {
730
- if (!key.startsWith('module:') && !key.startsWith('webpack:')) return;
731
- delete pkg[key];
732
- });
733
-
734
441
  this.fs.writeJSON(this.destinationPath('package.json'), pkg);
735
442
  }
736
443
 
@@ -778,7 +485,7 @@ export default class CommonBabelGenerator extends Generator {
778
485
  },
779
486
  );
780
487
  }
781
- } else {
488
+ } else if (!pkg.pob.typescript && pkg.pob.rollup !== false) {
782
489
  this.fs.delete('rollup.config.mjs');
783
490
  }
784
491
 
@@ -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 hasReact = useBabel && packageUtils.hasReact(pkg);
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, useBabel, [
315
+ packageUtils.addOrRemoveDevDependencies(pkg, useTypescript, [
314
316
  '@pob/eslint-config-typescript',
315
317
  ]);
316
318
  packageUtils.addOrRemoveDevDependencies(
317
319
  pkg,
318
- useBabel && shouldHavePluginsDependencies,
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 (useBabel) {
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 = !useBabel
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 (useBabel) {
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
- useBabel ? `${this.options.srcDirectory}/` : 'lib/'
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) && useBabel) {
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: useBabel,
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 && 'yarn run build',
109
+ this.options.withBabel ||
110
+ (this.options.withTypescript && 'yarn run build'),
104
111
  'repository-check-dirty',
105
112
  ]
106
113
  .filter(Boolean)