pob 11.9.0 → 12.0.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,28 @@
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
+ ## [12.0.0](https://github.com/christophehurpeau/pob/compare/pob@11.9.0...pob@12.0.0) (2023-04-18)
7
+
8
+
9
+ ### ⚠ BREAKING CHANGES
10
+
11
+ * require node 18 for pob and monorepo
12
+
13
+ ### Features
14
+
15
+ * **deps:** update dependency eslint to v8.38.0 ([#1596](https://github.com/christophehurpeau/pob/issues/1596)) ([6e0c03b](https://github.com/christophehurpeau/pob/commit/6e0c03b39fe040e9af465fa1e29ec757af3a9311))
16
+ * **deps:** update dependency semver to v7.4.0 ([#1599](https://github.com/christophehurpeau/pob/issues/1599)) ([d71ada7](https://github.com/christophehurpeau/pob/commit/d71ada7ca259ccf83b3226221fb6288e5cf42fcc))
17
+ * **deps:** update dependency semver to v7.5.0 ([#1608](https://github.com/christophehurpeau/pob/issues/1608)) ([1dda98b](https://github.com/christophehurpeau/pob/commit/1dda98b556f670f1316fea18b31a9ce806dd114e))
18
+ * **pob:** add node runner as testing option ([c96f6d8](https://github.com/christophehurpeau/pob/commit/c96f6d888a3cc62a5cba50f069e1c51124acb0d9))
19
+ * require node 18 for pob and monorepo ([5953695](https://github.com/christophehurpeau/pob/commit/5953695fc2a7a440bfaebc8abce8533b05a68f65))
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * fix rootIgnorePatterns for monorepo ([6731118](https://github.com/christophehurpeau/pob/commit/673111827a0c378febae87f7fefa9917cd8354c3))
25
+
26
+
27
+
6
28
  ## [11.9.0](https://github.com/christophehurpeau/pob/compare/pob@11.8.1...pob@11.9.0) (2023-04-03)
7
29
 
8
30
 
@@ -423,8 +423,8 @@ export default class CommonLintGenerator extends Generator {
423
423
  if ((!inLerna || !inLerna.root) && useBabel) {
424
424
  const buildPath = `/${this.options.buildDirectory}`;
425
425
  if (
426
- !this.options.ignorePaths ||
427
- !this.options.ignorePaths.includes(buildPath)
426
+ !this.options.rootIgnorePatterns ||
427
+ !this.options.rootIgnorePatterns.includes(buildPath)
428
428
  ) {
429
429
  ignorePatterns.add(buildPath);
430
430
  }
@@ -433,8 +433,8 @@ export default class CommonLintGenerator extends Generator {
433
433
  ignorePatterns.add('/rollup.config.mjs');
434
434
  }
435
435
 
436
- if (this.options.ignorePaths) {
437
- this.options.ignorePaths
436
+ if (this.options.rootIgnorePatterns) {
437
+ this.options.rootIgnorePatterns
438
438
  .split('\n')
439
439
  .filter(Boolean)
440
440
  .forEach((ignorePath) => {
@@ -20,6 +20,12 @@ export default class CommonTestingGenerator extends Generator {
20
20
  desc: 'enable testing',
21
21
  });
22
22
 
23
+ this.option('runner', {
24
+ type: String,
25
+ defaults: 'jest',
26
+ desc: 'test runner (jest or node)',
27
+ });
28
+
23
29
  this.option('enableReleasePlease', {
24
30
  type: Boolean,
25
31
  defaults: true,
@@ -128,10 +134,13 @@ export default class CommonTestingGenerator extends Generator {
128
134
  ? yoConfigPobMonorepo.react ?? packageUtils.hasReact(pkg)
129
135
  : packageUtils.hasReact(pkg));
130
136
 
131
- if (!this.options.enable) {
137
+ if (this.options.enable || this.options.runner !== 'jest') {
132
138
  packageUtils.removeDevDependencies(pkg, ['jest', '@types/jest']);
133
139
 
134
140
  delete pkg.jest;
141
+ }
142
+
143
+ if (!this.options.enable) {
135
144
  // if (inLerna) {
136
145
  // if (pkg.scripts.test === 'echo "No tests"') {
137
146
  // delete pkg.scripts.test;
@@ -142,15 +151,18 @@ export default class CommonTestingGenerator extends Generator {
142
151
  delete pkg.scripts.test;
143
152
  delete pkg.scripts['generate:test-coverage'];
144
153
  delete pkg.scripts['test:watch'];
154
+ delete pkg.scripts['test:coverage'];
145
155
  }
146
156
 
147
157
  this.fs.writeJSON(this.destinationPath('package.json'), pkg);
148
158
  } else {
149
- packageUtils.addOrRemoveDevDependencies(
150
- pkg,
151
- enableForMonorepo || !globalTesting,
152
- ['jest', '@types/jest'],
153
- );
159
+ if (this.options.runner === 'jest') {
160
+ packageUtils.addOrRemoveDevDependencies(
161
+ pkg,
162
+ enableForMonorepo || !globalTesting,
163
+ ['jest', '@types/jest'],
164
+ );
165
+ }
154
166
 
155
167
  packageUtils.removeScripts(['test:coverage']);
156
168
  if (this.options.monorepo && !globalTesting) {
@@ -161,57 +173,68 @@ export default class CommonTestingGenerator extends Generator {
161
173
  } else if (this.options.monorepo) {
162
174
  const shouldUseExperimentalVmModules = pkg.type === 'module';
163
175
 
164
- const jestCommand = `${
165
- shouldUseExperimentalVmModules
166
- ? 'NODE_OPTIONS=--experimental-vm-modules '
167
- : ''
168
- }jest`;
176
+ const testCommand =
177
+ this.options.runner === 'jest'
178
+ ? `${
179
+ shouldUseExperimentalVmModules
180
+ ? 'NODE_OPTIONS=--experimental-vm-modules '
181
+ : ''
182
+ }jest`
183
+ : 'node --test';
169
184
 
170
185
  packageUtils.addScripts(pkg, {
171
- test: jestCommand,
186
+ test: testCommand,
187
+ 'test:watch': `${testCommand} --watch`,
188
+ 'test:coverage':
189
+ this.options.runner === 'jest'
190
+ ? `${testCommand} --coverage --coverageReporters=json --coverageReporters=text`
191
+ : testCommand, // not yet configured
172
192
  });
173
193
 
174
- const workspacesWithoutStar = pkg.workspaces.map((workspace) => {
175
- if (!workspace.endsWith('/*')) {
176
- throw new Error(`Invalid workspace format: ${workspace}`);
194
+ if (this.options.runner === 'jest') {
195
+ const workspacesWithoutStar = pkg.workspaces.map((workspace) => {
196
+ if (!workspace.endsWith('/*')) {
197
+ throw new Error(`Invalid workspace format: ${workspace}`);
198
+ }
199
+ return workspace.slice(0, -2);
200
+ });
201
+ const workspacesPattern =
202
+ workspacesWithoutStar.length === 1
203
+ ? workspacesWithoutStar[0]
204
+ : `@(${workspacesWithoutStar.join('|')})`;
205
+ hasReact = yoConfigPobMonorepo.packageNames.some((pkgName) =>
206
+ pkgName.startsWith('react-'),
207
+ );
208
+
209
+ if (!pkg.jest) pkg.jest = {};
210
+ Object.assign(pkg.jest, {
211
+ cacheDirectory: './node_modules/.cache/jest',
212
+ testEnvironment: 'node',
213
+ testMatch: [
214
+ `<rootDir>/${workspacesPattern}/*/@(src|lib)/**/__tests__/**/*.${
215
+ transpileWithBabel ? '(ts|js|cjs|mjs)' : '(js|cjs|mjs)'
216
+ }${hasReact ? '?(x)' : ''}`,
217
+ `<rootDir>/${workspacesPattern}/*/@(src|lib)/**/*.test.${
218
+ transpileWithBabel ? '(ts|js|cjs|mjs)' : '(js|cjs|mjs)'
219
+ }${hasReact ? '?(x)' : ''}`,
220
+ ],
221
+ });
222
+
223
+ if (shouldUseExperimentalVmModules) {
224
+ pkg.jest.extensionsToTreatAsEsm = [
225
+ transpileWithBabel && '.ts',
226
+ transpileWithBabel && hasReact && '.tsx',
227
+ ].filter(Boolean);
228
+ } else {
229
+ delete pkg.jest.extensionsToTreatAsEsm;
177
230
  }
178
- return workspace.slice(0, -2);
179
- });
180
- const workspacesPattern =
181
- workspacesWithoutStar.length === 1
182
- ? workspacesWithoutStar[0]
183
- : `@(${workspacesWithoutStar.join('|')})`;
184
- hasReact = yoConfigPobMonorepo.packageNames.some((pkgName) =>
185
- pkgName.startsWith('react-'),
186
- );
187
-
188
- if (!pkg.jest) pkg.jest = {};
189
- Object.assign(pkg.jest, {
190
- cacheDirectory: './node_modules/.cache/jest',
191
- testEnvironment: 'node',
192
- testMatch: [
193
- `<rootDir>/${workspacesPattern}/*/@(src|lib)/**/__tests__/**/*.${
194
- transpileWithBabel ? '(ts|js|cjs|mjs)' : '(js|cjs|mjs)'
195
- }${hasReact ? '?(x)' : ''}`,
196
- `<rootDir>/${workspacesPattern}/*/@(src|lib)/**/*.test.${
197
- transpileWithBabel ? '(ts|js|cjs|mjs)' : '(js|cjs|mjs)'
198
- }${hasReact ? '?(x)' : ''}`,
199
- ],
200
- });
201
-
202
- if (shouldUseExperimentalVmModules) {
203
- pkg.jest.extensionsToTreatAsEsm = [
204
- transpileWithBabel && '.ts',
205
- transpileWithBabel && hasReact && '.tsx',
206
- ].filter(Boolean);
207
- } else {
208
- delete pkg.jest.extensionsToTreatAsEsm;
209
231
  }
210
232
  } else if (globalTesting) {
211
233
  delete pkg.jest;
212
234
  if (pkg.scripts) {
213
235
  delete pkg.scripts['generate:test-coverage'];
214
236
  delete pkg.scripts['test:watch'];
237
+ delete pkg.scripts['test:coverage'];
215
238
  }
216
239
  packageUtils.addScripts(pkg, {
217
240
  test: `yarn ../../ run test -- ${path
@@ -225,67 +248,78 @@ export default class CommonTestingGenerator extends Generator {
225
248
  const shouldUseExperimentalVmModules =
226
249
  pkg.type === 'module' && !inLerna;
227
250
 
228
- const jestCommand = `${
229
- shouldUseExperimentalVmModules
230
- ? 'NODE_OPTIONS=--experimental-vm-modules '
231
- : ''
232
- }jest`;
251
+ const testCommand =
252
+ this.options.runner === 'jest'
253
+ ? `${
254
+ shouldUseExperimentalVmModules
255
+ ? 'NODE_OPTIONS=--experimental-vm-modules '
256
+ : ''
257
+ }jest`
258
+ : 'node --test';
233
259
 
234
260
  packageUtils.addScripts(pkg, {
235
- test: jestCommand,
236
- 'test:watch': `${jestCommand} --watch`,
261
+ test: testCommand,
262
+ 'test:watch': `${testCommand} --watch`,
263
+ 'test:coverage':
264
+ this.options.runner === 'jest'
265
+ ? `${testCommand} --coverage --coverageReporters=json --coverageReporters=text`
266
+ : testCommand, // not yet configured,
237
267
  });
238
268
 
239
- const srcDirectory = transpileWithBabel ? 'src' : 'lib';
240
-
241
- if (!pkg.jest) pkg.jest = {};
242
- Object.assign(pkg.jest, {
243
- cacheDirectory: './node_modules/.cache/jest',
244
- testMatch: [
245
- `<rootDir>/${srcDirectory}/**/__tests__/**/*.${
246
- transpileWithBabel ? 'ts' : '?(m)js'
247
- }${hasReact ? '?(x)' : ''}`,
248
- `<rootDir>/${srcDirectory}/**/*.test.${
249
- transpileWithBabel ? 'ts' : '?(m)js'
250
- }${hasReact ? '?(x)' : ''}`,
251
- ],
252
- collectCoverageFrom: [
253
- `${srcDirectory}/**/*.${transpileWithBabel ? 'ts' : '?(m)js'}${
254
- hasReact ? '?(x)' : ''
255
- }`,
256
- ],
257
- moduleFileExtensions: [
258
- transpileWithBabel && 'ts',
259
- transpileWithBabel && hasReact && 'tsx',
260
- 'js',
261
- // 'jsx',
262
- 'json',
263
- ].filter(Boolean),
264
- // transform: {
265
- // [`^.+\\.ts${hasReact ? 'x?' : ''}$`]: 'babel-jest',
266
- // },
267
- });
268
- delete pkg.jest.transform;
269
+ if (this.options.runner === 'jest') {
270
+ const srcDirectory = transpileWithBabel ? 'src' : 'lib';
271
+
272
+ if (!pkg.jest) pkg.jest = {};
273
+ Object.assign(pkg.jest, {
274
+ cacheDirectory: './node_modules/.cache/jest',
275
+ testMatch: [
276
+ `<rootDir>/${srcDirectory}/**/__tests__/**/*.${
277
+ transpileWithBabel ? 'ts' : '?(m)js'
278
+ }${hasReact ? '?(x)' : ''}`,
279
+ `<rootDir>/${srcDirectory}/**/*.test.${
280
+ transpileWithBabel ? 'ts' : '?(m)js'
281
+ }${hasReact ? '?(x)' : ''}`,
282
+ ],
283
+ collectCoverageFrom: [
284
+ `${srcDirectory}/**/*.${transpileWithBabel ? 'ts' : '?(m)js'}${
285
+ hasReact ? '?(x)' : ''
286
+ }`,
287
+ ],
288
+ moduleFileExtensions: [
289
+ transpileWithBabel && 'ts',
290
+ transpileWithBabel && hasReact && 'tsx',
291
+ 'js',
292
+ // 'jsx',
293
+ 'json',
294
+ ].filter(Boolean),
295
+ // transform: {
296
+ // [`^.+\\.ts${hasReact ? 'x?' : ''}$`]: 'babel-jest',
297
+ // },
298
+ });
299
+ delete pkg.jest.transform;
300
+
301
+ if (shouldUseExperimentalVmModules) {
302
+ pkg.jest.extensionsToTreatAsEsm = [
303
+ transpileWithBabel && '.ts',
304
+ transpileWithBabel && hasReact && '.tsx',
305
+ ].filter(Boolean);
306
+ } else {
307
+ delete pkg.jest.extensionsToTreatAsEsm;
308
+ }
269
309
 
270
- if (shouldUseExperimentalVmModules) {
271
- pkg.jest.extensionsToTreatAsEsm = [
272
- transpileWithBabel && '.ts',
273
- transpileWithBabel && hasReact && '.tsx',
274
- ].filter(Boolean);
275
- } else {
276
- delete pkg.jest.extensionsToTreatAsEsm;
277
- }
310
+ if (
311
+ babelEnvs.length === 0 ||
312
+ babelEnvs.some((env) => env.target === 'node')
313
+ ) {
314
+ pkg.jest.testEnvironment = 'node';
315
+ } else {
316
+ delete pkg.jest.testEnvironment;
317
+ }
278
318
 
279
- if (
280
- babelEnvs.length === 0 ||
281
- babelEnvs.some((env) => env.target === 'node')
282
- ) {
283
- pkg.jest.testEnvironment = 'node';
319
+ if (!transpileWithBabel) delete pkg.jest.transform;
284
320
  } else {
285
- delete pkg.jest.testEnvironment;
321
+ delete pkg.jest;
286
322
  }
287
-
288
- if (!transpileWithBabel) delete pkg.jest.transform;
289
323
  }
290
324
  }
291
325
 
@@ -90,7 +90,7 @@ jobs:
90
90
  if: matrix.node-version != 18
91
91
 
92
92
  - name: Generate Test Coverage
93
- run: <%= packageManager %> run test --coverage --coverageReporters=json --coverageReporters=text
93
+ run: <%= packageManager %> run test:coverage
94
94
  if: matrix.node-version == 18
95
95
 
96
96
  - name: Send results to codecov
@@ -54,7 +54,7 @@ jobs:
54
54
  <% if (codecov) { -%>
55
55
 
56
56
  - name: Generate Test Coverage
57
- run: <%= packageManager %> run test --coverage --coverageReporters=json --coverageReporters=text
57
+ run: <%= packageManager %> run test:coverage
58
58
  if: startsWith(matrix.node-version, '18.')
59
59
  env:
60
60
  CI: true
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable camelcase */
2
2
 
3
- import fetch from 'node-fetch';
4
3
  import Generator from 'yeoman-generator';
5
4
  import { ciContexts } from '../../../ci/CoreCIGenerator.js';
6
5
  // const packageUtils = require('../../../../../utils/package');
@@ -170,9 +170,26 @@ export default class PobLibGenerator extends Generator {
170
170
  ? this.pobjson.documentation
171
171
  : true,
172
172
  },
173
+ {
174
+ type: 'checkbox',
175
+ name: 'runner',
176
+ message: 'Testing runner ?',
177
+ default: 'jest',
178
+ choices: [
179
+ {
180
+ name: 'Jest',
181
+ value: 'jest',
182
+ },
183
+ {
184
+ name: 'node:test',
185
+ value: 'node',
186
+ },
187
+ ],
188
+ },
173
189
  ]);
174
190
 
175
191
  this.pobjson.documentation = !!answers.documentation;
192
+ this.pobjson.runner = !!answers.runner;
176
193
  }
177
194
 
178
195
  // testing
@@ -248,6 +265,9 @@ export default class PobLibGenerator extends Generator {
248
265
  enable: this.pobjson.testing,
249
266
  enableReleasePlease,
250
267
  testing: this.pobjson.testing,
268
+ runner: this.pobjson.testing
269
+ ? this.pobjson.testing.runner || 'jest'
270
+ : undefined,
251
271
  build: withBabel,
252
272
  typescript: withBabel,
253
273
  documentation: !!this.pobjson.documentation,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "11.9.0",
3
+ "version": "12.0.0",
4
4
  "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
5
5
  "keywords": [
6
6
  "skeleton"
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "type": "module",
20
20
  "engines": {
21
- "node": ">=16.0.0"
21
+ "node": ">=18.0.0"
22
22
  },
23
23
  "main": "./lib/index.js",
24
24
  "exports": {
@@ -44,7 +44,7 @@
44
44
  "@pob/sort-eslint-config": "4.1.1",
45
45
  "@pob/sort-object": "5.1.1",
46
46
  "@pob/sort-pkg": "5.2.0",
47
- "eslint": "8.37.0",
47
+ "eslint": "8.38.0",
48
48
  "findup-sync": "^5.0.0",
49
49
  "git-remote-url": "^1.0.1",
50
50
  "github-username": "^6.0.0",
@@ -56,16 +56,15 @@
56
56
  "mem-fs": "2.3.0",
57
57
  "mem-fs-editor": "9.7.0",
58
58
  "minimist": "1.2.8",
59
- "node-fetch": "3.3.1",
60
59
  "parse-author": "2.0.0",
61
- "pob-dependencies": "7.7.0",
60
+ "pob-dependencies": "7.8.0",
62
61
  "prettier": "2.8.7",
63
- "semver": "7.3.8",
62
+ "semver": "7.5.0",
64
63
  "yeoman-environment": "3.15.1",
65
64
  "yeoman-generator": "5.8.0"
66
65
  },
67
66
  "devDependencies": {
68
- "@pob/root": "7.7.0"
67
+ "@pob/root": "7.8.0"
69
68
  },
70
- "gitHead": "512ed98cfd994cae7ceb9717f70caa1f87012449"
69
+ "gitHead": "efa1629282be7a06f88a2b2c84b87e56c6ea3d30"
71
70
  }