@pob/version 5.1.0 → 6.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.
Files changed (37) hide show
  1. package/LICENSE +21 -15
  2. package/README.md +147 -10
  3. package/dist/index-node.mjs +1482 -0
  4. package/dist/index-node.mjs.map +1 -0
  5. package/package.json +77 -24
  6. package/src/commands/version.test.ts +120 -0
  7. package/src/commands/version.ts +956 -0
  8. package/src/index.ts +13 -0
  9. package/src/missing-types.d.ts +10 -0
  10. package/src/pm/BunPackageManager.ts +29 -0
  11. package/src/pm/PackageManager.ts +90 -0
  12. package/src/pm/PnpmPackageManager.ts +23 -0
  13. package/src/pm/YarnPackageManager.ts +44 -0
  14. package/src/utils/UsageError.ts +6 -0
  15. package/src/utils/bumpTypeUtils.test.ts +65 -0
  16. package/src/utils/bumpTypeUtils.ts +111 -0
  17. package/src/utils/conventionalChangelogUtils.test.ts +762 -0
  18. package/src/utils/conventionalChangelogUtils.ts +104 -0
  19. package/src/utils/conventionalCommitConfigUtils.ts +19 -0
  20. package/src/utils/execCommand.ts +214 -0
  21. package/src/utils/generatorUtils.ts +11 -0
  22. package/src/utils/gitUtils.ts +193 -0
  23. package/src/utils/githubUtils.ts +120 -0
  24. package/src/utils/mapUtils.ts +7 -0
  25. package/src/utils/mapWorkspaces.test.ts +89 -0
  26. package/src/utils/packageDependenciesUtils.test.ts +25 -0
  27. package/src/utils/packageDependenciesUtils.ts +80 -0
  28. package/src/utils/packageUtils.test.ts +32 -0
  29. package/src/utils/packageUtils.ts +129 -0
  30. package/src/utils/updateChangelog.ts +39 -0
  31. package/src/utils/workspaceUtils.ts +142 -0
  32. package/.editorconfig +0 -13
  33. package/.eslintrc.json +0 -4
  34. package/CHANGELOG.md +0 -108
  35. package/generate-index.js +0 -13
  36. package/lib/index.d.ts +0 -8
  37. package/lib/index.js +0 -5
package/LICENSE CHANGED
@@ -1,15 +1,21 @@
1
- Copyright (c) 2019 Christophe Hurpeau <christophe@hurpeau.com> (https://christophe.hurpeau.com)
2
-
3
- Permission to use, copy, modify, and/or distribute this software for
4
- any purpose with or without fee is hereby granted, provided that the
5
- above copyright notice and this permission notice appear in all
6
- copies.
7
-
8
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
9
- WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
10
- WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
11
- AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
13
- PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
14
- TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15
- PERFORMANCE OF THIS SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Christophe Hurpeau <christophe@hurpeau.com> (https://christophe.hurpeau.com)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -3,24 +3,161 @@
3
3
  </h3>
4
4
 
5
5
  <p align="center">
6
- version of pob
7
- </p>
8
-
9
- <p align="center">
10
- <a href="https://npmjs.org/package/@pob/version"><img src="https://img.shields.io/npm/v/@pob/version.svg?style=flat-square"></a>
11
- <a href="https://david-dm.org/christophehurpeau/pob?path=@pob/version"><img src="https://david-dm.org/christophehurpeau/pob.svg?path=@pob/version?style=flat-square"></a>
6
+ versionning using conventional commits
12
7
  </p>
13
8
 
14
9
  ## Install
15
10
 
16
11
  ```bash
17
- npm install --save-dev pob-version
12
+ yarn add --dev @pob/version conventional-changelog-conventionalcommits
18
13
  ```
19
14
 
20
15
  ## Usage
21
16
 
22
- ```js
23
- import pobVersion from 'pob-version';
17
+ ```bash
18
+ yarn @pob/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
+ permissions:
39
+ id-token: write # Required for OIDC
40
+ contents: write # Required to create release
41
+
42
+ jobs:
43
+ release:
44
+ runs-on: ubuntu-latest
45
+ steps:
46
+ - uses: actions/checkout@v7
47
+ with:
48
+ fetch-depth: 0
49
+
50
+ - name: Enable Corepack
51
+ run: corepack enable
52
+
53
+ - uses: actions/setup-node@v7
54
+ with:
55
+ node-version: 24
56
+
57
+ - name: Install Dependencies
58
+ run: yarn install --immutable --immutable-cache
59
+
60
+ - name: New version (dry run)
61
+ if: github.ref == 'refs/heads/main' && inputs.dry-run
62
+ run: yarn pob-version --dry-run
63
+
64
+ - name: Configure Git user
65
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
66
+ run: |
67
+ git config --global user.name 'github-actions[bot]'
68
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
69
+
70
+ - name: New version
71
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
72
+ run: |
73
+ yarn pob-version --create-release=github -m 'chore: release %v [skip ci]'
74
+ env:
75
+ HUSKY: 0
76
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77
+ YARN_ENABLE_IMMUTABLE_INSTALLS: false
78
+
79
+ - name: Publish to npm
80
+ run: |
81
+ if [ -z "$NODE_AUTH_TOKEN" ]; then
82
+ echo "Missing env variable NODE_AUTH_TOKEN"
83
+ exit 1
84
+ fi
85
+ echo >> ./.yarnrc.yml
86
+ echo "npmAuthToken: $NODE_AUTH_TOKEN" >> ./.yarnrc.yml
87
+ yarn npm publish
88
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
89
+ env:
90
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
91
+ ```
92
+
93
+ ## Example with Github Action, for a monorepo
94
+
95
+ ```yml
96
+ name: Release
97
+ on:
98
+ workflow_dispatch:
99
+ inputs:
100
+ dry-run:
101
+ description: "Dry run"
102
+ required: true
103
+ type: boolean
104
+ default: false
105
+ bump-dependents-highest-as:
106
+ description: "Bump dependents highest as"
107
+ required: false
108
+ type: choice
109
+ options:
110
+ - major
111
+ - minor
112
+ - patch
113
+ default: "major"
114
+
115
+ jobs:
116
+ release:
117
+ runs-on: ubuntu-latest
118
+ steps:
119
+ - uses: actions/checkout@v7
120
+ with:
121
+ fetch-depth: 0
122
+
123
+ - name: Enable Corepack
124
+ run: corepack enable
125
+
126
+ - uses: actions/setup-node@v3
127
+ with:
128
+ node-version: 24
129
+
130
+ - name: Install Dependencies
131
+ run: yarn install --immutable --immutable-cache
132
+
133
+ - name: New version (dry run)
134
+ if: github.ref == 'refs/heads/main' && inputs.dry-run
135
+ run: yarn pob-version --dry-run --bump-dependents-highest-as=${{ inputs.bump-dependents-highest-as }}
136
+ - name: Configure Git user
137
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
138
+ run: |
139
+ git config --global user.name 'github-actions[bot]'
140
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
141
+
142
+ - name: New version
143
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
144
+ run: |
145
+ yarn pob-version --create-release=github --bump-dependents-highest-as=${{ inputs.bump-dependents-highest-as }} -m 'chore: release [skip ci]\n\n%t'
146
+ env:
147
+ HUSKY: 0
148
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149
+ YARN_ENABLE_IMMUTABLE_INSTALLS: false
24
150
 
25
- console.log(pobVersion);
151
+ - name: Publish to npm
152
+ run: |
153
+ if [ -z "$NODE_AUTH_TOKEN" ]; then
154
+ echo "Missing env variable NODE_AUTH_TOKEN"
155
+ exit 1
156
+ fi
157
+ echo >> ./.yarnrc.yml
158
+ echo "npmAuthToken: $NODE_AUTH_TOKEN" >> ./.yarnrc.yml
159
+ yarn workspaces foreach --parallel --no-private npm publish --tolerate-republish
160
+ if: github.ref == 'refs/heads/main' && !inputs.dry-run
161
+ env:
162
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
26
163
  ```