pob 17.4.0 → 18.1.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,45 @@
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
+ ## [18.1.0](https://github.com/christophehurpeau/pob/compare/pob@18.0.0...pob@18.1.0) (2023-12-29)
7
+
8
+
9
+ ### Features
10
+
11
+ * enable typescript-eslint EXPERIMENTAL_useProjectService option ([4bccf68](https://github.com/christophehurpeau/pob/commit/4bccf68b4f743dba5211432ea1dba056e901bc93))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * fix package.type for app library ([d5df9d7](https://github.com/christophehurpeau/pob/commit/d5df9d72f2325c042e3ff2d610a2d3d4c378c950))
17
+
18
+
19
+
20
+
21
+ ## [18.0.0](https://github.com/christophehurpeau/pob/compare/pob@17.4.0...pob@18.0.0) (2023-12-29)
22
+
23
+
24
+ ### Features
25
+
26
+ * improve tsconfigs ([9112fb1](https://github.com/christophehurpeau/pob/commit/9112fb13dd1ed9ab5191a39c92140a0d8653ff3a))
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * fix documentation lcov ([ff6166f](https://github.com/christophehurpeau/pob/commit/ff6166f77ad4faf6039d0dc69337ac6e20fa10af))
32
+ * fix experimental-test-coverage option ([d598efd](https://github.com/christophehurpeau/pob/commit/d598efd3818cd1e26dfb34f4f636bc2469400fe7))
33
+ * fix test override existing detection ([744d556](https://github.com/christophehurpeau/pob/commit/744d5569541d27c5c4beee84a620f0e40f369b29))
34
+ * **pob:** fix node test runner coverage ([e9ba7b1](https://github.com/christophehurpeau/pob/commit/e9ba7b1f035bb318fe9e20cddd93df295a4df1d1))
35
+ * **pob:** fix test override existing detection ([5916c16](https://github.com/christophehurpeau/pob/commit/5916c16162a28e333410315d8d82fbf3bea2f5cc))
36
+ * **pob:** update test runner ([29f7f0c](https://github.com/christophehurpeau/pob/commit/29f7f0c539401fcb9086fa913beb7935da7a8857))
37
+
38
+ Version bump for dependency: sort-eslint-config
39
+ Version bump for dependency: sort-object
40
+ Version bump for dependency: sort-pkg
41
+ Version bump for dependency: yarn-workspace-utils
42
+ Version bump for dependency: root
43
+
44
+
6
45
  ## [17.4.0](https://github.com/christophehurpeau/pob/compare/pob@17.3.0...pob@17.4.0) (2023-12-28)
7
46
 
8
47
 
@@ -157,6 +157,7 @@ export default class PobAppGenerator extends Generator {
157
157
  testing: this.appConfig.testing,
158
158
  documentation: false,
159
159
  fromPob: this.options.fromPob,
160
+ srcDirectory,
160
161
  buildDirectory: 'build',
161
162
  });
162
163
  }
@@ -193,6 +194,7 @@ export default class PobAppGenerator extends Generator {
193
194
  enable: typescript,
194
195
  isApp: true,
195
196
  isAppLibrary,
197
+ nextConfig: this.appConfig.type === 'next.js',
196
198
  // nextjs now supports src
197
199
  rootDir: this.appConfig.type === 'expo' ? '.' : srcDirectory,
198
200
  srcDirectory,
@@ -4,7 +4,9 @@ function updateOverrides(config, testsOverride) {
4
4
  const existingTestsOverrideIndex = !config.overrides
5
5
  ? -1
6
6
  : config.overrides.findIndex(
7
- (override) => override.env && override.env.jest,
7
+ testsOverride.env?.jest
8
+ ? (override) => override.env && override.env.jest
9
+ : (override) => override.extends.includes(testsOverride.extends[0]),
8
10
  );
9
11
  if (!testsOverride) {
10
12
  if (existingTestsOverrideIndex !== -1) {
@@ -55,6 +57,8 @@ function updateParserAndPlugins(
55
57
  };
56
58
  } else {
57
59
  config.parserOptions = {
60
+ // eslint-disable-next-line camelcase
61
+ EXPERIMENTAL_useProjectService: true,
58
62
  project: `${relativePath}/tsconfig.json`,
59
63
  };
60
64
  }
@@ -123,6 +123,7 @@ export default class CommonTestingGenerator extends Generator {
123
123
  enableYarnVersion: this.options.enableYarnVersion,
124
124
  disableYarnGitCache: this.options.disableYarnGitCache,
125
125
  testing: this.options.enable,
126
+ testRunner: this.options.runner,
126
127
  e2eTesting: this.options.e2eTesting,
127
128
  build: this.options.build,
128
129
  typescript: this.options.typescript,
@@ -207,6 +208,8 @@ export default class CommonTestingGenerator extends Generator {
207
208
 
208
209
  const createTestCommand = ({
209
210
  coverage,
211
+ coverageLcov,
212
+ coverageJson,
210
213
  watch,
211
214
  shouldUseExperimentalVmModules,
212
215
  }) => {
@@ -217,8 +220,14 @@ export default class CommonTestingGenerator extends Generator {
217
220
  ? 'NODE_OPTIONS=--experimental-vm-modules '
218
221
  : ''
219
222
  }jest${watch ? ' --watch' : ''}${
220
- coverage
221
- ? ' --coverage --coverageReporters=json --coverageReporters=text'
223
+ coverage || coverageJson || coverageLcov
224
+ ? ` --coverage ${
225
+ coverageLcov
226
+ ? '--coverageReporters=lcov'
227
+ : `--coverageReporters=json${
228
+ coverageJson ? '' : ' --coverageReporters=text'
229
+ }`
230
+ }`
222
231
  : ''
223
232
  }`;
224
233
  }
@@ -227,8 +236,16 @@ export default class CommonTestingGenerator extends Generator {
227
236
  tsTestUtil === 'ts-node'
228
237
  ? 'TS_NODE_PROJECT=tsconfig.test.json '
229
238
  : ''
230
- }node ${this.options.typescript ? `${tsTestLoaderOption} ` : ''}${
231
- coverage ? ' --experimental-test-coverage' : ''
239
+ }${
240
+ coverage || coverageJson || coverageLcov
241
+ ? `npx c8${
242
+ coverageLcov || coverageJson
243
+ ? ` --reporter=${coverageJson ? 'json' : 'lcov'}`
244
+ : ''
245
+ } --src ./${this.options.srcDirectory} `
246
+ : ''
247
+ }node ${
248
+ this.options.typescript ? `${tsTestLoaderOption} ` : ''
232
249
  }--test ${this.options.srcDirectory}/${
233
250
  this.options.typescript ? '**/*.test.ts' : '**/*.test.js'
234
251
  }`;
@@ -251,6 +268,8 @@ export default class CommonTestingGenerator extends Generator {
251
268
  delete pkg.scripts['generate:test-coverage'];
252
269
  delete pkg.scripts['test:watch'];
253
270
  delete pkg.scripts['test:coverage'];
271
+ delete pkg.scripts['test:coverage:json'];
272
+ delete pkg.scripts['test:coverage:lcov'];
254
273
  }
255
274
 
256
275
  writeAndFormatJson(this.fs, this.destinationPath('package.json'), pkg);
@@ -282,6 +301,14 @@ export default class CommonTestingGenerator extends Generator {
282
301
  shouldUseExperimentalVmModules,
283
302
  coverage: true,
284
303
  }),
304
+ 'test:coverage:lcov': createTestCommand({
305
+ shouldUseExperimentalVmModules,
306
+ coverageLcov: true,
307
+ }),
308
+ 'test:coverage:json': createTestCommand({
309
+ shouldUseExperimentalVmModules,
310
+ coverageJson: true,
311
+ }),
285
312
  });
286
313
 
287
314
  if (isJestRunner) {
@@ -355,6 +382,14 @@ export default class CommonTestingGenerator extends Generator {
355
382
  shouldUseExperimentalVmModules,
356
383
  coverage: true,
357
384
  }),
385
+ 'test:coverage:lcov': createTestCommand({
386
+ shouldUseExperimentalVmModules,
387
+ coverageLcov: true,
388
+ }),
389
+ 'test:coverage:json': createTestCommand({
390
+ shouldUseExperimentalVmModules,
391
+ coverageJson: true,
392
+ }),
358
393
  });
359
394
 
360
395
  if (this.options.runner === 'jest') {
@@ -46,6 +46,12 @@ export default class CommonTranspilerGenerator extends Generator {
46
46
  default: false,
47
47
  });
48
48
 
49
+ this.option('srcDirectory', {
50
+ type: String,
51
+ required: false,
52
+ default: 'src',
53
+ });
54
+
49
55
  this.option('buildDirectory', {
50
56
  type: String,
51
57
  required: false,
@@ -219,7 +225,7 @@ export default class CommonTranspilerGenerator extends Generator {
219
225
 
220
226
  /* main / aliases / typing */
221
227
 
222
- if (this.options.isApp) {
228
+ if (this.options.isApp && !this.options.isAppLibrary) {
223
229
  delete pkg.types;
224
230
  delete pkg.typings;
225
231
  } else if (pkg.typings) {
@@ -235,6 +241,8 @@ export default class CommonTranspilerGenerator extends Generator {
235
241
  pkg.types = `./${
236
242
  this.options.buildDirectory
237
243
  }/${'definitions/'}index.d.ts`;
244
+ } else if (this.options.isAppLibrary) {
245
+ pkg.types = `./${this.options.srcDirectory}/${'definitions/'}index.ts`;
238
246
  }
239
247
  } else {
240
248
  if (!pkg.main) {
@@ -245,7 +253,7 @@ export default class CommonTranspilerGenerator extends Generator {
245
253
  } else {
246
254
  pkg.main = './lib/index.js';
247
255
  }
248
- if (!this.options.isApp) {
256
+ if (!this.options.isApp || this.options.isAppLibrary) {
249
257
  if (this.fs.exists('./lib/index.ts')) {
250
258
  pkg.types = './lib/index.ts';
251
259
  } else if (this.fs.exists('./lib/index.d.ts') || pkg.types) {
@@ -90,6 +90,10 @@ export default class CommonTypescriptGenerator extends Generator {
90
90
  default: '',
91
91
  desc: 'typescript plugins',
92
92
  });
93
+ this.option('nextConfig', {
94
+ type: Boolean,
95
+ default: false,
96
+ });
93
97
  this.option('additionalIncludes', {
94
98
  type: String,
95
99
  default: '',
@@ -141,6 +145,10 @@ export default class CommonTypescriptGenerator extends Generator {
141
145
  }
142
146
  return ['@pob/root/tsconfigs/targets/rollup-es2015.json'];
143
147
  }
148
+
149
+ if (this.options.dom) {
150
+ return ['@pob/root/tsconfigs/targets/webpack.json'];
151
+ }
144
152
  return [];
145
153
  })();
146
154
 
@@ -258,6 +266,7 @@ export default class CommonTypescriptGenerator extends Generator {
258
266
  srcDirectory: this.options.srcDirectory || this.options.rootDir,
259
267
  jsx,
260
268
  jsxPreserve: this.options.jsxPreserve,
269
+ nextConfig: this.options.nextConfig,
261
270
  composite,
262
271
  dom,
263
272
  baseUrl: this.options.baseUrl,
@@ -62,6 +62,17 @@
62
62
  <% if(forceAllowJs) { -%>
63
63
  "allowJs": true,
64
64
  <% } -%>
65
+ <% if(nextConfig) { -%>
66
+ "strictNullChecks": true,
67
+ "module": "esnext",
68
+ "moduleResolution": "node",
69
+ "lib": ["dom", "esnext"],
70
+ "esModuleInterop": true,
71
+ "isolatedModules": true,
72
+ <% } -%>
73
+ <% if (resolveJsonModule) { -%>
74
+ "resolveJsonModule": <%= resolveJsonModule %>,
75
+ <% } -%>
65
76
  <% if(plugins && plugins.length > 0) { -%>
66
77
  "plugins": [<%- plugins.map((pluginName) => `{"name": "${pluginName}"}`).join(', ') %>],
67
78
  <% } -%>
@@ -69,9 +80,6 @@
69
80
  <% if(!presets || presets.length === 0) { -%>
70
81
  /* Module Resolution Options */
71
82
  "moduleResolution": "bundler" /* Specify module resolution strategy. */,
72
- <% if (resolveJsonModule) { -%>
73
- "resolveJsonModule": <%= resolveJsonModule %>,
74
- <% } -%>
75
83
  "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
76
84
  "esModuleInterop": true<% if (monorepoPackageSrcPaths) { %>,<% } %> /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
77
85
  <% } -%>
@@ -45,6 +45,12 @@ export default class CoreCIGenerator extends Generator {
45
45
  default: true,
46
46
  desc: 'enable testing',
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('e2eTesting', {
50
56
  type: String,
@@ -204,6 +210,7 @@ export default class CoreCIGenerator extends Generator {
204
210
  packageManager: this.options.packageManager,
205
211
  disableYarnGitCache: this.options.disableYarnGitCache,
206
212
  testing: this.options.testing,
213
+ testRunner: this.options.testRunner,
207
214
  typedoc: this.options.documentation && this.options.typescript,
208
215
  },
209
216
  );
@@ -32,9 +32,10 @@ jobs:
32
32
  run: yarn typedoc --tsconfig tsconfig.doc.json
33
33
  <% } -%>
34
34
 
35
- <% if (testing) { -%>
35
+ <% if (testing && testRunner === 'jest') { -%>
36
+
36
37
  - name: Generate Coverage
37
- run: yarn test --coverage --coverageReporters=lcov --coverageDirectory=docs/coverage/
38
+ run: yarn test:coverage:lcov --coverageDirectory=docs/coverage/
38
39
  <% } -%>
39
40
 
40
41
  - name: Create nojekyll
@@ -61,7 +61,7 @@ jobs:
61
61
  <% if (codecov) { -%>
62
62
 
63
63
  - name: Generate Test Coverage
64
- run: <%= packageManager %> run test:coverage
64
+ run: <%= packageManager %> run test:coverage:json
65
65
  if: startsWith(matrix.node-version, '20.')
66
66
  env:
67
67
  CI: true
@@ -162,22 +162,49 @@ export default class PobLibGenerator extends Generator {
162
162
  // documentation
163
163
  if (inMonorepo && !inMonorepo.root) {
164
164
  this.pobjson.documentation = false;
165
- } else if (!this.updateOnly) {
165
+ } else {
166
166
  const answers = await this.prompt([
167
167
  {
168
168
  type: 'confirm',
169
169
  name: 'documentation',
170
170
  message: 'Would you like documentation (manually generated) ?',
171
+ when: !this.updateOnly || this.pobjson.documentation === undefined,
171
172
  default:
172
173
  this.pobjson.documentation != null
173
174
  ? this.pobjson.documentation
174
175
  : true,
175
176
  },
177
+ ]);
178
+
179
+ Object.assign(this.pobjson, answers);
180
+ }
181
+
182
+ // testing
183
+ if (!this.updateOnly || this.pobjson.testing === undefined) {
184
+ const { testing } = await this.prompt({
185
+ type: 'confirm',
186
+ name: 'testing',
187
+ message: 'Would you like testing ?',
188
+ default: this.pobjson.testing || false,
189
+ });
190
+ this.pobjson.testing = !testing ? false : this.pobjson.testing || {};
191
+ }
192
+
193
+ if (this.pobjson.testing && !(inMonorepo || inMonorepo.root)) {
194
+ const testingPrompts = await this.prompt([
195
+ {
196
+ type: 'confirm',
197
+ name: 'ci',
198
+ message: 'Would you like ci with github actions ?',
199
+ when: !this.updateOnly || this.pobjson.testing?.ci === undefined,
200
+ default: this.pobjson.testing.ci !== false,
201
+ },
176
202
  {
177
- type: 'checkbox',
203
+ type: 'list',
178
204
  name: 'runner',
179
205
  message: 'Testing runner ?',
180
- default: 'jest',
206
+ when: !this.updateOnly || this.pobjson.testing?.runner === undefined,
207
+ default: this.pobjson.testing?.runner || 'jest',
181
208
  choices: [
182
209
  {
183
210
  name: 'Jest',
@@ -189,39 +216,15 @@ export default class PobLibGenerator extends Generator {
189
216
  },
190
217
  ],
191
218
  },
219
+ {
220
+ type: 'confirm',
221
+ name: 'codecov',
222
+ message: 'Would you like codecov ?',
223
+ when: !this.updateOnly || this.pobjson.testing?.codecov === undefined,
224
+ default: this.pobjson.testing.codecov === true,
225
+ },
192
226
  ]);
193
-
194
- this.pobjson.documentation = !!answers.documentation;
195
- this.pobjson.runner = !!answers.runner;
196
- }
197
-
198
- // testing
199
- if (!this.updateOnly) {
200
- const { testing } = await this.prompt({
201
- type: 'confirm',
202
- name: 'testing',
203
- message: 'Would you like testing ?',
204
- default: this.pobjson.testing || false,
205
- });
206
- this.pobjson.testing = !testing ? false : this.pobjson.testing || {};
207
-
208
- if (this.pobjson.testing && !(inMonorepo || inMonorepo.root)) {
209
- const testingPrompts = await this.prompt([
210
- {
211
- type: 'confirm',
212
- name: 'ci',
213
- message: 'Would you like ci with github actions ?',
214
- default: this.pobjson.testing.ci !== false,
215
- },
216
- {
217
- type: 'confirm',
218
- name: 'codecov',
219
- message: 'Would you like codecov ?',
220
- default: this.pobjson.testing.codecov === true,
221
- },
222
- ]);
223
- Object.assign(this.pobjson.testing, testingPrompts);
224
- }
227
+ Object.assign(this.pobjson.testing, testingPrompts);
225
228
  }
226
229
 
227
230
  this.fs.writeJSON(this.destinationPath('package.json'), pkg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "17.4.0",
3
+ "version": "18.1.0",
4
4
  "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
5
5
  "keywords": [
6
6
  "skeleton"
@@ -20,13 +20,13 @@
20
20
  "engines": {
21
21
  "node": ">=18.12.0"
22
22
  },
23
+ "sideEffects": false,
24
+ "bin": "./lib/pob.js",
23
25
  "main": "./lib/index.js",
24
26
  "exports": {
25
27
  ".": "./lib/index.js",
26
28
  "./package.json": "./package.json"
27
29
  },
28
- "sideEffects": false,
29
- "bin": "./lib/pob.js",
30
30
  "files": [
31
31
  "lib",
32
32
  "bin"
@@ -36,15 +36,15 @@
36
36
  "lint": "yarn run lint:eslint",
37
37
  "lint:eslint": "yarn ../.. run eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet packages/pob"
38
38
  },
39
- "prettier": "@pob/root/prettier-config",
40
39
  "pob": {},
40
+ "prettier": "@pob/root/prettier-config",
41
41
  "dependencies": {
42
42
  "@pob/eslint-config": "53.0.0",
43
43
  "@pob/eslint-config-typescript": "53.1.0",
44
44
  "@pob/eslint-config-typescript-react": "53.0.0",
45
- "@pob/sort-eslint-config": "5.2.0",
46
- "@pob/sort-object": "6.2.0",
47
- "@pob/sort-pkg": "6.2.0",
45
+ "@pob/sort-eslint-config": "5.2.1",
46
+ "@pob/sort-object": "6.2.1",
47
+ "@pob/sort-pkg": "7.0.0",
48
48
  "@types/inquirer": "9.0.7",
49
49
  "@yarnpkg/cli": "4.0.2",
50
50
  "@yarnpkg/core": "4.0.2",
@@ -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.4.0",
65
+ "pob-dependencies": "11.0.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.1.0",
69
+ "yarn-workspace-utils": "3.1.1",
70
70
  "yeoman-environment": "4.1.3",
71
71
  "yeoman-generator": "7.1.1"
72
72
  },
73
73
  "devDependencies": {
74
- "@pob/root": "8.12.0"
74
+ "@pob/root": "9.0.0"
75
75
  }
76
76
  }