pob 9.5.0 → 9.7.1

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +75 -0
  2. package/lib/.eslintrc.json +17 -1
  3. package/lib/generators/common/babel/CommonBabelGenerator.js +2 -17
  4. package/lib/generators/common/babel/templates/app.rollup.config.mjs.ejs +1 -1
  5. package/lib/generators/common/format-lint/CommonLintGenerator.js +22 -20
  6. package/lib/generators/common/testing/CommonTestingGenerator.js +56 -5
  7. package/lib/generators/common/testing/templates/babel.config.cjs.ejs +12 -0
  8. package/lib/generators/common/typescript/CommonTypescriptGenerator.js +1 -0
  9. package/lib/generators/common/typescript/templates/tsconfig.build.json.ejs +3 -0
  10. package/lib/generators/core/package/CorePackageGenerator.js +48 -2
  11. package/lib/generators/core/package/templates/check-package.js.ejs +3 -0
  12. package/lib/generators/core/package/templates/check-packages.js.ejs +5 -0
  13. package/lib/generators/core/package/templates/licenses/ISC.ejs +15 -0
  14. package/lib/generators/core/package/templates/licenses/MIT.ejs +21 -0
  15. package/lib/generators/core/package/templates/licenses/UNLICENSED.ejs +2 -0
  16. package/lib/generators/core/renovate/CoreRenovateGenerator.js +19 -4
  17. package/lib/generators/core/vscode/CoreVSCodeGenerator.js +8 -0
  18. package/lib/generators/core/vscode/templates/settings.json.ejs +1 -1
  19. package/lib/generators/core/vscode/templates/tasks.json.ejs +1 -2
  20. package/lib/generators/lib/PobLibGenerator.js +0 -7
  21. package/lib/generators/lib/release/LibReleaseGenerator.js +4 -1
  22. package/lib/generators/monorepo/PobMonorepoGenerator.js +13 -25
  23. package/lib/generators/monorepo/lerna/templates/workflow-publish.yml.ejs +2 -2
  24. package/lib/generators/pob/PobBaseGenerator.js +2 -21
  25. package/lib/pob.js +7 -9
  26. package/lib/utils/dependenciesPackages.cjs +7 -0
  27. package/lib/utils/json5.js +7 -0
  28. package/lib/utils/package.js +31 -3
  29. package/package.json +12 -14
  30. package/lib/generators/common/babel/templates/babel.config.cjs.ejs +0 -14
  31. package/lib/generators/core/renovate/templates/renovate.app.json +0 -3
  32. package/lib/generators/core/renovate/templates/renovate.lib.json +0 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,81 @@
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.7.1](https://github.com/christophehurpeau/pob/compare/pob@9.7.0...pob@9.7.1) (2021-12-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **pob:** add @ornikar/eslint-configs in dependencies ([0163505](https://github.com/christophehurpeau/pob/commit/0163505eecd7ca39c07dfe6a969184806e3d2630))
12
+
13
+
14
+
15
+
16
+
17
+ # [9.7.0](https://github.com/christophehurpeau/pob/compare/pob@9.6.1...pob@9.7.0) (2021-12-12)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * remove dependency generator-license ([f087175](https://github.com/christophehurpeau/pob/commit/f0871751cbd883b4a7e64f56853da73d1c2daef0))
23
+ * remove resolutions in pob ([04940d3](https://github.com/christophehurpeau/pob/commit/04940d36da39cc3771b241ff695b2ad54f28c5d3))
24
+ * update generator-license ([ef71b4d](https://github.com/christophehurpeau/pob/commit/ef71b4d2e0cb47736436945e4865df4e8eccd890))
25
+ * use lerna version with exact param ([9dd6a5c](https://github.com/christophehurpeau/pob/commit/9dd6a5c8d965cd4af40db3d93e022e6824baf97a))
26
+
27
+
28
+ ### Features
29
+
30
+ * support workspace:* in dependencies ([258a5e8](https://github.com/christophehurpeau/pob/commit/258a5e88ad890f0e2f429d63f8011e8d01c3ebe3))
31
+ * update @yarnpkg/parsers ([f778458](https://github.com/christophehurpeau/pob/commit/f778458f8e49f610f52e1111846d9465f54576a6))
32
+
33
+
34
+
35
+
36
+
37
+ ## [9.6.1](https://github.com/christophehurpeau/pob/compare/pob@9.6.0...pob@9.6.1) (2021-12-12)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * vscode settings for eslint 8 ([841b0ff](https://github.com/christophehurpeau/pob/commit/841b0ff3cf18b1aed9a070445508128806572680))
43
+
44
+
45
+
46
+
47
+
48
+ # [9.6.0](https://github.com/christophehurpeau/pob/compare/pob@9.5.0...pob@9.6.0) (2021-12-12)
49
+
50
+
51
+ ### Bug Fixes
52
+
53
+ * **pob:** move babel config generator to testing generator and configure for monorepo ([1d2a4e6](https://github.com/christophehurpeau/pob/commit/1d2a4e6f97adae84b8e4e045e36aa10c47913e5f))
54
+ * package locations in mongorepo generator ([63e7f62](https://github.com/christophehurpeau/pob/commit/63e7f62e934e6703066ac16ddb4fff7975811295))
55
+ * **pob:** dont remove preversion script for pob-dependencies ([f62355d](https://github.com/christophehurpeau/pob/commit/f62355d35ab186a9c680fee4836e4aaa5293d77b))
56
+ * **pob:** only add test-setup in ignored build tsconfig when package is not in a monorepo ([dba09fd](https://github.com/christophehurpeau/pob/commit/dba09fdec9a15617274ffe7acdb39c627ba84ab6))
57
+ * add missing clean script in apps ([a871c2c](https://github.com/christophehurpeau/pob/commit/a871c2c74386d9af0febf62ae09962ba092f6a29))
58
+ * add src/test-setup.ts in build exclude ([118efc9](https://github.com/christophehurpeau/pob/commit/118efc90130d07c1689db1f58ccab7762eefe0dd))
59
+ * allow extendable renovate config ([5d9a053](https://github.com/christophehurpeau/pob/commit/5d9a053f0485fa66586fb237b7770f450799c045))
60
+ * allow to extends renovate config ([e61b0b7](https://github.com/christophehurpeau/pob/commit/e61b0b792f63e9e938a9172a102089ff9eb3aa2f))
61
+ * doesJsCheckPackagesExists should be let ([6aac69f](https://github.com/christophehurpeau/pob/commit/6aac69f1a2eb6df4e98d4289da2e4b245a278e94))
62
+ * dont create and delete check-package script in workspace packages ([3398ef5](https://github.com/christophehurpeau/pob/commit/3398ef56a97933149eaea02cea58949cadfc61b2))
63
+ * dont delete plugin dependencies in eslint-config-pob ([31fe081](https://github.com/christophehurpeau/pob/commit/31fe08106647624317f277d2e31f820911445532))
64
+ * get eslint dependency versions from @pob/eslint-config ([4100cc5](https://github.com/christophehurpeau/pob/commit/4100cc5a342b1cc970f614de99692600f9ec89f9))
65
+ * order pob-babel/plugin-run.cjs ([57d6c8b](https://github.com/christophehurpeau/pob/commit/57d6c8bfbcfd756a23f96b436614db8991cf1ed2))
66
+ * read vscode tasks file ([436c480](https://github.com/christophehurpeau/pob/commit/436c480d4538b68893b3521573ab50199d63a23e))
67
+ * **pob:** esm condition for babel.config.cjs ([6aeb96f](https://github.com/christophehurpeau/pob/commit/6aeb96fd7648484755c595310008b0dff20fa6a4))
68
+ * **pob:** global testing config ([fc56a6d](https://github.com/christophehurpeau/pob/commit/fc56a6d28413a8ae2c7a45235f853b5123005c84))
69
+
70
+
71
+ ### Features
72
+
73
+ * configure pob-lcov-reporter for pob monorepo ([e7f40c4](https://github.com/christophehurpeau/pob/commit/e7f40c4dc9a2400e48a1497ac4ea0bdc5f842a15))
74
+ * **pob:** add default check-package-dependencies script if it doesnt exists and package type is module ([7e54041](https://github.com/christophehurpeau/pob/commit/7e540417e34d908f06f6263d668f9cbb4d9c7990))
75
+ * update eslint 8 and eslint-config-pob ([f881f05](https://github.com/christophehurpeau/pob/commit/f881f05852e00c22a35178979e1425445413ce70))
76
+
77
+
78
+
79
+
80
+
6
81
  # [9.5.0](https://github.com/christophehurpeau/pob/compare/pob@9.4.0...pob@9.5.0) (2021-12-11)
7
82
 
8
83
 
@@ -7,5 +7,21 @@
7
7
  "no-nested-ternary": "off",
8
8
  "no-console": "off",
9
9
  "complexity": "off"
10
- }
10
+ },
11
+ "overrides": [
12
+ {
13
+ "files": ["**/*.test.{cjs,js}", "__tests__/**/*.{cjs,js}"],
14
+ "env": {
15
+ "jest": true
16
+ },
17
+ "rules": {
18
+ "import/no-extraneous-dependencies": [
19
+ "error",
20
+ {
21
+ "devDependencies": true
22
+ }
23
+ ]
24
+ }
25
+ }
26
+ ]
11
27
  }
@@ -1,7 +1,6 @@
1
1
  import fs from 'fs';
2
2
  import semver from 'semver';
3
3
  import Generator from 'yeoman-generator';
4
- import inLerna from '../../../utils/inLerna.js';
5
4
  import * as packageUtils from '../../../utils/package.js';
6
5
 
7
6
  export default class CommonBabelGenerator extends Generator {
@@ -278,12 +277,14 @@ export default class CommonBabelGenerator extends Generator {
278
277
  packageUtils.addOrRemoveScripts(pkg, useBabel, {
279
278
  build: 'pob-build',
280
279
  start: 'pob-watch',
280
+ clean: 'rm -Rf dist',
281
281
  });
282
282
  } else {
283
283
  packageUtils.removeScripts(['start']);
284
284
  packageUtils.addOrRemoveScripts(pkg, useBabel, {
285
285
  build: 'pob-build',
286
286
  watch: 'pob-watch',
287
+ clean: 'rm -Rf dist',
287
288
  });
288
289
  }
289
290
 
@@ -688,7 +689,6 @@ export default class CommonBabelGenerator extends Generator {
688
689
  const pkg = this.fs.readJSON(this.destinationPath('package.json'));
689
690
 
690
691
  const useBabel = this.babelEnvs && this.babelEnvs.length > 0;
691
- const hasReact = useBabel && packageUtils.hasReact(pkg);
692
692
 
693
693
  /* pob-babel config */
694
694
 
@@ -723,21 +723,6 @@ export default class CommonBabelGenerator extends Generator {
723
723
  );
724
724
  }
725
725
 
726
- if (useBabel && this.options.testing && !inLerna) {
727
- // cjs for jest compat
728
- this.fs.copyTpl(
729
- this.templatePath('babel.config.cjs.ejs'),
730
- this.destinationPath('babel.config.cjs'),
731
- {
732
- hasReact,
733
- testing: this.options.testing,
734
- jestExperimentalESM: !inLerna,
735
- },
736
- );
737
- } else {
738
- this.fs.delete('babel.config.cjs');
739
- }
740
-
741
726
  this.fs.writeJSON(this.destinationPath('package.json'), pkg);
742
727
  }
743
728
  }
@@ -1,5 +1,5 @@
1
- import run from 'pob-babel/plugin-run';
2
1
  import createRollupConfig from 'pob-babel/createRollupConfig.js';
2
+ import run from 'pob-babel/plugin-run.cjs';
3
3
 
4
4
  const watch = process.env.ROLLUP_WATCH === 'true';
5
5
 
@@ -159,14 +159,9 @@ export default class CommonLintGenerator extends Generator {
159
159
  'babel-eslint',
160
160
  'eslint-config-pob',
161
161
  'eslint-config-prettier',
162
- 'eslint-plugin-babel',
163
- 'eslint-plugin-flowtype',
164
- 'eslint-plugin-prefer-class-properties',
165
- 'eslint-plugin-prettier',
166
- 'eslint-plugin-react',
167
- 'eslint-plugin-react-hooks',
168
162
  'typescript-eslint-parser',
169
163
  'standard',
164
+ 'eslint-import-resolver-node',
170
165
  ]);
171
166
 
172
167
  if (!pkg.name.startsWith('@pob/eslint-config')) {
@@ -174,11 +169,18 @@ export default class CommonLintGenerator extends Generator {
174
169
  'eslint-plugin-jsx-a11y',
175
170
  'eslint-config-airbnb',
176
171
  'eslint-config-airbnb-base',
172
+ 'eslint-plugin-babel',
173
+ 'eslint-plugin-flowtype',
174
+ 'eslint-plugin-prefer-class-properties',
175
+ 'eslint-plugin-prettier',
176
+ 'eslint-plugin-react',
177
+ 'eslint-plugin-react-hooks',
177
178
  ]);
178
179
  }
179
180
 
180
181
  const yoConfigPobMonorepo = inLerna && inLerna.pobMonorepoConfig;
181
182
  const globalEslint = yoConfigPobMonorepo && yoConfigPobMonorepo.eslint;
183
+ const globalTesting = yoConfigPobMonorepo && yoConfigPobMonorepo.testing;
182
184
  const composite = yoConfigPobMonorepo && yoConfigPobMonorepo.typescript;
183
185
  const { rootPackageManager, rootYarnNodeLinker } = inLerna || {};
184
186
  const lernaProjectType =
@@ -202,7 +204,6 @@ export default class CommonLintGenerator extends Generator {
202
204
  '@pob/eslint-config-react',
203
205
  '@typescript-eslint/eslint-plugin',
204
206
  '@typescript-eslint/parser',
205
- 'eslint-import-resolver-node',
206
207
  'eslint-plugin-node',
207
208
  'eslint-plugin-unicorn',
208
209
  'eslint-plugin-import',
@@ -244,7 +245,7 @@ export default class CommonLintGenerator extends Generator {
244
245
  packageUtils.addOrRemoveDevDependencies(
245
246
  pkg,
246
247
  shouldHavePluginsDependencies,
247
- ['eslint-plugin-node', 'eslint-import-resolver-node'],
248
+ ['eslint-plugin-node'],
248
249
  );
249
250
 
250
251
  if ((inLerna && inLerna.root) || this.options.monorepo) {
@@ -337,18 +338,19 @@ export default class CommonLintGenerator extends Generator {
337
338
  ? `{${pkg.type === 'commonjs' ? 'mjs' : 'cjs'},js}`
338
339
  : `${hasReact ? '{ts,tsx}' : 'ts'}`;
339
340
 
340
- const jestOverride = !pkg.jest
341
- ? null
342
- : {
343
- files: [`**/*.test.${ext}`, `__tests__/**/*.${ext}`],
344
- env: { jest: true },
345
- rules: {
346
- 'import/no-extraneous-dependencies': [
347
- 'error',
348
- { devDependencies: true },
349
- ],
350
- },
351
- };
341
+ const jestOverride =
342
+ !pkg.jest && !globalTesting
343
+ ? null
344
+ : {
345
+ files: [`**/*.test.${ext}`, `__tests__/**/*.${ext}`],
346
+ env: { jest: true },
347
+ rules: {
348
+ 'import/no-extraneous-dependencies': [
349
+ 'error',
350
+ { devDependencies: true },
351
+ ],
352
+ },
353
+ };
352
354
 
353
355
  if (jestOverride) {
354
356
  // if (!useBabel) {
@@ -1,6 +1,7 @@
1
1
  import Generator from 'yeoman-generator';
2
2
  import inLerna from '../../../utils/inLerna.js';
3
3
  import * as packageUtils from '../../../utils/package.js';
4
+ import { copyAndFormatTpl } from '../../../utils/writeAndFormat.js';
4
5
 
5
6
  export default class CommonTestingGenerator extends Generator {
6
7
  constructor(args, opts) {
@@ -82,6 +83,7 @@ export default class CommonTestingGenerator extends Generator {
82
83
  const yoConfigPobMonorepo = inLerna && inLerna.pobMonorepoConfig;
83
84
  const globalTesting = yoConfigPobMonorepo && yoConfigPobMonorepo.testing;
84
85
  const enableForMonorepo = this.options.monorepo && globalTesting;
86
+ const transpileWithBabel = yoConfigPobMonorepo.typescript;
85
87
 
86
88
  if (!this.options.enable) {
87
89
  packageUtils.removeDevDependencies(pkg, ['jest', '@types/jest']);
@@ -104,7 +106,11 @@ export default class CommonTestingGenerator extends Generator {
104
106
  packageUtils.addOrRemoveDevDependencies(
105
107
  pkg,
106
108
  enableForMonorepo || !globalTesting,
107
- ['pob-lcov-reporter', 'jest', '@types/jest'],
109
+ [
110
+ pkg.name !== 'pob-monorepo' && 'pob-lcov-reporter',
111
+ 'jest',
112
+ '@types/jest',
113
+ ],
108
114
  );
109
115
 
110
116
  if (this.options.monorepo && !globalTesting) {
@@ -120,7 +126,6 @@ export default class CommonTestingGenerator extends Generator {
120
126
  ? 'NODE_OPTIONS=--experimental-vm-modules '
121
127
  : ''
122
128
  }jest`;
123
- const transpileWithBabel = yoConfigPobMonorepo.typescript;
124
129
 
125
130
  packageUtils.addScripts(pkg, {
126
131
  test: jestCommand,
@@ -132,14 +137,32 @@ export default class CommonTestingGenerator extends Generator {
132
137
  ].join(' ; '),
133
138
  });
134
139
 
140
+ const workspacesWithoutStar = pkg.workspaces.map((workspace) => {
141
+ if (!workspace.endsWith('/*')) {
142
+ throw new Error(`Invalid workspace format: ${workspace}`);
143
+ }
144
+ return workspace.slice(0, -2);
145
+ });
146
+ const workspacesPattern =
147
+ workspacesWithoutStar.length === 1
148
+ ? workspacesWithoutStar[0]
149
+ : `(${workspacesWithoutStar.join('|')})`;
150
+ const hasReact = packageUtils.hasReact(pkg);
151
+
135
152
  if (!pkg.jest) pkg.jest = {};
136
153
  Object.assign(pkg.jest, {
137
154
  cacheDirectory: './node_modules/.cache/jest',
138
155
  testEnvironment: 'node',
156
+ testMatch: [
157
+ `<rootDir>/${workspacesPattern}/*/(src|lib)/**/__tests__/**/*.${
158
+ transpileWithBabel ? '(ts|js|cjs|mjs)' : '(js|cjs|mjs)'
159
+ }${hasReact ? '?(x)' : ''}`,
160
+ `<rootDir>/${workspacesPattern}/*/(src|lib)/**/*.test.${
161
+ transpileWithBabel ? '(ts|js|cjs|mjs)' : '(js|cjs|mjs)'
162
+ }${hasReact ? '?(x)' : ''}`,
163
+ ],
139
164
  });
140
165
 
141
- const hasReact = false;
142
-
143
166
  if (shouldUseExperimentalVmModules) {
144
167
  pkg.jest.extensionsToTreatAsEsm = [
145
168
  transpileWithBabel && '.ts',
@@ -160,7 +183,7 @@ export default class CommonTestingGenerator extends Generator {
160
183
  const transpileWithBabel = packageUtils.transpileWithBabel(pkg);
161
184
 
162
185
  const shouldUseExperimentalVmModules =
163
- pkg.type === 'module' || (transpileWithBabel && !inLerna);
186
+ pkg.type === 'module' && !inLerna;
164
187
 
165
188
  const jestCommand = `${
166
189
  shouldUseExperimentalVmModules
@@ -233,6 +256,34 @@ export default class CommonTestingGenerator extends Generator {
233
256
  }
234
257
  }
235
258
 
259
+ if (
260
+ transpileWithBabel &&
261
+ ((this.options.monorepo && globalTesting) || !globalTesting)
262
+ ) {
263
+ const hasReact = transpileWithBabel && packageUtils.hasReact(pkg);
264
+ // cjs for jest compat
265
+ copyAndFormatTpl(
266
+ this.fs,
267
+ this.templatePath('babel.config.cjs.ejs'),
268
+ this.destinationPath('babel.config.cjs'),
269
+ {
270
+ only: !this.options.monorepo
271
+ ? "'src'"
272
+ : pkg.workspaces
273
+ .flatMap((workspace) => [
274
+ `'${workspace}/src'`,
275
+ `'${workspace}/lib'`,
276
+ ])
277
+ .join(', '),
278
+ hasReact,
279
+ testing: this.options.testing,
280
+ jestExperimentalESM: pkg.type === 'module',
281
+ },
282
+ );
283
+ } else {
284
+ this.fs.delete('babel.config.cjs');
285
+ }
286
+
236
287
  this.fs.writeJSON(this.destinationPath('package.json'), pkg);
237
288
  }
238
289
  }
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ module.exports = function babelConfig(api) {
4
+ const isTest = api.env('test');
5
+
6
+ if (!isTest) return {};
7
+
8
+ return {
9
+ only: [<%- only %>],
10
+ presets: [[require.resolve('pob-babel/preset.cjs')<% if (!jestExperimentalESM) { %>, { modules: 'commonjs' }<% } %>]],
11
+ };
12
+ };
@@ -127,6 +127,7 @@ export default class CommonTypescriptGenerator extends Generator {
127
127
  this.templatePath('tsconfig.build.json.ejs'),
128
128
  tsconfigBuildPath,
129
129
  {
130
+ inMonorepo: inLerna && !inLerna.root,
130
131
  jsx,
131
132
  composite,
132
133
  monorepoPackageNames,
@@ -18,6 +18,9 @@
18
18
 
19
19
  "exclude": [
20
20
  "dist/**",
21
+ <% if (!inMonorepo) { -%>
22
+ "src/test-setup.ts",
23
+ <% } -%>
21
24
  "src/**/*.test.ts",
22
25
  <% if(jsx) { -%>
23
26
  "src/**/*.test.tsx",
@@ -128,6 +128,13 @@ export default class CorePackageGenerator extends Generator {
128
128
  choices: ['commonjs', 'module'],
129
129
  when: !pkg.type,
130
130
  },
131
+ {
132
+ name: 'license',
133
+ message: 'License Type',
134
+ type: 'list',
135
+ choices: ['MIT', 'ISC', 'UNLICENSED'],
136
+ when: !pkg.license,
137
+ },
131
138
  ].filter(Boolean),
132
139
  );
133
140
 
@@ -164,10 +171,19 @@ export default class CorePackageGenerator extends Generator {
164
171
  const doesMjsCheckPackagesExists = this.fs.exists(
165
172
  this.destinationPath('scripts/check-packages.mjs'),
166
173
  );
167
- const doesJsCheckPackagesExists = this.fs.exists(
174
+ let doesJsCheckPackagesExists = this.fs.exists(
168
175
  this.destinationPath('scripts/check-packages.js'),
169
176
  );
170
177
 
178
+ if (pkg.type === 'module' && !doesJsCheckPackagesExists) {
179
+ doesJsCheckPackagesExists = true;
180
+ this.fs.copyTpl(
181
+ this.templatePath('check-packages.js.ejs'),
182
+ this.destinationPath('scripts/check-packages.js'),
183
+ {},
184
+ );
185
+ }
186
+
171
187
  packageUtils.addOrRemoveScripts(
172
188
  pkg,
173
189
  doesMjsCheckPackagesExists || doesJsCheckPackagesExists,
@@ -177,13 +193,31 @@ export default class CorePackageGenerator extends Generator {
177
193
  }`,
178
194
  },
179
195
  );
196
+ } else if (inLerna && !inLerna.root) {
197
+ if (this.fs.exists('scripts/check-package.js')) {
198
+ this.fs.delete('scripts/check-package.js');
199
+ }
200
+ if (this.fs.exists('scripts/check-package.mjs')) {
201
+ this.fs.delete('scripts/check-package.mjs');
202
+ }
203
+ packageUtils.removeScripts(pkg, ['checks']);
180
204
  } else {
181
205
  const doesMjsCheckPackageExists = this.fs.exists(
182
206
  this.destinationPath('scripts/check-package.mjs'),
183
207
  );
184
- const doesJsCheckPackageExists = this.fs.exists(
208
+ let doesJsCheckPackageExists = this.fs.exists(
185
209
  this.destinationPath('scripts/check-package.js'),
186
210
  );
211
+
212
+ if (pkg.type === 'module' && !doesJsCheckPackageExists) {
213
+ doesJsCheckPackageExists = true;
214
+ this.fs.copyTpl(
215
+ this.templatePath('check-package.js.ejs'),
216
+ this.destinationPath('scripts/check-package.js'),
217
+ {},
218
+ );
219
+ }
220
+
187
221
  packageUtils.addOrRemoveScripts(
188
222
  pkg,
189
223
  doesMjsCheckPackageExists || doesJsCheckPackageExists,
@@ -205,6 +239,18 @@ export default class CorePackageGenerator extends Generator {
205
239
  author.url ? ` (${author.url})` : ''
206
240
  }`;
207
241
 
242
+ if (!pkg.license) {
243
+ pkg.license = props.license;
244
+ this.fs.copyTpl(
245
+ this.templatePath(`licenses/${props.license}.ejs`),
246
+ this.destinationPath('LICENSE'),
247
+ {
248
+ year: new Date().getFullYear(),
249
+ author: pkg.author,
250
+ },
251
+ );
252
+ }
253
+
208
254
  if (pkg.private) {
209
255
  if (!pkg.description) delete pkg.description;
210
256
  if (!pkg.keywords || pkg.keywords.length === 0) delete pkg.keywords;
@@ -0,0 +1,3 @@
1
+ import { createCheckPackage } from 'check-package-dependencies';
2
+
3
+ createCheckPackage().checkRecommended({});
@@ -0,0 +1,5 @@
1
+ import { createCheckPackageWithWorkspaces } from 'check-package-dependencies';
2
+
3
+ createCheckPackageWithWorkspaces().checkRecommended({
4
+ isLibrary: () => true,
5
+ });
@@ -0,0 +1,15 @@
1
+ Copyright (c) <%- year %> <%- author %>
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for
4
+ any purpose with or without fee is hereby granted, provided that the
5
+ above copyright notice and this permission notice appear in all
6
+ copies.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
9
+ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
10
+ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
11
+ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12
+ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
13
+ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
14
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) <%- year %> <%- author %>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,2 @@
1
+ Copyright (c) <%- year %> <%- author %>
2
+ All rights reserved.
@@ -1,5 +1,6 @@
1
1
  import Generator from 'yeoman-generator';
2
2
  import inLerna from '../../../utils/inLerna.js';
3
+ import { writeAndFormatJson } from '../../../utils/writeAndFormat.js';
3
4
 
4
5
  export default class CoreRenovateGenerator extends Generator {
5
6
  constructor(args, opts) {
@@ -58,11 +59,25 @@ export default class CoreRenovateGenerator extends Generator {
58
59
 
59
60
  writing() {
60
61
  if (this.enableRenovate) {
61
- this.fs.copy(
62
- this.templatePath(
63
- this.options.app ? 'renovate.app.json' : 'renovate.lib.json',
64
- ),
62
+ const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
63
+ const renovateConfig = this.fs.readJSON(
65
64
  this.destinationPath('renovate.json'),
65
+ {},
66
+ );
67
+
68
+ if (this.options.app) {
69
+ renovateConfig.extends = ['config:js-app', '@pob'];
70
+ } else {
71
+ renovateConfig.extends = [
72
+ 'config:js-lib',
73
+ pkg.name === 'pob-monorepo' ? undefined : '@pob',
74
+ ].filter(Boolean);
75
+ }
76
+
77
+ writeAndFormatJson(
78
+ this.fs,
79
+ this.destinationPath('renovate.json'),
80
+ renovateConfig,
66
81
  );
67
82
  } else if (this.fs.exists(this.destinationPath('renovate.json'))) {
68
83
  this.fs.delete(this.destinationPath('renovate.json'));
@@ -1,4 +1,5 @@
1
1
  import Generator from 'yeoman-generator';
2
+ import { readJSON5 } from '../../../utils/json5.js';
2
3
  import { copyAndFormatTpl } from '../../../utils/writeAndFormat.js';
3
4
 
4
5
  export default class CoreVSCodeGenerator extends Generator {
@@ -56,12 +57,19 @@ export default class CoreVSCodeGenerator extends Generator {
56
57
  typescript: this.options.typescript,
57
58
  },
58
59
  );
60
+
61
+ const tasksConfig = readJSON5(
62
+ this.fs,
63
+ this.destinationPath('.vscode/tasks.json'),
64
+ {},
65
+ );
59
66
  copyAndFormatTpl(
60
67
  this.fs,
61
68
  this.templatePath('tasks.json.ejs'),
62
69
  this.destinationPath('.vscode/tasks.json'),
63
70
  {
64
71
  typescript: this.options.typescript,
72
+ tasks: JSON.stringify(tasksConfig.tasks || [], null, 2),
65
73
  },
66
74
  );
67
75
  } else {
@@ -33,7 +33,7 @@
33
33
  "eslint.workingDirectories": ["."],
34
34
  "eslint.options": {
35
35
  "resolvePluginsRelativeTo": ".",
36
- "reportUnusedDisableDirectives": true
36
+ "reportUnusedDisableDirectives": "error"
37
37
  },
38
38
  "eslint.lintTask.enable": true,
39
39
 
@@ -2,6 +2,5 @@
2
2
  // See https://go.microsoft.com/fwlink/?LinkId=733558
3
3
  // for the documentation about the tasks.json format
4
4
  "version": "2.0.0",
5
- "tasks": [
6
- ]
5
+ "tasks": <%- tasks %>
7
6
  }
@@ -320,13 +320,6 @@ export default class PobLibGenerator extends Generator {
320
320
  delete pkg.scripts.version;
321
321
  }
322
322
  }
323
- if (withBabel && (!inLerna || !inLerna.root)) {
324
- packageUtils.addScripts(pkg, {
325
- clean: 'rm -Rf dist',
326
- });
327
- } else {
328
- delete pkg.scripts.clean;
329
- }
330
323
 
331
324
  if (!withBabel) {
332
325
  if (
@@ -39,7 +39,10 @@ export default class LibReleaseGenerator extends Generator {
39
39
 
40
40
  if (!isStandardVersionEnabled) {
41
41
  packageUtils.removeDevDependencies(pkg, ['standard-version']);
42
- packageUtils.removeScripts(pkg, ['release', 'preversion']);
42
+ packageUtils.removeScripts(pkg, [
43
+ 'release',
44
+ pkg.name === 'pob-dependencies' ? null : 'preversion',
45
+ ]);
43
46
  } else {
44
47
  packageUtils.addDevDependencies(pkg, ['standard-version']);
45
48
  packageUtils.addScripts(pkg, {
@@ -1,4 +1,5 @@
1
1
  import fs from 'fs';
2
+ import path from 'path';
2
3
  import { PackageGraph } from '@lerna/package-graph';
3
4
  import { Project as LernaProject } from '@lerna/project';
4
5
  import Generator from 'yeoman-generator';
@@ -82,10 +83,15 @@ export default class PobMonorepoGenerator extends Generator {
82
83
  const batch = [...graph.values()].filter(
83
84
  (node) => node.localDependencies.size === 0,
84
85
  );
86
+ batch.sort((a, b) => a.name.localeCompare(b.name, 'en'));
85
87
 
86
88
  // batches are composed of Package instances, not PackageGraphNodes
87
89
  this.packages.push(...batch.map((node) => node.pkg));
88
- this.packageLocations.push(...batch.map((node) => node.location));
90
+ this.packageLocations.push(
91
+ ...batch.map((node) =>
92
+ path.relative(this.destinationPath(), node.location),
93
+ ),
94
+ );
89
95
 
90
96
  // pruning the graph changes the node.localDependencies.size test
91
97
  graph.prune(...batch);
@@ -165,32 +171,14 @@ export default class PobMonorepoGenerator extends Generator {
165
171
  const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
166
172
 
167
173
  const packageNames = this.packageNames;
168
-
169
- const basePackageName = pkg.name.startsWith('@')
170
- ? `${pkg.name.replace(/-monorepo$/, '')}-`
171
- : `@${pkg.name}/`;
172
-
173
- const packagePaths = packageNames
174
- .map((packageName) =>
175
- this.options.isAppProject && packageName.startsWith(basePackageName)
176
- ? `packages/${packageName.slice(basePackageName.length)}`
177
- : `${packageName[0] === '@' ? '' : 'packages/'}${packageName}`,
178
- )
179
- .filter(
180
- this.pobLernaConfig.typescript
181
- ? (packagePath) => fs.existsSync(`${packagePath}/tsconfig.json`)
182
- : Boolean,
183
- );
174
+ const packagePaths = this.packageLocations.filter(
175
+ this.pobLernaConfig.typescript
176
+ ? (packagePath) => fs.existsSync(`${packagePath}/tsconfig.json`)
177
+ : Boolean,
178
+ );
184
179
 
185
180
  if (packagePaths.length === 0 && packageNames.length > 0) {
186
- console.log(
187
- packageNames,
188
- packageNames.map((packageName) =>
189
- this.options.isAppProject && packageName.startsWith(basePackageName)
190
- ? `packages/${packageName.slice(basePackageName.length)}`
191
- : `${packageName[0] === '@' ? '' : 'packages/'}${packageName}`,
192
- ),
193
- );
181
+ console.log(packageNames, packagePaths);
194
182
  throw new Error('packages should not be empty');
195
183
  }
196
184
 
@@ -39,7 +39,7 @@ jobs:
39
39
  if: |
40
40
  github.ref == 'refs/heads/main'
41
41
  && contains(github.event.inputs.dry-run, 'y')
42
- run: yarn lerna version --yes --no-push --conventional-commits --conventional-graduate --no-git-tag-version --loglevel=verbose
42
+ run: yarn lerna version --yes --no-push --exact --conventional-commits --conventional-graduate --no-git-tag-version --loglevel=verbose
43
43
 
44
44
  - name: Configure Git user
45
45
  if: |
@@ -54,7 +54,7 @@ jobs:
54
54
  github.ref == 'refs/heads/main'
55
55
  && contains(github.event.inputs.dry-run, 'y') == false
56
56
  run: |
57
- yarn lerna version --yes --push --conventional-commits --conventional-graduate --create-release=github -m 'chore: release [skip ci]'
57
+ yarn lerna version --yes --push --exact --conventional-commits --conventional-graduate --create-release=github -m 'chore: release [skip ci]'
58
58
  env:
59
59
  GH_TOKEN: ${{ secrets.GH_TOKEN }}
60
60
  YARN_ENABLE_IMMUTABLE_INSTALLS: false
@@ -43,13 +43,6 @@ export default class PobBaseGenerator extends Generator {
43
43
  required: true,
44
44
  desc: "Don't check diff",
45
45
  });
46
-
47
- this.option('license', {
48
- type: Boolean,
49
- required: false,
50
- defaults: true,
51
- desc: 'Include a license',
52
- });
53
46
  }
54
47
 
55
48
  rootGeneratorName() {
@@ -145,20 +138,6 @@ export default class PobBaseGenerator extends Generator {
145
138
  this.fs.delete('Makefile');
146
139
  this.fs.delete(this.destinationPath('.commitrc.js'));
147
140
 
148
- const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
149
- if (
150
- this.options.license &&
151
- !this.fs.exists(this.destinationPath('LICENSE'))
152
- ) {
153
- const author = packageUtils.parsePkgAuthor(pkg) || {};
154
- this.composeWith('generator-license/app', {
155
- name: author.name,
156
- email: author.email,
157
- website: author.url,
158
- defaultLicense: 'ISC',
159
- });
160
- }
161
-
162
141
  this.composeWith('pob:core:editorconfig');
163
142
 
164
143
  this.composeWith('pob:core:clean', {
@@ -170,6 +149,8 @@ export default class PobBaseGenerator extends Generator {
170
149
  app: this.projectConfig.type === 'app',
171
150
  });
172
151
 
152
+ const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
153
+
173
154
  this.composeWith('pob:core:vscode', {
174
155
  root: this.isRoot,
175
156
  packageManager: this.projectConfig.packageManager,
package/lib/pob.js CHANGED
@@ -286,16 +286,14 @@ const options = {
286
286
  force: argv.force,
287
287
  };
288
288
 
289
- (async () => {
290
- try {
291
- await env.run('pob', options);
292
- } catch (err) {
293
- if (err) {
294
- console.error(err.stack || err.message || err);
295
- process.exit(1);
296
- }
289
+ try {
290
+ await env.run('pob', options);
291
+ } catch (err) {
292
+ if (err) {
293
+ console.error(err.stack || err.message || err);
294
+ process.exit(1);
297
295
  }
298
- })();
296
+ }
299
297
 
300
298
  // generator.on('error', (err) => {
301
299
  // console.error(err.stack || err.message || err);
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ exports.pobEslintConfig = require('@pob/eslint-config/package.json');
4
+
5
+ exports.pobEslintConfigTypescript = require('@pob/eslint-config-typescript/package.json');
6
+
7
+ exports.pobEslintConfigTypescriptReact = require('@pob/eslint-config-typescript-react/package.json');
@@ -0,0 +1,7 @@
1
+ import JSON5 from 'json5';
2
+
3
+ export function readJSON5(fs, destinationPath, defaults) {
4
+ const content = fs.read(destinationPath, null);
5
+ if (content === null) return defaults;
6
+ return JSON5.parse(content);
7
+ }
@@ -3,6 +3,11 @@ import sortPkg from '@pob/sort-pkg';
3
3
  import parseAuthor from 'parse-author';
4
4
  import pobDependencies from 'pob-dependencies';
5
5
  import semver from 'semver';
6
+ import {
7
+ pobEslintConfig,
8
+ pobEslintConfigTypescript,
9
+ pobEslintConfigTypescriptReact,
10
+ } from './dependenciesPackages.cjs';
6
11
 
7
12
  export { default as parseAuthor } from 'parse-author';
8
13
 
@@ -62,7 +67,7 @@ function internalAddToObject(pkg, key, object) {
62
67
 
63
68
  function internalRemoveFromObject(pkg, key, keys) {
64
69
  if (!pkg[key]) return;
65
- keys.forEach((k) => {
70
+ keys.filter(Boolean).forEach((k) => {
66
71
  delete pkg[key][k];
67
72
  });
68
73
  if (Object.keys(pkg[key]).length === 0) {
@@ -78,6 +83,26 @@ const internalRemoveDependencies = (pkg, type, dependencyKeys) => {
78
83
  };
79
84
 
80
85
  const getVersionFromDependencyName = (dependency) => {
86
+ if (
87
+ [
88
+ // 'eslint-import-resolver-node',
89
+ 'eslint-plugin-import',
90
+ 'eslint-plugin-node',
91
+ 'eslint-plugin-unicorn',
92
+ ].includes(dependency)
93
+ ) {
94
+ return pobEslintConfig.dependencies[dependency];
95
+ }
96
+ if (['eslint-plugin-jsx-a11y', 'eslint-plugin-react'].includes(dependency)) {
97
+ return pobEslintConfigTypescriptReact.dependencies[dependency];
98
+ }
99
+ if (
100
+ ['@typescript-eslint/eslint-plugin', '@typescript-eslint/parser'].includes(
101
+ dependency,
102
+ )
103
+ ) {
104
+ return pobEslintConfigTypescript.dependencies[dependency];
105
+ }
81
106
  return pobDependencies[dependency];
82
107
  };
83
108
 
@@ -88,7 +113,7 @@ const internalAddDependencies = (pkg, type, dependencies, cleaned, prefix) => {
88
113
  const removeDependencies = [];
89
114
 
90
115
  const dependenciesToCheck = [];
91
- dependencies.forEach((dependency) => {
116
+ dependencies.filter(Boolean).forEach((dependency) => {
92
117
  if (ignoreDependencies[dependency] || pkg.name === dependency) {
93
118
  removeDependencies.push(dependency);
94
119
  } else {
@@ -120,7 +145,10 @@ const internalAddDependencies = (pkg, type, dependencies, cleaned, prefix) => {
120
145
  ? `${prefix || ''}${potentialNewVersionCleaned}`
121
146
  : potentialNewVersion;
122
147
  try {
123
- if (
148
+ if (currentVersion === 'workspace:*') {
149
+ // the package is in the monorepo
150
+ return;
151
+ } else if (
124
152
  !currentVersion ||
125
153
  semver.gt(potentialNewVersionCleaned, cleanVersion(currentVersion))
126
154
  ) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "9.5.0",
3
+ "version": "9.7.1",
4
4
  "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
5
5
  "keywords": [
6
6
  "skeleton"
@@ -38,37 +38,35 @@
38
38
  "arrowParens": "always"
39
39
  },
40
40
  "pob": {},
41
- "resolutions": {
42
- "yeoman-generator": "4.13.0"
43
- },
44
- "resolutionsExplained": {
45
- "yeoman-generator": "generator-license has a dependency to yeoman-generator@2.0.5"
46
- },
47
41
  "dependencies": {
48
42
  "@lerna/package-graph": "^4.0.0",
49
43
  "@lerna/project": "^4.0.0",
50
- "@pob/sort-eslint-config": "^3.0.0",
51
- "@pob/sort-object": "^4.0.0",
52
- "@pob/sort-pkg": "^4.0.0",
53
- "@yarnpkg/parsers": "^2.2.0",
44
+ "@pob/eslint-config": "48.0.5",
45
+ "@pob/eslint-config-typescript": "48.0.5",
46
+ "@pob/eslint-config-typescript-react": "48.0.5",
47
+ "@pob/sort-eslint-config": "^3.0.1",
48
+ "@pob/sort-object": "^4.0.1",
49
+ "@pob/sort-pkg": "^4.0.1",
50
+ "@yarnpkg/parsers": "2.5.0-rc.6",
51
+ "eslint": "8.4.1",
54
52
  "findup-sync": "^5.0.0",
55
- "generator-license": "^5.4.0",
56
53
  "git-remote-url": "^1.0.1",
57
54
  "github-username": "^6.0.0",
58
55
  "got": "^11.8.1",
59
56
  "inquirer-npm-name": "^4.0.0",
57
+ "json5": "^2.2.0",
60
58
  "lodash.camelcase": "^4.3.0",
61
59
  "lodash.kebabcase": "^4.1.1",
62
60
  "mem-fs": "1.2.0",
63
61
  "mem-fs-editor": "8.1.2",
64
62
  "minimist-argv": "^1.1.0",
65
63
  "parse-author": "^2.0.0",
66
- "pob-dependencies": "^6.1.0",
64
+ "pob-dependencies": "6.3.0",
67
65
  "prettier": "2.5.1",
68
66
  "semver": "^7.3.4",
69
67
  "update-notifier": "^5.0.1",
70
68
  "yeoman-environment": "^3.5.1",
71
69
  "yeoman-generator": "^5.4.0"
72
70
  },
73
- "gitHead": "48b073ef8e253234b0b08f69a250befe044dcc58"
71
+ "gitHead": "dd06ee4c68f029bbd1764e3564d91ba6667a415f"
74
72
  }
@@ -1,14 +0,0 @@
1
- 'use strict';
2
-
3
- const path = require('path');
4
-
5
- module.exports = function babelConfig(api) {
6
- const isTest = api.env('test');
7
-
8
- if (!isTest) return {};
9
-
10
- return {
11
- only: [path.resolve(__dirname, 'src')],
12
- presets: [[require.resolve('pob-babel/preset')<% if (!jestExperimentalESM) { %>, { modules: 'commonjs' }<% } %>]],
13
- };
14
- };
@@ -1,3 +0,0 @@
1
- {
2
- "extends": ["config:js-app", "@pob"]
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "extends": ["config:js-lib", "@pob"]
3
- }