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,48 +1,48 @@
|
|
|
1
|
-
import Generator from
|
|
2
|
-
import inMonorepo from
|
|
3
|
-
import * as packageUtils from
|
|
4
|
-
import { copyAndFormatTpl } from
|
|
1
|
+
import Generator from "yeoman-generator";
|
|
2
|
+
import inMonorepo from "../../../utils/inMonorepo.js";
|
|
3
|
+
import * as packageUtils from "../../../utils/package.js";
|
|
4
|
+
import { copyAndFormatTpl } from "../../../utils/writeAndFormat.js";
|
|
5
5
|
|
|
6
6
|
export default class LibDocGenerator extends Generator {
|
|
7
7
|
constructor(args, opts) {
|
|
8
8
|
super(args, opts);
|
|
9
9
|
|
|
10
|
-
this.option(
|
|
10
|
+
this.option("enabled", {
|
|
11
11
|
type: Boolean,
|
|
12
12
|
required: false,
|
|
13
13
|
default: true,
|
|
14
|
-
|
|
14
|
+
description: "Enabled.",
|
|
15
15
|
});
|
|
16
16
|
|
|
17
|
-
this.option(
|
|
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
|
-
this.option(
|
|
24
|
+
this.option("packageManager", {
|
|
25
25
|
type: String,
|
|
26
|
-
default:
|
|
27
|
-
|
|
26
|
+
default: "yarn",
|
|
27
|
+
description: "yarn or npm",
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
this.option(
|
|
30
|
+
this.option("packageNames", {
|
|
31
31
|
type: String,
|
|
32
32
|
required: false,
|
|
33
|
-
default:
|
|
33
|
+
default: "{}",
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
writing() {
|
|
38
|
-
if (this.fs.exists(this.destinationPath(
|
|
39
|
-
this.fs.delete(this.destinationPath(
|
|
38
|
+
if (this.fs.exists(this.destinationPath("jsdoc.conf.json"))) {
|
|
39
|
+
this.fs.delete(this.destinationPath("jsdoc.conf.json"));
|
|
40
40
|
}
|
|
41
|
-
if (this.fs.exists(this.destinationPath(
|
|
42
|
-
this.fs.delete(this.destinationPath(
|
|
41
|
+
if (this.fs.exists(this.destinationPath("jsdoc.conf.js"))) {
|
|
42
|
+
this.fs.delete(this.destinationPath("jsdoc.conf.js"));
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
45
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
46
46
|
|
|
47
47
|
if (this.options.enabled) {
|
|
48
48
|
const jsx =
|
|
@@ -52,14 +52,14 @@ export default class LibDocGenerator extends Generator {
|
|
|
52
52
|
|
|
53
53
|
if (inMonorepo && inMonorepo.root) {
|
|
54
54
|
const existingConfig = this.fs.readJSON(
|
|
55
|
-
this.destinationPath(
|
|
55
|
+
this.destinationPath("tsconfig.doc.json"),
|
|
56
56
|
{ typedocOptions: {} },
|
|
57
57
|
);
|
|
58
58
|
// "external-modulemap": ".*packages/([^/]+)/.*",
|
|
59
59
|
const packagePaths = JSON.parse(this.options.packagePaths);
|
|
60
60
|
|
|
61
61
|
const filteredPackages = packagePaths
|
|
62
|
-
.filter((pkgPath) => !pkgPath.endsWith(
|
|
62
|
+
.filter((pkgPath) => !pkgPath.endsWith("-example"))
|
|
63
63
|
.map((pkgPath) => {
|
|
64
64
|
return {
|
|
65
65
|
path: pkgPath,
|
|
@@ -85,8 +85,8 @@ export default class LibDocGenerator extends Generator {
|
|
|
85
85
|
}
|
|
86
86
|
copyAndFormatTpl(
|
|
87
87
|
this.fs,
|
|
88
|
-
this.templatePath(
|
|
89
|
-
this.destinationPath(
|
|
88
|
+
this.templatePath("tsconfig.doc.json.lerna.ejs"),
|
|
89
|
+
this.destinationPath("tsconfig.doc.json"),
|
|
90
90
|
{
|
|
91
91
|
jsx,
|
|
92
92
|
workspaces: pkg.workspaces,
|
|
@@ -94,7 +94,7 @@ export default class LibDocGenerator extends Generator {
|
|
|
94
94
|
packagePaths: filteredPackages.map((p) => p.path),
|
|
95
95
|
repositoryUrl: pkg.homepage, // or pkg.repository.replace(/\.git$/, '')
|
|
96
96
|
packageManager: this.options.packageManager,
|
|
97
|
-
readme: existingConfig.typedocOptions.readme ||
|
|
97
|
+
readme: existingConfig.typedocOptions.readme || "README.md",
|
|
98
98
|
},
|
|
99
99
|
);
|
|
100
100
|
} else {
|
|
@@ -103,32 +103,32 @@ export default class LibDocGenerator extends Generator {
|
|
|
103
103
|
);
|
|
104
104
|
copyAndFormatTpl(
|
|
105
105
|
this.fs,
|
|
106
|
-
this.templatePath(
|
|
107
|
-
this.destinationPath(
|
|
108
|
-
{ jsx, readme:
|
|
106
|
+
this.templatePath("tsconfig.doc.json.ejs"),
|
|
107
|
+
this.destinationPath("tsconfig.doc.json"),
|
|
108
|
+
{ jsx, readme: "README.md", entryPoints },
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
111
|
} else {
|
|
112
112
|
// this.fs.delete(this.destinationPath('jsdoc.conf.js'));
|
|
113
|
-
if (this.fs.exists(this.destinationPath(
|
|
114
|
-
this.fs.delete(this.destinationPath(
|
|
113
|
+
if (this.fs.exists(this.destinationPath("docs"))) {
|
|
114
|
+
this.fs.delete(this.destinationPath("docs"));
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
if (this.fs.exists(this.destinationPath(
|
|
118
|
-
this.fs.delete(this.destinationPath(
|
|
117
|
+
if (this.fs.exists(this.destinationPath("tsconfig.doc.json"))) {
|
|
118
|
+
this.fs.delete(this.destinationPath("tsconfig.doc.json"));
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
packageUtils.removeDevDependencies(pkg, [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
"jsdoc",
|
|
124
|
+
"minami",
|
|
125
|
+
"jaguarjs-jsdoc",
|
|
126
|
+
"typedoc-plugin-lerna-packages",
|
|
127
|
+
"@chrp/typedoc-plugin-lerna-packages",
|
|
128
128
|
]);
|
|
129
129
|
|
|
130
130
|
packageUtils.addOrRemoveDevDependencies(pkg, this.options.enabled, [
|
|
131
|
-
|
|
131
|
+
"typedoc",
|
|
132
132
|
]);
|
|
133
133
|
|
|
134
134
|
// packageUtils.addOrRemoveDevDependencies(
|
|
@@ -147,17 +147,17 @@ export default class LibDocGenerator extends Generator {
|
|
|
147
147
|
// );
|
|
148
148
|
|
|
149
149
|
if (pkg.scripts) {
|
|
150
|
-
delete pkg.scripts[
|
|
150
|
+
delete pkg.scripts["generate:docs"];
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
if (this.options.enabled) {
|
|
154
154
|
packageUtils.addScripts(pkg, {
|
|
155
|
-
|
|
155
|
+
"generate:api": "typedoc --tsconfig tsconfig.doc.json",
|
|
156
156
|
});
|
|
157
157
|
} else {
|
|
158
|
-
delete pkg.scripts[
|
|
158
|
+
delete pkg.scripts["generate:api"];
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
this.fs.writeJSON(this.destinationPath(
|
|
161
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
import camelCase from
|
|
2
|
-
import Generator from
|
|
3
|
-
import inMonorepo from
|
|
4
|
-
import * as packageUtils from
|
|
5
|
-
import { copyAndFormatTpl } from
|
|
1
|
+
import camelCase from "lodash.camelcase";
|
|
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 LibReadmeGenerator extends Generator {
|
|
8
8
|
constructor(args, opts) {
|
|
9
9
|
super(args, opts);
|
|
10
10
|
|
|
11
|
-
this.option(
|
|
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
|
-
this.option(
|
|
17
|
+
this.option("documentation", {
|
|
18
18
|
type: Boolean,
|
|
19
19
|
required: true,
|
|
20
|
-
|
|
20
|
+
description: "Include documentation",
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
-
this.option(
|
|
23
|
+
this.option("testing", {
|
|
24
24
|
type: Boolean,
|
|
25
25
|
required: true,
|
|
26
|
-
|
|
26
|
+
description: "Include testing badge",
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
-
this.option(
|
|
29
|
+
this.option("codecov", {
|
|
30
30
|
type: Boolean,
|
|
31
31
|
required: true,
|
|
32
|
-
|
|
32
|
+
description: "Include codecov badge",
|
|
33
33
|
});
|
|
34
34
|
|
|
35
|
-
this.option(
|
|
35
|
+
this.option("content", {
|
|
36
36
|
type: String,
|
|
37
37
|
required: false,
|
|
38
|
-
|
|
38
|
+
description: "Readme content",
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
writing() {
|
|
43
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
43
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"));
|
|
44
44
|
|
|
45
|
-
const readmePath = this.destinationPath(
|
|
45
|
+
const readmePath = this.destinationPath("README.md");
|
|
46
46
|
let content = this.options.content;
|
|
47
47
|
|
|
48
48
|
if (this.fs.exists(readmePath)) {
|
|
@@ -74,7 +74,7 @@ export default class LibReadmeGenerator extends Generator {
|
|
|
74
74
|
try {
|
|
75
75
|
copyAndFormatTpl(
|
|
76
76
|
this.fs,
|
|
77
|
-
this.templatePath(
|
|
77
|
+
this.templatePath("README.md.ejs"),
|
|
78
78
|
readmePath,
|
|
79
79
|
{
|
|
80
80
|
privatePackage: pkg.private,
|
|
@@ -93,7 +93,7 @@ export default class LibReadmeGenerator extends Generator {
|
|
|
93
93
|
codecov: this.options.codecov,
|
|
94
94
|
documentation: this.options.documentation,
|
|
95
95
|
documentationUrl:
|
|
96
|
-
this.options.documentation && gitHost ===
|
|
96
|
+
this.options.documentation && gitHost === "github"
|
|
97
97
|
? `https://${gitAccount}.github.io/${gitName}/`
|
|
98
98
|
: undefined,
|
|
99
99
|
testing: this.options.testing,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { execSync } from
|
|
2
|
-
import fs from
|
|
3
|
-
import { platform } from
|
|
4
|
-
import { getPluginConfiguration } from
|
|
5
|
-
import { Configuration, Project } from
|
|
6
|
-
import { ppath } from
|
|
1
|
+
import { execSync } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { platform } from "node:process";
|
|
4
|
+
import { getPluginConfiguration } from "@yarnpkg/cli";
|
|
5
|
+
import { Configuration, Project } from "@yarnpkg/core";
|
|
6
|
+
import { ppath } from "@yarnpkg/fslib";
|
|
7
7
|
import {
|
|
8
8
|
buildTopologicalOrderBatches,
|
|
9
9
|
buildDependenciesMaps,
|
|
10
10
|
getWorkspaceName,
|
|
11
|
-
} from
|
|
12
|
-
import Generator from
|
|
13
|
-
import * as packageUtils from
|
|
14
|
-
import { copyAndFormatTpl } from
|
|
11
|
+
} from "yarn-workspace-utils";
|
|
12
|
+
import Generator from "yeoman-generator";
|
|
13
|
+
import * as packageUtils from "../../utils/package.js";
|
|
14
|
+
import { copyAndFormatTpl } from "../../utils/writeAndFormat.js";
|
|
15
15
|
|
|
16
16
|
export const createYarnProject = async () => {
|
|
17
17
|
const portablePath = ppath.cwd();
|
|
@@ -28,7 +28,7 @@ export const createYarnProject = async () => {
|
|
|
28
28
|
|
|
29
29
|
const getAppTypes = (configs) => {
|
|
30
30
|
const appConfigs = configs.filter(
|
|
31
|
-
(config) => config && config.project && config.project.type ===
|
|
31
|
+
(config) => config && config.project && config.project.type === "app",
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const appTypes = new Set();
|
|
@@ -42,11 +42,10 @@ const getAppTypes = (configs) => {
|
|
|
42
42
|
const hasDist = (packages, configs) =>
|
|
43
43
|
configs.some(
|
|
44
44
|
(config, index) =>
|
|
45
|
-
!!(config && config.project && config.project.type ===
|
|
45
|
+
!!(config && config.project && config.project.type === "lib") &&
|
|
46
46
|
!!(
|
|
47
|
-
packages[index].pob
|
|
48
|
-
packages[index].pob
|
|
49
|
-
packages[index].pob.babelEnvs.length > 0
|
|
47
|
+
packages[index].pob?.babelEnvs?.length > 0 ||
|
|
48
|
+
packages[index].pob?.envs?.length > 0
|
|
50
49
|
),
|
|
51
50
|
);
|
|
52
51
|
|
|
@@ -56,8 +55,8 @@ const hasBuild = (packages, configs) =>
|
|
|
56
55
|
!!(
|
|
57
56
|
config &&
|
|
58
57
|
config.project &&
|
|
59
|
-
config.project.type ===
|
|
60
|
-
config.app.type ===
|
|
58
|
+
config.project.type === "app" &&
|
|
59
|
+
config.app.type === "alp-node"
|
|
61
60
|
),
|
|
62
61
|
);
|
|
63
62
|
|
|
@@ -65,44 +64,46 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
65
64
|
constructor(args, opts) {
|
|
66
65
|
super(args, opts);
|
|
67
66
|
|
|
68
|
-
this.option(
|
|
67
|
+
this.option("updateOnly", {
|
|
69
68
|
type: Boolean,
|
|
70
69
|
required: false,
|
|
71
70
|
default: false,
|
|
72
|
-
|
|
71
|
+
description: "Avoid asking questions",
|
|
73
72
|
});
|
|
74
73
|
|
|
75
|
-
this.option(
|
|
74
|
+
this.option("isAppProject", {
|
|
76
75
|
type: Boolean,
|
|
77
76
|
required: false,
|
|
78
77
|
default: false,
|
|
79
|
-
|
|
78
|
+
description: "app project, no pusblishing on npm",
|
|
80
79
|
});
|
|
81
80
|
|
|
82
|
-
this.option(
|
|
81
|
+
this.option("packageManager", {
|
|
83
82
|
type: String,
|
|
84
|
-
default:
|
|
85
|
-
|
|
83
|
+
default: "yarn",
|
|
84
|
+
description: "yarn or npm",
|
|
86
85
|
});
|
|
87
86
|
|
|
88
|
-
this.option(
|
|
87
|
+
this.option("yarnNodeLinker", {
|
|
89
88
|
type: String,
|
|
90
89
|
required: false,
|
|
91
|
-
default:
|
|
92
|
-
|
|
90
|
+
default: "pnp",
|
|
91
|
+
description:
|
|
92
|
+
"Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.",
|
|
93
93
|
});
|
|
94
94
|
|
|
95
|
-
this.option(
|
|
95
|
+
this.option("onlyLatestLTS", {
|
|
96
96
|
type: Boolean,
|
|
97
97
|
required: true,
|
|
98
|
-
|
|
98
|
+
description: "only latest lts",
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
this.option(
|
|
101
|
+
this.option("disableYarnGitCache", {
|
|
102
102
|
type: Boolean,
|
|
103
103
|
required: false,
|
|
104
104
|
default: false,
|
|
105
|
-
|
|
105
|
+
description:
|
|
106
|
+
"Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.",
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
|
|
@@ -119,7 +120,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
119
120
|
for (const batch of batches) {
|
|
120
121
|
// sort by name to ensure consistent ordering
|
|
121
122
|
batch.sort((a, b) =>
|
|
122
|
-
getWorkspaceName(a).localeCompare(getWorkspaceName(b),
|
|
123
|
+
getWorkspaceName(a).localeCompare(getWorkspaceName(b), "en"),
|
|
123
124
|
);
|
|
124
125
|
|
|
125
126
|
batch.forEach((workspace) => {
|
|
@@ -143,66 +144,66 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
143
144
|
}
|
|
144
145
|
|
|
145
146
|
async prompting() {
|
|
146
|
-
const config = this.config.get(
|
|
147
|
+
const config = this.config.get("monorepo");
|
|
147
148
|
|
|
148
149
|
if (this.options.updateOnly && config) {
|
|
149
150
|
this.pobLernaConfig = config;
|
|
150
151
|
this.pobLernaConfig.packageNames = this.packageNames;
|
|
151
|
-
this.config.set(
|
|
152
|
+
this.config.set("monorepo", this.pobLernaConfig);
|
|
152
153
|
return;
|
|
153
154
|
}
|
|
154
155
|
|
|
155
156
|
this.pobLernaConfig = await this.prompt([
|
|
156
157
|
{
|
|
157
|
-
type:
|
|
158
|
-
name:
|
|
159
|
-
message:
|
|
158
|
+
type: "confirm",
|
|
159
|
+
name: "ci",
|
|
160
|
+
message: "Would you like ci with github actions ?",
|
|
160
161
|
default: config
|
|
161
162
|
? config.ci
|
|
162
|
-
: this.fs.exists(this.destinationPath(
|
|
163
|
-
this.fs.exists(this.destinationPath(
|
|
163
|
+
: this.fs.exists(this.destinationPath(".circleci/config.yml")) ||
|
|
164
|
+
this.fs.exists(this.destinationPath(".github/workflows")),
|
|
164
165
|
},
|
|
165
166
|
{
|
|
166
|
-
type:
|
|
167
|
-
name:
|
|
168
|
-
message:
|
|
167
|
+
type: "confirm",
|
|
168
|
+
name: "testing",
|
|
169
|
+
message: "Would you like testing ?",
|
|
169
170
|
when: (answers) => answers.ci,
|
|
170
171
|
default: config ? config.testing : true,
|
|
171
172
|
},
|
|
172
173
|
{
|
|
173
|
-
type:
|
|
174
|
-
name:
|
|
175
|
-
message:
|
|
174
|
+
type: "confirm",
|
|
175
|
+
name: "codecov",
|
|
176
|
+
message: "Would you like code coverage ?",
|
|
176
177
|
when: (answers) => answers.ci && answers.testing,
|
|
177
178
|
default: config ? config.codecov : true,
|
|
178
179
|
},
|
|
179
180
|
{
|
|
180
|
-
type:
|
|
181
|
-
name:
|
|
182
|
-
message:
|
|
181
|
+
type: "confirm",
|
|
182
|
+
name: "documentation",
|
|
183
|
+
message: "Would you like documentation ?",
|
|
183
184
|
when: (answers) => answers.ci && !this.options.isAppProject,
|
|
184
185
|
default: config ? config.documentation : true,
|
|
185
186
|
},
|
|
186
187
|
{
|
|
187
|
-
type:
|
|
188
|
-
name:
|
|
189
|
-
message:
|
|
188
|
+
type: "confirm",
|
|
189
|
+
name: "typescript",
|
|
190
|
+
message: "Would you like typescript monorepo ?",
|
|
190
191
|
default: config ? config.typescript : true,
|
|
191
192
|
},
|
|
192
193
|
{
|
|
193
|
-
type:
|
|
194
|
-
name:
|
|
195
|
-
message:
|
|
194
|
+
type: "confirm",
|
|
195
|
+
name: "eslint",
|
|
196
|
+
message: "Would you like eslint in monorepo ?",
|
|
196
197
|
default: config ? config.eslint : true,
|
|
197
198
|
},
|
|
198
199
|
]);
|
|
199
200
|
this.pobLernaConfig.packageNames = this.packageNames;
|
|
200
|
-
this.config.set(
|
|
201
|
-
this.config.delete(
|
|
201
|
+
this.config.set("monorepo", this.pobLernaConfig);
|
|
202
|
+
this.config.delete("pob-config");
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
default() {
|
|
205
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
206
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"), {});
|
|
206
207
|
|
|
207
208
|
const packageNames = this.packageNames;
|
|
208
209
|
const packagePaths = this.packageLocations.filter(
|
|
@@ -213,19 +214,19 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
213
214
|
|
|
214
215
|
if (packagePaths.length === 0 && packageNames.length > 0) {
|
|
215
216
|
console.log(packageNames, packagePaths);
|
|
216
|
-
throw new Error(
|
|
217
|
+
throw new Error("packages should not be empty");
|
|
217
218
|
}
|
|
218
219
|
|
|
219
|
-
this.composeWith(
|
|
220
|
+
this.composeWith("pob:common:husky", {});
|
|
220
221
|
|
|
221
222
|
const isYarnVersionEnabled = this.pobLernaConfig.ci;
|
|
222
223
|
|
|
223
224
|
const splitCIJobs = this.packageNames.length > 8;
|
|
224
225
|
|
|
225
|
-
this.composeWith(
|
|
226
|
+
this.composeWith("pob:common:testing", {
|
|
226
227
|
monorepo: true,
|
|
227
228
|
enable: this.pobLernaConfig.testing,
|
|
228
|
-
runner: this.pobLernaConfig.testRunner ||
|
|
229
|
+
runner: this.pobLernaConfig.testRunner || "jest",
|
|
229
230
|
disableYarnGitCache: this.options.disableYarnGitCache,
|
|
230
231
|
enableReleasePlease: false,
|
|
231
232
|
enableYarnVersion: isYarnVersionEnabled,
|
|
@@ -242,7 +243,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
242
243
|
splitCIJobs,
|
|
243
244
|
});
|
|
244
245
|
|
|
245
|
-
this.composeWith(
|
|
246
|
+
this.composeWith("pob:common:format-lint", {
|
|
246
247
|
monorepo: true,
|
|
247
248
|
documentation: this.pobLernaConfig.documentation,
|
|
248
249
|
typescript: this.pobLernaConfig.typescript,
|
|
@@ -252,15 +253,15 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
252
253
|
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
253
254
|
appTypes: JSON.stringify(getAppTypes(this.packageConfigs)),
|
|
254
255
|
ignorePaths: [
|
|
255
|
-
hasDist(this.packages, this.packageConfigs) &&
|
|
256
|
-
hasBuild(this.packages, this.packageConfigs) &&
|
|
256
|
+
hasDist(this.packages, this.packageConfigs) && "/dist",
|
|
257
|
+
hasBuild(this.packages, this.packageConfigs) && "/build",
|
|
257
258
|
]
|
|
258
259
|
.filter(Boolean)
|
|
259
|
-
.join(
|
|
260
|
+
.join("\n"),
|
|
260
261
|
rootIgnorePaths: [],
|
|
261
262
|
});
|
|
262
263
|
|
|
263
|
-
this.composeWith(
|
|
264
|
+
this.composeWith("pob:lib:doc", {
|
|
264
265
|
enabled: this.pobLernaConfig.documentation,
|
|
265
266
|
testing: this.pobLernaConfig.testing,
|
|
266
267
|
packageNames: JSON.stringify(packageNames),
|
|
@@ -268,7 +269,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
268
269
|
packageManager: this.options.packageManager,
|
|
269
270
|
});
|
|
270
271
|
|
|
271
|
-
this.composeWith(
|
|
272
|
+
this.composeWith("pob:core:vscode", {
|
|
272
273
|
root: true,
|
|
273
274
|
monorepo: true,
|
|
274
275
|
packageManager: this.options.packageManager,
|
|
@@ -281,16 +282,16 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
281
282
|
});
|
|
282
283
|
|
|
283
284
|
// Always add a gitignore, because npm publish uses it.
|
|
284
|
-
this.composeWith(
|
|
285
|
+
this.composeWith("pob:core:gitignore", {
|
|
285
286
|
root: true,
|
|
286
287
|
typescript: this.pobLernaConfig.typescript,
|
|
287
288
|
documentation: this.pobLernaConfig.documentation,
|
|
288
289
|
testing: this.pobLernaConfig.testing,
|
|
289
290
|
});
|
|
290
291
|
|
|
291
|
-
this.composeWith(
|
|
292
|
+
this.composeWith("pob:common:remove-old-dependencies");
|
|
292
293
|
|
|
293
|
-
this.composeWith(
|
|
294
|
+
this.composeWith("pob:common:release", {
|
|
294
295
|
enable: true,
|
|
295
296
|
enablePublish: !this.options.isAppProject,
|
|
296
297
|
withBabel: this.pobLernaConfig.typescript,
|
|
@@ -301,7 +302,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
301
302
|
updateOnly: this.options.updateOnly,
|
|
302
303
|
});
|
|
303
304
|
|
|
304
|
-
this.composeWith(
|
|
305
|
+
this.composeWith("pob:monorepo:typescript", {
|
|
305
306
|
enable: this.pobLernaConfig.typescript,
|
|
306
307
|
isAppProject: this.options.isAppProject,
|
|
307
308
|
packageNames: JSON.stringify(packageNames),
|
|
@@ -309,18 +310,18 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
309
310
|
testRunner: this.pobLernaConfig.testRunner,
|
|
310
311
|
});
|
|
311
312
|
|
|
312
|
-
this.fs.writeJSON(this.destinationPath(
|
|
313
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
313
314
|
|
|
314
|
-
if (platform !==
|
|
315
|
+
if (platform !== "win32") {
|
|
315
316
|
execSync(
|
|
316
|
-
`rm -Rf ${[
|
|
317
|
+
`rm -Rf ${["lib-*", "coverage", "docs"].filter(Boolean).join(" ")}`,
|
|
317
318
|
);
|
|
318
319
|
}
|
|
319
320
|
}
|
|
320
321
|
|
|
321
322
|
writing() {
|
|
322
323
|
if (!this.options.isAppProject) {
|
|
323
|
-
const pkg = this.fs.readJSON(this.destinationPath(
|
|
324
|
+
const pkg = this.fs.readJSON(this.destinationPath("package.json"), {});
|
|
324
325
|
|
|
325
326
|
const rollupConfigs = [];
|
|
326
327
|
this.packageLocations.forEach((location) => {
|
|
@@ -336,32 +337,32 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
336
337
|
if (rollupConfigs.length > 0) {
|
|
337
338
|
copyAndFormatTpl(
|
|
338
339
|
this.fs,
|
|
339
|
-
this.templatePath(
|
|
340
|
-
this.destinationPath(
|
|
340
|
+
this.templatePath("monorepo.rollup.config.mjs.ejs"),
|
|
341
|
+
this.destinationPath("rollup.config.mjs"),
|
|
341
342
|
{
|
|
342
343
|
configLocations: rollupConfigs,
|
|
343
344
|
},
|
|
344
345
|
);
|
|
345
346
|
} else {
|
|
346
|
-
this.fs.delete(
|
|
347
|
+
this.fs.delete("rollup.config.mjs");
|
|
347
348
|
}
|
|
348
349
|
packageUtils.addOrRemoveScripts(pkg, rollupConfigs.length > 0, {
|
|
349
|
-
|
|
350
|
-
build:
|
|
351
|
-
watch:
|
|
350
|
+
"clean:build": "yarn workspaces foreach --parallel -A run clean:build",
|
|
351
|
+
build: "yarn clean:build && rollup --config rollup.config.mjs",
|
|
352
|
+
watch: "yarn clean:build && rollup --config rollup.config.mjs --watch",
|
|
352
353
|
});
|
|
353
354
|
packageUtils.addOrRemoveDevDependencies(pkg, rollupConfigs.length, [
|
|
354
|
-
|
|
355
|
-
|
|
355
|
+
"@babel/core",
|
|
356
|
+
"pob-babel",
|
|
356
357
|
]);
|
|
357
|
-
this.fs.writeJSON(this.destinationPath(
|
|
358
|
+
this.fs.writeJSON(this.destinationPath("package.json"), pkg);
|
|
358
359
|
}
|
|
359
360
|
|
|
360
|
-
this.composeWith(
|
|
361
|
+
this.composeWith("pob:core:sort-package");
|
|
361
362
|
}
|
|
362
363
|
|
|
363
364
|
end() {
|
|
364
|
-
console.log(
|
|
365
|
+
console.log("save config");
|
|
365
366
|
this.config.save();
|
|
366
367
|
}
|
|
367
368
|
}
|