pob 17.2.1 → 17.4.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,35 @@
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
+ ## [17.4.0](https://github.com/christophehurpeau/pob/compare/pob@17.3.0...pob@17.4.0) (2023-12-28)
7
+
8
+
9
+ ### Features
10
+
11
+ * **deps:** update @pob/eslint-config to v53 (major) ([#1886](https://github.com/christophehurpeau/pob/issues/1886)) ([de65f51](https://github.com/christophehurpeau/pob/commit/de65f51549afac0be03a124dba04dbb3a76f1b4e))
12
+ * **deps:** update dependency @pob/eslint-config-typescript to v53.1.0 ([#1887](https://github.com/christophehurpeau/pob/issues/1887)) ([cca20c4](https://github.com/christophehurpeau/pob/commit/cca20c4e44aafdf05ba7928e02b290d2445d00cb))
13
+ * keep configuring ts-node and typescript for ts without babel ([8483dc0](https://github.com/christophehurpeau/pob/commit/8483dc080170befe5a3be3e4dfc8fe7d8e74d0ae))
14
+
15
+ Version bump for dependency: yarn-workspace-utils
16
+
17
+
18
+ ## [17.3.0](https://github.com/christophehurpeau/pob/compare/pob@17.2.1...pob@17.3.0) (2023-12-28)
19
+
20
+
21
+ ### Features
22
+
23
+ * configure declarationDir ([338a4dc](https://github.com/christophehurpeau/pob/commit/338a4dc7a642e9f8c24f953d5368745467578a38))
24
+ * use ts-node if needed with rollup-typescript ([9aefca2](https://github.com/christophehurpeau/pob/commit/9aefca2f69ba7bf2ff6f142e5156937d1c9e47fe))
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * add srcdirectory for glob tests ([3902bbd](https://github.com/christophehurpeau/pob/commit/3902bbdc088293df17a328687661a3dcb0a0c2a3))
30
+ * add TS_NODE_PROJECT ([f67673b](https://github.com/christophehurpeau/pob/commit/f67673bd35a4ee84965de229266d5b944f8c49ef))
31
+
32
+ Version bump for dependency: root
33
+
34
+
6
35
  ## [17.2.1](https://github.com/christophehurpeau/pob/compare/pob@17.2.0...pob@17.2.1) (2023-12-27)
7
36
 
8
37
 
@@ -265,6 +265,7 @@ export default class PobAppGenerator extends Generator {
265
265
  isApp: true,
266
266
  documentation: false,
267
267
  testing: this.appConfig.testing,
268
+ testRunner: this.appConfig.testRunner,
268
269
  babel,
269
270
  typescript,
270
271
  node,
@@ -45,6 +45,12 @@ export default class CommonLintGenerator extends Generator {
45
45
  required: true,
46
46
  desc: 'Testing enabled',
47
47
  });
48
+ this.option('testRunner', {
49
+ type: String,
50
+ required: false,
51
+ default: 'jest',
52
+ desc: 'test runner: jest | node',
53
+ });
48
54
 
49
55
  this.option('typescript', {
50
56
  type: Boolean,
@@ -402,7 +408,10 @@ export default class CommonLintGenerator extends Generator {
402
408
  this.options.testing || globalTesting
403
409
  ? {
404
410
  files: [`**/*.test.${ext}`, `__tests__/**/*.${ext}`],
405
- env: { jest: true },
411
+ ...(this.options.testRunner == null ||
412
+ this.options.testRunner === 'jest'
413
+ ? { env: { jest: true } }
414
+ : {}),
406
415
  rules: {
407
416
  'import/no-extraneous-dependencies': [
408
417
  'error',
@@ -419,6 +428,7 @@ export default class CommonLintGenerator extends Generator {
419
428
 
420
429
  if (useTypescript) {
421
430
  testsOverride.extends = ['@pob/eslint-config-typescript/test'];
431
+ delete testsOverride.rules['import/no-extraneous-dependencies'];
422
432
  }
423
433
  }
424
434
 
@@ -14,12 +14,21 @@ function updateOverrides(config, testsOverride) {
14
14
  }
15
15
  }
16
16
  } else {
17
- // eslint-disable-next-line no-lonely-if
17
+ if (testsOverride.rules && Object.keys(testsOverride.rules).length === 0) {
18
+ delete testsOverride.rules;
19
+ }
20
+
18
21
  if (existingTestsOverrideIndex !== -1) {
19
- Object.assign(
20
- config.overrides[existingTestsOverrideIndex],
21
- testsOverride,
22
- );
22
+ const existingTestsOverride =
23
+ config.overrides[existingTestsOverrideIndex];
24
+ Object.assign(existingTestsOverride, testsOverride);
25
+
26
+ if (
27
+ existingTestsOverride.rules &&
28
+ Object.keys(existingTestsOverride.rules).length === 0
29
+ ) {
30
+ delete existingTestsOverride.rules;
31
+ }
23
32
  } else {
24
33
  if (!config.overrides) config.overrides = [];
25
34
  config.overrides.push(testsOverride);
@@ -186,14 +186,59 @@ export default class CommonTestingGenerator extends Generator {
186
186
  this.fs.delete(this.destinationPath('jest.config.json'));
187
187
  }
188
188
 
189
+ const tsTestUtil = 'ts-node'; // : 'tsimp' | 'ts-node' | 'swc
190
+ const tsTestLoaderOption = (() => {
191
+ switch (tsTestUtil) {
192
+ case 'tsimp':
193
+ return '--import=tsimp/import';
194
+ case 'ts-node':
195
+ return '--loader=ts-node/esm --experimental-specifier-resolution=node';
196
+ case '@swc-node/register':
197
+ return '--import=@swc-node/register/esm';
198
+ }
199
+ })();
189
200
  packageUtils.addOrRemoveDevDependencies(
190
201
  pkg,
191
202
  this.options.enable &&
192
203
  this.options.runner === 'node' &&
193
204
  this.options.typescript,
194
- ['tsimp'],
205
+ [tsTestUtil],
195
206
  );
196
207
 
208
+ const createTestCommand = ({
209
+ coverage,
210
+ watch,
211
+ shouldUseExperimentalVmModules,
212
+ }) => {
213
+ switch (this.options.runner) {
214
+ case 'jest': {
215
+ return `${
216
+ shouldUseExperimentalVmModules
217
+ ? 'NODE_OPTIONS=--experimental-vm-modules '
218
+ : ''
219
+ }jest${watch ? ' --watch' : ''}${
220
+ coverage
221
+ ? ' --coverage --coverageReporters=json --coverageReporters=text'
222
+ : ''
223
+ }`;
224
+ }
225
+ case 'node': {
226
+ return `${tsTestUtil === 'tsimp' ? 'TSIMP_DIAG=ignore ' : ''}${
227
+ tsTestUtil === 'ts-node'
228
+ ? 'TS_NODE_PROJECT=tsconfig.test.json '
229
+ : ''
230
+ }node ${this.options.typescript ? `${tsTestLoaderOption} ` : ''}${
231
+ coverage ? ' --experimental-test-coverage' : ''
232
+ }--test ${this.options.srcDirectory}/${
233
+ this.options.typescript ? '**/*.test.ts' : '**/*.test.js'
234
+ }`;
235
+ }
236
+ default: {
237
+ throw new Error('Invalid runner');
238
+ }
239
+ }
240
+ };
241
+
197
242
  if (!this.options.enable) {
198
243
  // if (inMonorepo) {
199
244
  // if (pkg.scripts.test === 'echo "No tests"') {
@@ -227,26 +272,16 @@ export default class CommonTestingGenerator extends Generator {
227
272
  } else if (this.options.monorepo) {
228
273
  const shouldUseExperimentalVmModules = pkg.type === 'module';
229
274
 
230
- const testCommand =
231
- this.options.runner === 'jest'
232
- ? `${
233
- shouldUseExperimentalVmModules
234
- ? 'NODE_OPTIONS=--experimental-vm-modules '
235
- : ''
236
- }jest`
237
- : `node ${
238
- this.options.typescript ? '--import=tsimp/import ' : ''
239
- }--test ${
240
- this.options.typescript ? '**/*.test.ts' : '**/*.test.js'
241
- }`;
242
-
243
275
  packageUtils.addScripts(pkg, {
244
- test: testCommand,
245
- 'test:watch': `${testCommand} --watch`,
246
- 'test:coverage':
247
- this.options.runner === 'jest'
248
- ? `${testCommand} --coverage --coverageReporters=json --coverageReporters=text`
249
- : testCommand, // not yet configured
276
+ test: createTestCommand({ shouldUseExperimentalVmModules }),
277
+ 'test:watch': createTestCommand({
278
+ shouldUseExperimentalVmModules,
279
+ watch: true,
280
+ }),
281
+ 'test:coverage': createTestCommand({
282
+ shouldUseExperimentalVmModules,
283
+ coverage: true,
284
+ }),
250
285
  });
251
286
 
252
287
  if (isJestRunner) {
@@ -310,26 +345,16 @@ export default class CommonTestingGenerator extends Generator {
310
345
  const shouldUseExperimentalVmModules =
311
346
  pkg.type === 'module' && !inMonorepo;
312
347
 
313
- const testCommand =
314
- this.options.runner === 'jest'
315
- ? `${
316
- shouldUseExperimentalVmModules
317
- ? 'NODE_OPTIONS=--experimental-vm-modules '
318
- : ''
319
- }jest`
320
- : `node ${
321
- this.options.typescript ? '--import=tsimp/import ' : ''
322
- }--test ${
323
- this.options.typescript ? '**/*.test.ts' : '**/*.test.js'
324
- }`;
325
-
326
348
  packageUtils.addScripts(pkg, {
327
- test: testCommand,
328
- 'test:watch': `${testCommand} --watch`,
329
- 'test:coverage':
330
- this.options.runner === 'jest'
331
- ? `${testCommand} --coverage --coverageReporters=json --coverageReporters=text`
332
- : testCommand, // not yet configured,
349
+ test: createTestCommand({ shouldUseExperimentalVmModules }),
350
+ 'test:watch': createTestCommand({
351
+ shouldUseExperimentalVmModules,
352
+ watch: true,
353
+ }),
354
+ 'test:coverage': createTestCommand({
355
+ shouldUseExperimentalVmModules,
356
+ coverage: true,
357
+ }),
333
358
  });
334
359
 
335
360
  if (this.options.runner === 'jest') {
@@ -232,9 +232,9 @@ export default class CommonTranspilerGenerator extends Generator {
232
232
  // see pkg.exports instead.
233
233
  delete pkg.main;
234
234
  if (!this.options.isApp) {
235
- pkg.types = `./${this.options.buildDirectory}/${
236
- withTypescript && !useRollup ? '' : 'definitions/'
237
- }index.d.ts`;
235
+ pkg.types = `./${
236
+ this.options.buildDirectory
237
+ }/${'definitions/'}index.d.ts`;
238
238
  }
239
239
  } else {
240
240
  if (!pkg.main) {
@@ -264,7 +264,15 @@ export default class CommonTranspilerGenerator extends Generator {
264
264
  delete pkg['browser-dev'];
265
265
  delete pkg['module-dev'];
266
266
 
267
- const esAllBrowserEnv = this.babelEnvs.find(
267
+ const envs = pkg.pob.babelEnvs ||
268
+ pkg.pob.envs || [
269
+ {
270
+ target: 'node',
271
+ version: '18',
272
+ },
273
+ ];
274
+
275
+ const esAllBrowserEnv = envs.find(
268
276
  (env) =>
269
277
  env.target === 'browser' &&
270
278
  env.version === undefined &&
@@ -298,7 +306,7 @@ export default class CommonTranspilerGenerator extends Generator {
298
306
  const isBrowserOnly =
299
307
  withBabel &&
300
308
  entry === 'browser' &&
301
- (this.babelEnvs.every((env) => env.target === 'browser') ||
309
+ (envs?.every((env) => env.target === 'browser') ||
302
310
  (this.entries.length === 2 && this.entries.includes('index')));
303
311
  const entryDistName = isBrowserOnly ? 'index' : entry;
304
312
  const exportName = entry === 'index' ? '.' : `./${entry}`;
@@ -313,73 +321,67 @@ export default class CommonTranspilerGenerator extends Generator {
313
321
  };
314
322
 
315
323
  const defaultNodeEnv =
316
- withBabel && this.babelEnvs.find((env) => env.target === 'node');
324
+ withBabel || withTypescript
325
+ ? envs.find((env) => env.target === 'node')
326
+ : undefined;
317
327
 
318
328
  const defaultNodeEnvVersion = defaultNodeEnv && defaultNodeEnv.version;
319
329
 
320
- if (withTypescript) {
321
- if (useRollup) {
322
- targets.import = `./${this.options.buildDirectory}/${entryDistName}-node.mjs`;
323
- } else {
324
- targets.import = `./${this.options.buildDirectory}/${entryDistName}.js`;
325
- }
326
- } else {
327
- this.babelEnvs.forEach(({ target, version, formats }) => {
328
- if (target === 'node' && entry === 'browser') return;
329
-
330
- const exportTarget = {};
331
-
332
- if (target === 'node') {
333
- const cjsExt = pkg.type === 'module' ? 'cjs' : 'cjs.js';
334
- if (!formats || formats.includes('es')) {
335
- exportTarget.import = `./${this.options.buildDirectory}/${entryDistName}-${target}${version}.mjs`;
336
-
337
- if (formats && formats.includes('cjs')) {
338
- exportTarget.require = `./${this.options.buildDirectory}/${entryDistName}-${target}${version}.${cjsExt}`;
339
- }
340
- } else if (formats && formats.includes('cjs')) {
341
- exportTarget.default = `./${this.options.buildDirectory}/${entryDistName}-${target}${version}.${cjsExt}`;
342
- }
343
- // eslint: https://github.com/benmosher/eslint-plugin-import/issues/2132
344
- // jest: https://github.com/facebook/jest/issues/9771
345
- if (!pkg.main && exportName === '.') {
346
- pkg.main =
347
- pkg.type === 'module'
348
- ? exportTarget.import
349
- : exportTarget.default ||
350
- exportTarget.require ||
351
- exportTarget.import;
352
- }
353
- } else if (target === 'browser') {
354
- if (!formats || formats.includes('es')) {
355
- exportTarget.import = `./${
356
- this.options.buildDirectory
357
- }/${entryDistName}-${target}${version || ''}.es.js`;
358
- }
330
+ envs.forEach(({ target, version, formats }) => {
331
+ if (target === 'node' && entry === 'browser') return;
332
+
333
+ const exportTarget = {};
334
+
335
+ if (target === 'node') {
336
+ const cjsExt = pkg.type === 'module' ? 'cjs' : 'cjs.js';
337
+ if (!formats || formats.includes('es')) {
338
+ exportTarget.import = `./${this.options.buildDirectory}/${entryDistName}-${target}${version}.mjs`;
359
339
 
360
340
  if (formats && formats.includes('cjs')) {
361
- exportTarget.require = `./${
362
- this.options.buildDirectory
363
- }/index-${target}${version || ''}.cjs.js`;
341
+ exportTarget.require = `./${this.options.buildDirectory}/${entryDistName}-${target}${version}.${cjsExt}`;
364
342
  }
343
+ } else if (formats && formats.includes('cjs')) {
344
+ exportTarget.default = `./${this.options.buildDirectory}/${entryDistName}-${target}${version}.${cjsExt}`;
345
+ }
346
+ // eslint: https://github.com/benmosher/eslint-plugin-import/issues/2132
347
+ // jest: https://github.com/facebook/jest/issues/9771
348
+ if (!pkg.main && exportName === '.') {
349
+ pkg.main =
350
+ pkg.type === 'module'
351
+ ? exportTarget.import
352
+ : exportTarget.default ||
353
+ exportTarget.require ||
354
+ exportTarget.import;
355
+ }
356
+ } else if (target === 'browser') {
357
+ if (!formats || formats.includes('es')) {
358
+ exportTarget.import = `./${
359
+ this.options.buildDirectory
360
+ }/${entryDistName}-${target}${version || ''}.es.js`;
365
361
  }
366
362
 
367
- if (
368
- !version ||
369
- (target === 'node' && version === defaultNodeEnvVersion)
370
- ) {
371
- targets[target] = {
372
- ...targets[target],
373
- ...exportTarget,
374
- };
375
- } else {
376
- targets[target] = {
377
- [`${target}:${version}`]: exportTarget,
378
- ...targets[target],
379
- };
363
+ if (formats && formats.includes('cjs')) {
364
+ exportTarget.require = `./${
365
+ this.options.buildDirectory
366
+ }/index-${target}${version || ''}.cjs.js`;
380
367
  }
381
- });
382
- }
368
+ }
369
+
370
+ if (
371
+ !version ||
372
+ (target === 'node' && version === defaultNodeEnvVersion)
373
+ ) {
374
+ targets[target] = {
375
+ ...targets[target],
376
+ ...exportTarget,
377
+ };
378
+ } else {
379
+ targets[target] = {
380
+ [`${target}:${version}`]: exportTarget,
381
+ ...targets[target],
382
+ };
383
+ }
384
+ });
383
385
 
384
386
  pkg.exports[exportName] = targets;
385
387
  });
@@ -125,7 +125,12 @@ export default class CommonTypescriptGenerator extends Generator {
125
125
  }
126
126
  if (withTypescript) {
127
127
  const nodeVersion = this.options.onlyLatestLTS ? '20' : '18';
128
- const envs = pkg.pob?.envs;
128
+ const envs = pkg.pob?.envs || [
129
+ {
130
+ target: 'node',
131
+ version: '18',
132
+ },
133
+ ];
129
134
  if (pkg.pob.rollup === false) {
130
135
  return [`@pob/root/tsconfigs/targets/node-${nodeVersion}.json`];
131
136
  }
@@ -21,6 +21,9 @@
21
21
  <% } -%>
22
22
  <% if (emitDefinitions || build) { -%>
23
23
  "outDir": "<%= build ? 'dist' : 'dist/definitions' %>",
24
+ <% if (build) { -%>
25
+ "declarationDir": "dist/definitions",
26
+ <% } -%>
24
27
  <% if (composite) {
25
28
  // dont emit in dist/definitions to avoid publish to npm
26
29
  -%>
@@ -65,6 +65,7 @@ jobs:
65
65
  if: startsWith(matrix.node-version, '20.')
66
66
  env:
67
67
  CI: true
68
+ NODE_V8_COVERAGE: coverage/
68
69
 
69
70
  - name: Send results to codecov
70
71
  uses: codecov/codecov-action@v3
@@ -75,6 +75,7 @@ export default class CoreGitignoreGenerator extends Generator {
75
75
  documentation: this.options.documentation,
76
76
  testing: this.options.testing,
77
77
  withBabel,
78
+ tsTestUtil: 'ts-node',
78
79
  typescript: withBabel || this.options.typescript,
79
80
  paths: this.options.paths,
80
81
  buildInGit: this.options.buildInGit,
@@ -27,7 +27,7 @@ yarn-error.log*
27
27
  <% } -%>
28
28
  <% if (testing) { -%>
29
29
 
30
- <% if (typescript && !withBabel) { -%>
30
+ <% if (typescript && !withBabel && tsTestUtil === 'tsimp') { -%>
31
31
  # tsimp cache
32
32
  /.tsimp
33
33
  <% } -%>
@@ -296,6 +296,7 @@ export default class PobLibGenerator extends Generator {
296
296
  !!this.pobjson.documentation ||
297
297
  !!(this.pobjson.testing && this.pobjson.testing.codecov),
298
298
  testing: !!this.pobjson.testing,
299
+ testRunner: this.pobjson.testing?.runner,
299
300
  packageManager: this.options.packageManager,
300
301
  yarnNodeLinker: this.options.yarnNodeLinker,
301
302
  ignorePaths: withBabel || withTypescript ? '/dist' : '',
@@ -246,6 +246,7 @@ export default class PobMonorepoGenerator extends Generator {
246
246
  documentation: this.pobLernaConfig.documentation,
247
247
  typescript: this.pobLernaConfig.typescript,
248
248
  testing: this.pobLernaConfig.testing,
249
+ testRunner: this.pobLernaConfig.testRunner,
249
250
  packageManager: this.options.packageManager,
250
251
  yarnNodeLinker: this.options.yarnNodeLinker,
251
252
  appTypes: JSON.stringify(getAppTypes(this.packageConfigs)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "17.2.1",
3
+ "version": "17.4.0",
4
4
  "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
5
5
  "keywords": [
6
6
  "skeleton"
@@ -39,9 +39,9 @@
39
39
  "prettier": "@pob/root/prettier-config",
40
40
  "pob": {},
41
41
  "dependencies": {
42
- "@pob/eslint-config": "51.2.2",
43
- "@pob/eslint-config-typescript": "51.2.2",
44
- "@pob/eslint-config-typescript-react": "51.2.2",
42
+ "@pob/eslint-config": "53.0.0",
43
+ "@pob/eslint-config-typescript": "53.1.0",
44
+ "@pob/eslint-config-typescript-react": "53.0.0",
45
45
  "@pob/sort-eslint-config": "5.2.0",
46
46
  "@pob/sort-object": "6.2.0",
47
47
  "@pob/sort-pkg": "6.2.0",
@@ -62,15 +62,15 @@
62
62
  "mem-fs-editor": "11.0.0",
63
63
  "minimist": "1.2.8",
64
64
  "parse-author": "2.0.0",
65
- "pob-dependencies": "10.2.0",
65
+ "pob-dependencies": "10.4.0",
66
66
  "prettier": "2.8.8",
67
67
  "semver": "7.5.4",
68
68
  "validate-npm-package-name": "^5.0.0",
69
- "yarn-workspace-utils": "3.0.0",
69
+ "yarn-workspace-utils": "3.1.0",
70
70
  "yeoman-environment": "4.1.3",
71
71
  "yeoman-generator": "7.1.1"
72
72
  },
73
73
  "devDependencies": {
74
- "@pob/root": "8.11.1"
74
+ "@pob/root": "8.12.0"
75
75
  }
76
76
  }