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,38 +1,38 @@
|
|
|
1
|
-
import { fileURLToPath } from
|
|
2
|
-
import Generator from
|
|
3
|
-
import ensureJsonFileFormatted from
|
|
4
|
-
import inMonorepo from
|
|
5
|
-
import * as packageUtils from
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import Generator from "yeoman-generator";
|
|
3
|
+
import ensureJsonFileFormatted from "../../utils/ensureJsonFileFormatted.js";
|
|
4
|
+
import inMonorepo from "../../utils/inMonorepo.js";
|
|
5
|
+
import * as packageUtils from "../../utils/package.js";
|
|
6
6
|
|
|
7
7
|
export default class PobBaseGenerator extends Generator {
|
|
8
8
|
constructor(args, opts) {
|
|
9
9
|
super(args, opts, { customInstallTask: true });
|
|
10
10
|
|
|
11
|
-
this.option(
|
|
11
|
+
this.option("monorepo", {
|
|
12
12
|
type: Boolean,
|
|
13
13
|
required: false,
|
|
14
|
-
desc:
|
|
14
|
+
desc: "monorepo",
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
this.option(
|
|
17
|
+
this.option("type", {
|
|
18
18
|
type: String,
|
|
19
19
|
required: true,
|
|
20
|
-
desc:
|
|
20
|
+
desc: "Type of generator",
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
this.option(
|
|
23
|
+
this.option("updateOnly", {
|
|
24
24
|
type: Boolean,
|
|
25
25
|
required: true,
|
|
26
26
|
desc: "Don't ask questions if we already have the answers",
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
this.option(
|
|
29
|
+
this.option("fromPob", {
|
|
30
30
|
type: Boolean,
|
|
31
31
|
required: true,
|
|
32
32
|
desc: "Don't run yarn or build",
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
this.option(
|
|
35
|
+
this.option("force", {
|
|
36
36
|
type: Boolean,
|
|
37
37
|
required: true,
|
|
38
38
|
desc: "Don't check diff",
|
|
@@ -40,12 +40,12 @@ export default class PobBaseGenerator extends Generator {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
rootGeneratorName() {
|
|
43
|
-
return
|
|
43
|
+
return "pob";
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
initializing() {
|
|
47
47
|
// prettier package.json to ensure diff is correct
|
|
48
|
-
ensureJsonFileFormatted(this.destinationPath(
|
|
48
|
+
ensureJsonFileFormatted(this.destinationPath("package.json"));
|
|
49
49
|
|
|
50
50
|
if (this.options.monorepo) {
|
|
51
51
|
this.isMonorepo = true;
|
|
@@ -59,115 +59,115 @@ export default class PobBaseGenerator extends Generator {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
async prompting() {
|
|
62
|
-
let config = this.config.get(
|
|
62
|
+
let config = this.config.get("project");
|
|
63
63
|
if (config && config.type && config.packageManager) {
|
|
64
64
|
this.projectConfig = config;
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
const oldConfigStorage = this._getStorage(super.rootGeneratorName());
|
|
69
|
-
config = oldConfigStorage.get(
|
|
69
|
+
config = oldConfigStorage.get("type") || oldConfigStorage.get("project");
|
|
70
70
|
if (config) {
|
|
71
|
-
oldConfigStorage.delete(
|
|
72
|
-
oldConfigStorage.delete(
|
|
71
|
+
oldConfigStorage.delete("type");
|
|
72
|
+
oldConfigStorage.delete("project");
|
|
73
73
|
} else {
|
|
74
74
|
config = {};
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
if (
|
|
77
|
+
if ("yarn2" in config) {
|
|
78
78
|
if (config.yarn2) {
|
|
79
|
-
config.yarnNodeLinker =
|
|
79
|
+
config.yarnNodeLinker = "node-modules";
|
|
80
80
|
}
|
|
81
81
|
delete config.yarn2;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (!config.type) {
|
|
85
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
85
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"), {});
|
|
86
86
|
if (pkg.dependencies?.next) {
|
|
87
|
-
config.type =
|
|
87
|
+
config.type = "app";
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
const responses = await this.prompt([
|
|
92
92
|
{
|
|
93
93
|
when: () => !config.type,
|
|
94
|
-
name:
|
|
95
|
-
message:
|
|
96
|
-
type:
|
|
97
|
-
choices: [
|
|
98
|
-
default: (config && config.type) || this.options.type ||
|
|
94
|
+
name: "type",
|
|
95
|
+
message: "What kind of project is this ?",
|
|
96
|
+
type: "list",
|
|
97
|
+
choices: ["lib", "app"],
|
|
98
|
+
default: (config && config.type) || this.options.type || "lib",
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
101
|
when: () => this.isRoot && !config.packageManager,
|
|
102
|
-
name:
|
|
103
|
-
message:
|
|
104
|
-
type:
|
|
105
|
-
choices: [
|
|
106
|
-
default: config.packageManager ||
|
|
102
|
+
name: "packageManager",
|
|
103
|
+
message: "Witch package manager do you want to use ?",
|
|
104
|
+
type: "list",
|
|
105
|
+
choices: ["yarn", "npm"],
|
|
106
|
+
default: config.packageManager || "yarn",
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
when: ({ packageManager = config.packageManager }) =>
|
|
110
|
-
this.isRoot && packageManager ===
|
|
111
|
-
name:
|
|
112
|
-
message:
|
|
113
|
-
type:
|
|
114
|
-
choices: [
|
|
115
|
-
default: config.yarnNodeLinker ||
|
|
110
|
+
this.isRoot && packageManager === "yarn" && !config.yarnNodeLinker,
|
|
111
|
+
name: "yarnNodeLinker",
|
|
112
|
+
message: "Witch Linker do you want to use ?",
|
|
113
|
+
type: "list",
|
|
114
|
+
choices: ["node-modules", "pnp", "pnpm"],
|
|
115
|
+
default: config.yarnNodeLinker || "node-modules",
|
|
116
116
|
},
|
|
117
117
|
]);
|
|
118
118
|
|
|
119
119
|
this.projectConfig = { ...config, ...responses };
|
|
120
|
-
this.config.set(
|
|
120
|
+
this.config.set("project", this.projectConfig);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
default() {
|
|
124
|
-
this.composeWith(
|
|
124
|
+
this.composeWith("pob:core:yarn", {
|
|
125
125
|
type: this.projectConfig.type,
|
|
126
|
-
enable: this.isRoot && this.projectConfig.packageManager ===
|
|
126
|
+
enable: this.isRoot && this.projectConfig.packageManager === "yarn",
|
|
127
127
|
yarnNodeLinker: this.projectConfig.yarnNodeLinker,
|
|
128
128
|
disableYarnGitCache: this.projectConfig.disableYarnGitCache !== false,
|
|
129
129
|
});
|
|
130
130
|
|
|
131
|
-
this.composeWith(
|
|
131
|
+
this.composeWith("pob:core:package", {
|
|
132
132
|
updateOnly: this.options.updateOnly,
|
|
133
|
-
private: this.isMonorepo || this.projectConfig.type ===
|
|
133
|
+
private: this.isMonorepo || this.projectConfig.type === "app",
|
|
134
134
|
isMonorepo: this.isMonorepo,
|
|
135
135
|
inMonorepo: !!inMonorepo,
|
|
136
136
|
isRoot: this.isRoot,
|
|
137
|
-
packageType: this.projectConfig.type ===
|
|
137
|
+
packageType: this.projectConfig.type === "app" ? "module" : undefined,
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
if (this.isMonorepo) {
|
|
141
|
-
this.composeWith(
|
|
141
|
+
this.composeWith("pob:monorepo:workspaces", {
|
|
142
142
|
force: this.options.force,
|
|
143
|
-
isAppProject: this.projectConfig.type ===
|
|
143
|
+
isAppProject: this.projectConfig.type === "app",
|
|
144
144
|
packageManager: this.projectConfig.packageManager,
|
|
145
145
|
disableYarnGitCache: this.projectConfig.disableYarnGitCache !== false,
|
|
146
146
|
});
|
|
147
|
-
this.composeWith(
|
|
147
|
+
this.composeWith("pob:monorepo:lerna", {
|
|
148
148
|
force: this.options.force,
|
|
149
|
-
isAppProject: this.projectConfig.type ===
|
|
149
|
+
isAppProject: this.projectConfig.type === "app",
|
|
150
150
|
packageManager: this.projectConfig.packageManager,
|
|
151
151
|
disableYarnGitCache: this.projectConfig.disableYarnGitCache !== false,
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
-
this.fs.delete(
|
|
156
|
-
this.fs.delete(this.destinationPath(
|
|
155
|
+
this.fs.delete("Makefile");
|
|
156
|
+
this.fs.delete(this.destinationPath(".commitrc.js"));
|
|
157
157
|
|
|
158
|
-
this.composeWith(
|
|
158
|
+
this.composeWith("pob:core:editorconfig");
|
|
159
159
|
|
|
160
|
-
this.composeWith(
|
|
160
|
+
this.composeWith("pob:core:clean", {
|
|
161
161
|
root: this.isRoot,
|
|
162
162
|
});
|
|
163
163
|
|
|
164
|
-
this.composeWith(
|
|
164
|
+
this.composeWith("pob:core:renovate", {
|
|
165
165
|
updateOnly: this.options.updateOnly,
|
|
166
|
-
app: this.projectConfig.type ===
|
|
166
|
+
app: this.projectConfig.type === "app",
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
const onlyLatestLTS =
|
|
170
|
-
this.projectConfig.type ===
|
|
170
|
+
this.projectConfig.type === "app" ||
|
|
171
171
|
(inMonorepo &&
|
|
172
172
|
(inMonorepo.pobConfig?.project?.supportsNode14 === false ||
|
|
173
173
|
inMonorepo.pobConfig?.project?.onlyLatestLTS === true));
|
|
@@ -175,49 +175,49 @@ export default class PobBaseGenerator extends Generator {
|
|
|
175
175
|
if (!this.hasAncestor) {
|
|
176
176
|
const splitCIJobs =
|
|
177
177
|
inMonorepo && inMonorepo.pobMonorepoConfig?.packageNames.length > 8;
|
|
178
|
-
this.composeWith(
|
|
178
|
+
this.composeWith("pob:core:git", {
|
|
179
179
|
onlyLatestLTS,
|
|
180
180
|
splitCIJobs,
|
|
181
181
|
});
|
|
182
182
|
} else {
|
|
183
|
-
if (this.fs.exists(
|
|
184
|
-
if (this.fs.exists(
|
|
185
|
-
if (this.fs.exists(
|
|
186
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
183
|
+
if (this.fs.exists(".git-hooks")) this.fs.delete(".git-hooks");
|
|
184
|
+
if (this.fs.exists("git-hooks")) this.fs.delete("git-hooks");
|
|
185
|
+
if (this.fs.exists(".commitrc.js")) this.fs.delete(".commitrc.js");
|
|
186
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"), {});
|
|
187
187
|
packageUtils.removeDevDependencies(pkg, [
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
pkg.name !==
|
|
188
|
+
"standard-version",
|
|
189
|
+
"repository-check-dirty",
|
|
190
|
+
"husky",
|
|
191
|
+
"yarnhook",
|
|
192
|
+
"lerna",
|
|
193
|
+
"@pob/lerna-light",
|
|
194
|
+
pkg.name !== "pob" && "@pob/root",
|
|
195
195
|
]);
|
|
196
196
|
delete pkg.commitlint;
|
|
197
197
|
delete pkg.husky;
|
|
198
|
-
delete pkg[
|
|
199
|
-
this.fs.writeJSON(this.destinationPath(
|
|
198
|
+
delete pkg["lint-staged"];
|
|
199
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
if (this.isMonorepo) {
|
|
203
203
|
this.composeWith(
|
|
204
204
|
// pob:monorepo <= for searching PobMonorepoGenerator.js
|
|
205
205
|
fileURLToPath(
|
|
206
|
-
new URL(
|
|
206
|
+
new URL("../monorepo/PobMonorepoGenerator.js", import.meta.url)
|
|
207
207
|
),
|
|
208
208
|
{
|
|
209
209
|
updateOnly: this.options.updateOnly,
|
|
210
210
|
disableYarnGitCache: this.projectConfig.disableYarnGitCache !== false,
|
|
211
|
-
isAppProject: this.projectConfig.type ===
|
|
211
|
+
isAppProject: this.projectConfig.type === "app",
|
|
212
212
|
packageManager: this.projectConfig.packageManager,
|
|
213
213
|
yarnNodeLinker: this.projectConfig.yarnNodeLinker,
|
|
214
214
|
onlyLatestLTS,
|
|
215
|
-
}
|
|
215
|
+
}
|
|
216
216
|
);
|
|
217
217
|
} else {
|
|
218
218
|
switch (this.projectConfig.type) {
|
|
219
|
-
case
|
|
220
|
-
this.composeWith(
|
|
219
|
+
case "lib":
|
|
220
|
+
this.composeWith("pob:lib", {
|
|
221
221
|
monorepo: this.isMonorepo,
|
|
222
222
|
isRoot: this.isRoot,
|
|
223
223
|
disableYarnGitCache:
|
|
@@ -228,8 +228,8 @@ export default class PobBaseGenerator extends Generator {
|
|
|
228
228
|
yarnNodeLinker: this.projectConfig.yarnNodeLinker,
|
|
229
229
|
});
|
|
230
230
|
break;
|
|
231
|
-
case
|
|
232
|
-
this.composeWith(
|
|
231
|
+
case "app":
|
|
232
|
+
this.composeWith("pob:app", {
|
|
233
233
|
monorepo: this.isMonorepo,
|
|
234
234
|
isRoot: this.isRoot,
|
|
235
235
|
disableYarnGitCache:
|
|
@@ -250,10 +250,10 @@ export default class PobBaseGenerator extends Generator {
|
|
|
250
250
|
if (this.options.fromPob) return;
|
|
251
251
|
|
|
252
252
|
switch (this.projectConfig.packageManager) {
|
|
253
|
-
case
|
|
254
|
-
this.spawnCommandSync(
|
|
253
|
+
case "npm":
|
|
254
|
+
this.spawnCommandSync("npm", ["install"]);
|
|
255
255
|
break;
|
|
256
|
-
case
|
|
256
|
+
case "yarn":
|
|
257
257
|
default:
|
|
258
258
|
// see CoreYarnGenerator
|
|
259
259
|
break;
|
|
@@ -262,8 +262,8 @@ export default class PobBaseGenerator extends Generator {
|
|
|
262
262
|
|
|
263
263
|
end() {
|
|
264
264
|
if (this.isMonorepo && !this.options.updateOnly) {
|
|
265
|
-
console.log(
|
|
266
|
-
console.log(
|
|
265
|
+
console.log("To create a new lerna package: ");
|
|
266
|
+
console.log(" pob add <packageName>");
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
269
|
}
|
package/lib/pob-dirname.cjs
CHANGED