pob 10.1.0 → 10.2.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,23 @@
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
+ # [10.2.0](https://github.com/christophehurpeau/pob/compare/pob@10.1.0...pob@10.2.0) (2022-02-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **deps:** update dependency @pob/eslint-config-typescript-react to v49.0.1 ([#1204](https://github.com/christophehurpeau/pob/issues/1204)) ([5fc0b39](https://github.com/christophehurpeau/pob/commit/5fc0b39970645a99188f8a74fb473535a6d38461))
12
+ * **pob:** create eslint specific tsconfig ([fb80eac](https://github.com/christophehurpeau/pob/commit/fb80eaccce5c48dfe4af98c411ef3839c11f3be8))
13
+
14
+
15
+ ### Features
16
+
17
+ * build directory for apps and alp-rollup-plugin-config ([0d57816](https://github.com/christophehurpeau/pob/commit/0d57816fbe0ac0a86d0bf7204aed42c3313366df))
18
+
19
+
20
+
21
+
22
+
6
23
  # [10.1.0](https://github.com/christophehurpeau/pob/compare/pob@10.0.0...pob@10.1.0) (2022-02-12)
7
24
 
8
25
 
@@ -1,3 +1,4 @@
1
+ import { execSync } from 'child_process';
1
2
  import Generator from 'yeoman-generator';
2
3
  import inLerna from '../../utils/inLerna.js';
3
4
  import inNpmLerna from '../../utils/inNpmLerna.js';
@@ -5,7 +6,7 @@ import * as packageUtils from '../../utils/package.js';
5
6
  import { appIgnorePaths } from './ignorePaths.js';
6
7
 
7
8
  const appsWithTypescript = ['alp', 'next.js', 'pobpack'];
8
- const appsWithNode = ['alp', 'next.js'];
9
+ const appsWithBrowser = ['alp', 'next.js'];
9
10
 
10
11
  export default class PobAppGenerator extends Generator {
11
12
  constructor(args, opts) {
@@ -66,7 +67,7 @@ export default class PobAppGenerator extends Generator {
66
67
  name: 'type',
67
68
  message: 'What kind of app is this ?',
68
69
  default: (config && config.type) || 'alp',
69
- choices: ['alp', 'pobpack', 'next.js', 'node', 'other'],
70
+ choices: ['alp', 'pobpack', 'next.js', 'node', 'alp-node', 'other'],
70
71
  },
71
72
  {
72
73
  type: 'confirm',
@@ -98,18 +99,26 @@ export default class PobAppGenerator extends Generator {
98
99
  },
99
100
  ]);
100
101
 
102
+ execSync(
103
+ `rm -Rf ${['lib-*', 'coverage', 'docs', 'dist']
104
+ .filter(Boolean)
105
+ .join(' ')}`,
106
+ );
107
+
101
108
  this.config.set('app', this.appConfig);
102
109
  this.config.save();
103
110
  }
104
111
 
105
112
  default() {
106
- if (this.appConfig.type === 'node') {
113
+ if (this.appConfig.type === 'node' || this.appConfig.type === 'alp-node') {
107
114
  this.composeWith('pob:common:babel', {
108
115
  updateOnly: this.options.updateOnly,
109
116
  isApp: true,
117
+ useAppConfig: this.appConfig.type === 'alp-node',
110
118
  testing: this.appConfig.testing,
111
119
  documentation: false,
112
120
  fromPob: this.options.fromPob,
121
+ buildDirectory: 'build',
113
122
  });
114
123
  }
115
124
 
@@ -123,7 +132,7 @@ export default class PobAppGenerator extends Generator {
123
132
  const babel =
124
133
  babelEnvs.length > 0 || appsWithTypescript.includes(this.appConfig.type);
125
134
  const node = true;
126
- const browser = appsWithNode.includes(this.appConfig.type);
135
+ const browser = appsWithBrowser.includes(this.appConfig.type);
127
136
  const jsx =
128
137
  babelEnvs.length > 0 && pkg.pob.jsx !== undefined
129
138
  ? pkg.pob.jsx
@@ -146,6 +155,7 @@ export default class PobAppGenerator extends Generator {
146
155
  this.appConfig.type === 'alp' ||
147
156
  this.appConfig.type === 'pobpack' ||
148
157
  this.appConfig.type === 'node' ||
158
+ this.appConfig.type === 'alp-node' ||
149
159
  this.appConfig.type === 'next.js'
150
160
  ) {
151
161
  return './src';
@@ -179,6 +189,7 @@ export default class PobAppGenerator extends Generator {
179
189
  packageManager: this.options.packageManager,
180
190
  yarnNodeLinker: this.options.yarnNodeLinker,
181
191
  ignorePaths: ignorePaths.join('\n'),
192
+ buildDirectory: 'build',
182
193
  });
183
194
 
184
195
  this.composeWith('pob:common:release', {
@@ -2,6 +2,7 @@ export const appIgnorePaths = {
2
2
  alp: (config) => ['# alp paths', '/build', '/public', '/data'],
3
3
  'next.js': (config) => ['# next.js paths', '/.next', '/out', '/build'],
4
4
  pobpack: (config) => ['/build', '/public'],
5
- node: (config) => ['/dist'],
5
+ node: (config) => ['/build'],
6
+ 'alp-node': (config) => ['/build'],
6
7
  other: (config) => [],
7
8
  };
@@ -2,6 +2,7 @@ import fs from 'fs';
2
2
  import semver from 'semver';
3
3
  import Generator from 'yeoman-generator';
4
4
  import * as packageUtils from '../../../utils/package.js';
5
+ import { copyAndFormatTpl } from '../../../utils/writeAndFormat.js';
5
6
 
6
7
  export default class CommonBabelGenerator extends Generator {
7
8
  constructor(args, opts) {
@@ -32,6 +33,18 @@ export default class CommonBabelGenerator extends Generator {
32
33
  required: false,
33
34
  defaults: false,
34
35
  });
36
+
37
+ this.option('useAppConfig', {
38
+ type: Boolean,
39
+ required: false,
40
+ defaults: false,
41
+ });
42
+
43
+ this.option('buildDirectory', {
44
+ type: String,
45
+ required: false,
46
+ defaults: 'dist',
47
+ });
35
48
  }
36
49
 
37
50
  initializing() {
@@ -271,7 +284,7 @@ export default class CommonBabelGenerator extends Generator {
271
284
  if (this.options.isApp) {
272
285
  packageUtils.removeScripts(['watch']);
273
286
  packageUtils.addOrRemoveScripts(pkg, useBabel, {
274
- 'clean:build': 'rm -Rf dist',
287
+ 'clean:build': `rm -Rf ${this.options.buildDirectory}`,
275
288
  build: 'yarn clean:build && rollup --config rollup.config.mjs',
276
289
  start: 'yarn clean:build && rollup --config rollup.config.mjs --watch',
277
290
  clean: 'yarn clean:build',
@@ -279,7 +292,7 @@ export default class CommonBabelGenerator extends Generator {
279
292
  } else {
280
293
  packageUtils.removeScripts(['start']);
281
294
  packageUtils.addOrRemoveScripts(pkg, useBabel, {
282
- 'clean:build': 'rm -Rf dist',
295
+ 'clean:build': `rm -Rf ${this.options.buildDirectory}`,
283
296
  build: 'yarn clean:build && rollup --config rollup.config.mjs',
284
297
  watch: 'yarn clean:build && rollup --config rollup.config.mjs --watch',
285
298
  clean: 'yarn clean:build',
@@ -712,13 +725,22 @@ export default class CommonBabelGenerator extends Generator {
712
725
  /* pob-babel config */
713
726
 
714
727
  packageUtils.removeDevDependencies(pkg, ['@rollup/plugin-run']);
728
+ packageUtils.addOrRemoveDependencies(
729
+ pkg,
730
+ useBabel && this.options.isApp && this.options.useAppConfig,
731
+ ['alp-rollup-plugin-config'],
732
+ );
715
733
 
716
734
  this.fs.delete('rollup.config.js');
717
735
  if (useBabel) {
718
736
  if (this.options.isApp) {
719
- this.fs.copy(
737
+ copyAndFormatTpl(
738
+ this.fs,
720
739
  this.templatePath('app.rollup.config.mjs.ejs'),
721
740
  this.destinationPath('rollup.config.mjs'),
741
+ {
742
+ config: this.options.useAppConfig,
743
+ },
722
744
  );
723
745
  } else {
724
746
  this.fs.copy(
@@ -1,3 +1,6 @@
1
+ <% if (config) { -%>
2
+ import config from 'alp-rollup-plugin-config';
3
+ <% } -%>
1
4
  import createRollupConfig from 'pob-babel/createRollupConfig.js';
2
5
  import run from 'pob-babel/plugin-run.cjs';
3
6
 
@@ -5,5 +8,12 @@ const watch = process.env.ROLLUP_WATCH === 'true';
5
8
 
6
9
  export default createRollupConfig({
7
10
  cwd: new URL('.', import.meta.url).pathname,
8
- plugins: [watch && run({ execArgv: ['--enable-source-maps'] })],
11
+ outDirectory: 'build',
12
+ plugins: [
13
+ <% if (config) { -%>
14
+ config({
15
+ targets: [{ src: 'src/config/**/*.yml' }],
16
+ }),
17
+ <% } -%>
18
+ watch && run({ execArgv: ['--enable-source-maps'] })],
9
19
  });
@@ -78,6 +78,12 @@ export default class CommonLintGenerator extends Generator {
78
78
  defaults: 'node-modules',
79
79
  desc: 'Defines what linker should be used for installing Node packages (useful to enable the node-modules plugin), one of: pnp, node-modules.',
80
80
  });
81
+
82
+ this.option('buildDirectory', {
83
+ type: String,
84
+ required: false,
85
+ defaults: 'dist',
86
+ });
81
87
  }
82
88
 
83
89
  writing() {
@@ -396,7 +402,7 @@ export default class CommonLintGenerator extends Generator {
396
402
  }
397
403
 
398
404
  if ((!inLerna || !inLerna.root) && useBabel) {
399
- ignorePatterns.add('/dist', '/test');
405
+ ignorePatterns.add(`/${this.options.buildDirectory}`, '/test');
400
406
  }
401
407
  if (inLerna && inLerna.root && this.options.typescript) {
402
408
  ignorePatterns.add('/rollup.config.mjs');
@@ -405,7 +411,7 @@ export default class CommonLintGenerator extends Generator {
405
411
  if (this.options.ignorePaths) {
406
412
  this.options.ignorePaths
407
413
  .split('\n')
408
- .filter((path) => path !== '/dist' && path)
414
+ .filter((path) => path !== `/${this.options.buildDirectory}` && path)
409
415
  .forEach((ignorePath) => {
410
416
  if (ignorePath.startsWith('#')) return;
411
417
  ignorePatterns.add(ignorePath);
@@ -38,12 +38,12 @@ function updateParserAndPlugins(
38
38
 
39
39
  if (!globalEslint) {
40
40
  config.parserOptions = {
41
- project: './tsconfig.json',
41
+ project: './tsconfig.eslint.json',
42
42
  createDefaultProgram: true, // fix for lint-staged
43
43
  };
44
44
  } else {
45
45
  config.parserOptions = {
46
- project: `${relativePath}/tsconfig.json`,
46
+ project: `${relativePath}/tsconfig.eslint.json`,
47
47
  };
48
48
  }
49
49
  } else {
@@ -73,6 +73,7 @@ export default class CommonTypescriptGenerator extends Generator {
73
73
  );
74
74
 
75
75
  const tsconfigPath = this.destinationPath('tsconfig.json');
76
+ const tsconfigEslintPath = this.destinationPath('tsconfig.eslint.json');
76
77
  const tsconfigBuildPath = this.destinationPath('tsconfig.build.json');
77
78
  if (this.options.enable) {
78
79
  const { jsx, dom } = this.options;
@@ -146,6 +147,12 @@ export default class CommonTypescriptGenerator extends Generator {
146
147
  resolveJsonModule: this.options.resolveJsonModule,
147
148
  },
148
149
  );
150
+ copyAndFormatTpl(
151
+ this.fs,
152
+ this.templatePath('tsconfig.eslint.json.ejs'),
153
+ tsconfigEslintPath,
154
+ {},
155
+ );
149
156
  if (
150
157
  this.options.builddefs // &&
151
158
  // (!composite || monorepoPackageNames.length !== 0)
@@ -168,6 +175,7 @@ export default class CommonTypescriptGenerator extends Generator {
168
175
  } else {
169
176
  if (pkg.scripts) delete pkg.scripts.tsc;
170
177
  this.fs.delete(tsconfigPath);
178
+ this.fs.delete(tsconfigEslintPath);
171
179
  this.fs.delete(tsconfigBuildPath);
172
180
  }
173
181
 
@@ -0,0 +1,7 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+
4
+ "compilerOptions": {
5
+ "noEmit": true,
6
+ }
7
+ }
@@ -31,6 +31,17 @@ const hasDist = (packages, configs) =>
31
31
  ),
32
32
  );
33
33
 
34
+ const hasBuild = (packages, configs) =>
35
+ configs.some(
36
+ (config, index) =>
37
+ !!(
38
+ config &&
39
+ config.project &&
40
+ config.project.type === 'app' &&
41
+ config.app.type === 'alp-node'
42
+ ),
43
+ );
44
+
34
45
  export default class PobMonorepoGenerator extends Generator {
35
46
  constructor(args, opts) {
36
47
  super(args, opts);
@@ -206,7 +217,12 @@ export default class PobMonorepoGenerator extends Generator {
206
217
  packageManager: this.options.packageManager,
207
218
  yarnNodeLinker: this.options.yarnNodeLinker,
208
219
  appTypes: JSON.stringify(getAppTypes(this.packageConfigs)),
209
- ignorePaths: hasDist(this.packages, this.packageConfigs) ? '/dist' : '',
220
+ ignorePaths: [
221
+ hasDist(this.packages, this.packageConfigs) && '/dist',
222
+ hasBuild(this.packages, this.packageConfigs) && '/build',
223
+ ]
224
+ .filter(Boolean)
225
+ .join('\n'),
210
226
  });
211
227
 
212
228
  this.composeWith('pob:lib:doc', {
@@ -281,7 +297,7 @@ export default class PobMonorepoGenerator extends Generator {
281
297
  }
282
298
  packageUtils.addOrRemoveScripts(pkg, rollupConfigs.length > 0, {
283
299
  'clean:build': `(${pkg.workspaces
284
- .map((workspaces) => `rm -Rf ${workspaces}/dist`)
300
+ .map((workspaces) => `rm -Rf ${workspaces}/dist ${workspaces}/build`)
285
301
  .join(' && ')}) || true`,
286
302
  build: 'yarn clean:build && rollup --config rollup.config.mjs',
287
303
  watch: 'yarn clean:build && rollup --config rollup.config.mjs --watch',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "10.1.0",
3
+ "version": "10.2.0",
4
4
  "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
5
5
  "keywords": [
6
6
  "skeleton"
@@ -43,7 +43,7 @@
43
43
  "@lerna/project": "^4.0.0",
44
44
  "@pob/eslint-config": "49.0.0",
45
45
  "@pob/eslint-config-typescript": "49.0.0",
46
- "@pob/eslint-config-typescript-react": "49.0.0",
46
+ "@pob/eslint-config-typescript-react": "49.0.1",
47
47
  "@pob/sort-eslint-config": "^3.0.1",
48
48
  "@pob/sort-object": "^4.0.1",
49
49
  "@pob/sort-pkg": "^4.0.1",
@@ -61,11 +61,11 @@
61
61
  "mem-fs-editor": "9.4.0",
62
62
  "minimist-argv": "^1.1.0",
63
63
  "parse-author": "^2.0.0",
64
- "pob-dependencies": "6.14.0",
64
+ "pob-dependencies": "6.15.0",
65
65
  "prettier": "2.5.1",
66
66
  "semver": "^7.3.4",
67
67
  "yeoman-environment": "^3.5.1",
68
68
  "yeoman-generator": "^5.4.0"
69
69
  },
70
- "gitHead": "a2c45c96006ec7d270c9d25386055411985932e6"
70
+ "gitHead": "0652ebee362a0e15f2d0cc1f936e461c7e32effd"
71
71
  }