pob 11.7.0 → 11.8.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,23 @@
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
+ ## [11.8.0](https://github.com/christophehurpeau/pob/compare/pob@11.7.0...pob@11.8.0) (2023-03-19)
7
+
8
+
9
+ ### Features
10
+
11
+ * add command to help migrate to monorepo ([5274068](https://github.com/christophehurpeau/pob/commit/52740680f63a0949a622831f38268d6d10007a07))
12
+ * drop webpack 4 legacy aliases ([e714540](https://github.com/christophehurpeau/pob/commit/e7145401e52dfe3cc6eff40f2f220b4b81bce561))
13
+ * **pob:** app add "node-library" ([bef77f5](https://github.com/christophehurpeau/pob/commit/bef77f5caee0b89aee5540c82146fea962acf6ff))
14
+
15
+
16
+ ### Bug Fixes
17
+
18
+ * fix "pob add" use monorepoArg ([92d4ca5](https://github.com/christophehurpeau/pob/commit/92d4ca5faf27fc1c054fd6c28cb5b8e8256d9f87))
19
+ * fix vscode config jestCommandLine ([434d7ad](https://github.com/christophehurpeau/pob/commit/434d7adfb4e73ba3021d516a149bcd1fb287a479))
20
+
21
+
22
+
6
23
  ## [11.7.0](https://github.com/christophehurpeau/pob/compare/pob@11.6.0...pob@11.7.0) (2023-03-13)
7
24
 
8
25
 
@@ -73,6 +73,7 @@ export default class PobAppGenerator extends Generator {
73
73
  'next.js',
74
74
  'remix',
75
75
  'node',
76
+ 'node-library', // monorepo library for app. Not a real library
76
77
  'alp-node',
77
78
  'other',
78
79
  ],
@@ -112,10 +113,14 @@ export default class PobAppGenerator extends Generator {
112
113
  }
113
114
 
114
115
  default() {
115
- if (this.appConfig.type === 'node' || this.appConfig.type === 'alp-node') {
116
+ if (
117
+ this.appConfig.type === 'node' ||
118
+ this.appConfig.type === 'node-library' ||
119
+ this.appConfig.type === 'alp-node'
120
+ ) {
116
121
  this.composeWith('pob:common:babel', {
117
122
  updateOnly: this.options.updateOnly,
118
- isApp: true,
123
+ isApp: this.appConfig.type !== 'node-library',
119
124
  useAppConfig: this.appConfig.type === 'alp-node',
120
125
  testing: this.appConfig.testing,
121
126
  documentation: false,
@@ -10,6 +10,7 @@ export const appIgnorePaths = {
10
10
  remix: (config) => ['# remix paths', '/.cache', '/build', '/public/build'],
11
11
  pobpack: (config) => ['/build', '/public'],
12
12
  node: (config) => ['/build'],
13
+ 'node-library': (config) => ['/build'],
13
14
  'alp-node': (config) => ['/build'],
14
15
  other: (config) => [],
15
16
  };
@@ -162,11 +162,11 @@ export default class CommonBabelGenerator extends Generator {
162
162
  default: browserVersions,
163
163
  choices: [
164
164
  {
165
- name: 'Modern (babel-preset-modern-browsers)',
165
+ name: 'Modern',
166
166
  value: 'modern',
167
167
  },
168
168
  {
169
- name: 'Supported (@babel/preset-env)',
169
+ name: 'Supported',
170
170
  value: 'supported',
171
171
  },
172
172
  ],
@@ -361,6 +361,7 @@ export default class CommonBabelGenerator extends Generator {
361
361
  'babel-preset-env', // now @babel/preset-env
362
362
  'babel-preset-jsdoc',
363
363
  'babel-plugin-add-jsdoc-annotations',
364
+ 'babel-preset-modern-browsers',
364
365
  ]);
365
366
 
366
367
  packageUtils.addOrRemoveDevDependencies(
@@ -371,14 +372,6 @@ export default class CommonBabelGenerator extends Generator {
371
372
  ['@babel/preset-env'],
372
373
  );
373
374
 
374
- packageUtils.addOrRemoveDevDependencies(
375
- pkg,
376
- this.babelEnvs.find(
377
- (env) => env.target === 'browser' && env.version === 'modern',
378
- ),
379
- ['babel-preset-modern-browsers'],
380
- );
381
-
382
375
  /* engines */
383
376
 
384
377
  if (hasTargetNode) {
@@ -424,13 +417,17 @@ export default class CommonBabelGenerator extends Generator {
424
417
  /* browserslist */
425
418
 
426
419
  if (hasTargetBrowser) {
427
- pkg.browserslist = [
428
- 'defaults',
429
- '> 0.2%',
430
- 'not ie < 12',
431
- 'not safari < 10',
432
- 'not ios_saf < 10',
433
- ];
420
+ pkg.browserslist = {
421
+ ...(Array.isArray(pkg.browserslist) ? {} : pkg.browserslist),
422
+ production: [
423
+ 'defaults',
424
+ '> 0.2%',
425
+ 'not ie < 12',
426
+ 'not safari < 10',
427
+ 'not ios_saf < 10',
428
+ ],
429
+ modern: ['defaults and >1% and supports es6-module'],
430
+ };
434
431
  } else if (this.options.isApp && pkg.browserslist) {
435
432
  pkg.browserslist = {
436
433
  ...pkg.browserslist,
@@ -515,21 +512,10 @@ export default class CommonBabelGenerator extends Generator {
515
512
  (!env.formats || env.formats.includes('es')),
516
513
  );
517
514
 
518
- const esModernBrowserEnv = this.babelEnvs.find(
519
- (env) =>
520
- env.target === 'browser' &&
521
- env.version === 'modern' &&
522
- (!env.formats || env.formats.includes('es')),
523
- );
524
-
525
- const esNodeEnv = this.babelEnvs.find(
526
- (env) =>
527
- env.target === 'node' && (!env.formats || env.formats.includes('es')),
528
- );
529
-
530
515
  // Legacy "dev" builds
531
516
  delete pkg['module:browser'];
532
517
  delete pkg['module:browser-dev'];
518
+ delete pkg['module:modern-browsers'];
533
519
  delete pkg['module:modern-browsers-dev'];
534
520
  delete pkg['module:node'];
535
521
  delete pkg['module:node-dev'];
@@ -543,44 +529,6 @@ export default class CommonBabelGenerator extends Generator {
543
529
  delete pkg.browser;
544
530
  }
545
531
 
546
- if (esModernBrowserEnv) {
547
- pkg[
548
- 'module:modern-browsers'
549
- ] = `./${this.options.buildDirectory}/index-browsermodern.es.js`;
550
- } else {
551
- delete pkg['module:modern-browsers'];
552
- }
553
-
554
- const aliases = (this.entries || []).filter((entry) => entry !== 'index');
555
-
556
- if (useBabel && aliases.length > 0 && (esNodeEnv || esAllBrowserEnv)) {
557
- [esNodeEnv, esAllBrowserEnv, esModernBrowserEnv]
558
- .filter(Boolean)
559
- .forEach((env) => {
560
- const key = (() => {
561
- if (env.target === 'node') return 'node';
562
- if (env.version === 'modern') return 'modern-browsers';
563
- return 'browser';
564
- })();
565
-
566
- const envAliases =
567
- this.entries.includes('index') && env.target === 'node'
568
- ? aliases.filter((alias) => alias !== 'browser')
569
- : aliases;
570
- if (envAliases.length === 0) return;
571
- pkg[`module:aliases-${key}`] = {};
572
-
573
- envAliases.forEach((aliasName) => {
574
- const isBrowserOnly =
575
- aliasName === 'browser' && env.target !== 'node';
576
- const aliasDistName = isBrowserOnly ? 'index' : aliasName;
577
- pkg[`module:aliases-${key}`][`./${aliasName}.js`] = `./${
578
- this.options.buildDirectory
579
- }/${aliasDistName}-${env.target}${env.version || ''}.es.js`;
580
- });
581
- });
582
- }
583
-
584
532
  /* webpack 5 and node with ESM support */
585
533
  if (useBabel) {
586
534
  pkg.exports = {
@@ -690,23 +638,6 @@ export default class CommonBabelGenerator extends Generator {
690
638
 
691
639
  Object.keys(pkg).forEach((key) => {
692
640
  if (!key.startsWith('module:') && !key.startsWith('webpack:')) return;
693
-
694
- // legacy
695
- if (key.endsWith('-dev')) {
696
- delete pkg[key];
697
- return;
698
- }
699
-
700
- if (key.startsWith('module:aliases') && aliases.length > 0) {
701
- if (key.startsWith('module:aliases-node') && esNodeEnv) return;
702
- if (key.startsWith('module:aliases-browser') && esAllBrowserEnv) return;
703
- if (
704
- key.startsWith('module:aliases-modern-browsers') &&
705
- esModernBrowserEnv
706
- ) {
707
- return;
708
- }
709
- }
710
641
  delete pkg[key];
711
642
  });
712
643
 
@@ -739,12 +670,17 @@ export default class CommonBabelGenerator extends Generator {
739
670
  this.destinationPath('rollup.config.mjs'),
740
671
  {
741
672
  config: this.options.useAppConfig,
673
+ outDirectory: this.options.buildDirectory,
742
674
  },
743
675
  );
744
676
  } else {
745
- this.fs.copy(
746
- this.templatePath('lib.rollup.config.mjs.txt'),
677
+ copyAndFormatTpl(
678
+ this.fs,
679
+ this.templatePath('lib.rollup.config.mjs.ejs'),
747
680
  this.destinationPath('rollup.config.mjs'),
681
+ {
682
+ outDirectory: this.options.buildDirectory,
683
+ },
748
684
  );
749
685
  }
750
686
  } else {
@@ -10,7 +10,7 @@ const watch = process.env.ROLLUP_WATCH === 'true';
10
10
 
11
11
  export default createRollupConfig({
12
12
  cwd: dirname(fileURLToPath(import.meta.url)),
13
- outDirectory: 'build',
13
+ outDirectory: '<%= outDirectory %>',
14
14
  plugins: [
15
15
  <% if (config) { -%>
16
16
  config({
@@ -4,4 +4,5 @@ import createRollupConfig from 'pob-babel/createRollupConfig.js';
4
4
 
5
5
  export default createRollupConfig({
6
6
  cwd: dirname(fileURLToPath(import.meta.url)),
7
+ outDirectory: '<%= outDirectory %>',
7
8
  });
@@ -207,7 +207,8 @@ export default class CommonLintGenerator extends Generator {
207
207
 
208
208
  const yoConfigPobMonorepo = inLerna && inLerna.pobMonorepoConfig;
209
209
  const globalEslint =
210
- yoConfigPobMonorepo && yoConfigPobMonorepo.eslint !== false;
210
+ this.options.monorepo ||
211
+ (yoConfigPobMonorepo && yoConfigPobMonorepo.eslint !== false);
211
212
  const globalTesting = yoConfigPobMonorepo && yoConfigPobMonorepo.testing;
212
213
  const composite = yoConfigPobMonorepo && yoConfigPobMonorepo.typescript;
213
214
  const { rootPackageManager, rootYarnNodeLinker } = inLerna || {};
@@ -148,6 +148,8 @@ export default class CoreVSCodeGenerator extends Generator {
148
148
  : {}),
149
149
  ...(this.options.testing
150
150
  ? {
151
+ 'jest.jestCommandLine':
152
+ 'NODE_OPTIONS=--experimental-vm-modules node_modules/.bin/jest',
151
153
  // disable all folders to enable only root.
152
154
  'jest.disabledWorkspaceFolders': folders.map(
153
155
  (folder) => folder.name,
@@ -34,6 +34,12 @@
34
34
  "source.organizeImports": false
35
35
  },
36
36
 
37
+
38
+ <% if (testing && module) { -%>
39
+ // jest
40
+ "jest.jestCommandLine": "NODE_OPTIONS=--experimental-vm-modules node_modules/.bin/jest",
41
+ <% } -%>
42
+
37
43
  // eslint config
38
44
  "eslint.workingDirectories": ["."],
39
45
  "eslint.options": {
@@ -164,7 +164,7 @@ export default class PobBaseGenerator extends Generator {
164
164
 
165
165
  if (!this.inLerna) {
166
166
  const splitCIJobs =
167
- inLerna && inLerna.pobMonorepoConfig.packageNames.length > 8;
167
+ inLerna && inLerna.pobMonorepoConfig?.packageNames.length > 8;
168
168
  this.composeWith('pob:core:git', {
169
169
  onlyLatestLTS,
170
170
  splitCIJobs,
package/lib/pob.js CHANGED
@@ -1,7 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { spawnSync } from 'child_process';
4
- import fs, { existsSync, writeFileSync, readFileSync } from 'fs';
3
+ import { execSync, spawnSync } from 'child_process';
4
+ import fs, {
5
+ existsSync,
6
+ writeFileSync,
7
+ readFileSync,
8
+ mkdirSync,
9
+ readdirSync,
10
+ } from 'fs';
5
11
  import path from 'path';
6
12
  import minimist from 'minimist';
7
13
  import yeoman from 'yeoman-environment';
@@ -224,7 +230,7 @@ if (action === 'add') {
224
230
  );
225
231
  }
226
232
 
227
- const packageName = monorepo ? argv._[2] : argv._[1];
233
+ const packageName = monorepoArg ? argv._[2] : argv._[1];
228
234
 
229
235
  if (!packageName) {
230
236
  console.error('Missing argument: packageName');
@@ -254,6 +260,48 @@ if (action === 'add') {
254
260
  process.exit(0);
255
261
  }
256
262
 
263
+ if (action === 'migrate-to-monorepo') {
264
+ if (projectPkg.workspaces) {
265
+ throw new Error('workspaces field already exists in package.json');
266
+ }
267
+
268
+ mkdirSync('packages');
269
+ mkdirSync(`packages/${projectPkg.name}`);
270
+
271
+ readdirSync('.').forEach((filename) => {
272
+ if (
273
+ ![
274
+ '.git',
275
+ '.vscode',
276
+ '.github',
277
+ '.husky',
278
+ '.yarn',
279
+ '.yarnrc.yml',
280
+ 'packages',
281
+ 'lint-staged.config.js',
282
+ 'yarn.lock',
283
+ ].includes(filename)
284
+ ) {
285
+ execSync(`mv "${filename}" "packages/${projectPkg.name}/"`);
286
+ }
287
+ });
288
+
289
+ const monorepoName = `${path.basename(process.cwd())}-monorepo`;
290
+ const monorepoPkg = {
291
+ name: monorepoName,
292
+ version: projectPkg.version,
293
+ author: projectPkg.author,
294
+ license: projectPkg.license,
295
+ repository: projectPkg.repository,
296
+ engines: projectPkg.engines,
297
+ packageManager: projectPkg.packageManager,
298
+ };
299
+
300
+ writeFileSync('package.json', JSON.stringify(monorepoPkg, null, 2));
301
+
302
+ monorepo = true;
303
+ }
304
+
257
305
  const updateOnly = action === 'update';
258
306
  const init = action === 'init';
259
307
  const type = updateOnly || init ? null : action;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "11.7.0",
3
+ "version": "11.8.0",
4
4
  "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
5
5
  "keywords": [
6
6
  "skeleton"
@@ -43,7 +43,7 @@
43
43
  "@pob/eslint-config-typescript-react": "50.0.0",
44
44
  "@pob/sort-eslint-config": "4.1.1",
45
45
  "@pob/sort-object": "5.1.1",
46
- "@pob/sort-pkg": "5.1.1",
46
+ "@pob/sort-pkg": "5.2.0",
47
47
  "eslint": "8.36.0",
48
48
  "findup-sync": "^5.0.0",
49
49
  "git-remote-url": "^1.0.1",
@@ -58,14 +58,14 @@
58
58
  "minimist": "1.2.8",
59
59
  "node-fetch": "3.3.1",
60
60
  "parse-author": "2.0.0",
61
- "pob-dependencies": "7.5.0",
61
+ "pob-dependencies": "7.6.0",
62
62
  "prettier": "2.8.4",
63
63
  "semver": "7.3.8",
64
64
  "yeoman-environment": "3.15.1",
65
65
  "yeoman-generator": "5.8.0"
66
66
  },
67
67
  "devDependencies": {
68
- "@pob/root": "7.5.0"
68
+ "@pob/root": "7.6.0"
69
69
  },
70
- "gitHead": "760271a7f86157af842aba3d3383c97605532097"
70
+ "gitHead": "e5930068baa1efff95c4918b66a1c8c9da3a35a8"
71
71
  }