pob 20.0.0 → 21.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.
- package/CHANGELOG.md +48 -0
- package/lib/generators/app/PobAppGenerator.js +12 -10
- package/lib/generators/app/e2e-testing/AppE2ETestingGenerator.js +2 -2
- package/lib/generators/app/ignorePaths.js +1 -0
- package/lib/generators/app/nextjs/AppNextjsGenerator.js +1 -1
- package/lib/generators/common/babel/CommonBabelGenerator.js +44 -28
- package/lib/generators/common/format-lint/CommonLintGenerator.js +33 -28
- package/lib/generators/common/format-lint/updateEslintConfig.js +5 -5
- package/lib/generators/common/husky/CommonHuskyGenerator.js +4 -4
- package/lib/generators/common/husky/templates/lint-staged.config.js.txt +1 -1
- package/lib/generators/common/release/CommonReleaseGenerator.js +14 -13
- package/lib/generators/common/release/templates/workflow-release.yml.ejs +2 -2
- package/lib/generators/common/testing/CommonTestingGenerator.js +46 -44
- package/lib/generators/common/transpiler/CommonTranspilerGenerator.js +18 -25
- package/lib/generators/common/typescript/CommonTypescriptGenerator.js +28 -24
- package/lib/generators/core/ci/CoreCIGenerator.js +20 -25
- package/lib/generators/core/clean/CoreCleanGenerator.js +1 -1
- package/lib/generators/core/editorconfig/CoreEditorConfigGenerator.js +1 -1
- package/lib/generators/core/git/CoreGitGenerator.js +6 -6
- package/lib/generators/core/git/generators/github/CoreGitGithubGenerator.js +8 -8
- package/lib/generators/core/gitignore/CoreGitignoreGenerator.js +7 -11
- package/lib/generators/core/npm/CoreNpmGenerator.js +4 -4
- package/lib/generators/core/package/CorePackageGenerator.js +18 -18
- package/lib/generators/core/renovate/CoreRenovateGenerator.js +5 -5
- package/lib/generators/core/sort-package/CoreSortPackageGenerator.js +1 -1
- package/lib/generators/core/vscode/CoreVSCodeGenerator.js +13 -12
- package/lib/generators/core/yarn/CoreYarnGenerator.js +32 -27
- package/lib/generators/lib/PobLibGenerator.js +22 -20
- package/lib/generators/lib/doc/LibDocGenerator.js +9 -9
- package/lib/generators/lib/readme/LibReadmeGenerator.js +7 -7
- package/lib/generators/monorepo/PobMonorepoGenerator.js +19 -18
- package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +19 -15
- package/lib/generators/monorepo/typescript/MonorepoTypescriptGenerator.js +6 -6
- package/lib/generators/monorepo/workspaces/MonorepoWorkspacesGenerator.js +23 -19
- package/lib/generators/pob/PobBaseGenerator.js +7 -7
- package/lib/pob.js +33 -33
- package/lib/utils/ensureJsonFileFormatted.js +1 -1
- package/lib/utils/inMonorepo.js +1 -1
- package/lib/utils/package.js +7 -7
- package/lib/utils/packagejson.js +5 -0
- package/lib/utils/templateUtils.js +1 -1
- package/lib/utils/writeAndFormat.js +2 -2
- package/package.json +21 -17
- package/lib/utils/packagejson.cjs +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,54 @@
|
|
|
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
|
+
## [21.0.0](https://github.com/christophehurpeau/pob/compare/pob@20.0.0...pob@21.0.0) (2024-06-07)
|
|
7
|
+
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* **deps:** use async prettier or prettier/sync
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add package yarn-version ([e2e8be6](https://github.com/christophehurpeau/pob/commit/e2e8be65fd50f9084c519fd07503748a1d970509))
|
|
15
|
+
* **deps:** update @pob/eslint-config to v56 (major) ([#2036](https://github.com/christophehurpeau/pob/issues/2036)) ([b26302b](https://github.com/christophehurpeau/pob/commit/b26302bd6dbf9bf4da2e97238c59ae80282ad9a4))
|
|
16
|
+
* **deps:** update dependency @rollup/plugin-run to v3.1.0 ([#2079](https://github.com/christophehurpeau/pob/issues/2079)) ([c2ef4fa](https://github.com/christophehurpeau/pob/commit/c2ef4fa22322952dcb626a5d99bc16e141684cd0))
|
|
17
|
+
* **deps:** update dependency conventional-changelog-conventionalcommits to v8 ([#2033](https://github.com/christophehurpeau/pob/issues/2033)) ([e7a568e](https://github.com/christophehurpeau/pob/commit/e7a568e4fabea00955bc6f005d85088f947f58cb))
|
|
18
|
+
* **deps:** update dependency esbuild to v0.21.0 ([#2040](https://github.com/christophehurpeau/pob/issues/2040)) ([dc252dc](https://github.com/christophehurpeau/pob/commit/dc252dc815dd450e2687e3f5784c3604bcfbab3c))
|
|
19
|
+
* **deps:** update dependency glob to v10.4.0 ([#2061](https://github.com/christophehurpeau/pob/issues/2061)) ([05dd06f](https://github.com/christophehurpeau/pob/commit/05dd06f1fb51d3cff0b95d6457fb9060d5d2db29))
|
|
20
|
+
* **deps:** update dependency prettier to v3 ([#1698](https://github.com/christophehurpeau/pob/issues/1698)) ([a65e641](https://github.com/christophehurpeau/pob/commit/a65e6418d4b80680b753a773b02925603df8ea12))
|
|
21
|
+
* **deps:** update dependency prettier to v3.3.0 ([#2071](https://github.com/christophehurpeau/pob/issues/2071)) ([04f24c3](https://github.com/christophehurpeau/pob/commit/04f24c33fcab0472cc830675696c219ee5ba14f9))
|
|
22
|
+
* **deps:** update dependency yeoman-generator to v7.2.0 ([#2063](https://github.com/christophehurpeau/pob/issues/2063)) ([a5b8748](https://github.com/christophehurpeau/pob/commit/a5b8748fecedff6291475656672feb1766c60e5f))
|
|
23
|
+
* migrate pob.babelEnvs to pob.envs + pob.bundler ([6baa9bb](https://github.com/christophehurpeau/pob/commit/6baa9bb986a1321beefcf9de3de566c285e548d1))
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* commit build of yarn-version ([539f4b2](https://github.com/christophehurpeau/pob/commit/539f4b2e12d8df4dc5cec272a24343721f4d2bdb))
|
|
28
|
+
* **deps:** update dependency esbuild to v0.21.1 ([#2042](https://github.com/christophehurpeau/pob/issues/2042)) ([2c47629](https://github.com/christophehurpeau/pob/commit/2c476296d1ecabaf272461df0901786bcea07aab))
|
|
29
|
+
* **deps:** update dependency esbuild to v0.21.2 ([#2051](https://github.com/christophehurpeau/pob/issues/2051)) ([8e8596f](https://github.com/christophehurpeau/pob/commit/8e8596f11350ee7e152ebec5603295edea8e6da7))
|
|
30
|
+
* **deps:** update dependency esbuild to v0.21.3 ([#2055](https://github.com/christophehurpeau/pob/issues/2055)) ([f27179c](https://github.com/christophehurpeau/pob/commit/f27179c5d6f4259a2885ee9097cf857b73849cef))
|
|
31
|
+
* **deps:** update dependency esbuild to v0.21.4 ([#2065](https://github.com/christophehurpeau/pob/issues/2065)) ([984e479](https://github.com/christophehurpeau/pob/commit/984e479c1958c224bc584936c13908578563e29d))
|
|
32
|
+
* **deps:** update dependency glob to v10.3.14 ([#2047](https://github.com/christophehurpeau/pob/issues/2047)) ([201fff2](https://github.com/christophehurpeau/pob/commit/201fff2e3def4a8c7344af403464e7bf16eb44bc))
|
|
33
|
+
* **deps:** update dependency glob to v10.3.15 ([#2050](https://github.com/christophehurpeau/pob/issues/2050)) ([8142969](https://github.com/christophehurpeau/pob/commit/8142969c29cda5fb5f8cf924522fd719ac0278d7))
|
|
34
|
+
* **deps:** update dependency glob to v10.3.16 ([#2056](https://github.com/christophehurpeau/pob/issues/2056)) ([d5ce7c0](https://github.com/christophehurpeau/pob/commit/d5ce7c0922a93a188250eb5e6a5eb8b14ac76630))
|
|
35
|
+
* **deps:** update dependency glob to v10.4.1 ([#2062](https://github.com/christophehurpeau/pob/issues/2062)) ([c9eb614](https://github.com/christophehurpeau/pob/commit/c9eb614f8b0906bf4757bb21ed2bed570dbf55c4))
|
|
36
|
+
* **deps:** update dependency lint-staged to v15.2.4 ([#2057](https://github.com/christophehurpeau/pob/issues/2057)) ([3266770](https://github.com/christophehurpeau/pob/commit/3266770fc90c82ccc25cd0bce67106063cf38b51))
|
|
37
|
+
* **deps:** update dependency lint-staged to v15.2.5 ([#2066](https://github.com/christophehurpeau/pob/issues/2066)) ([0c5396b](https://github.com/christophehurpeau/pob/commit/0c5396b73c9a99e37964c9752f2f55b4079f888e))
|
|
38
|
+
* **deps:** update dependency mem-fs-editor to v11.0.1 ([#2060](https://github.com/christophehurpeau/pob/issues/2060)) ([a4824cb](https://github.com/christophehurpeau/pob/commit/a4824cb89b8d94846ac7eb4ca062a500cadcc606))
|
|
39
|
+
* **deps:** update dependency prettier to v3.3.1 ([#2078](https://github.com/christophehurpeau/pob/issues/2078)) ([57ecb30](https://github.com/christophehurpeau/pob/commit/57ecb301bc6dded8e9063c1e3afc9f6f04d023b1))
|
|
40
|
+
* **deps:** update dependency semver to v7.6.1 ([#2041](https://github.com/christophehurpeau/pob/issues/2041)) ([17b20a3](https://github.com/christophehurpeau/pob/commit/17b20a3a352e4fbcda88d2e43938a8dbafe0667c))
|
|
41
|
+
* **deps:** update dependency semver to v7.6.2 ([#2048](https://github.com/christophehurpeau/pob/issues/2048)) ([e4a50f3](https://github.com/christophehurpeau/pob/commit/e4a50f3c11b87306ed30ec0cbcdd8f6f23a4ac75))
|
|
42
|
+
* **deps:** update dependency yeoman-environment to v4.4.1 ([#2073](https://github.com/christophehurpeau/pob/issues/2073)) ([528734e](https://github.com/christophehurpeau/pob/commit/528734e27f1f0b59ab5f5d87ff98e95385168b72))
|
|
43
|
+
* **deps:** update yarn monorepo ([#2045](https://github.com/christophehurpeau/pob/issues/2045)) ([bfce168](https://github.com/christophehurpeau/pob/commit/bfce1680e6df15f6a57e83fefc39e1257bf8f6e3))
|
|
44
|
+
* fix for CommonTestingGenerator ([e7f93df](https://github.com/christophehurpeau/pob/commit/e7f93df65007fe8a6e5faac6fd3d796adf6d3233))
|
|
45
|
+
* fix yarn-version command ([87e25ca](https://github.com/christophehurpeau/pob/commit/87e25cae86d3730f14e50e6370efe69bd2e21814))
|
|
46
|
+
* **pob:** leave default compressionLevel config ([3d4c5d1](https://github.com/christophehurpeau/pob/commit/3d4c5d1e92ec1194dec99e768c2743e085c1fa94))
|
|
47
|
+
* **pob:** missing await ([f91682b](https://github.com/christophehurpeau/pob/commit/f91682b72016733065d7d505c6be5d4fddad25d8))
|
|
48
|
+
* update json5 ([4034c94](https://github.com/christophehurpeau/pob/commit/4034c947a1111021ee037144cefbee0cd39b9d33))
|
|
49
|
+
Version bump for dependency: @pob/sort-pkg
|
|
50
|
+
Version bump for dependency: yarn-workspace-utils
|
|
51
|
+
Version bump for dependency: @pob/root
|
|
52
|
+
|
|
53
|
+
|
|
6
54
|
## [20.0.0](https://github.com/christophehurpeau/pob/compare/pob@19.2.0...pob@20.0.0) (2024-05-05)
|
|
7
55
|
|
|
8
56
|
Note: no notable changes
|
|
@@ -23,7 +23,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
23
23
|
type: Boolean,
|
|
24
24
|
required: false,
|
|
25
25
|
default: false,
|
|
26
|
-
|
|
26
|
+
description: "Avoid asking questions",
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
this.option("fromPob", {
|
|
@@ -35,21 +35,23 @@ export default class PobAppGenerator extends Generator {
|
|
|
35
35
|
this.option("packageManager", {
|
|
36
36
|
type: String,
|
|
37
37
|
default: "yarn",
|
|
38
|
-
|
|
38
|
+
description: "yarn or npm",
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
this.option("yarnNodeLinker", {
|
|
42
42
|
type: String,
|
|
43
43
|
required: false,
|
|
44
44
|
default: "node-modules",
|
|
45
|
-
|
|
45
|
+
description:
|
|
46
|
+
"Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.",
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
this.option("disableYarnGitCache", {
|
|
49
50
|
type: Boolean,
|
|
50
51
|
required: false,
|
|
51
52
|
default: false,
|
|
52
|
-
|
|
53
|
+
description:
|
|
54
|
+
"Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.",
|
|
53
55
|
});
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -171,16 +173,16 @@ export default class PobAppGenerator extends Generator {
|
|
|
171
173
|
this.composeWith("pob:common:husky", {});
|
|
172
174
|
}
|
|
173
175
|
|
|
174
|
-
const
|
|
176
|
+
const envs = (pkg.pob && (pkg.pob.babelEnvs || pkg.pob.envs)) || [];
|
|
175
177
|
const babel =
|
|
176
|
-
|
|
178
|
+
envs.length > 0 || appsWithTypescript.includes(this.appConfig.type);
|
|
177
179
|
const typescript = babel || pkg.pob?.typescript;
|
|
178
180
|
const node = true;
|
|
179
181
|
const browser =
|
|
180
182
|
appsWithBrowser.includes(this.appConfig.type) ||
|
|
181
|
-
(babel &&
|
|
183
|
+
(babel && envs.some((env) => env.target === "browser"));
|
|
182
184
|
const jsx =
|
|
183
|
-
|
|
185
|
+
envs.length > 0 && pkg.pob.jsx !== undefined
|
|
184
186
|
? pkg.pob.jsx
|
|
185
187
|
: packageUtils.hasReact(pkg);
|
|
186
188
|
|
|
@@ -190,7 +192,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
190
192
|
|
|
191
193
|
const ignorePaths = appIgnorePaths[this.appConfig.type](
|
|
192
194
|
this.appConfig,
|
|
193
|
-
pkg
|
|
195
|
+
pkg,
|
|
194
196
|
).filter(Boolean);
|
|
195
197
|
|
|
196
198
|
this.composeWith("pob:common:typescript", {
|
|
@@ -346,7 +348,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
346
348
|
execSync(
|
|
347
349
|
`rm -Rf ${["lib-*", "coverage", "docs", "dist"]
|
|
348
350
|
.filter(Boolean)
|
|
349
|
-
.join(" ")}
|
|
351
|
+
.join(" ")}`,
|
|
350
352
|
);
|
|
351
353
|
}
|
|
352
354
|
}
|
|
@@ -10,13 +10,13 @@ export default class AppE2ETestingGenerator extends Generator {
|
|
|
10
10
|
this.option("enable", {
|
|
11
11
|
type: Boolean,
|
|
12
12
|
default: true,
|
|
13
|
-
|
|
13
|
+
description: "enable e2e testing",
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
this.option("ci", {
|
|
17
17
|
type: Boolean,
|
|
18
18
|
required: true,
|
|
19
|
-
|
|
19
|
+
description: "ci",
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -3,6 +3,7 @@ import Generator from "yeoman-generator";
|
|
|
3
3
|
import * as packageUtils from "../../../utils/package.js";
|
|
4
4
|
import { copyAndFormatTpl } from "../../../utils/writeAndFormat.js";
|
|
5
5
|
|
|
6
|
+
/** @deprecated */
|
|
6
7
|
export default class CommonBabelGenerator extends Generator {
|
|
7
8
|
constructor(args, opts) {
|
|
8
9
|
super(args, opts);
|
|
@@ -11,14 +12,14 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
11
12
|
type: Boolean,
|
|
12
13
|
required: false,
|
|
13
14
|
default: false,
|
|
14
|
-
|
|
15
|
+
description: "Avoid asking questions",
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
this.option("testing", {
|
|
18
19
|
type: Boolean,
|
|
19
20
|
required: false,
|
|
20
21
|
default: false,
|
|
21
|
-
|
|
22
|
+
description: "Has testing.",
|
|
22
23
|
});
|
|
23
24
|
|
|
24
25
|
this.option("fromPob", {
|
|
@@ -55,26 +56,30 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
55
56
|
type: Boolean,
|
|
56
57
|
required: false,
|
|
57
58
|
default: false,
|
|
58
|
-
|
|
59
|
+
description: "only latest lts",
|
|
59
60
|
});
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
initializing() {
|
|
63
64
|
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
64
65
|
|
|
65
|
-
if (
|
|
66
|
-
|
|
66
|
+
if (
|
|
67
|
+
pkg.pob &&
|
|
68
|
+
(pkg.pob.babelEnvs ||
|
|
69
|
+
(pkg.pob.envs && pkg.pob.bundler === "rollup-babel"))
|
|
70
|
+
) {
|
|
71
|
+
let babelEnvs = pkg.pob.babelEnvs || pkg.pob.envs;
|
|
67
72
|
if (
|
|
68
73
|
!babelEnvs.some(
|
|
69
74
|
(env) =>
|
|
70
75
|
env.target === "node" &&
|
|
71
|
-
String(env.version) === (this.options.onlyLatestLTS ? "20" : "18")
|
|
76
|
+
String(env.version) === (this.options.onlyLatestLTS ? "20" : "18"),
|
|
72
77
|
) &&
|
|
73
78
|
babelEnvs.some(
|
|
74
79
|
(env) =>
|
|
75
80
|
env.target === "node" &&
|
|
76
81
|
(["8", "6", "10", "12", "14", "16"].includes(String(env.version)) ||
|
|
77
|
-
(this.options.onlyLatestLTS && String(env.version) === "18"))
|
|
82
|
+
(this.options.onlyLatestLTS && String(env.version) === "18")),
|
|
78
83
|
)
|
|
79
84
|
) {
|
|
80
85
|
babelEnvs.unshift({
|
|
@@ -86,10 +91,12 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
86
91
|
babelEnvs = babelEnvs.filter(
|
|
87
92
|
(env) =>
|
|
88
93
|
env.target !== "node" ||
|
|
89
|
-
env.version >= (this.options.onlyLatestLTS ? 20 : 18)
|
|
94
|
+
env.version >= (this.options.onlyLatestLTS ? 20 : 18),
|
|
90
95
|
);
|
|
91
96
|
|
|
92
|
-
pkg.pob.babelEnvs
|
|
97
|
+
delete pkg.pob.babelEnvs;
|
|
98
|
+
pkg.pob.bundler = "rollup-babel";
|
|
99
|
+
pkg.pob.envs = babelEnvs;
|
|
93
100
|
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
94
101
|
}
|
|
95
102
|
}
|
|
@@ -98,10 +105,12 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
98
105
|
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
99
106
|
|
|
100
107
|
const hasInitialPkgPob = !!pkg.pob;
|
|
101
|
-
|
|
102
108
|
if (!hasInitialPkgPob) pkg.pob = {};
|
|
103
109
|
|
|
104
|
-
const babelEnvs =
|
|
110
|
+
const babelEnvs =
|
|
111
|
+
pkg.pob.babelEnvs ||
|
|
112
|
+
(pkg.pob.bundler === "rollup-babel" && pkg.pob.envs) ||
|
|
113
|
+
[];
|
|
105
114
|
|
|
106
115
|
const targets = [
|
|
107
116
|
babelEnvs.some((env) => env.target === "node") ? "node" : undefined,
|
|
@@ -120,7 +129,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
120
129
|
return this.options.onlyLatestLTS ? "20" : "18";
|
|
121
130
|
}
|
|
122
131
|
return env.version;
|
|
123
|
-
})
|
|
132
|
+
}),
|
|
124
133
|
),
|
|
125
134
|
];
|
|
126
135
|
const browserVersions = babelEnvs
|
|
@@ -253,13 +262,17 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
253
262
|
|
|
254
263
|
delete pkg.pob.withReact;
|
|
255
264
|
if (newBabelEnvs.length === 0) {
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
delete pkg.pob.
|
|
259
|
-
|
|
265
|
+
if (!pkg.pob.bundler || pkg.pob.bundler === "rollup-babel") {
|
|
266
|
+
delete pkg.pob.envs;
|
|
267
|
+
delete pkg.pob.babelEnvs;
|
|
268
|
+
if (!pkg.pob.typescript) {
|
|
269
|
+
delete pkg.pob.entries;
|
|
270
|
+
delete pkg.pob.jsx;
|
|
271
|
+
}
|
|
260
272
|
}
|
|
261
273
|
} else {
|
|
262
|
-
pkg.pob.
|
|
274
|
+
pkg.pob.bundler = "rollup-babel";
|
|
275
|
+
pkg.pob.envs = newBabelEnvs;
|
|
263
276
|
pkg.pob.entries = pkg.pob.entries || ["index"];
|
|
264
277
|
if (pkg.pob.jsx) {
|
|
265
278
|
pkg.pob.jsx = jsx;
|
|
@@ -274,7 +287,10 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
274
287
|
configuring() {
|
|
275
288
|
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
276
289
|
this.entries = pkg.pob.entries;
|
|
277
|
-
this.babelEnvs =
|
|
290
|
+
this.babelEnvs =
|
|
291
|
+
pkg.pob.babelEnvs ||
|
|
292
|
+
(pkg.pob.bundler === "rollup-babel" && pkg.pob.envs) ||
|
|
293
|
+
[];
|
|
278
294
|
|
|
279
295
|
if (this.entries) {
|
|
280
296
|
this.entries.forEach((entry) => {
|
|
@@ -308,7 +324,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
308
324
|
? this.babelEnvs.find((env) => env.target === "node")
|
|
309
325
|
: useTypescript; // todo pkg.pob.typescriptTargets
|
|
310
326
|
const hasTargetBrowser = this.babelEnvs.find(
|
|
311
|
-
(env) => env.target === "browser"
|
|
327
|
+
(env) => env.target === "browser",
|
|
312
328
|
);
|
|
313
329
|
|
|
314
330
|
/* dependencies */
|
|
@@ -316,7 +332,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
316
332
|
packageUtils.addOrRemoveDevDependencies(
|
|
317
333
|
pkg,
|
|
318
334
|
useBabel || (pkg.peerDependencies && pkg.peerDependencies["@babel/core"]),
|
|
319
|
-
["@babel/core"]
|
|
335
|
+
["@babel/core"],
|
|
320
336
|
);
|
|
321
337
|
packageUtils.addOrRemoveDevDependencies(pkg, useBabel, ["pob-babel"]);
|
|
322
338
|
|
|
@@ -335,7 +351,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
335
351
|
pkg,
|
|
336
352
|
(useBabel && pkg.pob.jsx) ||
|
|
337
353
|
(pkg.devDependencies?.["@babel/preset-react"] && isLibraryRollupPlugin),
|
|
338
|
-
["@babel/preset-react"]
|
|
354
|
+
["@babel/preset-react"],
|
|
339
355
|
);
|
|
340
356
|
|
|
341
357
|
packageUtils.removeDevDependencies(pkg, [
|
|
@@ -348,10 +364,10 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
348
364
|
packageUtils.addOrRemoveDevDependencies(
|
|
349
365
|
pkg,
|
|
350
366
|
this.babelEnvs.find(
|
|
351
|
-
(env) => env.target === "browser" && env.version === undefined
|
|
367
|
+
(env) => env.target === "browser" && env.version === undefined,
|
|
352
368
|
) ||
|
|
353
369
|
(pkg.devDependencies?.["@babel/preset-env"] && isLibraryRollupPlugin),
|
|
354
|
-
["@babel/preset-env"]
|
|
370
|
+
["@babel/preset-env"],
|
|
355
371
|
);
|
|
356
372
|
|
|
357
373
|
/* engines */
|
|
@@ -362,7 +378,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
362
378
|
? Math.min(
|
|
363
379
|
...this.babelEnvs
|
|
364
380
|
.filter((env) => env.target === "node")
|
|
365
|
-
.map((env) => env.version)
|
|
381
|
+
.map((env) => env.version),
|
|
366
382
|
)
|
|
367
383
|
: // eslint-disable-next-line unicorn/no-unreadable-iife
|
|
368
384
|
(() => (this.options.onlyLatestLTS ? "20" : "18"))();
|
|
@@ -389,7 +405,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
389
405
|
pkg.devDependencies["@types/node"] &&
|
|
390
406
|
!semver.satisfies(
|
|
391
407
|
pkg.devDependencies["@types/node"],
|
|
392
|
-
`>=${minNodeVersion}.0.0
|
|
408
|
+
`>=${minNodeVersion}.0.0`,
|
|
393
409
|
)
|
|
394
410
|
) {
|
|
395
411
|
pkg.devDependencies["@types/node"] = `>=${minNodeVersion}.0.0`;
|
|
@@ -469,7 +485,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
469
485
|
config: this.options.useAppConfig,
|
|
470
486
|
outDirectory: this.options.buildDirectory,
|
|
471
487
|
enableRun: !this.options.isAppLibrary && entries.includes("index"),
|
|
472
|
-
}
|
|
488
|
+
},
|
|
473
489
|
);
|
|
474
490
|
} else {
|
|
475
491
|
copyAndFormatTpl(
|
|
@@ -478,7 +494,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
478
494
|
this.destinationPath("rollup.config.mjs"),
|
|
479
495
|
{
|
|
480
496
|
outDirectory: this.options.buildDirectory,
|
|
481
|
-
}
|
|
497
|
+
},
|
|
482
498
|
);
|
|
483
499
|
}
|
|
484
500
|
} else if (!pkg.pob.typescript && pkg.pob.rollup !== false) {
|
|
@@ -493,7 +509,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
493
509
|
if (this.fs.exists(this.destinationPath("babel.config.js"))) {
|
|
494
510
|
this.fs.move(
|
|
495
511
|
this.destinationPath("babel.config.js"),
|
|
496
|
-
this.destinationPath("babel.config.cjs")
|
|
512
|
+
this.destinationPath("babel.config.cjs"),
|
|
497
513
|
);
|
|
498
514
|
}
|
|
499
515
|
|
|
@@ -30,86 +30,87 @@ export default class CommonLintGenerator extends Generator {
|
|
|
30
30
|
type: String,
|
|
31
31
|
required: false,
|
|
32
32
|
default: "undefined",
|
|
33
|
-
|
|
33
|
+
description: "Use babel.",
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
this.option("documentation", {
|
|
37
37
|
type: Boolean,
|
|
38
38
|
required: false,
|
|
39
39
|
default: false,
|
|
40
|
-
|
|
40
|
+
description: "Documentation enabled",
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
this.option("testing", {
|
|
44
44
|
type: Boolean,
|
|
45
45
|
required: true,
|
|
46
|
-
|
|
46
|
+
description: "Testing enabled",
|
|
47
47
|
});
|
|
48
48
|
this.option("testRunner", {
|
|
49
49
|
type: String,
|
|
50
50
|
required: false,
|
|
51
51
|
default: "jest",
|
|
52
|
-
|
|
52
|
+
description: "test runner: jest | node",
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
this.option("typescript", {
|
|
56
56
|
type: Boolean,
|
|
57
57
|
required: false,
|
|
58
58
|
default: false,
|
|
59
|
-
|
|
59
|
+
description: "Typescript enabled",
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
this.option("enableSrcResolver", {
|
|
63
63
|
type: Boolean,
|
|
64
64
|
required: false,
|
|
65
65
|
default: false,
|
|
66
|
-
|
|
66
|
+
description: "Enable resolving from src directory",
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
this.option("rootAsSrc", {
|
|
70
70
|
type: Boolean,
|
|
71
71
|
required: false,
|
|
72
72
|
default: false,
|
|
73
|
-
|
|
73
|
+
description: "src directory is root",
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
this.option("appTypes", {
|
|
77
77
|
type: String,
|
|
78
78
|
required: false,
|
|
79
|
-
|
|
79
|
+
description: "list of app types",
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
this.option("rootIgnorePaths", {
|
|
83
83
|
type: String,
|
|
84
84
|
required: false,
|
|
85
85
|
default: "",
|
|
86
|
-
|
|
86
|
+
description: "list of ignore paths to add",
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
this.option("ignorePaths", {
|
|
90
90
|
type: String,
|
|
91
91
|
required: false,
|
|
92
92
|
default: "",
|
|
93
|
-
|
|
93
|
+
description: "list of ignore paths to add",
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
this.option("packageManager", {
|
|
97
97
|
type: String,
|
|
98
98
|
default: "yarn",
|
|
99
|
-
|
|
99
|
+
description: "yarn or npm",
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
this.option("yarnNodeLinker", {
|
|
103
103
|
type: String,
|
|
104
104
|
required: false,
|
|
105
105
|
default: "node-modules",
|
|
106
|
-
|
|
106
|
+
description:
|
|
107
|
+
"Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.",
|
|
107
108
|
});
|
|
108
109
|
|
|
109
110
|
this.option("srcDirectory", {
|
|
110
111
|
type: String,
|
|
111
112
|
default: "src",
|
|
112
|
-
|
|
113
|
+
description: "customize src directory. Default to src",
|
|
113
114
|
});
|
|
114
115
|
|
|
115
116
|
this.option("buildDirectory", {
|
|
@@ -121,7 +122,11 @@ export default class CommonLintGenerator extends Generator {
|
|
|
121
122
|
|
|
122
123
|
writing() {
|
|
123
124
|
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
124
|
-
const babelEnvs =
|
|
125
|
+
const babelEnvs =
|
|
126
|
+
(pkg.pob &&
|
|
127
|
+
(pkg.pob.babelEnvs ||
|
|
128
|
+
(pkg.pob.bundler === "rollup-babel" && pkg.pob.envs))) ||
|
|
129
|
+
[];
|
|
125
130
|
// const typescriptTargets = (pkg.pob && pkg.pob.typescriptTargets) || [];
|
|
126
131
|
const useBabel =
|
|
127
132
|
this.options.babel !== "undefined"
|
|
@@ -139,7 +144,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
139
144
|
pkg.pob?.entries.every(
|
|
140
145
|
(entry) =>
|
|
141
146
|
typeof entry === "string" ||
|
|
142
|
-
(entry.target && entry.target !== "node")
|
|
147
|
+
(entry.target && entry.target !== "node"),
|
|
143
148
|
))) ||
|
|
144
149
|
(babelEnvs.length > 0 && babelEnvs.every((env) => env.target === "node"));
|
|
145
150
|
|
|
@@ -165,10 +170,10 @@ export default class CommonLintGenerator extends Generator {
|
|
|
165
170
|
|
|
166
171
|
if (!inMonorepo || inMonorepo.root || this.options.monorepo) {
|
|
167
172
|
const rootIgnorePatterns = new Set(
|
|
168
|
-
this.options.rootIgnorePaths.split("\n").filter(Boolean)
|
|
173
|
+
this.options.rootIgnorePaths.split("\n").filter(Boolean),
|
|
169
174
|
);
|
|
170
175
|
const ignorePatterns = new Set(
|
|
171
|
-
this.options.ignorePaths.split("\n").filter(Boolean)
|
|
176
|
+
this.options.ignorePaths.split("\n").filter(Boolean),
|
|
172
177
|
);
|
|
173
178
|
|
|
174
179
|
if (this.options.appTypes) {
|
|
@@ -195,7 +200,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
195
200
|
hasApp: this.options.hasApp,
|
|
196
201
|
rootIgnorePatterns: [...rootIgnorePatterns],
|
|
197
202
|
ignorePatterns: [...ignorePatterns],
|
|
198
|
-
}
|
|
203
|
+
},
|
|
199
204
|
);
|
|
200
205
|
} else if (this.fs.exists(this.destinationPath(".prettierignore"))) {
|
|
201
206
|
this.fs.delete(this.destinationPath(".prettierignore"));
|
|
@@ -270,7 +275,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
270
275
|
"eslint-plugin-unicorn",
|
|
271
276
|
"eslint-plugin-import",
|
|
272
277
|
],
|
|
273
|
-
true
|
|
278
|
+
true,
|
|
274
279
|
);
|
|
275
280
|
}
|
|
276
281
|
} else {
|
|
@@ -286,7 +291,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
286
291
|
(rootPackageManager === "yarn" &&
|
|
287
292
|
rootYarnNodeLinker !== "node-modules") ||
|
|
288
293
|
!!(pkg.peerDependencies && pkg.peerDependencies.eslint),
|
|
289
|
-
["eslint"]
|
|
294
|
+
["eslint"],
|
|
290
295
|
);
|
|
291
296
|
const shouldHavePluginsDependencies =
|
|
292
297
|
rootPackageManager === "yarn" && rootYarnNodeLinker !== "node-modules";
|
|
@@ -300,13 +305,13 @@ export default class CommonLintGenerator extends Generator {
|
|
|
300
305
|
packageUtils.addOrRemoveDevDependencies(
|
|
301
306
|
pkg,
|
|
302
307
|
shouldHavePluginsDependencies,
|
|
303
|
-
["eslint-plugin-import", "eslint-plugin-unicorn"]
|
|
308
|
+
["eslint-plugin-import", "eslint-plugin-unicorn"],
|
|
304
309
|
);
|
|
305
310
|
|
|
306
311
|
packageUtils.addOrRemoveDevDependencies(
|
|
307
312
|
pkg,
|
|
308
313
|
shouldHavePluginsDependencies,
|
|
309
|
-
["eslint-plugin-node"]
|
|
314
|
+
["eslint-plugin-node"],
|
|
310
315
|
);
|
|
311
316
|
|
|
312
317
|
if ((inMonorepo && inMonorepo.root) || this.options.monorepo) {
|
|
@@ -324,7 +329,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
324
329
|
packageUtils.addOrRemoveDevDependencies(
|
|
325
330
|
pkg,
|
|
326
331
|
this.options.typescript && shouldHavePluginsDependencies,
|
|
327
|
-
["@typescript-eslint/eslint-plugin", "@typescript-eslint/parser"]
|
|
332
|
+
["@typescript-eslint/eslint-plugin", "@typescript-eslint/parser"],
|
|
328
333
|
);
|
|
329
334
|
} else {
|
|
330
335
|
packageUtils.addOrRemoveDevDependencies(pkg, useTypescript, [
|
|
@@ -333,7 +338,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
333
338
|
packageUtils.addOrRemoveDevDependencies(
|
|
334
339
|
pkg,
|
|
335
340
|
useTypescript && shouldHavePluginsDependencies,
|
|
336
|
-
["@typescript-eslint/eslint-plugin", "@typescript-eslint/parser"]
|
|
341
|
+
["@typescript-eslint/eslint-plugin", "@typescript-eslint/parser"],
|
|
337
342
|
);
|
|
338
343
|
|
|
339
344
|
packageUtils.addOrRemoveDevDependencies(pkg, hasReact, [
|
|
@@ -450,7 +455,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
450
455
|
: this.destinationPath(
|
|
451
456
|
`${
|
|
452
457
|
useTypescript ? `${this.options.srcDirectory}/` : "lib/"
|
|
453
|
-
}.eslintrc.json
|
|
458
|
+
}.eslintrc.json`,
|
|
454
459
|
);
|
|
455
460
|
|
|
456
461
|
const getRootIgnorePatterns = () => {
|
|
@@ -506,7 +511,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
506
511
|
rootIgnorePatterns.size === 0
|
|
507
512
|
? undefined
|
|
508
513
|
: [...rootIgnorePatterns],
|
|
509
|
-
}
|
|
514
|
+
},
|
|
510
515
|
);
|
|
511
516
|
|
|
512
517
|
writeAndFormatJson(this.fs, rootEslintrcPath, rootEslintrcConfig);
|
|
@@ -555,7 +560,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
555
560
|
: false,
|
|
556
561
|
},
|
|
557
562
|
relativePath: inMonorepo ? inMonorepo.relative : undefined,
|
|
558
|
-
}
|
|
563
|
+
},
|
|
559
564
|
);
|
|
560
565
|
|
|
561
566
|
writeAndFormatJson(this.fs, srcEslintrcPath, srcEslintrcConfig);
|
|
@@ -571,7 +576,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
571
576
|
const lintRootJsFiles = (useBabel && useNode) || !inMonorepo;
|
|
572
577
|
|
|
573
578
|
const lintPaths = [srcDirectory, "bin", "scripts", "migrations"].filter(
|
|
574
|
-
(dir) => fs.existsSync(this.destinationPath(dir))
|
|
579
|
+
(dir) => fs.existsSync(this.destinationPath(dir)),
|
|
575
580
|
);
|
|
576
581
|
|
|
577
582
|
if (lintRootJsFiles) {
|
|
@@ -8,7 +8,7 @@ function updateOverrides(config, testsOverride) {
|
|
|
8
8
|
? (override) => override.env && override.env.jest
|
|
9
9
|
: (override) =>
|
|
10
10
|
override?.env?.jest ||
|
|
11
|
-
override.extends?.includes(testsOverride.extends[0])
|
|
11
|
+
override.extends?.includes(testsOverride.extends[0]),
|
|
12
12
|
);
|
|
13
13
|
if (!testsOverride) {
|
|
14
14
|
if (existingTestsOverrideIndex !== -1) {
|
|
@@ -45,7 +45,7 @@ function updateParserAndPlugins(
|
|
|
45
45
|
config,
|
|
46
46
|
useTypescript,
|
|
47
47
|
globalEslint,
|
|
48
|
-
relativePath
|
|
48
|
+
relativePath,
|
|
49
49
|
) {
|
|
50
50
|
if (useTypescript) {
|
|
51
51
|
// webstorm uses this to detect eslint .ts compat
|
|
@@ -126,7 +126,7 @@ export default function updateEslintConfig(
|
|
|
126
126
|
settings,
|
|
127
127
|
ignorePatterns,
|
|
128
128
|
relativePath,
|
|
129
|
-
}
|
|
129
|
+
},
|
|
130
130
|
) {
|
|
131
131
|
config.root = true;
|
|
132
132
|
config.extends = [
|
|
@@ -134,7 +134,7 @@ export default function updateEslintConfig(
|
|
|
134
134
|
...(config?.extends && Array.isArray(config.extends)
|
|
135
135
|
? config.extends.filter(
|
|
136
136
|
(extendsValue) =>
|
|
137
|
-
extendsValue === "@pob/eslint-config-typescript/allow-unsafe"
|
|
137
|
+
extendsValue === "@pob/eslint-config-typescript/allow-unsafe",
|
|
138
138
|
)
|
|
139
139
|
: []),
|
|
140
140
|
];
|
|
@@ -143,7 +143,7 @@ export default function updateEslintConfig(
|
|
|
143
143
|
config,
|
|
144
144
|
useTypescript,
|
|
145
145
|
globalEslint,
|
|
146
|
-
relativePath
|
|
146
|
+
relativePath,
|
|
147
147
|
);
|
|
148
148
|
config = updateOverrides(config, testsOverride);
|
|
149
149
|
if (settings) {
|