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,66 +1,68 @@
|
|
|
1
|
-
import { rmSync } from
|
|
2
|
-
import Generator from
|
|
3
|
-
import inMonorepo from
|
|
4
|
-
import * as packageUtils from
|
|
1
|
+
import { rmSync } 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
5
|
|
|
6
6
|
export default class PobLibGenerator extends Generator {
|
|
7
7
|
constructor(args, opts) {
|
|
8
8
|
super(args, opts);
|
|
9
9
|
|
|
10
|
-
this.option(
|
|
10
|
+
this.option("updateOnly", {
|
|
11
11
|
type: Boolean,
|
|
12
12
|
required: false,
|
|
13
13
|
default: false,
|
|
14
|
-
|
|
14
|
+
description: "Avoid asking questions",
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
this.option(
|
|
17
|
+
this.option("fromPob", {
|
|
18
18
|
type: Boolean,
|
|
19
19
|
required: false,
|
|
20
20
|
default: false,
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
this.option(
|
|
23
|
+
this.option("packageManager", {
|
|
24
24
|
type: String,
|
|
25
|
-
default:
|
|
26
|
-
|
|
25
|
+
default: "yarn",
|
|
26
|
+
description: "yarn or npm",
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
this.option(
|
|
29
|
+
this.option("yarnNodeLinker", {
|
|
30
30
|
type: String,
|
|
31
31
|
required: false,
|
|
32
|
-
default:
|
|
33
|
-
|
|
32
|
+
default: "node-modules",
|
|
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
|
-
this.option(
|
|
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
|
|
|
44
46
|
initializing() {
|
|
45
47
|
this.pobjson =
|
|
46
|
-
this.config.get(
|
|
47
|
-
this.config.get(
|
|
48
|
-
this.config.get(
|
|
49
|
-
this.config.get(
|
|
48
|
+
this.config.get("lib") ||
|
|
49
|
+
this.config.get("pob") ||
|
|
50
|
+
this.config.get("pob-config") ||
|
|
51
|
+
this.config.get("pob-lib-config");
|
|
50
52
|
|
|
51
53
|
if (!this.pobjson) {
|
|
52
|
-
this.pobjson = this.fs.readJSON(this.destinationPath(
|
|
54
|
+
this.pobjson = this.fs.readJSON(this.destinationPath(".pob.json"), null);
|
|
53
55
|
if (this.pobjson) {
|
|
54
|
-
this.config.set(
|
|
56
|
+
this.config.set("lib", this.pobjson);
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
this.config.delete(
|
|
59
|
-
this.config.delete(
|
|
60
|
-
this.config.delete(
|
|
61
|
-
this.config.delete(
|
|
60
|
+
this.config.delete("libtest"); // deprecated
|
|
61
|
+
this.config.delete("pob"); // deprecated
|
|
62
|
+
this.config.delete("pob-config"); // deprecated
|
|
63
|
+
this.config.delete("pob-lib-config"); // deprecated
|
|
62
64
|
this.config.save();
|
|
63
|
-
this.fs.delete(
|
|
65
|
+
this.fs.delete(".pob.json"); // deprecated
|
|
64
66
|
|
|
65
67
|
if (!this.pobjson || this.pobjson.babelEnvs) {
|
|
66
68
|
this.pobjson = {};
|
|
@@ -69,50 +71,53 @@ export default class PobLibGenerator extends Generator {
|
|
|
69
71
|
this.updateOnly = this.options.updateOnly;
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
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;
|
|
79
84
|
|
|
80
|
-
if (babelEnvs && typeof babelEnvs[0] ===
|
|
85
|
+
if (babelEnvs && typeof babelEnvs[0] === "string") {
|
|
81
86
|
babelEnvs = babelEnvs.map((env) => {
|
|
82
87
|
switch (env) {
|
|
83
|
-
case
|
|
84
|
-
case
|
|
85
|
-
case
|
|
86
|
-
case
|
|
88
|
+
case "node6":
|
|
89
|
+
case "node7":
|
|
90
|
+
case "node8":
|
|
91
|
+
case "node10":
|
|
87
92
|
return {
|
|
88
|
-
target:
|
|
93
|
+
target: "node",
|
|
89
94
|
version: 14,
|
|
90
|
-
formats: [
|
|
95
|
+
formats: ["cjs"],
|
|
91
96
|
};
|
|
92
97
|
|
|
93
|
-
case
|
|
94
|
-
case
|
|
95
|
-
case
|
|
98
|
+
case "webpack-node7":
|
|
99
|
+
case "module-node7":
|
|
100
|
+
case "module-node8":
|
|
96
101
|
return {
|
|
97
|
-
target:
|
|
102
|
+
target: "node",
|
|
98
103
|
version: 14,
|
|
99
|
-
formats: [
|
|
104
|
+
formats: ["es"],
|
|
100
105
|
};
|
|
101
106
|
|
|
102
|
-
case
|
|
103
|
-
case
|
|
104
|
-
return { target:
|
|
107
|
+
case "module":
|
|
108
|
+
case "webpack":
|
|
109
|
+
return { target: "browser", formats: ["es"] };
|
|
105
110
|
|
|
106
|
-
case
|
|
107
|
-
case
|
|
111
|
+
case "module-modern-browsers":
|
|
112
|
+
case "webpack-modern-browsers":
|
|
108
113
|
return {
|
|
109
|
-
target:
|
|
110
|
-
version:
|
|
111
|
-
formats: [
|
|
114
|
+
target: "browser",
|
|
115
|
+
version: "modern",
|
|
116
|
+
formats: ["es"],
|
|
112
117
|
};
|
|
113
118
|
|
|
114
|
-
case
|
|
115
|
-
return { target:
|
|
119
|
+
case "browsers":
|
|
120
|
+
return { target: "browser", formats: ["cjs"] };
|
|
116
121
|
|
|
117
122
|
default:
|
|
118
123
|
throw new Error(`Unsupported env ${env}`);
|
|
@@ -127,13 +132,13 @@ export default class PobLibGenerator extends Generator {
|
|
|
127
132
|
};
|
|
128
133
|
} else if (this.pobjson.testing) {
|
|
129
134
|
delete this.pobjson.testing.travisci;
|
|
130
|
-
if (
|
|
135
|
+
if ("circleci" in this.pobjson.testing) {
|
|
131
136
|
this.pobjson.testing.ci = this.pobjson.testing.circleci;
|
|
132
137
|
delete this.pobjson.testing.circleci;
|
|
133
138
|
}
|
|
134
139
|
}
|
|
135
140
|
|
|
136
|
-
if (typeof this.pobjson.documentation ===
|
|
141
|
+
if (typeof this.pobjson.documentation === "object") {
|
|
137
142
|
this.pobjson.documentation = true;
|
|
138
143
|
}
|
|
139
144
|
|
|
@@ -148,16 +153,18 @@ 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
|
}
|
|
155
162
|
|
|
156
|
-
this.fs.writeJSON(this.destinationPath(
|
|
163
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
157
164
|
}
|
|
158
165
|
|
|
159
166
|
async prompting() {
|
|
160
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
167
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
161
168
|
|
|
162
169
|
// documentation
|
|
163
170
|
if (inMonorepo && !inMonorepo.root) {
|
|
@@ -165,9 +172,9 @@ export default class PobLibGenerator extends Generator {
|
|
|
165
172
|
} else {
|
|
166
173
|
const answers = await this.prompt([
|
|
167
174
|
{
|
|
168
|
-
type:
|
|
169
|
-
name:
|
|
170
|
-
message:
|
|
175
|
+
type: "confirm",
|
|
176
|
+
name: "documentation",
|
|
177
|
+
message: "Would you like documentation (manually generated) ?",
|
|
171
178
|
when: !this.updateOnly || this.pobjson.documentation === undefined,
|
|
172
179
|
default:
|
|
173
180
|
this.pobjson.documentation != null
|
|
@@ -182,9 +189,9 @@ export default class PobLibGenerator extends Generator {
|
|
|
182
189
|
// testing
|
|
183
190
|
if (!this.updateOnly || this.pobjson.testing === undefined) {
|
|
184
191
|
const { testing } = await this.prompt({
|
|
185
|
-
type:
|
|
186
|
-
name:
|
|
187
|
-
message:
|
|
192
|
+
type: "confirm",
|
|
193
|
+
name: "testing",
|
|
194
|
+
message: "Would you like testing ?",
|
|
188
195
|
default: this.pobjson.testing || false,
|
|
189
196
|
});
|
|
190
197
|
this.pobjson.testing = !testing ? false : this.pobjson.testing || {};
|
|
@@ -193,33 +200,33 @@ export default class PobLibGenerator extends Generator {
|
|
|
193
200
|
if (this.pobjson.testing && !(inMonorepo || inMonorepo.root)) {
|
|
194
201
|
const testingPrompts = await this.prompt([
|
|
195
202
|
{
|
|
196
|
-
type:
|
|
197
|
-
name:
|
|
198
|
-
message:
|
|
203
|
+
type: "confirm",
|
|
204
|
+
name: "ci",
|
|
205
|
+
message: "Would you like ci with github actions ?",
|
|
199
206
|
when: !this.updateOnly || this.pobjson.testing?.ci === undefined,
|
|
200
207
|
default: this.pobjson.testing.ci !== false,
|
|
201
208
|
},
|
|
202
209
|
{
|
|
203
|
-
type:
|
|
204
|
-
name:
|
|
205
|
-
message:
|
|
210
|
+
type: "list",
|
|
211
|
+
name: "runner",
|
|
212
|
+
message: "Testing runner ?",
|
|
206
213
|
when: !this.updateOnly || this.pobjson.testing?.runner === undefined,
|
|
207
|
-
default: this.pobjson.testing?.runner ||
|
|
214
|
+
default: this.pobjson.testing?.runner || "jest",
|
|
208
215
|
choices: [
|
|
209
216
|
{
|
|
210
|
-
name:
|
|
211
|
-
value:
|
|
217
|
+
name: "Jest",
|
|
218
|
+
value: "jest",
|
|
212
219
|
},
|
|
213
220
|
{
|
|
214
|
-
name:
|
|
215
|
-
value:
|
|
221
|
+
name: "node:test",
|
|
222
|
+
value: "node",
|
|
216
223
|
},
|
|
217
224
|
],
|
|
218
225
|
},
|
|
219
226
|
{
|
|
220
|
-
type:
|
|
221
|
-
name:
|
|
222
|
-
message:
|
|
227
|
+
type: "confirm",
|
|
228
|
+
name: "codecov",
|
|
229
|
+
message: "Would you like codecov ?",
|
|
223
230
|
when: !this.updateOnly || this.pobjson.testing?.codecov === undefined,
|
|
224
231
|
default: this.pobjson.testing.codecov === true,
|
|
225
232
|
},
|
|
@@ -227,16 +234,16 @@ export default class PobLibGenerator extends Generator {
|
|
|
227
234
|
Object.assign(this.pobjson.testing, testingPrompts);
|
|
228
235
|
}
|
|
229
236
|
|
|
230
|
-
this.fs.writeJSON(this.destinationPath(
|
|
237
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
231
238
|
|
|
232
|
-
this.composeWith(
|
|
239
|
+
this.composeWith("pob:common:babel", {
|
|
233
240
|
updateOnly: this.options.updateOnly,
|
|
234
241
|
testing: !!this.pobjson.testing,
|
|
235
242
|
documentation: !!this.pobjson.documentation,
|
|
236
243
|
fromPob: this.options.fromPob,
|
|
237
244
|
onlyLatestLTS: false,
|
|
238
245
|
});
|
|
239
|
-
this.composeWith(
|
|
246
|
+
this.composeWith("pob:common:transpiler", {
|
|
240
247
|
updateOnly: this.options.updateOnly,
|
|
241
248
|
testing: !!this.pobjson.testing,
|
|
242
249
|
documentation: !!this.pobjson.documentation,
|
|
@@ -246,34 +253,36 @@ export default class PobLibGenerator extends Generator {
|
|
|
246
253
|
}
|
|
247
254
|
|
|
248
255
|
default() {
|
|
249
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
250
|
-
const babelEnvs =
|
|
256
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
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
|
-
this.composeWith(
|
|
267
|
+
this.composeWith("pob:common:typescript", {
|
|
259
268
|
enable: withTypescript,
|
|
260
269
|
isApp: false,
|
|
261
270
|
dom: browser,
|
|
262
271
|
jsx,
|
|
263
272
|
updateOnly: this.options.updateOnly,
|
|
264
|
-
baseUrl:
|
|
273
|
+
baseUrl: "none", // causes issues on dist definition files
|
|
265
274
|
builddefs: true,
|
|
266
275
|
onlyLatestLTS: false,
|
|
267
276
|
});
|
|
268
277
|
|
|
269
|
-
this.composeWith(
|
|
278
|
+
this.composeWith("pob:common:husky", {});
|
|
270
279
|
|
|
271
|
-
this.composeWith(
|
|
280
|
+
this.composeWith("pob:common:remove-old-dependencies");
|
|
272
281
|
|
|
273
282
|
const enableReleasePlease =
|
|
274
283
|
!inMonorepo && this.pobjson.testing && this.pobjson.testing.ci;
|
|
275
284
|
|
|
276
|
-
this.composeWith(
|
|
285
|
+
this.composeWith("pob:common:testing", {
|
|
277
286
|
enable: this.pobjson.testing,
|
|
278
287
|
disableYarnGitCache: this.options.disableYarnGitCache,
|
|
279
288
|
enableReleasePlease,
|
|
@@ -282,7 +291,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
282
291
|
runner: this.pobjson.testing
|
|
283
292
|
? (inMonorepo
|
|
284
293
|
? inMonorepo.pobMonorepoConfig.testRunner
|
|
285
|
-
: this.pobjson.testing.runner) ||
|
|
294
|
+
: this.pobjson.testing.runner) || "jest"
|
|
286
295
|
: undefined,
|
|
287
296
|
build: withBabel || withTypescript,
|
|
288
297
|
typescript: withTypescript,
|
|
@@ -292,11 +301,11 @@ export default class PobLibGenerator extends Generator {
|
|
|
292
301
|
packageManager: this.options.packageManager,
|
|
293
302
|
isApp: false,
|
|
294
303
|
splitCIJobs: false,
|
|
295
|
-
srcDirectory: withBabel || withTypescript ?
|
|
304
|
+
srcDirectory: withBabel || withTypescript ? "src" : "lib",
|
|
296
305
|
});
|
|
297
306
|
|
|
298
307
|
// must be after testing
|
|
299
|
-
this.composeWith(
|
|
308
|
+
this.composeWith("pob:common:format-lint", {
|
|
300
309
|
typescript: withTypescript,
|
|
301
310
|
documentation:
|
|
302
311
|
!!this.pobjson.documentation ||
|
|
@@ -307,23 +316,23 @@ export default class PobLibGenerator extends Generator {
|
|
|
307
316
|
: this.pobjson.testing?.runner,
|
|
308
317
|
packageManager: this.options.packageManager,
|
|
309
318
|
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
310
|
-
ignorePaths: withBabel || withTypescript ?
|
|
319
|
+
ignorePaths: withBabel || withTypescript ? "/dist" : "",
|
|
311
320
|
});
|
|
312
321
|
|
|
313
|
-
this.composeWith(
|
|
322
|
+
this.composeWith("pob:lib:doc", {
|
|
314
323
|
enabled: this.pobjson.documentation,
|
|
315
324
|
testing: this.pobjson.testing,
|
|
316
325
|
});
|
|
317
326
|
|
|
318
327
|
// must be after doc, testing
|
|
319
|
-
this.composeWith(
|
|
328
|
+
this.composeWith("pob:lib:readme", {
|
|
320
329
|
documentation: !!this.pobjson.documentation,
|
|
321
330
|
testing: !!this.pobjson.testing,
|
|
322
331
|
ci: this.pobjson.testing && this.pobjson.testing.ci,
|
|
323
332
|
codecov: this.pobjson.testing && this.pobjson.testing.codecov,
|
|
324
333
|
});
|
|
325
334
|
|
|
326
|
-
this.composeWith(
|
|
335
|
+
this.composeWith("pob:common:release", {
|
|
327
336
|
enable: !inMonorepo && this.pobjson.testing,
|
|
328
337
|
enablePublish: true,
|
|
329
338
|
withBabel,
|
|
@@ -335,7 +344,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
335
344
|
updateOnly: this.options.updateOnly,
|
|
336
345
|
});
|
|
337
346
|
|
|
338
|
-
this.composeWith(
|
|
347
|
+
this.composeWith("pob:core:vscode", {
|
|
339
348
|
root: !inMonorepo,
|
|
340
349
|
monorepo: false,
|
|
341
350
|
packageManager: this.options.packageManager,
|
|
@@ -346,7 +355,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
346
355
|
});
|
|
347
356
|
|
|
348
357
|
// must be after doc, testing
|
|
349
|
-
this.composeWith(
|
|
358
|
+
this.composeWith("pob:core:gitignore", {
|
|
350
359
|
root: !inMonorepo,
|
|
351
360
|
withBabel: babelEnvs.length > 0,
|
|
352
361
|
typescript: withTypescript,
|
|
@@ -354,32 +363,34 @@ export default class PobLibGenerator extends Generator {
|
|
|
354
363
|
testing: !!this.pobjson.testing,
|
|
355
364
|
});
|
|
356
365
|
|
|
357
|
-
this.composeWith(
|
|
366
|
+
this.composeWith("pob:core:npm", {
|
|
358
367
|
enable: !pkg.private,
|
|
359
|
-
srcDirectory: withBabel || withTypescript ?
|
|
360
|
-
distDirectory: withBabel || withTypescript ?
|
|
368
|
+
srcDirectory: withBabel || withTypescript ? "src" : "lib",
|
|
369
|
+
distDirectory: withBabel || withTypescript ? "dist" : "",
|
|
361
370
|
});
|
|
362
371
|
}
|
|
363
372
|
|
|
364
373
|
writing() {
|
|
365
374
|
// Re-read the content at this point because a composed generator might modify it.
|
|
366
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
375
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
367
376
|
|
|
368
377
|
if (pkg.engines) {
|
|
369
378
|
delete pkg.engines.yarn;
|
|
370
379
|
}
|
|
371
380
|
|
|
372
|
-
if (
|
|
381
|
+
if ("sideEffects" in pkg) {
|
|
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
|
-
packageUtils.removeDevDependencies(pkg, [
|
|
390
|
+
packageUtils.removeDevDependencies(pkg, ["lerna", "@pob/lerna-light"]);
|
|
380
391
|
if (inMonorepo) {
|
|
381
392
|
if (pkg.scripts) {
|
|
382
|
-
if (pkg.name !==
|
|
393
|
+
if (pkg.name !== "pob-dependencies") {
|
|
383
394
|
delete pkg.scripts.preversion;
|
|
384
395
|
}
|
|
385
396
|
delete pkg.scripts.release;
|
|
@@ -389,23 +400,23 @@ export default class PobLibGenerator extends Generator {
|
|
|
389
400
|
|
|
390
401
|
if (!withBabel && !withTypescript) {
|
|
391
402
|
if (
|
|
392
|
-
!this.fs.exists(this.destinationPath(
|
|
393
|
-
this.fs.exists(this.destinationPath(
|
|
403
|
+
!this.fs.exists(this.destinationPath("lib/index.js")) &&
|
|
404
|
+
this.fs.exists(this.destinationPath("index.js"))
|
|
394
405
|
) {
|
|
395
406
|
this.fs.move(
|
|
396
|
-
this.destinationPath(
|
|
397
|
-
this.destinationPath(
|
|
407
|
+
this.destinationPath("index.js"),
|
|
408
|
+
this.destinationPath("lib/index.js"),
|
|
398
409
|
);
|
|
399
410
|
}
|
|
400
411
|
}
|
|
401
412
|
|
|
402
|
-
this.fs.writeJSON(this.destinationPath(
|
|
413
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
403
414
|
[
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
this.pobjson.documentation &&
|
|
408
|
-
!(withBabel || withTypescript) &&
|
|
415
|
+
"lib-node14",
|
|
416
|
+
"lib-node16",
|
|
417
|
+
"coverage",
|
|
418
|
+
this.pobjson.documentation && "docs",
|
|
419
|
+
!(withBabel || withTypescript) && "dist",
|
|
409
420
|
]
|
|
410
421
|
.filter(Boolean)
|
|
411
422
|
.forEach((path) => {
|
|
@@ -414,18 +425,9 @@ export default class PobLibGenerator extends Generator {
|
|
|
414
425
|
|
|
415
426
|
const { pobjson } = this;
|
|
416
427
|
|
|
417
|
-
|
|
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
|
-
this.config.set('lib', pobjson);
|
|
428
|
+
this.config.set("lib", pobjson);
|
|
427
429
|
this.config.save();
|
|
428
430
|
|
|
429
|
-
this.composeWith(
|
|
431
|
+
this.composeWith("pob:core:sort-package");
|
|
430
432
|
}
|
|
431
433
|
}
|