yarn-version 8.6.1 → 8.7.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 CHANGED
@@ -3,6 +3,15 @@
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.0](https://github.com/christophehurpeau/pob/compare/yarn-version@8.6.1...yarn-version@8.7.0) (2025-11-18)
7
+
8
+ ### Features
9
+
10
+ * use new nightingale logger-cli
11
+
12
+ Version bump for dependency: @pob/rollup-esbuild
13
+
14
+
6
15
  ## [8.6.1](https://github.com/christophehurpeau/pob/compare/yarn-version@8.6.0...yarn-version@8.6.1) (2025-11-04)
7
16
 
8
17
  ### Bug Fixes
@@ -1,6 +1,6 @@
1
1
  import fs$1 from 'node:fs';
2
2
  import { program, Option } from 'commander';
3
- import { addConfig, ConsoleHandler, Logger, Level } from 'nightingale';
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';
@@ -664,15 +664,7 @@ const todayInYYYYMMDD = () => {
664
664
  });
665
665
  return dateFormatter.format(/* @__PURE__ */ new Date());
666
666
  };
667
- const versionCommandAction = async (options, { nightingaleHandler = new ConsoleHandler(Level.INFO) } = {}) => {
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");
667
+ const versionCommandAction = async (options, { logger = new LoggerCLI("yarn-version", { json: options.json }) } = {}) => {
676
668
  const rootWorkspace = await (options.cwdIsRoot ? createWorkspace(options.cwd) : findRootWorkspace(options.cwd));
677
669
  if (!rootWorkspace) {
678
670
  throw new UsageError("Could not find root workspace from this path.");
@@ -720,36 +712,38 @@ There are uncommitted changes in the git repository. Please commit or stash them
720
712
  const buildTagName = (workspace, version) => `${isMonorepo && workspace !== rootWorkspace ? `${getWorkspaceName(workspace)}@` : options.tagVersionPrefix}${version}`;
721
713
  const changedWorkspaces = /* @__PURE__ */ new Map();
722
714
  const dependenciesMap = isMonorepo ? buildDependenciesMaps(project) : null;
723
- logger.info(
724
- options.force ? "Check all workspaces (force option)" : "Finding changed workspaces"
725
- );
726
715
  const bumpableWorkspaces = [];
727
- for (const workspace of workspaces) {
728
- const workspaceName = getWorkspaceName(workspace);
729
- const isRoot = workspace === rootWorkspace;
730
- if (isRoot && isMonorepo && isMonorepoVersionIndependent) continue;
731
- const version = workspace.pkg.version;
732
- if (!version || version === "0.0.0") {
733
- if ((isRoot || isMonorepoVersionIndependent) && (!isMonorepo || !isMonorepoVersionIndependent)) {
734
- throw new UsageError(
735
- 'package.json has no version in its manifest. For the first release, set to "1.0.0-pre" or "0.1.0-pre".'
736
- );
716
+ logger.group(
717
+ options.force ? "Check all workspaces (force option)" : "Finding changed workspaces",
718
+ () => {
719
+ for (const workspace of workspaces) {
720
+ const workspaceName = getWorkspaceName(workspace);
721
+ const isRoot = workspace === rootWorkspace;
722
+ if (isRoot && isMonorepo && isMonorepoVersionIndependent) continue;
723
+ const version = workspace.pkg.version;
724
+ if (!version || version === "0.0.0") {
725
+ if ((isRoot || isMonorepoVersionIndependent) && (!isMonorepo || !isMonorepoVersionIndependent)) {
726
+ throw new UsageError(
727
+ 'package.json has no version in its manifest. For the first release, set to "1.0.0-pre" or "0.1.0-pre".'
728
+ );
729
+ }
730
+ logger.info(`${workspaceName}: skipped (no version)`);
731
+ continue;
732
+ }
733
+ bumpableWorkspaces.push({
734
+ workspace,
735
+ workspaceName,
736
+ isRoot,
737
+ version
738
+ });
739
+ }
740
+ if (bumpableWorkspaces.length > 0) {
741
+ logger.info("Found bumpable workspaces", {
742
+ count: bumpableWorkspaces.length
743
+ });
737
744
  }
738
- logger.info(`${workspaceName}: skipped (no version)`);
739
- continue;
740
745
  }
741
- bumpableWorkspaces.push({
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
- }
746
+ );
753
747
  const previousTagVersionByWorkspace = new Map(
754
748
  await Promise.all(
755
749
  bumpableWorkspaces.map(async ({ workspace, workspaceName, isRoot }) => {
@@ -793,153 +787,155 @@ There are uncommitted changes in the git repository. Please commit or stash them
793
787
  })
794
788
  )
795
789
  );
796
- for (const { workspace, workspaceName } of bumpableWorkspaces) {
797
- let bumpType = null;
798
- let bumpReason;
799
- if (options.force) {
800
- bumpType = options.force;
801
- bumpReason = "forced by --force flag";
802
- } else {
803
- const commits = commitsByWorkspace?.get(workspace);
804
- if (!commits || commits.length === 0) {
805
- logger.info(`${workspaceName}: skipped (no changes)`);
806
- continue;
790
+ await logger.group("Finding changed workspaces", async () => {
791
+ for (const { workspace, workspaceName } of bumpableWorkspaces) {
792
+ let bumpType = null;
793
+ let bumpReason;
794
+ if (options.force) {
795
+ bumpType = options.force;
796
+ bumpReason = "forced by --force flag";
797
+ } else {
798
+ const commits = commitsByWorkspace?.get(workspace);
799
+ if (!commits || commits.length === 0) {
800
+ logger.info(`${workspaceName}: skipped (no changes)`);
801
+ continue;
802
+ }
803
+ const { releaseType, reason } = await recommendBump(
804
+ commits,
805
+ conventionalCommitConfig
806
+ );
807
+ bumpReason = reason;
808
+ if (releaseType) {
809
+ bumpType = releaseType;
810
+ }
807
811
  }
808
- const { releaseType, reason } = await recommendBump(
809
- commits,
810
- conventionalCommitConfig
811
- );
812
- bumpReason = reason;
813
- if (releaseType) {
814
- bumpType = releaseType;
812
+ if (bumpType) {
813
+ if (isMonorepo && !workspace.pkg.name) {
814
+ throw new Error("Workspace name is required");
815
+ }
816
+ const currentVersion = workspace.pkg.version;
817
+ if (!currentVersion) {
818
+ throw new UsageError(
819
+ `Invalid "${getWorkspaceName(workspace)}" version`
820
+ );
821
+ }
822
+ changedWorkspaces.set(workspace, {
823
+ bumpType,
824
+ bumpReason
825
+ });
815
826
  }
816
827
  }
817
- if (bumpType) {
818
- if (isMonorepo && !workspace.pkg.name) {
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
- });
828
+ if (changedWorkspaces.size === 0) {
829
+ logger.info("No changed workspaces");
831
830
  }
832
- }
833
- if (changedWorkspaces.size === 0) {
834
- logger.info("No changed workspaces");
835
- return;
836
- }
837
- logger.info("Preparing bumping");
831
+ });
838
832
  const bumpedWorkspaces = /* @__PURE__ */ new Map();
839
833
  const noVersionToUpdateWorkspaces = /* @__PURE__ */ new Map();
840
834
  const batches = dependenciesMap ? buildTopologicalOrderBatches(project, dependenciesMap) : [[rootWorkspace]];
841
- for (const batch of batches) {
842
- for (const workspace of batch) {
843
- const currentVersion = workspace.pkg.version;
844
- if (!currentVersion && !workspace.pkg.private) {
845
- throw new UsageError(
846
- `Invalid "${getWorkspaceName(workspace)}" version`
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)}`
835
+ logger.group("Preparing bumping", () => {
836
+ for (const batch of batches) {
837
+ for (const workspace of batch) {
838
+ const currentVersion = workspace.pkg.version;
839
+ if (!currentVersion && !workspace.pkg.private) {
840
+ throw new UsageError(
841
+ `Invalid "${getWorkspaceName(workspace)}" version`
898
842
  );
899
843
  }
900
- }
901
- const workspaceName = getWorkspaceName(workspace);
902
- if (!currentVersion) {
903
- logger.info(`${workspaceName}: skipped (no version)`);
904
- if (workspace !== rootWorkspace) {
905
- noVersionToUpdateWorkspaces.set(workspace, {
906
- dependenciesToBump
907
- });
844
+ const changedWorkspace = changedWorkspaces.get(workspace);
845
+ let bumpType = null;
846
+ const bumpReasons = [];
847
+ const dependenciesToBump = [];
848
+ if (changedWorkspace) {
849
+ bumpType = changedWorkspace.bumpType;
850
+ bumpReasons.push(changedWorkspace.bumpReason || "by commits");
908
851
  }
909
- } else if (!bumpType) {
910
- logger.info(
911
- `${workspaceName}: skipped (${changedWorkspace ? `no bump recommended by ${options.preset}` : "no changes"})`
912
- );
913
- } else {
914
- const newVersion = incrementVersion(
915
- workspace,
916
- currentVersion,
917
- bumpType
918
- );
919
- const tagName = buildTagName(workspace, newVersion);
920
- if (workspace === rootWorkspace) {
921
- rootNewVersion = newVersion;
922
- rootNewTag = tagName;
852
+ const dependencies = dependenciesMap?.get(workspace);
853
+ if (dependencies) {
854
+ for (const [
855
+ dependencyWorkspace,
856
+ dependencyType,
857
+ dependencyDescriptor
858
+ ] of dependencies) {
859
+ const dependencyBumpedWorkspace = bumpedWorkspaces.get(dependencyWorkspace);
860
+ if (!dependencyBumpedWorkspace) {
861
+ continue;
862
+ }
863
+ if (dependencyType === "peerDependencies" && !options.alwaysBumpPeerDependencies && // skip when peerdependency with a new version satisfied by the existing range.
864
+ satisfies(
865
+ dependencyBumpedWorkspace.newVersion,
866
+ dependencyDescriptor.selector,
867
+ { includePrerelease: true }
868
+ )) {
869
+ continue;
870
+ }
871
+ const newRange = calcBumpRange(
872
+ workspace,
873
+ dependencyDescriptor.selector,
874
+ dependencyBumpedWorkspace.newVersion
875
+ );
876
+ if (dependencyDescriptor.selector === newRange) {
877
+ continue;
878
+ }
879
+ dependenciesToBump.push([
880
+ dependencyType,
881
+ dependencyDescriptor,
882
+ newRange
883
+ ]);
884
+ bumpType = getHighestBumpType([
885
+ bumpType ?? "patch",
886
+ calcBumpType(
887
+ dependencyBumpedWorkspace.bumpType,
888
+ options.bumpDependentsHighestAs
889
+ )
890
+ ]);
891
+ bumpReasons.push(
892
+ `Version bump for dependency: ${PackageDescriptorNameUtils.stringify(dependencyDescriptor.name)}`
893
+ );
894
+ }
923
895
  }
924
- if (workspace !== rootWorkspace || !isMonorepo) {
925
- const bumpReason = bumpReasons.join("\n");
926
- bumpedWorkspaces.set(workspace, {
927
- currentVersion,
928
- bumpType,
929
- bumpReason,
930
- bumpForDependenciesReasons: changedWorkspace ? bumpReasons.slice(1) : bumpReasons,
931
- newVersion,
932
- newTag: tagName,
933
- hasChanged: changedWorkspace !== void 0,
934
- dependenciesToBump
935
- });
896
+ const workspaceName = getWorkspaceName(workspace);
897
+ if (!currentVersion) {
898
+ logger.info(`${workspaceName}: skipped (no version)`);
899
+ if (workspace !== rootWorkspace) {
900
+ noVersionToUpdateWorkspaces.set(workspace, {
901
+ dependenciesToBump
902
+ });
903
+ }
904
+ } else if (!bumpType) {
936
905
  logger.info(
937
- `${workspaceName}: ${currentVersion} -> ${!isMonorepo || isMonorepoVersionIndependent ? newVersion : "bump"} (${bumpReason.replace("\n", " ; ")})`
906
+ `${workspaceName}: skipped (${changedWorkspace ? `no bump recommended by ${options.preset}` : "no changes"})`
938
907
  );
908
+ } else {
909
+ const newVersion = incrementVersion(
910
+ workspace,
911
+ currentVersion,
912
+ bumpType
913
+ );
914
+ const tagName = buildTagName(workspace, newVersion);
915
+ if (workspace === rootWorkspace) {
916
+ rootNewVersion = newVersion;
917
+ rootNewTag = tagName;
918
+ }
919
+ if (workspace !== rootWorkspace || !isMonorepo) {
920
+ const bumpReason = bumpReasons.join("\n");
921
+ bumpedWorkspaces.set(workspace, {
922
+ currentVersion,
923
+ bumpType,
924
+ bumpReason,
925
+ bumpForDependenciesReasons: changedWorkspace ? bumpReasons.slice(1) : bumpReasons,
926
+ newVersion,
927
+ newTag: tagName,
928
+ hasChanged: changedWorkspace !== void 0,
929
+ dependenciesToBump
930
+ });
931
+ logger.info(
932
+ `${workspaceName}: ${currentVersion} -> ${!isMonorepo || isMonorepoVersionIndependent ? newVersion : "bump"} (${bumpReason.replace("\n", " ; ")})`
933
+ );
934
+ }
939
935
  }
940
936
  }
941
937
  }
942
- }
938
+ });
943
939
  if (isMonorepo && !isMonorepoVersionIndependent) {
944
940
  const currentVersion = rootWorkspace.pkg.version;
945
941
  const highestBumpType = getHighestBumpType(
@@ -989,55 +985,61 @@ There are uncommitted changes in the git repository. Please commit or stash them
989
985
  // newVersion, },
990
986
  );
991
987
  }
992
- if (!options.dryRun) {
993
- logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
994
- await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
995
- logger.info("Lifecycle script: preversion");
996
- if (isMonorepoVersionIndependent && rootWorkspace.pkg.scripts?.preversion) {
997
- await execCommand(
998
- rootWorkspace,
999
- ["yarn", "run", "preversion"],
1000
- "inherit"
1001
- );
1002
- }
1003
- for (const workspace of bumpedWorkspaces.keys()) {
1004
- if (workspace.pkg.scripts?.preversion) {
1005
- await execCommand(workspace, ["yarn", "run", "preversion"], "inherit");
988
+ await logger.group("Applying changes", async () => {
989
+ if (!options.dryRun) {
990
+ logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
991
+ await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
992
+ logger.info("Lifecycle script: preversion");
993
+ if (isMonorepoVersionIndependent && rootWorkspace.pkg.scripts?.preversion) {
994
+ await execCommand(
995
+ rootWorkspace,
996
+ ["yarn", "run", "preversion"],
997
+ "inherit"
998
+ );
1006
999
  }
1007
- }
1008
- logger.info("Modifying versions in package.json");
1009
- await Promise.all(
1010
- [...bumpedWorkspaces.entries()].map(
1011
- ([workspace, { newVersion, dependenciesToBump }]) => {
1012
- workspace.pkg.version = newVersion;
1013
- for (const [
1014
- dependencyType,
1015
- dependencyDescriptor,
1016
- dependencyNewRange
1017
- ] of dependenciesToBump) {
1018
- const newDescriptor = PackageDependencyDescriptorUtils.make(
1000
+ for (const workspace of bumpedWorkspaces.keys()) {
1001
+ if (workspace.pkg.scripts?.preversion) {
1002
+ await execCommand(
1003
+ workspace,
1004
+ ["yarn", "run", "preversion"],
1005
+ "inherit"
1006
+ );
1007
+ }
1008
+ }
1009
+ logger.info("Modifying versions in package.json");
1010
+ await Promise.all(
1011
+ [...bumpedWorkspaces.entries()].map(
1012
+ ([workspace, { newVersion, dependenciesToBump }]) => {
1013
+ workspace.pkg.version = newVersion;
1014
+ for (const [
1015
+ dependencyType,
1019
1016
  dependencyDescriptor,
1020
1017
  dependencyNewRange
1021
- );
1022
- const [key, newValue] = PackageDependencyDescriptorUtils.stringify(newDescriptor);
1023
- workspace.pkg[dependencyType][key] = newValue;
1018
+ ] of dependenciesToBump) {
1019
+ const newDescriptor = PackageDependencyDescriptorUtils.make(
1020
+ dependencyDescriptor,
1021
+ dependencyNewRange
1022
+ );
1023
+ const [key, newValue] = PackageDependencyDescriptorUtils.stringify(newDescriptor);
1024
+ workspace.pkg[dependencyType][key] = newValue;
1025
+ }
1026
+ return writePkg(workspace);
1024
1027
  }
1025
- return writePkg(workspace);
1028
+ )
1029
+ );
1030
+ logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
1031
+ await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
1032
+ logger.info("Lifecycle script: version");
1033
+ for (const workspace of bumpedWorkspaces.keys()) {
1034
+ if (workspace.pkg.scripts?.version) {
1035
+ await execCommand(workspace, ["yarn", "run", "version"], "inherit");
1026
1036
  }
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
1037
  }
1036
1038
  }
1037
- }
1038
- if (isMonorepoVersionIndependent && rootWorkspace.pkg.scripts?.version) {
1039
- await execCommand(rootWorkspace, ["yarn", "run", "version"], "inherit");
1040
- }
1039
+ if (isMonorepoVersionIndependent && rootWorkspace.pkg.scripts?.version) {
1040
+ await execCommand(rootWorkspace, ["yarn", "run", "version"], "inherit");
1041
+ }
1042
+ });
1041
1043
  const changelogs = /* @__PURE__ */ new Map();
1042
1044
  await Promise.all(
1043
1045
  [...bumpedWorkspaces.entries()].map(
@@ -1099,10 +1101,10 @@ ${changelog}`
1099
1101
  )
1100
1102
  );
1101
1103
  if (!options.dryRun) {
1102
- console.log();
1104
+ logger.separator();
1103
1105
  logger.info(`${getWorkspaceName(rootWorkspace)}: Running install`);
1104
1106
  await execCommand(rootWorkspace, ["yarn", "install"], "inherit");
1105
- console.log();
1107
+ logger.separator();
1106
1108
  logger.info("Commit, tag and push", {
1107
1109
  changedFiles: await getDirtyFiles(rootWorkspace)
1108
1110
  });
@@ -1238,7 +1240,7 @@ program.command("version").usage("Bump package version using conventional commit
1238
1240
  "--ignore-changes <glob>",
1239
1241
  'Ignore changes in files matching the glob. Example: "**/*.test.js"'
1240
1242
  )
1241
- ).action((options) => versionCommandAction(options));
1243
+ ).addOption(new Option("--json", "Logger json")).action((options) => versionCommandAction(options));
1242
1244
 
1243
1245
  const pkg = JSON.parse(
1244
1246
  // eslint-disable-next-line unicorn/prefer-json-parse-buffer