pob 14.4.2 → 14.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
@@ -1,8 +1,42 @@
1
- # Change Log
1
+ # Changelog
2
2
 
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
+ ## [14.5.0](https://github.com/christophehurpeau/pob/compare/pob@14.4.2...pob@14.5.0) (2023-11-05)
7
+
8
+
9
+ ### Features
10
+
11
+ * add option omitVersionInFileName ([b599330](https://github.com/christophehurpeau/pob/commit/b599330cb8c077a9dd412066f6aa843b0e999f4e))
12
+ * configure and use yarn 4 ([b272bd1](https://github.com/christophehurpeau/pob/commit/b272bd18df2291e30b5aa062af24547880b3bde0))
13
+ * **deps:** update dependency eslint to v8.52.0 ([#1828](https://github.com/christophehurpeau/pob/issues/1828)) ([d331dda](https://github.com/christophehurpeau/pob/commit/d331ddaad56f5ed0e119c356842192964bf89641))
14
+ * **deps:** update dependency eslint to v8.53.0 ([#1836](https://github.com/christophehurpeau/pob/issues/1836)) ([71e2bcc](https://github.com/christophehurpeau/pob/commit/71e2bccf96bef05db3c4be3e415fd5d20db63a5c))
15
+ * **deps:** update yarn monorepo (major) ([#1830](https://github.com/christophehurpeau/pob/issues/1830)) ([d3bc3da](https://github.com/christophehurpeau/pob/commit/d3bc3dae88e724fbfb5666aa96a96d8d2bce1f34))
16
+ * **pob:** add schema in renovate config ([56bfa78](https://github.com/christophehurpeau/pob/commit/56bfa7838cf862538ea765af5e69e06d9ba140cc))
17
+ * remove lerna by default ([8af4340](https://github.com/christophehurpeau/pob/commit/8af434081e42300f7b355dfa2ac9e98a44db3338))
18
+ * update renovate config to use github repo ([0c21d38](https://github.com/christophehurpeau/pob/commit/0c21d38a4e70c8a97e22eddad1f41731fbb17e8c))
19
+ * update to latest lts ([f0f1ef2](https://github.com/christophehurpeau/pob/commit/f0f1ef26e74e39e6ac61bc916f2db672511e281c))
20
+ * use yarn plugin version in common release generator ([4d48101](https://github.com/christophehurpeau/pob/commit/4d48101292ca37e9ffe283453b3ef492f252ddcb))
21
+
22
+
23
+ ### Bug Fixes
24
+
25
+ * correctly identify if ci is used in monorepo generator for release generator ([f152998](https://github.com/christophehurpeau/pob/commit/f1529987dd026a91bd4fb337912ae8156b7ef451))
26
+ * correctly identify if version plugin should be removed ([e262c32](https://github.com/christophehurpeau/pob/commit/e262c323553721622fcb1c9b2abc50c5c299540d))
27
+ * **deps:** update @pob/eslint-config to v51.1.2 ([#1825](https://github.com/christophehurpeau/pob/issues/1825)) ([cbbccb1](https://github.com/christophehurpeau/pob/commit/cbbccb1a784a0b56fbb3601ef1217a486094cc7a))
28
+ * enable isYarnVersionEnabled even without testing ([9a10396](https://github.com/christophehurpeau/pob/commit/9a10396c134ee16eddea164feb8ea25d05dde941))
29
+ * fix publish command for yarn 4 ([fab3b9f](https://github.com/christophehurpeau/pob/commit/fab3b9f46f5a46ab3b2c20fb2a9289cf868f52d5))
30
+ * only allow to configure bump-dependents-highest-as for independent monorepo ([e56d0eb](https://github.com/christophehurpeau/pob/commit/e56d0eb5ee0f090e35f6274d9d5f2184b53e545f))
31
+ * remove console.log ([5fb2c16](https://github.com/christophehurpeau/pob/commit/5fb2c1608cd5ddf7439d2eeb5bae65eb897361ad))
32
+
33
+ Version bump for dependency: sort-eslint-config
34
+ Version bump for dependency: sort-object
35
+ Version bump for dependency: sort-pkg
36
+ Version bump for dependency: yarn-workspace-utils
37
+ Version bump for dependency: root
38
+
39
+
6
40
  ## [14.4.2](https://github.com/christophehurpeau/pob/compare/pob@14.4.1...pob@14.4.2) (2023-10-18)
7
41
 
8
42
 
@@ -138,6 +138,7 @@ export default class PobAppGenerator extends Generator {
138
138
  ) {
139
139
  this.composeWith('pob:common:babel', {
140
140
  updateOnly: this.options.updateOnly,
141
+ onlyLatestLTS: true,
141
142
  isApp: true,
142
143
  isAppLibrary,
143
144
  useAppConfig: this.appConfig.type === 'alp-node',
@@ -243,9 +244,13 @@ export default class PobAppGenerator extends Generator {
243
244
  });
244
245
 
245
246
  this.composeWith('pob:common:release', {
246
- enable: !inMonorepo && this.appConfig.testing && this.appConfig.ci,
247
+ enable: !inMonorepo && this.appConfig.testing,
248
+ enablePublish: false,
247
249
  withBabel: babel,
248
- documentation: false,
250
+ isMonorepo: false,
251
+ enableYarnVersion: true,
252
+ ci: this.appConfig.ci,
253
+ disableYarnGitCache: this.options.disableYarnGitCache,
249
254
  updateOnly: this.options.updateOnly,
250
255
  });
251
256
  }
@@ -51,6 +51,13 @@ export default class CommonBabelGenerator extends Generator {
51
51
  required: false,
52
52
  default: 'dist',
53
53
  });
54
+
55
+ this.option('onlyLatestLTS', {
56
+ type: Boolean,
57
+ required: false,
58
+ default: false,
59
+ desc: 'only latest lts',
60
+ });
54
61
  }
55
62
 
56
63
  initializing() {
@@ -60,26 +67,27 @@ export default class CommonBabelGenerator extends Generator {
60
67
  let babelEnvs = pkg.pob.babelEnvs;
61
68
  if (
62
69
  !babelEnvs.some(
63
- (env) => env.target === 'node' && String(env.version) === '18',
70
+ (env) =>
71
+ env.target === 'node' &&
72
+ String(env.version) === (this.options.onlyLatestLTS ? '20' : '18'),
64
73
  ) &&
65
74
  babelEnvs.some(
66
75
  (env) =>
67
76
  env.target === 'node' &&
68
- (String(env.version) === '8' ||
69
- String(env.version) === '6' ||
70
- String(env.version) === '10' ||
71
- String(env.version) === '12' ||
72
- String(env.version) === '14' ||
73
- String(env.version) === '16'),
77
+ (['8', '6', '10', '12', '14', '16'].includes(String(env.version)) ||
78
+ (this.options.onlyLatestLTS && String(env.version) === '18')),
74
79
  )
75
80
  ) {
76
81
  babelEnvs.unshift({
77
82
  target: 'node',
78
- version: '18',
83
+ version: this.options.onlyLatestLTS ? '20' : '18',
84
+ omitVersionInFileName: this.options.onlyLatestLTS ? true : undefined,
79
85
  });
80
86
  }
81
87
  babelEnvs = babelEnvs.filter(
82
- (env) => env.target !== 'node' || env.version >= 18,
88
+ (env) =>
89
+ env.target !== 'node' ||
90
+ env.version >= (this.options.onlyLatestLTS ? 20 : 18),
83
91
  );
84
92
 
85
93
  pkg.pob.babelEnvs = babelEnvs;
@@ -105,7 +113,13 @@ export default class CommonBabelGenerator extends Generator {
105
113
  babelEnvs
106
114
  .filter((env) => env.target === 'node')
107
115
  .map((env) => {
108
- if (env.version === '14' || env.version === '16') return '18';
116
+ if (
117
+ env.version === '14' ||
118
+ env.version === '16' ||
119
+ (this.options.onlyLatestLTS && env.version === '18')
120
+ ) {
121
+ return this.options.onlyLatestLTS ? '20' : '18';
122
+ }
109
123
  return env.version;
110
124
  }),
111
125
  ),
@@ -155,7 +169,11 @@ export default class CommonBabelGenerator extends Generator {
155
169
  default: nodeVersions,
156
170
  choices: [
157
171
  {
158
- name: '18 (Active LTS)',
172
+ name: '20 (Active LTS)',
173
+ value: '20',
174
+ },
175
+ {
176
+ name: '18 (Maintenance LTS)',
159
177
  value: '18',
160
178
  },
161
179
  ],
@@ -209,10 +227,13 @@ export default class CommonBabelGenerator extends Generator {
209
227
  formats:
210
228
  babelConfig.formats && babelConfig.formats.includes('cjs')
211
229
  ? // eslint-disable-next-line unicorn/no-nested-ternary
212
- version === '16' || version === '18'
230
+ version === '18' || version === '20'
213
231
  ? babelConfig.formats
214
232
  : undefined
215
233
  : undefined,
234
+ omitVersionInFileName:
235
+ // todo add `|| babelConfig.nodeVersions.length === 1` in next major
236
+ version === '20' && this.options.onlyLatestLTS ? true : undefined,
216
237
  })),
217
238
  ...(babelConfig.browserVersions || []).map((version) => ({
218
239
  target: 'browser',
@@ -400,11 +421,12 @@ export default class CommonBabelGenerator extends Generator {
400
421
  case '12':
401
422
  case '14':
402
423
  case '16':
403
- pkg.engines.node = '>=16.12.0';
404
- break;
405
424
  case '18':
406
425
  pkg.engines.node = '>=18.12.0';
407
426
  break;
427
+ case '20':
428
+ pkg.engines.node = '>=20.9.0';
429
+ break;
408
430
  default:
409
431
  throw new Error(`Invalid min node version: ${minNodeVersion}`);
410
432
  }
@@ -426,7 +448,11 @@ export default class CommonBabelGenerator extends Generator {
426
448
  packageUtils.removeDependencies(pkg, ['@types/node']);
427
449
  packageUtils.removeDevDependencies(pkg, ['@types/node']);
428
450
  // Supports oldest current or active LTS version of node
429
- pkg.engines.node = '>=18.12.0';
451
+ if (this.options.onlyLatestLTS) {
452
+ pkg.engines.node = '>=20.9.0';
453
+ } else {
454
+ pkg.engines.node = '>=18.12.0';
455
+ }
430
456
  }
431
457
 
432
458
  /* browserslist */
@@ -11,6 +11,12 @@ export default class CommonReleaseGenerator extends Generator {
11
11
  desc: 'If releasing is enabled',
12
12
  });
13
13
 
14
+ this.option('enablePublish', {
15
+ type: Boolean,
16
+ required: true,
17
+ desc: 'If publish on npm is enabled',
18
+ });
19
+
14
20
  this.option('withBabel', {
15
21
  type: Boolean,
16
22
  required: false,
@@ -18,10 +24,29 @@ export default class CommonReleaseGenerator extends Generator {
18
24
  desc: 'Babel enabled.',
19
25
  });
20
26
 
21
- this.option('documentation', {
27
+ this.option('isMonorepo', {
28
+ type: Boolean,
29
+ default: false,
30
+ desc: 'is monorepo',
31
+ });
32
+
33
+ this.option('enableYarnVersion', {
34
+ type: Boolean,
35
+ default: true,
36
+ desc: 'enable yarn version conventional commits',
37
+ });
38
+
39
+ this.option('ci', {
22
40
  type: Boolean,
23
41
  required: true,
24
- desc: 'Include documentation',
42
+ desc: 'ci with github actions',
43
+ });
44
+
45
+ this.option('disableYarnGitCache', {
46
+ type: Boolean,
47
+ required: false,
48
+ default: false,
49
+ desc: 'Disable git cache. See https://yarnpkg.com/features/caching#offline-mirror.',
25
50
  });
26
51
 
27
52
  this.option('updateOnly', {
@@ -35,19 +60,44 @@ export default class CommonReleaseGenerator extends Generator {
35
60
  writing() {
36
61
  const pkg = this.fs.readJSON(this.destinationPath('package.json'));
37
62
 
38
- const isStandardVersionEnabled =
39
- this.options.enable && !!pkg.devDependencies?.['standard-version'];
63
+ if (this.options.enable && this.options.ci) {
64
+ const useLegacyName = this.fs.exists(
65
+ this.destinationPath('.github/workflows/publish.yml'),
66
+ );
67
+
68
+ const name = useLegacyName ? 'publish.yml' : 'release.yml';
40
69
 
41
- if (!isStandardVersionEnabled) {
42
- packageUtils.removeDevDependencies(pkg, ['standard-version']);
43
- packageUtils.removeScripts(pkg, [
44
- 'release',
45
- pkg.name === 'pob-dependencies' ? null : 'preversion',
46
- ]);
70
+ // TODO rename release (release = version + publish)
71
+ this.fs.copyTpl(
72
+ this.templatePath('workflow-release.yml.ejs'),
73
+ this.destinationPath(`.github/workflows/${name}`),
74
+ {
75
+ enablePublish: this.options.enablePublish,
76
+ enableYarnVersion: this.options.enableYarnVersion,
77
+ disableYarnGitCache: this.options.disableYarnGitCache,
78
+ isMonorepo: this.options.isMonorepo,
79
+ isMonorepoIndependent:
80
+ this.options.isMonorepo &&
81
+ (!pkg.version || pkg.version === '0.0.0'),
82
+ },
83
+ );
47
84
  } else {
85
+ this.fs.delete(this.destinationPath('.github/workflows/publish.yml'));
86
+ this.fs.delete(this.destinationPath('.github/workflows/release.yml'));
87
+ }
88
+
89
+ packageUtils.removeDevDependencies(pkg, ['standard-version']);
90
+ packageUtils.removeScripts(pkg, [
91
+ 'release',
92
+ pkg.name === 'pob-dependencies' ? null : 'preversion',
93
+ ]);
94
+
95
+ if (pkg.scripts.version === 'pob-version') {
96
+ delete pkg.scripts.version;
97
+ }
98
+
99
+ if (this.options.enable && !this.options.ci) {
48
100
  packageUtils.addScripts(pkg, {
49
- release:
50
- "repository-check-dirty && yarn preversion && standard-version -a -m 'chore(release): %s [skip ci]' && git push --follow-tags origin master && npm publish",
51
101
  preversion: [
52
102
  'yarn run lint',
53
103
  this.options.withBabel && 'yarn run build',
@@ -56,10 +106,6 @@ export default class CommonReleaseGenerator extends Generator {
56
106
  .filter(Boolean)
57
107
  .join(' && '),
58
108
  });
59
-
60
- if (pkg.scripts.version === 'pob-version') {
61
- delete pkg.scripts.version;
62
- }
63
109
  }
64
110
 
65
111
  if (
@@ -7,7 +7,7 @@ on:
7
7
  required: true
8
8
  type: boolean
9
9
  default: false
10
- <% if (enableYarnVersion) { -%>
10
+ <% if (enableYarnVersion && isMonorepo && isMonorepoIndependent) { -%>
11
11
  bump-dependents-highest-as:
12
12
  description: "Bump dependents highest as"
13
13
  required: false
@@ -28,9 +28,12 @@ jobs:
28
28
  token: ${{ secrets.GH_TOKEN }}
29
29
  fetch-depth: 0
30
30
 
31
- - uses: actions/setup-node@v3
31
+ - uses: actions/setup-node@v4
32
32
  with:
33
- node-version: 18
33
+ node-version: 20
34
+
35
+ - name: Enable Corepack
36
+ run: corepack enable
34
37
 
35
38
  - name: Install Dependencies
36
39
  <% if (disableYarnGitCache) { -%>
@@ -42,7 +45,7 @@ jobs:
42
45
  - name: New version (dry run)
43
46
  if: github.ref == 'refs/heads/main' && inputs.dry-run
44
47
  <% if (enableYarnVersion) { -%>
45
- run: yarn version --dry-run
48
+ run: yarn version --dry-run<% if (isMonorepo && isMonorepoIndependent) { %> --bump-dependents-highest-as=${{ inputs.bump-dependents-highest-as }}<% } %>
46
49
  <% } else { -%>
47
50
  run: yarn lerna version --yes --no-push --exact --conventional-commits --conventional-graduate --changelog-preset conventional-changelog-conventionalcommits --no-git-tag-version --loglevel=verbose
48
51
  <% } -%>
@@ -56,7 +59,7 @@ jobs:
56
59
  if: github.ref == 'refs/heads/main' && !inputs.dry-run
57
60
  run: |
58
61
  <% if (enableYarnVersion) { -%>
59
- yarn version --create-release=github --bump-dependents-highest-as=${{ inputs.bump-dependents-highest-as }} -m 'chore: release <%- isIndependent ? '' : '%v ' %>[skip ci]<%- isIndependent ? '\\n\\n%t' : '' %>'
62
+ yarn version --create-release=github <% if (isMonorepo && isMonorepoIndependent) { %> --bump-dependents-highest-as=${{ inputs.bump-dependents-highest-as }}<% } %> -m 'chore: release <%- isMonorepoIndependent ? '' : '%v ' %>[skip ci]<%- isMonorepoIndependent ? '\\n\\n%t' : '' %>'
60
63
  <% } else { -%>
61
64
  yarn lerna version --yes --push --exact --conventional-commits --conventional-graduate --changelog-preset conventional-changelog-conventionalcommits --create-release=github -m 'chore: release [skip ci]'
62
65
  <% } -%>
@@ -64,7 +67,7 @@ jobs:
64
67
  HUSKY: 0
65
68
  GH_TOKEN: ${{ secrets.GH_TOKEN }}
66
69
  YARN_ENABLE_IMMUTABLE_INSTALLS: false
67
- <% if (publish) { -%>
70
+ <% if (enablePublish) { -%>
68
71
 
69
72
  - name: Publish to npm
70
73
  run: |
@@ -74,7 +77,11 @@ jobs:
74
77
  fi
75
78
  echo >> ./.yarnrc.yml
76
79
  echo "npmAuthToken: $NODE_AUTH_TOKEN" >> ./.yarnrc.yml
77
- yarn workspaces foreach --parallel --no-private npm publish --tolerate-republish
80
+ <% if (isMonorepo) { -%>
81
+ yarn workspaces foreach --all --parallel --no-private npm publish --tolerate-republish
82
+ <% } else { -%>
83
+ yarn npm publish
84
+ <% } -%>
78
85
  if: github.ref == 'refs/heads/main' && !inputs.dry-run
79
86
  env:
80
87
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -168,12 +168,12 @@ export default class CoreCIGenerator extends Generator {
168
168
  checks && 'checks',
169
169
  build && 'build',
170
170
  'lint',
171
- testing && 'test (18)',
172
- testing && !this.options.onlyLatestLTS && 'test (20)',
171
+ testing && !this.options.onlyLatestLTS && 'test (18)',
172
+ testing && 'test (20)',
173
173
  ].filter(Boolean)
174
174
  : [
175
- 'build (18.x)',
176
- !this.options.onlyLatestLTS && 'build (20.x)',
175
+ !this.options.onlyLatestLTS && 'build (18.x)',
176
+ 'build (20.x)',
177
177
  ].filter(Boolean)),
178
178
  );
179
179
  } else {
@@ -10,9 +10,12 @@ jobs:
10
10
  steps:
11
11
  - uses: actions/checkout@v4
12
12
 
13
- - uses: actions/setup-node@v3
13
+ - uses: actions/setup-node@v4
14
14
  with:
15
- node-version: 18
15
+ node-version: 20
16
+
17
+ - name: Enable Corepack
18
+ run: corepack enable
16
19
 
17
20
  - name: Install Dependencies
18
21
  <% if (disableYarnGitCache) { -%>
@@ -10,9 +10,12 @@ jobs:
10
10
  steps:
11
11
  - uses: actions/checkout@v4
12
12
 
13
- - uses: actions/setup-node@v3
13
+ - uses: actions/setup-node@v4
14
14
  with:
15
- node-version: 18
15
+ node-version: 20
16
+
17
+ - name: Enable Corepack
18
+ run: corepack enable
16
19
 
17
20
  - name: Install Dependencies
18
21
  <% if (disableYarnGitCache) { -%>
@@ -32,9 +35,12 @@ jobs:
32
35
  steps:
33
36
  - uses: actions/checkout@v4
34
37
 
35
- - uses: actions/setup-node@v3
38
+ - uses: actions/setup-node@v4
36
39
  with:
37
- node-version: 18
40
+ node-version: 20
41
+
42
+ - name: Enable Corepack
43
+ run: corepack enable
38
44
 
39
45
  - name: Install Dependencies
40
46
  <% if (disableYarnGitCache) { -%>
@@ -56,9 +62,12 @@ jobs:
56
62
  steps:
57
63
  - uses: actions/checkout@v4
58
64
 
59
- - uses: actions/setup-node@v3
65
+ - uses: actions/setup-node@v4
60
66
  with:
61
- node-version: 18
67
+ node-version: 20
68
+
69
+ - name: Enable Corepack
70
+ run: corepack enable
62
71
 
63
72
  - name: Install Dependencies
64
73
  <% if (disableYarnGitCache) { -%>
@@ -89,10 +98,13 @@ jobs:
89
98
  steps:
90
99
  - uses: actions/checkout@v4
91
100
 
92
- - uses: actions/setup-node@v3
101
+ - uses: actions/setup-node@v4
93
102
  with:
94
103
  node-version: ${{ matrix.node-version }}
95
104
 
105
+ - name: Enable Corepack
106
+ run: corepack enable
107
+
96
108
  - name: Install Dependencies
97
109
  <% if (disableYarnGitCache) { -%>
98
110
  run: yarn install --immutable
@@ -129,9 +141,9 @@ jobs:
129
141
  steps:
130
142
  - uses: actions/checkout@v4
131
143
 
132
- - uses: actions/setup-node@v3
144
+ - uses: actions/setup-node@v4
133
145
  with:
134
- node-version: 18
146
+ node-version: 20
135
147
 
136
148
  - uses: GoogleCloudPlatform/release-please-action@v3
137
149
  if: ${{ github.ref == 'refs/heads/main' }}
@@ -8,17 +8,20 @@ jobs:
8
8
 
9
9
  strategy:
10
10
  matrix:
11
- node-version: [18.x<% if (!onlyLatestLTS) { -%>, 20.x <% } -%>]
11
+ node-version: [<% if (!onlyLatestLTS) { -%>18.x, <% } -%>20.x]
12
12
 
13
13
  steps:
14
14
  - uses: actions/checkout@v4
15
15
 
16
16
  - name: Use Node.js ${{ matrix.node-version }}
17
- uses: actions/setup-node@v3
17
+ uses: actions/setup-node@v4
18
18
  with:
19
19
  node-version: ${{ matrix.node-version }}
20
20
  registry-url: 'https://registry.npmjs.org'
21
21
 
22
+ - name: Enable Corepack
23
+ run: corepack enable
24
+
22
25
  <% if (packageManager === 'yarn') { -%>
23
26
  - name: Install Dependencies
24
27
  <% if (disableYarnGitCache) { -%>
@@ -46,7 +46,11 @@ export default class CorePackageGenerator extends Generator {
46
46
  // dont override engines if set to latest
47
47
  if (
48
48
  !pkg.engines.node ||
49
- !(pkg.engines.node.startsWith('>=18.') && pkg.engines.node !== '>=18.0.0')
49
+ !(
50
+ pkg.engines.node.startsWith('>=20.') &&
51
+ pkg.engines.node.startsWith('>=18.') &&
52
+ pkg.engines.node !== '>=18.0.0'
53
+ )
50
54
  ) {
51
55
  // this might be overridden by babel generator
52
56
  pkg.engines.node = '>=18.12.0'; // .12.0 is the first lts node 18 version
@@ -66,11 +66,18 @@ export default class CoreRenovateGenerator extends Generator {
66
66
  );
67
67
 
68
68
  if (this.options.app) {
69
- renovateConfig.extends = ['config:js-app', '@pob'];
69
+ renovateConfig.$schema =
70
+ 'https://docs.renovatebot.com/renovate-schema.json';
71
+ renovateConfig.extends = [
72
+ 'config:js-app',
73
+ 'github>christophehurpeau/renovate-presets',
74
+ ];
70
75
  } else {
71
76
  renovateConfig.extends = [
72
77
  'config:js-lib',
73
- pkg.name === 'pob-monorepo' ? undefined : '@pob',
78
+ pkg.name === 'pob-monorepo'
79
+ ? undefined
80
+ : 'github>christophehurpeau/renovate-presets',
74
81
  ].filter(Boolean);
75
82
  }
76
83
 
@@ -1,5 +1,7 @@
1
1
  import fs from 'node:fs';
2
+ import sortObject from '@pob/sort-object';
2
3
  import yml from 'js-yaml';
4
+ import { lt } from 'semver';
3
5
  import Generator from 'yeoman-generator';
4
6
  import ensureJsonFileFormatted from '../../../utils/ensureJsonFileFormatted.js';
5
7
  import inMonorepo from '../../../utils/inMonorepo.js';
@@ -45,9 +47,10 @@ export default class CoreYarnGenerator extends Generator {
45
47
  // yarn 2 not yet installed
46
48
  // https://yarnpkg.com/getting-started/install
47
49
  this.spawnSync('yarn', ['set', 'version', 'stable']);
48
- } else {
49
- this.spawnSync('yarn', ['set', 'version', 'stable']);
50
50
  ensureJsonFileFormatted(this.destinationPath('package.json'));
51
+ } else {
52
+ // disabled now that corepack is supposed to set the version used
53
+ // this.spawnSync('yarn', ['set', 'version', 'stable']);)
51
54
  }
52
55
  }
53
56
  }
@@ -94,7 +97,6 @@ export default class CoreYarnGenerator extends Generator {
94
97
  };
95
98
 
96
99
  const postinstallDevPluginName = '@yarnpkg/plugin-postinstall-dev';
97
- const workspacesPluginName = '@yarnpkg/plugin-workspace-tools';
98
100
  const versionPluginName = '@yarnpkg/plugin-conventional-version';
99
101
 
100
102
  if (!inMonorepo && !pkg.private) {
@@ -107,16 +109,27 @@ export default class CoreYarnGenerator extends Generator {
107
109
  }
108
110
 
109
111
  if (pkg.workspaces) {
110
- installPluginIfNotInstalled(workspacesPluginName);
111
112
  if (!pkg.devDependencies?.['@pob/lerna-light']) {
112
113
  installPluginIfNotInstalled(
113
114
  versionPluginName,
114
115
  'https://raw.githubusercontent.com/christophehurpeau/yarn-plugin-conventional-version/main/bundles/%40yarnpkg/plugin-conventional-version.cjs',
115
116
  );
117
+ } else {
118
+ removePluginIfInstalled(versionPluginName);
116
119
  }
117
120
  } else {
118
- removePluginIfInstalled(workspacesPluginName);
119
- removePluginIfInstalled(versionPluginName);
121
+ installPluginIfNotInstalled(
122
+ versionPluginName,
123
+ 'https://raw.githubusercontent.com/christophehurpeau/yarn-plugin-conventional-version/main/bundles/%40yarnpkg/plugin-conventional-version.cjs',
124
+ );
125
+ }
126
+
127
+ if (
128
+ !pkg.packageManager ||
129
+ !pkg.packageManager.startsWith('yarn@') ||
130
+ lt(pkg.packageManager.slice('yarn@'.length), '4.0.1')
131
+ ) {
132
+ pkg.packageManager = 'yarn@4.0.1';
120
133
  }
121
134
 
122
135
  // must be done after plugins installed
@@ -125,16 +138,29 @@ export default class CoreYarnGenerator extends Generator {
125
138
  schema: yml.FAILSAFE_SCHEMA,
126
139
  json: true,
127
140
  });
141
+ if (this.options.disableYarnGitCache) {
142
+ config.compressionLevel = 'mixed'; // optimized for size
143
+ config.enableGlobalCache = true;
144
+ } else {
145
+ config.compressionLevel = 0; // optimized for github config
146
+ config.enableGlobalCache = false;
147
+ // https://yarnpkg.dev/releases/3-1/
148
+ // make sure all supported architectures are in yarn cache
149
+ config.supportedArchitectures = {
150
+ cpu: ['x64', 'arm64'],
151
+ os: ['linux', 'darwin'],
152
+ };
153
+ }
128
154
  config.defaultSemverRangePrefix = this.options.type === 'app' ? '' : '^';
129
155
  config.enableMessageNames = false;
130
156
  config.nodeLinker = this.options.yarnNodeLinker;
131
- // https://yarnpkg.dev/releases/3-1/
132
- // make sure all supported architectures are in yarn cache
133
- config.supportedArchitectures = {
134
- cpu: ['x64', 'arm64'],
135
- os: ['linux', 'darwin'],
136
- };
137
- writeAndFormat(this.fs, '.yarnrc.yml', yml.dump(config, {}));
157
+
158
+ if (config.yarnPath) {
159
+ this.fs.delete(config.yarnPath);
160
+ delete config.yarnPath;
161
+ }
162
+
163
+ writeAndFormat(this.fs, '.yarnrc.yml', yml.dump(sortObject(config), {}));
138
164
  } else {
139
165
  this.fs.delete('.yarn');
140
166
  this.fs.delete('.yarnrc.yml');
@@ -160,7 +186,7 @@ export default class CoreYarnGenerator extends Generator {
160
186
  });
161
187
  this.spawnSync('yarn', ['dedupe']);
162
188
 
163
- this.spawnSync('yarn', ['prettier', '--write', '.vscode']);
189
+ this.spawnSync('yarn', ['prettier', '--write', '.vscode', '.yarnrc.yml']);
164
190
 
165
191
  const pkg = this.fs.readJSON(this.destinationPath('package.json'));
166
192
 
@@ -235,6 +235,7 @@ export default class PobLibGenerator extends Generator {
235
235
  testing: !!this.pobjson.testing,
236
236
  documentation: !!this.pobjson.documentation,
237
237
  fromPob: this.options.fromPob,
238
+ onlyLatestLTS: false,
238
239
  });
239
240
  }
240
241
 
@@ -312,9 +313,13 @@ export default class PobLibGenerator extends Generator {
312
313
  });
313
314
 
314
315
  this.composeWith('pob:common:release', {
315
- enable: !inMonorepo && this.pobjson.testing && this.pobjson.testing.ci,
316
+ enable: !inMonorepo && this.pobjson.testing,
317
+ enablePublish: true,
316
318
  withBabel: babelEnvs.length > 0,
317
- documentation: !!this.pobjson.documentation,
319
+ isMonorepo: false,
320
+ enableYarnVersion: true,
321
+ ci: this.pobjson.testing && this.pobjson.testing.ci,
322
+ disableYarnGitCache: this.options.disableYarnGitCache,
318
323
  updateOnly: this.options.updateOnly,
319
324
  });
320
325
 
@@ -219,9 +219,7 @@ export default class PobMonorepoGenerator extends Generator {
219
219
  this.composeWith('pob:common:husky', {});
220
220
 
221
221
  const isYarnVersionEnabled =
222
- this.pobLernaConfig.testing &&
223
- this.pobLernaConfig.ci &&
224
- !pkg.devDependencies?.['@pob/lerna-light'];
222
+ this.pobLernaConfig.ci && !pkg.devDependencies?.['@pob/lerna-light'];
225
223
 
226
224
  const splitCIJobs = this.packageNames.length > 8;
227
225
 
@@ -290,10 +288,13 @@ export default class PobMonorepoGenerator extends Generator {
290
288
  this.composeWith('pob:common:remove-old-dependencies');
291
289
 
292
290
  this.composeWith('pob:common:release', {
293
- enable: this.pobLernaConfig.testing && this.pobLernaConfig.ci,
294
- isYarnVersionEnabled,
291
+ enable: true,
292
+ enablePublish: !this.options.isAppProject,
295
293
  withBabel: this.pobLernaConfig.typescript,
296
- documentation: this.pobLernaConfig.documentation,
294
+ isMonorepo: true,
295
+ enableYarnVersion: isYarnVersionEnabled,
296
+ ci: this.pobLernaConfig.ci,
297
+ disableYarnGitCache: this.options.disableYarnGitCache,
297
298
  updateOnly: this.options.updateOnly,
298
299
  });
299
300
 
@@ -93,6 +93,15 @@ export default class MonorepoLernaGenerator extends Generator {
93
93
  }
94
94
 
95
95
  writing() {
96
+ // package.json
97
+ const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
98
+ delete pkg.lerna;
99
+ packageUtils.removeDependencies(pkg, ['lerna']);
100
+ packageUtils.removeDevDependencies(pkg, ['lerna']);
101
+
102
+ // TODO remove lerna completely
103
+ const isYarnVersionEnabled = !pkg.devDependencies?.['@pob/lerna-light'];
104
+
96
105
  const getPackagePobConfig = (config) => ({
97
106
  babelEnvs: [],
98
107
  ...(config && config.pob),
@@ -107,6 +116,7 @@ export default class MonorepoLernaGenerator extends Generator {
107
116
  {},
108
117
  );
109
118
 
119
+ // TODO pass that to yarn plugin
110
120
  lernaConfig.command.publish.ignoreChanges = [
111
121
  '**/.yo-rc.json',
112
122
  '**/.eslintrc.json',
@@ -116,25 +126,27 @@ export default class MonorepoLernaGenerator extends Generator {
116
126
  lernaConfig.command.publish.ignoreChanges.push('**/tsconfig.json');
117
127
  }
118
128
 
119
- writeAndFormatJson(
120
- this.fs,
121
- this.destinationPath('lerna.json'),
122
- lernaConfig,
123
- );
124
-
125
- // package.json
126
- const pkg = this.fs.readJSON(this.destinationPath('package.json'), {});
127
- delete pkg.lerna;
128
- packageUtils.removeDependencies(pkg, ['lerna']);
129
- packageUtils.removeDevDependencies(pkg, ['lerna']);
129
+ if (isYarnVersionEnabled) {
130
+ if (pkg.version === '0.0.0' && lernaConfig && lernaConfig.version) {
131
+ if (lernaConfig.version === 'independent') {
132
+ delete pkg.version;
133
+ } else {
134
+ pkg.version = lernaConfig.version;
135
+ }
136
+ }
137
+ this.fs.delete(this.destinationPath('lerna.json'));
138
+ } else {
139
+ writeAndFormatJson(
140
+ this.fs,
141
+ this.destinationPath('lerna.json'),
142
+ lernaConfig,
143
+ );
144
+ }
130
145
 
131
146
  if (this.fs.exists(this.destinationPath('lerna-debug.log'))) {
132
147
  this.fs.delete(this.destinationPath('lerna-debug.log'));
133
148
  }
134
149
 
135
- // TODO remove lerna completely
136
- const isYarnVersionEnabled = !pkg.devDependencies?.['@pob/lerna-light'];
137
-
138
150
  packageUtils.addOrRemoveScripts(
139
151
  pkg,
140
152
  this.options.packageManager === 'yarn' && !isYarnVersionEnabled,
@@ -76,17 +76,7 @@ export default class MonorepoWorkspacesGenerator extends Generator {
76
76
  delete pkg.engines.yarn;
77
77
  }
78
78
 
79
- if (pkg.name === 'pob-monorepo') {
80
- pkg.devDependencies['@pob/lerna-light'] = 'workspace:*';
81
- } else {
82
- packageUtils.addOrRemoveDevDependencies(
83
- pkg,
84
- pkg.name !== 'pob-monorepo-test-repository' &&
85
- pkg.name !== 'use-react-intl-formatters-monorepo',
86
- // pkg.name !== '@pob/eslint-config-monorepo'
87
- ['@pob/lerna-light'],
88
- );
89
- }
79
+ packageUtils.removeDevDependencies(pkg, ['@pob/lerna-light']);
90
80
 
91
81
  const isYarnVersionEnabled = !pkg.devDependencies?.['@pob/lerna-light'];
92
82
 
@@ -94,8 +84,6 @@ export default class MonorepoWorkspacesGenerator extends Generator {
94
84
  packageUtils.addDevDependencies(pkg, ['repository-check-dirty']);
95
85
  }
96
86
 
97
- packageUtils.removeDevDependencies(pkg, ['standard-version']);
98
-
99
87
  const monorepoConfig = this.config.get('monorepo');
100
88
  const packageManager = this.npm ? 'npm' : 'yarn';
101
89
 
@@ -129,25 +117,6 @@ export default class MonorepoWorkspacesGenerator extends Generator {
129
117
  },
130
118
  );
131
119
 
132
- // TODO rename release (release = version + publish)
133
- this.fs.copyTpl(
134
- this.templatePath('workflow-publish.yml.ejs'),
135
- this.destinationPath('.github/workflows/publish.yml'),
136
- {
137
- publish: !this.options.isAppProject,
138
- enableYarnVersion: isYarnVersionEnabled,
139
- disableYarnGitCache: this.options.disableYarnGitCache,
140
- isIndependent: !pkg.version || pkg.version === '0.0.0',
141
- },
142
- );
143
-
144
- packageUtils.removeScripts(
145
- pkg,
146
- [pkg.name !== 'pob-dependencies' && 'preversion', 'release'].filter(
147
- Boolean,
148
- ),
149
- );
150
-
151
120
  packageUtils.addOrRemoveScripts(pkg, withBabel, {
152
121
  build:
153
122
  'yarn workspaces foreach --parallel --topological-dev -Av run build',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pob",
3
- "version": "14.4.2",
3
+ "version": "14.5.0",
4
4
  "description": "Pile of bones, library generator with git/babel/typescript/typedoc/readme/jest",
5
5
  "keywords": [
6
6
  "skeleton"
@@ -40,18 +40,18 @@
40
40
  "prettier": "@pob/root/prettier-config",
41
41
  "pob": {},
42
42
  "dependencies": {
43
- "@pob/eslint-config": "51.1.1",
44
- "@pob/eslint-config-typescript": "51.1.1",
45
- "@pob/eslint-config-typescript-react": "51.1.1",
46
- "@pob/sort-eslint-config": "5.0.2",
47
- "@pob/sort-object": "6.0.2",
48
- "@pob/sort-pkg": "6.0.2",
43
+ "@pob/eslint-config": "51.1.2",
44
+ "@pob/eslint-config-typescript": "51.1.2",
45
+ "@pob/eslint-config-typescript-react": "51.1.2",
46
+ "@pob/sort-eslint-config": "5.0.3",
47
+ "@pob/sort-object": "6.0.3",
48
+ "@pob/sort-pkg": "6.0.3",
49
49
  "@types/inquirer": "9.0.6",
50
- "@yarnpkg/cli": "3.6.4",
51
- "@yarnpkg/core": "3.5.4",
52
- "@yarnpkg/fslib": "2.10.3",
50
+ "@yarnpkg/cli": "4.0.1",
51
+ "@yarnpkg/core": "4.0.1",
52
+ "@yarnpkg/fslib": "3.0.1",
53
53
  "@yeoman/types": "1.1.1",
54
- "eslint": "8.51.0",
54
+ "eslint": "8.53.0",
55
55
  "findup-sync": "^5.0.0",
56
56
  "git-remote-url": "^1.0.1",
57
57
  "github-username": "^7.0.0",
@@ -64,14 +64,14 @@
64
64
  "mem-fs-editor": "10.0.3",
65
65
  "minimist": "1.2.8",
66
66
  "parse-author": "2.0.0",
67
- "pob-dependencies": "8.7.1",
67
+ "pob-dependencies": "8.8.0",
68
68
  "prettier": "2.8.8",
69
69
  "semver": "7.5.4",
70
- "yarn-workspace-utils": "1.0.3",
70
+ "yarn-workspace-utils": "1.1.0",
71
71
  "yeoman-environment": "4.0.0-beta.5",
72
72
  "yeoman-generator": "6.0.0-rc.6"
73
73
  },
74
74
  "devDependencies": {
75
- "@pob/root": "8.4.2"
75
+ "@pob/root": "8.5.0"
76
76
  }
77
77
  }