pob 18.2.0 → 18.4.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 +63 -0
- package/lib/generators/app/PobAppGenerator.js +9 -4
- package/lib/generators/app/ignorePaths.js +2 -1
- package/lib/generators/common/babel/CommonBabelGenerator.js +0 -8
- package/lib/generators/common/format-lint/CommonLintGenerator.js +10 -7
- package/lib/generators/common/format-lint/templates/prettierignore.ejs +1 -1
- package/lib/generators/common/format-lint/updateEslintConfig.js +1 -1
- package/lib/generators/common/testing/CommonTestingGenerator.js +143 -33
- package/lib/generators/common/transpiler/CommonTranspilerGenerator.js +92 -29
- package/lib/generators/common/transpiler/templates/app.rollup.config.mjs.ejs +2 -2
- package/lib/generators/common/transpiler/templates/lib.rollup.config.mjs.ejs +1 -1
- package/lib/generators/common/typescript/CommonTypescriptGenerator.js +7 -3
- package/lib/generators/core/ci/templates/github-action-documentation-workflow.yml.ejs +1 -1
- package/lib/generators/core/gitignore/templates/gitignore.ejs +0 -4
- package/lib/generators/core/npm/CoreNpmGenerator.js +7 -0
- package/lib/generators/core/package/CorePackageGenerator.js +10 -0
- package/lib/generators/core/vscode/CoreVSCodeGenerator.js +7 -0
- package/lib/generators/core/vscode/templates/settings.json.ejs +1 -1
- package/lib/generators/lib/PobLibGenerator.js +2 -0
- package/lib/generators/monorepo/PobMonorepoGenerator.js +1 -0
- package/lib/generators/monorepo/workspaces/MonorepoWorkspacesGenerator.js +2 -0
- package/lib/generators/pob/PobBaseGenerator.js +10 -1
- package/lib/pob.js +2 -0
- package/lib/utils/package.js +2 -2
- package/package.json +18 -18
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,69 @@
|
|
|
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
|
+
## [18.4.0](https://github.com/christophehurpeau/pob/compare/pob@18.3.0...pob@18.4.0) (2024-04-21)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add app untranspiled-library ([c702f3e](https://github.com/christophehurpeau/pob/commit/c702f3e8170809b8c7b9ac5fe6cad4f6f7e70779))
|
|
12
|
+
* add rollup-esbuild ([a1085db](https://github.com/christophehurpeau/pob/commit/a1085dbe6ea69767596dd46813044b96fbf713dd))
|
|
13
|
+
* add swc support and improve jest without babel ([e7b050d](https://github.com/christophehurpeau/pob/commit/e7b050d3b7ac5ab2ec68d98095bb9832fdbc88bb))
|
|
14
|
+
* add vitest support ([db3344c](https://github.com/christophehurpeau/pob/commit/db3344c45197f4b1bdfaa78df7dff25b37d291e2))
|
|
15
|
+
* better support next and add example ([a60ce83](https://github.com/christophehurpeau/pob/commit/a60ce83d8277efb0eef65c5b3372ff89570919fb))
|
|
16
|
+
* **deps:** update @pob/eslint-config to v55 (major) ([#2020](https://github.com/christophehurpeau/pob/issues/2020)) ([434d5b3](https://github.com/christophehurpeau/pob/commit/434d5b3dce53b1925091138444881a13e2a962d9))
|
|
17
|
+
* **deps:** update @pob/eslint-config to v55.2.1 ([#2021](https://github.com/christophehurpeau/pob/issues/2021)) ([cdfe421](https://github.com/christophehurpeau/pob/commit/cdfe42126842ac1cb46d233ca7203fd241863a81))
|
|
18
|
+
* **deps:** update dependency @yeoman/types to v1.2.0 ([#1962](https://github.com/christophehurpeau/pob/issues/1962)) ([3566bfd](https://github.com/christophehurpeau/pob/commit/3566bfdbc71ee07662d4b10ec76887c5407118e7))
|
|
19
|
+
* **deps:** update dependency eslint to v8.57.0 ([#1942](https://github.com/christophehurpeau/pob/issues/1942)) ([69753af](https://github.com/christophehurpeau/pob/commit/69753aff1bea9e5801bd4deaa22d6d4eefba8e62))
|
|
20
|
+
* **deps:** update dependency mem-fs to v4.1.0 ([#1945](https://github.com/christophehurpeau/pob/issues/1945)) ([c5c31cf](https://github.com/christophehurpeau/pob/commit/c5c31cfdf15018fbdfa9a4511d86fd6a9d72f277))
|
|
21
|
+
* **deps:** update dependency yeoman-environment to v4.4.0 ([#1963](https://github.com/christophehurpeau/pob/issues/1963)) ([1a7dbb8](https://github.com/christophehurpeau/pob/commit/1a7dbb8fde589f3ad9e6e870cc767b9821832170))
|
|
22
|
+
* **pob:** add tslib ([fb4ead7](https://github.com/christophehurpeau/pob/commit/fb4ead72f5ae31ae894b4f7e9f65fdc05c5e6be0))
|
|
23
|
+
* simple esbuild bundler ([80659fa](https://github.com/christophehurpeau/pob/commit/80659fadb42190463585ff54e865af09e31fdc0d))
|
|
24
|
+
* update peaceiris/actions-gh-pages to v4 ([a67c672](https://github.com/christophehurpeau/pob/commit/a67c672c539c2662650e7b1c00bbc95a4c53fca3))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### Bug Fixes
|
|
28
|
+
|
|
29
|
+
* **deps:** update @pob/eslint-config to v54.0.1 ([#1943](https://github.com/christophehurpeau/pob/issues/1943)) ([309437f](https://github.com/christophehurpeau/pob/commit/309437f195bfdfc9a6c00eec039fd74cba0a6ef8))
|
|
30
|
+
* **deps:** update @pob/eslint-config to v54.0.2 ([#2000](https://github.com/christophehurpeau/pob/issues/2000)) ([04366c3](https://github.com/christophehurpeau/pob/commit/04366c3fe1917595a4b52369837ba31868e84164))
|
|
31
|
+
* **deps:** update yarn monorepo to v4.1.1 ([#1955](https://github.com/christophehurpeau/pob/issues/1955)) ([872ccc1](https://github.com/christophehurpeau/pob/commit/872ccc1c51462a42edbce7b50c6d44dbf625647b))
|
|
32
|
+
* few fixes for monorepo migrate ([a36ab40](https://github.com/christophehurpeau/pob/commit/a36ab408456ced31d8512a1b30391273dffcbe73))
|
|
33
|
+
* fix previous commit ([cd870dc](https://github.com/christophehurpeau/pob/commit/cd870dccce1e4d80ed38e854915407084e8b0001))
|
|
34
|
+
* missing dependency alp-rollup-plugin-config ([9cdc4e4](https://github.com/christophehurpeau/pob/commit/9cdc4e40fb7fa9ee2140618da5eef978de0f5f31))
|
|
35
|
+
* **pob:** fix lint src directory with typescript and no babel ([b7d32a4](https://github.com/christophehurpeau/pob/commit/b7d32a4753ecf20742c8c4158f50f96e5d225e6d))
|
|
36
|
+
* properly determine node only with typescript and no babel ([3a8d958](https://github.com/christophehurpeau/pob/commit/3a8d9584ecb9c6810e577891f4c040b338364c10))
|
|
37
|
+
* tslib prefix ([b86d5e4](https://github.com/christophehurpeau/pob/commit/b86d5e47912fb16d0f58157d228772af43f00e80))
|
|
38
|
+
|
|
39
|
+
Version bump for dependency: sort-eslint-config
|
|
40
|
+
Version bump for dependency: sort-object
|
|
41
|
+
Version bump for dependency: sort-pkg
|
|
42
|
+
Version bump for dependency: yarn-workspace-utils
|
|
43
|
+
Version bump for dependency: root
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
## [18.3.0](https://github.com/christophehurpeau/pob/compare/pob@18.2.0...pob@18.3.0) (2024-02-17)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
### Features
|
|
50
|
+
|
|
51
|
+
* add directory in extraEntries for usage in files ([17839e6](https://github.com/christophehurpeau/pob/commit/17839e65d6a4f5c50e8f7e4e9da635fc3e0b7382))
|
|
52
|
+
* custom test folder ([f3214b9](https://github.com/christophehurpeau/pob/commit/f3214b9554dd2ce057786dad762a9eef07a25c41))
|
|
53
|
+
* **deps:** update dependency semver to v7.6.0 ([#1930](https://github.com/christophehurpeau/pob/issues/1930)) ([dfc8761](https://github.com/christophehurpeau/pob/commit/dfc8761b8123fbb5a9bdf25ba296a20043e25aae))
|
|
54
|
+
* **deps:** update dependency yeoman-environment to v4.2.1 ([#1901](https://github.com/christophehurpeau/pob/issues/1901)) ([e8bb372](https://github.com/christophehurpeau/pob/commit/e8bb372cd141cedc2736913b84e861768636f26e))
|
|
55
|
+
* **deps:** update dependency yeoman-environment to v4.3.0 ([#1917](https://github.com/christophehurpeau/pob/issues/1917)) ([453fdd9](https://github.com/christophehurpeau/pob/commit/453fdd96725e740306c9341595f1b9e1af15f3fc))
|
|
56
|
+
* **deps:** update yarn monorepo ([#1918](https://github.com/christophehurpeau/pob/issues/1918)) ([288ed84](https://github.com/christophehurpeau/pob/commit/288ed84945daa7813dcfb692ee459676a119b9bf))
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### Bug Fixes
|
|
60
|
+
|
|
61
|
+
* fix export when omitVersionInFileName is set ([501367f](https://github.com/christophehurpeau/pob/commit/501367f0072f9ac41ace22312c0576afd7b1645a))
|
|
62
|
+
* fix jest enabled condition ([c10f8b1](https://github.com/christophehurpeau/pob/commit/c10f8b19139d41ef1565a5e7314dbdee5d67cdba))
|
|
63
|
+
* fix srcDirectory for app library ([7df6ba1](https://github.com/christophehurpeau/pob/commit/7df6ba14228326ee9b00b3fa2ec7af1204398860))
|
|
64
|
+
|
|
65
|
+
Version bump for dependency: yarn-workspace-utils
|
|
66
|
+
Version bump for dependency: root
|
|
67
|
+
|
|
68
|
+
|
|
6
69
|
## [18.2.0](https://github.com/christophehurpeau/pob/compare/pob@18.1.1...pob@18.2.0) (2023-12-31)
|
|
7
70
|
|
|
8
71
|
|
|
@@ -88,6 +88,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
88
88
|
'remix',
|
|
89
89
|
'node',
|
|
90
90
|
'node-library', // monorepo library for app. Not a real library
|
|
91
|
+
'untranspiled-library', // monorepo library for app. Not a real library
|
|
91
92
|
'alp-node',
|
|
92
93
|
'expo',
|
|
93
94
|
'other',
|
|
@@ -130,7 +131,9 @@ export default class PobAppGenerator extends Generator {
|
|
|
130
131
|
default() {
|
|
131
132
|
const srcDirectory =
|
|
132
133
|
this.appConfig.type === 'yarn-plugin' ? 'sources' : 'src';
|
|
133
|
-
const isAppLibrary =
|
|
134
|
+
const isAppLibrary =
|
|
135
|
+
this.appConfig.type === 'node-library' ||
|
|
136
|
+
this.appConfig.type === 'untranspiled-library';
|
|
134
137
|
|
|
135
138
|
if (
|
|
136
139
|
this.appConfig.type === 'node' ||
|
|
@@ -228,9 +231,9 @@ export default class PobAppGenerator extends Generator {
|
|
|
228
231
|
return '';
|
|
229
232
|
})(),
|
|
230
233
|
additionalIncludes: (() => {
|
|
231
|
-
if (this.appConfig.type === 'next.js') {
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
+
// if (this.appConfig.type === 'next.js') {
|
|
235
|
+
// return '.next/types/**/*.ts';
|
|
236
|
+
// }
|
|
234
237
|
return '';
|
|
235
238
|
})(),
|
|
236
239
|
});
|
|
@@ -308,6 +311,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
308
311
|
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
309
312
|
typescript,
|
|
310
313
|
testing: this.appConfig.testing,
|
|
314
|
+
testRunner: this.appConfig.testRunner,
|
|
311
315
|
});
|
|
312
316
|
|
|
313
317
|
// only for gitignore
|
|
@@ -335,6 +339,7 @@ export default class PobAppGenerator extends Generator {
|
|
|
335
339
|
case 'remix':
|
|
336
340
|
this.composeWith('pob:app:remix', {});
|
|
337
341
|
break;
|
|
342
|
+
// no default
|
|
338
343
|
}
|
|
339
344
|
|
|
340
345
|
if (platform !== 'win32') {
|
|
@@ -14,6 +14,7 @@ export const appIgnorePaths = {
|
|
|
14
14
|
pobpack: (config) => ['/build', '/public'],
|
|
15
15
|
node: (config) => ['/build'],
|
|
16
16
|
'node-library': (config) => ['/build'],
|
|
17
|
+
'untranspiled-library': (config) => [],
|
|
17
18
|
'alp-node': (config) => ['/build'],
|
|
18
19
|
other: (config) => [],
|
|
19
20
|
expo: (config) => [
|
|
@@ -27,7 +28,7 @@ export const appIgnorePaths = {
|
|
|
27
28
|
'/web-build/',
|
|
28
29
|
|
|
29
30
|
'# Temporary files created by Metro to check the health of the file watcher',
|
|
30
|
-
'
|
|
31
|
+
'/.metro-health-check*',
|
|
31
32
|
],
|
|
32
33
|
'yarn-plugin': (config) => [],
|
|
33
34
|
};
|
|
@@ -457,14 +457,6 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
457
457
|
|
|
458
458
|
packageUtils.removeDevDependencies(pkg, ['@rollup/plugin-run']);
|
|
459
459
|
packageUtils.removeDependencies(pkg, ['alp-rollup-plugin-config']);
|
|
460
|
-
packageUtils.addOrRemoveDevDependencies(
|
|
461
|
-
pkg,
|
|
462
|
-
useBabel &&
|
|
463
|
-
this.options.isApp &&
|
|
464
|
-
!this.options.isAppLibrary &&
|
|
465
|
-
this.options.useAppConfig,
|
|
466
|
-
['alp-rollup-plugin-config'],
|
|
467
|
-
);
|
|
468
460
|
|
|
469
461
|
this.fs.delete('rollup.config.js');
|
|
470
462
|
if (useBabel) {
|
|
@@ -133,12 +133,14 @@ export default class CommonLintGenerator extends Generator {
|
|
|
133
133
|
const useNodeOnly =
|
|
134
134
|
(!useBabel && !useTypescript) ||
|
|
135
135
|
(useTypescript &&
|
|
136
|
-
pkg.pob?.envs
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
(entry
|
|
141
|
-
|
|
136
|
+
(!pkg.pob?.envs ||
|
|
137
|
+
pkg.pob?.envs?.every((env) => env.target === 'node')) &&
|
|
138
|
+
(!pkg.pob?.entries ||
|
|
139
|
+
pkg.pob?.entries.every(
|
|
140
|
+
(entry) =>
|
|
141
|
+
typeof entry === 'string' ||
|
|
142
|
+
(entry.target && entry.target !== 'node'),
|
|
143
|
+
))) ||
|
|
142
144
|
(babelEnvs.length > 0 && babelEnvs.every((env) => env.target === 'node'));
|
|
143
145
|
|
|
144
146
|
if (this.fs.exists(this.destinationPath('.eslintignore'))) {
|
|
@@ -564,7 +566,8 @@ export default class CommonLintGenerator extends Generator {
|
|
|
564
566
|
|
|
565
567
|
// see monorepo/lerna/index.js
|
|
566
568
|
if (!(inMonorepo && inMonorepo.root) && !this.options.monorepo) {
|
|
567
|
-
const srcDirectory =
|
|
569
|
+
const srcDirectory =
|
|
570
|
+
useBabel || this.options.typescript ? this.options.srcDirectory : 'lib';
|
|
568
571
|
const lintRootJsFiles = (useBabel && useNode) || !inMonorepo;
|
|
569
572
|
|
|
570
573
|
const lintPaths = [srcDirectory, 'bin', 'scripts', 'migrations'].filter(
|
|
@@ -15,7 +15,7 @@ CHANGELOG.md
|
|
|
15
15
|
<% for (let workspace of workspaces) { -%>
|
|
16
16
|
<% if (ignorePatterns) { -%>
|
|
17
17
|
<% for (let ignorePattern of ignorePatterns) { -%>
|
|
18
|
-
<%= '/' + workspace + ignorePattern %>
|
|
18
|
+
<%= ignorePattern.startsWith('*') ? ignorePattern : '/' + workspace + ignorePattern %>
|
|
19
19
|
<% } -%>
|
|
20
20
|
<% } -%>
|
|
21
21
|
<% } -%>
|
|
@@ -132,7 +132,7 @@ export default function updateEslintConfig(
|
|
|
132
132
|
config.root = true;
|
|
133
133
|
config.extends = [
|
|
134
134
|
...extendsConfig,
|
|
135
|
-
...(config?.extends
|
|
135
|
+
...(config?.extends && Array.isArray(config.extends)
|
|
136
136
|
? config.extends.filter(
|
|
137
137
|
(extendsValue) =>
|
|
138
138
|
extendsValue === '@pob/eslint-config-typescript/allow-unsafe',
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import Generator from 'yeoman-generator';
|
|
3
4
|
import inMonorepo from '../../../utils/inMonorepo.js';
|
|
@@ -113,6 +114,13 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
113
114
|
default: false,
|
|
114
115
|
desc: 'Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.',
|
|
115
116
|
});
|
|
117
|
+
|
|
118
|
+
this.option('swc', {
|
|
119
|
+
type: Boolean,
|
|
120
|
+
required: false,
|
|
121
|
+
default: false,
|
|
122
|
+
desc: 'Use swc to transpile code.',
|
|
123
|
+
});
|
|
116
124
|
}
|
|
117
125
|
|
|
118
126
|
default() {
|
|
@@ -154,7 +162,8 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
154
162
|
'pob-lcov-reporter',
|
|
155
163
|
]);
|
|
156
164
|
|
|
157
|
-
const yoConfigPobMonorepo =
|
|
165
|
+
const yoConfigPobMonorepo =
|
|
166
|
+
(inMonorepo && inMonorepo.pobMonorepoConfig) || {};
|
|
158
167
|
const globalTesting = yoConfigPobMonorepo && yoConfigPobMonorepo.testing;
|
|
159
168
|
const enableForMonorepo = this.options.monorepo && globalTesting;
|
|
160
169
|
const transpileWithEsbuild = packageUtils.transpileWithEsbuild(pkg);
|
|
@@ -176,14 +185,62 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
176
185
|
|
|
177
186
|
const isJestRunner = testRunner === 'jest';
|
|
178
187
|
|
|
179
|
-
const tsTestUtil =
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
[
|
|
188
|
+
const tsTestUtil = (() => {
|
|
189
|
+
if (testRunner === 'vitest') return undefined;
|
|
190
|
+
if (this.options.swc || isJestRunner) return 'swc';
|
|
191
|
+
return 'ts-node';
|
|
192
|
+
})();
|
|
193
|
+
|
|
194
|
+
const dependenciesForTestUtil = {
|
|
195
|
+
'ts-node': { devDependenciesShared: ['ts-node'] },
|
|
196
|
+
swc: {
|
|
197
|
+
devDependenciesShared: ['@swc/core'],
|
|
198
|
+
devDependenciesWithJest: ['@swc/jest'],
|
|
199
|
+
devDependenciesWithNode: ['@swc-node/register'],
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
Object.entries(dependenciesForTestUtil).forEach(
|
|
204
|
+
([
|
|
205
|
+
key,
|
|
206
|
+
{
|
|
207
|
+
devDependenciesShared,
|
|
208
|
+
devDependenciesWithJest,
|
|
209
|
+
devDependenciesWithNode,
|
|
210
|
+
},
|
|
211
|
+
]) => {
|
|
212
|
+
const sharedCondition =
|
|
213
|
+
this.options.enable &&
|
|
214
|
+
(!inMonorepo || inMonorepo.root) &&
|
|
215
|
+
this.options.typescript &&
|
|
216
|
+
key === tsTestUtil;
|
|
217
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
218
|
+
pkg,
|
|
219
|
+
sharedCondition &&
|
|
220
|
+
(testRunner === 'node' || (withTypescript && !transpileWithBabel)),
|
|
221
|
+
devDependenciesShared,
|
|
222
|
+
);
|
|
223
|
+
if (devDependenciesWithJest) {
|
|
224
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
225
|
+
pkg,
|
|
226
|
+
sharedCondition &&
|
|
227
|
+
withTypescript &&
|
|
228
|
+
!transpileWithBabel &&
|
|
229
|
+
testRunner === 'jest',
|
|
230
|
+
devDependenciesWithJest,
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
if (devDependenciesWithNode) {
|
|
234
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
235
|
+
pkg,
|
|
236
|
+
sharedCondition &&
|
|
237
|
+
withTypescript &&
|
|
238
|
+
!transpileWithBabel &&
|
|
239
|
+
testRunner === 'node',
|
|
240
|
+
devDependenciesWithNode,
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
},
|
|
187
244
|
);
|
|
188
245
|
|
|
189
246
|
if (
|
|
@@ -202,15 +259,18 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
202
259
|
|
|
203
260
|
const tsTestLoaderOption = (() => {
|
|
204
261
|
switch (tsTestUtil) {
|
|
205
|
-
case 'tsimp':
|
|
206
|
-
return '--import=tsimp/import';
|
|
207
262
|
case 'ts-node':
|
|
208
263
|
return '--loader=ts-node/esm --experimental-specifier-resolution=node';
|
|
209
|
-
case '
|
|
264
|
+
case 'swc':
|
|
210
265
|
return '--import=@swc-node/register/esm';
|
|
266
|
+
|
|
267
|
+
// no default
|
|
211
268
|
}
|
|
212
269
|
})();
|
|
213
270
|
|
|
271
|
+
const hasTestFolder =
|
|
272
|
+
!this.options.monorepo && fs.existsSync(this.destinationPath('test'));
|
|
273
|
+
|
|
214
274
|
const createTestCommand = ({
|
|
215
275
|
coverage,
|
|
216
276
|
coverageLcov,
|
|
@@ -242,7 +302,7 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
242
302
|
if (!workspacesPattern && this.options.monorepo) {
|
|
243
303
|
throw new Error('Invalid workspacesPattern');
|
|
244
304
|
}
|
|
245
|
-
return `${
|
|
305
|
+
return `${
|
|
246
306
|
tsTestUtil === 'ts-node'
|
|
247
307
|
? 'TS_NODE_PROJECT=tsconfig.test.json '
|
|
248
308
|
: ''
|
|
@@ -256,11 +316,18 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
256
316
|
: ''
|
|
257
317
|
}node ${
|
|
258
318
|
this.options.typescript ? `${tsTestLoaderOption} ` : ''
|
|
259
|
-
}--test ${
|
|
260
|
-
this.options.
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
319
|
+
}--test ${this.options.monorepo ? `${workspacesPattern}/` : ''}${`${
|
|
320
|
+
hasTestFolder ? 'test/*' : `${this.options.srcDirectory}/**/*.test`
|
|
321
|
+
}.${this.options.typescript ? 'ts' : 'js'}`}`;
|
|
322
|
+
}
|
|
323
|
+
case 'vitest': {
|
|
324
|
+
return `${
|
|
325
|
+
coverage || coverageJson || coverageLcov
|
|
326
|
+
? `POB_VITEST_COVERAGE=${
|
|
327
|
+
coverageLcov ? 'lcov' : `json${coverageJson ? '' : ',text'} `
|
|
328
|
+
}`
|
|
329
|
+
: ''
|
|
330
|
+
}vitest${watch ? ' --watch' : ''}`;
|
|
264
331
|
}
|
|
265
332
|
default: {
|
|
266
333
|
throw new Error(`Invalid runner: "${testRunner}"`);
|
|
@@ -271,7 +338,9 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
271
338
|
const jestConfigPath = this.destinationPath('jest.config.json');
|
|
272
339
|
packageUtils.addOrRemoveDevDependencies(
|
|
273
340
|
pkg,
|
|
274
|
-
|
|
341
|
+
this.options.enable &&
|
|
342
|
+
(enableForMonorepo || !globalTesting) &&
|
|
343
|
+
testRunner === 'jest',
|
|
275
344
|
['jest', '@types/jest'],
|
|
276
345
|
);
|
|
277
346
|
|
|
@@ -372,6 +441,24 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
372
441
|
} else {
|
|
373
442
|
delete jestConfig.extensionsToTreatAsEsm;
|
|
374
443
|
}
|
|
444
|
+
|
|
445
|
+
if (tsTestUtil === 'swc' && !transpileWithBabel && withTypescript) {
|
|
446
|
+
jestConfig.transform = {
|
|
447
|
+
[hasReact ? '^.+\\.tsx?$' : '^.+\\.ts$']: ['@swc/jest'],
|
|
448
|
+
};
|
|
449
|
+
} else if (jestConfig.transform) {
|
|
450
|
+
jestConfig.transform = Object.fromEntries(
|
|
451
|
+
Object.entries(jestConfig.transform).filter(
|
|
452
|
+
([key, value]) =>
|
|
453
|
+
value !== '@swc/jest' &&
|
|
454
|
+
!(Array.isArray(value) && value[0] === '@swc/jest'),
|
|
455
|
+
),
|
|
456
|
+
);
|
|
457
|
+
if (Object.keys(jestConfig.transform).length === 0) {
|
|
458
|
+
delete jestConfig.transform;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
375
462
|
writeAndFormatJson(this.fs, jestConfigPath, jestConfig);
|
|
376
463
|
}
|
|
377
464
|
} else {
|
|
@@ -472,21 +559,44 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
472
559
|
},
|
|
473
560
|
],
|
|
474
561
|
};
|
|
475
|
-
} else if (!transpileWithBabel) {
|
|
562
|
+
} else if (!transpileWithBabel && !withTypescript) {
|
|
476
563
|
delete jestConfig.transform;
|
|
477
|
-
} else
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
564
|
+
} else {
|
|
565
|
+
if (
|
|
566
|
+
tsTestUtil === 'swc' &&
|
|
567
|
+
!transpileWithBabel &&
|
|
568
|
+
withTypescript
|
|
569
|
+
) {
|
|
570
|
+
jestConfig.transform = {
|
|
571
|
+
[hasReact ? '^.+\\.tsx?$' : '^.+\\.ts$']: ['@swc/jest'],
|
|
572
|
+
};
|
|
573
|
+
} else if (jestConfig.transform) {
|
|
574
|
+
jestConfig.transform = Object.fromEntries(
|
|
575
|
+
Object.entries(jestConfig.transform).filter(
|
|
576
|
+
([key, value]) =>
|
|
577
|
+
value !== '@swc/jest' &&
|
|
578
|
+
!(Array.isArray(value) && value[0] === '@swc/jest'),
|
|
579
|
+
),
|
|
580
|
+
);
|
|
581
|
+
if (Object.keys(jestConfig.transform).length === 0) {
|
|
582
|
+
delete jestConfig.transform;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
if (jestConfig.transform) {
|
|
587
|
+
jestConfig.transform = Object.fromEntries(
|
|
588
|
+
Object.entries(jestConfig.transform).filter(
|
|
589
|
+
([key, value]) =>
|
|
590
|
+
!(
|
|
591
|
+
value &&
|
|
592
|
+
Array.isArray(value) &&
|
|
593
|
+
value[0] === 'jest-esbuild'
|
|
594
|
+
),
|
|
595
|
+
),
|
|
596
|
+
);
|
|
597
|
+
if (Object.keys(jestConfig.transform).length === 0) {
|
|
598
|
+
delete jestConfig.transform;
|
|
599
|
+
}
|
|
490
600
|
}
|
|
491
601
|
}
|
|
492
602
|
|
|
@@ -130,15 +130,23 @@ export default class CommonTranspilerGenerator extends Generator {
|
|
|
130
130
|
|
|
131
131
|
default() {
|
|
132
132
|
const pkg = this.fs.readJSON(this.destinationPath('package.json'));
|
|
133
|
-
const withTypescript = pkg.pob.typescript;
|
|
134
133
|
const withBabel = this.babelEnvs && this.babelEnvs.length > 0;
|
|
135
|
-
const
|
|
134
|
+
const withTypescript = pkg.pob.typescript || withBabel || !!pkg.pob.bundler;
|
|
135
|
+
const bundler =
|
|
136
|
+
withTypescript &&
|
|
137
|
+
(pkg.pob.rollup === false
|
|
138
|
+
? 'tsc'
|
|
139
|
+
: pkg.pob.bundler ??
|
|
140
|
+
(pkg.pob.typescript ? 'rollup-typescript' : 'rollup'));
|
|
141
|
+
this.bundler = bundler;
|
|
136
142
|
|
|
137
143
|
const cleanCommand = (() => {
|
|
138
|
-
if (
|
|
139
|
-
|
|
144
|
+
if (bundler === 'rollup-typescript') return 'pob-typescript-clean-out';
|
|
145
|
+
if (bundler === 'rollup-esbuild') return 'pob-esbuild-clean-out';
|
|
146
|
+
if (bundler === 'rollup') {
|
|
140
147
|
return 'pob-babel-clean-out';
|
|
141
148
|
}
|
|
149
|
+
if (bundler === 'esbuild') return 'pob-esbuild-clean-out';
|
|
142
150
|
return null;
|
|
143
151
|
})();
|
|
144
152
|
|
|
@@ -146,36 +154,47 @@ export default class CommonTranspilerGenerator extends Generator {
|
|
|
146
154
|
|
|
147
155
|
if (this.options.isApp) {
|
|
148
156
|
packageUtils.removeScripts(['watch']);
|
|
149
|
-
packageUtils.addOrRemoveScripts(pkg,
|
|
157
|
+
packageUtils.addOrRemoveScripts(pkg, bundler && bundler !== 'tsc', {
|
|
150
158
|
'clean:build': `${cleanCommand} ${this.options.buildDirectory}`,
|
|
151
159
|
clean: 'yarn clean:build',
|
|
152
160
|
});
|
|
153
161
|
|
|
154
|
-
packageUtils.addOrRemoveScripts(pkg,
|
|
155
|
-
start:
|
|
156
|
-
|
|
157
|
-
|
|
162
|
+
packageUtils.addOrRemoveScripts(pkg, bundler, {
|
|
163
|
+
start: (() => {
|
|
164
|
+
if (bundler && bundler.startsWith('rollup')) {
|
|
165
|
+
return 'yarn clean:build && rollup --config rollup.config.mjs --watch';
|
|
166
|
+
}
|
|
167
|
+
if (bundler === 'tsc') return 'tsc --watch';
|
|
168
|
+
if (bundler === 'esbuild') return 'pob-esbuild-watch';
|
|
169
|
+
})(),
|
|
158
170
|
});
|
|
159
171
|
} else {
|
|
160
172
|
packageUtils.removeScripts(['start']);
|
|
161
|
-
packageUtils.addOrRemoveScripts(pkg,
|
|
173
|
+
packageUtils.addOrRemoveScripts(pkg, bundler && bundler !== 'tsc', {
|
|
162
174
|
'clean:build': `${cleanCommand} ${this.options.buildDirectory}`,
|
|
163
175
|
});
|
|
164
176
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
177
|
+
|
|
178
|
+
packageUtils.addOrRemoveScripts(pkg, bundler, {
|
|
179
|
+
build: (() => {
|
|
180
|
+
if (bundler && bundler.startsWith('rollup')) {
|
|
181
|
+
return 'yarn clean:build && rollup --config rollup.config.mjs';
|
|
182
|
+
}
|
|
183
|
+
if (bundler === 'tsc') return 'tsc';
|
|
184
|
+
if (bundler === 'esbuild') return 'pob-esbuild-build';
|
|
185
|
+
})(),
|
|
169
186
|
});
|
|
170
187
|
|
|
171
|
-
const shouldBuildDefinitions =
|
|
188
|
+
const shouldBuildDefinitions =
|
|
189
|
+
!this.options.isApp && withTypescript && bundler !== 'tsc';
|
|
190
|
+
|
|
172
191
|
packageUtils.addOrRemoveScripts(pkg, shouldBuildDefinitions, {
|
|
173
192
|
'build:definitions': 'tsc -p tsconfig.json',
|
|
174
193
|
});
|
|
175
194
|
|
|
176
195
|
if (shouldBuildDefinitions) {
|
|
177
196
|
pkg.scripts.build += ' && yarn run build:definitions';
|
|
178
|
-
} else if (!this.options.isApp && !
|
|
197
|
+
} else if (!this.options.isApp && !bundler && !withTypescript) {
|
|
179
198
|
// check definitions, but also force lerna to execute build:definitions in right order
|
|
180
199
|
// example: nightingale-types depends on nightingale-levels
|
|
181
200
|
if (this.fs.exists(this.destinationPath('lib/index.d.ts'))) {
|
|
@@ -203,9 +222,36 @@ export default class CommonTranspilerGenerator extends Generator {
|
|
|
203
222
|
|
|
204
223
|
/* dependencies */
|
|
205
224
|
|
|
206
|
-
packageUtils.addOrRemoveDevDependencies(
|
|
207
|
-
|
|
208
|
-
|
|
225
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
226
|
+
pkg,
|
|
227
|
+
bundler === 'rollup-typescript',
|
|
228
|
+
['@pob/rollup-typescript'],
|
|
229
|
+
);
|
|
230
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
231
|
+
pkg,
|
|
232
|
+
bundler === 'esbuild' && withTypescript,
|
|
233
|
+
['@pob/esbuild'],
|
|
234
|
+
);
|
|
235
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
236
|
+
pkg,
|
|
237
|
+
bundler === 'rollup-esbuild' && withTypescript,
|
|
238
|
+
['@pob/rollup-esbuild'],
|
|
239
|
+
);
|
|
240
|
+
packageUtils.addOrRemoveDependencies(
|
|
241
|
+
pkg,
|
|
242
|
+
(bundler === 'tsc' || bundler === 'rollup-typescript') && withTypescript,
|
|
243
|
+
['tslib'],
|
|
244
|
+
'^',
|
|
245
|
+
);
|
|
246
|
+
|
|
247
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
248
|
+
pkg,
|
|
249
|
+
bundler === 'rollup' &&
|
|
250
|
+
this.options.isApp &&
|
|
251
|
+
!this.options.isAppLibrary &&
|
|
252
|
+
this.options.useAppConfig,
|
|
253
|
+
['alp-rollup-plugin-config'],
|
|
254
|
+
);
|
|
209
255
|
|
|
210
256
|
/* engines */
|
|
211
257
|
// TODO move from CommonBabelGenerator
|
|
@@ -234,7 +280,7 @@ export default class CommonTranspilerGenerator extends Generator {
|
|
|
234
280
|
}
|
|
235
281
|
|
|
236
282
|
// if (!pkg.main || pkg.main.startsWith('./lib/')) {
|
|
237
|
-
if (
|
|
283
|
+
if (bundler || withTypescript) {
|
|
238
284
|
// see pkg.exports instead.
|
|
239
285
|
delete pkg.main;
|
|
240
286
|
if (!this.options.isApp) {
|
|
@@ -305,12 +351,14 @@ export default class CommonTranspilerGenerator extends Generator {
|
|
|
305
351
|
}
|
|
306
352
|
|
|
307
353
|
/* webpack 5 and node with ESM support */
|
|
308
|
-
if (
|
|
354
|
+
if (bundler || withTypescript) {
|
|
355
|
+
const omitTarget = bundler === 'esbuild';
|
|
309
356
|
pkg.exports = {
|
|
310
357
|
'./package.json': './package.json',
|
|
311
358
|
};
|
|
312
359
|
|
|
313
|
-
this.entries.forEach((
|
|
360
|
+
this.entries.forEach((entryWithOptionalExt) => {
|
|
361
|
+
const entry = entryWithOptionalExt.replace(/\.[jt]sx?$/, '');
|
|
314
362
|
const isBrowserOnly =
|
|
315
363
|
withBabel &&
|
|
316
364
|
entry === 'browser' &&
|
|
@@ -324,7 +372,7 @@ export default class CommonTranspilerGenerator extends Generator {
|
|
|
324
372
|
pkg.private || this.options.isAppLibrary
|
|
325
373
|
? `./src/${entryDistName}.ts`
|
|
326
374
|
: `./${this.options.buildDirectory}/${
|
|
327
|
-
|
|
375
|
+
bundler !== 'tsc' ? 'definitions/' : ''
|
|
328
376
|
}${entryDistName}.d.ts`,
|
|
329
377
|
};
|
|
330
378
|
|
|
@@ -335,21 +383,26 @@ export default class CommonTranspilerGenerator extends Generator {
|
|
|
335
383
|
|
|
336
384
|
const defaultNodeEnvVersion = defaultNodeEnv && defaultNodeEnv.version;
|
|
337
385
|
|
|
338
|
-
envs.forEach(({ target, version, formats }) => {
|
|
386
|
+
envs.forEach(({ target, version, formats, omitVersionInFileName }) => {
|
|
339
387
|
if (target === 'node' && entry === 'browser') return;
|
|
340
388
|
|
|
341
389
|
const exportTarget = {};
|
|
342
390
|
|
|
343
391
|
if (target === 'node') {
|
|
344
392
|
const cjsExt = pkg.type === 'module' ? 'cjs' : 'cjs.js';
|
|
393
|
+
const filenameWithoutExt = `${entryDistName}${
|
|
394
|
+
omitTarget
|
|
395
|
+
? ''
|
|
396
|
+
: `-${target}${omitVersionInFileName ? '' : version}`
|
|
397
|
+
}`;
|
|
345
398
|
if (!formats || formats.includes('es')) {
|
|
346
|
-
exportTarget.import = `./${this.options.buildDirectory}/${
|
|
399
|
+
exportTarget.import = `./${this.options.buildDirectory}/${filenameWithoutExt}.mjs`;
|
|
347
400
|
|
|
348
401
|
if (formats && formats.includes('cjs')) {
|
|
349
|
-
exportTarget.require = `./${this.options.buildDirectory}/${
|
|
402
|
+
exportTarget.require = `./${this.options.buildDirectory}/${filenameWithoutExt}.${cjsExt}`;
|
|
350
403
|
}
|
|
351
404
|
} else if (formats && formats.includes('cjs')) {
|
|
352
|
-
exportTarget.default = `./${this.options.buildDirectory}/${
|
|
405
|
+
exportTarget.default = `./${this.options.buildDirectory}/${filenameWithoutExt}.${cjsExt}`;
|
|
353
406
|
}
|
|
354
407
|
// eslint: https://github.com/benmosher/eslint-plugin-import/issues/2132
|
|
355
408
|
// jest: https://github.com/facebook/jest/issues/9771
|
|
@@ -470,13 +523,18 @@ export default class CommonTranspilerGenerator extends Generator {
|
|
|
470
523
|
const entries = pkg.pob.entries || ['index'];
|
|
471
524
|
|
|
472
525
|
this.fs.delete('rollup.config.js');
|
|
473
|
-
if (
|
|
526
|
+
if (
|
|
527
|
+
pkg.pob.typescript &&
|
|
528
|
+
pkg.pob.rollup !== false &&
|
|
529
|
+
(!pkg.pob.bundler || pkg.pob.bundler.startsWith('rollup'))
|
|
530
|
+
) {
|
|
474
531
|
if (this.options.isApp) {
|
|
475
532
|
copyAndFormatTpl(
|
|
476
533
|
this.fs,
|
|
477
534
|
this.templatePath('app.rollup.config.mjs.ejs'),
|
|
478
535
|
this.destinationPath('rollup.config.mjs'),
|
|
479
536
|
{
|
|
537
|
+
rollupConfigLib: this.bundler,
|
|
480
538
|
config: this.options.useAppConfig,
|
|
481
539
|
outDirectory: this.options.buildDirectory,
|
|
482
540
|
enableRun: !this.options.isAppLibrary && entries.includes('index'),
|
|
@@ -488,11 +546,16 @@ export default class CommonTranspilerGenerator extends Generator {
|
|
|
488
546
|
this.templatePath('lib.rollup.config.mjs.ejs'),
|
|
489
547
|
this.destinationPath('rollup.config.mjs'),
|
|
490
548
|
{
|
|
549
|
+
rollupConfigLib: this.bundler,
|
|
491
550
|
outDirectory: this.options.buildDirectory,
|
|
492
551
|
},
|
|
493
552
|
);
|
|
494
553
|
}
|
|
495
|
-
} else if (
|
|
554
|
+
} else if (
|
|
555
|
+
!pkg.pob.babelEnvs ||
|
|
556
|
+
pkg.pob.babelEnvs.length === 0 ||
|
|
557
|
+
pkg.pob?.bundler === 'esbuild'
|
|
558
|
+
) {
|
|
496
559
|
this.fs.delete('rollup.config.mjs');
|
|
497
560
|
}
|
|
498
561
|
|
|
@@ -3,9 +3,9 @@ import { fileURLToPath } from 'node:url';
|
|
|
3
3
|
<% if (config) { -%>
|
|
4
4
|
import config from 'alp-rollup-plugin-config';
|
|
5
5
|
<% } -%>
|
|
6
|
-
import createRollupConfig from '@pob
|
|
6
|
+
import createRollupConfig from '@pob/<%= rollupConfigLib %>/createRollupConfig.js';
|
|
7
7
|
<% if (enableRun) { -%>
|
|
8
|
-
import run from '@pob
|
|
8
|
+
import run from '@pob/<%= rollupConfigLib %>/plugin-run.cjs';
|
|
9
9
|
|
|
10
10
|
const watch = process.env.ROLLUP_WATCH === 'true';
|
|
11
11
|
<% } -%>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
|
-
import createRollupConfig from '@pob
|
|
3
|
+
import createRollupConfig from '@pob/<%= rollupConfigLib %>/createRollupConfig.js';
|
|
4
4
|
|
|
5
5
|
export default createRollupConfig({
|
|
6
6
|
cwd: dirname(fileURLToPath(import.meta.url)),
|
|
@@ -135,12 +135,16 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
135
135
|
version: '18',
|
|
136
136
|
},
|
|
137
137
|
];
|
|
138
|
-
if (pkg.pob.rollup === false) {
|
|
138
|
+
if (pkg.pob.rollup === false || pkg.pob.bundler === false) {
|
|
139
139
|
return [`@pob/root/tsconfigs/targets/node-${nodeVersion}.json`];
|
|
140
140
|
}
|
|
141
141
|
if (envs && envs.every((env) => env.target === 'node')) {
|
|
142
142
|
return [
|
|
143
|
-
`@pob/root/tsconfigs/targets
|
|
143
|
+
`@pob/root/tsconfigs/targets/${
|
|
144
|
+
!pkg.pob.bundler || pkg.pob.bundler.startsWith('rollup')
|
|
145
|
+
? 'rollup'
|
|
146
|
+
: pkg.pob.bundler
|
|
147
|
+
}-node-${nodeVersion}.json`,
|
|
144
148
|
];
|
|
145
149
|
}
|
|
146
150
|
return ['@pob/root/tsconfigs/targets/rollup-es2015.json'];
|
|
@@ -258,7 +262,7 @@ export default class CommonTypescriptGenerator extends Generator {
|
|
|
258
262
|
tsconfigPath,
|
|
259
263
|
{
|
|
260
264
|
emitDefinitions: this.options.builddefs,
|
|
261
|
-
build: pkg.pob?.rollup === false,
|
|
265
|
+
build: pkg.pob?.rollup === false || pkg.pob?.bundler === false,
|
|
262
266
|
cacheEnabled: !this.options.isApp || this.options.isAppLibrary,
|
|
263
267
|
monorepoPackageSrcPaths,
|
|
264
268
|
monorepoPackageReferences,
|
|
@@ -60,6 +60,13 @@ export default class CoreNpmGenerator extends Generator {
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
+
if (pkg.pob?.extraEntries) {
|
|
64
|
+
pkg.pob?.extraEntries.forEach((extraEntry) => {
|
|
65
|
+
if (extraEntry.directory) {
|
|
66
|
+
files.add(extraEntry.directory);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
63
70
|
|
|
64
71
|
pkg.files = [...files].filter(Boolean);
|
|
65
72
|
} else {
|
|
@@ -36,6 +36,12 @@ export default class CorePackageGenerator extends Generator {
|
|
|
36
36
|
default: false,
|
|
37
37
|
desc: 'private package',
|
|
38
38
|
});
|
|
39
|
+
|
|
40
|
+
this.option('packageType', {
|
|
41
|
+
type: String,
|
|
42
|
+
required: false,
|
|
43
|
+
desc: 'package type',
|
|
44
|
+
});
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
async initializing() {
|
|
@@ -106,6 +112,10 @@ export default class CorePackageGenerator extends Generator {
|
|
|
106
112
|
pkg.name = name;
|
|
107
113
|
}
|
|
108
114
|
|
|
115
|
+
if (this.options.packageType) {
|
|
116
|
+
pkg.type = this.options.packageType;
|
|
117
|
+
}
|
|
118
|
+
|
|
109
119
|
let author = packageUtils.parsePkgAuthor(pkg);
|
|
110
120
|
|
|
111
121
|
const props = await this.prompt(
|
|
@@ -34,6 +34,12 @@ export default class CoreVSCodeGenerator extends Generator {
|
|
|
34
34
|
desc: 'Testing enabled',
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
this.option('testRunner', {
|
|
38
|
+
type: String,
|
|
39
|
+
required: false,
|
|
40
|
+
desc: 'Test runner (jest, vitest, ...)',
|
|
41
|
+
});
|
|
42
|
+
|
|
37
43
|
this.option('yarnNodeLinker', {
|
|
38
44
|
type: String,
|
|
39
45
|
required: false,
|
|
@@ -81,6 +87,7 @@ export default class CoreVSCodeGenerator extends Generator {
|
|
|
81
87
|
npm: this.options.packageManager === 'npm',
|
|
82
88
|
typescript: this.options.typescript,
|
|
83
89
|
testing: this.options.testing,
|
|
90
|
+
testRunner: this.options.testRunner,
|
|
84
91
|
module: pkg.type === 'module',
|
|
85
92
|
},
|
|
86
93
|
);
|
|
@@ -292,6 +292,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
292
292
|
packageManager: this.options.packageManager,
|
|
293
293
|
isApp: false,
|
|
294
294
|
splitCIJobs: false,
|
|
295
|
+
srcDirectory: withBabel || withTypescript ? 'src' : 'lib',
|
|
295
296
|
});
|
|
296
297
|
|
|
297
298
|
// must be after testing
|
|
@@ -341,6 +342,7 @@ export default class PobLibGenerator extends Generator {
|
|
|
341
342
|
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
342
343
|
typescript: withBabel || withTypescript,
|
|
343
344
|
testing: this.pobjson.testing,
|
|
345
|
+
testRunner: this.pobjson.testRunner,
|
|
344
346
|
});
|
|
345
347
|
|
|
346
348
|
// must be after doc, testing
|
|
@@ -275,6 +275,7 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
275
275
|
yarnNodeLinker: this.options.yarnNodeLinker,
|
|
276
276
|
typescript: this.pobLernaConfig.typescript,
|
|
277
277
|
testing: this.pobLernaConfig.testing,
|
|
278
|
+
testRunner: this.pobLernaConfig.testRunner,
|
|
278
279
|
packageNames: JSON.stringify(packageNames),
|
|
279
280
|
packageLocations: JSON.stringify(this.packageLocations),
|
|
280
281
|
});
|
|
@@ -81,6 +81,13 @@ export default class PobBaseGenerator extends Generator {
|
|
|
81
81
|
delete config.yarn2;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
if (!config.type) {
|
|
85
|
+
const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
|
|
86
|
+
if (pkg.dependencies?.next) {
|
|
87
|
+
config.type = 'app';
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
84
91
|
const responses = await this.prompt([
|
|
85
92
|
{
|
|
86
93
|
when: () => !config.type,
|
|
@@ -123,10 +130,11 @@ export default class PobBaseGenerator extends Generator {
|
|
|
123
130
|
|
|
124
131
|
this.composeWith('pob:core:package', {
|
|
125
132
|
updateOnly: this.options.updateOnly,
|
|
126
|
-
private: this.isMonorepo,
|
|
133
|
+
private: this.isMonorepo || this.projectConfig.type === 'app',
|
|
127
134
|
isMonorepo: this.isMonorepo,
|
|
128
135
|
inMonorepo: !!inMonorepo,
|
|
129
136
|
isRoot: this.isRoot,
|
|
137
|
+
packageType: this.projectConfig.type === 'app' ? 'module' : undefined,
|
|
130
138
|
});
|
|
131
139
|
|
|
132
140
|
if (this.isMonorepo) {
|
|
@@ -244,6 +252,7 @@ export default class PobBaseGenerator extends Generator {
|
|
|
244
252
|
this.spawnCommandSync('npm', ['install']);
|
|
245
253
|
break;
|
|
246
254
|
case 'yarn':
|
|
255
|
+
default:
|
|
247
256
|
// see CoreYarnGenerator
|
|
248
257
|
break;
|
|
249
258
|
}
|
package/lib/pob.js
CHANGED
|
@@ -306,6 +306,7 @@ if (action === 'migrate-to-monorepo') {
|
|
|
306
306
|
|
|
307
307
|
const monorepoName = `${path.basename(process.cwd())}-monorepo`;
|
|
308
308
|
const monorepoPkg = {
|
|
309
|
+
private: true,
|
|
309
310
|
name: monorepoName,
|
|
310
311
|
version: projectPkg.version,
|
|
311
312
|
author: projectPkg.author,
|
|
@@ -313,6 +314,7 @@ if (action === 'migrate-to-monorepo') {
|
|
|
313
314
|
repository: projectPkg.repository,
|
|
314
315
|
engines: projectPkg.engines,
|
|
315
316
|
packageManager: projectPkg.packageManager,
|
|
317
|
+
workspaces: ['packages/*'],
|
|
316
318
|
};
|
|
317
319
|
|
|
318
320
|
writeFileSync('package.json', JSON.stringify(monorepoPkg, null, 2));
|
package/lib/utils/package.js
CHANGED
|
@@ -222,8 +222,8 @@ export function removeDevDependencies(pkg, dependencies, forceEvenIfInPeerDep) {
|
|
|
222
222
|
);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
-
export function addOrRemoveDependencies(pkg, condition, dependencies) {
|
|
226
|
-
if (condition) return addDependencies(pkg, dependencies);
|
|
225
|
+
export function addOrRemoveDependencies(pkg, condition, dependencies, prefix) {
|
|
226
|
+
if (condition) return addDependencies(pkg, dependencies, prefix);
|
|
227
227
|
return removeDependencies(pkg, dependencies);
|
|
228
228
|
}
|
|
229
229
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pob",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.4.0",
|
|
4
4
|
"description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"skeleton"
|
|
@@ -39,18 +39,18 @@
|
|
|
39
39
|
"pob": {},
|
|
40
40
|
"prettier": "@pob/root/prettier-config",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@pob/eslint-config": "
|
|
43
|
-
"@pob/eslint-config-typescript": "
|
|
44
|
-
"@pob/eslint-config-typescript-react": "
|
|
45
|
-
"@pob/sort-eslint-config": "5.
|
|
46
|
-
"@pob/sort-object": "6.
|
|
47
|
-
"@pob/sort-pkg": "7.
|
|
42
|
+
"@pob/eslint-config": "55.2.1",
|
|
43
|
+
"@pob/eslint-config-typescript": "55.2.1",
|
|
44
|
+
"@pob/eslint-config-typescript-react": "55.2.1",
|
|
45
|
+
"@pob/sort-eslint-config": "5.3.0",
|
|
46
|
+
"@pob/sort-object": "6.3.0",
|
|
47
|
+
"@pob/sort-pkg": "7.1.0",
|
|
48
48
|
"@types/inquirer": "9.0.7",
|
|
49
|
-
"@yarnpkg/cli": "4.
|
|
50
|
-
"@yarnpkg/core": "4.0.
|
|
51
|
-
"@yarnpkg/fslib": "3.0.
|
|
52
|
-
"@yeoman/types": "1.
|
|
53
|
-
"eslint": "8.
|
|
49
|
+
"@yarnpkg/cli": "4.1.1",
|
|
50
|
+
"@yarnpkg/core": "4.0.3",
|
|
51
|
+
"@yarnpkg/fslib": "3.0.2",
|
|
52
|
+
"@yeoman/types": "1.2.0",
|
|
53
|
+
"eslint": "8.57.0",
|
|
54
54
|
"findup-sync": "^5.0.0",
|
|
55
55
|
"git-remote-url": "^1.0.1",
|
|
56
56
|
"github-username": "^7.0.0",
|
|
@@ -58,19 +58,19 @@
|
|
|
58
58
|
"json5": "^2.2.2",
|
|
59
59
|
"lodash.camelcase": "^4.3.0",
|
|
60
60
|
"lodash.kebabcase": "^4.1.1",
|
|
61
|
-
"mem-fs": "4.
|
|
61
|
+
"mem-fs": "4.1.0",
|
|
62
62
|
"mem-fs-editor": "11.0.0",
|
|
63
63
|
"minimist": "1.2.8",
|
|
64
64
|
"parse-author": "2.0.0",
|
|
65
|
-
"pob-dependencies": "11.0
|
|
65
|
+
"pob-dependencies": "11.2.0",
|
|
66
66
|
"prettier": "2.8.8",
|
|
67
|
-
"semver": "7.
|
|
67
|
+
"semver": "7.6.0",
|
|
68
68
|
"validate-npm-package-name": "^5.0.0",
|
|
69
|
-
"yarn-workspace-utils": "3.
|
|
70
|
-
"yeoman-environment": "4.
|
|
69
|
+
"yarn-workspace-utils": "3.3.0",
|
|
70
|
+
"yeoman-environment": "4.4.0",
|
|
71
71
|
"yeoman-generator": "7.1.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@pob/root": "9.
|
|
74
|
+
"@pob/root": "9.3.0"
|
|
75
75
|
}
|
|
76
76
|
}
|