pob 19.1.1 → 20.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/lib/generators/app/PobAppGenerator.js +120 -120
  3. package/lib/generators/app/e2e-testing/AppE2ETestingGenerator.js +11 -11
  4. package/lib/generators/app/ignorePaths.js +24 -24
  5. package/lib/generators/app/nextjs/AppNextjsGenerator.js +9 -9
  6. package/lib/generators/app/remix/AppRemixGenerator.js +7 -7
  7. package/lib/generators/common/babel/CommonBabelGenerator.js +146 -146
  8. package/lib/generators/common/format-lint/CommonLintGenerator.js +185 -185
  9. package/lib/generators/common/format-lint/updateEslintConfig.js +14 -15
  10. package/lib/generators/common/husky/CommonHuskyGenerator.js +44 -44
  11. package/lib/generators/common/old-dependencies/CommonRemoveOldDependenciesGenerator.js +44 -44
  12. package/lib/generators/common/release/CommonReleaseGenerator.js +40 -40
  13. package/lib/generators/common/testing/CommonTestingGenerator.js +190 -190
  14. package/lib/generators/common/testing/templates/index.js +3 -3
  15. package/lib/generators/common/transpiler/CommonTranspilerGenerator.js +163 -163
  16. package/lib/generators/common/typescript/CommonTypescriptGenerator.js +79 -79
  17. package/lib/generators/common/typescript/templates/tsconfig.js.json.ejs +12 -0
  18. package/lib/generators/core/ci/CoreCIGenerator.js +72 -72
  19. package/lib/generators/core/clean/CoreCleanGenerator.js +4 -4
  20. package/lib/generators/core/editorconfig/CoreEditorConfigGenerator.js +3 -3
  21. package/lib/generators/core/git/CoreGitGenerator.js +43 -43
  22. package/lib/generators/core/git/generators/github/CoreGitGithubGenerator.js +43 -43
  23. package/lib/generators/core/gitignore/CoreGitignoreGenerator.js +19 -19
  24. package/lib/generators/core/npm/CoreNpmGenerator.js +20 -20
  25. package/lib/generators/core/package/CorePackageGenerator.js +98 -98
  26. package/lib/generators/core/package/askName.js +4 -4
  27. package/lib/generators/core/renovate/CoreRenovateGenerator.js +28 -28
  28. package/lib/generators/core/sort-package/CoreSortPackageGenerator.js +6 -6
  29. package/lib/generators/core/vscode/CoreVSCodeGenerator.js +43 -43
  30. package/lib/generators/core/yarn/CoreYarnGenerator.js +70 -70
  31. package/lib/generators/lib/PobLibGenerator.js +111 -111
  32. package/lib/generators/lib/doc/LibDocGenerator.js +45 -45
  33. package/lib/generators/lib/readme/LibReadmeGenerator.js +21 -21
  34. package/lib/generators/monorepo/PobMonorepoGenerator.js +89 -89
  35. package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +47 -47
  36. package/lib/generators/monorepo/typescript/MonorepoTypescriptGenerator.js +38 -38
  37. package/lib/generators/monorepo/workspaces/MonorepoWorkspacesGenerator.js +57 -57
  38. package/lib/generators/pob/PobBaseGenerator.js +81 -81
  39. package/lib/pob-dirname.cjs +1 -1
  40. package/lib/pob.js +143 -143
  41. package/lib/utils/dependenciesPackages.cjs +4 -4
  42. package/lib/utils/ensureJsonFileFormatted.js +5 -5
  43. package/lib/utils/inMonorepo.js +8 -8
  44. package/lib/utils/json5.js +1 -1
  45. package/lib/utils/package.js +43 -43
  46. package/lib/utils/packagejson.cjs +2 -2
  47. package/lib/utils/templateUtils.js +1 -1
  48. package/lib/utils/writeAndFormat.js +9 -10
  49. package/package.json +10 -10
@@ -1,66 +1,66 @@
1
- import { rmSync } from 'node:fs';
2
- import Generator from 'yeoman-generator';
3
- import inMonorepo from '../../utils/inMonorepo.js';
4
- import * as packageUtils from '../../utils/package.js';
1
+ import { rmSync } from "node:fs";
2
+ import Generator from "yeoman-generator";
3
+ import inMonorepo from "../../utils/inMonorepo.js";
4
+ import * as packageUtils from "../../utils/package.js";
5
5
 
6
6
  export default class PobLibGenerator extends Generator {
7
7
  constructor(args, opts) {
8
8
  super(args, opts);
9
9
 
10
- this.option('updateOnly', {
10
+ this.option("updateOnly", {
11
11
  type: Boolean,
12
12
  required: false,
13
13
  default: false,
14
- desc: 'Avoid asking questions',
14
+ desc: "Avoid asking questions",
15
15
  });
16
16
 
17
- this.option('fromPob', {
17
+ this.option("fromPob", {
18
18
  type: Boolean,
19
19
  required: false,
20
20
  default: false,
21
21
  });
22
22
 
23
- this.option('packageManager', {
23
+ this.option("packageManager", {
24
24
  type: String,
25
- default: 'yarn',
26
- desc: 'yarn or npm',
25
+ default: "yarn",
26
+ desc: "yarn or npm",
27
27
  });
28
28
 
29
- this.option('yarnNodeLinker', {
29
+ this.option("yarnNodeLinker", {
30
30
  type: String,
31
31
  required: false,
32
- default: 'node-modules',
33
- desc: 'Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.',
32
+ default: "node-modules",
33
+ desc: "Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.",
34
34
  });
35
35
 
36
- this.option('disableYarnGitCache', {
36
+ this.option("disableYarnGitCache", {
37
37
  type: Boolean,
38
38
  required: false,
39
39
  default: false,
40
- desc: 'Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.',
40
+ desc: "Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.",
41
41
  });
42
42
  }
43
43
 
44
44
  initializing() {
45
45
  this.pobjson =
46
- this.config.get('lib') ||
47
- this.config.get('pob') ||
48
- this.config.get('pob-config') ||
49
- this.config.get('pob-lib-config');
46
+ this.config.get("lib") ||
47
+ this.config.get("pob") ||
48
+ this.config.get("pob-config") ||
49
+ this.config.get("pob-lib-config");
50
50
 
51
51
  if (!this.pobjson) {
52
- this.pobjson = this.fs.readJSON(this.destinationPath('.pob.json'), null);
52
+ this.pobjson = this.fs.readJSON(this.destinationPath(".pob.json"), null);
53
53
  if (this.pobjson) {
54
- this.config.set('lib', this.pobjson);
54
+ this.config.set("lib", this.pobjson);
55
55
  }
56
56
  }
57
57
 
58
- this.config.delete('libtest'); // deprecated
59
- this.config.delete('pob'); // deprecated
60
- this.config.delete('pob-config'); // deprecated
61
- this.config.delete('pob-lib-config'); // deprecated
58
+ this.config.delete("libtest"); // deprecated
59
+ this.config.delete("pob"); // deprecated
60
+ this.config.delete("pob-config"); // deprecated
61
+ this.config.delete("pob-lib-config"); // deprecated
62
62
  this.config.save();
63
- this.fs.delete('.pob.json'); // deprecated
63
+ this.fs.delete(".pob.json"); // deprecated
64
64
 
65
65
  if (!this.pobjson || this.pobjson.babelEnvs) {
66
66
  this.pobjson = {};
@@ -69,7 +69,7 @@ export default class PobLibGenerator extends Generator {
69
69
  this.updateOnly = this.options.updateOnly;
70
70
  }
71
71
 
72
- const pkg = this.fs.readJSON(this.destinationPath('package.json'));
72
+ const pkg = this.fs.readJSON(this.destinationPath("package.json"));
73
73
  const pobPkgConfig = pkg.pob || {};
74
74
 
75
75
  let babelEnvs = this.pobjson.envs || pobPkgConfig.babelEnvs;
@@ -77,42 +77,42 @@ export default class PobLibGenerator extends Generator {
77
77
  const jsx =
78
78
  this.pobjson.withReact || pobPkgConfig.withReact || pobPkgConfig.jsx;
79
79
 
80
- if (babelEnvs && typeof babelEnvs[0] === 'string') {
80
+ if (babelEnvs && typeof babelEnvs[0] === "string") {
81
81
  babelEnvs = babelEnvs.map((env) => {
82
82
  switch (env) {
83
- case 'node6':
84
- case 'node7':
85
- case 'node8':
86
- case 'node10':
83
+ case "node6":
84
+ case "node7":
85
+ case "node8":
86
+ case "node10":
87
87
  return {
88
- target: 'node',
88
+ target: "node",
89
89
  version: 14,
90
- formats: ['cjs'],
90
+ formats: ["cjs"],
91
91
  };
92
92
 
93
- case 'webpack-node7':
94
- case 'module-node7':
95
- case 'module-node8':
93
+ case "webpack-node7":
94
+ case "module-node7":
95
+ case "module-node8":
96
96
  return {
97
- target: 'node',
97
+ target: "node",
98
98
  version: 14,
99
- formats: ['es'],
99
+ formats: ["es"],
100
100
  };
101
101
 
102
- case 'module':
103
- case 'webpack':
104
- return { target: 'browser', formats: ['es'] };
102
+ case "module":
103
+ case "webpack":
104
+ return { target: "browser", formats: ["es"] };
105
105
 
106
- case 'module-modern-browsers':
107
- case 'webpack-modern-browsers':
106
+ case "module-modern-browsers":
107
+ case "webpack-modern-browsers":
108
108
  return {
109
- target: 'browser',
110
- version: 'modern',
111
- formats: ['es'],
109
+ target: "browser",
110
+ version: "modern",
111
+ formats: ["es"],
112
112
  };
113
113
 
114
- case 'browsers':
115
- return { target: 'browser', formats: ['cjs'] };
114
+ case "browsers":
115
+ return { target: "browser", formats: ["cjs"] };
116
116
 
117
117
  default:
118
118
  throw new Error(`Unsupported env ${env}`);
@@ -127,13 +127,13 @@ export default class PobLibGenerator extends Generator {
127
127
  };
128
128
  } else if (this.pobjson.testing) {
129
129
  delete this.pobjson.testing.travisci;
130
- if ('circleci' in this.pobjson.testing) {
130
+ if ("circleci" in this.pobjson.testing) {
131
131
  this.pobjson.testing.ci = this.pobjson.testing.circleci;
132
132
  delete this.pobjson.testing.circleci;
133
133
  }
134
134
  }
135
135
 
136
- if (typeof this.pobjson.documentation === 'object') {
136
+ if (typeof this.pobjson.documentation === "object") {
137
137
  this.pobjson.documentation = true;
138
138
  }
139
139
 
@@ -153,11 +153,11 @@ export default class PobLibGenerator extends Generator {
153
153
  pkg.pob.jsx = jsx;
154
154
  }
155
155
 
156
- this.fs.writeJSON(this.destinationPath('package.json'), pkg);
156
+ this.fs.writeJSON(this.destinationPath("package.json"), pkg);
157
157
  }
158
158
 
159
159
  async prompting() {
160
- const pkg = this.fs.readJSON(this.destinationPath('package.json'));
160
+ const pkg = this.fs.readJSON(this.destinationPath("package.json"));
161
161
 
162
162
  // documentation
163
163
  if (inMonorepo && !inMonorepo.root) {
@@ -165,9 +165,9 @@ export default class PobLibGenerator extends Generator {
165
165
  } else {
166
166
  const answers = await this.prompt([
167
167
  {
168
- type: 'confirm',
169
- name: 'documentation',
170
- message: 'Would you like documentation (manually generated) ?',
168
+ type: "confirm",
169
+ name: "documentation",
170
+ message: "Would you like documentation (manually generated) ?",
171
171
  when: !this.updateOnly || this.pobjson.documentation === undefined,
172
172
  default:
173
173
  this.pobjson.documentation != null
@@ -182,9 +182,9 @@ export default class PobLibGenerator extends Generator {
182
182
  // testing
183
183
  if (!this.updateOnly || this.pobjson.testing === undefined) {
184
184
  const { testing } = await this.prompt({
185
- type: 'confirm',
186
- name: 'testing',
187
- message: 'Would you like testing ?',
185
+ type: "confirm",
186
+ name: "testing",
187
+ message: "Would you like testing ?",
188
188
  default: this.pobjson.testing || false,
189
189
  });
190
190
  this.pobjson.testing = !testing ? false : this.pobjson.testing || {};
@@ -193,33 +193,33 @@ export default class PobLibGenerator extends Generator {
193
193
  if (this.pobjson.testing && !(inMonorepo || inMonorepo.root)) {
194
194
  const testingPrompts = await this.prompt([
195
195
  {
196
- type: 'confirm',
197
- name: 'ci',
198
- message: 'Would you like ci with github actions ?',
196
+ type: "confirm",
197
+ name: "ci",
198
+ message: "Would you like ci with github actions ?",
199
199
  when: !this.updateOnly || this.pobjson.testing?.ci === undefined,
200
200
  default: this.pobjson.testing.ci !== false,
201
201
  },
202
202
  {
203
- type: 'list',
204
- name: 'runner',
205
- message: 'Testing runner ?',
203
+ type: "list",
204
+ name: "runner",
205
+ message: "Testing runner ?",
206
206
  when: !this.updateOnly || this.pobjson.testing?.runner === undefined,
207
- default: this.pobjson.testing?.runner || 'jest',
207
+ default: this.pobjson.testing?.runner || "jest",
208
208
  choices: [
209
209
  {
210
- name: 'Jest',
211
- value: 'jest',
210
+ name: "Jest",
211
+ value: "jest",
212
212
  },
213
213
  {
214
- name: 'node:test',
215
- value: 'node',
214
+ name: "node:test",
215
+ value: "node",
216
216
  },
217
217
  ],
218
218
  },
219
219
  {
220
- type: 'confirm',
221
- name: 'codecov',
222
- message: 'Would you like codecov ?',
220
+ type: "confirm",
221
+ name: "codecov",
222
+ message: "Would you like codecov ?",
223
223
  when: !this.updateOnly || this.pobjson.testing?.codecov === undefined,
224
224
  default: this.pobjson.testing.codecov === true,
225
225
  },
@@ -227,16 +227,16 @@ export default class PobLibGenerator extends Generator {
227
227
  Object.assign(this.pobjson.testing, testingPrompts);
228
228
  }
229
229
 
230
- this.fs.writeJSON(this.destinationPath('package.json'), pkg);
230
+ this.fs.writeJSON(this.destinationPath("package.json"), pkg);
231
231
 
232
- this.composeWith('pob:common:babel', {
232
+ this.composeWith("pob:common:babel", {
233
233
  updateOnly: this.options.updateOnly,
234
234
  testing: !!this.pobjson.testing,
235
235
  documentation: !!this.pobjson.documentation,
236
236
  fromPob: this.options.fromPob,
237
237
  onlyLatestLTS: false,
238
238
  });
239
- this.composeWith('pob:common:transpiler', {
239
+ this.composeWith("pob:common:transpiler", {
240
240
  updateOnly: this.options.updateOnly,
241
241
  testing: !!this.pobjson.testing,
242
242
  documentation: !!this.pobjson.documentation,
@@ -246,34 +246,34 @@ export default class PobLibGenerator extends Generator {
246
246
  }
247
247
 
248
248
  default() {
249
- const pkg = this.fs.readJSON(this.destinationPath('package.json'));
249
+ const pkg = this.fs.readJSON(this.destinationPath("package.json"));
250
250
  const babelEnvs = pkg.pob.babelEnvs || [];
251
251
 
252
252
  const withBabel = babelEnvs.length > 0;
253
253
  const withTypescript = withBabel || pkg.pob.typescript === true;
254
254
  const jsx = (withBabel || withTypescript) && pkg.pob.jsx === true;
255
255
  const browser =
256
- withBabel && babelEnvs.some((env) => env.target === 'browser');
256
+ withBabel && babelEnvs.some((env) => env.target === "browser");
257
257
 
258
- this.composeWith('pob:common:typescript', {
258
+ this.composeWith("pob:common:typescript", {
259
259
  enable: withTypescript,
260
260
  isApp: false,
261
261
  dom: browser,
262
262
  jsx,
263
263
  updateOnly: this.options.updateOnly,
264
- baseUrl: 'none', // causes issues on dist definition files
264
+ baseUrl: "none", // causes issues on dist definition files
265
265
  builddefs: true,
266
266
  onlyLatestLTS: false,
267
267
  });
268
268
 
269
- this.composeWith('pob:common:husky', {});
269
+ this.composeWith("pob:common:husky", {});
270
270
 
271
- this.composeWith('pob:common:remove-old-dependencies');
271
+ this.composeWith("pob:common:remove-old-dependencies");
272
272
 
273
273
  const enableReleasePlease =
274
274
  !inMonorepo && this.pobjson.testing && this.pobjson.testing.ci;
275
275
 
276
- this.composeWith('pob:common:testing', {
276
+ this.composeWith("pob:common:testing", {
277
277
  enable: this.pobjson.testing,
278
278
  disableYarnGitCache: this.options.disableYarnGitCache,
279
279
  enableReleasePlease,
@@ -282,7 +282,7 @@ export default class PobLibGenerator extends Generator {
282
282
  runner: this.pobjson.testing
283
283
  ? (inMonorepo
284
284
  ? inMonorepo.pobMonorepoConfig.testRunner
285
- : this.pobjson.testing.runner) || 'jest'
285
+ : this.pobjson.testing.runner) || "jest"
286
286
  : undefined,
287
287
  build: withBabel || withTypescript,
288
288
  typescript: withTypescript,
@@ -292,11 +292,11 @@ export default class PobLibGenerator extends Generator {
292
292
  packageManager: this.options.packageManager,
293
293
  isApp: false,
294
294
  splitCIJobs: false,
295
- srcDirectory: withBabel || withTypescript ? 'src' : 'lib',
295
+ srcDirectory: withBabel || withTypescript ? "src" : "lib",
296
296
  });
297
297
 
298
298
  // must be after testing
299
- this.composeWith('pob:common:format-lint', {
299
+ this.composeWith("pob:common:format-lint", {
300
300
  typescript: withTypescript,
301
301
  documentation:
302
302
  !!this.pobjson.documentation ||
@@ -307,23 +307,23 @@ export default class PobLibGenerator extends Generator {
307
307
  : this.pobjson.testing?.runner,
308
308
  packageManager: this.options.packageManager,
309
309
  yarnNodeLinker: this.options.yarnNodeLinker,
310
- ignorePaths: withBabel || withTypescript ? '/dist' : '',
310
+ ignorePaths: withBabel || withTypescript ? "/dist" : "",
311
311
  });
312
312
 
313
- this.composeWith('pob:lib:doc', {
313
+ this.composeWith("pob:lib:doc", {
314
314
  enabled: this.pobjson.documentation,
315
315
  testing: this.pobjson.testing,
316
316
  });
317
317
 
318
318
  // must be after doc, testing
319
- this.composeWith('pob:lib:readme', {
319
+ this.composeWith("pob:lib:readme", {
320
320
  documentation: !!this.pobjson.documentation,
321
321
  testing: !!this.pobjson.testing,
322
322
  ci: this.pobjson.testing && this.pobjson.testing.ci,
323
323
  codecov: this.pobjson.testing && this.pobjson.testing.codecov,
324
324
  });
325
325
 
326
- this.composeWith('pob:common:release', {
326
+ this.composeWith("pob:common:release", {
327
327
  enable: !inMonorepo && this.pobjson.testing,
328
328
  enablePublish: true,
329
329
  withBabel,
@@ -335,7 +335,7 @@ export default class PobLibGenerator extends Generator {
335
335
  updateOnly: this.options.updateOnly,
336
336
  });
337
337
 
338
- this.composeWith('pob:core:vscode', {
338
+ this.composeWith("pob:core:vscode", {
339
339
  root: !inMonorepo,
340
340
  monorepo: false,
341
341
  packageManager: this.options.packageManager,
@@ -346,7 +346,7 @@ export default class PobLibGenerator extends Generator {
346
346
  });
347
347
 
348
348
  // must be after doc, testing
349
- this.composeWith('pob:core:gitignore', {
349
+ this.composeWith("pob:core:gitignore", {
350
350
  root: !inMonorepo,
351
351
  withBabel: babelEnvs.length > 0,
352
352
  typescript: withTypescript,
@@ -354,32 +354,32 @@ export default class PobLibGenerator extends Generator {
354
354
  testing: !!this.pobjson.testing,
355
355
  });
356
356
 
357
- this.composeWith('pob:core:npm', {
357
+ this.composeWith("pob:core:npm", {
358
358
  enable: !pkg.private,
359
- srcDirectory: withBabel || withTypescript ? 'src' : 'lib',
360
- distDirectory: withBabel || withTypescript ? 'dist' : '',
359
+ srcDirectory: withBabel || withTypescript ? "src" : "lib",
360
+ distDirectory: withBabel || withTypescript ? "dist" : "",
361
361
  });
362
362
  }
363
363
 
364
364
  writing() {
365
365
  // Re-read the content at this point because a composed generator might modify it.
366
- const pkg = this.fs.readJSON(this.destinationPath('package.json'));
366
+ const pkg = this.fs.readJSON(this.destinationPath("package.json"));
367
367
 
368
368
  if (pkg.engines) {
369
369
  delete pkg.engines.yarn;
370
370
  }
371
371
 
372
- if ('sideEffects' in pkg) {
372
+ if ("sideEffects" in pkg) {
373
373
  pkg.sideEffects = false;
374
374
  }
375
375
 
376
376
  const withBabel = Boolean(pkg.pob.babelEnvs);
377
377
  const withTypescript = pkg.pob.typescript === true;
378
378
 
379
- packageUtils.removeDevDependencies(pkg, ['lerna', '@pob/lerna-light']);
379
+ packageUtils.removeDevDependencies(pkg, ["lerna", "@pob/lerna-light"]);
380
380
  if (inMonorepo) {
381
381
  if (pkg.scripts) {
382
- if (pkg.name !== 'pob-dependencies') {
382
+ if (pkg.name !== "pob-dependencies") {
383
383
  delete pkg.scripts.preversion;
384
384
  }
385
385
  delete pkg.scripts.release;
@@ -389,23 +389,23 @@ export default class PobLibGenerator extends Generator {
389
389
 
390
390
  if (!withBabel && !withTypescript) {
391
391
  if (
392
- !this.fs.exists(this.destinationPath('lib/index.js')) &&
393
- this.fs.exists(this.destinationPath('index.js'))
392
+ !this.fs.exists(this.destinationPath("lib/index.js")) &&
393
+ this.fs.exists(this.destinationPath("index.js"))
394
394
  ) {
395
395
  this.fs.move(
396
- this.destinationPath('index.js'),
397
- this.destinationPath('lib/index.js'),
396
+ this.destinationPath("index.js"),
397
+ this.destinationPath("lib/index.js")
398
398
  );
399
399
  }
400
400
  }
401
401
 
402
- this.fs.writeJSON(this.destinationPath('package.json'), pkg);
402
+ this.fs.writeJSON(this.destinationPath("package.json"), pkg);
403
403
  [
404
- 'lib-node14',
405
- 'lib-node16',
406
- 'coverage',
407
- this.pobjson.documentation && 'docs',
408
- !(withBabel || withTypescript) && 'dist',
404
+ "lib-node14",
405
+ "lib-node16",
406
+ "coverage",
407
+ this.pobjson.documentation && "docs",
408
+ !(withBabel || withTypescript) && "dist",
409
409
  ]
410
410
  .filter(Boolean)
411
411
  .forEach((path) => {
@@ -423,9 +423,9 @@ export default class PobLibGenerator extends Generator {
423
423
  // this.babelEnvs.includes('browsers') && 'browsers',
424
424
  // ].filter(Boolean);
425
425
 
426
- this.config.set('lib', pobjson);
426
+ this.config.set("lib", pobjson);
427
427
  this.config.save();
428
428
 
429
- this.composeWith('pob:core:sort-package');
429
+ this.composeWith("pob:core:sort-package");
430
430
  }
431
431
  }