pob 9.7.1 → 9.8.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,58 @@
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.8.0](https://github.com/christophehurpeau/pob/compare/pob@9.7.4...pob@9.8.0) (2021-12-12)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **pob:** dont try release-please if release is disabled ([86d6edf](https://github.com/christophehurpeau/pob/commit/86d6edf3e84cf98c0605044e09fb994fb036a3cc))
12
+ * sort package after running yarn version update ([b9773f0](https://github.com/christophehurpeau/pob/commit/b9773f0ac08c857b87836cbb2a665557f652bffd))
13
+ * **deps:** update @pob/eslint-config to v48.0.6 ([#1137](https://github.com/christophehurpeau/pob/issues/1137)) ([999b411](https://github.com/christophehurpeau/pob/commit/999b411e0e4a1c0a47e3c8f23ca20694ca8f2451))
14
+
15
+
16
+ ### Features
17
+
18
+ * **pob:** add env in app gitignore ([148a02a](https://github.com/christophehurpeau/pob/commit/148a02a9437b638051b384c7bd61ce1195cae8aa))
19
+ * allow to configure resolveJsonModule and fix baseUrl in tsconfig for apps ([d68393f](https://github.com/christophehurpeau/pob/commit/d68393f9bf02598aa3638e21d2dc407b9b282d1b))
20
+ * **pob:** allow release-please in apps ([6d567c6](https://github.com/christophehurpeau/pob/commit/6d567c6ee49f4faa26d7ab23f042615134681158))
21
+ * **pob:** suggest to enable release-please ([f62e46c](https://github.com/christophehurpeau/pob/commit/f62e46c8fd9e5936b10790288b14f516e9d8e6d6))
22
+ * conditional publish in release workflow ([162c83e](https://github.com/christophehurpeau/pob/commit/162c83ed7875d7caeaef43169742eef8742825f5))
23
+
24
+
25
+
26
+
27
+
28
+ ## [9.7.4](https://github.com/christophehurpeau/pob/compare/pob@9.7.3...pob@9.7.4) (2021-12-12)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * no process.env.POB_GITHUB_TOKEN in ci ([8248c48](https://github.com/christophehurpeau/pob/commit/8248c48441d4c6cfea86367166159444f4711bb8))
34
+
35
+
36
+
37
+
38
+
39
+ ## [9.7.3](https://github.com/christophehurpeau/pob/compare/pob@9.7.2...pob@9.7.3) (2021-12-12)
40
+
41
+ **Note:** Version bump only for package pob
42
+
43
+
44
+
45
+
46
+
47
+ ## [9.7.2](https://github.com/christophehurpeau/pob/compare/pob@9.7.1...pob@9.7.2) (2021-12-12)
48
+
49
+
50
+ ### Bug Fixes
51
+
52
+ * **pob:** testing babel condition ([a468640](https://github.com/christophehurpeau/pob/commit/a4686400a2844d8930a77a201dea3d7f5f302384))
53
+
54
+
55
+
56
+
57
+
6
58
  ## [9.7.1](https://github.com/christophehurpeau/pob/compare/pob@9.7.0...pob@9.7.1) (2021-12-12)
7
59
 
8
60
 
@@ -1,3 +1,4 @@
1
+ import fs from 'fs';
1
2
  import Generator from 'yeoman-generator';
2
3
  import inLerna from '../../utils/inLerna.js';
3
4
  import inNpmLerna from '../../utils/inNpmLerna.js';
@@ -132,10 +133,12 @@ export default class PobAppGenerator extends Generator {
132
133
  dom: browser,
133
134
  jsx,
134
135
  updateOnly: this.options.updateOnly,
136
+ resolveJsonModule: true,
135
137
  baseUrl: (() => {
136
138
  if (
137
139
  this.appConfig.type === 'alp' ||
138
- this.appConfig.type === 'pobpack'
140
+ this.appConfig.type === 'pobpack' ||
141
+ this.appConfig.type === 'node'
139
142
  ) {
140
143
  return './src';
141
144
  }
@@ -168,6 +171,21 @@ export default class PobAppGenerator extends Generator {
168
171
  ignorePaths: ignorePaths.join('\n'),
169
172
  });
170
173
 
174
+ this.composeWith('pob:common:release', {
175
+ enable: !inLerna && this.appConfig.testing && this.appConfig.ci,
176
+ withBabel: babel,
177
+ documentation: false,
178
+ updateOnly: this.options.updateOnly,
179
+ });
180
+
181
+ // only for gitignore
182
+ if (this.fs.exists('.env.example')) {
183
+ ignorePaths.push('/.env*', '!/.env.example');
184
+ }
185
+ if (fs.existsSync('private_key')) {
186
+ ignorePaths.push('/private_key');
187
+ }
188
+
171
189
  this.composeWith('pob:core:gitignore', {
172
190
  root: !inLerna || inLerna.root,
173
191
  documentation: false,
@@ -2,7 +2,7 @@ import Generator from 'yeoman-generator';
2
2
  import inLerna from '../../../utils/inLerna.js';
3
3
  import * as packageUtils from '../../../utils/package.js';
4
4
 
5
- export default class LibReleaseGenerator extends Generator {
5
+ export default class CommonReleaseGenerator extends Generator {
6
6
  constructor(args, opts) {
7
7
  super(args, opts);
8
8
 
@@ -24,16 +24,41 @@ export default class LibReleaseGenerator extends Generator {
24
24
  required: true,
25
25
  desc: 'Include documentation',
26
26
  });
27
- }
28
27
 
29
- writing() {
30
- const pkg = this.fs.readJSON(this.destinationPath('package.json'));
28
+ this.option('updateOnly', {
29
+ type: Boolean,
30
+ required: false,
31
+ defaults: false,
32
+ desc: 'Avoid asking questions',
33
+ });
34
+ }
31
35
 
32
- const isReleasePleaseEnabled =
36
+ async prompting() {
37
+ this.isReleasePleaseEnabled =
33
38
  this.options.enable &&
34
39
  this.fs.exists(
35
40
  this.destinationPath('.github/workflows/release-please.yml'),
36
41
  );
42
+
43
+ if (
44
+ this.options.enable &&
45
+ !process.env.CI &&
46
+ !this.isReleasePleaseEnabled
47
+ ) {
48
+ const { enableReleasePlease } = await this.prompt({
49
+ type: 'confirm',
50
+ name: 'enableReleasePlease',
51
+ message: 'Would you like to enable release please ?',
52
+ default: true,
53
+ });
54
+ this.isReleasePleaseEnabled = enableReleasePlease;
55
+ }
56
+ }
57
+
58
+ writing() {
59
+ const pkg = this.fs.readJSON(this.destinationPath('package.json'));
60
+
61
+ const isReleasePleaseEnabled = this.isReleasePleaseEnabled;
37
62
  const isStandardVersionEnabled =
38
63
  this.options.enable && !isReleasePleaseEnabled;
39
64
 
@@ -79,7 +104,7 @@ export default class LibReleaseGenerator extends Generator {
79
104
  this.destinationPath('.github/workflows/release-please.yml'),
80
105
  {
81
106
  isLerna: !!inLerna,
82
- // publish: ...
107
+ publish: !pkg.private,
83
108
  },
84
109
  );
85
110
  }
@@ -27,8 +27,10 @@ jobs:
27
27
  node-version: 14
28
28
  registry-url: 'https://registry.npmjs.org'
29
29
  if: ${{ steps.release.outputs.release_created }}
30
+ <% if (publish) { -%>
30
31
 
31
32
  - run: npm publish
32
33
  env:
33
34
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
34
35
  if: ${{ steps.release.outputs.release_created }}
36
+ <% } -%>
@@ -83,7 +83,9 @@ export default class CommonTestingGenerator extends Generator {
83
83
  const yoConfigPobMonorepo = inLerna && inLerna.pobMonorepoConfig;
84
84
  const globalTesting = yoConfigPobMonorepo && yoConfigPobMonorepo.testing;
85
85
  const enableForMonorepo = this.options.monorepo && globalTesting;
86
- const transpileWithBabel = yoConfigPobMonorepo.typescript;
86
+ const transpileWithBabel = this.options.monorepo
87
+ ? yoConfigPobMonorepo.typescript
88
+ : pkg.pob && pkg.pob.babelEnvs && pkg.pob.babelEnvs.length > 0;
87
89
 
88
90
  if (!this.options.enable) {
89
91
  packageUtils.removeDevDependencies(pkg, ['jest', '@types/jest']);
@@ -32,6 +32,12 @@ export default class CommonTypescriptGenerator extends Generator {
32
32
  desc: 'baseUrl option',
33
33
  });
34
34
 
35
+ this.option('resolveJsonModule', {
36
+ type: Boolean,
37
+ defaults: false,
38
+ desc: 'resolveJsonModule option',
39
+ });
40
+
35
41
  this.option('builddefs', {
36
42
  type: Boolean,
37
43
  defaults: true,
@@ -116,6 +122,7 @@ export default class CommonTypescriptGenerator extends Generator {
116
122
  jsx,
117
123
  dom,
118
124
  baseUrl: this.options.baseUrl,
125
+ resolveJsonModule: this.options.resolveJsonModule,
119
126
  },
120
127
  );
121
128
  if (
@@ -31,6 +31,9 @@
31
31
  "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
32
32
  "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
33
33
  "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
34
+ <% if (resolveJsonModule) { -%>
35
+ "resolveJsonModule": <%= resolveJsonModule %>,
36
+ <% } -%>
34
37
  "baseUrl": "<%= baseUrl %>"<% if (monorepoPackageNames) { %>,<% } %><%= ' '.slice(0, -(baseUrl.length + (monorepoPackageNames ? 1 : 0))) %>/* Base directory to resolve non-absolute module names. */
35
38
  <% if (monorepoPackageNames && monorepoPackageNames.length !== 0) { -%>
36
39
 
@@ -67,7 +67,7 @@ export default class CoreGitGithubGenerator extends Generator {
67
67
  desc: 'repo name',
68
68
  });
69
69
 
70
- if (!GITHUB_TOKEN) {
70
+ if (!GITHUB_TOKEN && process.env.CI !== 'true') {
71
71
  throw new Error(
72
72
  'Missing POB_GITHUB_TOKEN. Create one with https://github.com/settings/tokens/new?scopes=repo&description=POB%20Generator and add it in your env variables.',
73
73
  );
@@ -75,6 +75,7 @@ export default class CoreGitGithubGenerator extends Generator {
75
75
  }
76
76
 
77
77
  async end() {
78
+ if (!GITHUB_TOKEN) return;
78
79
  const owner = this.options.gitHostAccount;
79
80
  const repo = this.options.repoName;
80
81
 
@@ -1,6 +1,7 @@
1
1
  import fs from 'fs';
2
2
  import yarnParsers from '@yarnpkg/parsers';
3
3
  import Generator from 'yeoman-generator';
4
+ import ensureJsonFileFormatted from '../../../utils/ensureJsonFileFormatted.js';
4
5
  import inLerna from '../../../utils/inLerna.js';
5
6
  import * as packageUtils from '../../../utils/package.js';
6
7
  import { writeAndFormat } from '../../../utils/writeAndFormat.js';
@@ -40,6 +41,7 @@ export default class CoreYarnGenerator extends Generator {
40
41
  this.spawnCommandSync('yarn', ['set', 'version', 'latest']);
41
42
  } else {
42
43
  this.spawnCommandSync('yarn', ['set', 'version', 'latest']);
44
+ ensureJsonFileFormatted(this.destinationPath('package.json'));
43
45
  }
44
46
  }
45
47
  }
@@ -275,10 +275,11 @@ export default class PobLibGenerator extends Generator {
275
275
  codecov: this.pobjson.testing && this.pobjson.testing.codecov,
276
276
  });
277
277
 
278
- this.composeWith('pob:lib:release', {
278
+ this.composeWith('pob:common:release', {
279
279
  enable: !inLerna && this.pobjson.testing && this.pobjson.testing.ci,
280
280
  withBabel: babelEnvs.length > 0,
281
281
  documentation: !!this.pobjson.documentation,
282
+ updateOnly: this.options.updateOnly,
282
283
  });
283
284
 
284
285
  // must be after doc, testing
package/lib/pob.js CHANGED
@@ -12,6 +12,7 @@ import CommonBabelGenerator from './generators/common/babel/CommonBabelGenerator
12
12
  import CommonLintGenerator from './generators/common/format-lint/CommonLintGenerator.js';
13
13
  import CommonHuskyGenerator from './generators/common/husky/CommonHuskyGenerator.js';
14
14
  import CommonRemoveOldDependenciesGenerator from './generators/common/old-dependencies/CommonRemoveOldDependenciesGenerator.js';
15
+ import CommonReleaseGenerator from './generators/common/release/CommonReleaseGenerator.js';
15
16
  import CommonTestingGenerator from './generators/common/testing/CommonTestingGenerator.js';
16
17
  import CommonTypescriptGenerator from './generators/common/typescript/CommonTypescriptGenerator.js';
17
18
  import CoreCIGenerator from './generators/core/ci/CoreCIGenerator.js';
@@ -29,7 +30,6 @@ import CoreYarnGenerator from './generators/core/yarn/CoreYarnGenerator.js';
29
30
  import PobLibGenerator from './generators/lib/PobLibGenerator.js';
30
31
  import LibDocGenerator from './generators/lib/doc/LibDocGenerator.js';
31
32
  import LibReadmeGenerator from './generators/lib/readme/LibReadmeGenerator.js';
32
- import LibReleaseGenerator from './generators/lib/release/LibReleaseGenerator.js';
33
33
  import PobMonorepoGenerator from './generators/monorepo/PobMonorepoGenerator.js';
34
34
  import MonorepoLernaGenerator from './generators/monorepo/lerna/MonorepoLernaGenerator.js';
35
35
  import MonorepoTypescriptGenerator from './generators/monorepo/typescript/MonorepoTypescriptGenerator.js';
@@ -103,6 +103,11 @@ env.registerStub(
103
103
  'pob:common:remove-old-dependencies',
104
104
  `${__dirname}/generators/common/old-dependencies/CommonRemoveOldDependenciesGenerator.js`,
105
105
  );
106
+ env.registerStub(
107
+ CommonReleaseGenerator,
108
+ 'pob:common:release',
109
+ `${__dirname}/generators/common/release/CommonReleaseGenerator.js`,
110
+ );
106
111
  env.registerStub(
107
112
  CommonTestingGenerator,
108
113
  'pob:common:testing',
@@ -188,11 +193,6 @@ env.registerStub(
188
193
  'pob:lib:readme',
189
194
  `${__dirname}/generators/lib/readme/LibReadmeGenerator.js`,
190
195
  );
191
- env.registerStub(
192
- LibReleaseGenerator,
193
- 'pob:lib:release',
194
- `${__dirname}/generators/lib/release/LibReleaseGenerator.js`,
195
- );
196
196
  env.registerStub(
197
197
  PobMonorepoGenerator,
198
198
  'pob:monorepo',
@@ -1,13 +1,17 @@
1
1
  import fs from 'fs';
2
+ import sortPkg from '@pob/sort-pkg';
2
3
  import prettier from 'prettier';
3
4
 
4
5
  export default function ensureJsonFileFormatted(path) {
5
6
  try {
6
- const pkgJson = fs.readFileSync(path, 'utf-8');
7
- const formattedPkg = prettier.format(pkgJson, {
7
+ let contentJson = fs.readFileSync(path, 'utf-8');
8
+ if (path === 'package.json' || path.endsWith('/package.json')) {
9
+ contentJson = JSON.stringify(sortPkg(JSON.parse(contentJson)), null, 2);
10
+ }
11
+ const formattedPkg = prettier.format(contentJson, {
8
12
  filepath: path,
9
13
  });
10
- if (pkgJson !== formattedPkg) {
14
+ if (contentJson !== formattedPkg) {
11
15
  console.warn(`formatted json file ${path}`);
12
16
  fs.writeFileSync(path, formattedPkg);
13
17
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "9.7.1",
3
+ "version": "9.8.0",
4
4
  "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
5
5
  "keywords": [
6
6
  "skeleton"
@@ -42,8 +42,8 @@
42
42
  "@lerna/package-graph": "^4.0.0",
43
43
  "@lerna/project": "^4.0.0",
44
44
  "@pob/eslint-config": "48.0.5",
45
- "@pob/eslint-config-typescript": "48.0.5",
46
- "@pob/eslint-config-typescript-react": "48.0.5",
45
+ "@pob/eslint-config-typescript": "48.0.6",
46
+ "@pob/eslint-config-typescript-react": "48.0.6",
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,12 +61,12 @@
61
61
  "mem-fs-editor": "8.1.2",
62
62
  "minimist-argv": "^1.1.0",
63
63
  "parse-author": "^2.0.0",
64
- "pob-dependencies": "6.3.0",
64
+ "pob-dependencies": "6.3.3",
65
65
  "prettier": "2.5.1",
66
66
  "semver": "^7.3.4",
67
67
  "update-notifier": "^5.0.1",
68
68
  "yeoman-environment": "^3.5.1",
69
69
  "yeoman-generator": "^5.4.0"
70
70
  },
71
- "gitHead": "dd06ee4c68f029bbd1764e3564d91ba6667a415f"
71
+ "gitHead": "1c94efb8acec1f95aeeea9b673c22c56497b9fcd"
72
72
  }