pob 19.2.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 +59 -0
- package/lib/generators/app/PobAppGenerator.js +124 -122
- package/lib/generators/app/e2e-testing/AppE2ETestingGenerator.js +11 -11
- package/lib/generators/app/ignorePaths.js +25 -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 +167 -151
- package/lib/generators/common/format-lint/CommonLintGenerator.js +185 -180
- package/lib/generators/common/format-lint/updateEslintConfig.js +9 -9
- package/lib/generators/common/husky/CommonHuskyGenerator.js +44 -44
- package/lib/generators/common/husky/templates/lint-staged.config.js.txt +1 -1
- package/lib/generators/common/old-dependencies/CommonRemoveOldDependenciesGenerator.js +44 -44
- package/lib/generators/common/release/CommonReleaseGenerator.js +40 -39
- package/lib/generators/common/release/templates/workflow-release.yml.ejs +2 -2
- package/lib/generators/common/testing/CommonTestingGenerator.js +193 -191
- package/lib/generators/common/testing/templates/index.js +3 -3
- package/lib/generators/common/transpiler/CommonTranspilerGenerator.js +160 -167
- package/lib/generators/common/typescript/CommonTypescriptGenerator.js +79 -75
- package/lib/generators/core/ci/CoreCIGenerator.js +70 -75
- 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 +42 -42
- package/lib/generators/core/git/generators/github/CoreGitGithubGenerator.js +41 -41
- package/lib/generators/core/gitignore/CoreGitignoreGenerator.js +19 -23
- package/lib/generators/core/npm/CoreNpmGenerator.js +19 -19
- package/lib/generators/core/package/CorePackageGenerator.js +94 -94
- package/lib/generators/core/package/askName.js +4 -4
- package/lib/generators/core/renovate/CoreRenovateGenerator.js +26 -26
- package/lib/generators/core/sort-package/CoreSortPackageGenerator.js +5 -5
- package/lib/generators/core/vscode/CoreVSCodeGenerator.js +39 -38
- package/lib/generators/core/yarn/CoreYarnGenerator.js +82 -77
- package/lib/generators/lib/PobLibGenerator.js +127 -125
- package/lib/generators/lib/doc/LibDocGenerator.js +40 -40
- package/lib/generators/lib/readme/LibReadmeGenerator.js +19 -19
- package/lib/generators/monorepo/PobMonorepoGenerator.js +87 -86
- package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +44 -40
- package/lib/generators/monorepo/typescript/MonorepoTypescriptGenerator.js +35 -35
- package/lib/generators/monorepo/workspaces/MonorepoWorkspacesGenerator.js +60 -56
- package/lib/generators/pob/PobBaseGenerator.js +83 -83
- package/lib/pob-dirname.cjs +1 -1
- package/lib/pob.js +112 -112
- 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 +37 -37
- package/lib/utils/packagejson.js +5 -0
- package/lib/utils/writeAndFormat.js +8 -9
- package/package.json +23 -19
- package/lib/utils/packagejson.cjs +0 -3
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import Generator from
|
|
4
|
-
import inMonorepo from
|
|
5
|
-
import * as packageUtils from
|
|
6
|
-
import { askName } from
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import Generator from "yeoman-generator";
|
|
4
|
+
import inMonorepo from "../../../utils/inMonorepo.js";
|
|
5
|
+
import * as packageUtils from "../../../utils/package.js";
|
|
6
|
+
import { askName } from "./askName.js";
|
|
7
7
|
|
|
8
8
|
export default class CorePackageGenerator extends Generator {
|
|
9
9
|
constructor(args, opts) {
|
|
10
10
|
super(args, opts);
|
|
11
11
|
|
|
12
|
-
this.option(
|
|
12
|
+
this.option("isMonorepo", {
|
|
13
13
|
type: Boolean,
|
|
14
14
|
required: true,
|
|
15
15
|
default: false,
|
|
16
|
-
|
|
16
|
+
description: "is monorepo",
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
-
this.option(
|
|
19
|
+
this.option("inMonorepo", {
|
|
20
20
|
type: Boolean,
|
|
21
21
|
required: true,
|
|
22
22
|
default: false,
|
|
23
|
-
|
|
23
|
+
description: "in monorepo",
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
this.option(
|
|
26
|
+
this.option("isRoot", {
|
|
27
27
|
type: Boolean,
|
|
28
28
|
required: true,
|
|
29
29
|
default: false,
|
|
30
|
-
|
|
30
|
+
description: "is root",
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
this.option(
|
|
33
|
+
this.option("private", {
|
|
34
34
|
type: Boolean,
|
|
35
35
|
required: false,
|
|
36
36
|
default: false,
|
|
37
|
-
|
|
37
|
+
description: "private package",
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
this.option(
|
|
40
|
+
this.option("packageType", {
|
|
41
41
|
type: String,
|
|
42
42
|
required: false,
|
|
43
|
-
|
|
43
|
+
description: "package type",
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
async initializing() {
|
|
48
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
48
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"), {});
|
|
49
49
|
|
|
50
50
|
if (!pkg.engines) pkg.engines = {};
|
|
51
51
|
|
|
@@ -53,13 +53,13 @@ export default class CorePackageGenerator extends Generator {
|
|
|
53
53
|
if (
|
|
54
54
|
!pkg.engines.node ||
|
|
55
55
|
!(
|
|
56
|
-
pkg.engines.node.startsWith(
|
|
57
|
-
pkg.engines.node.startsWith(
|
|
58
|
-
pkg.engines.node !==
|
|
56
|
+
pkg.engines.node.startsWith(">=20.") &&
|
|
57
|
+
pkg.engines.node.startsWith(">=18.") &&
|
|
58
|
+
pkg.engines.node !== ">=18.0.0"
|
|
59
59
|
)
|
|
60
60
|
) {
|
|
61
61
|
// this might be overridden by babel generator
|
|
62
|
-
pkg.engines.node =
|
|
62
|
+
pkg.engines.node = ">=18.12.0"; // .12.0 is the first lts node 18 version
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
if (!this.options.isRoot) {
|
|
@@ -73,9 +73,9 @@ export default class CorePackageGenerator extends Generator {
|
|
|
73
73
|
pkg.private = true;
|
|
74
74
|
} else {
|
|
75
75
|
const { isPrivate } = await this.prompt({
|
|
76
|
-
type:
|
|
77
|
-
name:
|
|
78
|
-
message:
|
|
76
|
+
type: "confirm",
|
|
77
|
+
name: "isPrivate",
|
|
78
|
+
message: "Private package ?",
|
|
79
79
|
default: pkg.private === true,
|
|
80
80
|
});
|
|
81
81
|
if (isPrivate) {
|
|
@@ -89,19 +89,19 @@ export default class CorePackageGenerator extends Generator {
|
|
|
89
89
|
if (this.options.isMonorepo && this.options.isRoot) {
|
|
90
90
|
if (!pkg.name) {
|
|
91
91
|
const { name } = await this.prompt({
|
|
92
|
-
name:
|
|
93
|
-
message:
|
|
92
|
+
name: "name",
|
|
93
|
+
message: "Monorepo Name",
|
|
94
94
|
default: path.basename(process.cwd()),
|
|
95
95
|
validate: (str) => str.length > 0,
|
|
96
96
|
});
|
|
97
97
|
pkg.name = name;
|
|
98
|
-
} else if (pkg.name.endsWith(
|
|
99
|
-
pkg.name = pkg.name.replace(
|
|
98
|
+
} else if (pkg.name.endsWith("-lerna")) {
|
|
99
|
+
pkg.name = pkg.name.replace("-lerna", "-monorepo");
|
|
100
100
|
}
|
|
101
101
|
} else if (!pkg.name) {
|
|
102
102
|
const prompt = {
|
|
103
|
-
name:
|
|
104
|
-
message:
|
|
103
|
+
name: "name",
|
|
104
|
+
message: "Module Name",
|
|
105
105
|
default: path.basename(process.cwd()),
|
|
106
106
|
validate: (str) => str.length > 0,
|
|
107
107
|
};
|
|
@@ -122,39 +122,39 @@ export default class CorePackageGenerator extends Generator {
|
|
|
122
122
|
[
|
|
123
123
|
!this.options.updateOnly &&
|
|
124
124
|
!(this.options.isMonorepo && this.options.isRoot) && {
|
|
125
|
-
name:
|
|
126
|
-
message:
|
|
125
|
+
name: "description",
|
|
126
|
+
message: "Description",
|
|
127
127
|
default: pkg.description,
|
|
128
128
|
},
|
|
129
129
|
{
|
|
130
|
-
name:
|
|
130
|
+
name: "authorName",
|
|
131
131
|
message: "Author's Name",
|
|
132
132
|
when: !pkg.authors && (!author || !author.name),
|
|
133
|
-
default: this.git.name(),
|
|
133
|
+
default: await this.git.name(),
|
|
134
134
|
},
|
|
135
135
|
{
|
|
136
|
-
name:
|
|
136
|
+
name: "authorEmail",
|
|
137
137
|
message: "Author's Email",
|
|
138
138
|
when: !pkg.authors && (!author || !author.email),
|
|
139
|
-
default: this.git.email(),
|
|
139
|
+
default: await this.git.email(),
|
|
140
140
|
},
|
|
141
141
|
{
|
|
142
|
-
name:
|
|
142
|
+
name: "authorUrl",
|
|
143
143
|
message: "Author's Homepage",
|
|
144
144
|
when: !pkg.authors && (!author || !author.url),
|
|
145
145
|
},
|
|
146
146
|
{
|
|
147
|
-
name:
|
|
148
|
-
message:
|
|
149
|
-
type:
|
|
150
|
-
choices: [
|
|
147
|
+
name: "type",
|
|
148
|
+
message: "Package Type",
|
|
149
|
+
type: "list",
|
|
150
|
+
choices: ["commonjs", "module"],
|
|
151
151
|
when: !pkg.type,
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
|
-
name:
|
|
155
|
-
message:
|
|
156
|
-
type:
|
|
157
|
-
choices: [
|
|
154
|
+
name: "license",
|
|
155
|
+
message: "License Type",
|
|
156
|
+
type: "list",
|
|
157
|
+
choices: ["MIT", "ISC", "UNLICENSED"],
|
|
158
158
|
when: !pkg.license,
|
|
159
159
|
},
|
|
160
160
|
].filter(Boolean),
|
|
@@ -164,9 +164,9 @@ export default class CorePackageGenerator extends Generator {
|
|
|
164
164
|
if (
|
|
165
165
|
inMonorepo &&
|
|
166
166
|
!inMonorepo.root &&
|
|
167
|
-
inMonorepo.rootMonorepoPkg.type ===
|
|
167
|
+
inMonorepo.rootMonorepoPkg.type === "module"
|
|
168
168
|
) {
|
|
169
|
-
pkg.type =
|
|
169
|
+
pkg.type = "module";
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
pkg.description = this.options.updateOnly
|
|
@@ -176,46 +176,46 @@ export default class CorePackageGenerator extends Generator {
|
|
|
176
176
|
if (this.options.inMonorepo && !this.options.isRoot) {
|
|
177
177
|
const rootMonorepoPkg = inMonorepo.rootMonorepoPkg;
|
|
178
178
|
const rootRepositoryUrl =
|
|
179
|
-
typeof rootMonorepoPkg.repository ===
|
|
179
|
+
typeof rootMonorepoPkg.repository === "string"
|
|
180
180
|
? rootMonorepoPkg.repository
|
|
181
181
|
: rootMonorepoPkg.repository.url;
|
|
182
182
|
pkg.repository = {
|
|
183
|
-
type:
|
|
183
|
+
type: "git",
|
|
184
184
|
url: rootRepositoryUrl,
|
|
185
185
|
directory: process.cwd().slice(inMonorepo.rootPath.length + 1),
|
|
186
186
|
};
|
|
187
187
|
pkg.homepage = rootMonorepoPkg.homepage;
|
|
188
188
|
|
|
189
|
-
if (this.fs.exists(this.destinationPath(
|
|
190
|
-
fs.unlinkSync(this.destinationPath(
|
|
189
|
+
if (this.fs.exists(this.destinationPath("yarn.lock"))) {
|
|
190
|
+
fs.unlinkSync(this.destinationPath("yarn.lock"));
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
if (this.fs.exists(this.destinationPath(
|
|
194
|
-
fs.unlinkSync(this.destinationPath(
|
|
193
|
+
if (this.fs.exists(this.destinationPath("yarn-error.log"))) {
|
|
194
|
+
fs.unlinkSync(this.destinationPath("yarn-error.log"));
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
if (this.options.inMonorepo && !this.options.isRoot) {
|
|
198
|
-
packageUtils.removeScripts(pkg, [
|
|
199
|
-
packageUtils.removeDevDependencies(pkg, [
|
|
198
|
+
packageUtils.removeScripts(pkg, ["checks"]);
|
|
199
|
+
packageUtils.removeDevDependencies(pkg, ["check-package-dependencies"]);
|
|
200
200
|
} else if (this.options.isMonorepo && this.options.isRoot) {
|
|
201
201
|
const doesMjsCheckPackagesExists = this.fs.exists(
|
|
202
|
-
this.destinationPath(
|
|
202
|
+
this.destinationPath("scripts/check-packages.mjs"),
|
|
203
203
|
);
|
|
204
204
|
let doesJsCheckPackagesExists = this.fs.exists(
|
|
205
|
-
this.destinationPath(
|
|
205
|
+
this.destinationPath("scripts/check-packages.js"),
|
|
206
206
|
);
|
|
207
207
|
|
|
208
|
-
if (pkg.type ===
|
|
208
|
+
if (pkg.type === "module" && !doesJsCheckPackagesExists) {
|
|
209
209
|
doesJsCheckPackagesExists = true;
|
|
210
210
|
this.fs.copyTpl(
|
|
211
|
-
this.templatePath(
|
|
212
|
-
this.destinationPath(
|
|
211
|
+
this.templatePath("check-packages.js.ejs"),
|
|
212
|
+
this.destinationPath("scripts/check-packages.js"),
|
|
213
213
|
{},
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
if (doesJsCheckPackagesExists || doesMjsCheckPackagesExists) {
|
|
218
|
-
packageUtils.addDevDependencies(pkg, [
|
|
218
|
+
packageUtils.addDevDependencies(pkg, ["check-package-dependencies"]);
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
packageUtils.addOrRemoveScripts(
|
|
@@ -223,32 +223,32 @@ export default class CorePackageGenerator extends Generator {
|
|
|
223
223
|
doesMjsCheckPackagesExists || doesJsCheckPackagesExists,
|
|
224
224
|
{
|
|
225
225
|
checks: `node scripts/check-packages.${
|
|
226
|
-
doesMjsCheckPackagesExists ?
|
|
226
|
+
doesMjsCheckPackagesExists ? "mjs" : "js"
|
|
227
227
|
}`,
|
|
228
228
|
},
|
|
229
229
|
);
|
|
230
230
|
} else if (inMonorepo && !inMonorepo.root) {
|
|
231
|
-
if (this.fs.exists(
|
|
232
|
-
this.fs.delete(
|
|
231
|
+
if (this.fs.exists("scripts/check-package.js")) {
|
|
232
|
+
this.fs.delete("scripts/check-package.js");
|
|
233
233
|
}
|
|
234
|
-
if (this.fs.exists(
|
|
235
|
-
this.fs.delete(
|
|
234
|
+
if (this.fs.exists("scripts/check-package.mjs")) {
|
|
235
|
+
this.fs.delete("scripts/check-package.mjs");
|
|
236
236
|
}
|
|
237
|
-
packageUtils.removeScripts(pkg, [
|
|
237
|
+
packageUtils.removeScripts(pkg, ["checks"]);
|
|
238
238
|
} else {
|
|
239
239
|
const doesMjsCheckPackageExists = this.fs.exists(
|
|
240
|
-
this.destinationPath(
|
|
240
|
+
this.destinationPath("scripts/check-package.mjs"),
|
|
241
241
|
);
|
|
242
242
|
let doesJsCheckPackageExists = this.fs.exists(
|
|
243
|
-
this.destinationPath(
|
|
243
|
+
this.destinationPath("scripts/check-package.js"),
|
|
244
244
|
);
|
|
245
245
|
|
|
246
|
-
if (pkg.type ===
|
|
246
|
+
if (pkg.type === "module") {
|
|
247
247
|
if (!doesJsCheckPackageExists) {
|
|
248
248
|
doesJsCheckPackageExists = true;
|
|
249
249
|
this.fs.copyTpl(
|
|
250
|
-
this.templatePath(
|
|
251
|
-
this.destinationPath(
|
|
250
|
+
this.templatePath("check-package.js.ejs"),
|
|
251
|
+
this.destinationPath("scripts/check-package.js"),
|
|
252
252
|
{
|
|
253
253
|
isLibrary: pkg.private !== true,
|
|
254
254
|
},
|
|
@@ -256,7 +256,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
if (doesJsCheckPackageExists || doesMjsCheckPackageExists) {
|
|
259
|
-
packageUtils.addDevDependencies(pkg, [
|
|
259
|
+
packageUtils.addDevDependencies(pkg, ["check-package-dependencies"]);
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
packageUtils.addOrRemoveScripts(
|
|
@@ -264,7 +264,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
264
264
|
doesMjsCheckPackageExists || doesJsCheckPackageExists,
|
|
265
265
|
{
|
|
266
266
|
checks: `node scripts/check-package.${
|
|
267
|
-
doesMjsCheckPackageExists ?
|
|
267
|
+
doesMjsCheckPackageExists ? "mjs" : "js"
|
|
268
268
|
}`,
|
|
269
269
|
},
|
|
270
270
|
);
|
|
@@ -278,7 +278,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
278
278
|
};
|
|
279
279
|
|
|
280
280
|
pkg.author = `${author.name} <${author.email}>${
|
|
281
|
-
author.url ? ` (${author.url})` :
|
|
281
|
+
author.url ? ` (${author.url})` : ""
|
|
282
282
|
}`;
|
|
283
283
|
}
|
|
284
284
|
|
|
@@ -286,7 +286,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
286
286
|
pkg.license = props.license;
|
|
287
287
|
this.fs.copyTpl(
|
|
288
288
|
this.templatePath(`licenses/${props.license}.ejs`),
|
|
289
|
-
this.destinationPath(
|
|
289
|
+
this.destinationPath("LICENSE"),
|
|
290
290
|
{
|
|
291
291
|
year: new Date().getFullYear(),
|
|
292
292
|
author: pkg.author,
|
|
@@ -303,58 +303,58 @@ export default class CorePackageGenerator extends Generator {
|
|
|
303
303
|
|
|
304
304
|
if (!pkg.private && !pkg.version) {
|
|
305
305
|
// lerna root pkg should not have version
|
|
306
|
-
pkg.version =
|
|
306
|
+
pkg.version = "0.0.0";
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
if (!pkg.private && !pkg.publishConfig && pkg.name[0] ===
|
|
309
|
+
if (!pkg.private && !pkg.publishConfig && pkg.name[0] === "@") {
|
|
310
310
|
pkg.publishConfig = {
|
|
311
|
-
access:
|
|
311
|
+
access: "public",
|
|
312
312
|
};
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
this.fs.writeJSON(this.destinationPath(
|
|
315
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
writing() {
|
|
319
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
319
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"), {});
|
|
320
320
|
if (!pkg.scripts) pkg.scripts = {};
|
|
321
321
|
|
|
322
322
|
const installPostinstallScript = (scriptName) => {
|
|
323
323
|
if (
|
|
324
324
|
!pkg.scripts[scriptName] ||
|
|
325
|
-
!pkg.scripts[scriptName].includes(
|
|
325
|
+
!pkg.scripts[scriptName].includes("pob-root-postinstall")
|
|
326
326
|
) {
|
|
327
|
-
pkg.scripts[scriptName] =
|
|
327
|
+
pkg.scripts[scriptName] = "pob-root-postinstall";
|
|
328
328
|
}
|
|
329
329
|
};
|
|
330
330
|
|
|
331
331
|
const uninstallPostinstallScript = (scriptName) => {
|
|
332
332
|
if (pkg.scripts && pkg.scripts[scriptName]) {
|
|
333
|
-
if (pkg.scripts[scriptName] ===
|
|
333
|
+
if (pkg.scripts[scriptName] === "pob-root-postinstall") {
|
|
334
334
|
delete pkg.scripts[scriptName];
|
|
335
335
|
} else if (
|
|
336
|
-
pkg.scripts[scriptName].startsWith(
|
|
336
|
+
pkg.scripts[scriptName].startsWith("pob-root-postinstall && ")
|
|
337
337
|
) {
|
|
338
338
|
pkg.scripts[scriptName] = pkg.scripts[scriptName].slice(
|
|
339
|
-
|
|
339
|
+
"pob-root-postinstall && ".length - 1,
|
|
340
340
|
);
|
|
341
|
-
} else if (pkg.scripts[scriptName].includes(
|
|
342
|
-
throw new Error(
|
|
341
|
+
} else if (pkg.scripts[scriptName].includes("pob-root-postinstall")) {
|
|
342
|
+
throw new Error("Could not remove pob-root-postinstall");
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
};
|
|
346
346
|
if (this.options.inMonorepo || inMonorepo || pkg.private) {
|
|
347
|
-
uninstallPostinstallScript(
|
|
347
|
+
uninstallPostinstallScript("postinstallDev");
|
|
348
348
|
if (this.options.isRoot) {
|
|
349
|
-
installPostinstallScript(
|
|
349
|
+
installPostinstallScript("postinstall");
|
|
350
350
|
} else {
|
|
351
|
-
uninstallPostinstallScript(
|
|
351
|
+
uninstallPostinstallScript("postinstall");
|
|
352
352
|
}
|
|
353
353
|
} else {
|
|
354
|
-
uninstallPostinstallScript(
|
|
355
|
-
installPostinstallScript(
|
|
354
|
+
uninstallPostinstallScript("postinstall");
|
|
355
|
+
installPostinstallScript("postinstallDev");
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
this.fs.writeJSON(this.destinationPath(
|
|
358
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
359
359
|
}
|
|
360
360
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import validatePackageName from
|
|
1
|
+
import validatePackageName from "validate-npm-package-name";
|
|
2
2
|
|
|
3
3
|
const defaults = {
|
|
4
|
-
message:
|
|
4
|
+
message: "Module Name",
|
|
5
5
|
validate() {
|
|
6
6
|
return true;
|
|
7
7
|
},
|
|
@@ -10,7 +10,7 @@ const defaults = {
|
|
|
10
10
|
const ucFirst = (str) => str.charAt(0).toUpperCase() + str.slice(1);
|
|
11
11
|
|
|
12
12
|
export const askName = (prompt, inquirer) => {
|
|
13
|
-
if (typeof prompt ===
|
|
13
|
+
if (typeof prompt === "string") {
|
|
14
14
|
prompt = {
|
|
15
15
|
name: prompt,
|
|
16
16
|
};
|
|
@@ -32,7 +32,7 @@ export const askName = (prompt, inquirer) => {
|
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
ucFirst(packageNameValidity.errors[0]) ||
|
|
35
|
-
|
|
35
|
+
"The provided value is not a valid npm package name"
|
|
36
36
|
);
|
|
37
37
|
},
|
|
38
38
|
},
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import Generator from
|
|
2
|
-
import inMonorepo from
|
|
3
|
-
import { writeAndFormatJson } from
|
|
1
|
+
import Generator from "yeoman-generator";
|
|
2
|
+
import inMonorepo from "../../../utils/inMonorepo.js";
|
|
3
|
+
import { writeAndFormatJson } from "../../../utils/writeAndFormat.js";
|
|
4
4
|
|
|
5
5
|
export default class CoreRenovateGenerator extends Generator {
|
|
6
6
|
constructor(args, opts) {
|
|
7
7
|
super(args, opts);
|
|
8
8
|
|
|
9
|
-
this.option(
|
|
9
|
+
this.option("disable", {
|
|
10
10
|
type: Boolean,
|
|
11
11
|
required: false,
|
|
12
12
|
default: false,
|
|
13
|
-
|
|
13
|
+
description: "disable",
|
|
14
14
|
});
|
|
15
15
|
|
|
16
|
-
this.option(
|
|
16
|
+
this.option("app", {
|
|
17
17
|
type: Boolean,
|
|
18
18
|
required: false,
|
|
19
19
|
default: false,
|
|
20
|
-
|
|
20
|
+
description: "is app (instead of lib)",
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
this.option(
|
|
23
|
+
this.option("updateOnly", {
|
|
24
24
|
type: Boolean,
|
|
25
25
|
required: false,
|
|
26
26
|
default: false,
|
|
27
|
-
|
|
27
|
+
description: "Avoid asking questions",
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
initializing() {
|
|
32
32
|
if (inMonorepo && !inMonorepo.root) {
|
|
33
33
|
this.enableRenovate = false;
|
|
34
|
-
this.config.delete(
|
|
34
|
+
this.config.delete("renovate");
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
this.enableRenovateConfig = this.config.get(
|
|
38
|
+
this.enableRenovateConfig = this.config.get("renovate");
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async prompting() {
|
|
@@ -49,45 +49,45 @@ export default class CoreRenovateGenerator extends Generator {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
this.enableRenovateConfig = await this.prompt({
|
|
52
|
-
type:
|
|
53
|
-
name:
|
|
54
|
-
message:
|
|
52
|
+
type: "confirm",
|
|
53
|
+
name: "enable",
|
|
54
|
+
message: "Enable renovate ?",
|
|
55
55
|
});
|
|
56
|
-
this.config.set(
|
|
56
|
+
this.config.set("renovate", this.enableRenovateConfig);
|
|
57
57
|
this.enableRenovate = this.enableRenovateConfig.enable;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
writing() {
|
|
61
61
|
if (this.enableRenovate) {
|
|
62
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
62
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"), {});
|
|
63
63
|
const renovateConfig = this.fs.readJSON(
|
|
64
|
-
this.destinationPath(
|
|
64
|
+
this.destinationPath("renovate.json"),
|
|
65
65
|
{},
|
|
66
66
|
);
|
|
67
67
|
|
|
68
68
|
if (this.options.app) {
|
|
69
69
|
renovateConfig.$schema =
|
|
70
|
-
|
|
70
|
+
"https://docs.renovatebot.com/renovate-schema.json";
|
|
71
71
|
renovateConfig.extends = [
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
"config:js-app",
|
|
73
|
+
"github>christophehurpeau/renovate-presets",
|
|
74
74
|
];
|
|
75
75
|
} else {
|
|
76
76
|
renovateConfig.extends = [
|
|
77
|
-
|
|
78
|
-
pkg.name ===
|
|
77
|
+
"config:js-lib",
|
|
78
|
+
pkg.name === "pob-monorepo"
|
|
79
79
|
? undefined
|
|
80
|
-
:
|
|
80
|
+
: "github>christophehurpeau/renovate-presets",
|
|
81
81
|
].filter(Boolean);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
writeAndFormatJson(
|
|
85
85
|
this.fs,
|
|
86
|
-
this.destinationPath(
|
|
86
|
+
this.destinationPath("renovate.json"),
|
|
87
87
|
renovateConfig,
|
|
88
88
|
);
|
|
89
|
-
} else if (this.fs.exists(this.destinationPath(
|
|
90
|
-
this.fs.delete(this.destinationPath(
|
|
89
|
+
} else if (this.fs.exists(this.destinationPath("renovate.json"))) {
|
|
90
|
+
this.fs.delete(this.destinationPath("renovate.json"));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import Generator from
|
|
2
|
-
import * as packageUtils from
|
|
3
|
-
import { writeAndFormatJson } from
|
|
1
|
+
import Generator from "yeoman-generator";
|
|
2
|
+
import * as packageUtils from "../../../utils/package.js";
|
|
3
|
+
import { writeAndFormatJson } from "../../../utils/writeAndFormat.js";
|
|
4
4
|
|
|
5
5
|
export default class CoreSortPackageGenerator extends Generator {
|
|
6
6
|
writing() {
|
|
7
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
7
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
8
8
|
writeAndFormatJson(
|
|
9
9
|
this.fs,
|
|
10
|
-
this.destinationPath(
|
|
10
|
+
this.destinationPath("package.json"),
|
|
11
11
|
packageUtils.sort(pkg),
|
|
12
12
|
);
|
|
13
13
|
}
|