pob 9.8.0 → 9.11.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,72 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [9.11.0](https://github.com/christophehurpeau/pob/compare/pob@9.10.0...pob@9.11.0) (2022-01-01)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **pob:** legacy pkg.main cjs ([04dc5e2](https://github.com/christophehurpeau/pob/commit/04dc5e22e77b7383660b3bc62516d884670cf25a))
12
+ * force package type module when lerna and root is module ([c8e89a8](https://github.com/christophehurpeau/pob/commit/c8e89a8d04936ea7035d86a646437ba74e54146b))
13
+ * **deps:** update dependency @yarnpkg/parsers to v2.5.0-rc.7 ([#1148](https://github.com/christophehurpeau/pob/issues/1148)) ([8da56d4](https://github.com/christophehurpeau/pob/commit/8da56d4c1576908570c16da89caebad87a50c473))
14
+ * **pob:** monorepo react testing detection ([3f95cbf](https://github.com/christophehurpeau/pob/commit/3f95cbf667f624301aab82a88080c526507fe662))
15
+ * **pob:** test babel config with react ([726b954](https://github.com/christophehurpeau/pob/commit/726b95400eeef042bb22cafd1f4cdec23e0008df))
16
+ * package main when only esm is used ([b02684f](https://github.com/christophehurpeau/pob/commit/b02684f03a7bdf5875ac4919aa69df6b4993532f))
17
+
18
+
19
+ ### Features
20
+
21
+ * **deps:** update dependency eslint to v8.6.0 ([#1152](https://github.com/christophehurpeau/pob/issues/1152)) ([004bf4f](https://github.com/christophehurpeau/pob/commit/004bf4f78e200606813498ee4f211ed06fec659f))
22
+
23
+
24
+
25
+
26
+
27
+ # [9.10.0](https://github.com/christophehurpeau/pob/compare/pob@9.9.1...pob@9.10.0) (2021-12-26)
28
+
29
+
30
+ ### Features
31
+
32
+ * **deps:** update dependency mem-fs-editor to v9.4.0 ([#992](https://github.com/christophehurpeau/pob/issues/992)) ([692888b](https://github.com/christophehurpeau/pob/commit/692888bfb3546028f6cf86c58bd8cf2efecfbf71))
33
+
34
+
35
+
36
+
37
+
38
+ ## [9.9.1](https://github.com/christophehurpeau/pob/compare/pob@9.9.0...pob@9.9.1) (2021-12-19)
39
+
40
+
41
+ ### Bug Fixes
42
+
43
+ * **pob:** add missing workspaces plugin when needed ([f3759c3](https://github.com/christophehurpeau/pob/commit/f3759c3f9bc34f30a7f72580df85b352fb67fbad))
44
+ * **pob:** exports for browser only ([0ede342](https://github.com/christophehurpeau/pob/commit/0ede342c71aefbcad6b037c3bd6ea1ac4eec2a61))
45
+ * **pob:** watch command ([e026f52](https://github.com/christophehurpeau/pob/commit/e026f5209d5bc0eb81ce766bbc8b7e5f62abe4b7))
46
+
47
+
48
+
49
+
50
+
51
+ # [9.9.0](https://github.com/christophehurpeau/pob/compare/pob@9.8.0...pob@9.9.0) (2021-12-18)
52
+
53
+
54
+ ### Bug Fixes
55
+
56
+ * update mem-fs ([8fdf8f7](https://github.com/christophehurpeau/pob/commit/8fdf8f79768ac0ca6e0326e629834657e2992c71))
57
+ * **pob:** ci testing check fix ([c8eb2cd](https://github.com/christophehurpeau/pob/commit/c8eb2cdf000766699e5590aebcc55e1c23d15700))
58
+ * coverage is a documentation ([cfde873](https://github.com/christophehurpeau/pob/commit/cfde8733ef340dd097143acb66e9acd87e69fbbe))
59
+ * defaults for readJSON5 method ([2a213b5](https://github.com/christophehurpeau/pob/commit/2a213b545be5e653b4f0a279983ea4cfeaacaa11))
60
+ * update legacy yarn2 to node-modules ([d543e5e](https://github.com/christophehurpeau/pob/commit/d543e5ede8273f16fb0416424671c2d1d7c60c73))
61
+
62
+
63
+ ### Features
64
+
65
+ * always use yarn workspaces commands ([83945e0](https://github.com/christophehurpeau/pob/commit/83945e0a2ee07c52ecd1a105e1e7b9749f91b712))
66
+ * **deps:** update dependency eslint to v8.5.0 ([#1069](https://github.com/christophehurpeau/pob/issues/1069)) ([46d8538](https://github.com/christophehurpeau/pob/commit/46d85381f97fbd55e424ca8b6f1fc0138900ff7f))
67
+
68
+
69
+
70
+
71
+
6
72
  # [9.8.0](https://github.com/christophehurpeau/pob/compare/pob@9.7.4...pob@9.8.0) (2021-12-12)
7
73
 
8
74
 
@@ -421,6 +421,17 @@ export default class CommonBabelGenerator extends Generator {
421
421
  'not safari < 10',
422
422
  'not ios_saf < 10',
423
423
  ];
424
+ } else if (this.options.isApp && pkg.browserslist) {
425
+ pkg.browserslist = {
426
+ ...pkg.browserslist,
427
+ production: [
428
+ 'defaults',
429
+ '> 0.2%',
430
+ 'not ie < 12',
431
+ 'not safari < 10',
432
+ 'not ios_saf < 10',
433
+ ],
434
+ };
424
435
  } else {
425
436
  delete pkg.browserslist;
426
437
  }
@@ -457,7 +468,11 @@ export default class CommonBabelGenerator extends Generator {
457
468
  if (!pkg.main) {
458
469
  pkg.exports = './lib/index.js';
459
470
  }
460
- pkg.main = './lib/index.js';
471
+ if (pkg.type === 'module' && this.fs.exists('./lib/index.cjs')) {
472
+ pkg.main = './lib/index.cjs';
473
+ } else {
474
+ pkg.main = './lib/index.js';
475
+ }
461
476
  if (!this.options.isApp) {
462
477
  if (this.fs.exists('./lib/index.ts')) {
463
478
  pkg.types = './lib/index.ts';
@@ -568,9 +583,10 @@ export default class CommonBabelGenerator extends Generator {
568
583
  this.entries.forEach((entry) => {
569
584
  const isBrowserOnly =
570
585
  entry === 'browser' &&
571
- this.babelEnvs.every((env) => env.target === 'browser');
586
+ (this.babelEnvs.every((env) => env.target === 'browser') ||
587
+ (this.entries.length === 2 && this.entries.includes('index')));
572
588
  const entryDistName = isBrowserOnly ? 'index' : entry;
573
- const exportName = entryDistName === 'index' ? '.' : `./${entry}`;
589
+ const exportName = entry === 'index' ? '.' : `./${entry}`;
574
590
 
575
591
  const targets = {};
576
592
 
@@ -597,7 +613,10 @@ export default class CommonBabelGenerator extends Generator {
597
613
  // eslint: https://github.com/benmosher/eslint-plugin-import/issues/2132
598
614
  // jest: https://github.com/facebook/jest/issues/9771
599
615
  if (!pkg.main && exportName === '.') {
600
- pkg.main = exportTarget.default || exportTarget.require;
616
+ pkg.main =
617
+ exportTarget.default ||
618
+ exportTarget.require ||
619
+ exportTarget.import;
601
620
  }
602
621
  } else if (target === 'browser') {
603
622
  if (formats.includes('es')) {
@@ -86,6 +86,7 @@ export default class CommonTestingGenerator extends Generator {
86
86
  const transpileWithBabel = this.options.monorepo
87
87
  ? yoConfigPobMonorepo.typescript
88
88
  : pkg.pob && pkg.pob.babelEnvs && pkg.pob.babelEnvs.length > 0;
89
+ let hasReact = transpileWithBabel && packageUtils.hasReact(pkg);
89
90
 
90
91
  if (!this.options.enable) {
91
92
  packageUtils.removeDevDependencies(pkg, ['jest', '@types/jest']);
@@ -149,7 +150,9 @@ export default class CommonTestingGenerator extends Generator {
149
150
  workspacesWithoutStar.length === 1
150
151
  ? workspacesWithoutStar[0]
151
152
  : `(${workspacesWithoutStar.join('|')})`;
152
- const hasReact = packageUtils.hasReact(pkg);
153
+ hasReact = yoConfigPobMonorepo.packageNames.some((pkgName) =>
154
+ pkgName.startsWith('react-'),
155
+ );
153
156
 
154
157
  if (!pkg.jest) pkg.jest = {};
155
158
  Object.assign(pkg.jest, {
@@ -204,7 +207,6 @@ export default class CommonTestingGenerator extends Generator {
204
207
  ].join(' ; '),
205
208
  });
206
209
 
207
- const hasReact = transpileWithBabel && packageUtils.hasReact(pkg);
208
210
  const srcDirectory = transpileWithBabel ? 'src' : 'lib';
209
211
 
210
212
  if (!pkg.jest) pkg.jest = {};
@@ -262,7 +264,6 @@ export default class CommonTestingGenerator extends Generator {
262
264
  transpileWithBabel &&
263
265
  ((this.options.monorepo && globalTesting) || !globalTesting)
264
266
  ) {
265
- const hasReact = transpileWithBabel && packageUtils.hasReact(pkg);
266
267
  // cjs for jest compat
267
268
  copyAndFormatTpl(
268
269
  this.fs,
@@ -7,6 +7,15 @@ module.exports = function babelConfig(api) {
7
7
 
8
8
  return {
9
9
  only: [<%- only %>],
10
- presets: [[require.resolve('pob-babel/preset.cjs')<% if (!jestExperimentalESM) { %>, { modules: 'commonjs' }<% } %>]],
10
+ presets: [
11
+ [require.resolve('pob-babel/preset.cjs')<% if (!jestExperimentalESM) { %>, { modules: 'commonjs' }<% } %>]
12
+ <% if (hasReact) { %>, [
13
+ '@babel/preset-react',
14
+ {
15
+ development: false,
16
+ useBuiltIns: true,
17
+ },
18
+ ]<% } %>
19
+ ],
11
20
  };
12
21
  };
@@ -69,7 +69,7 @@ export default class CoreCIGenerator extends Generator {
69
69
  this.destinationPath('.github/workflows/push.yml'),
70
70
  {
71
71
  packageManager: this.options.packageManager,
72
- testing: this.options.testing && !!pkg.scripts.test,
72
+ testing: this.options.testing && !!pkg.scripts && !!pkg.scripts.test,
73
73
  checks: !!pkg.scripts && !!pkg.scripts.checks,
74
74
  documentation: this.options.documentation,
75
75
  build: this.options.build,
@@ -139,6 +139,9 @@ export default class CorePackageGenerator extends Generator {
139
139
  );
140
140
 
141
141
  if (!pkg.type) pkg.type = props.type;
142
+ if (inLerna && !inLerna.root && inLerna.rootMonorepoPkg.type === 'module') {
143
+ pkg.type = 'module';
144
+ }
142
145
 
143
146
  pkg.description = this.options.updateOnly
144
147
  ? pkg.description
@@ -66,22 +66,32 @@ export default class CoreYarnGenerator extends Generator {
66
66
  const isPluginInstalled = (name) =>
67
67
  installedPlugins.some((plugin) => plugin.name === name);
68
68
 
69
+ const installPlugin = (nameOrUrl) => {
70
+ this.spawnCommandSync('yarn', ['plugin', 'import', nameOrUrl]);
71
+ };
72
+ const removePlugin = (name) => {
73
+ this.spawnCommandSync('yarn', ['plugin', 'remove', name]);
74
+ };
75
+
69
76
  const postinstallDevPluginName = '@yarnpkg/plugin-postinstall-dev';
77
+ const workspacesPluginName = '@yarnpkg/plugin-workspace-tools';
70
78
 
71
79
  if (!inLerna && !pkg.private) {
72
80
  if (!isPluginInstalled(postinstallDevPluginName)) {
73
- this.spawnCommandSync('yarn', [
74
- 'plugin',
75
- 'import',
81
+ installPlugin(
76
82
  'https://raw.githubusercontent.com/sachinraja/yarn-plugin-postinstall-dev/main/bundles/%40yarnpkg/plugin-postinstall-dev.js',
77
- ]);
83
+ );
78
84
  }
79
85
  } else if (isPluginInstalled(postinstallDevPluginName)) {
80
- this.spawnCommandSync('yarn', [
81
- 'plugin',
82
- 'remove',
83
- postinstallDevPluginName,
84
- ]);
86
+ removePlugin(postinstallDevPluginName);
87
+ }
88
+
89
+ if (pkg.workspaces) {
90
+ if (!isPluginInstalled(workspacesPluginName)) {
91
+ installPlugin(workspacesPluginName);
92
+ }
93
+ } else if (isPluginInstalled(workspacesPluginName)) {
94
+ removePlugin(workspacesPluginName);
85
95
  }
86
96
 
87
97
  // must be done after plugins installed
@@ -254,7 +254,9 @@ export default class PobLibGenerator extends Generator {
254
254
 
255
255
  // must be after testing
256
256
  this.composeWith('pob:common:format-lint', {
257
- documentation: !!this.pobjson.documentation,
257
+ documentation:
258
+ !!this.pobjson.documentation ||
259
+ !!(this.pobjson.testing && this.pobjson.testing.codecov),
258
260
  testing: this.pobjson.testing,
259
261
  packageManager: this.options.packageManager,
260
262
  yarnNodeLinker: this.options.yarnNodeLinker,
@@ -228,11 +228,6 @@ export default class PobMonorepoGenerator extends Generator {
228
228
  packagePaths: JSON.stringify(packagePaths),
229
229
  });
230
230
 
231
- // packageUtils.addOrRemoveScripts(pkg, this.pobLernaConfig.documentation, {
232
- // 'generate:test-coverage':
233
- // 'lerna run --parallel --ignore "*-example" generate:test-coverage',
234
- // });
235
-
236
231
  if (this.pobLernaConfig.documentation) {
237
232
  pkg.scripts.build = `${
238
233
  pkg.scripts.build ? `${pkg.scripts.build} && ` : ''
@@ -154,8 +154,6 @@ export default class MonorepoLernaGenerator extends Generator {
154
154
 
155
155
  const monorepoConfig = this.config.get('monorepo');
156
156
  const packageManager = this.npm ? 'npm' : 'yarn';
157
- const useYarnWorkspacesCommand =
158
- pkg.name === 'pob-monorepo' || pkg.name === 'nightingale-monorepo'; // this.options.packageManager === 'yarn';
159
157
 
160
158
  packageUtils.addScripts(pkg, {
161
159
  lint: `${packageManager} run lint:prettier && ${packageManager} run lint:eslint`,
@@ -174,7 +172,7 @@ export default class MonorepoLernaGenerator extends Generator {
174
172
  ? `NODE_OPTIONS=--max_old_space_size=4096 eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet . --ignore-pattern ${pkg.workspaces.join(
175
173
  ',',
176
174
  )} && yarn workspaces foreach --parallel -Av run lint:eslint`
177
- : 'lerna run --stream lint:eslint',
175
+ : 'npm run lint:eslint --workspaces',
178
176
  });
179
177
 
180
178
  this.fs.copyTpl(
@@ -193,16 +191,10 @@ export default class MonorepoLernaGenerator extends Generator {
193
191
  );
194
192
 
195
193
  packageUtils.addOrRemoveScripts(pkg, withBabel, {
196
- build: `${
197
- useYarnWorkspacesCommand
198
- ? 'yarn workspaces foreach --parallel --topological-dev -Av run'
199
- : 'lerna run --stream'
200
- } build`,
201
- watch: `${
202
- useYarnWorkspacesCommand
203
- ? 'yarn workspaces foreach --parallel --exclude "*-example" -Av run'
204
- : 'lerna run --parallel --ignore "*-example"'
205
- } watch`,
194
+ build:
195
+ 'yarn workspaces foreach --parallel --topological-dev -Av run build',
196
+ watch:
197
+ 'yarn workspaces foreach --parallel --jobs unlimited --interlaced --exclude "*-example" -Av run watch',
206
198
  });
207
199
 
208
200
  // packageUtils.addOrRemoveScripts(pkg, withTypescript, {
@@ -82,7 +82,7 @@ export default class PobBaseGenerator extends Generator {
82
82
 
83
83
  if ('yarn2' in config) {
84
84
  if (config.yarn2) {
85
- config.yarnNodeLinker = 'pnp';
85
+ config.yarnNodeLinker = 'node-modules';
86
86
  }
87
87
  delete config.yarn2;
88
88
  }
package/lib/pob.js CHANGED
@@ -1,12 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import { execSync, spawnSync } from 'child_process';
3
+ import { spawnSync } from 'child_process';
4
4
  import fs, { existsSync, writeFileSync, readFileSync } from 'fs';
5
5
  import path from 'path';
6
6
  import argv from 'minimist-argv';
7
- // import updateNotifier from 'update-notifier';
8
7
  import yeoman from 'yeoman-environment';
9
- // import pkg from '../package.json';
10
8
  import PobAppGenerator from './generators/app/PobAppGenerator.js';
11
9
  import CommonBabelGenerator from './generators/common/babel/CommonBabelGenerator.js';
12
10
  import CommonLintGenerator from './generators/common/format-lint/CommonLintGenerator.js';
@@ -39,7 +37,6 @@ import { __dirname } from './pob-dirname.cjs';
39
37
  const printUsage = () => {
40
38
  console.error('Usage: pob [monorepo] [lib|app|init]');
41
39
  console.error(' pob [monorepo] update [--force]');
42
- console.error(' pob monorepo convert-npm');
43
40
  console.error(' pob add <packageName>');
44
41
  };
45
42
 
@@ -60,8 +57,6 @@ if (argv.version) {
60
57
  process.exit(0);
61
58
  }
62
59
 
63
- // updateNotifier({ pkg }).notify();
64
-
65
60
  const env = yeoman.createEnv();
66
61
 
67
62
  env.on('error', (err) => {
@@ -250,16 +245,6 @@ if (action === 'add') {
250
245
  process.exit(0);
251
246
  }
252
247
 
253
- if (monorepo && action === 'convert-npm') {
254
- execSync('sed -i \'/"npmClient": "yarn",/d\' ./lerna.json', {
255
- stdio: 'inherit',
256
- });
257
- execSync('npm install packages/*', { stdio: 'inherit' });
258
- execSync('yarn lerna link convert', { stdio: 'inherit' });
259
- execSync('rm -Rf yarn.lock packages/*/yarn.lock', { stdio: 'inherit' });
260
- process.exit(0);
261
- }
262
-
263
248
  const updateOnly = action === 'update';
264
249
  const init = action === 'init';
265
250
  const type = updateOnly || init ? null : action;
@@ -1,7 +1,7 @@
1
1
  import JSON5 from 'json5';
2
2
 
3
3
  export function readJSON5(fs, destinationPath, defaults) {
4
- const content = fs.read(destinationPath, null);
4
+ const content = fs.read(destinationPath, { defaults: null });
5
5
  if (content === null) return defaults;
6
6
  return JSON5.parse(content);
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "9.8.0",
3
+ "version": "9.11.0",
4
4
  "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
5
5
  "keywords": [
6
6
  "skeleton"
@@ -47,8 +47,8 @@
47
47
  "@pob/sort-eslint-config": "^3.0.1",
48
48
  "@pob/sort-object": "^4.0.1",
49
49
  "@pob/sort-pkg": "^4.0.1",
50
- "@yarnpkg/parsers": "2.5.0-rc.6",
51
- "eslint": "8.4.1",
50
+ "@yarnpkg/parsers": "2.5.0-rc.7",
51
+ "eslint": "8.6.0",
52
52
  "findup-sync": "^5.0.0",
53
53
  "git-remote-url": "^1.0.1",
54
54
  "github-username": "^6.0.0",
@@ -57,16 +57,15 @@
57
57
  "json5": "^2.2.0",
58
58
  "lodash.camelcase": "^4.3.0",
59
59
  "lodash.kebabcase": "^4.1.1",
60
- "mem-fs": "1.2.0",
61
- "mem-fs-editor": "8.1.2",
60
+ "mem-fs": "2.2.1",
61
+ "mem-fs-editor": "9.4.0",
62
62
  "minimist-argv": "^1.1.0",
63
63
  "parse-author": "^2.0.0",
64
- "pob-dependencies": "6.3.3",
64
+ "pob-dependencies": "6.6.0",
65
65
  "prettier": "2.5.1",
66
66
  "semver": "^7.3.4",
67
- "update-notifier": "^5.0.1",
68
67
  "yeoman-environment": "^3.5.1",
69
68
  "yeoman-generator": "^5.4.0"
70
69
  },
71
- "gitHead": "1c94efb8acec1f95aeeea9b673c22c56497b9fcd"
70
+ "gitHead": "5d8871a5277b29282db5599a9e2a6032275da8d1"
72
71
  }