yarn-version 1.0.0-pre → 1.0.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 ADDED
@@ -0,0 +1,106 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+ See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
+
6
+ ## 1.0.0 (2024-06-07)
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * **deps:** use async prettier or prettier/sync
11
+ * change prettier config to get closer to default
12
+ * enable "disableYarnGitCache" by default
13
+
14
+ ### Features
15
+
16
+ * add app untranspiled-library ([c702f3e](https://github.com/christophehurpeau/pob/commit/c702f3e8170809b8c7b9ac5fe6cad4f6f7e70779))
17
+ * add package yarn-version ([e2e8be6](https://github.com/christophehurpeau/pob/commit/e2e8be65fd50f9084c519fd07503748a1d970509))
18
+ * add rollup-esbuild ([a1085db](https://github.com/christophehurpeau/pob/commit/a1085dbe6ea69767596dd46813044b96fbf713dd))
19
+ * add swc support and improve jest without babel ([e7b050d](https://github.com/christophehurpeau/pob/commit/e7b050d3b7ac5ab2ec68d98095bb9832fdbc88bb))
20
+ * add tsconfig template for js ([237ad7a](https://github.com/christophehurpeau/pob/commit/237ad7a54abe14d8f49db8057adffe00d1b823cd))
21
+ * add vitest support ([db3344c](https://github.com/christophehurpeau/pob/commit/db3344c45197f4b1bdfaa78df7dff25b37d291e2))
22
+ * better support next and add example ([a60ce83](https://github.com/christophehurpeau/pob/commit/a60ce83d8277efb0eef65c5b3372ff89570919fb))
23
+ * change prettier config to get closer to default ([8e472a9](https://github.com/christophehurpeau/pob/commit/8e472a98b0a722c5cd779e4731ff625b0bfa07bb))
24
+ * **deps:** update @pob/eslint-config to v55 (major) ([#2020](https://github.com/christophehurpeau/pob/issues/2020)) ([434d5b3](https://github.com/christophehurpeau/pob/commit/434d5b3dce53b1925091138444881a13e2a962d9))
25
+ * **deps:** update @pob/eslint-config to v55.2.1 ([#2021](https://github.com/christophehurpeau/pob/issues/2021)) ([cdfe421](https://github.com/christophehurpeau/pob/commit/cdfe42126842ac1cb46d233ca7203fd241863a81))
26
+ * **deps:** update @pob/eslint-config to v55.3.0 ([#2035](https://github.com/christophehurpeau/pob/issues/2035)) ([0f05da8](https://github.com/christophehurpeau/pob/commit/0f05da803035953e8b32c87bab59649cdb448aa5))
27
+ * **deps:** update @pob/eslint-config to v56 (major) ([#2036](https://github.com/christophehurpeau/pob/issues/2036)) ([b26302b](https://github.com/christophehurpeau/pob/commit/b26302bd6dbf9bf4da2e97238c59ae80282ad9a4))
28
+ * **deps:** update dependency @rollup/plugin-run to v3.1.0 ([#2079](https://github.com/christophehurpeau/pob/issues/2079)) ([c2ef4fa](https://github.com/christophehurpeau/pob/commit/c2ef4fa22322952dcb626a5d99bc16e141684cd0))
29
+ * **deps:** update dependency @yeoman/types to v1.2.0 ([#1962](https://github.com/christophehurpeau/pob/issues/1962)) ([3566bfd](https://github.com/christophehurpeau/pob/commit/3566bfdbc71ee07662d4b10ec76887c5407118e7))
30
+ * **deps:** update dependency conventional-changelog-conventionalcommits to v8 ([#2033](https://github.com/christophehurpeau/pob/issues/2033)) ([e7a568e](https://github.com/christophehurpeau/pob/commit/e7a568e4fabea00955bc6f005d85088f947f58cb))
31
+ * **deps:** update dependency esbuild to v0.21.0 ([#2040](https://github.com/christophehurpeau/pob/issues/2040)) ([dc252dc](https://github.com/christophehurpeau/pob/commit/dc252dc815dd450e2687e3f5784c3604bcfbab3c))
32
+ * **deps:** update dependency eslint to v8.57.0 ([#1942](https://github.com/christophehurpeau/pob/issues/1942)) ([69753af](https://github.com/christophehurpeau/pob/commit/69753aff1bea9e5801bd4deaa22d6d4eefba8e62))
33
+ * **deps:** update dependency glob to v10.4.0 ([#2061](https://github.com/christophehurpeau/pob/issues/2061)) ([05dd06f](https://github.com/christophehurpeau/pob/commit/05dd06f1fb51d3cff0b95d6457fb9060d5d2db29))
34
+ * **deps:** update dependency husky to v9 ([#1910](https://github.com/christophehurpeau/pob/issues/1910)) ([6b88cd0](https://github.com/christophehurpeau/pob/commit/6b88cd016cc52cf2630a15a619a66b8ff47308f7))
35
+ * **deps:** update dependency mem-fs to v4.1.0 ([#1945](https://github.com/christophehurpeau/pob/issues/1945)) ([c5c31cf](https://github.com/christophehurpeau/pob/commit/c5c31cfdf15018fbdfa9a4511d86fd6a9d72f277))
36
+ * **deps:** update dependency next to v14.2.0 ([#2010](https://github.com/christophehurpeau/pob/issues/2010)) ([dd8ffc8](https://github.com/christophehurpeau/pob/commit/dd8ffc852a79546321317122eedc352d24744716))
37
+ * **deps:** update dependency prettier to v3 ([#1698](https://github.com/christophehurpeau/pob/issues/1698)) ([a65e641](https://github.com/christophehurpeau/pob/commit/a65e6418d4b80680b753a773b02925603df8ea12))
38
+ * **deps:** update dependency prettier to v3.3.0 ([#2071](https://github.com/christophehurpeau/pob/issues/2071)) ([04f24c3](https://github.com/christophehurpeau/pob/commit/04f24c33fcab0472cc830675696c219ee5ba14f9))
39
+ * **deps:** update dependency yeoman-environment to v4.4.0 ([#1963](https://github.com/christophehurpeau/pob/issues/1963)) ([1a7dbb8](https://github.com/christophehurpeau/pob/commit/1a7dbb8fde589f3ad9e6e870cc767b9821832170))
40
+ * **deps:** update dependency yeoman-generator to v7.2.0 ([#2063](https://github.com/christophehurpeau/pob/issues/2063)) ([a5b8748](https://github.com/christophehurpeau/pob/commit/a5b8748fecedff6291475656672feb1766c60e5f))
41
+ * **deps:** update yarn monorepo ([#2032](https://github.com/christophehurpeau/pob/issues/2032)) ([d2b7b8a](https://github.com/christophehurpeau/pob/commit/d2b7b8adc11a13f4b4d96cdd08851ad66f3c83a0))
42
+ * enable "disableYarnGitCache" by default ([b7ce323](https://github.com/christophehurpeau/pob/commit/b7ce323c51e0e875228478d708f27511325b844c))
43
+ * initial bun support ([0f0d36d](https://github.com/christophehurpeau/pob/commit/0f0d36db4cb5532a8976cba368cbc2fbe29e7802))
44
+ * migrate pob.babelEnvs to pob.envs + pob.bundler ([6baa9bb](https://github.com/christophehurpeau/pob/commit/6baa9bb986a1321beefcf9de3de566c285e548d1))
45
+ * **pob:** add tslib ([fb4ead7](https://github.com/christophehurpeau/pob/commit/fb4ead72f5ae31ae894b4f7e9f65fdc05c5e6be0))
46
+ * **pob:** remove metro-health-check in gitignore as I dont use them ([dc09df0](https://github.com/christophehurpeau/pob/commit/dc09df0ae0600294ae4ecdc0fb571797f5cc7b43))
47
+ * remove rollup-swc ([3f59111](https://github.com/christophehurpeau/pob/commit/3f59111b3ce58124fa7817cf0ebc39e8cc108d45))
48
+ * simple esbuild bundler ([80659fa](https://github.com/christophehurpeau/pob/commit/80659fadb42190463585ff54e865af09e31fdc0d))
49
+ * support vitest ([2fe540e](https://github.com/christophehurpeau/pob/commit/2fe540e6ab66255735910745062a92636c87f21e))
50
+ * support yarn nodeLinker pnpm ([340e5ab](https://github.com/christophehurpeau/pob/commit/340e5aba71f6943614445f50b20f1c3d3e68f01a))
51
+ * update peaceiris/actions-gh-pages to v4 ([a67c672](https://github.com/christophehurpeau/pob/commit/a67c672c539c2662650e7b1c00bbc95a4c53fca3))
52
+ * use codecov-action v4 ([73174bd](https://github.com/christophehurpeau/pob/commit/73174bd93ce1b0b9f93e360a7ea29478d7550400))
53
+ * use ts-node-lite ([ccbbb5e](https://github.com/christophehurpeau/pob/commit/ccbbb5e178d816191589cfa378ec99fcf5caec20))
54
+
55
+ ### Bug Fixes
56
+
57
+ * **@pob/root:** vitest --run option to disable watch mode ([d7e8640](https://github.com/christophehurpeau/pob/commit/d7e86404e2c17fe24bb3ad27468e52c6a6b4c1da))
58
+ * commit build of yarn-version ([539f4b2](https://github.com/christophehurpeau/pob/commit/539f4b2e12d8df4dc5cec272a24343721f4d2bdb))
59
+ * **deps:** update @pob/eslint-config to v54.0.1 ([#1943](https://github.com/christophehurpeau/pob/issues/1943)) ([309437f](https://github.com/christophehurpeau/pob/commit/309437f195bfdfc9a6c00eec039fd74cba0a6ef8))
60
+ * **deps:** update @pob/eslint-config to v54.0.2 ([#2000](https://github.com/christophehurpeau/pob/issues/2000)) ([04366c3](https://github.com/christophehurpeau/pob/commit/04366c3fe1917595a4b52369837ba31868e84164))
61
+ * **deps:** update dependency esbuild to v0.21.1 ([#2042](https://github.com/christophehurpeau/pob/issues/2042)) ([2c47629](https://github.com/christophehurpeau/pob/commit/2c476296d1ecabaf272461df0901786bcea07aab))
62
+ * **deps:** update dependency esbuild to v0.21.2 ([#2051](https://github.com/christophehurpeau/pob/issues/2051)) ([8e8596f](https://github.com/christophehurpeau/pob/commit/8e8596f11350ee7e152ebec5603295edea8e6da7))
63
+ * **deps:** update dependency esbuild to v0.21.3 ([#2055](https://github.com/christophehurpeau/pob/issues/2055)) ([f27179c](https://github.com/christophehurpeau/pob/commit/f27179c5d6f4259a2885ee9097cf857b73849cef))
64
+ * **deps:** update dependency esbuild to v0.21.4 ([#2065](https://github.com/christophehurpeau/pob/issues/2065)) ([984e479](https://github.com/christophehurpeau/pob/commit/984e479c1958c224bc584936c13908578563e29d))
65
+ * **deps:** update dependency glob to v10.3.12 ([#1988](https://github.com/christophehurpeau/pob/issues/1988)) ([edb6140](https://github.com/christophehurpeau/pob/commit/edb61405b62a7f94673243cdc47451571e493592))
66
+ * **deps:** update dependency glob to v10.3.14 ([#2047](https://github.com/christophehurpeau/pob/issues/2047)) ([201fff2](https://github.com/christophehurpeau/pob/commit/201fff2e3def4a8c7344af403464e7bf16eb44bc))
67
+ * **deps:** update dependency glob to v10.3.15 ([#2050](https://github.com/christophehurpeau/pob/issues/2050)) ([8142969](https://github.com/christophehurpeau/pob/commit/8142969c29cda5fb5f8cf924522fd719ac0278d7))
68
+ * **deps:** update dependency glob to v10.3.16 ([#2056](https://github.com/christophehurpeau/pob/issues/2056)) ([d5ce7c0](https://github.com/christophehurpeau/pob/commit/d5ce7c0922a93a188250eb5e6a5eb8b14ac76630))
69
+ * **deps:** update dependency glob to v10.4.1 ([#2062](https://github.com/christophehurpeau/pob/issues/2062)) ([c9eb614](https://github.com/christophehurpeau/pob/commit/c9eb614f8b0906bf4757bb21ed2bed570dbf55c4))
70
+ * **deps:** update dependency jscodeshift to v0.15.2 ([#1940](https://github.com/christophehurpeau/pob/issues/1940)) ([edb4bef](https://github.com/christophehurpeau/pob/commit/edb4befd4d03d126b9eeb36583e38e1c79539db9))
71
+ * **deps:** update dependency lint-staged to v15.2.4 ([#2057](https://github.com/christophehurpeau/pob/issues/2057)) ([3266770](https://github.com/christophehurpeau/pob/commit/3266770fc90c82ccc25cd0bce67106063cf38b51))
72
+ * **deps:** update dependency lint-staged to v15.2.5 ([#2066](https://github.com/christophehurpeau/pob/issues/2066)) ([0c5396b](https://github.com/christophehurpeau/pob/commit/0c5396b73c9a99e37964c9752f2f55b4079f888e))
73
+ * **deps:** update dependency mem-fs-editor to v11.0.1 ([#2060](https://github.com/christophehurpeau/pob/issues/2060)) ([a4824cb](https://github.com/christophehurpeau/pob/commit/a4824cb89b8d94846ac7eb4ca062a500cadcc606))
74
+ * **deps:** update dependency next to v14.1.4 ([#1977](https://github.com/christophehurpeau/pob/issues/1977)) ([6913af7](https://github.com/christophehurpeau/pob/commit/6913af7fc660e9ee08e7a412dfe16d7f44c9a4db))
75
+ * **deps:** update dependency next to v14.2.1 ([#2013](https://github.com/christophehurpeau/pob/issues/2013)) ([28b9b77](https://github.com/christophehurpeau/pob/commit/28b9b77170ba57e793a9afda766dc3944eb7cdcb))
76
+ * **deps:** update dependency next to v14.2.2 ([#2018](https://github.com/christophehurpeau/pob/issues/2018)) ([e4e1b1d](https://github.com/christophehurpeau/pob/commit/e4e1b1d086ea2bd7a7cd66f43c188518eba177da))
77
+ * **deps:** update dependency next to v14.2.3 ([#2024](https://github.com/christophehurpeau/pob/issues/2024)) ([0ba3639](https://github.com/christophehurpeau/pob/commit/0ba36391910c2ce6318bb405674256e2d06ba42a))
78
+ * **deps:** update dependency prettier to v3.3.1 ([#2078](https://github.com/christophehurpeau/pob/issues/2078)) ([57ecb30](https://github.com/christophehurpeau/pob/commit/57ecb301bc6dded8e9063c1e3afc9f6f04d023b1))
79
+ * **deps:** update dependency semver to v7.6.1 ([#2041](https://github.com/christophehurpeau/pob/issues/2041)) ([17b20a3](https://github.com/christophehurpeau/pob/commit/17b20a3a352e4fbcda88d2e43938a8dbafe0667c))
80
+ * **deps:** update dependency semver to v7.6.2 ([#2048](https://github.com/christophehurpeau/pob/issues/2048)) ([e4a50f3](https://github.com/christophehurpeau/pob/commit/e4a50f3c11b87306ed30ec0cbcdd8f6f23a4ac75))
81
+ * **deps:** update dependency yeoman-environment to v4.4.1 ([#2073](https://github.com/christophehurpeau/pob/issues/2073)) ([528734e](https://github.com/christophehurpeau/pob/commit/528734e27f1f0b59ab5f5d87ff98e95385168b72))
82
+ * **deps:** update react monorepo to v18.3.1 ([#2026](https://github.com/christophehurpeau/pob/issues/2026)) ([ba29f51](https://github.com/christophehurpeau/pob/commit/ba29f51309c6839cc445386303e20619ebf50498))
83
+ * **deps:** update yarn monorepo ([#2045](https://github.com/christophehurpeau/pob/issues/2045)) ([bfce168](https://github.com/christophehurpeau/pob/commit/bfce1680e6df15f6a57e83fefc39e1257bf8f6e3))
84
+ * **deps:** update yarn monorepo to v4.1.1 ([#1955](https://github.com/christophehurpeau/pob/issues/1955)) ([872ccc1](https://github.com/christophehurpeau/pob/commit/872ccc1c51462a42edbce7b50c6d44dbf625647b))
85
+ * few fixes for monorepo migrate ([a36ab40](https://github.com/christophehurpeau/pob/commit/a36ab408456ced31d8512a1b30391273dffcbe73))
86
+ * fix bun command to install ([5585fa3](https://github.com/christophehurpeau/pob/commit/5585fa3aa073a0194891677e4a33d7d71b96588b))
87
+ * fix checks run using pm ([12f955e](https://github.com/christophehurpeau/pob/commit/12f955e7b00f16d0b2b4f9f1090a4bde2c755442))
88
+ * fix for CommonTestingGenerator ([e7f93df](https://github.com/christophehurpeau/pob/commit/e7f93df65007fe8a6e5faac6fd3d796adf6d3233))
89
+ * fix previous commit ([cd870dc](https://github.com/christophehurpeau/pob/commit/cd870dccce1e4d80ed38e854915407084e8b0001))
90
+ * fix yarn-version command ([87e25ca](https://github.com/christophehurpeau/pob/commit/87e25cae86d3730f14e50e6370efe69bd2e21814))
91
+ * improve bun support ([bab80e5](https://github.com/christophehurpeau/pob/commit/bab80e5257b753b7c28031b1e75681766edf4c5f))
92
+ * make sure .yarn/cache is deleted when disableYarnGitCache is enabled ([242c678](https://github.com/christophehurpeau/pob/commit/242c678a26b49b617d401b598c466cdeb88ad497))
93
+ * missing dependency alp-rollup-plugin-config ([9cdc4e4](https://github.com/christophehurpeau/pob/commit/9cdc4e40fb7fa9ee2140618da5eef978de0f5f31))
94
+ * **pob:** fix lint src directory with typescript and no babel ([b7d32a4](https://github.com/christophehurpeau/pob/commit/b7d32a4753ecf20742c8c4158f50f96e5d225e6d))
95
+ * **pob:** fix vitest coverage commands ([770f995](https://github.com/christophehurpeau/pob/commit/770f995a2f679e63771ca5b1d30a386a66fd2f05))
96
+ * **pob:** leave default compressionLevel config ([3d4c5d1](https://github.com/christophehurpeau/pob/commit/3d4c5d1e92ec1194dec99e768c2743e085c1fa94))
97
+ * **pob:** missing await ([f91682b](https://github.com/christophehurpeau/pob/commit/f91682b72016733065d7d505c6be5d4fddad25d8))
98
+ * properly determine node only with typescript and no babel ([3a8d958](https://github.com/christophehurpeau/pob/commit/3a8d9584ecb9c6810e577891f4c040b338364c10))
99
+ * **rollup-esbuild:** configure node target ([840c9df](https://github.com/christophehurpeau/pob/commit/840c9df8b0d07e5624494661884f559aee70e4db))
100
+ * run tsc with typescript and no babel ([96d1283](https://github.com/christophehurpeau/pob/commit/96d1283d2f79dfdeabc1c39ad57d299419ec44ed))
101
+ * tslib prefix ([b86d5e4](https://github.com/christophehurpeau/pob/commit/b86d5e47912fb16d0f58157d228772af43f00e80))
102
+ * update json5 ([4034c94](https://github.com/christophehurpeau/pob/commit/4034c947a1111021ee037144cefbee0cd39b9d33))
103
+ Version bump for dependency: @pob/pretty-pkg
104
+ Version bump for dependency: @pob/rollup-esbuild
105
+
106
+
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ <h3 align="center">
2
+ yarn-version
3
+ </h3>
4
+
5
+ <p align="center">
6
+ yarn berry versionning using conventional commits
7
+ </p>
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ yarn add --dev yarn-version conventional-changelog-conventionalcommits
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```bash
18
+ yarn yarn-version version --help
19
+ ```
20
+
21
+ ## Options
22
+
23
+ `--bump-dependents-highest-as` is for updates in dependent packages. In a monorepo, when a package B has a peer dependency on package A, if A is updated with a breaking change (major), but B has no changes, B will be updated with this option. Sometimes, a major in A should update B with patch or minor. Sometimes, it should also be a major as it also breaks things for B. The default is `major`. If A is `minor` and the value is `major`, B will be updated as `minor`.
24
+
25
+ ## Example with Github Action, for a simple repository
26
+
27
+ ```yml
28
+ name: Release
29
+ on:
30
+ workflow_dispatch:
31
+ inputs:
32
+ dry-run:
33
+ description: "Dry run"
34
+ required: true
35
+ type: boolean
36
+ default: false
37
+
38
+ jobs:
39
+ release:
40
+ runs-on: ubuntu-latest
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+ with:
44
+ token: ${{ secrets.GH_TOKEN }}
45
+ fetch-depth: 0
46
+
47
+ - uses: actions/setup-node@v3
48
+ with:
49
+ node-version: 18
50
+
51
+ - name: Enable Corepack
52
+ run: corepack enable
53
+
54
+ - name: Install Dependencies
55
+ run: yarn install --immutable --immutable-cache
56
+
57
+ - name: New version (dry run)
58
+ if: github.ref == 'refs/heads/main' && inputs.dry-run
59
+ run: yarn yarn-version version --dry-run
60
+
61
+ - name: Configure Git user
62
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
63
+ run: |
64
+ git config --global user.name 'github-actions[bot]'
65
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
66
+
67
+ - name: New version
68
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
69
+ run: |
70
+ yarn yarn-version version --create-release=github -m 'chore: release %v [skip ci]'
71
+ env:
72
+ HUSKY: 0
73
+ GH_TOKEN: ${{ secrets.GH_TOKEN }}
74
+ YARN_ENABLE_IMMUTABLE_INSTALLS: false
75
+
76
+ - name: Publish to npm
77
+ run: |
78
+ if [ -z "$NODE_AUTH_TOKEN" ]; then
79
+ echo "Missing env variable NODE_AUTH_TOKEN"
80
+ exit 1
81
+ fi
82
+ echo >> ./.yarnrc.yml
83
+ echo "npmAuthToken: $NODE_AUTH_TOKEN" >> ./.yarnrc.yml
84
+ yarn npm publish
85
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
86
+ env:
87
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
88
+ ```
89
+
90
+ ## Example with Github Action, for a monorepo
91
+
92
+ ```yml
93
+ name: Release
94
+ on:
95
+ workflow_dispatch:
96
+ inputs:
97
+ dry-run:
98
+ description: "Dry run"
99
+ required: true
100
+ type: boolean
101
+ default: false
102
+ bump-dependents-highest-as:
103
+ description: "Bump dependents highest as"
104
+ required: false
105
+ type: choice
106
+ options:
107
+ - major
108
+ - minor
109
+ - patch
110
+ default: "major"
111
+
112
+ jobs:
113
+ release:
114
+ runs-on: ubuntu-latest
115
+ steps:
116
+ - uses: actions/checkout@v4
117
+ with:
118
+ token: ${{ secrets.GH_TOKEN }}
119
+ fetch-depth: 0
120
+
121
+ - uses: actions/setup-node@v3
122
+ with:
123
+ node-version: 18
124
+
125
+ - name: Enable Corepack
126
+ run: corepack enable
127
+
128
+ - name: Install Dependencies
129
+ run: yarn install --immutable --immutable-cache
130
+
131
+ - name: New version (dry run)
132
+ if: github.ref == 'refs/heads/main' && inputs.dry-run
133
+ run: yarn yarn-version version --dry-run --bump-dependents-highest-as=${{ inputs.bump-dependents-highest-as }}
134
+ - name: Configure Git user
135
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
136
+ run: |
137
+ git config --global user.name 'github-actions[bot]'
138
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
139
+
140
+ - name: New version
141
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
142
+ run: |
143
+ yarn yarn-version version --create-release=github --bump-dependents-highest-as=${{ inputs.bump-dependents-highest-as }} -m 'chore: release [skip ci]\n\n%t'
144
+ env:
145
+ HUSKY: 0
146
+ GH_TOKEN: ${{ secrets.GH_TOKEN }}
147
+ YARN_ENABLE_IMMUTABLE_INSTALLS: false
148
+
149
+ - name: Publish to npm
150
+ run: |
151
+ if [ -z "$NODE_AUTH_TOKEN" ]; then
152
+ echo "Missing env variable NODE_AUTH_TOKEN"
153
+ exit 1
154
+ fi
155
+ echo >> ./.yarnrc.yml
156
+ echo "npmAuthToken: $NODE_AUTH_TOKEN" >> ./.yarnrc.yml
157
+ yarn workspaces foreach --parallel --no-private npm publish --tolerate-republish
158
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
159
+ env:
160
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
161
+ ```
@@ -1,9 +1,9 @@
1
- import fs$2 from 'node:fs';
1
+ import fs$1 from 'node:fs';
2
2
  import { program, Option } from 'commander';
3
3
  import childProcess, { spawnSync } from 'node:child_process';
4
4
  import path from 'node:path';
5
5
  import { ConventionalGitClient } from '@conventional-changelog/git-client';
6
- import { addConfig, Level, Logger } from 'nightingale';
6
+ import { addConfig, Logger, Level } from 'nightingale';
7
7
  import { ConsoleHandler } from 'nightingale-console';
8
8
  import semver, { satisfies } from 'semver';
9
9
  import { text } from 'node:stream/consumers';
@@ -13,9 +13,13 @@ import { Octokit } from '@octokit/rest';
13
13
  import fs from 'node:fs/promises';
14
14
  import mapWorkspaces from '@npmcli/map-workspaces';
15
15
  import prettyPkg from '@pob/pretty-pkg';
16
- import fs$1 from 'fs/promises';
17
16
 
18
- const UsageError = Error;
17
+ class UsageError extends Error {
18
+ constructor(message) {
19
+ super(message);
20
+ this.name = "UsageError";
21
+ }
22
+ }
19
23
 
20
24
  function getMapArrayItemForKey(map, key) {
21
25
  let value = map.get(key);
@@ -28,7 +32,7 @@ function getMapArrayItemForKey(map, key) {
28
32
  const PackageDescriptorNameUtils = {
29
33
  parse: (value) => {
30
34
  if (value.startsWith("@")) {
31
- const [scope, name] = value.split("/", 2);
35
+ const [scope, name] = value.slice(1).split("/", 2);
32
36
  return { scope, name };
33
37
  }
34
38
  return { name: value };
@@ -38,8 +42,16 @@ const PackageDescriptorNameUtils = {
38
42
  }
39
43
  };
40
44
  const PackageDependencyDescriptorUtils = {
45
+ make: (descriptor, selector) => {
46
+ return { key: descriptor.key, name: descriptor.name, selector };
47
+ },
41
48
  parse: (dependencyKey, dependencyValue) => {
42
- const [name, selector] = dependencyValue.startsWith("npm:") ? dependencyValue.slice("npm:".length).split("@", 2) : [dependencyKey, dependencyValue];
49
+ const [name, selector] = dependencyValue.startsWith("npm:") ? (() => {
50
+ const v = dependencyValue.slice("npm:".length);
51
+ if (!v.startsWith("@")) v.split("@", 2);
52
+ const [packageNameWithoutFirstChar, selector2] = v.slice(1).split("@", 2);
53
+ return [`@${packageNameWithoutFirstChar}`, selector2];
54
+ })() : [dependencyKey, dependencyValue];
43
55
  return {
44
56
  key: dependencyKey,
45
57
  name: PackageDescriptorNameUtils.parse(name),
@@ -482,14 +494,14 @@ const updateChangelogFile = async (versionChangelogContent, tagPrefix, file = "C
482
494
  );
483
495
  let oldContent = "";
484
496
  try {
485
- oldContent = await fs$1.readFile(file, "utf8");
497
+ oldContent = await fs.readFile(file, "utf8");
486
498
  const oldContentStart = oldContent.search(START_OF_LAST_RELEASE_PATTERN);
487
499
  if (oldContentStart !== -1) {
488
500
  oldContent = oldContent.slice(Math.max(0, oldContentStart));
489
501
  }
490
502
  } catch {
491
503
  }
492
- await fs$1.writeFile(
504
+ await fs.writeFile(
493
505
  file,
494
506
  `${CHANGELOG_HEADER}
495
507
  ${versionChangelogContent}
@@ -497,79 +509,16 @@ ${oldContent}`
497
509
  );
498
510
  };
499
511
 
500
- program.command("version").usage("Bump package version using conventional commit").addOption(
501
- new Option("--includes-root", "Release root workspace [untested]").default(
502
- false
503
- )
504
- ).addOption(new Option("--cwd", "working directory").default(process.cwd())).addOption(
505
- new Option(
506
- "--dry-run",
507
- "Print the versions without actually generating the package archive"
508
- ).default(false)
509
- ).addOption(new Option("-v,--verbose").default(false)).addOption(
510
- new Option("--force <type>", "Specify the release type").choices([
511
- "major",
512
- "minor",
513
- "patch"
514
- ])
515
- ).addOption(
516
- new Option(
517
- "--prerelease [releaseType]",
518
- "Add a prerelease identifier to new versions"
519
- )
520
- ).addOption(
521
- new Option(
522
- "--preset <presetName>",
523
- "Conventional Changelog preset to require. Defaults to conventional-changelog-conventionalcommits."
524
- ).default("conventional-changelog-conventionalcommits")
525
- ).addOption(
526
- new Option("--tag-version-prefix <prefix>", "Tag version prefix").default(
527
- "v"
528
- )
529
- ).addOption(
530
- new Option(
531
- "--changelog <path>",
532
- "Changelog path. Default to CHANGELOG.md."
533
- ).default("CHANGELOG.md")
534
- ).addOption(
535
- new Option(
536
- "-m,--commit-message <message>",
537
- 'Commit message. Default to "chore: release %a". You can use %v for the version, %s for the version with prefix, %t to list tags, %a for auto best display.'
538
- ).default("chore: release %a")
539
- ).addOption(
540
- new Option("--create-release <type>", "Create a release").choices([
541
- "github"
542
- ])
543
- ).addOption(
544
- new Option(
545
- "--bump-dependents-highest-as <type>",
546
- "Bump dependents highest version as major, minor or patch"
547
- ).choices(["major", "minor", "patch"]).default("major")
548
- ).addOption(
549
- new Option(
550
- "--always-bump-peer-dependencies",
551
- "Always bump peer dependencies. Default to bumping only if the version doesn't satisfies the peer dependency range."
552
- ).default(false)
553
- ).addOption(
554
- new Option(
555
- "--git-remote <remote-name>",
556
- "Git remote to push commits and tags to"
557
- ).default("origin")
558
- ).addOption(
559
- new Option(
560
- "--ignore-changes <glob>",
561
- 'Ignore changes in files matching the glob. Example: "**/*.test.js"'
562
- )
563
- ).action(async (options) => {
512
+ const versionCommandAction = async (options, { nightingaleHandler = new ConsoleHandler(Level.INFO) } = {}) => {
564
513
  if (options.json) {
565
514
  process.env.NIGHTINGALE_CONSOLE_FORMATTER = "json";
566
515
  }
567
516
  addConfig({
568
517
  pattern: /^yarn-version/,
569
- handler: new ConsoleHandler(Level.INFO)
518
+ handler: nightingaleHandler
570
519
  });
571
520
  const logger = new Logger("yarn-version");
572
- const rootWorkspace = await findRootWorkspace(options.cwd);
521
+ const rootWorkspace = await (options.cwdIsRoot ? createWorkspace(options.cwd) : findRootWorkspace(options.cwd));
573
522
  if (!rootWorkspace) {
574
523
  throw new UsageError("Could not find root workspace from this path.");
575
524
  }
@@ -617,7 +566,9 @@ There are uncommitted changes in the git repository. Please commit or stash them
617
566
  const buildTagName = (workspace, version) => `${isMonorepo && workspace !== rootWorkspace ? `${getWorkspaceName(workspace)}@` : options.tagVersionPrefix}${version}`;
618
567
  const changedWorkspaces = /* @__PURE__ */ new Map();
619
568
  const dependenciesMap = isMonorepo ? buildDependenciesMaps(project) : null;
620
- logger.info("Finding changed workspaces");
569
+ logger.info(
570
+ options.force ? "Check all workspaces (force option)" : "Finding changed workspaces"
571
+ );
621
572
  const bumpableWorkspaces = [];
622
573
  for (const workspace of workspaces) {
623
574
  const workspaceName = getWorkspaceName(workspace);
@@ -640,6 +591,11 @@ There are uncommitted changes in the git repository. Please commit or stash them
640
591
  version
641
592
  });
642
593
  }
594
+ if (bumpableWorkspaces.length > 0) {
595
+ logger.info("Found bumpable workspaces", {
596
+ count: bumpableWorkspaces.length
597
+ });
598
+ }
643
599
  const previousTagByWorkspace = new Map(
644
600
  await Promise.all(
645
601
  bumpableWorkspaces.map(async ({ workspace, workspaceName, isRoot }) => {
@@ -674,7 +630,6 @@ There are uncommitted changes in the git repository. Please commit or stash them
674
630
  )
675
631
  );
676
632
  for (const { workspace, workspaceName } of bumpableWorkspaces) {
677
- if (workspaceName !== "pob") continue;
678
633
  let bumpType = null;
679
634
  let bumpReason;
680
635
  if (options.force) {
@@ -833,17 +788,15 @@ There are uncommitted changes in the git repository. Please commit or stash them
833
788
  );
834
789
  rootNewVersion = newVersion;
835
790
  rootNewTag = buildTagName(rootWorkspace, newVersion);
836
- [...bumpedWorkspaces.entries()].forEach(
837
- ([workspace, bumpedWorkspace]) => {
838
- const isRoot = workspace === rootWorkspace;
839
- if (isRoot) {
840
- throw new Error("Unexpected root found in bumped workspaces");
841
- }
842
- bumpedWorkspace.bumpType = highestBumpType;
843
- bumpedWorkspace.newVersion = newVersion;
844
- bumpedWorkspace.newTag = null;
791
+ [...bumpedWorkspaces.entries()].forEach(([workspace, bumpedWorkspace]) => {
792
+ const isRoot = workspace === rootWorkspace;
793
+ if (isRoot) {
794
+ throw new Error("Unexpected root found in bumped workspaces");
845
795
  }
846
- );
796
+ bumpedWorkspace.bumpType = highestBumpType;
797
+ bumpedWorkspace.newVersion = newVersion;
798
+ bumpedWorkspace.newTag = null;
799
+ });
847
800
  [
848
801
  ...bumpedWorkspaces.entries(),
849
802
  ...noVersionToUpdateWorkspaces.entries()
@@ -882,16 +835,14 @@ There are uncommitted changes in the git repository. Please commit or stash them
882
835
  });
883
836
  }
884
837
  if (!options.dryRun) {
885
- await Promise.all(
886
- [...bumpedWorkspaces.entries()].map(async ([workspace]) => {
887
- if (workspace.pkg.scripts?.preversion) {
888
- spawnSync("yarn run preversion", {
889
- cwd: workspace.cwd,
890
- stdio: "inherit"
891
- });
892
- }
893
- })
894
- );
838
+ for (const workspace of bumpedWorkspaces.keys()) {
839
+ if (workspace.pkg.scripts?.preversion) {
840
+ spawnSync("yarn run preversion", {
841
+ cwd: workspace.cwd,
842
+ stdio: "inherit"
843
+ });
844
+ }
845
+ }
895
846
  logger.info("Modifying versions in package.json");
896
847
  await Promise.all(
897
848
  [...bumpedWorkspaces.entries()].map(
@@ -919,16 +870,14 @@ There are uncommitted changes in the git repository. Please commit or stash them
919
870
  stdio: "inherit"
920
871
  });
921
872
  logger.info("Lifecycle script: version");
922
- await Promise.all(
923
- [...bumpedWorkspaces.entries()].map(async ([workspace]) => {
924
- if (workspace.pkg.scripts?.version) {
925
- spawnSync("yarn run version", {
926
- cwd: workspace.cwd,
927
- stdio: "inherit"
928
- });
929
- }
930
- })
931
- );
873
+ for (const workspace of bumpedWorkspaces.keys()) {
874
+ if (workspace.pkg.scripts?.version) {
875
+ spawnSync("yarn run version", {
876
+ cwd: workspace.cwd,
877
+ stdio: "inherit"
878
+ });
879
+ }
880
+ }
932
881
  }
933
882
  if (isMonorepoVersionIndependent && rootWorkspace.pkg.scripts?.version) {
934
883
  spawnSync("yarn run version", {
@@ -1047,12 +996,93 @@ ${tagsInCommitMessage}` : rootNewVersion
1047
996
  );
1048
997
  }
1049
998
  }
1050
- logger.success("Done");
1051
- });
999
+ if (process.env.NODE_ENV !== "test") {
1000
+ process.exit(0);
1001
+ }
1002
+ };
1003
+ const Defaults = {
1004
+ cwd: process.cwd(),
1005
+ includesRoot: false,
1006
+ dryRun: false,
1007
+ json: false,
1008
+ preset: "conventional-changelog-conventionalcommits",
1009
+ tagVersionPrefix: "v",
1010
+ changelog: "CHANGELOG.md",
1011
+ commitMessage: "chore: release %a",
1012
+ createRelease: false,
1013
+ bumpDependentsHighestAs: "major",
1014
+ alwaysBumpPeerDependencies: false,
1015
+ gitRemote: "origin",
1016
+ verbose: false
1017
+ };
1018
+ program.command("version").usage("Bump package version using conventional commit").addOption(
1019
+ new Option("--includes-root", "Release root workspace [untested]").default(
1020
+ Defaults.includesRoot
1021
+ )
1022
+ ).addOption(new Option("--cwd", "working directory").default(process.cwd())).addOption(
1023
+ new Option(
1024
+ "--dry-run",
1025
+ "Print the versions without actually generating the package archive"
1026
+ ).default(Defaults.dryRun)
1027
+ ).addOption(new Option("-v,--verbose").default(Defaults.verbose)).addOption(
1028
+ new Option("--force <type>", "Specify the release type").choices([
1029
+ "major",
1030
+ "minor",
1031
+ "patch"
1032
+ ])
1033
+ ).addOption(
1034
+ new Option(
1035
+ "--prerelease [releaseType]",
1036
+ "Add a prerelease identifier to new versions"
1037
+ )
1038
+ ).addOption(
1039
+ new Option(
1040
+ "--preset <presetName>",
1041
+ "Conventional Changelog preset to require. Defaults to conventional-changelog-conventionalcommits."
1042
+ ).default("conventional-changelog-conventionalcommits")
1043
+ ).addOption(
1044
+ new Option("--tag-version-prefix <prefix>", "Tag version prefix").default(
1045
+ Defaults.tagVersionPrefix
1046
+ )
1047
+ ).addOption(
1048
+ new Option(
1049
+ "--changelog <path>",
1050
+ "Changelog path. Default to CHANGELOG.md."
1051
+ ).default(Defaults.changelog)
1052
+ ).addOption(
1053
+ new Option(
1054
+ "-m,--commit-message <message>",
1055
+ 'Commit message. Default to "chore: release %a". You can use %v for the version, %s for the version with prefix, %t to list tags, %a for auto best display.'
1056
+ ).default(Defaults.commitMessage)
1057
+ ).addOption(
1058
+ new Option("--create-release <type>", "Create a release").choices([
1059
+ "github"
1060
+ ])
1061
+ ).addOption(
1062
+ new Option(
1063
+ "--bump-dependents-highest-as <type>",
1064
+ "Bump dependents highest version as major, minor or patch"
1065
+ ).choices(["major", "minor", "patch"]).default(Defaults.bumpDependentsHighestAs)
1066
+ ).addOption(
1067
+ new Option(
1068
+ "--always-bump-peer-dependencies",
1069
+ "Always bump peer dependencies. Default to bumping only if the version doesn't satisfies the peer dependency range."
1070
+ ).default(Defaults.alwaysBumpPeerDependencies)
1071
+ ).addOption(
1072
+ new Option(
1073
+ "--git-remote <remote-name>",
1074
+ "Git remote to push commits and tags to"
1075
+ ).default(Defaults.gitRemote)
1076
+ ).addOption(
1077
+ new Option(
1078
+ "--ignore-changes <glob>",
1079
+ 'Ignore changes in files matching the glob. Example: "**/*.test.js"'
1080
+ )
1081
+ ).action((options) => versionCommandAction(options));
1052
1082
 
1053
1083
  const pkg = JSON.parse(
1054
1084
  // eslint-disable-next-line unicorn/prefer-json-parse-buffer
1055
- fs$2.readFileSync(new URL("../package.json", import.meta.url), "utf8")
1085
+ fs$1.readFileSync(new URL("../package.json", import.meta.url), "utf8")
1056
1086
  );
1057
1087
  program.name(pkg.name).description(pkg.description).version(pkg.version);
1058
1088
  program.parse();