update-workspace-root-version 0.2.0 → 0.3.1
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/README.md +5 -15
- package/dist/src/steps/get-new-version.js +1 -1
- package/dist/src/steps/get-package-versions.js +5 -2
- package/dist/src/steps/get-workspace-root-version.js +1 -1
- package/dist/src/utils/version/allow.js +6 -0
- package/dist/src/utils/{versions → version}/index.js +1 -0
- package/package.json +5 -5
- /package/dist/src/utils/{versions → version}/compare.js +0 -0
- /package/dist/src/utils/{versions → version}/increment.js +0 -0
package/README.md
CHANGED
|
@@ -15,9 +15,11 @@ _Update the workspace root version in a monorepo_
|
|
|
15
15
|
|
|
16
16
|
## Why use it?
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Git tags mark a specific point in a repo's history and are usually created before release. Thanks to these tags, we can easily send people links and point to specific code. We can also compare tags to see how files have changed.
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
Creating tags can be tricky in monorepos, because we can release many packages at once: How do we create just 1 tag (no matter how many packages) and give it a name that resembles a [semantic version](https://semver.org/)?
|
|
21
|
+
|
|
22
|
+
Solution: We let the workspace root's version indicate the state of the whole project, then set the tag name to be this version. `update-workspace-root-version` helps you update the version automatically.
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
## Usage
|
|
@@ -59,19 +61,7 @@ update-workspace-root-version --algorithm increment-by-one
|
|
|
59
61
|
|
|
60
62
|
### Limitations
|
|
61
63
|
|
|
62
|
-
The codemod
|
|
63
|
-
|
|
64
|
-
To better meet your needs, consider cloning the repo and running the codemod locally.
|
|
65
|
-
|
|
66
|
-
```sh
|
|
67
|
-
cd <path/to/cloned/repo>
|
|
68
|
-
|
|
69
|
-
# Compile TypeScript
|
|
70
|
-
pnpm build
|
|
71
|
-
|
|
72
|
-
# Run codemod
|
|
73
|
-
./dist/bin/update-workspace-root-version.js --root <path/to/your/project>
|
|
74
|
-
```
|
|
64
|
+
The codemod assumes that every package follows semantic versioning. It is designed to cover typical cases.
|
|
75
65
|
|
|
76
66
|
|
|
77
67
|
## Compatibility
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { join } from 'node:path';
|
|
2
2
|
import { findFiles } from '@codemod-utils/files';
|
|
3
3
|
import { readPackageJson } from '@codemod-utils/json';
|
|
4
|
+
import { allow } from '../utils/version/index.js';
|
|
4
5
|
function getPackageRoots(options) {
|
|
5
6
|
const { projectRoot } = options;
|
|
6
7
|
const packageRoots = findFiles('**/package.json', {
|
|
@@ -18,8 +19,10 @@ function getPackageRoots(options) {
|
|
|
18
19
|
}
|
|
19
20
|
export function getPackageVersions(options) {
|
|
20
21
|
const packageRoots = getPackageRoots(options);
|
|
21
|
-
return packageRoots
|
|
22
|
+
return packageRoots
|
|
23
|
+
.map((packageRoot) => {
|
|
22
24
|
const packageJson = readPackageJson({ projectRoot: packageRoot });
|
|
23
25
|
return packageJson['version'];
|
|
24
|
-
})
|
|
26
|
+
})
|
|
27
|
+
.filter(allow);
|
|
25
28
|
}
|
|
@@ -2,5 +2,5 @@ import { readPackageJson } from '@codemod-utils/json';
|
|
|
2
2
|
export function getWorkspaceRootVersion(options) {
|
|
3
3
|
const { projectRoot } = options;
|
|
4
4
|
const packageJson = readPackageJson({ projectRoot });
|
|
5
|
-
return packageJson['version'];
|
|
5
|
+
return packageJson['version'] ?? '0.0.0';
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "update-workspace-root-version",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Update the workspace root version in a monorepo",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
"@sondr3/minitest": "^0.1.2",
|
|
36
36
|
"@tsconfig/node18": "^18.2.4",
|
|
37
37
|
"@tsconfig/strictest": "^2.0.5",
|
|
38
|
-
"@types/node": "^18.19.
|
|
38
|
+
"@types/node": "^18.19.49",
|
|
39
39
|
"@types/yargs": "^17.0.33",
|
|
40
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
41
|
-
"@typescript-eslint/parser": "^8.
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^8.4.0",
|
|
41
|
+
"@typescript-eslint/parser": "^8.4.0",
|
|
42
42
|
"concurrently": "^8.2.2",
|
|
43
43
|
"eslint": "^8.57.0",
|
|
44
44
|
"eslint-config-prettier": "^9.1.0",
|
|
45
45
|
"eslint-import-resolver-typescript": "^3.6.3",
|
|
46
|
-
"eslint-plugin-import": "^2.
|
|
46
|
+
"eslint-plugin-import": "^2.30.0",
|
|
47
47
|
"eslint-plugin-n": "^17.10.2",
|
|
48
48
|
"eslint-plugin-prettier": "^5.2.1",
|
|
49
49
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
File without changes
|
|
File without changes
|