yarn-version 8.6.1 → 8.7.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/CHANGELOG.md +14 -0
- package/dist/index-node.mjs +257 -230
- package/dist/index-node.mjs.map +1 -1
- package/package.json +7 -12
- package/src/__fixtures__/monorepo-duplicate-names/package.json +7 -0
- package/src/__fixtures__/monorepo-duplicate-names/packages/pkg-a/package.json +4 -0
- package/src/__fixtures__/monorepo-duplicate-names/packages/pkg-b/package.json +4 -0
- package/src/__fixtures__/monorepo-invalid-package-json/package.json +7 -0
- package/src/__fixtures__/monorepo-invalid-package-json/packages/pkg-with-invalid-json/package.json +5 -0
- package/src/__fixtures__/monorepo-nested/package.json +9 -0
- package/src/__fixtures__/monorepo-nested/packages/deep-nested/package.json +4 -0
- package/src/__fixtures__/monorepo-nested/packages/nested-1/packages/package-nested.json +4 -0
- package/src/__fixtures__/monorepo-nested/packages/nested-1/packages/package.json +4 -0
- package/src/__fixtures__/monorepo-nested/packages/package-1/package.json +4 -0
- package/src/__fixtures__/monorepo-no-name/package.json +7 -0
- package/src/__fixtures__/monorepo-no-name/packages/no-name-package/package.json +3 -0
- package/src/__fixtures__/monorepo-object-form/package.json +9 -0
- package/src/__fixtures__/monorepo-object-form/packages/package-1/package.json +4 -0
- package/src/__fixtures__/monorepo-object-form/packages/package-2/package.json +4 -0
- package/src/__fixtures__/monorepo-object-form/packages/package-3/package.json +4 -0
- package/src/__fixtures__/monorepo-object-form/packages/package-4/package.json +4 -0
- package/src/__fixtures__/monorepo-object-form/packages/package-5/package.json +4 -0
- package/src/commands/version.test.ts +14 -8
- package/src/commands/version.ts +269 -273
- package/src/missing-types.d.ts +0 -1
- package/src/utils/conventionalChangelogUtils.test.ts +1 -0
- package/src/utils/mapWorkspaces.test.ts +89 -0
- package/src/utils/packageDependenciesUtils.test.ts +1 -0
- package/src/utils/packageUtils.test.ts +32 -0
- package/src/utils/packageUtils.ts +52 -22
- package/tsconfig.json +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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
|
+
## [8.7.1](https://github.com/christophehurpeau/pob/compare/yarn-version@8.7.0...yarn-version@8.7.1) (2025-11-24)
|
|
7
|
+
|
|
8
|
+
Version bump for dependency: @pob/rollup-esbuild
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [8.7.0](https://github.com/christophehurpeau/pob/compare/yarn-version@8.6.1...yarn-version@8.7.0) (2025-11-18)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* use new nightingale logger-cli
|
|
16
|
+
|
|
17
|
+
Version bump for dependency: @pob/rollup-esbuild
|
|
18
|
+
|
|
19
|
+
|
|
6
20
|
## [8.6.1](https://github.com/christophehurpeau/pob/compare/yarn-version@8.6.0...yarn-version@8.6.1) (2025-11-04)
|
|
7
21
|
|
|
8
22
|
### Bug Fixes
|
package/dist/index-node.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs$1 from 'node:fs';
|
|
2
2
|
import { program, Option } from 'commander';
|
|
3
|
-
import {
|
|
3
|
+
import { LoggerCLI } from 'nightingale';
|
|
4
4
|
import semver, { satisfies } from 'semver';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import { writeChangelogString } from 'conventional-changelog-writer';
|
|
@@ -8,9 +8,7 @@ import { parseCommits } from 'conventional-commits-parser';
|
|
|
8
8
|
import { loadPreset } from 'conventional-changelog-preset-loader';
|
|
9
9
|
import childProcess from 'node:child_process';
|
|
10
10
|
import { Octokit } from '@octokit/rest';
|
|
11
|
-
import fs from 'node:fs/promises';
|
|
12
|
-
import mapWorkspaces from '@npmcli/map-workspaces';
|
|
13
|
-
import prettyPkg from '@pob/pretty-pkg';
|
|
11
|
+
import fs, { glob } from 'node:fs/promises';
|
|
14
12
|
|
|
15
13
|
class UsageError extends Error {
|
|
16
14
|
constructor(message) {
|
|
@@ -568,20 +566,46 @@ const createGitRelease = async (githubClient, parsedRepoUrl, tag, body, prerelea
|
|
|
568
566
|
});
|
|
569
567
|
};
|
|
570
568
|
|
|
569
|
+
async function mapWorkspacesFromPkg({
|
|
570
|
+
cwd,
|
|
571
|
+
pkg
|
|
572
|
+
}) {
|
|
573
|
+
const workspacesPatterns = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces?.packages || [];
|
|
574
|
+
const map = /* @__PURE__ */ new Map();
|
|
575
|
+
for (const pattern of workspacesPatterns) {
|
|
576
|
+
const normalized = pattern.endsWith("package.json") ? pattern : `${pattern.replace(/\/*$/, "")}/package.json`;
|
|
577
|
+
const files = glob(normalized, { cwd });
|
|
578
|
+
for await (const file of files) {
|
|
579
|
+
const packageDir = path.join(cwd, path.dirname(file));
|
|
580
|
+
const packageJson = await readPkg(packageDir);
|
|
581
|
+
const workspaceName = packageJson.name || path.basename(packageDir);
|
|
582
|
+
if (map.has(workspaceName)) {
|
|
583
|
+
const existingWorkspace = map.get(workspaceName);
|
|
584
|
+
if (existingWorkspace && existingWorkspace.cwd !== packageDir) {
|
|
585
|
+
throw new Error(
|
|
586
|
+
`must not have multiple workspaces with the same name
|
|
587
|
+
package '${workspaceName}' has conflicts in the following paths:
|
|
588
|
+
${existingWorkspace.cwd}
|
|
589
|
+
${packageDir}`
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
if (existingWorkspace && existingWorkspace.cwd === packageDir) continue;
|
|
593
|
+
}
|
|
594
|
+
map.set(workspaceName, { cwd: packageDir, pkg: packageJson });
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return map;
|
|
598
|
+
}
|
|
571
599
|
const createProjectWorkspace = async (root) => {
|
|
572
|
-
const map = root.pkg.workspaces ? await
|
|
600
|
+
const map = root.pkg.workspaces ? await mapWorkspacesFromPkg({ cwd: root.cwd, pkg: root.pkg }) : /* @__PURE__ */ new Map();
|
|
573
601
|
const children = new Map(
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
}
|
|
582
|
-
]
|
|
583
|
-
)
|
|
584
|
-
)
|
|
602
|
+
[...map.entries()].map(([packageName, workspace]) => {
|
|
603
|
+
const w = {
|
|
604
|
+
...workspace,
|
|
605
|
+
relativeCwd: path.relative(root.cwd, workspace.cwd)
|
|
606
|
+
};
|
|
607
|
+
return [packageName, w];
|
|
608
|
+
})
|
|
585
609
|
);
|
|
586
610
|
return { root, children };
|
|
587
611
|
};
|
|
@@ -608,8 +632,9 @@ const createWorkspace = async (path2) => {
|
|
|
608
632
|
const pkg = await readPkg(path2);
|
|
609
633
|
return { cwd: path2, pkg };
|
|
610
634
|
};
|
|
611
|
-
async function writePkg(workspace
|
|
612
|
-
const string =
|
|
635
|
+
async function writePkg(workspace) {
|
|
636
|
+
const string = `${JSON.stringify(workspace.pkg, null, 2)}
|
|
637
|
+
`;
|
|
613
638
|
await fs.writeFile(getPackageJsonPath(workspace.cwd), string, "utf8");
|
|
614
639
|
}
|
|
615
640
|
async function readPkg(cwd) {
|
|
@@ -664,15 +689,7 @@ const todayInYYYYMMDD = () => {
|
|
|
664
689
|
});
|
|
665
690
|
return dateFormatter.format(/* @__PURE__ */ new Date());
|
|
666
691
|
};
|
|
667
|
-
const versionCommandAction = async (options, {
|
|
668
|
-
if (options.json) {
|
|
669
|
-
process.env.NIGHTINGALE_CONSOLE_FORMATTER = "json";
|
|
670
|
-
}
|
|
671
|
-
addConfig({
|
|
672
|
-
pattern: /^yarn-version/,
|
|
673
|
-
handler: nightingaleHandler
|
|
674
|
-
});
|
|
675
|
-
const logger = new Logger("yarn-version");
|
|
692
|
+
const versionCommandAction = async (options, { logger = new LoggerCLI("yarn-version", { json: options.json }) } = {}) => {
|
|
676
693
|
const rootWorkspace = await (options.cwdIsRoot ? createWorkspace(options.cwd) : findRootWorkspace(options.cwd));
|
|
677
694
|
if (!rootWorkspace) {
|
|
678
695
|
throw new UsageError("Could not find root workspace from this path.");
|
|
@@ -720,36 +737,38 @@ There are uncommitted changes in the git repository. Please commit or stash them
|
|
|
720
737
|
const buildTagName = (workspace, version) => `${isMonorepo && workspace !== rootWorkspace ? `${getWorkspaceName(workspace)}@` : options.tagVersionPrefix}${version}`;
|
|
721
738
|
const changedWorkspaces = /* @__PURE__ */ new Map();
|
|
722
739
|
const dependenciesMap = isMonorepo ? buildDependenciesMaps(project) : null;
|
|
723
|
-
logger.info(
|
|
724
|
-
options.force ? "Check all workspaces (force option)" : "Finding changed workspaces"
|
|
725
|
-
);
|
|
726
740
|
const bumpableWorkspaces = [];
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
741
|
+
logger.group(
|
|
742
|
+
options.force ? "Check all workspaces (force option)" : "Finding changed workspaces",
|
|
743
|
+
() => {
|
|
744
|
+
for (const workspace of workspaces) {
|
|
745
|
+
const workspaceName = getWorkspaceName(workspace);
|
|
746
|
+
const isRoot = workspace === rootWorkspace;
|
|
747
|
+
if (isRoot && isMonorepo && isMonorepoVersionIndependent) continue;
|
|
748
|
+
const version = workspace.pkg.version;
|
|
749
|
+
if (!version || version === "0.0.0") {
|
|
750
|
+
if ((isRoot || isMonorepoVersionIndependent) && (!isMonorepo || !isMonorepoVersionIndependent)) {
|
|
751
|
+
throw new UsageError(
|
|
752
|
+
'package.json has no version in its manifest. For the first release, set to "1.0.0-pre" or "0.1.0-pre".'
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
logger.info(`${workspaceName}: skipped (no version)`);
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
bumpableWorkspaces.push({
|
|
759
|
+
workspace,
|
|
760
|
+
workspaceName,
|
|
761
|
+
isRoot,
|
|
762
|
+
version
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
if (bumpableWorkspaces.length > 0) {
|
|
766
|
+
logger.info("Found bumpable workspaces", {
|
|
767
|
+
count: bumpableWorkspaces.length
|
|
768
|
+
});
|
|
737
769
|
}
|
|
738
|
-
logger.info(`${workspaceName}: skipped (no version)`);
|
|
739
|
-
continue;
|
|
740
770
|
}
|
|
741
|
-
|
|
742
|
-
workspace,
|
|
743
|
-
workspaceName,
|
|
744
|
-
isRoot,
|
|
745
|
-
version
|
|
746
|
-
});
|
|
747
|
-
}
|
|
748
|
-
if (bumpableWorkspaces.length > 0) {
|
|
749
|
-
logger.info("Found bumpable workspaces", {
|
|
750
|
-
count: bumpableWorkspaces.length
|
|
751
|
-
});
|
|
752
|
-
}
|
|
771
|
+
);
|
|
753
772
|
const previousTagVersionByWorkspace = new Map(
|
|
754
773
|
await Promise.all(
|
|
755
774
|
bumpableWorkspaces.map(async ({ workspace, workspaceName, isRoot }) => {
|
|
@@ -793,153 +812,155 @@ There are uncommitted changes in the git repository. Please commit or stash them
|
|
|
793
812
|
})
|
|
794
813
|
)
|
|
795
814
|
);
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
815
|
+
await logger.group("Finding changed workspaces", async () => {
|
|
816
|
+
for (const { workspace, workspaceName } of bumpableWorkspaces) {
|
|
817
|
+
let bumpType = null;
|
|
818
|
+
let bumpReason;
|
|
819
|
+
if (options.force) {
|
|
820
|
+
bumpType = options.force;
|
|
821
|
+
bumpReason = "forced by --force flag";
|
|
822
|
+
} else {
|
|
823
|
+
const commits = commitsByWorkspace?.get(workspace);
|
|
824
|
+
if (!commits || commits.length === 0) {
|
|
825
|
+
logger.info(`${workspaceName}: skipped (no changes)`);
|
|
826
|
+
continue;
|
|
827
|
+
}
|
|
828
|
+
const { releaseType, reason } = await recommendBump(
|
|
829
|
+
commits,
|
|
830
|
+
conventionalCommitConfig
|
|
831
|
+
);
|
|
832
|
+
bumpReason = reason;
|
|
833
|
+
if (releaseType) {
|
|
834
|
+
bumpType = releaseType;
|
|
835
|
+
}
|
|
807
836
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
837
|
+
if (bumpType) {
|
|
838
|
+
if (isMonorepo && !workspace.pkg.name) {
|
|
839
|
+
throw new Error("Workspace name is required");
|
|
840
|
+
}
|
|
841
|
+
const currentVersion = workspace.pkg.version;
|
|
842
|
+
if (!currentVersion) {
|
|
843
|
+
throw new UsageError(
|
|
844
|
+
`Invalid "${getWorkspaceName(workspace)}" version`
|
|
845
|
+
);
|
|
846
|
+
}
|
|
847
|
+
changedWorkspaces.set(workspace, {
|
|
848
|
+
bumpType,
|
|
849
|
+
bumpReason
|
|
850
|
+
});
|
|
815
851
|
}
|
|
816
852
|
}
|
|
817
|
-
if (
|
|
818
|
-
|
|
819
|
-
throw new Error("Workspace name is required");
|
|
820
|
-
}
|
|
821
|
-
const currentVersion = workspace.pkg.version;
|
|
822
|
-
if (!currentVersion) {
|
|
823
|
-
throw new UsageError(
|
|
824
|
-
`Invalid "${getWorkspaceName(workspace)}" version`
|
|
825
|
-
);
|
|
826
|
-
}
|
|
827
|
-
changedWorkspaces.set(workspace, {
|
|
828
|
-
bumpType,
|
|
829
|
-
bumpReason
|
|
830
|
-
});
|
|
853
|
+
if (changedWorkspaces.size === 0) {
|
|
854
|
+
logger.info("No changed workspaces");
|
|
831
855
|
}
|
|
832
|
-
}
|
|
833
|
-
if (changedWorkspaces.size === 0) {
|
|
834
|
-
logger.info("No changed workspaces");
|
|
835
|
-
return;
|
|
836
|
-
}
|
|
837
|
-
logger.info("Preparing bumping");
|
|
856
|
+
});
|
|
838
857
|
const bumpedWorkspaces = /* @__PURE__ */ new Map();
|
|
839
858
|
const noVersionToUpdateWorkspaces = /* @__PURE__ */ new Map();
|
|
840
859
|
const batches = dependenciesMap ? buildTopologicalOrderBatches(project, dependenciesMap) : [[rootWorkspace]];
|
|
841
|
-
|
|
842
|
-
for (const
|
|
843
|
-
const
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
}
|
|
849
|
-
const changedWorkspace = changedWorkspaces.get(workspace);
|
|
850
|
-
let bumpType = null;
|
|
851
|
-
const bumpReasons = [];
|
|
852
|
-
const dependenciesToBump = [];
|
|
853
|
-
if (changedWorkspace) {
|
|
854
|
-
bumpType = changedWorkspace.bumpType;
|
|
855
|
-
bumpReasons.push(changedWorkspace.bumpReason || "by commits");
|
|
856
|
-
}
|
|
857
|
-
const dependencies = dependenciesMap?.get(workspace);
|
|
858
|
-
if (dependencies) {
|
|
859
|
-
for (const [
|
|
860
|
-
dependencyWorkspace,
|
|
861
|
-
dependencyType,
|
|
862
|
-
dependencyDescriptor
|
|
863
|
-
] of dependencies) {
|
|
864
|
-
const dependencyBumpedWorkspace = bumpedWorkspaces.get(dependencyWorkspace);
|
|
865
|
-
if (!dependencyBumpedWorkspace) {
|
|
866
|
-
continue;
|
|
867
|
-
}
|
|
868
|
-
if (dependencyType === "peerDependencies" && !options.alwaysBumpPeerDependencies && // skip when peerdependency with a new version satisfied by the existing range.
|
|
869
|
-
satisfies(
|
|
870
|
-
dependencyBumpedWorkspace.newVersion,
|
|
871
|
-
dependencyDescriptor.selector,
|
|
872
|
-
{ includePrerelease: true }
|
|
873
|
-
)) {
|
|
874
|
-
continue;
|
|
875
|
-
}
|
|
876
|
-
const newRange = calcBumpRange(
|
|
877
|
-
workspace,
|
|
878
|
-
dependencyDescriptor.selector,
|
|
879
|
-
dependencyBumpedWorkspace.newVersion
|
|
880
|
-
);
|
|
881
|
-
if (dependencyDescriptor.selector === newRange) {
|
|
882
|
-
continue;
|
|
883
|
-
}
|
|
884
|
-
dependenciesToBump.push([
|
|
885
|
-
dependencyType,
|
|
886
|
-
dependencyDescriptor,
|
|
887
|
-
newRange
|
|
888
|
-
]);
|
|
889
|
-
bumpType = getHighestBumpType([
|
|
890
|
-
bumpType ?? "patch",
|
|
891
|
-
calcBumpType(
|
|
892
|
-
dependencyBumpedWorkspace.bumpType,
|
|
893
|
-
options.bumpDependentsHighestAs
|
|
894
|
-
)
|
|
895
|
-
]);
|
|
896
|
-
bumpReasons.push(
|
|
897
|
-
`Version bump for dependency: ${PackageDescriptorNameUtils.stringify(dependencyDescriptor.name)}`
|
|
860
|
+
logger.group("Preparing bumping", () => {
|
|
861
|
+
for (const batch of batches) {
|
|
862
|
+
for (const workspace of batch) {
|
|
863
|
+
const currentVersion = workspace.pkg.version;
|
|
864
|
+
if (!currentVersion && !workspace.pkg.private) {
|
|
865
|
+
throw new UsageError(
|
|
866
|
+
`Invalid "${getWorkspaceName(workspace)}" version`
|
|
898
867
|
);
|
|
899
868
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
if (
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
});
|
|
869
|
+
const changedWorkspace = changedWorkspaces.get(workspace);
|
|
870
|
+
let bumpType = null;
|
|
871
|
+
const bumpReasons = [];
|
|
872
|
+
const dependenciesToBump = [];
|
|
873
|
+
if (changedWorkspace) {
|
|
874
|
+
bumpType = changedWorkspace.bumpType;
|
|
875
|
+
bumpReasons.push(changedWorkspace.bumpReason || "by commits");
|
|
908
876
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
877
|
+
const dependencies = dependenciesMap?.get(workspace);
|
|
878
|
+
if (dependencies) {
|
|
879
|
+
for (const [
|
|
880
|
+
dependencyWorkspace,
|
|
881
|
+
dependencyType,
|
|
882
|
+
dependencyDescriptor
|
|
883
|
+
] of dependencies) {
|
|
884
|
+
const dependencyBumpedWorkspace = bumpedWorkspaces.get(dependencyWorkspace);
|
|
885
|
+
if (!dependencyBumpedWorkspace) {
|
|
886
|
+
continue;
|
|
887
|
+
}
|
|
888
|
+
if (dependencyType === "peerDependencies" && !options.alwaysBumpPeerDependencies && // skip when peerdependency with a new version satisfied by the existing range.
|
|
889
|
+
satisfies(
|
|
890
|
+
dependencyBumpedWorkspace.newVersion,
|
|
891
|
+
dependencyDescriptor.selector,
|
|
892
|
+
{ includePrerelease: true }
|
|
893
|
+
)) {
|
|
894
|
+
continue;
|
|
895
|
+
}
|
|
896
|
+
const newRange = calcBumpRange(
|
|
897
|
+
workspace,
|
|
898
|
+
dependencyDescriptor.selector,
|
|
899
|
+
dependencyBumpedWorkspace.newVersion
|
|
900
|
+
);
|
|
901
|
+
if (dependencyDescriptor.selector === newRange) {
|
|
902
|
+
continue;
|
|
903
|
+
}
|
|
904
|
+
dependenciesToBump.push([
|
|
905
|
+
dependencyType,
|
|
906
|
+
dependencyDescriptor,
|
|
907
|
+
newRange
|
|
908
|
+
]);
|
|
909
|
+
bumpType = getHighestBumpType([
|
|
910
|
+
bumpType ?? "patch",
|
|
911
|
+
calcBumpType(
|
|
912
|
+
dependencyBumpedWorkspace.bumpType,
|
|
913
|
+
options.bumpDependentsHighestAs
|
|
914
|
+
)
|
|
915
|
+
]);
|
|
916
|
+
bumpReasons.push(
|
|
917
|
+
`Version bump for dependency: ${PackageDescriptorNameUtils.stringify(dependencyDescriptor.name)}`
|
|
918
|
+
);
|
|
919
|
+
}
|
|
923
920
|
}
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
hasChanged: changedWorkspace !== void 0,
|
|
934
|
-
dependenciesToBump
|
|
935
|
-
});
|
|
921
|
+
const workspaceName = getWorkspaceName(workspace);
|
|
922
|
+
if (!currentVersion) {
|
|
923
|
+
logger.info(`${workspaceName}: skipped (no version)`);
|
|
924
|
+
if (workspace !== rootWorkspace) {
|
|
925
|
+
noVersionToUpdateWorkspaces.set(workspace, {
|
|
926
|
+
dependenciesToBump
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
} else if (!bumpType) {
|
|
936
930
|
logger.info(
|
|
937
|
-
`${workspaceName}:
|
|
931
|
+
`${workspaceName}: skipped (${changedWorkspace ? `no bump recommended by ${options.preset}` : "no changes"})`
|
|
938
932
|
);
|
|
933
|
+
} else {
|
|
934
|
+
const newVersion = incrementVersion(
|
|
935
|
+
workspace,
|
|
936
|
+
currentVersion,
|
|
937
|
+
bumpType
|
|
938
|
+
);
|
|
939
|
+
const tagName = buildTagName(workspace, newVersion);
|
|
940
|
+
if (workspace === rootWorkspace) {
|
|
941
|
+
rootNewVersion = newVersion;
|
|
942
|
+
rootNewTag = tagName;
|
|
943
|
+
}
|
|
944
|
+
if (workspace !== rootWorkspace || !isMonorepo) {
|
|
945
|
+
const bumpReason = bumpReasons.join("\n");
|
|
946
|
+
bumpedWorkspaces.set(workspace, {
|
|
947
|
+
currentVersion,
|
|
948
|
+
bumpType,
|
|
949
|
+
bumpReason,
|
|
950
|
+
bumpForDependenciesReasons: changedWorkspace ? bumpReasons.slice(1) : bumpReasons,
|
|
951
|
+
newVersion,
|
|
952
|
+
newTag: tagName,
|
|
953
|
+
hasChanged: changedWorkspace !== void 0,
|
|
954
|
+
dependenciesToBump
|
|
955
|
+
});
|
|
956
|
+
logger.info(
|
|
957
|
+
`${workspaceName}: ${currentVersion} -> ${!isMonorepo || isMonorepoVersionIndependent ? newVersion : "bump"} (${bumpReason.replace("\n", " ; ")})`
|
|
958
|
+
);
|
|
959
|
+
}
|
|
939
960
|
}
|
|
940
961
|
}
|
|
941
962
|
}
|
|
942
|
-
}
|
|
963
|
+
});
|
|
943
964
|
if (isMonorepo && !isMonorepoVersionIndependent) {
|
|
944
965
|
const currentVersion = rootWorkspace.pkg.version;
|
|
945
966
|
const highestBumpType = getHighestBumpType(
|
|
@@ -989,55 +1010,61 @@ There are uncommitted changes in the git repository. Please commit or stash them
|
|
|
989
1010
|
// newVersion, },
|
|
990
1011
|
);
|
|
991
1012
|
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
for (const workspace of bumpedWorkspaces.keys()) {
|
|
1004
|
-
if (workspace.pkg.scripts?.preversion) {
|
|
1005
|
-
await execCommand(workspace, ["yarn", "run", "preversion"], "inherit");
|
|
1013
|
+
await logger.group("Applying changes", async () => {
|
|
1014
|
+
if (!options.dryRun) {
|
|
1015
|
+
logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
|
|
1016
|
+
await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
|
|
1017
|
+
logger.info("Lifecycle script: preversion");
|
|
1018
|
+
if (isMonorepoVersionIndependent && rootWorkspace.pkg.scripts?.preversion) {
|
|
1019
|
+
await execCommand(
|
|
1020
|
+
rootWorkspace,
|
|
1021
|
+
["yarn", "run", "preversion"],
|
|
1022
|
+
"inherit"
|
|
1023
|
+
);
|
|
1006
1024
|
}
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1025
|
+
for (const workspace of bumpedWorkspaces.keys()) {
|
|
1026
|
+
if (workspace.pkg.scripts?.preversion) {
|
|
1027
|
+
await execCommand(
|
|
1028
|
+
workspace,
|
|
1029
|
+
["yarn", "run", "preversion"],
|
|
1030
|
+
"inherit"
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
logger.info("Modifying versions in package.json");
|
|
1035
|
+
await Promise.all(
|
|
1036
|
+
[...bumpedWorkspaces.entries()].map(
|
|
1037
|
+
([workspace, { newVersion, dependenciesToBump }]) => {
|
|
1038
|
+
workspace.pkg.version = newVersion;
|
|
1039
|
+
for (const [
|
|
1040
|
+
dependencyType,
|
|
1019
1041
|
dependencyDescriptor,
|
|
1020
1042
|
dependencyNewRange
|
|
1021
|
-
)
|
|
1022
|
-
|
|
1023
|
-
|
|
1043
|
+
] of dependenciesToBump) {
|
|
1044
|
+
const newDescriptor = PackageDependencyDescriptorUtils.make(
|
|
1045
|
+
dependencyDescriptor,
|
|
1046
|
+
dependencyNewRange
|
|
1047
|
+
);
|
|
1048
|
+
const [key, newValue] = PackageDependencyDescriptorUtils.stringify(newDescriptor);
|
|
1049
|
+
workspace.pkg[dependencyType][key] = newValue;
|
|
1050
|
+
}
|
|
1051
|
+
return writePkg(workspace);
|
|
1024
1052
|
}
|
|
1025
|
-
|
|
1053
|
+
)
|
|
1054
|
+
);
|
|
1055
|
+
logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
|
|
1056
|
+
await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
|
|
1057
|
+
logger.info("Lifecycle script: version");
|
|
1058
|
+
for (const workspace of bumpedWorkspaces.keys()) {
|
|
1059
|
+
if (workspace.pkg.scripts?.version) {
|
|
1060
|
+
await execCommand(workspace, ["yarn", "run", "version"], "inherit");
|
|
1026
1061
|
}
|
|
1027
|
-
)
|
|
1028
|
-
);
|
|
1029
|
-
logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
|
|
1030
|
-
await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
|
|
1031
|
-
logger.info("Lifecycle script: version");
|
|
1032
|
-
for (const workspace of bumpedWorkspaces.keys()) {
|
|
1033
|
-
if (workspace.pkg.scripts?.version) {
|
|
1034
|
-
await execCommand(workspace, ["yarn", "run", "version"], "inherit");
|
|
1035
1062
|
}
|
|
1036
1063
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
}
|
|
1064
|
+
if (isMonorepoVersionIndependent && rootWorkspace.pkg.scripts?.version) {
|
|
1065
|
+
await execCommand(rootWorkspace, ["yarn", "run", "version"], "inherit");
|
|
1066
|
+
}
|
|
1067
|
+
});
|
|
1041
1068
|
const changelogs = /* @__PURE__ */ new Map();
|
|
1042
1069
|
await Promise.all(
|
|
1043
1070
|
[...bumpedWorkspaces.entries()].map(
|
|
@@ -1099,10 +1126,10 @@ ${changelog}`
|
|
|
1099
1126
|
)
|
|
1100
1127
|
);
|
|
1101
1128
|
if (!options.dryRun) {
|
|
1102
|
-
|
|
1129
|
+
logger.separator();
|
|
1103
1130
|
logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
|
|
1104
1131
|
await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
|
|
1105
|
-
|
|
1132
|
+
logger.separator();
|
|
1106
1133
|
logger.info("Commit, tag and push", {
|
|
1107
1134
|
changedFiles: await getDirtyFiles(rootWorkspace)
|
|
1108
1135
|
});
|
|
@@ -1238,7 +1265,7 @@ program.command("version").usage("Bump package version using conventional commit
|
|
|
1238
1265
|
"--ignore-changes <glob>",
|
|
1239
1266
|
'Ignore changes in files matching the glob. Example: "**/*.test.js"'
|
|
1240
1267
|
)
|
|
1241
|
-
).action((options) => versionCommandAction(options));
|
|
1268
|
+
).addOption(new Option("--json", "Logger json")).action((options) => versionCommandAction(options));
|
|
1242
1269
|
|
|
1243
1270
|
const pkg = JSON.parse(
|
|
1244
1271
|
// eslint-disable-next-line unicorn/prefer-json-parse-buffer
|