pob 8.8.1 → 8.10.1
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 +60 -0
- package/lib/generators/app/PobAppGenerator.js +1 -0
- package/lib/generators/common/babel/CommonBabelGenerator.js +13 -4
- package/lib/generators/common/format-lint/CommonLintGenerator.js +21 -9
- package/lib/generators/common/old-dependencies/CommonRemoveOldDependenciesGenerator.js +1 -0
- package/lib/generators/core/git/generators/github/CoreGitGithubGenerator.js +34 -6
- package/lib/generators/core/package/CorePackageGenerator.js +29 -13
- package/lib/generators/lib/PobLibGenerator.js +1 -1
- package/lib/generators/lib/doc/templates/tsconfig.doc.json.lerna.ejs +1 -0
- package/lib/generators/monorepo/PobMonorepoGenerator.js +1 -0
- package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +13 -8
- package/lib/generators/pob/PobBaseGenerator.js +14 -1
- package/lib/pob.js +26 -23
- package/lib/utils/package.js +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,66 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [8.10.1](https://github.com/christophehurpeau/pob/compare/pob@8.10.0...pob@8.10.1) (2021-12-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **pob:** only install release workflow if ci is enabled ([8e2fc45](https://github.com/christophehurpeau/pob/commit/8e2fc45ec5435a149b4580b09ae4636e3dbc0fdf))
|
|
12
|
+
* **pob:** start script for apps ([623cfb5](https://github.com/christophehurpeau/pob/commit/623cfb5e5a9af9978b5533962ec7fb3b85035a3b))
|
|
13
|
+
* init new monorepo ([7a212de](https://github.com/christophehurpeau/pob/commit/7a212deb2feb480c19b5243a201f31a7b2ce45c3))
|
|
14
|
+
* monorepo add ([3ae8bfb](https://github.com/christophehurpeau/pob/commit/3ae8bfb487b8a88b62ad8692789ecdddf01ec376))
|
|
15
|
+
* **deps:** update dependency prettier to v2.5.1 ([#1122](https://github.com/christophehurpeau/pob/issues/1122)) ([ba903e3](https://github.com/christophehurpeau/pob/commit/ba903e3c63ff90eab7938d5aecbd9d37fac68293))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# [8.10.0](https://github.com/christophehurpeau/pob/compare/pob@8.9.0...pob@8.10.0) (2021-11-28)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **pob:** also remove react eslint plugins ([77dc9c5](https://github.com/christophehurpeau/pob/commit/77dc9c564bf8d2622956f23973b5258fa97aed2d))
|
|
27
|
+
* **pob:** monorepo typedoc enable tsc skipLibCheck ([87b8e88](https://github.com/christophehurpeau/pob/commit/87b8e88656308cea49994335f1aafcb3eb49121a))
|
|
28
|
+
* **pob:** node options when lots of packages ([4829f93](https://github.com/christophehurpeau/pob/commit/4829f9386504c5de4ccc488544c10cf194b0f0f0))
|
|
29
|
+
* **pob:** remove deprecated dependency xunit-file ([62d4602](https://github.com/christophehurpeau/pob/commit/62d460276709d6a5630ba3759984910d36a506cc))
|
|
30
|
+
* postinstall script for non lerna private packages ([8a3f3a4](https://github.com/christophehurpeau/pob/commit/8a3f3a4143f2595391503d51c31dd9b8157ccc97))
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **deps:** update dependency prettier to v2.5.0 ([#1114](https://github.com/christophehurpeau/pob/issues/1114)) ([50d4b98](https://github.com/christophehurpeau/pob/commit/50d4b98f8ec76ee8a44e3f01eea882089b1a89e5))
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# [8.9.0](https://github.com/christophehurpeau/pob/compare/pob@8.8.2...pob@8.9.0) (2021-11-16)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Bug Fixes
|
|
45
|
+
|
|
46
|
+
* **pob:** fixes for @pob/eslint-config ([e84152c](https://github.com/christophehurpeau/pob/commit/e84152c8e2b2c8421d51c9883426646afad49134))
|
|
47
|
+
* **pob:** startsWith of undefined ([b0ebc73](https://github.com/christophehurpeau/pob/commit/b0ebc73bb74f4a2c98221b917ec8e159fd5a7c22))
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Features
|
|
51
|
+
|
|
52
|
+
* **deps:** update @pob/eslint-config to v47 (major) ([#1101](https://github.com/christophehurpeau/pob/issues/1101)) ([e726bf5](https://github.com/christophehurpeau/pob/commit/e726bf5a5baa8631933a5f69dbd3c48f9bf25ca5))
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## [8.8.2](https://github.com/christophehurpeau/pob/compare/pob@8.8.1...pob@8.8.2) (2021-11-14)
|
|
59
|
+
|
|
60
|
+
**Note:** Version bump only for package pob
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
6
66
|
## [8.8.1](https://github.com/christophehurpeau/pob/compare/pob@8.8.0...pob@8.8.1) (2021-11-14)
|
|
7
67
|
|
|
8
68
|
**Note:** Version bump only for package pob
|
|
@@ -267,10 +267,19 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
267
267
|
|
|
268
268
|
/* scripts */
|
|
269
269
|
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
if (this.options.isApp) {
|
|
271
|
+
packageUtils.removeScripts(['watch']);
|
|
272
|
+
packageUtils.addOrRemoveScripts(pkg, useBabel, {
|
|
273
|
+
build: 'pob-build',
|
|
274
|
+
start: 'pob-watch',
|
|
275
|
+
});
|
|
276
|
+
} else {
|
|
277
|
+
packageUtils.removeScripts(['start']);
|
|
278
|
+
packageUtils.addOrRemoveScripts(pkg, useBabel, {
|
|
279
|
+
build: 'pob-build',
|
|
280
|
+
watch: 'pob-watch',
|
|
281
|
+
});
|
|
282
|
+
}
|
|
274
283
|
|
|
275
284
|
const shouldBuildDefinitions = !this.options.isApp && useBabel;
|
|
276
285
|
packageUtils.addOrRemoveScripts(pkg, shouldBuildDefinitions, {
|
|
@@ -12,6 +12,13 @@ export default class CommonLintGenerator extends Generator {
|
|
|
12
12
|
constructor(args, opts) {
|
|
13
13
|
super(args, opts);
|
|
14
14
|
|
|
15
|
+
this.option('monorepo', {
|
|
16
|
+
type: Boolean,
|
|
17
|
+
required: false,
|
|
18
|
+
defaults: false,
|
|
19
|
+
description: 'Is root monorepo',
|
|
20
|
+
});
|
|
21
|
+
|
|
15
22
|
this.option('babel', {
|
|
16
23
|
type: String,
|
|
17
24
|
required: false,
|
|
@@ -104,7 +111,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
104
111
|
arrowParens: 'always',
|
|
105
112
|
};
|
|
106
113
|
|
|
107
|
-
if (!inLerna || inLerna.root) {
|
|
114
|
+
if (!inLerna || inLerna.root || this.options.monorepo) {
|
|
108
115
|
const ignorePatterns = new Set(
|
|
109
116
|
this.options.ignorePaths.split('\n').filter(Boolean),
|
|
110
117
|
);
|
|
@@ -125,7 +132,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
125
132
|
this.templatePath('prettierignore.ejs'),
|
|
126
133
|
this.destinationPath('.prettierignore'),
|
|
127
134
|
{
|
|
128
|
-
inRoot: !inLerna || inLerna.root,
|
|
135
|
+
inRoot: !inLerna || inLerna.root || this.options.monorepo,
|
|
129
136
|
documentation: this.options.documentation,
|
|
130
137
|
packageManager: this.options.packageManager,
|
|
131
138
|
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
@@ -155,14 +162,16 @@ export default class CommonLintGenerator extends Generator {
|
|
|
155
162
|
'eslint-plugin-babel',
|
|
156
163
|
'eslint-plugin-flowtype',
|
|
157
164
|
'eslint-plugin-prefer-class-properties',
|
|
158
|
-
'eslint-plugin-jsx-a11y',
|
|
159
165
|
'eslint-plugin-prettier',
|
|
166
|
+
'eslint-plugin-react',
|
|
167
|
+
'eslint-plugin-react-hooks',
|
|
160
168
|
'typescript-eslint-parser',
|
|
161
169
|
'standard',
|
|
162
170
|
]);
|
|
163
171
|
|
|
164
172
|
if (!pkg.name.startsWith('@pob/eslint-config')) {
|
|
165
173
|
packageUtils.removeDevDependencies(pkg, [
|
|
174
|
+
'eslint-plugin-jsx-a11y',
|
|
166
175
|
'eslint-config-airbnb',
|
|
167
176
|
'eslint-config-airbnb-base',
|
|
168
177
|
]);
|
|
@@ -179,7 +188,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
179
188
|
|
|
180
189
|
if (
|
|
181
190
|
globalEslint &&
|
|
182
|
-
!(inLerna && inLerna.root) &&
|
|
191
|
+
!((inLerna && inLerna.root) || this.options.monorepo) &&
|
|
183
192
|
(rootPackageManager !== 'yarn' || rootYarnNodeLinker === 'node-modules')
|
|
184
193
|
) {
|
|
185
194
|
packageUtils.removeDevDependencies(
|
|
@@ -203,15 +212,18 @@ export default class CommonLintGenerator extends Generator {
|
|
|
203
212
|
} else {
|
|
204
213
|
packageUtils.addOrRemoveDevDependencies(
|
|
205
214
|
pkg,
|
|
206
|
-
(inLerna && inLerna.root) || !globalEslint,
|
|
215
|
+
(inLerna && inLerna.root) || this.options.monorepo || !globalEslint,
|
|
207
216
|
['prettier'],
|
|
208
217
|
);
|
|
209
218
|
packageUtils.addOrRemoveDevDependencies(
|
|
210
219
|
pkg,
|
|
211
220
|
!globalEslint ||
|
|
212
221
|
(inLerna && inLerna.root) ||
|
|
222
|
+
this.options.monorepo ||
|
|
213
223
|
lernaProjectType === 'app' ||
|
|
214
|
-
rootPackageManager === 'yarn'
|
|
224
|
+
(rootPackageManager === 'yarn' &&
|
|
225
|
+
rootYarnNodeLinker !== 'node-modules') ||
|
|
226
|
+
!!(pkg.peerDependencies && pkg.peerDependencies.eslint),
|
|
215
227
|
['eslint'],
|
|
216
228
|
);
|
|
217
229
|
const shouldHavePluginsDependencies =
|
|
@@ -238,7 +250,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
238
250
|
['eslint-plugin-node', 'eslint-import-resolver-node'],
|
|
239
251
|
);
|
|
240
252
|
|
|
241
|
-
if (inLerna && inLerna.root) {
|
|
253
|
+
if ((inLerna && inLerna.root) || this.options.monorepo) {
|
|
242
254
|
if (this.options.typescript) {
|
|
243
255
|
packageUtils.updateDevDependenciesIfPresent(pkg, [
|
|
244
256
|
'@pob/eslint-config-typescript',
|
|
@@ -407,7 +419,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
407
419
|
console.warn(`Could not parse/edit ${rootEslintrcPath}: `, err);
|
|
408
420
|
}
|
|
409
421
|
|
|
410
|
-
if (inLerna && inLerna.root) {
|
|
422
|
+
if ((inLerna && inLerna.root) || this.options.monorepo) {
|
|
411
423
|
if (this.fs.exists(srcEslintrcPath)) {
|
|
412
424
|
this.fs.delete(srcEslintrcPath);
|
|
413
425
|
}
|
|
@@ -445,7 +457,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
445
457
|
}
|
|
446
458
|
|
|
447
459
|
// see monorepo/lerna/index.js
|
|
448
|
-
if (!(inLerna && inLerna.root)) {
|
|
460
|
+
if (!(inLerna && inLerna.root) && !this.options.monorepo) {
|
|
449
461
|
const srcDirectory = useBabel ? 'src' : 'lib';
|
|
450
462
|
const lintRootJsFiles = (useBabel && useNode) || !inLerna;
|
|
451
463
|
|
|
@@ -37,9 +37,14 @@ const configureProtectionRule = async (owner, repo) => {
|
|
|
37
37
|
allow_deletions: false,
|
|
38
38
|
},
|
|
39
39
|
});
|
|
40
|
+
if (branch === 'master') {
|
|
41
|
+
console.warn('You should rename your "master" branch to "main"');
|
|
42
|
+
}
|
|
40
43
|
} catch (err) {
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
if (branch === 'main') {
|
|
45
|
+
console.error(`Failed to configure ${branch} branch protection`);
|
|
46
|
+
console.error(err.stack || err.message || err);
|
|
47
|
+
}
|
|
43
48
|
}
|
|
44
49
|
}
|
|
45
50
|
};
|
|
@@ -79,14 +84,17 @@ export default class CoreGitGithubGenerator extends Generator {
|
|
|
79
84
|
const repo = this.options.repoName;
|
|
80
85
|
|
|
81
86
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
|
|
87
|
+
const name = pkg.name.endsWith('-monorepo')
|
|
88
|
+
? pkg.name.slice(0, -'-monorepo'.length)
|
|
89
|
+
: pkg.name;
|
|
82
90
|
|
|
83
91
|
if (this.options.shouldCreate) {
|
|
84
92
|
try {
|
|
85
93
|
if (this.options.shouldCreate) {
|
|
86
94
|
try {
|
|
87
|
-
await gh('user/repos', {
|
|
95
|
+
await gh.post('user/repos', {
|
|
88
96
|
json: {
|
|
89
|
-
name
|
|
97
|
+
name,
|
|
90
98
|
description: pkg.description,
|
|
91
99
|
homepage: null,
|
|
92
100
|
private: false,
|
|
@@ -103,13 +111,33 @@ export default class CoreGitGithubGenerator extends Generator {
|
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
const cwd = this.destinationPath();
|
|
106
|
-
|
|
114
|
+
try {
|
|
115
|
+
this.spawnCommandSync('git', ['add', '--all', '.'], { cwd });
|
|
116
|
+
} catch (err) {
|
|
117
|
+
this.spawnCommandSync('git', ['init'], { cwd });
|
|
118
|
+
this.spawnCommandSync('git', ['add', '--all', '.'], { cwd });
|
|
119
|
+
this.spawnCommandSync(
|
|
120
|
+
'git',
|
|
121
|
+
[
|
|
122
|
+
'remote',
|
|
123
|
+
'add',
|
|
124
|
+
'origin',
|
|
125
|
+
`git@github.com:christophehurpeau/${name}.git`,
|
|
126
|
+
],
|
|
127
|
+
{ cwd },
|
|
128
|
+
);
|
|
129
|
+
console.error('Failed to create repository');
|
|
130
|
+
console.error(err.stack || err.message || err);
|
|
131
|
+
}
|
|
107
132
|
this.spawnCommandSync(
|
|
108
133
|
'git',
|
|
109
134
|
['commit', '-m', 'chore: initial commit [skip ci]'],
|
|
110
135
|
{ cwd },
|
|
111
136
|
);
|
|
112
|
-
this.spawnCommandSync('git', ['
|
|
137
|
+
this.spawnCommandSync('git', ['branch', '-M', 'main'], {
|
|
138
|
+
cwd,
|
|
139
|
+
});
|
|
140
|
+
this.spawnCommandSync('git', ['push', '-u', 'origin', 'main'], {
|
|
113
141
|
cwd,
|
|
114
142
|
});
|
|
115
143
|
|
|
@@ -9,6 +9,20 @@ export default class CorePackageGenerator extends Generator {
|
|
|
9
9
|
constructor(args, opts) {
|
|
10
10
|
super(args, opts);
|
|
11
11
|
|
|
12
|
+
this.option('monorepo', {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
required: true,
|
|
15
|
+
defaults: false,
|
|
16
|
+
desc: 'is monorepo',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
this.option('isRoot', {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
required: true,
|
|
22
|
+
defaults: false,
|
|
23
|
+
desc: 'is root',
|
|
24
|
+
});
|
|
25
|
+
|
|
12
26
|
this.option('private', {
|
|
13
27
|
type: Boolean,
|
|
14
28
|
required: false,
|
|
@@ -29,7 +43,9 @@ export default class CorePackageGenerator extends Generator {
|
|
|
29
43
|
}
|
|
30
44
|
|
|
31
45
|
if (!this.options.updateOnly) {
|
|
32
|
-
if (this.options.
|
|
46
|
+
if (this.options.monorepo && this.options.isRoot) {
|
|
47
|
+
pkg.private = true;
|
|
48
|
+
} else if (this.options.private) {
|
|
33
49
|
pkg.private = true;
|
|
34
50
|
} else {
|
|
35
51
|
const { isPrivate } = await this.prompt({
|
|
@@ -46,7 +62,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
46
62
|
}
|
|
47
63
|
}
|
|
48
64
|
|
|
49
|
-
if (
|
|
65
|
+
if (this.options.monorepo && this.options.isRoot) {
|
|
50
66
|
if (!pkg.name) {
|
|
51
67
|
const { name } = await this.prompt({
|
|
52
68
|
name: 'name',
|
|
@@ -77,7 +93,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
77
93
|
const props = await this.prompt(
|
|
78
94
|
[
|
|
79
95
|
!this.options.updateOnly &&
|
|
80
|
-
!(
|
|
96
|
+
!(this.options.monorepo && this.options.isRoot) && {
|
|
81
97
|
name: 'description',
|
|
82
98
|
message: 'Description',
|
|
83
99
|
default: pkg.description,
|
|
@@ -115,7 +131,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
115
131
|
? pkg.description
|
|
116
132
|
: props.description || pkg.description;
|
|
117
133
|
|
|
118
|
-
if (
|
|
134
|
+
if (this.options.monorepo && !this.options.isRoot) {
|
|
119
135
|
const rootMonorepoPkg = inLerna.rootMonorepoPkg;
|
|
120
136
|
const rootRepositoryUrl =
|
|
121
137
|
typeof rootMonorepoPkg.repository === 'string'
|
|
@@ -136,9 +152,9 @@ export default class CorePackageGenerator extends Generator {
|
|
|
136
152
|
fs.unlinkSync(this.destinationPath('yarn-error.log'));
|
|
137
153
|
}
|
|
138
154
|
|
|
139
|
-
if (
|
|
155
|
+
if (this.options.monorepo && !this.options.isRoot) {
|
|
140
156
|
packageUtils.removeScripts(pkg, ['checks']);
|
|
141
|
-
} else if (
|
|
157
|
+
} else if (this.options.monorepo && this.options.isRoot) {
|
|
142
158
|
const doesMjsCheckPackagesExists = this.fs.exists(
|
|
143
159
|
this.destinationPath('scripts/check-packages.mjs'),
|
|
144
160
|
);
|
|
@@ -206,6 +222,7 @@ export default class CorePackageGenerator extends Generator {
|
|
|
206
222
|
|
|
207
223
|
writing() {
|
|
208
224
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
|
|
225
|
+
if (!pkg.scripts) pkg.scripts = {};
|
|
209
226
|
|
|
210
227
|
const installPostinstallScript = (scriptName) => {
|
|
211
228
|
if (
|
|
@@ -217,12 +234,12 @@ export default class CorePackageGenerator extends Generator {
|
|
|
217
234
|
};
|
|
218
235
|
|
|
219
236
|
const uninstallPostinstallScript = (scriptName) => {
|
|
220
|
-
if (pkg.scripts[scriptName]) {
|
|
237
|
+
if (pkg.scripts && pkg.scripts[scriptName]) {
|
|
221
238
|
if (pkg.scripts[scriptName] === 'pob-root-postinstall') {
|
|
222
239
|
delete pkg.scripts[scriptName];
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
240
|
+
} else if (
|
|
241
|
+
pkg.scripts[scriptName].startsWith('pob-root-postinstall && ')
|
|
242
|
+
) {
|
|
226
243
|
pkg.scripts[scriptName] = pkg.scripts[scriptName].slice(
|
|
227
244
|
'pob-root-postinstall && '.length - 1,
|
|
228
245
|
);
|
|
@@ -231,10 +248,9 @@ export default class CorePackageGenerator extends Generator {
|
|
|
231
248
|
}
|
|
232
249
|
}
|
|
233
250
|
};
|
|
234
|
-
|
|
235
|
-
if (inLerna || pkg.private) {
|
|
251
|
+
if (this.options.monorepo || pkg.private) {
|
|
236
252
|
uninstallPostinstallScript('postinstallDev');
|
|
237
|
-
if (
|
|
253
|
+
if (this.options.isRoot) {
|
|
238
254
|
installPostinstallScript('postinstall');
|
|
239
255
|
} else {
|
|
240
256
|
uninstallPostinstallScript('postinstall');
|
|
@@ -273,7 +273,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
273
273
|
});
|
|
274
274
|
|
|
275
275
|
this.composeWith('pob:lib:release', {
|
|
276
|
-
enable: !inLerna,
|
|
276
|
+
enable: !inLerna && this.pobjson.testing && this.pobjson.testing.ci,
|
|
277
277
|
withBabel: babelEnvs.length > 0,
|
|
278
278
|
documentation: !!this.pobjson.documentation,
|
|
279
279
|
});
|
|
@@ -207,6 +207,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
207
207
|
this.composeWith('pob:common:husky', {});
|
|
208
208
|
|
|
209
209
|
this.composeWith('pob:common:format-lint', {
|
|
210
|
+
monorepo: true,
|
|
210
211
|
documentation: this.pobLernaConfig.documentation,
|
|
211
212
|
typescript: this.pobLernaConfig.typescript,
|
|
212
213
|
testing: this.pobLernaConfig.testing,
|
|
@@ -93,7 +93,7 @@ export default class MonorepoLernaGenerator extends Generator {
|
|
|
93
93
|
|
|
94
94
|
const getPackagePobConfig = (config) => ({
|
|
95
95
|
babelEnvs: [],
|
|
96
|
-
...(
|
|
96
|
+
...(config && config.pob),
|
|
97
97
|
});
|
|
98
98
|
const withBabel = this.packages.some(
|
|
99
99
|
(config) => getPackagePobConfig(config).babelEnvs.length > 0,
|
|
@@ -153,10 +153,9 @@ export default class MonorepoLernaGenerator extends Generator {
|
|
|
153
153
|
packageUtils.removeDevDependencies(pkg, ['standard-version']);
|
|
154
154
|
|
|
155
155
|
const getPobConfig = (config) => ({
|
|
156
|
-
...(
|
|
156
|
+
...(config &&
|
|
157
157
|
config.pob &&
|
|
158
|
-
(config.pob['pob-config'] || config.pob.lib || config.pob.app))
|
|
159
|
-
{}),
|
|
158
|
+
(config.pob['pob-config'] || config.pob.lib || config.pob.app)),
|
|
160
159
|
});
|
|
161
160
|
// ynnub doesnt use babel but still have typescript
|
|
162
161
|
// const withTypescript = this.packagePaths.some((packagePath) =>
|
|
@@ -177,12 +176,18 @@ export default class MonorepoLernaGenerator extends Generator {
|
|
|
177
176
|
'lint:eslint':
|
|
178
177
|
monorepoConfig &&
|
|
179
178
|
monorepoConfig.eslint &&
|
|
180
|
-
this.packagesConfig.length <
|
|
181
|
-
?
|
|
179
|
+
this.packagesConfig.length < 50
|
|
180
|
+
? `${
|
|
181
|
+
this.packagesConfig.length > 20
|
|
182
|
+
? 'NODE_OPTIONS=--max_old_space_size=4096 '
|
|
183
|
+
: ''
|
|
184
|
+
}eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet .`
|
|
182
185
|
: // eslint-disable-next-line unicorn/no-nested-ternary
|
|
183
186
|
this.options.packageManager === 'yarn'
|
|
184
|
-
?
|
|
185
|
-
|
|
187
|
+
? `NODE_OPTIONS=--max_old_space_size=4096 eslint --report-unused-disable-directives --resolve-plugins-relative-to . --quiet . --ignore-pattern ${pkg.workspaces.join(
|
|
188
|
+
',',
|
|
189
|
+
)} && yarn workspaces foreach --parallel -Av run lint:eslint`
|
|
190
|
+
: 'lerna run --stream lint:eslint',
|
|
186
191
|
});
|
|
187
192
|
|
|
188
193
|
this.fs.copyTpl(
|
|
@@ -7,12 +7,19 @@ export default class PobBaseGenerator extends Generator {
|
|
|
7
7
|
constructor(args, opts) {
|
|
8
8
|
super(args, opts, { customInstallTask: true });
|
|
9
9
|
|
|
10
|
+
/** @deprecated use monorepo option instead */
|
|
10
11
|
this.option('lerna', {
|
|
11
12
|
type: Boolean,
|
|
12
13
|
required: false,
|
|
13
14
|
desc: 'Lerna monorepo',
|
|
14
15
|
});
|
|
15
16
|
|
|
17
|
+
this.option('monorepo', {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
required: false,
|
|
20
|
+
desc: 'monorepo',
|
|
21
|
+
});
|
|
22
|
+
|
|
16
23
|
this.option('type', {
|
|
17
24
|
type: String,
|
|
18
25
|
required: true,
|
|
@@ -53,7 +60,7 @@ export default class PobBaseGenerator extends Generator {
|
|
|
53
60
|
// prettier package.json to ensure diff is correct
|
|
54
61
|
ensureJsonFileFormatted(this.destinationPath('package.json'));
|
|
55
62
|
|
|
56
|
-
if (this.options.lerna) {
|
|
63
|
+
if (this.options.monorepo || this.options.lerna) {
|
|
57
64
|
this.useLerna = true;
|
|
58
65
|
this.inLerna = false;
|
|
59
66
|
this.isRoot = true;
|
|
@@ -123,6 +130,8 @@ export default class PobBaseGenerator extends Generator {
|
|
|
123
130
|
this.composeWith('pob:core:package', {
|
|
124
131
|
updateOnly: this.options.updateOnly,
|
|
125
132
|
private: this.useLerna,
|
|
133
|
+
monorepo: this.useLerna,
|
|
134
|
+
isRoot: this.isRoot,
|
|
126
135
|
});
|
|
127
136
|
|
|
128
137
|
if (this.useLerna) {
|
|
@@ -207,6 +216,8 @@ export default class PobBaseGenerator extends Generator {
|
|
|
207
216
|
switch (this.projectConfig.type) {
|
|
208
217
|
case 'lib':
|
|
209
218
|
this.composeWith('pob:lib', {
|
|
219
|
+
monorepo: this.useLerna,
|
|
220
|
+
isRoot: this.isRoot,
|
|
210
221
|
updateOnly: this.options.updateOnly,
|
|
211
222
|
fromPob: this.options.fromPob,
|
|
212
223
|
packageManager: this.projectConfig.packageManager,
|
|
@@ -215,6 +226,8 @@ export default class PobBaseGenerator extends Generator {
|
|
|
215
226
|
break;
|
|
216
227
|
case 'app':
|
|
217
228
|
this.composeWith('pob:app', {
|
|
229
|
+
monorepo: this.useLerna,
|
|
230
|
+
isRoot: this.isRoot,
|
|
218
231
|
updateOnly: this.options.updateOnly,
|
|
219
232
|
fromPob: this.options.fromPob,
|
|
220
233
|
packageManager: this.projectConfig.packageManager,
|
package/lib/pob.js
CHANGED
|
@@ -37,9 +37,9 @@ import PobBaseGenerator from './generators/pob/PobBaseGenerator.js';
|
|
|
37
37
|
import { __dirname } from './pob-dirname.cjs';
|
|
38
38
|
|
|
39
39
|
const printUsage = () => {
|
|
40
|
-
console.error('Usage: pob [
|
|
41
|
-
console.error(' pob [
|
|
42
|
-
console.error(' pob
|
|
40
|
+
console.error('Usage: pob [monorepo] [lib|app|init]');
|
|
41
|
+
console.error(' pob [monorepo] update [--force]');
|
|
42
|
+
console.error(' pob monorepo convert-npm');
|
|
43
43
|
console.error(' pob add <packageName>');
|
|
44
44
|
};
|
|
45
45
|
|
|
@@ -209,32 +209,27 @@ env.registerStub(
|
|
|
209
209
|
`${__dirname}/generators/monorepo/typescript/MonorepoTypescriptGenerator.js`,
|
|
210
210
|
);
|
|
211
211
|
|
|
212
|
-
let
|
|
213
|
-
const action =
|
|
212
|
+
let monorepo = argv._[0] === 'lerna' || argv._[0] === 'monorepo';
|
|
213
|
+
const action = monorepo ? argv._[1] : argv._[0];
|
|
214
214
|
const projectPkg = readJson(path.resolve('./package.json'));
|
|
215
215
|
|
|
216
216
|
if (action === 'add') {
|
|
217
|
-
if (!
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
if (!projectPkg.workspaces) {
|
|
218
|
+
throw new Error(
|
|
219
|
+
'Missing workspaces field in package.json: not a lerna repo',
|
|
220
|
+
);
|
|
220
221
|
}
|
|
221
222
|
|
|
222
|
-
const packageName = argv._[1];
|
|
223
|
+
const packageName = monorepo ? argv._[2] : argv._[1];
|
|
223
224
|
|
|
224
225
|
if (!packageName) {
|
|
225
226
|
console.error('Missing argument: packageName');
|
|
226
227
|
printUsage();
|
|
227
228
|
process.exit(1);
|
|
228
229
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
throw new Error(
|
|
233
|
-
'Missing workspaces field in package.json: not a lerna repo',
|
|
234
|
-
);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
const packagesPath = pkg.workspaces[0].replace(/\/\*$/, '');
|
|
230
|
+
const packagesPath = packageName.startsWith('@')
|
|
231
|
+
? packageName
|
|
232
|
+
: projectPkg.workspaces[0].replace(/\/\*$/, '');
|
|
238
233
|
|
|
239
234
|
fs.mkdirSync(`${packagesPath}/${packageName}`, { recursive: true });
|
|
240
235
|
writeFileSync(`${packagesPath}/${packageName}/.yo-rc.json`, '{}');
|
|
@@ -242,14 +237,20 @@ if (action === 'add') {
|
|
|
242
237
|
`${packagesPath}/${packageName}/package.json`,
|
|
243
238
|
JSON.stringify({ name: packageName, version: '1.0.0-pre' }, null, 2),
|
|
244
239
|
);
|
|
245
|
-
|
|
240
|
+
console.log('> Creating new Package');
|
|
241
|
+
spawnSync(process.argv[0], [process.argv[1]], {
|
|
246
242
|
cwd: `${packagesPath}/${packageName}`,
|
|
247
243
|
stdio: 'inherit',
|
|
248
244
|
});
|
|
245
|
+
|
|
246
|
+
console.log('> Updating monorepo');
|
|
247
|
+
spawnSync(process.argv[0], [process.argv[1], 'update'], {
|
|
248
|
+
stdio: 'inherit',
|
|
249
|
+
});
|
|
249
250
|
process.exit(0);
|
|
250
251
|
}
|
|
251
252
|
|
|
252
|
-
if (
|
|
253
|
+
if (monorepo && action === 'convert-npm') {
|
|
253
254
|
execSync('sed -i \'/"npmClient": "yarn",/d\' ./lerna.json', {
|
|
254
255
|
stdio: 'inherit',
|
|
255
256
|
});
|
|
@@ -260,7 +261,8 @@ if (lerna && action === 'convert-npm') {
|
|
|
260
261
|
}
|
|
261
262
|
|
|
262
263
|
const updateOnly = action === 'update';
|
|
263
|
-
const
|
|
264
|
+
const init = action === 'init';
|
|
265
|
+
const type = updateOnly || init ? null : action;
|
|
264
266
|
const fromPob = updateOnly && argv._[1] === 'from-pob';
|
|
265
267
|
|
|
266
268
|
if (!existsSync('.yo-rc.json')) {
|
|
@@ -272,13 +274,14 @@ if (!existsSync('.yo-rc.json')) {
|
|
|
272
274
|
}
|
|
273
275
|
|
|
274
276
|
if (existsSync('lerna.json') || (projectPkg && projectPkg.lerna)) {
|
|
275
|
-
|
|
277
|
+
monorepo = true;
|
|
276
278
|
}
|
|
277
279
|
|
|
278
280
|
const options = {
|
|
279
281
|
type,
|
|
282
|
+
init,
|
|
280
283
|
updateOnly,
|
|
281
|
-
|
|
284
|
+
monorepo,
|
|
282
285
|
fromPob,
|
|
283
286
|
force: argv.force,
|
|
284
287
|
};
|
package/lib/utils/package.js
CHANGED
|
@@ -4,7 +4,7 @@ import parseAuthor from 'parse-author';
|
|
|
4
4
|
import pobDependencies from 'pob-dependencies';
|
|
5
5
|
import semver from 'semver';
|
|
6
6
|
|
|
7
|
-
export { parseAuthor };
|
|
7
|
+
export { default as parseAuthor } from 'parse-author';
|
|
8
8
|
|
|
9
9
|
export const parsePkgAuthor = (pkg) =>
|
|
10
10
|
typeof pkg.author === 'string' ? parseAuthor(pkg.author) : pkg.author;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pob",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.10.1",
|
|
4
4
|
"description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"skeleton"
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
"mem-fs-editor": "8.1.2",
|
|
64
64
|
"minimist-argv": "^1.1.0",
|
|
65
65
|
"parse-author": "^2.0.0",
|
|
66
|
-
"pob-dependencies": "^5.
|
|
67
|
-
"prettier": "2.
|
|
66
|
+
"pob-dependencies": "^5.12.0",
|
|
67
|
+
"prettier": "2.5.1",
|
|
68
68
|
"semver": "^7.3.4",
|
|
69
69
|
"update-notifier": "^5.0.1",
|
|
70
70
|
"yeoman-environment": "^3.5.1",
|
|
71
71
|
"yeoman-generator": "^5.4.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "22fce6512461fa2282baf86a31d090002abca7ac"
|
|
74
74
|
}
|