pob 20.0.0 → 21.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/lib/generators/app/PobAppGenerator.js +12 -10
  3. package/lib/generators/app/e2e-testing/AppE2ETestingGenerator.js +2 -2
  4. package/lib/generators/app/ignorePaths.js +1 -0
  5. package/lib/generators/app/nextjs/AppNextjsGenerator.js +1 -1
  6. package/lib/generators/common/babel/CommonBabelGenerator.js +44 -28
  7. package/lib/generators/common/format-lint/CommonLintGenerator.js +33 -28
  8. package/lib/generators/common/format-lint/updateEslintConfig.js +5 -5
  9. package/lib/generators/common/husky/CommonHuskyGenerator.js +4 -4
  10. package/lib/generators/common/husky/templates/lint-staged.config.js.txt +1 -1
  11. package/lib/generators/common/release/CommonReleaseGenerator.js +14 -13
  12. package/lib/generators/common/release/templates/workflow-release.yml.ejs +2 -2
  13. package/lib/generators/common/testing/CommonTestingGenerator.js +46 -44
  14. package/lib/generators/common/transpiler/CommonTranspilerGenerator.js +18 -25
  15. package/lib/generators/common/typescript/CommonTypescriptGenerator.js +28 -24
  16. package/lib/generators/core/ci/CoreCIGenerator.js +20 -25
  17. package/lib/generators/core/clean/CoreCleanGenerator.js +1 -1
  18. package/lib/generators/core/editorconfig/CoreEditorConfigGenerator.js +1 -1
  19. package/lib/generators/core/git/CoreGitGenerator.js +6 -6
  20. package/lib/generators/core/git/generators/github/CoreGitGithubGenerator.js +8 -8
  21. package/lib/generators/core/gitignore/CoreGitignoreGenerator.js +7 -11
  22. package/lib/generators/core/npm/CoreNpmGenerator.js +4 -4
  23. package/lib/generators/core/package/CorePackageGenerator.js +18 -18
  24. package/lib/generators/core/renovate/CoreRenovateGenerator.js +5 -5
  25. package/lib/generators/core/sort-package/CoreSortPackageGenerator.js +1 -1
  26. package/lib/generators/core/vscode/CoreVSCodeGenerator.js +13 -12
  27. package/lib/generators/core/yarn/CoreYarnGenerator.js +32 -27
  28. package/lib/generators/lib/PobLibGenerator.js +22 -20
  29. package/lib/generators/lib/doc/LibDocGenerator.js +9 -9
  30. package/lib/generators/lib/readme/LibReadmeGenerator.js +7 -7
  31. package/lib/generators/monorepo/PobMonorepoGenerator.js +19 -18
  32. package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +19 -15
  33. package/lib/generators/monorepo/typescript/MonorepoTypescriptGenerator.js +6 -6
  34. package/lib/generators/monorepo/workspaces/MonorepoWorkspacesGenerator.js +23 -19
  35. package/lib/generators/pob/PobBaseGenerator.js +7 -7
  36. package/lib/pob.js +33 -33
  37. package/lib/utils/ensureJsonFileFormatted.js +1 -1
  38. package/lib/utils/inMonorepo.js +1 -1
  39. package/lib/utils/package.js +7 -7
  40. package/lib/utils/packagejson.js +5 -0
  41. package/lib/utils/templateUtils.js +1 -1
  42. package/lib/utils/writeAndFormat.js +2 -2
  43. package/package.json +21 -17
  44. package/lib/utils/packagejson.cjs +0 -3
@@ -11,13 +11,13 @@ export default class CommonTypescriptGenerator extends Generator {
11
11
  this.option("enable", {
12
12
  type: Boolean,
13
13
  default: true,
14
- desc: "enable typescript",
14
+ description: "enable typescript",
15
15
  });
16
16
 
17
17
  this.option("isApp", {
18
18
  type: Boolean,
19
19
  required: true,
20
- desc: "is app",
20
+ description: "is app",
21
21
  });
22
22
 
23
23
  this.option("isAppLibrary", {
@@ -29,66 +29,67 @@ export default class CommonTypescriptGenerator extends Generator {
29
29
  this.option("rootDir", {
30
30
  type: String,
31
31
  default: "src",
32
- desc: "customize rootDir",
32
+ description: "customize rootDir",
33
33
  });
34
34
 
35
35
  this.option("srcDirectory", {
36
36
  type: String,
37
37
  default: "src",
38
- desc: "customize srcDirectory, if different than rootDir",
38
+ description: "customize srcDirectory, if different than rootDir",
39
39
  });
40
40
 
41
41
  this.option("jsx", {
42
42
  type: Boolean,
43
43
  default: true,
44
- desc: "enable jsx with typescript",
44
+ description: "enable jsx with typescript",
45
45
  });
46
46
 
47
47
  this.option("jsxPreserve", {
48
48
  type: Boolean,
49
49
  default: false,
50
- desc: "force jsx preserve in tsconfig for legacy apps (nextjs, CRA)",
50
+ description:
51
+ "force jsx preserve in tsconfig for legacy apps (nextjs, CRA)",
51
52
  });
52
53
 
53
54
  this.option("forceExcludeNodeModules", {
54
55
  type: Boolean,
55
56
  default: false,
56
- desc: "force exclude node_modules for legacy apps (nextjs, CRA)",
57
+ description: "force exclude node_modules for legacy apps (nextjs, CRA)",
57
58
  });
58
59
 
59
60
  this.option("forceAllowJs", {
60
61
  type: Boolean,
61
62
  default: false,
62
- desc: "force allow js for legacy apps (nextjs, CRA)",
63
+ description: "force allow js for legacy apps (nextjs, CRA)",
63
64
  });
64
65
 
65
66
  this.option("dom", {
66
67
  type: Boolean,
67
68
  default: true,
68
- desc: "enable dom with typescript",
69
+ description: "enable dom with typescript",
69
70
  });
70
71
 
71
72
  this.option("baseUrl", {
72
73
  type: String,
73
74
  default: "",
74
- desc: "baseUrl option",
75
+ description: "baseUrl option",
75
76
  });
76
77
 
77
78
  this.option("resolveJsonModule", {
78
79
  type: Boolean,
79
80
  default: false,
80
- desc: "resolveJsonModule option",
81
+ description: "resolveJsonModule option",
81
82
  });
82
83
 
83
84
  this.option("builddefs", {
84
85
  type: Boolean,
85
86
  default: true,
86
- desc: "build .d.ts option",
87
+ description: "build .d.ts option",
87
88
  });
88
89
  this.option("plugins", {
89
90
  type: String,
90
91
  default: "",
91
- desc: "typescript plugins",
92
+ description: "typescript plugins",
92
93
  });
93
94
  this.option("nextConfig", {
94
95
  type: Boolean,
@@ -97,14 +98,14 @@ export default class CommonTypescriptGenerator extends Generator {
97
98
  this.option("additionalIncludes", {
98
99
  type: String,
99
100
  default: "",
100
- desc: "typescript additional includes",
101
+ description: "typescript additional includes",
101
102
  });
102
103
 
103
104
  this.option("onlyLatestLTS", {
104
105
  type: Boolean,
105
106
  required: false,
106
107
  default: false,
107
- desc: "only latest lts",
108
+ description: "only latest lts",
108
109
  });
109
110
  }
110
111
 
@@ -117,7 +118,10 @@ export default class CommonTypescriptGenerator extends Generator {
117
118
  const pkg = this.fs.readJSON(this.destinationPath("package.json"));
118
119
 
119
120
  const presets = (() => {
120
- const babelEnvs = pkg.pob?.babelEnvs || [];
121
+ const babelEnvs =
122
+ pkg.pob?.babelEnvs ||
123
+ (pkg.pob?.bundler === "rollup-babel" && pkg.pob.envs) ||
124
+ [];
121
125
  const withBabel = babelEnvs.length > 0;
122
126
  const withTypescript = withBabel || pkg.pob?.typescript === true;
123
127
  const jsx = (withBabel || withTypescript) && pkg.pob.jsx === true;
@@ -166,7 +170,7 @@ export default class CommonTypescriptGenerator extends Generator {
166
170
  pkg,
167
171
  this.options.enable ||
168
172
  this.fs.exists(this.destinationPath("lib/index.d.ts")),
169
- ["typescript"]
173
+ ["typescript"],
170
174
  );
171
175
 
172
176
  const tsconfigPath = this.destinationPath("tsconfig.json");
@@ -193,7 +197,7 @@ export default class CommonTypescriptGenerator extends Generator {
193
197
  packageUtils.addOrRemoveDevDependencies(
194
198
  pkg,
195
199
  inMonorepo.rootPackageManager === "yarn",
196
- ["typescript"]
200
+ ["typescript"],
197
201
  );
198
202
 
199
203
  const packageLocations = new Map(
@@ -202,7 +206,7 @@ export default class CommonTypescriptGenerator extends Generator {
202
206
  (packageName) =>
203
207
  (pkg.dependencies && pkg.dependencies[packageName]) ||
204
208
  (pkg.devDependencies && pkg.devDependencies[packageName]) ||
205
- (pkg.peerDependencies && pkg.peerDependencies[packageName])
209
+ (pkg.peerDependencies && pkg.peerDependencies[packageName]),
206
210
  )
207
211
  .map((packageName) => [
208
212
  packageName,
@@ -211,12 +215,12 @@ export default class CommonTypescriptGenerator extends Generator {
211
215
  ? // eslint-disable-next-line unicorn/no-nested-ternary
212
216
  yoConfig.pob.project.type === "app"
213
217
  ? `packages/${packageName.slice(
214
- packageName.indexOf("/") + 1
218
+ packageName.indexOf("/") + 1,
215
219
  )}`
216
220
  : packageName
217
221
  : `packages/${packageName}`
218
222
  }`,
219
- ])
223
+ ]),
220
224
  );
221
225
 
222
226
  monorepoPackageSrcPaths = [...packageLocations.entries()].map(
@@ -227,11 +231,11 @@ export default class CommonTypescriptGenerator extends Generator {
227
231
  ? "src"
228
232
  : "lib"
229
233
  }`,
230
- ]
234
+ ],
231
235
  );
232
236
  monorepoPackageReferences = yoConfig.pob.monorepo.packageNames
233
237
  .filter((packageName) =>
234
- existsSync(`${packageLocations.get(packageName)}/tsconfig.json`)
238
+ existsSync(`${packageLocations.get(packageName)}/tsconfig.json`),
235
239
  )
236
240
  .map((packageName) => packageLocations.get(packageName));
237
241
  // monorepoPackageBuildReferences = yoConfig.pob.monorepo.packageNames
@@ -282,7 +286,7 @@ export default class CommonTypescriptGenerator extends Generator {
282
286
  .split(",")
283
287
  .filter(Boolean),
284
288
  presets,
285
- }
289
+ },
286
290
  );
287
291
 
288
292
  // if (
@@ -13,98 +13,93 @@ export default class CoreCIGenerator extends Generator {
13
13
  this.option("enable", {
14
14
  type: Boolean,
15
15
  default: true,
16
- desc: "enable ci",
16
+ description: "enable ci",
17
17
  });
18
18
 
19
19
  this.option("enableReleasePlease", {
20
20
  type: Boolean,
21
21
  default: true,
22
- desc: "enable release-please",
22
+ description: "enable release-please",
23
23
  });
24
24
 
25
25
  this.option("enableYarnVersion", {
26
26
  type: Boolean,
27
27
  default: true,
28
- desc: "enable yarn version conventional commits",
28
+ description: "enable yarn version conventional commits",
29
29
  });
30
30
 
31
31
  this.option("build", {
32
32
  type: Boolean,
33
33
  default: true,
34
- desc: "enable build",
34
+ description: "enable build",
35
35
  });
36
36
 
37
37
  this.option("typescript", {
38
38
  type: Boolean,
39
39
  default: true,
40
- desc: "enable typescript",
40
+ description: "enable typescript",
41
41
  });
42
42
 
43
43
  this.option("testing", {
44
44
  type: Boolean,
45
45
  default: true,
46
- desc: "enable testing",
46
+ description: "enable testing",
47
47
  });
48
48
  this.option("testRunner", {
49
49
  type: String,
50
50
  required: false,
51
51
  default: "jest",
52
- desc: "test runner: jest | node",
52
+ description: "test runner: jest | node",
53
53
  });
54
54
 
55
55
  this.option("e2eTesting", {
56
56
  type: String,
57
57
  default: "",
58
- desc: "e2e testing package path",
58
+ description: "e2e testing package path",
59
59
  });
60
60
 
61
- // this.option('babelEnvs', {
62
- // type: String,
63
- // required: true,
64
- // desc: 'Babel Envs',
65
- // });
66
-
67
61
  this.option("ci", {
68
62
  type: Boolean,
69
63
  required: true,
70
- desc: "ci with github actions",
64
+ description: "ci with github actions",
71
65
  });
72
66
 
73
67
  this.option("codecov", {
74
68
  type: Boolean,
75
69
  required: true,
76
- desc: "Include codecov report",
70
+ description: "Include codecov report",
77
71
  });
78
72
 
79
73
  this.option("documentation", {
80
74
  type: Boolean,
81
75
  required: true,
82
- desc: "Include documentation generation",
76
+ description: "Include documentation generation",
83
77
  });
84
78
 
85
79
  this.option("isApp", {
86
80
  type: Boolean,
87
81
  required: true,
88
- desc: "is app",
82
+ description: "is app",
89
83
  });
90
84
 
91
85
  this.option("onlyLatestLTS", {
92
86
  type: Boolean,
93
87
  required: true,
94
- desc: "only latest lts",
88
+ description: "only latest lts",
95
89
  });
96
90
 
97
91
  this.option("splitJobs", {
98
92
  type: Boolean,
99
93
  required: true,
100
- desc: "split CI jobs for faster result",
94
+ description: "split CI jobs for faster result",
101
95
  });
102
96
 
103
97
  this.option("disableYarnGitCache", {
104
98
  type: Boolean,
105
99
  required: false,
106
100
  default: false,
107
- desc: "Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.",
101
+ description:
102
+ "Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.",
108
103
  });
109
104
  }
110
105
 
@@ -150,7 +145,7 @@ export default class CoreCIGenerator extends Generator {
150
145
  this.templatePath(
151
146
  this.options.splitJobs
152
147
  ? "github-action-push-workflow-split.yml.ejs"
153
- : "github-action-push-workflow.yml.ejs"
148
+ : "github-action-push-workflow.yml.ejs",
154
149
  ),
155
150
  this.destinationPath(".github/workflows/push.yml"),
156
151
  {
@@ -174,7 +169,7 @@ export default class CoreCIGenerator extends Generator {
174
169
  inMonorepo &&
175
170
  inMonorepo.root &&
176
171
  inMonorepo.pobConfig?.project?.type === "lib",
177
- }
172
+ },
178
173
  );
179
174
 
180
175
  ciContexts.push(
@@ -190,7 +185,7 @@ export default class CoreCIGenerator extends Generator {
190
185
  : [
191
186
  !this.options.onlyLatestLTS && "build (18.x)",
192
187
  "build (20.x)",
193
- ].filter(Boolean))
188
+ ].filter(Boolean)),
194
189
  );
195
190
  } else {
196
191
  this.fs.delete(this.destinationPath(".github/workflows/push.yml"));
@@ -212,7 +207,7 @@ export default class CoreCIGenerator extends Generator {
212
207
  testing: this.options.testing,
213
208
  testRunner: this.options.testRunner,
214
209
  typedoc: this.options.documentation && this.options.typescript,
215
- }
210
+ },
216
211
  );
217
212
  } else {
218
213
  this.fs.delete(this.destinationPath(".github/workflows/gh-pages.yml"));
@@ -8,7 +8,7 @@ export default class CoreCleanGenerator extends Generator {
8
8
  type: Boolean,
9
9
  required: false,
10
10
  default: true,
11
- desc: "Root package.",
11
+ description: "Root package.",
12
12
  });
13
13
  }
14
14
 
@@ -4,7 +4,7 @@ export default class CoreEditorConfigGenerator extends Generator {
4
4
  writing() {
5
5
  this.fs.copy(
6
6
  this.templatePath("editorconfig"),
7
- this.destinationPath(".editorconfig")
7
+ this.destinationPath(".editorconfig"),
8
8
  );
9
9
  }
10
10
  }
@@ -11,25 +11,25 @@ export default class CoreGitGenerator extends Generator {
11
11
  type: Boolean,
12
12
  required: false,
13
13
  default: "",
14
- desc: "Should create the repo on github",
14
+ description: "Should create the repo on github",
15
15
  });
16
16
 
17
17
  this.option("onlyLatestLTS", {
18
18
  type: Boolean,
19
19
  required: true,
20
- desc: "only latest lts",
20
+ description: "only latest lts",
21
21
  });
22
22
 
23
23
  this.option("splitCIJobs", {
24
24
  type: Boolean,
25
25
  required: true,
26
- desc: "split CI jobs for faster result",
26
+ description: "split CI jobs for faster result",
27
27
  });
28
28
  }
29
29
 
30
30
  async initializing() {
31
31
  let originUrl = await remoteUrl(this.destinationPath(), "origin").catch(
32
- () => ""
32
+ () => "",
33
33
  );
34
34
 
35
35
  if (!originUrl) {
@@ -42,7 +42,7 @@ export default class CoreGitGenerator extends Generator {
42
42
  originUrl &&
43
43
  typeof originUrl === "string" &&
44
44
  originUrl.match(
45
- /^(?:git@|https?:\/\/)(?:([^./:]+)(?:\.com)?[/:])?([^/:]+)\/([^./:]+)(?:.git)?/
45
+ /^(?:git@|https?:\/\/)(?:([^./:]+)(?:\.com)?[/:])?([^/:]+)\/([^./:]+)(?:.git)?/,
46
46
  );
47
47
  if (!match) return;
48
48
  const [, gitHost, gitAccount, repoName] = match;
@@ -83,7 +83,7 @@ export default class CoreGitGenerator extends Generator {
83
83
  const pkg = this.fs.readJSON(this.destinationPath("package.json"), {});
84
84
  const author = packageUtils.parsePkgAuthor(pkg);
85
85
  this.gitHostAccount = await githubUsername(author.email).catch(
86
- () => ""
86
+ () => "",
87
87
  );
88
88
  }
89
89
  }
@@ -70,36 +70,36 @@ export default class CoreGitGithubGenerator extends Generator {
70
70
  type: Boolean,
71
71
  required: false,
72
72
  default: "",
73
- desc: "Should create the repo on github",
73
+ description: "Should create the repo on github",
74
74
  });
75
75
 
76
76
  this.option("gitHostAccount", {
77
77
  type: String,
78
78
  required: true,
79
- desc: "host account",
79
+ description: "host account",
80
80
  });
81
81
 
82
82
  this.option("repoName", {
83
83
  type: String,
84
84
  required: true,
85
- desc: "repo name",
85
+ description: "repo name",
86
86
  });
87
87
 
88
88
  this.option("onlyLatestLTS", {
89
89
  type: Boolean,
90
90
  required: true,
91
- desc: "only latest lts",
91
+ description: "only latest lts",
92
92
  });
93
93
 
94
94
  this.option("splitCIJobs", {
95
95
  type: Boolean,
96
96
  required: true,
97
- desc: "split CI jobs for faster result",
97
+ description: "split CI jobs for faster result",
98
98
  });
99
99
 
100
100
  if (!GITHUB_TOKEN && process.env.CI !== "true") {
101
101
  throw new Error(
102
- "Missing POB_GITHUB_TOKEN. Create one with https://github.com/settings/tokens/new?scopes=repo&description=POB%20Generator and add it in your env variables."
102
+ "Missing POB_GITHUB_TOKEN. Create one with https://github.com/settings/tokens/new?scopes=repo&description=POB%20Generator and add it in your env variables.",
103
103
  );
104
104
  }
105
105
  }
@@ -146,7 +146,7 @@ export default class CoreGitGithubGenerator extends Generator {
146
146
  "origin",
147
147
  `git@github.com:christophehurpeau/${name}.git`,
148
148
  ],
149
- { cwd }
149
+ { cwd },
150
150
  );
151
151
  console.error("Failed to create repository");
152
152
  console.error(error.stack || error.message || error);
@@ -154,7 +154,7 @@ export default class CoreGitGithubGenerator extends Generator {
154
154
  this.spawnCommandSync(
155
155
  "git",
156
156
  ["commit", "-m", "chore: initial commit [skip ci]"],
157
- { cwd }
157
+ { cwd },
158
158
  );
159
159
  this.spawnCommandSync("git", ["branch", "-M", "main"], {
160
160
  cwd,
@@ -8,59 +8,55 @@ export default class CoreGitignoreGenerator extends Generator {
8
8
  type: Boolean,
9
9
  required: false,
10
10
  default: true,
11
- desc: "Root package.",
11
+ description: "Root package.",
12
12
  });
13
13
 
14
14
  this.option("documentation", {
15
15
  type: Boolean,
16
16
  required: false,
17
17
  default: false,
18
- desc: "Documentation enabled.",
18
+ description: "Documentation enabled.",
19
19
  });
20
20
 
21
21
  this.option("testing", {
22
22
  type: Boolean,
23
23
  required: false,
24
24
  default: false,
25
- desc: "Testing enabled.",
25
+ description: "Testing enabled.",
26
26
  });
27
27
 
28
28
  this.option("withBabel", {
29
29
  type: Boolean,
30
30
  required: false,
31
31
  default: undefined,
32
- desc: "Babel enabled.",
32
+ description: "Babel enabled.",
33
33
  });
34
34
 
35
35
  this.option("paths", {
36
36
  type: String,
37
37
  required: false,
38
38
  default: "",
39
- desc: "Paths ignored.",
39
+ description: "Paths ignored.",
40
40
  });
41
41
 
42
42
  this.option("typescript", {
43
43
  type: Boolean,
44
44
  required: false,
45
45
  default: true,
46
- desc: "Typescript use.",
46
+ description: "Typescript use.",
47
47
  });
48
48
 
49
49
  this.option("buildInGit", {
50
50
  type: Boolean,
51
51
  required: false,
52
52
  default: true,
53
- desc: "Build is saved in git.",
53
+ description: "Build is saved in git.",
54
54
  });
55
55
  }
56
56
 
57
57
  writing() {
58
58
  const dest = this.destinationPath(".gitignore");
59
59
  const withBabel = this.options.withBabel;
60
- // if (withBabel === undefined) {
61
- // const babelEnvs = (pkg.pob && pkg.pob.babelEnvs) || [];
62
- // withBabel = babelEnvs.length !== 0;
63
- // }
64
60
 
65
61
  if (
66
62
  !this.options.root &&
@@ -8,20 +8,20 @@ export default class CoreNpmGenerator extends Generator {
8
8
  type: Boolean,
9
9
  required: false,
10
10
  default: true,
11
- desc: "Enable npm",
11
+ description: "Enable npm",
12
12
  });
13
13
 
14
14
  this.option("srcDirectory", {
15
15
  type: String,
16
16
  required: true,
17
17
  default: "lib",
18
- desc: "src directory to include in published files",
18
+ description: "src directory to include in published files",
19
19
  });
20
20
 
21
21
  this.option("distDirectory", {
22
22
  type: String,
23
23
  required: false,
24
- desc: "dist directory to include in published files",
24
+ description: "dist directory to include in published files",
25
25
  });
26
26
  }
27
27
 
@@ -32,7 +32,7 @@ export default class CoreNpmGenerator extends Generator {
32
32
  this.fs.copyTpl(
33
33
  this.templatePath("npmignore.ejs"),
34
34
  this.destinationPath(".npmignore"),
35
- {}
35
+ {},
36
36
  );
37
37
  } else if (this.fs.exists(this.destinationPath(".npmignore"))) {
38
38
  this.fs.delete(this.destinationPath(".npmignore"));