pob 9.3.1 → 9.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 +11 -0
- package/lib/generators/common/babel/CommonBabelGenerator.js +2 -0
- package/lib/generators/common/babel/templates/babel.config.cjs.ejs +1 -1
- package/lib/generators/common/format-lint/CommonLintGenerator.js +1 -1
- package/lib/generators/common/testing/CommonTestingGenerator.js +99 -75
- package/lib/generators/monorepo/PobMonorepoGenerator.js +9 -9
- package/lib/generators/monorepo/lerna/MonorepoLernaGenerator.js +0 -21
- package/lib/utils/package.js +0 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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
|
+
# [9.4.0](https://github.com/christophehurpeau/pob/compare/pob@9.3.1...pob@9.4.0) (2021-12-11)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* monorepo testing generator ([b444042](https://github.com/christophehurpeau/pob/commit/b444042aa5203e4ac7a56a3d93f5a3b98c0fce11))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [9.3.1](https://github.com/christophehurpeau/pob/compare/pob@9.3.0...pob@9.3.1) (2021-12-11)
|
|
7
18
|
|
|
8
19
|
**Note:** Version bump only for package pob
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import semver from 'semver';
|
|
3
3
|
import Generator from 'yeoman-generator';
|
|
4
|
+
import inLerna from '../../../utils/inLerna.js';
|
|
4
5
|
import * as packageUtils from '../../../utils/package.js';
|
|
5
6
|
|
|
6
7
|
export default class CommonBabelGenerator extends Generator {
|
|
@@ -734,6 +735,7 @@ export default class CommonBabelGenerator extends Generator {
|
|
|
734
735
|
{
|
|
735
736
|
hasReact,
|
|
736
737
|
testing: this.options.testing,
|
|
738
|
+
jestExperimentalESM: !inLerna,
|
|
737
739
|
},
|
|
738
740
|
);
|
|
739
741
|
} else {
|
|
@@ -9,6 +9,6 @@ module.exports = function babelConfig(api) {
|
|
|
9
9
|
|
|
10
10
|
return {
|
|
11
11
|
only: [path.resolve(__dirname, 'src')],
|
|
12
|
-
presets: [require.resolve('pob-babel/preset')],
|
|
12
|
+
presets: [[require.resolve('pob-babel/preset')<% if (!jestExperimentalESM) { %>, { modules: 'commonjs' }<% } %>]],
|
|
13
13
|
};
|
|
14
14
|
};
|
|
@@ -337,7 +337,7 @@ export default class CommonLintGenerator extends Generator {
|
|
|
337
337
|
? `{${pkg.type === 'commonjs' ? 'mjs' : 'cjs'},js}`
|
|
338
338
|
: `${hasReact ? '{ts,tsx}' : 'ts'}`;
|
|
339
339
|
|
|
340
|
-
const jestOverride = !
|
|
340
|
+
const jestOverride = !pkg.jest
|
|
341
341
|
? null
|
|
342
342
|
: {
|
|
343
343
|
files: [`**/*.test.${ext}`, `__tests__/**/*.${ext}`],
|
|
@@ -6,6 +6,12 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
6
6
|
constructor(args, opts) {
|
|
7
7
|
super(args, opts);
|
|
8
8
|
|
|
9
|
+
this.option('monorepo', {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
defaults: false,
|
|
12
|
+
desc: 'is root monorepo',
|
|
13
|
+
});
|
|
14
|
+
|
|
9
15
|
this.option('enable', {
|
|
10
16
|
type: Boolean,
|
|
11
17
|
defaults: true,
|
|
@@ -44,10 +50,10 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
44
50
|
}
|
|
45
51
|
|
|
46
52
|
default() {
|
|
47
|
-
if (!inLerna) {
|
|
53
|
+
if (!inLerna || inLerna.root) {
|
|
48
54
|
this.composeWith('pob:core:ci', {
|
|
49
55
|
enable: this.options.ci,
|
|
50
|
-
testing: this.options.
|
|
56
|
+
testing: this.options.enable,
|
|
51
57
|
build: this.options.typescript,
|
|
52
58
|
typescript: this.options.typescript,
|
|
53
59
|
documentation: this.options.documentation,
|
|
@@ -73,6 +79,12 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
73
79
|
'babel-jest',
|
|
74
80
|
]);
|
|
75
81
|
|
|
82
|
+
// const yoConfigPobMonorepo = inLerna && inLerna.pobMonorepoConfig;
|
|
83
|
+
// const globalTesting = yoConfigPobMonorepo && yoConfigPobMonorepo.testing;
|
|
84
|
+
const globalTesting = false;
|
|
85
|
+
|
|
86
|
+
const enableForMonorepo = this.options.monorepo && globalTesting;
|
|
87
|
+
|
|
76
88
|
if (!this.options.enable) {
|
|
77
89
|
packageUtils.removeDevDependencies(pkg, ['jest', '@types/jest']);
|
|
78
90
|
|
|
@@ -91,81 +103,93 @@ export default class CommonTestingGenerator extends Generator {
|
|
|
91
103
|
|
|
92
104
|
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
|
|
93
105
|
} else {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
: ''
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
packageUtils.addScripts(pkg, {
|
|
107
|
-
test: jestCommand,
|
|
108
|
-
'test:watch': `${jestCommand} --watch`,
|
|
109
|
-
'generate:test-coverage': [
|
|
110
|
-
'rm -Rf docs/coverage/',
|
|
111
|
-
`NODE_ENV=production ${
|
|
112
|
-
transpileWithBabel ? 'BABEL_ENV=test ' : ''
|
|
113
|
-
}${jestCommand} --coverage --coverageReporters=pob-lcov-reporter --coverageDirectory=docs/coverage/`,
|
|
114
|
-
].join(' ; '),
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
packageUtils.addDevDependencies(pkg, [
|
|
118
|
-
'pob-lcov-reporter',
|
|
119
|
-
'jest',
|
|
120
|
-
'@types/jest',
|
|
121
|
-
]);
|
|
122
|
-
|
|
123
|
-
const hasReact = transpileWithBabel && packageUtils.hasReact(pkg);
|
|
124
|
-
const srcDirectory = transpileWithBabel ? 'src' : 'lib';
|
|
125
|
-
|
|
126
|
-
if (!pkg.jest) pkg.jest = {};
|
|
127
|
-
Object.assign(pkg.jest, {
|
|
128
|
-
cacheDirectory: './node_modules/.cache/jest',
|
|
129
|
-
testMatch: [
|
|
130
|
-
`<rootDir>/${srcDirectory}/**/__tests__/**/*.${
|
|
131
|
-
transpileWithBabel ? 'ts' : '?(m)js'
|
|
132
|
-
}${hasReact ? '?(x)' : ''}`,
|
|
133
|
-
`<rootDir>/${srcDirectory}/**/*.test.${
|
|
134
|
-
transpileWithBabel ? 'ts' : '?(m)js'
|
|
135
|
-
}${hasReact ? '?(x)' : ''}`,
|
|
136
|
-
],
|
|
137
|
-
collectCoverageFrom: [
|
|
138
|
-
`${srcDirectory}/**/*.${transpileWithBabel ? 'ts' : '?(m)js'}${
|
|
139
|
-
hasReact ? '?(x)' : ''
|
|
140
|
-
}`,
|
|
141
|
-
],
|
|
142
|
-
moduleFileExtensions: [
|
|
143
|
-
transpileWithBabel && 'ts',
|
|
144
|
-
transpileWithBabel && hasReact && 'tsx',
|
|
145
|
-
'js',
|
|
146
|
-
// 'jsx',
|
|
147
|
-
'json',
|
|
148
|
-
].filter(Boolean),
|
|
149
|
-
extensionsToTreatAsEsm: [
|
|
150
|
-
transpileWithBabel && '.ts',
|
|
151
|
-
transpileWithBabel && hasReact && '.tsx',
|
|
152
|
-
].filter(Boolean),
|
|
153
|
-
// transform: {
|
|
154
|
-
// [`^.+\\.ts${hasReact ? 'x?' : ''}$`]: 'babel-jest',
|
|
155
|
-
// },
|
|
156
|
-
});
|
|
157
|
-
delete pkg.jest.transform;
|
|
158
|
-
|
|
159
|
-
if (
|
|
160
|
-
babelEnvs.length === 0 ||
|
|
161
|
-
babelEnvs.some((env) => env.target === 'node')
|
|
162
|
-
) {
|
|
163
|
-
pkg.jest.testEnvironment = 'node';
|
|
106
|
+
packageUtils.addOrRemoveDevDependencies(
|
|
107
|
+
pkg,
|
|
108
|
+
enableForMonorepo || !globalTesting,
|
|
109
|
+
['pob-lcov-reporter', 'jest', '@types/jest'],
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
if (this.options.monorepo) {
|
|
113
|
+
delete pkg.jest;
|
|
114
|
+
packageUtils.addScripts(pkg, {
|
|
115
|
+
test: 'yarn workspaces foreach --parallel -Av run test',
|
|
116
|
+
});
|
|
164
117
|
} else {
|
|
165
|
-
|
|
118
|
+
const babelEnvs = pkg.pob.babelEnvs || [];
|
|
119
|
+
const transpileWithBabel = packageUtils.transpileWithBabel(pkg);
|
|
120
|
+
|
|
121
|
+
const shouldUseExperimentalVmModules =
|
|
122
|
+
pkg.type === 'module' || (transpileWithBabel && !inLerna);
|
|
123
|
+
|
|
124
|
+
const jestCommand = `${
|
|
125
|
+
shouldUseExperimentalVmModules
|
|
126
|
+
? 'NODE_OPTIONS=--experimental-vm-modules '
|
|
127
|
+
: ''
|
|
128
|
+
}jest`;
|
|
129
|
+
|
|
130
|
+
packageUtils.addScripts(pkg, {
|
|
131
|
+
test: jestCommand,
|
|
132
|
+
'test:watch': `${jestCommand} --watch`,
|
|
133
|
+
'generate:test-coverage': [
|
|
134
|
+
'rm -Rf docs/coverage/',
|
|
135
|
+
`NODE_ENV=production ${
|
|
136
|
+
transpileWithBabel ? 'BABEL_ENV=test ' : ''
|
|
137
|
+
}${jestCommand} --coverage --coverageReporters=pob-lcov-reporter --coverageDirectory=docs/coverage/`,
|
|
138
|
+
].join(' ; '),
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const hasReact = transpileWithBabel && packageUtils.hasReact(pkg);
|
|
142
|
+
const srcDirectory = transpileWithBabel ? 'src' : 'lib';
|
|
143
|
+
|
|
144
|
+
if (!pkg.jest) pkg.jest = {};
|
|
145
|
+
Object.assign(pkg.jest, {
|
|
146
|
+
cacheDirectory: './node_modules/.cache/jest',
|
|
147
|
+
testMatch: [
|
|
148
|
+
`<rootDir>/${srcDirectory}/**/__tests__/**/*.${
|
|
149
|
+
transpileWithBabel ? 'ts' : '?(m)js'
|
|
150
|
+
}${hasReact ? '?(x)' : ''}`,
|
|
151
|
+
`<rootDir>/${srcDirectory}/**/*.test.${
|
|
152
|
+
transpileWithBabel ? 'ts' : '?(m)js'
|
|
153
|
+
}${hasReact ? '?(x)' : ''}`,
|
|
154
|
+
],
|
|
155
|
+
collectCoverageFrom: [
|
|
156
|
+
`${srcDirectory}/**/*.${transpileWithBabel ? 'ts' : '?(m)js'}${
|
|
157
|
+
hasReact ? '?(x)' : ''
|
|
158
|
+
}`,
|
|
159
|
+
],
|
|
160
|
+
moduleFileExtensions: [
|
|
161
|
+
transpileWithBabel && 'ts',
|
|
162
|
+
transpileWithBabel && hasReact && 'tsx',
|
|
163
|
+
'js',
|
|
164
|
+
// 'jsx',
|
|
165
|
+
'json',
|
|
166
|
+
].filter(Boolean),
|
|
167
|
+
// transform: {
|
|
168
|
+
// [`^.+\\.ts${hasReact ? 'x?' : ''}$`]: 'babel-jest',
|
|
169
|
+
// },
|
|
170
|
+
});
|
|
171
|
+
delete pkg.jest.transform;
|
|
172
|
+
|
|
173
|
+
if (shouldUseExperimentalVmModules) {
|
|
174
|
+
pkg.jest.extensionsToTreatAsEsm = [
|
|
175
|
+
transpileWithBabel && '.ts',
|
|
176
|
+
transpileWithBabel && hasReact && '.tsx',
|
|
177
|
+
].filter(Boolean);
|
|
178
|
+
} else {
|
|
179
|
+
delete pkg.jest.extensionsToTreatAsEsm;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (
|
|
183
|
+
babelEnvs.length === 0 ||
|
|
184
|
+
babelEnvs.some((env) => env.target === 'node')
|
|
185
|
+
) {
|
|
186
|
+
pkg.jest.testEnvironment = 'node';
|
|
187
|
+
} else {
|
|
188
|
+
delete pkg.jest.testEnvironment;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (!transpileWithBabel) delete pkg.jest.transform;
|
|
166
192
|
}
|
|
167
|
-
|
|
168
|
-
if (!transpileWithBabel) delete pkg.jest.transform;
|
|
169
193
|
}
|
|
170
194
|
|
|
171
195
|
this.fs.writeJSON(this.destinationPath('package.json'), pkg);
|
|
@@ -194,19 +194,19 @@ export default class PobMonorepoGenerator extends Generator {
|
|
|
194
194
|
throw new Error('packages should not be empty');
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
this.composeWith('pob:
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
197
|
+
this.composeWith('pob:common:husky', {});
|
|
198
|
+
|
|
199
|
+
this.composeWith('pob:common:testing', {
|
|
200
|
+
monorepo: true,
|
|
201
|
+
enable: this.pobLernaConfig.testing,
|
|
201
202
|
testing: this.pobLernaConfig.testing,
|
|
202
|
-
|
|
203
|
-
documentation: this.pobLernaConfig.documentation,
|
|
204
|
-
|
|
203
|
+
typescript: this.pobLernaConfig.typescript,
|
|
204
|
+
documentation: !!this.pobLernaConfig.documentation,
|
|
205
|
+
codecov: this.pobLernaConfig.testing && this.pobLernaConfig.codecov,
|
|
206
|
+
ci: this.pobLernaConfig.ci,
|
|
205
207
|
packageManager: this.options.packageManager,
|
|
206
208
|
});
|
|
207
209
|
|
|
208
|
-
this.composeWith('pob:common:husky', {});
|
|
209
|
-
|
|
210
210
|
this.composeWith('pob:common:format-lint', {
|
|
211
211
|
monorepo: true,
|
|
212
212
|
documentation: this.pobLernaConfig.documentation,
|
|
@@ -152,19 +152,6 @@ export default class MonorepoLernaGenerator extends Generator {
|
|
|
152
152
|
|
|
153
153
|
packageUtils.removeDevDependencies(pkg, ['standard-version']);
|
|
154
154
|
|
|
155
|
-
const getPobConfig = (config) => ({
|
|
156
|
-
...(config &&
|
|
157
|
-
config.pob &&
|
|
158
|
-
(config.pob['pob-config'] || config.pob.lib || config.pob.app)),
|
|
159
|
-
});
|
|
160
|
-
// ynnub doesnt use babel but still have typescript
|
|
161
|
-
// const withTypescript = this.packagePaths.some((packagePath) =>
|
|
162
|
-
// this.fs.exists(this.destinationPath(`${packagePath}/tsconfig.json`)),
|
|
163
|
-
// );
|
|
164
|
-
const withTests = this.packagesConfig.some(
|
|
165
|
-
(config) => getPobConfig(config).testing,
|
|
166
|
-
);
|
|
167
|
-
|
|
168
155
|
const monorepoConfig = this.config.get('monorepo');
|
|
169
156
|
const packageManager = this.npm ? 'npm' : 'yarn';
|
|
170
157
|
const useYarnWorkspacesCommand =
|
|
@@ -205,14 +192,6 @@ export default class MonorepoLernaGenerator extends Generator {
|
|
|
205
192
|
),
|
|
206
193
|
);
|
|
207
194
|
|
|
208
|
-
packageUtils.addOrRemoveScripts(pkg, withTests, {
|
|
209
|
-
test: `${
|
|
210
|
-
useYarnWorkspacesCommand
|
|
211
|
-
? 'yarn workspaces foreach --parallel -Av run'
|
|
212
|
-
: 'lerna run --stream'
|
|
213
|
-
} test`,
|
|
214
|
-
});
|
|
215
|
-
|
|
216
195
|
packageUtils.addOrRemoveScripts(pkg, withBabel, {
|
|
217
196
|
build: `${
|
|
218
197
|
useYarnWorkspacesCommand
|
package/lib/utils/package.js
CHANGED
|
@@ -37,9 +37,6 @@ export const hasReact = (pkg) =>
|
|
|
37
37
|
(pkg.peerDependencies && pkg.peerDependencies.react)
|
|
38
38
|
);
|
|
39
39
|
|
|
40
|
-
export const hasJest = (pkg) =>
|
|
41
|
-
!!(pkg.devDependencies && pkg.devDependencies.jest);
|
|
42
|
-
|
|
43
40
|
export const sort = function sort(pkg) {
|
|
44
41
|
return sortPkg(pkg);
|
|
45
42
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pob",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0",
|
|
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": "^6.0.
|
|
66
|
+
"pob-dependencies": "^6.0.6",
|
|
67
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": "578f2d74ffe7819f88444604226014077a3ba869"
|
|
74
74
|
}
|