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.
- package/CHANGELOG.md +22 -0
- package/lib/generators/app/PobAppGenerator.js +120 -120
- package/lib/generators/app/e2e-testing/AppE2ETestingGenerator.js +11 -11
- package/lib/generators/app/ignorePaths.js +24 -24
- package/lib/generators/app/nextjs/AppNextjsGenerator.js +9 -9
- package/lib/generators/app/remix/AppRemixGenerator.js +7 -7
- package/lib/generators/common/babel/CommonBabelGenerator.js +146 -146
- package/lib/generators/common/format-lint/CommonLintGenerator.js +185 -185
- package/lib/generators/common/format-lint/updateEslintConfig.js +14 -15
- package/lib/generators/common/husky/CommonHuskyGenerator.js +44 -44
- package/lib/generators/common/old-dependencies/CommonRemoveOldDependenciesGenerator.js +44 -44
- package/lib/generators/common/release/CommonReleaseGenerator.js +40 -40
- package/lib/generators/common/testing/CommonTestingGenerator.js +190 -190
- package/lib/generators/common/testing/templates/index.js +3 -3
- package/lib/generators/common/transpiler/CommonTranspilerGenerator.js +163 -163
- package/lib/generators/common/typescript/CommonTypescriptGenerator.js +79 -79
- package/lib/generators/common/typescript/templates/tsconfig.js.json.ejs +12 -0
- package/lib/generators/core/ci/CoreCIGenerator.js +72 -72
- package/lib/generators/core/clean/CoreCleanGenerator.js +4 -4
- package/lib/generators/core/editorconfig/CoreEditorConfigGenerator.js +3 -3
- package/lib/generators/core/git/CoreGitGenerator.js +43 -43
- package/lib/generators/core/git/generators/github/CoreGitGithubGenerator.js +43 -43
- package/lib/generators/core/gitignore/CoreGitignoreGenerator.js +19 -19
- package/lib/generators/core/npm/CoreNpmGenerator.js +20 -20
- package/lib/generators/core/package/CorePackageGenerator.js +98 -98
- package/lib/generators/core/package/askName.js +4 -4
- package/lib/generators/core/renovate/CoreRenovateGenerator.js +28 -28
- package/lib/generators/core/sort-package/CoreSortPackageGenerator.js +6 -6
- package/lib/generators/core/vscode/CoreVSCodeGenerator.js +43 -43
- package/lib/generators/core/yarn/CoreYarnGenerator.js +70 -70
- package/lib/generators/lib/PobLibGenerator.js +111 -111
- package/lib/generators/lib/doc/LibDocGenerator.js +45 -45
- package/lib/generators/lib/readme/LibReadmeGenerator.js +21 -21
- package/lib/generators/monorepo/PobMonorepoGenerator.js +89 -89
- package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +47 -47
- package/lib/generators/monorepo/typescript/MonorepoTypescriptGenerator.js +38 -38
- package/lib/generators/monorepo/workspaces/MonorepoWorkspacesGenerator.js +57 -57
- package/lib/generators/pob/PobBaseGenerator.js +81 -81
- package/lib/pob-dirname.cjs +1 -1
- package/lib/pob.js +143 -143
- package/lib/utils/dependenciesPackages.cjs +4 -4
- package/lib/utils/ensureJsonFileFormatted.js +5 -5
- package/lib/utils/inMonorepo.js +8 -8
- package/lib/utils/json5.js +1 -1
- package/lib/utils/package.js +43 -43
- package/lib/utils/packagejson.cjs +2 -2
- package/lib/utils/templateUtils.js +1 -1
- package/lib/utils/writeAndFormat.js +9 -10
- package/package.json +10 -10
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
import { existsSync } from
|
|
2
|
-
import Generator from
|
|
3
|
-
import inMonorepo from
|
|
4
|
-
import * as packageUtils from
|
|
5
|
-
import { copyAndFormatTpl } from
|
|
1
|
+
import { existsSync } 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
|
+
import { copyAndFormatTpl } from "../../../utils/writeAndFormat.js";
|
|
6
6
|
|
|
7
7
|
export default class CommonTypescriptGenerator extends Generator {
|
|
8
8
|
constructor(args, opts) {
|
|
9
9
|
super(args, opts);
|
|
10
10
|
|
|
11
|
-
this.option(
|
|
11
|
+
this.option("enable", {
|
|
12
12
|
type: Boolean,
|
|
13
13
|
default: true,
|
|
14
|
-
desc:
|
|
14
|
+
desc: "enable typescript",
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
this.option(
|
|
17
|
+
this.option("isApp", {
|
|
18
18
|
type: Boolean,
|
|
19
19
|
required: true,
|
|
20
|
-
desc:
|
|
20
|
+
desc: "is app",
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
this.option(
|
|
23
|
+
this.option("isAppLibrary", {
|
|
24
24
|
type: Boolean,
|
|
25
25
|
required: false,
|
|
26
26
|
default: false,
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
this.option(
|
|
29
|
+
this.option("rootDir", {
|
|
30
30
|
type: String,
|
|
31
|
-
default:
|
|
32
|
-
desc:
|
|
31
|
+
default: "src",
|
|
32
|
+
desc: "customize rootDir",
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
this.option(
|
|
35
|
+
this.option("srcDirectory", {
|
|
36
36
|
type: String,
|
|
37
|
-
default:
|
|
38
|
-
desc:
|
|
37
|
+
default: "src",
|
|
38
|
+
desc: "customize srcDirectory, if different than rootDir",
|
|
39
39
|
});
|
|
40
40
|
|
|
41
|
-
this.option(
|
|
41
|
+
this.option("jsx", {
|
|
42
42
|
type: Boolean,
|
|
43
43
|
default: true,
|
|
44
|
-
desc:
|
|
44
|
+
desc: "enable jsx with typescript",
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
this.option(
|
|
47
|
+
this.option("jsxPreserve", {
|
|
48
48
|
type: Boolean,
|
|
49
49
|
default: false,
|
|
50
|
-
desc:
|
|
50
|
+
desc: "force jsx preserve in tsconfig for legacy apps (nextjs, CRA)",
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
this.option(
|
|
53
|
+
this.option("forceExcludeNodeModules", {
|
|
54
54
|
type: Boolean,
|
|
55
55
|
default: false,
|
|
56
|
-
desc:
|
|
56
|
+
desc: "force exclude node_modules for legacy apps (nextjs, CRA)",
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
this.option(
|
|
59
|
+
this.option("forceAllowJs", {
|
|
60
60
|
type: Boolean,
|
|
61
61
|
default: false,
|
|
62
|
-
desc:
|
|
62
|
+
desc: "force allow js for legacy apps (nextjs, CRA)",
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
this.option(
|
|
65
|
+
this.option("dom", {
|
|
66
66
|
type: Boolean,
|
|
67
67
|
default: true,
|
|
68
|
-
desc:
|
|
68
|
+
desc: "enable dom with typescript",
|
|
69
69
|
});
|
|
70
70
|
|
|
71
|
-
this.option(
|
|
71
|
+
this.option("baseUrl", {
|
|
72
72
|
type: String,
|
|
73
|
-
default:
|
|
74
|
-
desc:
|
|
73
|
+
default: "",
|
|
74
|
+
desc: "baseUrl option",
|
|
75
75
|
});
|
|
76
76
|
|
|
77
|
-
this.option(
|
|
77
|
+
this.option("resolveJsonModule", {
|
|
78
78
|
type: Boolean,
|
|
79
79
|
default: false,
|
|
80
|
-
desc:
|
|
80
|
+
desc: "resolveJsonModule option",
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
this.option(
|
|
83
|
+
this.option("builddefs", {
|
|
84
84
|
type: Boolean,
|
|
85
85
|
default: true,
|
|
86
|
-
desc:
|
|
86
|
+
desc: "build .d.ts option",
|
|
87
87
|
});
|
|
88
|
-
this.option(
|
|
88
|
+
this.option("plugins", {
|
|
89
89
|
type: String,
|
|
90
|
-
default:
|
|
91
|
-
desc:
|
|
90
|
+
default: "",
|
|
91
|
+
desc: "typescript plugins",
|
|
92
92
|
});
|
|
93
|
-
this.option(
|
|
93
|
+
this.option("nextConfig", {
|
|
94
94
|
type: Boolean,
|
|
95
95
|
default: false,
|
|
96
96
|
});
|
|
97
|
-
this.option(
|
|
97
|
+
this.option("additionalIncludes", {
|
|
98
98
|
type: String,
|
|
99
|
-
default:
|
|
100
|
-
desc:
|
|
99
|
+
default: "",
|
|
100
|
+
desc: "typescript additional includes",
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
this.option(
|
|
103
|
+
this.option("onlyLatestLTS", {
|
|
104
104
|
type: Boolean,
|
|
105
105
|
required: false,
|
|
106
106
|
default: false,
|
|
107
|
-
desc:
|
|
107
|
+
desc: "only latest lts",
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
writing() {
|
|
112
|
-
if (this.fs.exists(
|
|
113
|
-
if (this.fs.exists(this.destinationPath(
|
|
114
|
-
this.fs.delete(this.destinationPath(
|
|
112
|
+
if (this.fs.exists("flow-typed")) this.fs.delete("flow-typed");
|
|
113
|
+
if (this.fs.exists(this.destinationPath(".flowconfig"))) {
|
|
114
|
+
this.fs.delete(this.destinationPath(".flowconfig"));
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
117
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
118
118
|
|
|
119
119
|
const presets = (() => {
|
|
120
120
|
const babelEnvs = pkg.pob?.babelEnvs || [];
|
|
@@ -124,39 +124,39 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
124
124
|
|
|
125
125
|
if (withBabel) {
|
|
126
126
|
return jsx || this.options.dom
|
|
127
|
-
? [
|
|
128
|
-
: [
|
|
127
|
+
? ["@pob/root/tsconfigs/targets/rollup-babel-with-dom.json"]
|
|
128
|
+
: ["@pob/root/tsconfigs/targets/rollup-babel.json"];
|
|
129
129
|
}
|
|
130
130
|
if (withTypescript) {
|
|
131
|
-
const nodeVersion = this.options.onlyLatestLTS ?
|
|
131
|
+
const nodeVersion = this.options.onlyLatestLTS ? "20" : "18";
|
|
132
132
|
const envs = pkg.pob?.envs || [
|
|
133
133
|
{
|
|
134
|
-
target:
|
|
135
|
-
version:
|
|
134
|
+
target: "node",
|
|
135
|
+
version: "18",
|
|
136
136
|
},
|
|
137
137
|
];
|
|
138
138
|
if (pkg.pob.rollup === false || pkg.pob.bundler === false) {
|
|
139
139
|
return [`@pob/root/tsconfigs/targets/node-${nodeVersion}.json`];
|
|
140
140
|
}
|
|
141
|
-
if (envs && envs.every((env) => env.target ===
|
|
141
|
+
if (envs && envs.every((env) => env.target === "node")) {
|
|
142
142
|
return [
|
|
143
143
|
`@pob/root/tsconfigs/targets/${
|
|
144
|
-
!pkg.pob.bundler || pkg.pob.bundler.startsWith(
|
|
145
|
-
?
|
|
144
|
+
!pkg.pob.bundler || pkg.pob.bundler.startsWith("rollup")
|
|
145
|
+
? "rollup"
|
|
146
146
|
: pkg.pob.bundler
|
|
147
147
|
}-node-${nodeVersion}.json`,
|
|
148
148
|
];
|
|
149
149
|
}
|
|
150
|
-
return [
|
|
150
|
+
return ["@pob/root/tsconfigs/targets/rollup-es2015.json"];
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
if (this.options.dom) {
|
|
154
|
-
return [
|
|
154
|
+
return ["@pob/root/tsconfigs/targets/webpack.json"];
|
|
155
155
|
}
|
|
156
156
|
return [];
|
|
157
157
|
})();
|
|
158
158
|
|
|
159
|
-
packageUtils.removeDevDependencies(pkg, [
|
|
159
|
+
packageUtils.removeDevDependencies(pkg, ["flow-bin"]);
|
|
160
160
|
|
|
161
161
|
if (pkg.scripts) {
|
|
162
162
|
delete pkg.scripts.flow;
|
|
@@ -165,14 +165,14 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
165
165
|
packageUtils.addOrRemoveDevDependencies(
|
|
166
166
|
pkg,
|
|
167
167
|
this.options.enable ||
|
|
168
|
-
this.fs.exists(this.destinationPath(
|
|
169
|
-
[
|
|
168
|
+
this.fs.exists(this.destinationPath("lib/index.d.ts")),
|
|
169
|
+
["typescript"]
|
|
170
170
|
);
|
|
171
171
|
|
|
172
|
-
const tsconfigPath = this.destinationPath(
|
|
173
|
-
const tsconfigCheckPath = this.destinationPath(
|
|
174
|
-
const tsconfigEslintPath = this.destinationPath(
|
|
175
|
-
const tsconfigBuildPath = this.destinationPath(
|
|
172
|
+
const tsconfigPath = this.destinationPath("tsconfig.json");
|
|
173
|
+
const tsconfigCheckPath = this.destinationPath("tsconfig.check.json");
|
|
174
|
+
const tsconfigEslintPath = this.destinationPath("tsconfig.eslint.json");
|
|
175
|
+
const tsconfigBuildPath = this.destinationPath("tsconfig.build.json");
|
|
176
176
|
|
|
177
177
|
if (this.options.enable) {
|
|
178
178
|
const { jsx, dom } = this.options;
|
|
@@ -192,8 +192,8 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
192
192
|
if (composite) {
|
|
193
193
|
packageUtils.addOrRemoveDevDependencies(
|
|
194
194
|
pkg,
|
|
195
|
-
inMonorepo.rootPackageManager ===
|
|
196
|
-
[
|
|
195
|
+
inMonorepo.rootPackageManager === "yarn",
|
|
196
|
+
["typescript"]
|
|
197
197
|
);
|
|
198
198
|
|
|
199
199
|
const packageLocations = new Map(
|
|
@@ -202,21 +202,21 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
202
202
|
(packageName) =>
|
|
203
203
|
(pkg.dependencies && pkg.dependencies[packageName]) ||
|
|
204
204
|
(pkg.devDependencies && pkg.devDependencies[packageName]) ||
|
|
205
|
-
(pkg.peerDependencies && pkg.peerDependencies[packageName])
|
|
205
|
+
(pkg.peerDependencies && pkg.peerDependencies[packageName])
|
|
206
206
|
)
|
|
207
207
|
.map((packageName) => [
|
|
208
208
|
packageName,
|
|
209
209
|
`../../${
|
|
210
|
-
packageName[0] ===
|
|
210
|
+
packageName[0] === "@"
|
|
211
211
|
? // eslint-disable-next-line unicorn/no-nested-ternary
|
|
212
|
-
yoConfig.pob.project.type ===
|
|
212
|
+
yoConfig.pob.project.type === "app"
|
|
213
213
|
? `packages/${packageName.slice(
|
|
214
|
-
packageName.indexOf(
|
|
214
|
+
packageName.indexOf("/") + 1
|
|
215
215
|
)}`
|
|
216
216
|
: packageName
|
|
217
217
|
: `packages/${packageName}`
|
|
218
218
|
}`,
|
|
219
|
-
])
|
|
219
|
+
])
|
|
220
220
|
);
|
|
221
221
|
|
|
222
222
|
monorepoPackageSrcPaths = [...packageLocations.entries()].map(
|
|
@@ -224,14 +224,14 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
224
224
|
packageName,
|
|
225
225
|
`${packageLocation}/${
|
|
226
226
|
existsSync(`${packageLocations.get(packageName)}/tsconfig.json`)
|
|
227
|
-
?
|
|
228
|
-
:
|
|
227
|
+
? "src"
|
|
228
|
+
: "lib"
|
|
229
229
|
}`,
|
|
230
|
-
]
|
|
230
|
+
]
|
|
231
231
|
);
|
|
232
232
|
monorepoPackageReferences = yoConfig.pob.monorepo.packageNames
|
|
233
233
|
.filter((packageName) =>
|
|
234
|
-
existsSync(`${packageLocations.get(packageName)}/tsconfig.json`)
|
|
234
|
+
existsSync(`${packageLocations.get(packageName)}/tsconfig.json`)
|
|
235
235
|
)
|
|
236
236
|
.map((packageName) => packageLocations.get(packageName));
|
|
237
237
|
// monorepoPackageBuildReferences = yoConfig.pob.monorepo.packageNames
|
|
@@ -258,7 +258,7 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
258
258
|
*/
|
|
259
259
|
copyAndFormatTpl(
|
|
260
260
|
this.fs,
|
|
261
|
-
this.templatePath(
|
|
261
|
+
this.templatePath("tsconfig.json.ejs"),
|
|
262
262
|
tsconfigPath,
|
|
263
263
|
{
|
|
264
264
|
emitDefinitions: this.options.builddefs,
|
|
@@ -277,12 +277,12 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
277
277
|
resolveJsonModule: this.options.resolveJsonModule,
|
|
278
278
|
forceExcludeNodeModules: this.options.forceExcludeNodeModules,
|
|
279
279
|
forceAllowJs: this.options.forceAllowJs,
|
|
280
|
-
plugins: this.options.plugins.split(
|
|
280
|
+
plugins: this.options.plugins.split(",").filter(Boolean),
|
|
281
281
|
additionalIncludes: this.options.additionalIncludes
|
|
282
|
-
.split(
|
|
282
|
+
.split(",")
|
|
283
283
|
.filter(Boolean),
|
|
284
284
|
presets,
|
|
285
|
-
}
|
|
285
|
+
}
|
|
286
286
|
);
|
|
287
287
|
|
|
288
288
|
// if (
|
|
@@ -312,6 +312,6 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
312
312
|
this.fs.delete(tsconfigEslintPath);
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
this.fs.writeJSON(this.destinationPath(
|
|
315
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import Generator from
|
|
3
|
-
import inMonorepo from
|
|
4
|
-
import * as packageUtils from
|
|
5
|
-
import { copyAndFormatTpl } from
|
|
1
|
+
import fs 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
|
+
import { copyAndFormatTpl } from "../../../utils/writeAndFormat.js";
|
|
6
6
|
|
|
7
7
|
export const ciContexts = [];
|
|
8
8
|
|
|
@@ -10,52 +10,52 @@ export default class CoreCIGenerator extends Generator {
|
|
|
10
10
|
constructor(args, opts) {
|
|
11
11
|
super(args, opts);
|
|
12
12
|
|
|
13
|
-
this.option(
|
|
13
|
+
this.option("enable", {
|
|
14
14
|
type: Boolean,
|
|
15
15
|
default: true,
|
|
16
|
-
desc:
|
|
16
|
+
desc: "enable ci",
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
this.option(
|
|
19
|
+
this.option("enableReleasePlease", {
|
|
20
20
|
type: Boolean,
|
|
21
21
|
default: true,
|
|
22
|
-
desc:
|
|
22
|
+
desc: "enable release-please",
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
this.option(
|
|
25
|
+
this.option("enableYarnVersion", {
|
|
26
26
|
type: Boolean,
|
|
27
27
|
default: true,
|
|
28
|
-
desc:
|
|
28
|
+
desc: "enable yarn version conventional commits",
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
this.option(
|
|
31
|
+
this.option("build", {
|
|
32
32
|
type: Boolean,
|
|
33
33
|
default: true,
|
|
34
|
-
desc:
|
|
34
|
+
desc: "enable build",
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
this.option(
|
|
37
|
+
this.option("typescript", {
|
|
38
38
|
type: Boolean,
|
|
39
39
|
default: true,
|
|
40
|
-
desc:
|
|
40
|
+
desc: "enable typescript",
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
this.option(
|
|
43
|
+
this.option("testing", {
|
|
44
44
|
type: Boolean,
|
|
45
45
|
default: true,
|
|
46
|
-
desc:
|
|
46
|
+
desc: "enable testing",
|
|
47
47
|
});
|
|
48
|
-
this.option(
|
|
48
|
+
this.option("testRunner", {
|
|
49
49
|
type: String,
|
|
50
50
|
required: false,
|
|
51
|
-
default:
|
|
52
|
-
desc:
|
|
51
|
+
default: "jest",
|
|
52
|
+
desc: "test runner: jest | node",
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
this.option(
|
|
55
|
+
this.option("e2eTesting", {
|
|
56
56
|
type: String,
|
|
57
|
-
default:
|
|
58
|
-
desc:
|
|
57
|
+
default: "",
|
|
58
|
+
desc: "e2e testing package path",
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
// this.option('babelEnvs', {
|
|
@@ -64,57 +64,57 @@ export default class CoreCIGenerator extends Generator {
|
|
|
64
64
|
// desc: 'Babel Envs',
|
|
65
65
|
// });
|
|
66
66
|
|
|
67
|
-
this.option(
|
|
67
|
+
this.option("ci", {
|
|
68
68
|
type: Boolean,
|
|
69
69
|
required: true,
|
|
70
|
-
desc:
|
|
70
|
+
desc: "ci with github actions",
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
this.option(
|
|
73
|
+
this.option("codecov", {
|
|
74
74
|
type: Boolean,
|
|
75
75
|
required: true,
|
|
76
|
-
desc:
|
|
76
|
+
desc: "Include codecov report",
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
this.option(
|
|
79
|
+
this.option("documentation", {
|
|
80
80
|
type: Boolean,
|
|
81
81
|
required: true,
|
|
82
|
-
desc:
|
|
82
|
+
desc: "Include documentation generation",
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
this.option(
|
|
85
|
+
this.option("isApp", {
|
|
86
86
|
type: Boolean,
|
|
87
87
|
required: true,
|
|
88
|
-
desc:
|
|
88
|
+
desc: "is app",
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
this.option(
|
|
91
|
+
this.option("onlyLatestLTS", {
|
|
92
92
|
type: Boolean,
|
|
93
93
|
required: true,
|
|
94
|
-
desc:
|
|
94
|
+
desc: "only latest lts",
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
this.option(
|
|
97
|
+
this.option("splitJobs", {
|
|
98
98
|
type: Boolean,
|
|
99
99
|
required: true,
|
|
100
|
-
desc:
|
|
100
|
+
desc: "split CI jobs for faster result",
|
|
101
101
|
});
|
|
102
102
|
|
|
103
|
-
this.option(
|
|
103
|
+
this.option("disableYarnGitCache", {
|
|
104
104
|
type: Boolean,
|
|
105
105
|
required: false,
|
|
106
106
|
default: false,
|
|
107
|
-
desc:
|
|
107
|
+
desc: "Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.",
|
|
108
108
|
});
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
async prompting() {
|
|
112
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
112
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
113
113
|
|
|
114
114
|
this.isReleasePleaseEnabled =
|
|
115
115
|
this.options.enableReleasePlease &&
|
|
116
116
|
!this.options.enableYarnVersion &&
|
|
117
|
-
!pkg.devDependencies?.[
|
|
117
|
+
!pkg.devDependencies?.["standard-version"];
|
|
118
118
|
|
|
119
119
|
if (
|
|
120
120
|
this.options.enableReleasePlease &&
|
|
@@ -123,9 +123,9 @@ export default class CoreCIGenerator extends Generator {
|
|
|
123
123
|
!this.options.enableYarnVersion
|
|
124
124
|
) {
|
|
125
125
|
const { enableReleasePlease } = await this.prompt({
|
|
126
|
-
type:
|
|
127
|
-
name:
|
|
128
|
-
message:
|
|
126
|
+
type: "confirm",
|
|
127
|
+
name: "enableReleasePlease",
|
|
128
|
+
message: "Would you like to enable release please ?",
|
|
129
129
|
default: true,
|
|
130
130
|
});
|
|
131
131
|
this.isReleasePleaseEnabled = enableReleasePlease;
|
|
@@ -133,12 +133,12 @@ export default class CoreCIGenerator extends Generator {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
default() {
|
|
136
|
-
if (fs.existsSync(this.destinationPath(
|
|
137
|
-
fs.rmdirSync(this.destinationPath(
|
|
136
|
+
if (fs.existsSync(this.destinationPath(".circleci"))) {
|
|
137
|
+
fs.rmdirSync(this.destinationPath(".circleci"), { recursive: true });
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
if (this.options.enable) {
|
|
141
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
141
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
142
142
|
|
|
143
143
|
const checks = !!pkg.scripts && !!pkg.scripts.checks;
|
|
144
144
|
const testing =
|
|
@@ -149,16 +149,16 @@ export default class CoreCIGenerator extends Generator {
|
|
|
149
149
|
this.fs,
|
|
150
150
|
this.templatePath(
|
|
151
151
|
this.options.splitJobs
|
|
152
|
-
?
|
|
153
|
-
:
|
|
152
|
+
? "github-action-push-workflow-split.yml.ejs"
|
|
153
|
+
: "github-action-push-workflow.yml.ejs"
|
|
154
154
|
),
|
|
155
|
-
this.destinationPath(
|
|
155
|
+
this.destinationPath(".github/workflows/push.yml"),
|
|
156
156
|
{
|
|
157
157
|
packageManager: this.options.packageManager,
|
|
158
158
|
disableYarnGitCache: this.options.disableYarnGitCache,
|
|
159
159
|
testing,
|
|
160
160
|
e2eTesting:
|
|
161
|
-
this.options.e2eTesting && this.options.e2eTesting !==
|
|
161
|
+
this.options.e2eTesting && this.options.e2eTesting !== "false"
|
|
162
162
|
? this.options.e2eTesting
|
|
163
163
|
: false,
|
|
164
164
|
checks,
|
|
@@ -173,64 +173,64 @@ export default class CoreCIGenerator extends Generator {
|
|
|
173
173
|
this.isReleasePleaseEnabled &&
|
|
174
174
|
inMonorepo &&
|
|
175
175
|
inMonorepo.root &&
|
|
176
|
-
inMonorepo.pobConfig?.project?.type ===
|
|
177
|
-
}
|
|
176
|
+
inMonorepo.pobConfig?.project?.type === "lib",
|
|
177
|
+
}
|
|
178
178
|
);
|
|
179
179
|
|
|
180
180
|
ciContexts.push(
|
|
181
|
-
|
|
181
|
+
"reviewflow",
|
|
182
182
|
...(this.options.splitJobs
|
|
183
183
|
? [
|
|
184
|
-
checks &&
|
|
185
|
-
build &&
|
|
186
|
-
|
|
187
|
-
testing && !this.options.onlyLatestLTS &&
|
|
188
|
-
testing &&
|
|
184
|
+
checks && "checks",
|
|
185
|
+
build && "build",
|
|
186
|
+
"lint",
|
|
187
|
+
testing && !this.options.onlyLatestLTS && "test (18)",
|
|
188
|
+
testing && "test (20)",
|
|
189
189
|
].filter(Boolean)
|
|
190
190
|
: [
|
|
191
|
-
!this.options.onlyLatestLTS &&
|
|
192
|
-
|
|
193
|
-
].filter(Boolean))
|
|
191
|
+
!this.options.onlyLatestLTS && "build (18.x)",
|
|
192
|
+
"build (20.x)",
|
|
193
|
+
].filter(Boolean))
|
|
194
194
|
);
|
|
195
195
|
} else {
|
|
196
|
-
this.fs.delete(this.destinationPath(
|
|
196
|
+
this.fs.delete(this.destinationPath(".github/workflows/push.yml"));
|
|
197
197
|
}
|
|
198
198
|
|
|
199
199
|
if (
|
|
200
200
|
this.options.enable &&
|
|
201
201
|
!this.options.isApp &&
|
|
202
202
|
(this.options.documentation ||
|
|
203
|
-
(this.options.testing && this.options.testing.runner !==
|
|
203
|
+
(this.options.testing && this.options.testing.runner !== "node"))
|
|
204
204
|
) {
|
|
205
205
|
copyAndFormatTpl(
|
|
206
206
|
this.fs,
|
|
207
|
-
this.templatePath(
|
|
208
|
-
this.destinationPath(
|
|
207
|
+
this.templatePath("github-action-documentation-workflow.yml.ejs"),
|
|
208
|
+
this.destinationPath(".github/workflows/gh-pages.yml"),
|
|
209
209
|
{
|
|
210
210
|
packageManager: this.options.packageManager,
|
|
211
211
|
disableYarnGitCache: this.options.disableYarnGitCache,
|
|
212
212
|
testing: this.options.testing,
|
|
213
213
|
testRunner: this.options.testRunner,
|
|
214
214
|
typedoc: this.options.documentation && this.options.typescript,
|
|
215
|
-
}
|
|
215
|
+
}
|
|
216
216
|
);
|
|
217
217
|
} else {
|
|
218
|
-
this.fs.delete(this.destinationPath(
|
|
218
|
+
this.fs.delete(this.destinationPath(".github/workflows/gh-pages.yml"));
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
writing() {
|
|
223
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
223
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
224
224
|
|
|
225
|
-
this.fs.delete(this.destinationPath(
|
|
226
|
-
this.fs.delete(this.destinationPath(
|
|
225
|
+
this.fs.delete(this.destinationPath(".travis.yml"));
|
|
226
|
+
this.fs.delete(this.destinationPath("circle.yml"));
|
|
227
227
|
|
|
228
228
|
if (!this.options.enable) {
|
|
229
|
-
packageUtils.removeDevDependencies(pkg, [
|
|
229
|
+
packageUtils.removeDevDependencies(pkg, ["jest-junit-reporter"]);
|
|
230
230
|
} else {
|
|
231
|
-
packageUtils.removeDevDependencies(pkg, [
|
|
231
|
+
packageUtils.removeDevDependencies(pkg, ["jest-junit-reporter"]);
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
this.fs.writeJSON(this.destinationPath(
|
|
234
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import Generator from
|
|
1
|
+
import Generator from "yeoman-generator";
|
|
2
2
|
|
|
3
3
|
export default class CoreCleanGenerator extends Generator {
|
|
4
4
|
constructor(args, opts) {
|
|
5
5
|
super(args, opts);
|
|
6
6
|
|
|
7
|
-
this.option(
|
|
7
|
+
this.option("root", {
|
|
8
8
|
type: Boolean,
|
|
9
9
|
required: false,
|
|
10
10
|
default: true,
|
|
11
|
-
desc:
|
|
11
|
+
desc: "Root package.",
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
writing() {
|
|
16
16
|
if (!this.options.root) {
|
|
17
|
-
this.fs.delete(
|
|
17
|
+
this.fs.delete(".idea");
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}
|