pob 19.2.0 → 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 (48) hide show
  1. package/CHANGELOG.md +11 -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 +13 -13
  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/core/ci/CoreCIGenerator.js +72 -72
  18. package/lib/generators/core/clean/CoreCleanGenerator.js +4 -4
  19. package/lib/generators/core/editorconfig/CoreEditorConfigGenerator.js +3 -3
  20. package/lib/generators/core/git/CoreGitGenerator.js +43 -43
  21. package/lib/generators/core/git/generators/github/CoreGitGithubGenerator.js +43 -43
  22. package/lib/generators/core/gitignore/CoreGitignoreGenerator.js +19 -19
  23. package/lib/generators/core/npm/CoreNpmGenerator.js +20 -20
  24. package/lib/generators/core/package/CorePackageGenerator.js +98 -98
  25. package/lib/generators/core/package/askName.js +4 -4
  26. package/lib/generators/core/renovate/CoreRenovateGenerator.js +28 -28
  27. package/lib/generators/core/sort-package/CoreSortPackageGenerator.js +6 -6
  28. package/lib/generators/core/vscode/CoreVSCodeGenerator.js +43 -43
  29. package/lib/generators/core/yarn/CoreYarnGenerator.js +70 -70
  30. package/lib/generators/lib/PobLibGenerator.js +111 -111
  31. package/lib/generators/lib/doc/LibDocGenerator.js +45 -45
  32. package/lib/generators/lib/readme/LibReadmeGenerator.js +21 -21
  33. package/lib/generators/monorepo/PobMonorepoGenerator.js +89 -89
  34. package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +47 -47
  35. package/lib/generators/monorepo/typescript/MonorepoTypescriptGenerator.js +38 -38
  36. package/lib/generators/monorepo/workspaces/MonorepoWorkspacesGenerator.js +57 -57
  37. package/lib/generators/pob/PobBaseGenerator.js +81 -81
  38. package/lib/pob-dirname.cjs +1 -1
  39. package/lib/pob.js +143 -143
  40. package/lib/utils/dependenciesPackages.cjs +4 -4
  41. package/lib/utils/ensureJsonFileFormatted.js +5 -5
  42. package/lib/utils/inMonorepo.js +8 -8
  43. package/lib/utils/json5.js +1 -1
  44. package/lib/utils/package.js +43 -43
  45. package/lib/utils/packagejson.cjs +2 -2
  46. package/lib/utils/templateUtils.js +1 -1
  47. package/lib/utils/writeAndFormat.js +9 -10
  48. package/package.json +7 -7
@@ -1,65 +1,65 @@
1
- import Generator from 'yeoman-generator';
2
- import { readJSON5 } from '../../../utils/json5.js';
3
- import { copyAndFormatTpl } from '../../../utils/writeAndFormat.js';
1
+ import Generator from "yeoman-generator";
2
+ import { readJSON5 } from "../../../utils/json5.js";
3
+ import { copyAndFormatTpl } from "../../../utils/writeAndFormat.js";
4
4
 
5
5
  export default class CoreVSCodeGenerator extends Generator {
6
6
  constructor(args, opts) {
7
7
  super(args, opts);
8
8
 
9
- this.option('root', {
9
+ this.option("root", {
10
10
  type: Boolean,
11
11
  required: false,
12
- default: '',
13
- desc: 'Is root',
12
+ default: "",
13
+ desc: "Is root",
14
14
  });
15
15
 
16
- this.option('packageManager', {
16
+ this.option("packageManager", {
17
17
  type: String,
18
18
  required: false,
19
- default: 'yarn',
20
- desc: 'yarn|npm.',
19
+ default: "yarn",
20
+ desc: "yarn|npm.",
21
21
  });
22
22
 
23
- this.option('monorepo', {
23
+ this.option("monorepo", {
24
24
  type: Boolean,
25
25
  required: false,
26
26
  default: false,
27
- desc: 'is monorepo',
27
+ desc: "is monorepo",
28
28
  });
29
29
 
30
- this.option('testing', {
30
+ this.option("testing", {
31
31
  type: Boolean,
32
32
  required: false,
33
33
  default: false,
34
- desc: 'Testing enabled',
34
+ desc: "Testing enabled",
35
35
  });
36
36
 
37
- this.option('testRunner', {
37
+ this.option("testRunner", {
38
38
  type: String,
39
39
  required: false,
40
- desc: 'Test runner (jest, vitest, ...)',
40
+ desc: "Test runner (jest, vitest, ...)",
41
41
  });
42
42
 
43
- this.option('yarnNodeLinker', {
43
+ this.option("yarnNodeLinker", {
44
44
  type: String,
45
45
  required: false,
46
- default: 'node-modules',
47
- desc: 'Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.',
46
+ default: "node-modules",
47
+ desc: "Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.",
48
48
  });
49
49
 
50
- this.option('typescript', {
50
+ this.option("typescript", {
51
51
  type: Boolean,
52
52
  required: false,
53
53
  default: false,
54
- desc: 'Typescript enabled',
54
+ desc: "Typescript enabled",
55
55
  });
56
56
 
57
- this.option('packageNames', {
57
+ this.option("packageNames", {
58
58
  type: String,
59
59
  required: false,
60
60
  });
61
61
 
62
- this.option('packageLocations', {
62
+ this.option("packageLocations", {
63
63
  type: String,
64
64
  required: false,
65
65
  });
@@ -67,57 +67,57 @@ export default class CoreVSCodeGenerator extends Generator {
67
67
 
68
68
  writing() {
69
69
  if (this.options.root) {
70
- const pkg = this.fs.readJSON(this.destinationPath('package.json'));
70
+ const pkg = this.fs.readJSON(this.destinationPath("package.json"));
71
71
  copyAndFormatTpl(
72
72
  this.fs,
73
- this.templatePath('extensions.json.ejs'),
74
- this.destinationPath('.vscode/extensions.json'),
73
+ this.templatePath("extensions.json.ejs"),
74
+ this.destinationPath(".vscode/extensions.json"),
75
75
  {
76
- yarn: this.options.packageManager === 'yarn',
77
- pnp: this.options.yarnNodeLinker === 'pnp',
78
- },
76
+ yarn: this.options.packageManager === "yarn",
77
+ pnp: this.options.yarnNodeLinker === "pnp",
78
+ }
79
79
  );
80
80
  copyAndFormatTpl(
81
81
  this.fs,
82
- this.templatePath('settings.json.ejs'),
83
- this.destinationPath('.vscode/settings.json'),
82
+ this.templatePath("settings.json.ejs"),
83
+ this.destinationPath(".vscode/settings.json"),
84
84
  {
85
- yarn: this.options.packageManager === 'yarn',
86
- pnp: this.options.yarnNodeLinker === 'pnp',
87
- npm: this.options.packageManager === 'npm',
85
+ yarn: this.options.packageManager === "yarn",
86
+ pnp: this.options.yarnNodeLinker === "pnp",
87
+ npm: this.options.packageManager === "npm",
88
88
  typescript: this.options.typescript,
89
89
  testing: this.options.testing,
90
90
  testRunner: this.options.testRunner,
91
- module: pkg.type === 'module',
92
- },
91
+ module: pkg.type === "module",
92
+ }
93
93
  );
94
94
 
95
95
  const tasksConfig = readJSON5(
96
96
  this.fs,
97
- this.destinationPath('.vscode/tasks.json'),
98
- {},
97
+ this.destinationPath(".vscode/tasks.json"),
98
+ {}
99
99
  );
100
100
  const tasks = tasksConfig.tasks || [];
101
101
 
102
102
  copyAndFormatTpl(
103
103
  this.fs,
104
- this.templatePath('tasks.json.ejs'),
105
- this.destinationPath('.vscode/tasks.json'),
104
+ this.templatePath("tasks.json.ejs"),
105
+ this.destinationPath(".vscode/tasks.json"),
106
106
  {
107
107
  typescript: this.options.typescript,
108
108
  tasks: JSON.stringify(tasks, null, 2),
109
- },
109
+ }
110
110
  );
111
111
 
112
112
  if (this.options.monorepo) {
113
- const projectName = pkg.name.replace('/', '-');
113
+ const projectName = pkg.name.replace("/", "-");
114
114
  // legacy project code-workspace
115
115
  this.fs.delete(
116
- this.destinationPath(`.vscode/${projectName}.code-workspace`),
116
+ this.destinationPath(`.vscode/${projectName}.code-workspace`)
117
117
  );
118
118
  }
119
119
  } else {
120
- this.fs.delete('.vscode');
120
+ this.fs.delete(".vscode");
121
121
  }
122
122
  }
123
123
  }
@@ -1,53 +1,53 @@
1
- import fs from 'node:fs';
2
- import sortObject from '@pob/sort-object';
3
- import yml from 'js-yaml';
4
- import { lt } from 'semver';
5
- import Generator from 'yeoman-generator';
6
- import ensureJsonFileFormatted from '../../../utils/ensureJsonFileFormatted.js';
7
- import inMonorepo from '../../../utils/inMonorepo.js';
8
- import * as packageUtils from '../../../utils/package.js';
9
- import { writeAndFormat } from '../../../utils/writeAndFormat.js';
1
+ import fs from "node:fs";
2
+ import sortObject from "@pob/sort-object";
3
+ import yml from "js-yaml";
4
+ import { lt } from "semver";
5
+ import Generator from "yeoman-generator";
6
+ import ensureJsonFileFormatted from "../../../utils/ensureJsonFileFormatted.js";
7
+ import inMonorepo from "../../../utils/inMonorepo.js";
8
+ import * as packageUtils from "../../../utils/package.js";
9
+ import { writeAndFormat } from "../../../utils/writeAndFormat.js";
10
10
 
11
11
  export default class CoreYarnGenerator extends Generator {
12
12
  constructor(args, opts) {
13
13
  super(args, opts);
14
14
 
15
- this.option('type', {
15
+ this.option("type", {
16
16
  type: String,
17
17
  required: false,
18
- default: 'app',
19
- desc: 'Project type',
18
+ default: "app",
19
+ desc: "Project type",
20
20
  });
21
21
 
22
- this.option('enable', {
22
+ this.option("enable", {
23
23
  type: Boolean,
24
24
  required: true,
25
- desc: 'Enable yarn',
25
+ desc: "Enable yarn",
26
26
  });
27
27
 
28
- this.option('yarnNodeLinker', {
28
+ this.option("yarnNodeLinker", {
29
29
  type: String,
30
30
  required: false,
31
- default: 'node-modules',
32
- desc: 'Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.',
31
+ default: "node-modules",
32
+ desc: "Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.",
33
33
  });
34
34
 
35
- this.option('disableYarnGitCache', {
35
+ this.option("disableYarnGitCache", {
36
36
  type: Boolean,
37
37
  required: false,
38
38
  default: false,
39
- desc: 'Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.',
39
+ desc: "Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.",
40
40
  });
41
41
  }
42
42
 
43
43
  initializing() {
44
44
  if (this.options.enable) {
45
45
  // dont use this.fs here, as it will cache the result
46
- if (!fs.existsSync('.yarnrc.yml')) {
46
+ if (!fs.existsSync(".yarnrc.yml")) {
47
47
  // yarn 2 not yet installed
48
48
  // https://yarnpkg.com/getting-started/install
49
- this.spawnSync('yarn', ['set', 'version', 'stable']);
50
- ensureJsonFileFormatted(this.destinationPath('package.json'));
49
+ this.spawnSync("yarn", ["set", "version", "stable"]);
50
+ ensureJsonFileFormatted(this.destinationPath("package.json"));
51
51
  } else {
52
52
  // disabled now that corepack is supposed to set the version used
53
53
  // this.spawnSync('yarn', ['set', 'version', 'stable']);)
@@ -56,38 +56,38 @@ export default class CoreYarnGenerator extends Generator {
56
56
  }
57
57
 
58
58
  writing() {
59
- const pkg = this.fs.readJSON(this.destinationPath('package.json'));
59
+ const pkg = this.fs.readJSON(this.destinationPath("package.json"));
60
60
 
61
61
  if (this.options.enable) {
62
62
  this.fs.copyTpl(
63
- this.templatePath('yarn_gitignore.ejs'),
64
- this.destinationPath('.yarn/.gitignore'),
63
+ this.templatePath("yarn_gitignore.ejs"),
64
+ this.destinationPath(".yarn/.gitignore"),
65
65
  {
66
66
  disableYarnGitCache: this.options.disableYarnGitCache,
67
- },
67
+ }
68
68
  );
69
69
 
70
70
  const { stdout } = this.spawnSync(
71
- 'yarn',
72
- ['plugin', 'runtime', '--json'],
73
- { stdio: 'pipe' },
71
+ "yarn",
72
+ ["plugin", "runtime", "--json"],
73
+ { stdio: "pipe" }
74
74
  );
75
- const installedPlugins = stdout.split('\n').map(JSON.parse);
75
+ const installedPlugins = stdout.split("\n").map(JSON.parse);
76
76
 
77
77
  const isPluginInstalled = (name) =>
78
78
  installedPlugins.some((plugin) => plugin.name === name);
79
79
 
80
80
  const installPlugin = (nameOrUrl) => {
81
- this.spawnSync('yarn', ['plugin', 'import', nameOrUrl]);
81
+ this.spawnSync("yarn", ["plugin", "import", nameOrUrl]);
82
82
  };
83
83
  const removePlugin = (name) => {
84
- this.spawnSync('yarn', ['plugin', 'remove', name]);
84
+ this.spawnSync("yarn", ["plugin", "remove", name]);
85
85
  };
86
86
 
87
87
  const installPluginIfNotInstalled = (
88
88
  name,
89
89
  nameOrUrl = name,
90
- forceInstallIfInstalled = () => false,
90
+ forceInstallIfInstalled = () => false
91
91
  ) => {
92
92
  if (!isPluginInstalled(name)) {
93
93
  installPlugin(nameOrUrl);
@@ -102,48 +102,48 @@ export default class CoreYarnGenerator extends Generator {
102
102
  }
103
103
  };
104
104
 
105
- const postinstallDevPluginName = '@yarnpkg/plugin-postinstall-dev';
106
- const versionPluginName = '@yarnpkg/plugin-conventional-version';
105
+ const postinstallDevPluginName = "@yarnpkg/plugin-postinstall-dev";
106
+ const versionPluginName = "@yarnpkg/plugin-conventional-version";
107
107
 
108
108
  if (!inMonorepo && !pkg.private) {
109
109
  installPluginIfNotInstalled(
110
110
  postinstallDevPluginName,
111
- 'https://raw.githubusercontent.com/sachinraja/yarn-plugin-postinstall-dev/main/bundles/%40yarnpkg/plugin-postinstall-dev.js',
111
+ "https://raw.githubusercontent.com/sachinraja/yarn-plugin-postinstall-dev/main/bundles/%40yarnpkg/plugin-postinstall-dev.js"
112
112
  );
113
113
  } else {
114
114
  removePluginIfInstalled(postinstallDevPluginName);
115
115
  }
116
116
 
117
- if (pkg.name !== 'yarn-plugin-conventional-version') {
117
+ if (pkg.name !== "yarn-plugin-conventional-version") {
118
118
  installPluginIfNotInstalled(
119
119
  versionPluginName,
120
- 'https://raw.githubusercontent.com/christophehurpeau/yarn-plugin-conventional-version/main/bundles/%40yarnpkg/plugin-conventional-version.cjs',
120
+ "https://raw.githubusercontent.com/christophehurpeau/yarn-plugin-conventional-version/main/bundles/%40yarnpkg/plugin-conventional-version.cjs",
121
121
  () => {
122
122
  const content = fs.readFileSync(
123
- '.yarn/plugins/@yarnpkg/plugin-conventional-version.cjs',
124
- 'utf8',
123
+ ".yarn/plugins/@yarnpkg/plugin-conventional-version.cjs",
124
+ "utf8"
125
125
  );
126
- return !content.includes('Lifecycle script: preversion');
127
- },
126
+ return !content.includes("Lifecycle script: preversion");
127
+ }
128
128
  );
129
129
  }
130
130
 
131
131
  if (
132
132
  !pkg.packageManager ||
133
- !pkg.packageManager.startsWith('yarn@') ||
134
- lt(pkg.packageManager.slice('yarn@'.length), '4.0.2')
133
+ !pkg.packageManager.startsWith("yarn@") ||
134
+ lt(pkg.packageManager.slice("yarn@".length), "4.0.2")
135
135
  ) {
136
- pkg.packageManager = 'yarn@4.0.2';
136
+ pkg.packageManager = "yarn@4.0.2";
137
137
  }
138
138
 
139
139
  // must be done after plugins installed
140
- const configString = this.fs.read('.yarnrc.yml');
140
+ const configString = this.fs.read(".yarnrc.yml");
141
141
  const config = yml.load(configString, {
142
142
  schema: yml.FAILSAFE_SCHEMA,
143
143
  json: true,
144
144
  });
145
145
  if (this.options.disableYarnGitCache) {
146
- config.compressionLevel = 'mixed'; // optimized for size
146
+ config.compressionLevel = "mixed"; // optimized for size
147
147
  config.enableGlobalCache = true;
148
148
  delete config.supportedArchitectures;
149
149
  } else {
@@ -152,12 +152,12 @@ export default class CoreYarnGenerator extends Generator {
152
152
  // https://yarnpkg.dev/releases/3-1/
153
153
  // make sure all supported architectures are in yarn cache
154
154
  config.supportedArchitectures = {
155
- cpu: ['x64', 'arm64'],
156
- os: ['linux', 'darwin'],
157
- libc: ['glibc', 'musl'],
155
+ cpu: ["x64", "arm64"],
156
+ os: ["linux", "darwin"],
157
+ libc: ["glibc", "musl"],
158
158
  };
159
159
  }
160
- config.defaultSemverRangePrefix = this.options.type === 'app' ? '' : '^';
160
+ config.defaultSemverRangePrefix = this.options.type === "app" ? "" : "^";
161
161
  delete config.enableMessageNames; // was a config for yarn < 4
162
162
  config.nodeLinker = this.options.yarnNodeLinker;
163
163
 
@@ -168,52 +168,52 @@ export default class CoreYarnGenerator extends Generator {
168
168
 
169
169
  writeAndFormat(
170
170
  this.fs,
171
- '.yarnrc.yml',
171
+ ".yarnrc.yml",
172
172
  yml.dump(sortObject(config), {
173
173
  lineWidth: 9999,
174
- }),
174
+ })
175
175
  );
176
176
  } else {
177
- this.fs.delete('.yarn');
178
- this.fs.delete('.yarnrc.yml');
179
- this.fs.delete('.yarn.lock');
177
+ this.fs.delete(".yarn");
178
+ this.fs.delete(".yarnrc.yml");
179
+ this.fs.delete(".yarn.lock");
180
180
  }
181
181
 
182
- packageUtils.removeDevDependencies(pkg, ['@yarnpkg/pnpify']);
183
- this.fs.writeJSON(this.destinationPath('package.json'), pkg);
182
+ packageUtils.removeDevDependencies(pkg, ["@yarnpkg/pnpify"]);
183
+ this.fs.writeJSON(this.destinationPath("package.json"), pkg);
184
184
  }
185
185
 
186
186
  end() {
187
- this.fs.delete(this.destinationPath('.yarn/build-state.yml'));
187
+ this.fs.delete(this.destinationPath(".yarn/build-state.yml"));
188
188
  if (this.options.enable) {
189
- if (this.options.yarnNodeLinker === 'pnp') {
190
- this.spawnSync('yarn', ['dlx', '@yarnpkg/sdks', 'vscode']);
189
+ if (this.options.yarnNodeLinker === "pnp") {
190
+ this.spawnSync("yarn", ["dlx", "@yarnpkg/sdks", "vscode"]);
191
191
  } else {
192
- this.fs.delete('.yarn/sdks');
192
+ this.fs.delete(".yarn/sdks");
193
193
  }
194
194
  if (this.options.disableYarnGitCache) {
195
195
  try {
196
- this.spawnSync('rm', ['-rf', '.yarn/cache']);
196
+ this.spawnSync("rm", ["-rf", ".yarn/cache"]);
197
197
  } catch {}
198
198
  }
199
- this.spawnSync('yarn', ['install'], {
199
+ this.spawnSync("yarn", ["install"], {
200
200
  env: {
201
- YARN_ENABLE_IMMUTABLE_INSTALLS: 'false',
201
+ YARN_ENABLE_IMMUTABLE_INSTALLS: "false",
202
202
  },
203
203
  });
204
- this.spawnSync('yarn', ['dedupe']);
204
+ this.spawnSync("yarn", ["dedupe"]);
205
205
 
206
- this.spawnSync('yarn', ['prettier', '--write', '.vscode', '.yarnrc.yml']);
206
+ this.spawnSync("yarn", ["prettier", "--write", ".vscode", ".yarnrc.yml"]);
207
207
 
208
- const pkg = this.fs.readJSON(this.destinationPath('package.json'));
208
+ const pkg = this.fs.readJSON(this.destinationPath("package.json"));
209
209
 
210
210
  if (pkg.scripts.preversion) {
211
211
  try {
212
- this.spawnSync('yarn', ['run', 'preversion']);
212
+ this.spawnSync("yarn", ["run", "preversion"]);
213
213
  } catch {}
214
214
  } else if (pkg.scripts.build) {
215
215
  try {
216
- this.spawnSync('yarn', ['run', 'build']);
216
+ this.spawnSync("yarn", ["run", "build"]);
217
217
  } catch {}
218
218
  }
219
219
  }