yarn-version 8.7.0 → 9.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 (42) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +2 -152
  3. package/package.json +9 -39
  4. package/yarn-version.mjs +3 -0
  5. package/dist/index-node.mjs +0 -1251
  6. package/dist/index-node.mjs.map +0 -1
  7. package/rollup.config.mjs +0 -12
  8. package/src/__fixtures__/basic/package.json +0 -4
  9. package/src/__fixtures__/basic/yarn.lock +0 -12
  10. package/src/__fixtures__/monorepo/package.json +0 -7
  11. package/src/__fixtures__/monorepo/packages/package-1/package.json +0 -4
  12. package/src/__fixtures__/monorepo/packages/package-2/package.json +0 -7
  13. package/src/__fixtures__/monorepo/packages/package-3/package.json +0 -7
  14. package/src/__fixtures__/monorepo/packages/package-4/package.json +0 -7
  15. package/src/__fixtures__/monorepo/packages/package-5/package.json +0 -8
  16. package/src/__fixtures__/monorepo/yarn.lock +0 -0
  17. package/src/__fixtures__/no-version/package.json +0 -3
  18. package/src/__fixtures__/no-version/yarn.lock +0 -0
  19. package/src/__fixtures__/with-lifecycle/.yarn/install-state.gz +0 -0
  20. package/src/__fixtures__/with-lifecycle/package.json +0 -7
  21. package/src/__fixtures__/with-lifecycle/yarn.lock +0 -11
  22. package/src/commands/version.test.ts +0 -94
  23. package/src/commands/version.ts +0 -902
  24. package/src/index.ts +0 -13
  25. package/src/missing-types.d.ts +0 -11
  26. package/src/utils/UsageError.ts +0 -6
  27. package/src/utils/bumpTypeUtils.ts +0 -113
  28. package/src/utils/conventionalChangelogUtils.test.ts +0 -761
  29. package/src/utils/conventionalChangelogUtils.ts +0 -104
  30. package/src/utils/conventionalCommitConfigUtils.ts +0 -20
  31. package/src/utils/execCommand.ts +0 -189
  32. package/src/utils/generatorUtils.ts +0 -11
  33. package/src/utils/gitUtils.ts +0 -193
  34. package/src/utils/githubUtils.ts +0 -82
  35. package/src/utils/mapUtils.ts +0 -7
  36. package/src/utils/packageDependenciesUtils.test.ts +0 -24
  37. package/src/utils/packageDependenciesUtils.ts +0 -80
  38. package/src/utils/packageUtils.ts +0 -97
  39. package/src/utils/updateChangelog.ts +0 -39
  40. package/src/utils/workspaceUtils.ts +0 -142
  41. package/tsconfig.json +0 -23
  42. package/vitest.config.js +0 -9
package/src/index.ts DELETED
@@ -1,13 +0,0 @@
1
- import fs from "node:fs";
2
- import { program } from "commander";
3
-
4
- import "./commands/version.ts";
5
-
6
- // relative to dist directory
7
- const pkg = JSON.parse(
8
- // eslint-disable-next-line unicorn/prefer-json-parse-buffer
9
- fs.readFileSync(new URL("../package.json", import.meta.url), "utf8"),
10
- );
11
-
12
- program.name(pkg.name).description(pkg.description).version(pkg.version);
13
- program.parse();
@@ -1,11 +0,0 @@
1
- // declare module "conventional-changelog-core" {
2
- // export default function conventionalChangelogCore(
3
- // options: any,
4
- // context?: any,
5
- // gitRawCommitsOpts?: any,
6
- // parserOpts?: any,
7
- // writerOpts?: any,
8
- // gitRawExecOpts?: any,
9
- // ): Readable;
10
- // }
11
- declare module "@pob/pretty-pkg";
@@ -1,6 +0,0 @@
1
- export class UsageError extends Error {
2
- constructor(message: string) {
3
- super(message);
4
- this.name = "UsageError";
5
- }
6
- }
@@ -1,113 +0,0 @@
1
- import semver from "semver";
2
- import { UsageError } from "./UsageError.ts";
3
- import type { Workspace } from "./packageUtils.ts";
4
- import { getWorkspaceName } from "./workspaceUtils.ts";
5
-
6
- export type BumpType = "major" | "minor" | "patch";
7
-
8
- // https://github.com/yarnpkg/berry/blob/506ded5f5f5a89553435940c74f1d857fd685a42/packages/plugin-version/sources/versionUtils.ts#L10
9
- // Basically we only support auto-upgrading the ranges that are very simple (^x.y.z, ~x.y.z, >=x.y.z, and of course x.y.z)
10
- const SUPPORTED_UPGRADE_REGEXP =
11
- // eslint-disable-next-line regexp/no-unused-capturing-group
12
- /^((?:>=|[~^])?)(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-z-][0-9a-z-]*)(\.(0|[1-9]\d*|\d*[a-z-][0-9a-z-]*))*)?(\+[0-9a-z-]+(\.[0-9a-z-]+)*)?$/i;
13
-
14
- const yarnWorkspaceProtocol = "workspace:";
15
-
16
- export const calcBumpRange = (
17
- workspace: Workspace,
18
- range: string,
19
- newVersion: string,
20
- ): string => {
21
- if (range === "*") {
22
- return range;
23
- }
24
-
25
- let useWorkspaceProtocol = false;
26
-
27
- if (range.startsWith(yarnWorkspaceProtocol)) {
28
- const slicedRange = range.slice(yarnWorkspaceProtocol.length);
29
-
30
- // Workspaces referenced through their path never get upgraded ("workspace:packages/yarnpkg-core")
31
- if (slicedRange === workspace.relativeCwd) {
32
- return range;
33
- }
34
-
35
- if (slicedRange === "*") {
36
- return range;
37
- }
38
-
39
- range = slicedRange;
40
- useWorkspaceProtocol = true;
41
- }
42
-
43
- const parsed = SUPPORTED_UPGRADE_REGEXP.exec(range);
44
- if (!parsed) {
45
- const workspaceName = getWorkspaceName(workspace);
46
- throw new Error(`Couldn't bump range ${range} in ${workspaceName}`);
47
- }
48
-
49
- return `${useWorkspaceProtocol ? yarnWorkspaceProtocol : ""}${
50
- parsed[1] ?? ""
51
- }${newVersion}`;
52
- };
53
-
54
- export const getHighestBumpType = (bumpTypes: BumpType[]): BumpType => {
55
- if (bumpTypes.includes("major")) {
56
- return "major";
57
- }
58
-
59
- if (bumpTypes.includes("minor")) {
60
- return "minor";
61
- }
62
-
63
- return "patch";
64
- };
65
-
66
- export const calcBumpType = (
67
- bumpType: BumpType,
68
- maxBumpType: BumpType,
69
- ): BumpType => {
70
- if (maxBumpType === "major") {
71
- return bumpType;
72
- }
73
-
74
- if (maxBumpType === "minor") {
75
- return bumpType === "major" || bumpType === "minor" ? "minor" : "patch";
76
- }
77
-
78
- return "patch";
79
- };
80
-
81
- const incVersion = (version: string, bumpType: BumpType): string | null => {
82
- // handle breaking of 0.x
83
- if (bumpType === "major" && semver.major(version) === 0) {
84
- bumpType = "minor";
85
- }
86
- return semver.inc(version, bumpType);
87
- };
88
-
89
- export const incrementVersion = (
90
- workspace: Workspace,
91
- currentVersion: string,
92
- bumpType: BumpType,
93
- ): string => {
94
- const newVersion = incVersion(currentVersion, bumpType);
95
-
96
- if (!newVersion) {
97
- throw new UsageError(
98
- `Could not determine next version for "${getWorkspaceName(
99
- workspace,
100
- )}" (currentVersion: ${currentVersion}, bumpType: ${bumpType}})`,
101
- );
102
- }
103
-
104
- return newVersion;
105
- };
106
-
107
- // const createPrerelease = (
108
- // version: string,
109
- // prereleaseType: ReleaseType,
110
- // prereleaseId: string,
111
- // ) => {
112
- // return semver.inc(version, prereleaseType, prereleaseId);
113
- // };