pob 9.4.0 → 9.5.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 CHANGED
@@ -3,6 +3,18 @@
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.5.0](https://github.com/christophehurpeau/pob/compare/pob@9.4.0...pob@9.5.0) (2021-12-11)
7
+
8
+
9
+ ### Features
10
+
11
+ * **pob-babel:** include plugin-run as export ([9a4515d](https://github.com/christophehurpeau/pob/commit/9a4515d26d816df6f257a90647046c7da5d83a16))
12
+ * enable global testing in monorepo ([178775b](https://github.com/christophehurpeau/pob/commit/178775bb7fc971bc6a9712b105623508f739ba7b))
13
+
14
+
15
+
16
+
17
+
6
18
  # [9.4.0](https://github.com/christophehurpeau/pob/compare/pob@9.3.1...pob@9.4.0) (2021-12-11)
7
19
 
8
20
 
@@ -692,11 +692,7 @@ export default class CommonBabelGenerator extends Generator {
692
692
 
693
693
  /* pob-babel config */
694
694
 
695
- packageUtils.addOrRemoveDevDependencies(
696
- pkg,
697
- useBabel && this.options.isApp,
698
- ['@rollup/plugin-run'],
699
- );
695
+ packageUtils.removeDevDependencies(pkg, ['@rollup/plugin-run']);
700
696
 
701
697
  this.fs.delete('rollup.config.js');
702
698
  if (useBabel) {
@@ -727,7 +723,7 @@ export default class CommonBabelGenerator extends Generator {
727
723
  );
728
724
  }
729
725
 
730
- if (useBabel && this.options.testing) {
726
+ if (useBabel && this.options.testing && !inLerna) {
731
727
  // cjs for jest compat
732
728
  this.fs.copyTpl(
733
729
  this.templatePath('babel.config.cjs.ejs'),
@@ -1,4 +1,4 @@
1
- import run from '@rollup/plugin-run';
1
+ import run from 'pob-babel/plugin-run';
2
2
  import createRollupConfig from 'pob-babel/createRollupConfig.js';
3
3
 
4
4
  const watch = process.env.ROLLUP_WATCH === 'true';
@@ -79,10 +79,8 @@ export default class CommonTestingGenerator extends Generator {
79
79
  'babel-jest',
80
80
  ]);
81
81
 
82
- // const yoConfigPobMonorepo = inLerna && inLerna.pobMonorepoConfig;
83
- // const globalTesting = yoConfigPobMonorepo && yoConfigPobMonorepo.testing;
84
- const globalTesting = false;
85
-
82
+ const yoConfigPobMonorepo = inLerna && inLerna.pobMonorepoConfig;
83
+ const globalTesting = yoConfigPobMonorepo && yoConfigPobMonorepo.testing;
86
84
  const enableForMonorepo = this.options.monorepo && globalTesting;
87
85
 
88
86
  if (!this.options.enable) {
@@ -109,11 +107,54 @@ export default class CommonTestingGenerator extends Generator {
109
107
  ['pob-lcov-reporter', 'jest', '@types/jest'],
110
108
  );
111
109
 
112
- if (this.options.monorepo) {
110
+ if (this.options.monorepo && !globalTesting) {
113
111
  delete pkg.jest;
114
112
  packageUtils.addScripts(pkg, {
115
113
  test: 'yarn workspaces foreach --parallel -Av run test',
116
114
  });
115
+ } else if (this.options.monorepo) {
116
+ const shouldUseExperimentalVmModules = pkg.type === 'module';
117
+
118
+ const jestCommand = `${
119
+ shouldUseExperimentalVmModules
120
+ ? 'NODE_OPTIONS=--experimental-vm-modules '
121
+ : ''
122
+ }jest`;
123
+ const transpileWithBabel = yoConfigPobMonorepo.typescript;
124
+
125
+ packageUtils.addScripts(pkg, {
126
+ test: jestCommand,
127
+ 'generate:test-coverage': [
128
+ 'rm -Rf docs/coverage/',
129
+ `NODE_ENV=production ${
130
+ transpileWithBabel ? 'BABEL_ENV=test ' : ''
131
+ }${jestCommand} --coverage --coverageReporters=pob-lcov-reporter --coverageDirectory=docs/coverage/`,
132
+ ].join(' ; '),
133
+ });
134
+
135
+ if (!pkg.jest) pkg.jest = {};
136
+ Object.assign(pkg.jest, {
137
+ cacheDirectory: './node_modules/.cache/jest',
138
+ testEnvironment: 'node',
139
+ });
140
+
141
+ const hasReact = false;
142
+
143
+ if (shouldUseExperimentalVmModules) {
144
+ pkg.jest.extensionsToTreatAsEsm = [
145
+ transpileWithBabel && '.ts',
146
+ transpileWithBabel && hasReact && '.tsx',
147
+ ].filter(Boolean);
148
+ } else {
149
+ delete pkg.jest.extensionsToTreatAsEsm;
150
+ }
151
+ } else if (globalTesting) {
152
+ delete pkg.jest;
153
+ if (pkg.scripts) {
154
+ delete pkg.scripts.test;
155
+ delete pkg.scripts['generate:test-coverage'];
156
+ delete pkg.scripts['test:watch'];
157
+ }
117
158
  } else {
118
159
  const babelEnvs = pkg.pob.babelEnvs || [];
119
160
  const transpileWithBabel = packageUtils.transpileWithBabel(pkg);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "9.4.0",
3
+ "version": "9.5.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.6",
66
+ "pob-dependencies": "^6.1.0",
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": "578f2d74ffe7819f88444604226014077a3ba869"
73
+ "gitHead": "48b073ef8e253234b0b08f69a250befe044dcc58"
74
74
  }