pob 20.0.0 → 21.1.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 +53 -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
|
@@ -13,34 +13,34 @@ export default class CorePackageGenerator extends Generator {
|
|
|
13
13
|
type: Boolean,
|
|
14
14
|
required: true,
|
|
15
15
|
default: false,
|
|
16
|
-
|
|
16
|
+
description: "is monorepo",
|
|
17
17
|
});
|
|
18
18
|
|
|
19
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
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
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
40
|
this.option("packageType", {
|
|
41
41
|
type: String,
|
|
42
42
|
required: false,
|
|
43
|
-
|
|
43
|
+
description: "package type",
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -130,13 +130,13 @@ export default class CorePackageGenerator extends Generator {
|
|
|
130
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
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
142
|
name: "authorUrl",
|
|
@@ -157,7 +157,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
157
157
|
choices: ["MIT", "ISC", "UNLICENSED"],
|
|
158
158
|
when: !pkg.license,
|
|
159
159
|
},
|
|
160
|
-
].filter(Boolean)
|
|
160
|
+
].filter(Boolean),
|
|
161
161
|
);
|
|
162
162
|
|
|
163
163
|
if (!pkg.type) pkg.type = props.type;
|
|
@@ -199,10 +199,10 @@ export default class CorePackageGenerator extends Generator {
|
|
|
199
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("scripts/check-packages.mjs")
|
|
202
|
+
this.destinationPath("scripts/check-packages.mjs"),
|
|
203
203
|
);
|
|
204
204
|
let doesJsCheckPackagesExists = this.fs.exists(
|
|
205
|
-
this.destinationPath("scripts/check-packages.js")
|
|
205
|
+
this.destinationPath("scripts/check-packages.js"),
|
|
206
206
|
);
|
|
207
207
|
|
|
208
208
|
if (pkg.type === "module" && !doesJsCheckPackagesExists) {
|
|
@@ -210,7 +210,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
210
210
|
this.fs.copyTpl(
|
|
211
211
|
this.templatePath("check-packages.js.ejs"),
|
|
212
212
|
this.destinationPath("scripts/check-packages.js"),
|
|
213
|
-
{}
|
|
213
|
+
{},
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
216
|
|
|
@@ -225,7 +225,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
225
225
|
checks: `node scripts/check-packages.${
|
|
226
226
|
doesMjsCheckPackagesExists ? "mjs" : "js"
|
|
227
227
|
}`,
|
|
228
|
-
}
|
|
228
|
+
},
|
|
229
229
|
);
|
|
230
230
|
} else if (inMonorepo && !inMonorepo.root) {
|
|
231
231
|
if (this.fs.exists("scripts/check-package.js")) {
|
|
@@ -237,10 +237,10 @@ export default class CorePackageGenerator extends Generator {
|
|
|
237
237
|
packageUtils.removeScripts(pkg, ["checks"]);
|
|
238
238
|
} else {
|
|
239
239
|
const doesMjsCheckPackageExists = this.fs.exists(
|
|
240
|
-
this.destinationPath("scripts/check-package.mjs")
|
|
240
|
+
this.destinationPath("scripts/check-package.mjs"),
|
|
241
241
|
);
|
|
242
242
|
let doesJsCheckPackageExists = this.fs.exists(
|
|
243
|
-
this.destinationPath("scripts/check-package.js")
|
|
243
|
+
this.destinationPath("scripts/check-package.js"),
|
|
244
244
|
);
|
|
245
245
|
|
|
246
246
|
if (pkg.type === "module") {
|
|
@@ -251,7 +251,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
251
251
|
this.destinationPath("scripts/check-package.js"),
|
|
252
252
|
{
|
|
253
253
|
isLibrary: pkg.private !== true,
|
|
254
|
-
}
|
|
254
|
+
},
|
|
255
255
|
);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
@@ -266,7 +266,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
266
266
|
checks: `node scripts/check-package.${
|
|
267
267
|
doesMjsCheckPackageExists ? "mjs" : "js"
|
|
268
268
|
}`,
|
|
269
|
-
}
|
|
269
|
+
},
|
|
270
270
|
);
|
|
271
271
|
}
|
|
272
272
|
|
|
@@ -290,7 +290,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
290
290
|
{
|
|
291
291
|
year: new Date().getFullYear(),
|
|
292
292
|
author: pkg.author,
|
|
293
|
-
}
|
|
293
|
+
},
|
|
294
294
|
);
|
|
295
295
|
}
|
|
296
296
|
|
|
@@ -336,7 +336,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
336
336
|
pkg.scripts[scriptName].startsWith("pob-root-postinstall && ")
|
|
337
337
|
) {
|
|
338
338
|
pkg.scripts[scriptName] = pkg.scripts[scriptName].slice(
|
|
339
|
-
"pob-root-postinstall && ".length - 1
|
|
339
|
+
"pob-root-postinstall && ".length - 1,
|
|
340
340
|
);
|
|
341
341
|
} else if (pkg.scripts[scriptName].includes("pob-root-postinstall")) {
|
|
342
342
|
throw new Error("Could not remove pob-root-postinstall");
|
|
@@ -10,21 +10,21 @@ export default class CoreRenovateGenerator extends Generator {
|
|
|
10
10
|
type: Boolean,
|
|
11
11
|
required: false,
|
|
12
12
|
default: false,
|
|
13
|
-
|
|
13
|
+
description: "disable",
|
|
14
14
|
});
|
|
15
15
|
|
|
16
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
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
|
|
|
@@ -62,7 +62,7 @@ export default class CoreRenovateGenerator extends Generator {
|
|
|
62
62
|
const pkg = this.fs.readJSON(this.destinationPath("package.json"), {});
|
|
63
63
|
const renovateConfig = this.fs.readJSON(
|
|
64
64
|
this.destinationPath("renovate.json"),
|
|
65
|
-
{}
|
|
65
|
+
{},
|
|
66
66
|
);
|
|
67
67
|
|
|
68
68
|
if (this.options.app) {
|
|
@@ -84,7 +84,7 @@ export default class CoreRenovateGenerator extends Generator {
|
|
|
84
84
|
writeAndFormatJson(
|
|
85
85
|
this.fs,
|
|
86
86
|
this.destinationPath("renovate.json"),
|
|
87
|
-
renovateConfig
|
|
87
|
+
renovateConfig,
|
|
88
88
|
);
|
|
89
89
|
} else if (this.fs.exists(this.destinationPath("renovate.json"))) {
|
|
90
90
|
this.fs.delete(this.destinationPath("renovate.json"));
|
|
@@ -10,48 +10,49 @@ export default class CoreVSCodeGenerator extends Generator {
|
|
|
10
10
|
type: Boolean,
|
|
11
11
|
required: false,
|
|
12
12
|
default: "",
|
|
13
|
-
|
|
13
|
+
description: "Is root",
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
this.option("packageManager", {
|
|
17
17
|
type: String,
|
|
18
18
|
required: false,
|
|
19
19
|
default: "yarn",
|
|
20
|
-
|
|
20
|
+
description: "yarn|npm.",
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
this.option("monorepo", {
|
|
24
24
|
type: Boolean,
|
|
25
25
|
required: false,
|
|
26
26
|
default: false,
|
|
27
|
-
|
|
27
|
+
description: "is monorepo",
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
this.option("testing", {
|
|
31
31
|
type: Boolean,
|
|
32
32
|
required: false,
|
|
33
33
|
default: false,
|
|
34
|
-
|
|
34
|
+
description: "Testing enabled",
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
this.option("testRunner", {
|
|
38
38
|
type: String,
|
|
39
39
|
required: false,
|
|
40
|
-
|
|
40
|
+
description: "Test runner (jest, vitest, ...)",
|
|
41
41
|
});
|
|
42
42
|
|
|
43
43
|
this.option("yarnNodeLinker", {
|
|
44
44
|
type: String,
|
|
45
45
|
required: false,
|
|
46
46
|
default: "node-modules",
|
|
47
|
-
|
|
47
|
+
description:
|
|
48
|
+
"Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.",
|
|
48
49
|
});
|
|
49
50
|
|
|
50
51
|
this.option("typescript", {
|
|
51
52
|
type: Boolean,
|
|
52
53
|
required: false,
|
|
53
54
|
default: false,
|
|
54
|
-
|
|
55
|
+
description: "Typescript enabled",
|
|
55
56
|
});
|
|
56
57
|
|
|
57
58
|
this.option("packageNames", {
|
|
@@ -75,7 +76,7 @@ export default class CoreVSCodeGenerator extends Generator {
|
|
|
75
76
|
{
|
|
76
77
|
yarn: this.options.packageManager === "yarn",
|
|
77
78
|
pnp: this.options.yarnNodeLinker === "pnp",
|
|
78
|
-
}
|
|
79
|
+
},
|
|
79
80
|
);
|
|
80
81
|
copyAndFormatTpl(
|
|
81
82
|
this.fs,
|
|
@@ -89,13 +90,13 @@ export default class CoreVSCodeGenerator extends Generator {
|
|
|
89
90
|
testing: this.options.testing,
|
|
90
91
|
testRunner: this.options.testRunner,
|
|
91
92
|
module: pkg.type === "module",
|
|
92
|
-
}
|
|
93
|
+
},
|
|
93
94
|
);
|
|
94
95
|
|
|
95
96
|
const tasksConfig = readJSON5(
|
|
96
97
|
this.fs,
|
|
97
98
|
this.destinationPath(".vscode/tasks.json"),
|
|
98
|
-
{}
|
|
99
|
+
{},
|
|
99
100
|
);
|
|
100
101
|
const tasks = tasksConfig.tasks || [];
|
|
101
102
|
|
|
@@ -106,14 +107,14 @@ export default class CoreVSCodeGenerator extends Generator {
|
|
|
106
107
|
{
|
|
107
108
|
typescript: this.options.typescript,
|
|
108
109
|
tasks: JSON.stringify(tasks, null, 2),
|
|
109
|
-
}
|
|
110
|
+
},
|
|
110
111
|
);
|
|
111
112
|
|
|
112
113
|
if (this.options.monorepo) {
|
|
113
114
|
const projectName = pkg.name.replace("/", "-");
|
|
114
115
|
// legacy project code-workspace
|
|
115
116
|
this.fs.delete(
|
|
116
|
-
this.destinationPath(`.vscode/${projectName}.code-workspace`)
|
|
117
|
+
this.destinationPath(`.vscode/${projectName}.code-workspace`),
|
|
117
118
|
);
|
|
118
119
|
}
|
|
119
120
|
} else {
|
|
@@ -16,27 +16,29 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
16
16
|
type: String,
|
|
17
17
|
required: false,
|
|
18
18
|
default: "app",
|
|
19
|
-
|
|
19
|
+
description: "Project type",
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
this.option("enable", {
|
|
23
23
|
type: Boolean,
|
|
24
24
|
required: true,
|
|
25
|
-
|
|
25
|
+
description: "Enable yarn",
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
this.option("yarnNodeLinker", {
|
|
29
29
|
type: String,
|
|
30
30
|
required: false,
|
|
31
31
|
default: "node-modules",
|
|
32
|
-
|
|
32
|
+
description:
|
|
33
|
+
"Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.",
|
|
33
34
|
});
|
|
34
35
|
|
|
35
36
|
this.option("disableYarnGitCache", {
|
|
36
37
|
type: Boolean,
|
|
37
38
|
required: false,
|
|
38
39
|
default: false,
|
|
39
|
-
|
|
40
|
+
description:
|
|
41
|
+
"Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.",
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
|
|
@@ -64,13 +66,13 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
64
66
|
this.destinationPath(".yarn/.gitignore"),
|
|
65
67
|
{
|
|
66
68
|
disableYarnGitCache: this.options.disableYarnGitCache,
|
|
67
|
-
}
|
|
69
|
+
},
|
|
68
70
|
);
|
|
69
71
|
|
|
70
72
|
const { stdout } = this.spawnSync(
|
|
71
73
|
"yarn",
|
|
72
74
|
["plugin", "runtime", "--json"],
|
|
73
|
-
{ stdio: "pipe" }
|
|
75
|
+
{ stdio: "pipe" },
|
|
74
76
|
);
|
|
75
77
|
const installedPlugins = stdout.split("\n").map(JSON.parse);
|
|
76
78
|
|
|
@@ -87,7 +89,7 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
87
89
|
const installPluginIfNotInstalled = (
|
|
88
90
|
name,
|
|
89
91
|
nameOrUrl = name,
|
|
90
|
-
forceInstallIfInstalled = () => false
|
|
92
|
+
forceInstallIfInstalled = () => false,
|
|
91
93
|
) => {
|
|
92
94
|
if (!isPluginInstalled(name)) {
|
|
93
95
|
installPlugin(nameOrUrl);
|
|
@@ -103,29 +105,30 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
103
105
|
};
|
|
104
106
|
|
|
105
107
|
const postinstallDevPluginName = "@yarnpkg/plugin-postinstall-dev";
|
|
106
|
-
const
|
|
108
|
+
const legacyVersionPluginName = "@yarnpkg/plugin-conventional-version";
|
|
107
109
|
|
|
108
110
|
if (!inMonorepo && !pkg.private) {
|
|
109
111
|
installPluginIfNotInstalled(
|
|
110
112
|
postinstallDevPluginName,
|
|
111
|
-
"https://raw.githubusercontent.com/sachinraja/yarn-plugin-postinstall-dev/main/bundles/%40yarnpkg/plugin-postinstall-dev.js"
|
|
113
|
+
"https://raw.githubusercontent.com/sachinraja/yarn-plugin-postinstall-dev/main/bundles/%40yarnpkg/plugin-postinstall-dev.js",
|
|
112
114
|
);
|
|
113
115
|
} else {
|
|
114
116
|
removePluginIfInstalled(postinstallDevPluginName);
|
|
115
117
|
}
|
|
116
118
|
|
|
117
119
|
if (pkg.name !== "yarn-plugin-conventional-version") {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
120
|
+
removePluginIfInstalled(legacyVersionPluginName);
|
|
121
|
+
// installPluginIfNotInstalled(
|
|
122
|
+
// versionPluginName,
|
|
123
|
+
// "https://raw.githubusercontent.com/christophehurpeau/yarn-plugin-conventional-version/main/bundles/%40yarnpkg/plugin-conventional-version.cjs",
|
|
124
|
+
// () => {
|
|
125
|
+
// const content = fs.readFileSync(
|
|
126
|
+
// ".yarn/plugins/@yarnpkg/plugin-conventional-version.cjs",
|
|
127
|
+
// "utf8",
|
|
128
|
+
// );
|
|
129
|
+
// return !content.includes("Lifecycle script: preversion");
|
|
130
|
+
// },
|
|
131
|
+
// );
|
|
129
132
|
}
|
|
130
133
|
|
|
131
134
|
if (
|
|
@@ -137,13 +140,15 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
137
140
|
}
|
|
138
141
|
|
|
139
142
|
// must be done after plugins installed
|
|
140
|
-
const configString = this.fs.read(".yarnrc.yml");
|
|
141
|
-
const config =
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
143
|
+
const configString = this.fs.read(".yarnrc.yml", { defaults: "" });
|
|
144
|
+
const config =
|
|
145
|
+
yml.load(configString, {
|
|
146
|
+
schema: yml.FAILSAFE_SCHEMA,
|
|
147
|
+
json: true,
|
|
148
|
+
}) || {};
|
|
145
149
|
if (this.options.disableYarnGitCache) {
|
|
146
|
-
|
|
150
|
+
// leave default compressionLevel instead of this next line
|
|
151
|
+
// config.compressionLevel = "mixed"; // optimized for size
|
|
147
152
|
config.enableGlobalCache = true;
|
|
148
153
|
delete config.supportedArchitectures;
|
|
149
154
|
} else {
|
|
@@ -171,7 +176,7 @@ export default class CoreYarnGenerator extends Generator {
|
|
|
171
176
|
".yarnrc.yml",
|
|
172
177
|
yml.dump(sortObject(config), {
|
|
173
178
|
lineWidth: 9999,
|
|
174
|
-
})
|
|
179
|
+
}),
|
|
175
180
|
);
|
|
176
181
|
} else {
|
|
177
182
|
this.fs.delete(".yarn");
|
|
@@ -11,7 +11,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
11
11
|
type: Boolean,
|
|
12
12
|
required: false,
|
|
13
13
|
default: false,
|
|
14
|
-
|
|
14
|
+
description: "Avoid asking questions",
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
this.option("fromPob", {
|
|
@@ -23,21 +23,23 @@ export default class PobLibGenerator extends Generator {
|
|
|
23
23
|
this.option("packageManager", {
|
|
24
24
|
type: String,
|
|
25
25
|
default: "yarn",
|
|
26
|
-
|
|
26
|
+
description: "yarn or npm",
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
this.option("yarnNodeLinker", {
|
|
30
30
|
type: String,
|
|
31
31
|
required: false,
|
|
32
32
|
default: "node-modules",
|
|
33
|
-
|
|
33
|
+
description:
|
|
34
|
+
"Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.",
|
|
34
35
|
});
|
|
35
36
|
|
|
36
37
|
this.option("disableYarnGitCache", {
|
|
37
38
|
type: Boolean,
|
|
38
39
|
required: false,
|
|
39
40
|
default: false,
|
|
40
|
-
|
|
41
|
+
description:
|
|
42
|
+
"Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.",
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
|
|
@@ -72,7 +74,10 @@ export default class PobLibGenerator extends Generator {
|
|
|
72
74
|
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
73
75
|
const pobPkgConfig = pkg.pob || {};
|
|
74
76
|
|
|
75
|
-
let babelEnvs =
|
|
77
|
+
let babelEnvs =
|
|
78
|
+
this.pobjson.envs ||
|
|
79
|
+
pobPkgConfig.babelEnvs ||
|
|
80
|
+
(pobPkgConfig.bundler === "rollup-babel" && pobPkgConfig.envs);
|
|
76
81
|
const entries = this.pobjson.entries || pobPkgConfig.entries;
|
|
77
82
|
const jsx =
|
|
78
83
|
this.pobjson.withReact || pobPkgConfig.withReact || pobPkgConfig.jsx;
|
|
@@ -148,7 +153,9 @@ export default class PobLibGenerator extends Generator {
|
|
|
148
153
|
|
|
149
154
|
delete pkg.pob.withReact;
|
|
150
155
|
if (babelEnvs && babelEnvs.length > 0) {
|
|
151
|
-
pkg.pob.babelEnvs
|
|
156
|
+
delete pkg.pob.babelEnvs;
|
|
157
|
+
pkg.pob.bundler = "rollup-babel";
|
|
158
|
+
pkg.pob.envs = babelEnvs;
|
|
152
159
|
pkg.pob.entries = entries;
|
|
153
160
|
pkg.pob.jsx = jsx;
|
|
154
161
|
}
|
|
@@ -247,13 +254,15 @@ export default class PobLibGenerator extends Generator {
|
|
|
247
254
|
|
|
248
255
|
default() {
|
|
249
256
|
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
250
|
-
const babelEnvs =
|
|
257
|
+
const babelEnvs =
|
|
258
|
+
pkg.pob.babelEnvs ||
|
|
259
|
+
(pkg.pob.bundler === "rollup-babel" && pkg.pob.envs) ||
|
|
260
|
+
[];
|
|
251
261
|
|
|
252
262
|
const withBabel = babelEnvs.length > 0;
|
|
253
263
|
const withTypescript = withBabel || pkg.pob.typescript === true;
|
|
254
264
|
const jsx = (withBabel || withTypescript) && pkg.pob.jsx === true;
|
|
255
|
-
const browser =
|
|
256
|
-
withBabel && babelEnvs.some((env) => env.target === "browser");
|
|
265
|
+
const browser = pkg.pob.envs?.some((env) => env.target === "browser");
|
|
257
266
|
|
|
258
267
|
this.composeWith("pob:common:typescript", {
|
|
259
268
|
enable: withTypescript,
|
|
@@ -373,7 +382,9 @@ export default class PobLibGenerator extends Generator {
|
|
|
373
382
|
pkg.sideEffects = false;
|
|
374
383
|
}
|
|
375
384
|
|
|
376
|
-
const withBabel = Boolean(
|
|
385
|
+
const withBabel = Boolean(
|
|
386
|
+
pkg.pob.babelEnvs || pkg.pob.bundler === "rollup-babel",
|
|
387
|
+
);
|
|
377
388
|
const withTypescript = pkg.pob.typescript === true;
|
|
378
389
|
|
|
379
390
|
packageUtils.removeDevDependencies(pkg, ["lerna", "@pob/lerna-light"]);
|
|
@@ -394,7 +405,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
394
405
|
) {
|
|
395
406
|
this.fs.move(
|
|
396
407
|
this.destinationPath("index.js"),
|
|
397
|
-
this.destinationPath("lib/index.js")
|
|
408
|
+
this.destinationPath("lib/index.js"),
|
|
398
409
|
);
|
|
399
410
|
}
|
|
400
411
|
}
|
|
@@ -414,15 +425,6 @@ export default class PobLibGenerator extends Generator {
|
|
|
414
425
|
|
|
415
426
|
const { pobjson } = this;
|
|
416
427
|
|
|
417
|
-
// .includes('node6') && 'node6',
|
|
418
|
-
// this.babelEnvs.includes('node8') && 'node8',
|
|
419
|
-
// this.babelEnvs.includes('olderNode') && 'older-node',
|
|
420
|
-
// this.babelEnvs.includes('moduleModernBrowsers') && 'module-modern-browsers',
|
|
421
|
-
// this.babelEnvs.includes('moduleAllBrowsers') && 'module',
|
|
422
|
-
// this.babelEnvs.includes('moduleNode8') && 'module-node8',
|
|
423
|
-
// this.babelEnvs.includes('browsers') && 'browsers',
|
|
424
|
-
// ].filter(Boolean);
|
|
425
|
-
|
|
426
428
|
this.config.set("lib", pobjson);
|
|
427
429
|
this.config.save();
|
|
428
430
|
|
|
@@ -11,20 +11,20 @@ export default class LibDocGenerator extends Generator {
|
|
|
11
11
|
type: Boolean,
|
|
12
12
|
required: false,
|
|
13
13
|
default: true,
|
|
14
|
-
|
|
14
|
+
description: "Enabled.",
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
this.option("testing", {
|
|
18
18
|
type: Boolean,
|
|
19
19
|
required: false,
|
|
20
20
|
default: false,
|
|
21
|
-
|
|
21
|
+
description: "Coverage.",
|
|
22
22
|
});
|
|
23
23
|
|
|
24
24
|
this.option("packageManager", {
|
|
25
25
|
type: String,
|
|
26
26
|
default: "yarn",
|
|
27
|
-
|
|
27
|
+
description: "yarn or npm",
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
this.option("packageNames", {
|
|
@@ -53,7 +53,7 @@ export default class LibDocGenerator extends Generator {
|
|
|
53
53
|
if (inMonorepo && inMonorepo.root) {
|
|
54
54
|
const existingConfig = this.fs.readJSON(
|
|
55
55
|
this.destinationPath("tsconfig.doc.json"),
|
|
56
|
-
{ typedocOptions: {} }
|
|
56
|
+
{ typedocOptions: {} },
|
|
57
57
|
);
|
|
58
58
|
// "external-modulemap": ".*packages/([^/]+)/.*",
|
|
59
59
|
const packagePaths = JSON.parse(this.options.packagePaths);
|
|
@@ -64,7 +64,7 @@ export default class LibDocGenerator extends Generator {
|
|
|
64
64
|
return {
|
|
65
65
|
path: pkgPath,
|
|
66
66
|
packageJSON: this.fs.readJSON(
|
|
67
|
-
this.destinationPath(`${pkgPath}/package.json`)
|
|
67
|
+
this.destinationPath(`${pkgPath}/package.json`),
|
|
68
68
|
),
|
|
69
69
|
};
|
|
70
70
|
});
|
|
@@ -79,7 +79,7 @@ export default class LibDocGenerator extends Generator {
|
|
|
79
79
|
// unshift:https://typedoc.org/guides/project-references/
|
|
80
80
|
entryPoints.unshift(
|
|
81
81
|
// `${path}/src/`,
|
|
82
|
-
...entries.map((entry) => `${path}/src/${entry}.ts`)
|
|
82
|
+
...entries.map((entry) => `${path}/src/${entry}.ts`),
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -95,17 +95,17 @@ export default class LibDocGenerator extends Generator {
|
|
|
95
95
|
repositoryUrl: pkg.homepage, // or pkg.repository.replace(/\.git$/, '')
|
|
96
96
|
packageManager: this.options.packageManager,
|
|
97
97
|
readme: existingConfig.typedocOptions.readme || "README.md",
|
|
98
|
-
}
|
|
98
|
+
},
|
|
99
99
|
);
|
|
100
100
|
} else {
|
|
101
101
|
const entryPoints = ((pkg.pob && pkg.pob.entries) || []).map(
|
|
102
|
-
(entryName) => `src/${entryName}.ts
|
|
102
|
+
(entryName) => `src/${entryName}.ts`,
|
|
103
103
|
);
|
|
104
104
|
copyAndFormatTpl(
|
|
105
105
|
this.fs,
|
|
106
106
|
this.templatePath("tsconfig.doc.json.ejs"),
|
|
107
107
|
this.destinationPath("tsconfig.doc.json"),
|
|
108
|
-
{ jsx, readme: "README.md", entryPoints }
|
|
108
|
+
{ jsx, readme: "README.md", entryPoints },
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
} else {
|
|
@@ -11,31 +11,31 @@ export default class LibReadmeGenerator extends Generator {
|
|
|
11
11
|
this.option("privatePackage", {
|
|
12
12
|
type: Boolean,
|
|
13
13
|
required: true,
|
|
14
|
-
|
|
14
|
+
description: "If the project is private",
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
this.option("documentation", {
|
|
18
18
|
type: Boolean,
|
|
19
19
|
required: true,
|
|
20
|
-
|
|
20
|
+
description: "Include documentation",
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
this.option("testing", {
|
|
24
24
|
type: Boolean,
|
|
25
25
|
required: true,
|
|
26
|
-
|
|
26
|
+
description: "Include testing badge",
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
this.option("codecov", {
|
|
30
30
|
type: Boolean,
|
|
31
31
|
required: true,
|
|
32
|
-
|
|
32
|
+
description: "Include codecov badge",
|
|
33
33
|
});
|
|
34
34
|
|
|
35
35
|
this.option("content", {
|
|
36
36
|
type: String,
|
|
37
37
|
required: false,
|
|
38
|
-
|
|
38
|
+
description: "Readme content",
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -68,7 +68,7 @@ export default class LibReadmeGenerator extends Generator {
|
|
|
68
68
|
const match =
|
|
69
69
|
repository &&
|
|
70
70
|
repository.match(
|
|
71
|
-
/^(?:git@|https?:\/\/)(?:([^./:]+)(?:\.com)?[/:])?([^/:]+)\/([^./:]+)(?:.git)
|
|
71
|
+
/^(?:git@|https?:\/\/)(?:([^./:]+)(?:\.com)?[/:])?([^/:]+)\/([^./:]+)(?:.git)?/,
|
|
72
72
|
);
|
|
73
73
|
const [, gitHost, gitAccount, gitName] = match || [];
|
|
74
74
|
try {
|
|
@@ -98,7 +98,7 @@ export default class LibReadmeGenerator extends Generator {
|
|
|
98
98
|
: undefined,
|
|
99
99
|
testing: this.options.testing,
|
|
100
100
|
content,
|
|
101
|
-
}
|
|
101
|
+
},
|
|
102
102
|
);
|
|
103
103
|
} catch (error) {
|
|
104
104
|
console.log(error.stack || error.message || error);
|