package-versioner 0.7.0 → 0.7.2

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/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import * as fs9 from "node:fs";
5
- import path7 from "node:path";
4
+ import * as fs10 from "fs";
5
+ import path8 from "path";
6
6
  import { Command } from "commander";
7
7
 
8
8
  // src/changelog/changelogRegenerator.ts
9
- import { execSync as execSync2 } from "node:child_process";
10
- import fs from "node:fs";
11
- import path from "node:path";
9
+ import { execSync as execSync2 } from "child_process";
10
+ import fs from "fs";
11
+ import path from "path";
12
12
 
13
13
  // src/utils/logging.ts
14
14
  import chalk from "chalk";
@@ -92,7 +92,7 @@ function log(message, level = "info") {
92
92
  }
93
93
 
94
94
  // src/changelog/commitParser.ts
95
- import { execSync } from "node:child_process";
95
+ import { execSync } from "child_process";
96
96
  var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
97
97
  var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
98
98
  function extractChangelogEntriesFromCommits(projectDir, revisionRange) {
@@ -105,7 +105,23 @@ function extractChangelogEntriesFromCommits(projectDir, revisionRange) {
105
105
  const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
106
106
  return commits.map((commit) => parseCommitMessage(commit)).filter((entry) => entry !== null);
107
107
  } catch (error) {
108
- log(`Error extracting commits: ${error}`, "error");
108
+ const errorMessage = error instanceof Error ? error.message : String(error);
109
+ if (errorMessage.includes("ambiguous argument") && errorMessage.includes("unknown revision")) {
110
+ const tagName = revisionRange.split("..")[0] || revisionRange;
111
+ if (tagName.startsWith("v") && !tagName.includes("@")) {
112
+ log(
113
+ `Error: Tag "${tagName}" not found. If you're using package-specific tags (like "package-name@v1.0.0"), you may need to configure "tagTemplate" in your version.config.json to use: \${packageName}@\${prefix}\${version}`,
114
+ "error"
115
+ );
116
+ } else {
117
+ log(
118
+ `Error: Tag or revision "${tagName}" not found in the repository. Please check if this tag exists or if you need to fetch it from the remote.`,
119
+ "error"
120
+ );
121
+ }
122
+ } else {
123
+ log(`Error extracting commits: ${errorMessage}`, "error");
124
+ }
109
125
  return [];
110
126
  }
111
127
  }
@@ -521,8 +537,8 @@ async function writeChangelog(content, outputPath, dryRun) {
521
537
  }
522
538
 
523
539
  // src/config.ts
524
- import * as fs2 from "node:fs";
525
- import { cwd } from "node:process";
540
+ import * as fs2 from "fs";
541
+ import { cwd } from "process";
526
542
  function loadConfig(configPath) {
527
543
  const localProcess = cwd();
528
544
  const filePath = configPath || `${localProcess}/version.config.json`;
@@ -544,7 +560,7 @@ function loadConfig(configPath) {
544
560
  }
545
561
 
546
562
  // src/core/versionEngine.ts
547
- import { cwd as cwd4 } from "node:process";
563
+ import { cwd as cwd4 } from "process";
548
564
  import { getPackagesSync } from "@manypkg/get-packages";
549
565
 
550
566
  // src/errors/gitError.ts
@@ -591,14 +607,14 @@ function createVersionError(code, details) {
591
607
  }
592
608
 
593
609
  // src/core/versionStrategies.ts
594
- import fs8 from "node:fs";
595
- import * as path6 from "node:path";
610
+ import fs9 from "fs";
611
+ import * as path7 from "path";
596
612
 
597
613
  // src/git/commands.ts
598
- import { cwd as cwd2 } from "node:process";
614
+ import { cwd as cwd2 } from "process";
599
615
 
600
616
  // src/git/commandExecutor.ts
601
- import { exec, execSync as nativeExecSync } from "node:child_process";
617
+ import { exec, execSync as nativeExecSync } from "child_process";
602
618
  var execAsync = (command, options) => {
603
619
  const defaultOptions = { maxBuffer: 1024 * 1024 * 10, ...options };
604
620
  return new Promise((resolve, reject) => {
@@ -618,8 +634,8 @@ var execAsync = (command, options) => {
618
634
  var execSync3 = (command, args) => nativeExecSync(command, { maxBuffer: 1024 * 1024 * 10, ...args });
619
635
 
620
636
  // src/git/repository.ts
621
- import { existsSync, statSync } from "node:fs";
622
- import { join } from "node:path";
637
+ import { existsSync, statSync } from "fs";
638
+ import { join } from "path";
623
639
  function isGitRepository(directory) {
624
640
  const gitDir = join(directory, ".git");
625
641
  if (!existsSync(gitDir)) {
@@ -699,6 +715,11 @@ async function gitProcess(options) {
699
715
  }
700
716
  } catch (err) {
701
717
  const errorMessage = err instanceof Error ? err.message : String(err);
718
+ log(`Git process error: ${errorMessage}`, "error");
719
+ if (err instanceof Error && err.stack) {
720
+ console.error("Git process stack trace:");
721
+ console.error(err.stack);
722
+ }
702
723
  throw createGitError("GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */, errorMessage);
703
724
  }
704
725
  }
@@ -728,9 +749,16 @@ async function createGitCommitAndTag(files, nextTag, commitMessage, skipHooks, d
728
749
  const errorMessage = error instanceof Error ? error.message : String(error);
729
750
  log(`Failed to create git commit and tag: ${errorMessage}`, "error");
730
751
  if (error instanceof Error) {
752
+ console.error("Git operation error details:");
731
753
  console.error(error.stack || error.message);
754
+ if (errorMessage.includes("Command failed:")) {
755
+ const cmdOutput = errorMessage.split("Command failed:")[1];
756
+ if (cmdOutput) {
757
+ console.error("Git command output:", cmdOutput.trim());
758
+ }
759
+ }
732
760
  } else {
733
- console.error(error);
761
+ console.error("Unknown git error:", error);
734
762
  }
735
763
  throw new GitError(`Git operation failed: ${errorMessage}`, "GIT_ERROR" /* GIT_ERROR */);
736
764
  }
@@ -743,38 +771,42 @@ import { getSemverTags } from "git-semver-tags";
743
771
  function escapeRegExp(string) {
744
772
  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
745
773
  }
746
- function formatTag(version, versionPrefix, packageName, tagTemplate = "${prefix}${version}", packageTagTemplate = "${packageName}@${prefix}${version}") {
747
- const variables = {
748
- version,
749
- prefix: versionPrefix || "",
750
- packageName: packageName || ""
751
- };
752
- const template = packageName ? packageTagTemplate : tagTemplate;
753
- return createTemplateString(template, variables);
754
- }
755
- function formatVersionPrefix(versionPrefix, scope) {
756
- if (!versionPrefix) return "";
757
- const cleanPrefix = versionPrefix.replace(/\/$/, "");
758
- if (scope) {
759
- return `${cleanPrefix}/${scope}`;
760
- }
761
- return cleanPrefix;
762
- }
763
- function formatCommitMessage(template, version, packageName, scope) {
764
- return createTemplateString(template, {
765
- version,
766
- scope,
767
- packageName: packageName || ""
768
- });
774
+ function formatVersionPrefix(prefix) {
775
+ return prefix.endsWith("/") ? prefix.slice(0, -1) : prefix;
769
776
  }
770
- function createTemplateString(template, variables) {
771
- return Object.entries(variables).reduce((result, [key, value]) => {
772
- if (value === void 0) {
773
- return result;
777
+ function formatTag(version, prefix, packageName, template, packageSpecificTags) {
778
+ if ((template == null ? void 0 : template.includes("${packageName}")) && !packageName) {
779
+ log(
780
+ 'Warning: Your tagTemplate contains ${packageName} but no package name is available.\nThis will result in an empty package name in the tag (e.g., "@v1.0.0" instead of "my-package@v1.0.0").\n\nTo fix this:\n\u2022 If using synced mode: Set "packageSpecificTags": true in your config to enable package names in tags\n\u2022 If you want global tags: Remove ${packageName} from your tagTemplate (e.g., use "${prefix}${version}")\n\u2022 If using single/async mode: Ensure your package.json has a valid "name" field',
781
+ "warning"
782
+ );
783
+ }
784
+ if (template) {
785
+ return template.replace(/\$\{version\}/g, version).replace(/\$\{prefix\}/g, prefix).replace(/\$\{packageName\}/g, packageName || "");
786
+ }
787
+ if (packageSpecificTags && packageName) {
788
+ return `${packageName}@${prefix}${version}`;
789
+ }
790
+ return `${prefix}${version}`;
791
+ }
792
+ function formatCommitMessage(template, version, packageName, additionalContext) {
793
+ if (template.includes("${packageName}") && !packageName) {
794
+ log(
795
+ 'Warning: Your commitMessage template contains ${packageName} but no package name is available.\nThis will result in an empty package name in the commit message (e.g., "Release @v1.0.0").\n\nTo fix this:\n\u2022 If using synced mode: Set "packageSpecificTags": true to enable package names in commits\n\u2022 If you want generic commit messages: Remove ${packageName} from your commitMessage template\n\u2022 If using single/async mode: Ensure your package.json has a valid "name" field',
796
+ "warning"
797
+ );
798
+ }
799
+ let result = template.replace(/\$\{version\}/g, version).replace(/\$\{packageName\}/g, packageName || "");
800
+ if (additionalContext) {
801
+ for (const [key, value] of Object.entries(additionalContext)) {
802
+ const placeholder = `\${${key}}`;
803
+ result = result.replace(
804
+ new RegExp(placeholder.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"),
805
+ value
806
+ );
774
807
  }
775
- const regex = new RegExp(`\\$\\{${key}\\}`, "g");
776
- return result.replace(regex, value);
777
- }, template);
808
+ }
809
+ return result;
778
810
  }
779
811
 
780
812
  // src/git/tagsAndBranches.ts
@@ -817,56 +849,71 @@ async function lastMergeBranchName(branches, baseBranch) {
817
849
  return null;
818
850
  }
819
851
  }
820
- async function getLatestTagForPackage(packageName, versionPrefix) {
852
+ async function getLatestTagForPackage(packageName, versionPrefix, options) {
821
853
  try {
854
+ const tagTemplate = (options == null ? void 0 : options.tagTemplate) || "${prefix}${version}";
855
+ const packageSpecificTags = (options == null ? void 0 : options.packageSpecificTags) ?? false;
822
856
  const escapedPackageName = escapeRegExp(packageName);
857
+ const escapedPrefix = versionPrefix ? escapeRegExp(versionPrefix) : "";
823
858
  log(
824
- `Looking for tags for package ${packageName} with prefix ${versionPrefix || "none"}`,
859
+ `Looking for tags for package ${packageName} with prefix ${versionPrefix || "none"}, packageSpecificTags: ${packageSpecificTags}`,
825
860
  "debug"
826
861
  );
827
862
  const allTags = await getSemverTags({
828
863
  tagPrefix: versionPrefix
829
864
  });
830
865
  log(`Retrieved ${allTags.length} tags: ${allTags.join(", ")}`, "debug");
831
- let packageTags = [];
832
- if (versionPrefix) {
833
- const pattern1 = new RegExp(`^${escapedPackageName}@${escapeRegExp(versionPrefix)}`);
834
- packageTags = allTags.filter((tag) => pattern1.test(tag));
866
+ if (packageSpecificTags) {
867
+ const packageTagPattern = escapeRegExp(tagTemplate).replace(/\\\$\\\{packageName\\\}/g, `(?:${escapedPackageName})`).replace(/\\\$\\\{prefix\\\}/g, `(?:${escapedPrefix})`).replace(/\\\$\\\{version\\\}/g, "(?:[0-9]+\\.[0-9]+\\.[0-9]+(?:-[a-zA-Z0-9.-]+)?)");
868
+ log(`Using package tag pattern: ${packageTagPattern}`, "debug");
869
+ const packageTagRegex = new RegExp(`^${packageTagPattern}$`);
870
+ let packageTags = allTags.filter((tag) => packageTagRegex.test(tag));
835
871
  if (packageTags.length > 0) {
836
- log(
837
- `Found ${packageTags.length} package tags using pattern: packageName@${versionPrefix}...`,
838
- "debug"
839
- );
872
+ log(`Found ${packageTags.length} package tags using configured pattern`, "debug");
840
873
  log(`Using tag: ${packageTags[0]}`, "debug");
841
874
  return packageTags[0];
842
875
  }
843
- }
844
- if (versionPrefix) {
845
- const pattern2 = new RegExp(`^${escapeRegExp(versionPrefix)}${escapedPackageName}@`);
846
- packageTags = allTags.filter((tag) => pattern2.test(tag));
847
- if (packageTags.length > 0) {
848
- log(
849
- `Found ${packageTags.length} package tags using pattern: ${versionPrefix}packageName@...`,
850
- "debug"
851
- );
852
- log(`Using tag: ${packageTags[0]}`, "debug");
853
- return packageTags[0];
876
+ if (versionPrefix) {
877
+ const pattern1 = new RegExp(`^${escapedPackageName}@${escapeRegExp(versionPrefix)}`);
878
+ packageTags = allTags.filter((tag) => pattern1.test(tag));
879
+ if (packageTags.length > 0) {
880
+ log(
881
+ `Found ${packageTags.length} package tags using pattern: packageName@${versionPrefix}...`,
882
+ "debug"
883
+ );
884
+ log(`Using tag: ${packageTags[0]}`, "debug");
885
+ return packageTags[0];
886
+ }
854
887
  }
855
- }
856
- const pattern3 = new RegExp(`^${escapedPackageName}@`);
857
- packageTags = allTags.filter((tag) => pattern3.test(tag));
858
- log(`Found ${packageTags.length} package tags for ${packageName}`, "debug");
859
- if (packageTags.length === 0) {
860
- log("No matching tags found for pattern: packageName@version", "debug");
861
- if (allTags.length > 0) {
862
- log(`Available tags: ${allTags.join(", ")}`, "debug");
888
+ if (versionPrefix) {
889
+ const pattern2 = new RegExp(`^${escapeRegExp(versionPrefix)}${escapedPackageName}@`);
890
+ packageTags = allTags.filter((tag) => pattern2.test(tag));
891
+ if (packageTags.length > 0) {
892
+ log(
893
+ `Found ${packageTags.length} package tags using pattern: ${versionPrefix}packageName@...`,
894
+ "debug"
895
+ );
896
+ log(`Using tag: ${packageTags[0]}`, "debug");
897
+ return packageTags[0];
898
+ }
899
+ }
900
+ const pattern3 = new RegExp(`^${escapedPackageName}@`);
901
+ packageTags = allTags.filter((tag) => pattern3.test(tag));
902
+ log(`Found ${packageTags.length} package tags for ${packageName}`, "debug");
903
+ if (packageTags.length === 0) {
904
+ log("No matching tags found for pattern: packageName@version", "debug");
905
+ if (allTags.length > 0) {
906
+ log(`Available tags: ${allTags.join(", ")}`, "debug");
907
+ } else {
908
+ log("No tags available in the repository", "debug");
909
+ }
863
910
  } else {
864
- log("No tags available in the repository", "debug");
911
+ log(`Using tag: ${packageTags[0]}`, "debug");
865
912
  }
866
- } else {
867
- log(`Using tag: ${packageTags[0]}`, "debug");
913
+ return packageTags[0] || "";
868
914
  }
869
- return packageTags[0] || "";
915
+ log(`Package-specific tags disabled for ${packageName}, falling back to global tags`, "debug");
916
+ return "";
870
917
  } catch (error) {
871
918
  const errorMessage = error instanceof Error ? error.message : String(error);
872
919
  log(`Failed to get latest tag for package ${packageName}: ${errorMessage}`, "error");
@@ -878,11 +925,12 @@ async function getLatestTagForPackage(packageName, versionPrefix) {
878
925
  }
879
926
 
880
927
  // src/package/packageManagement.ts
881
- import fs4 from "node:fs";
928
+ import fs4 from "fs";
929
+ import path3 from "path";
882
930
 
883
931
  // src/cargo/cargoHandler.ts
884
- import fs3 from "node:fs";
885
- import path2 from "node:path";
932
+ import fs3 from "fs";
933
+ import path2 from "path";
886
934
  import * as TOML from "smol-toml";
887
935
  function getCargoInfo(cargoPath) {
888
936
  var _a;
@@ -968,13 +1016,13 @@ function updatePackageVersion(packagePath, version) {
968
1016
  }
969
1017
 
970
1018
  // src/package/packageProcessor.ts
971
- import * as fs7 from "node:fs";
972
- import path5 from "node:path";
973
- import { exit } from "node:process";
1019
+ import * as fs8 from "fs";
1020
+ import path6 from "path";
1021
+ import { exit } from "process";
974
1022
 
975
1023
  // src/changelog/changelogManager.ts
976
- import * as fs5 from "node:fs";
977
- import * as path3 from "node:path";
1024
+ import * as fs5 from "fs";
1025
+ import * as path4 from "path";
978
1026
  function createChangelog(_packagePath, packageName) {
979
1027
  return {
980
1028
  projectName: packageName,
@@ -990,7 +1038,7 @@ function parseChangelog(filePath) {
990
1038
  fs5.readFileSync(filePath, "utf8");
991
1039
  log(`Parsed changelog at ${filePath}`, "info");
992
1040
  return {
993
- projectName: path3.basename(path3.dirname(filePath)),
1041
+ projectName: path4.basename(path4.dirname(filePath)),
994
1042
  unreleased: [],
995
1043
  versions: []
996
1044
  };
@@ -1259,7 +1307,7 @@ function generateChangelogContent(changelog, repoUrl, format = "keep-a-changelog
1259
1307
  }
1260
1308
  function updateChangelog(packagePath, packageName, version, entries, repoUrl, format = "keep-a-changelog") {
1261
1309
  try {
1262
- const changelogPath = path3.join(packagePath, "CHANGELOG.md");
1310
+ const changelogPath = path4.join(packagePath, "CHANGELOG.md");
1263
1311
  let changelog;
1264
1312
  if (fs5.existsSync(changelogPath)) {
1265
1313
  const existingChangelog = parseChangelog(changelogPath);
@@ -1298,16 +1346,16 @@ function capitalizeFirstLetter(input) {
1298
1346
  }
1299
1347
 
1300
1348
  // src/core/versionCalculator.ts
1301
- import { cwd as cwd3 } from "node:process";
1349
+ import { cwd as cwd3 } from "process";
1302
1350
  import { Bumper } from "conventional-recommended-bump";
1303
1351
  import semver2 from "semver";
1304
1352
 
1305
1353
  // src/utils/manifestHelpers.ts
1306
- import fs6 from "node:fs";
1307
- import path4 from "node:path";
1354
+ import fs6 from "fs";
1355
+ import path5 from "path";
1308
1356
  function getVersionFromManifests(packageDir) {
1309
- const packageJsonPath = path4.join(packageDir, "package.json");
1310
- const cargoTomlPath = path4.join(packageDir, "Cargo.toml");
1357
+ const packageJsonPath = path5.join(packageDir, "package.json");
1358
+ const cargoTomlPath = path5.join(packageDir, "Cargo.toml");
1311
1359
  if (fs6.existsSync(packageJsonPath)) {
1312
1360
  try {
1313
1361
  const packageJson = JSON.parse(fs6.readFileSync(packageJsonPath, "utf-8"));
@@ -1352,14 +1400,15 @@ function getVersionFromManifests(packageDir) {
1352
1400
  };
1353
1401
  }
1354
1402
  function throwIfNoManifestsFound(packageDir) {
1355
- const packageJsonPath = path4.join(packageDir, "package.json");
1356
- const cargoTomlPath = path4.join(packageDir, "Cargo.toml");
1403
+ const packageJsonPath = path5.join(packageDir, "package.json");
1404
+ const cargoTomlPath = path5.join(packageDir, "Cargo.toml");
1357
1405
  throw new Error(
1358
1406
  `Neither package.json nor Cargo.toml found at ${packageDir}. Checked paths: ${packageJsonPath}, ${cargoTomlPath}. Cannot determine version.`
1359
1407
  );
1360
1408
  }
1361
1409
 
1362
1410
  // src/utils/versionUtils.ts
1411
+ import fs7 from "fs";
1363
1412
  import semver from "semver";
1364
1413
  import * as TOML2 from "smol-toml";
1365
1414
  var STANDARD_BUMP_TYPES = ["major", "minor", "patch"];
@@ -1399,32 +1448,90 @@ function bumpVersion(currentVersion, bumpType, prereleaseIdentifier) {
1399
1448
  // src/core/versionCalculator.ts
1400
1449
  async function calculateVersion(config, options) {
1401
1450
  const {
1402
- latestTag = "",
1403
- type,
1404
- versionPrefix = "",
1451
+ type: configType,
1452
+ preset = "angular",
1453
+ versionPrefix,
1454
+ prereleaseIdentifier: configPrereleaseIdentifier,
1405
1455
  branchPattern,
1406
- baseBranch,
1407
- prereleaseIdentifier,
1456
+ baseBranch
1457
+ } = config;
1458
+ const {
1459
+ latestTag,
1460
+ name,
1408
1461
  path: pkgPath,
1409
- name
1462
+ type: optionsType,
1463
+ prereleaseIdentifier: optionsPrereleaseIdentifier
1410
1464
  } = options;
1411
- const preset = config.preset || "conventional-commits";
1465
+ const type = optionsType || configType;
1466
+ const prereleaseIdentifier = optionsPrereleaseIdentifier || configPrereleaseIdentifier;
1412
1467
  const initialVersion = "0.1.0";
1468
+ const hasNoTags = !latestTag || latestTag.trim() === "";
1413
1469
  const normalizedPrereleaseId = normalizePrereleaseIdentifier(prereleaseIdentifier, config);
1414
1470
  try {
1415
1471
  let determineTagSearchPattern2 = function(packageName, prefix) {
1416
- if (packageName) {
1417
- const escapedPackageName = escapeRegExp(packageName);
1418
- const escapedPrefix = escapeRegExp(prefix);
1419
- return `${escapedPackageName}[@]?${escapedPrefix}`;
1472
+ if (!packageName) {
1473
+ return prefix;
1420
1474
  }
1421
- return escapeRegExp(prefix);
1475
+ return `${packageName}@${prefix}`;
1476
+ }, escapeRegExp3 = function(string) {
1477
+ return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1422
1478
  };
1423
- var determineTagSearchPattern = determineTagSearchPattern2;
1424
- const hasNoTags = !latestTag;
1425
- const originalPrefix = versionPrefix;
1479
+ var determineTagSearchPattern = determineTagSearchPattern2, escapeRegExp2 = escapeRegExp3;
1480
+ const originalPrefix = versionPrefix || "";
1426
1481
  const tagSearchPattern = determineTagSearchPattern2(name, originalPrefix);
1427
- const escapedTagPattern = escapeRegExp(tagSearchPattern);
1482
+ const escapedTagPattern = escapeRegExp3(tagSearchPattern);
1483
+ if (!hasNoTags && pkgPath) {
1484
+ const packageDir = pkgPath || cwd3();
1485
+ const manifestResult = getVersionFromManifests(packageDir);
1486
+ if (manifestResult.manifestFound && manifestResult.version) {
1487
+ const cleanedTag = semver2.clean(latestTag) || latestTag;
1488
+ const tagVersion = semver2.clean(cleanedTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
1489
+ const packageVersion = manifestResult.version;
1490
+ if (semver2.gt(packageVersion, tagVersion)) {
1491
+ log(
1492
+ `Warning: Version mismatch detected!
1493
+ \u2022 ${manifestResult.manifestType} version: ${packageVersion}
1494
+ \u2022 Latest Git tag version: ${tagVersion} (from ${latestTag})
1495
+ \u2022 Package version is AHEAD of Git tags
1496
+
1497
+ This usually happens when:
1498
+ \u2022 A version was released but the tag wasn't pushed to the remote repository
1499
+ \u2022 The ${manifestResult.manifestType} was manually updated without creating a corresponding tag
1500
+ \u2022 You're running in CI and the latest tag isn't available yet
1501
+
1502
+ The tool will use the Git tag version (${tagVersion}) as the base for calculation.
1503
+ Expected next version will be based on ${tagVersion}, not ${packageVersion}.
1504
+
1505
+ To fix this mismatch:
1506
+ \u2022 Push missing tags: git push origin --tags
1507
+ \u2022 Or use package version as base by ensuring tags are up to date`,
1508
+ "warning"
1509
+ );
1510
+ } else if (semver2.gt(tagVersion, packageVersion)) {
1511
+ log(
1512
+ `Warning: Version mismatch detected!
1513
+ \u2022 ${manifestResult.manifestType} version: ${packageVersion}
1514
+ \u2022 Latest Git tag version: ${tagVersion} (from ${latestTag})
1515
+ \u2022 Git tag version is AHEAD of package version
1516
+
1517
+ This usually happens when:
1518
+ \u2022 A release was tagged but the ${manifestResult.manifestType} wasn't updated
1519
+ \u2022 You're on an older branch that hasn't been updated with the latest version
1520
+ \u2022 Automated release process created tags but didn't update manifest files
1521
+ \u2022 You pulled tags but not the corresponding commits that update the package version
1522
+
1523
+ The tool will use the Git tag version (${tagVersion}) as the base for calculation.
1524
+ This will likely result in a version that's already been released.
1525
+
1526
+ To fix this mismatch:
1527
+ \u2022 Update ${manifestResult.manifestType}: Set version to ${tagVersion} or higher
1528
+ \u2022 Or checkout the branch/commit that corresponds to the tag
1529
+ \u2022 Or ensure your branch is up to date with the latest changes`,
1530
+ "warning"
1531
+ );
1532
+ }
1533
+ }
1534
+ }
1428
1535
  const specifiedType = type;
1429
1536
  if (specifiedType) {
1430
1537
  if (hasNoTags) {
@@ -1571,13 +1678,39 @@ function calculateNextVersion(version, manifestType, name, releaseType, prerelea
1571
1678
  return result || initialVersion;
1572
1679
  }
1573
1680
 
1681
+ // src/utils/packageMatching.ts
1682
+ function matchesPackageTarget(packageName, target) {
1683
+ if (packageName === target) {
1684
+ return true;
1685
+ }
1686
+ if (target.endsWith("/*")) {
1687
+ const scope = target.slice(0, -2);
1688
+ if (scope.startsWith("@")) {
1689
+ return packageName.startsWith(`${scope}/`);
1690
+ }
1691
+ return packageName.startsWith(`${scope}/`);
1692
+ }
1693
+ if (target === "*") {
1694
+ return true;
1695
+ }
1696
+ return false;
1697
+ }
1698
+ function shouldProcessPackage(packageName, targets = [], skip = []) {
1699
+ if (skip.includes(packageName)) {
1700
+ return false;
1701
+ }
1702
+ if (targets.length === 0) {
1703
+ return true;
1704
+ }
1705
+ return targets.some((target) => matchesPackageTarget(packageName, target));
1706
+ }
1707
+
1574
1708
  // src/package/packageProcessor.ts
1575
1709
  var PackageProcessor = class {
1576
1710
  skip;
1577
1711
  targets;
1578
1712
  versionPrefix;
1579
1713
  tagTemplate;
1580
- packageTagTemplate;
1581
1714
  commitMessageTemplate;
1582
1715
  dryRun;
1583
1716
  skipHooks;
@@ -1590,7 +1723,6 @@ var PackageProcessor = class {
1590
1723
  this.targets = options.targets || [];
1591
1724
  this.versionPrefix = options.versionPrefix || "v";
1592
1725
  this.tagTemplate = options.tagTemplate;
1593
- this.packageTagTemplate = options.packageTagTemplate;
1594
1726
  this.commitMessageTemplate = options.commitMessageTemplate || "";
1595
1727
  this.dryRun = options.dryRun || false;
1596
1728
  this.skipHooks = options.skipHooks || false;
@@ -1618,18 +1750,15 @@ var PackageProcessor = class {
1618
1750
  const pkgsToConsider = packages.filter((pkg) => {
1619
1751
  var _a2;
1620
1752
  const pkgName = pkg.packageJson.name;
1621
- if ((_a2 = this.skip) == null ? void 0 : _a2.includes(pkgName)) {
1622
- log(`Skipping package ${pkgName} as it's in the skip list.`, "info");
1623
- return false;
1624
- }
1625
- if (!this.targets || this.targets.length === 0) {
1626
- return true;
1627
- }
1628
- const isTargeted = this.targets.includes(pkgName);
1629
- if (!isTargeted) {
1630
- log(`Package ${pkgName} not in target list, skipping.`, "info");
1753
+ const shouldProcess = shouldProcessPackage(pkgName, this.targets, this.skip);
1754
+ if (!shouldProcess) {
1755
+ if ((_a2 = this.skip) == null ? void 0 : _a2.includes(pkgName)) {
1756
+ log(`Skipping package ${pkgName} as it's in the skip list.`, "info");
1757
+ } else {
1758
+ log(`Package ${pkgName} not in target list, skipping.`, "info");
1759
+ }
1631
1760
  }
1632
- return isTargeted;
1761
+ return shouldProcess;
1633
1762
  });
1634
1763
  log(`Found ${pkgsToConsider.length} targeted package(s) to process after filtering.`, "info");
1635
1764
  if (pkgsToConsider.length === 0) {
@@ -1642,7 +1771,10 @@ var PackageProcessor = class {
1642
1771
  const formattedPrefix = formatVersionPrefix(this.versionPrefix);
1643
1772
  let latestTagResult = "";
1644
1773
  try {
1645
- latestTagResult = await getLatestTagForPackage(name, this.versionPrefix);
1774
+ latestTagResult = await getLatestTagForPackage(name, this.versionPrefix, {
1775
+ tagTemplate: this.tagTemplate,
1776
+ packageSpecificTags: this.fullConfig.packageSpecificTags
1777
+ });
1646
1778
  } catch (error) {
1647
1779
  const errorMessage = error instanceof Error ? error.message : String(error);
1648
1780
  log(
@@ -1719,9 +1851,9 @@ var PackageProcessor = class {
1719
1851
  }
1720
1852
  let repoUrl;
1721
1853
  try {
1722
- const packageJsonPath2 = path5.join(pkgPath, "package.json");
1723
- if (fs7.existsSync(packageJsonPath2)) {
1724
- const packageJson = JSON.parse(fs7.readFileSync(packageJsonPath2, "utf8"));
1854
+ const packageJsonPath2 = path6.join(pkgPath, "package.json");
1855
+ if (fs8.existsSync(packageJsonPath2)) {
1856
+ const packageJson = JSON.parse(fs8.readFileSync(packageJsonPath2, "utf8"));
1725
1857
  if (packageJson.repository) {
1726
1858
  if (typeof packageJson.repository === "string") {
1727
1859
  repoUrl = packageJson.repository;
@@ -1748,8 +1880,8 @@ var PackageProcessor = class {
1748
1880
  this.fullConfig.changelogFormat
1749
1881
  );
1750
1882
  }
1751
- const packageJsonPath = path5.join(pkgPath, "package.json");
1752
- if (fs7.existsSync(packageJsonPath)) {
1883
+ const packageJsonPath = path6.join(pkgPath, "package.json");
1884
+ if (fs8.existsSync(packageJsonPath)) {
1753
1885
  updatePackageVersion(packageJsonPath, nextVersion);
1754
1886
  }
1755
1887
  const cargoEnabled = ((_a = this.fullConfig.cargo) == null ? void 0 : _a.enabled) !== false;
@@ -1757,14 +1889,14 @@ var PackageProcessor = class {
1757
1889
  const cargoPaths = (_b = this.fullConfig.cargo) == null ? void 0 : _b.paths;
1758
1890
  if (cargoPaths && cargoPaths.length > 0) {
1759
1891
  for (const cargoPath of cargoPaths) {
1760
- const resolvedCargoPath = path5.resolve(pkgPath, cargoPath, "Cargo.toml");
1761
- if (fs7.existsSync(resolvedCargoPath)) {
1892
+ const resolvedCargoPath = path6.resolve(pkgPath, cargoPath, "Cargo.toml");
1893
+ if (fs8.existsSync(resolvedCargoPath)) {
1762
1894
  updatePackageVersion(resolvedCargoPath, nextVersion);
1763
1895
  }
1764
1896
  }
1765
1897
  } else {
1766
- const cargoTomlPath = path5.join(pkgPath, "Cargo.toml");
1767
- if (fs7.existsSync(cargoTomlPath)) {
1898
+ const cargoTomlPath = path6.join(pkgPath, "Cargo.toml");
1899
+ if (fs8.existsSync(cargoTomlPath)) {
1768
1900
  updatePackageVersion(cargoTomlPath, nextVersion);
1769
1901
  }
1770
1902
  }
@@ -1774,7 +1906,7 @@ var PackageProcessor = class {
1774
1906
  this.versionPrefix,
1775
1907
  name,
1776
1908
  this.tagTemplate,
1777
- this.packageTagTemplate
1909
+ this.fullConfig.packageSpecificTags
1778
1910
  );
1779
1911
  const tagMessage = `chore(release): ${name} ${nextVersion}`;
1780
1912
  addTag(packageTag);
@@ -1801,8 +1933,8 @@ var PackageProcessor = class {
1801
1933
  }
1802
1934
  const filesToCommit = [];
1803
1935
  for (const info of updatedPackagesInfo) {
1804
- const packageJsonPath = path5.join(info.path, "package.json");
1805
- if (fs7.existsSync(packageJsonPath)) {
1936
+ const packageJsonPath = path6.join(info.path, "package.json");
1937
+ if (fs8.existsSync(packageJsonPath)) {
1806
1938
  filesToCommit.push(packageJsonPath);
1807
1939
  }
1808
1940
  const cargoEnabled = ((_c = this.fullConfig.cargo) == null ? void 0 : _c.enabled) !== false;
@@ -1810,14 +1942,14 @@ var PackageProcessor = class {
1810
1942
  const cargoPaths = (_d = this.fullConfig.cargo) == null ? void 0 : _d.paths;
1811
1943
  if (cargoPaths && cargoPaths.length > 0) {
1812
1944
  for (const cargoPath of cargoPaths) {
1813
- const resolvedCargoPath = path5.resolve(info.path, cargoPath, "Cargo.toml");
1814
- if (fs7.existsSync(resolvedCargoPath)) {
1945
+ const resolvedCargoPath = path6.resolve(info.path, cargoPath, "Cargo.toml");
1946
+ if (fs8.existsSync(resolvedCargoPath)) {
1815
1947
  filesToCommit.push(resolvedCargoPath);
1816
1948
  }
1817
1949
  }
1818
1950
  } else {
1819
- const cargoTomlPath = path5.join(info.path, "Cargo.toml");
1820
- if (fs7.existsSync(cargoTomlPath)) {
1951
+ const cargoTomlPath = path6.join(info.path, "Cargo.toml");
1952
+ if (fs8.existsSync(cargoTomlPath)) {
1821
1953
  filesToCommit.push(cargoTomlPath);
1822
1954
  }
1823
1955
  }
@@ -1860,16 +1992,9 @@ var PackageProcessor = class {
1860
1992
  };
1861
1993
 
1862
1994
  // src/core/versionStrategies.ts
1863
- function shouldProcessPackage(pkg, config, targets = []) {
1864
- var _a;
1995
+ function shouldProcessPackage2(pkg, config, targets = []) {
1865
1996
  const pkgName = pkg.packageJson.name;
1866
- if ((_a = config.skip) == null ? void 0 : _a.includes(pkgName)) {
1867
- return false;
1868
- }
1869
- if (!targets || targets.length === 0) {
1870
- return true;
1871
- }
1872
- return targets.includes(pkgName);
1997
+ return shouldProcessPackage(pkgName, targets, config.skip);
1873
1998
  }
1874
1999
  function createSyncedStrategy(config) {
1875
2000
  return async (packages) => {
@@ -1882,16 +2007,41 @@ function createSyncedStrategy(config) {
1882
2007
  commitMessage = "chore(release): v${version}",
1883
2008
  prereleaseIdentifier,
1884
2009
  dryRun,
1885
- skipHooks
2010
+ skipHooks,
2011
+ mainPackage
1886
2012
  } = config;
1887
2013
  const formattedPrefix = formatVersionPrefix(versionPrefix || "v");
1888
2014
  const latestTag = await getLatestTag();
2015
+ let mainPkgPath = packages.root;
2016
+ let mainPkgName;
2017
+ if (mainPackage) {
2018
+ const mainPkg = packages.packages.find((p) => p.packageJson.name === mainPackage);
2019
+ if (mainPkg) {
2020
+ mainPkgPath = mainPkg.dir;
2021
+ mainPkgName = mainPkg.packageJson.name;
2022
+ log(`Using ${mainPkgName} as primary package for version determination`, "info");
2023
+ } else {
2024
+ log(
2025
+ `Main package '${mainPackage}' not found. Using root package for version determination.`,
2026
+ "warning"
2027
+ );
2028
+ }
2029
+ }
2030
+ if (!mainPkgPath) {
2031
+ mainPkgPath = process.cwd();
2032
+ log(
2033
+ `No valid package path found, using current working directory: ${mainPkgPath}`,
2034
+ "warning"
2035
+ );
2036
+ }
1889
2037
  const nextVersion = await calculateVersion(config, {
1890
2038
  latestTag,
1891
2039
  versionPrefix: formattedPrefix,
1892
2040
  branchPattern,
1893
2041
  baseBranch,
1894
2042
  prereleaseIdentifier,
2043
+ path: mainPkgPath,
2044
+ name: mainPkgName,
1895
2045
  type: config.type
1896
2046
  });
1897
2047
  if (!nextVersion) {
@@ -1900,25 +2050,35 @@ function createSyncedStrategy(config) {
1900
2050
  }
1901
2051
  const files = [];
1902
2052
  const updatedPackages = [];
2053
+ const processedPaths = /* @__PURE__ */ new Set();
1903
2054
  try {
1904
- const rootPkgPath = path6.join(packages.root, "package.json");
1905
- if (fs8.existsSync(rootPkgPath)) {
1906
- updatePackageVersion(rootPkgPath, nextVersion);
1907
- files.push(rootPkgPath);
1908
- updatedPackages.push("root");
2055
+ if (packages.root) {
2056
+ const rootPkgPath = path7.join(packages.root, "package.json");
2057
+ if (fs9.existsSync(rootPkgPath)) {
2058
+ updatePackageVersion(rootPkgPath, nextVersion);
2059
+ files.push(rootPkgPath);
2060
+ updatedPackages.push("root");
2061
+ processedPaths.add(rootPkgPath);
2062
+ }
2063
+ } else {
2064
+ log("Root package path is undefined, skipping root package.json update", "warning");
1909
2065
  }
1910
2066
  } catch (error) {
1911
2067
  const errMessage = error instanceof Error ? error.message : String(error);
1912
2068
  log(`Failed to update root package.json: ${errMessage}`, "error");
1913
2069
  }
1914
2070
  for (const pkg of packages.packages) {
1915
- if (!shouldProcessPackage(pkg, config)) {
2071
+ if (!shouldProcessPackage2(pkg, config)) {
2072
+ continue;
2073
+ }
2074
+ const packageJsonPath = path7.join(pkg.dir, "package.json");
2075
+ if (processedPaths.has(packageJsonPath)) {
1916
2076
  continue;
1917
2077
  }
1918
- const packageJsonPath = path6.join(pkg.dir, "package.json");
1919
2078
  updatePackageVersion(packageJsonPath, nextVersion);
1920
2079
  files.push(packageJsonPath);
1921
2080
  updatedPackages.push(pkg.packageJson.name);
2081
+ processedPaths.add(packageJsonPath);
1922
2082
  }
1923
2083
  if (updatedPackages.length > 0) {
1924
2084
  log(`Updated ${updatedPackages.length} package(s) to version ${nextVersion}`, "success");
@@ -1926,8 +2086,25 @@ function createSyncedStrategy(config) {
1926
2086
  log("No packages were updated", "warning");
1927
2087
  return;
1928
2088
  }
1929
- const nextTag = formatTag(nextVersion, formattedPrefix, null, tagTemplate);
1930
- const formattedCommitMessage = formatCommitMessage(commitMessage, nextVersion);
2089
+ let tagPackageName = null;
2090
+ let commitPackageName = void 0;
2091
+ if (config.packageSpecificTags && packages.packages.length === 1) {
2092
+ tagPackageName = packages.packages[0].packageJson.name;
2093
+ commitPackageName = packages.packages[0].packageJson.name;
2094
+ }
2095
+ const nextTag = formatTag(
2096
+ nextVersion,
2097
+ formattedPrefix,
2098
+ tagPackageName,
2099
+ tagTemplate,
2100
+ config.packageSpecificTags || false
2101
+ );
2102
+ const formattedCommitMessage = formatCommitMessage(
2103
+ commitMessage,
2104
+ nextVersion,
2105
+ commitPackageName,
2106
+ void 0
2107
+ );
1931
2108
  await createGitCommitAndTag(files, nextTag, formattedCommitMessage, skipHooks, dryRun);
1932
2109
  } catch (error) {
1933
2110
  if (error instanceof VersionError || error instanceof GitError) {
@@ -1945,27 +2122,34 @@ function createSingleStrategy(config) {
1945
2122
  try {
1946
2123
  const {
1947
2124
  packages: configPackages,
2125
+ mainPackage,
1948
2126
  versionPrefix,
1949
2127
  tagTemplate,
1950
- packageTagTemplate,
1951
2128
  commitMessage = "chore(release): ${version}",
1952
2129
  dryRun,
1953
2130
  skipHooks
1954
2131
  } = config;
1955
- if (!configPackages || configPackages.length !== 1) {
2132
+ let packageName;
2133
+ if (mainPackage) {
2134
+ packageName = mainPackage;
2135
+ } else if (configPackages && configPackages.length === 1) {
2136
+ packageName = configPackages[0];
2137
+ } else {
1956
2138
  throw createVersionError(
1957
2139
  "INVALID_CONFIG" /* INVALID_CONFIG */,
1958
- "Single mode requires exactly one package name"
2140
+ "Single mode requires either mainPackage or exactly one package in the packages array"
1959
2141
  );
1960
2142
  }
1961
- const packageName = configPackages[0];
1962
2143
  const pkg = packages.packages.find((p) => p.packageJson.name === packageName);
1963
2144
  if (!pkg) {
1964
2145
  throw createVersionError("PACKAGE_NOT_FOUND" /* PACKAGE_NOT_FOUND */, packageName);
1965
2146
  }
1966
2147
  const pkgPath = pkg.dir;
1967
2148
  const formattedPrefix = formatVersionPrefix(versionPrefix || "v");
1968
- let latestTagResult = await getLatestTagForPackage(packageName, formattedPrefix);
2149
+ let latestTagResult = await getLatestTagForPackage(packageName, formattedPrefix, {
2150
+ tagTemplate,
2151
+ packageSpecificTags: config.packageSpecificTags
2152
+ });
1969
2153
  if (!latestTagResult) {
1970
2154
  const globalTagResult = await getLatestTag();
1971
2155
  latestTagResult = globalTagResult || "";
@@ -1988,7 +2172,7 @@ function createSingleStrategy(config) {
1988
2172
  log(`No version change needed for ${packageName}`, "info");
1989
2173
  return;
1990
2174
  }
1991
- const packageJsonPath = path6.join(pkgPath, "package.json");
2175
+ const packageJsonPath = path7.join(pkgPath, "package.json");
1992
2176
  updatePackageVersion(packageJsonPath, nextVersion);
1993
2177
  log(`Updated package ${packageName} to version ${nextVersion}`, "success");
1994
2178
  const nextTag = formatTag(
@@ -1996,7 +2180,7 @@ function createSingleStrategy(config) {
1996
2180
  formattedPrefix,
1997
2181
  packageName,
1998
2182
  tagTemplate,
1999
- packageTagTemplate
2183
+ config.packageSpecificTags
2000
2184
  );
2001
2185
  const formattedCommitMessage = formatCommitMessage(commitMessage, nextVersion, packageName);
2002
2186
  await createGitCommitAndTag(
@@ -2029,7 +2213,6 @@ function createAsyncStrategy(config) {
2029
2213
  targets: config.packages || [],
2030
2214
  versionPrefix: config.versionPrefix || "v",
2031
2215
  tagTemplate: config.tagTemplate,
2032
- packageTagTemplate: config.packageTagTemplate,
2033
2216
  commitMessageTemplate: config.commitMessage || "",
2034
2217
  dryRun: config.dryRun || false,
2035
2218
  skipHooks: config.skipHooks || false,
@@ -2082,7 +2265,7 @@ function createStrategy(config) {
2082
2265
  if (config.synced) {
2083
2266
  return createSyncedStrategy(config);
2084
2267
  }
2085
- if (((_a = config.packages) == null ? void 0 : _a.length) === 1) {
2268
+ if (config.mainPackage || ((_a = config.packages) == null ? void 0 : _a.length) === 1) {
2086
2269
  return createSingleStrategy(config);
2087
2270
  }
2088
2271
  return createAsyncStrategy(config);
@@ -2127,6 +2310,13 @@ var VersionEngine = class {
2127
2310
  if (!pkgsResult || !pkgsResult.packages) {
2128
2311
  throw createVersionError("PACKAGES_NOT_FOUND" /* PACKAGES_NOT_FOUND */);
2129
2312
  }
2313
+ if (!pkgsResult.root) {
2314
+ log(
2315
+ "Root path is undefined in packages result, setting to current working directory",
2316
+ "warning"
2317
+ );
2318
+ pkgsResult.root = cwd4();
2319
+ }
2130
2320
  this.workspaceCache = pkgsResult;
2131
2321
  return pkgsResult;
2132
2322
  } catch (error) {
@@ -2147,9 +2337,22 @@ var VersionEngine = class {
2147
2337
  } catch (error) {
2148
2338
  if (error instanceof VersionError || error instanceof GitError) {
2149
2339
  log(`Version engine failed: ${error.message} (${error.code || "UNKNOWN"})`, "error");
2340
+ if (error instanceof GitError) {
2341
+ console.error("Git error details:");
2342
+ if (error.message.includes("Command failed:")) {
2343
+ const cmdOutput = error.message.split("Command failed:")[1];
2344
+ if (cmdOutput) {
2345
+ console.error("Command output:", cmdOutput.trim());
2346
+ }
2347
+ }
2348
+ }
2150
2349
  } else {
2151
2350
  const errorMessage = error instanceof Error ? error.message : String(error);
2152
2351
  log(`Version engine failed: ${errorMessage}`, "error");
2352
+ if (error instanceof Error && error.stack) {
2353
+ console.error("Error stack trace:");
2354
+ console.error(error.stack);
2355
+ }
2153
2356
  }
2154
2357
  throw error;
2155
2358
  }
@@ -2166,11 +2369,11 @@ var VersionEngine = class {
2166
2369
  // src/index.ts
2167
2370
  function getPackageVersion() {
2168
2371
  try {
2169
- const packageJsonPath = path7.resolve(
2170
- path7.dirname(import.meta.url.replace("file:", "")),
2372
+ const packageJsonPath = path8.resolve(
2373
+ path8.dirname(import.meta.url.replace("file:", "")),
2171
2374
  "../package.json"
2172
2375
  );
2173
- const packageJsonContent = fs9.readFileSync(packageJsonPath, "utf-8");
2376
+ const packageJsonContent = fs10.readFileSync(packageJsonPath, "utf-8");
2174
2377
  const packageJson = JSON.parse(packageJsonContent);
2175
2378
  return packageJson.version || "0.0.0";
2176
2379
  } catch (error) {
@@ -2227,6 +2430,16 @@ async function run() {
2227
2430
  printJsonOutput();
2228
2431
  } catch (error) {
2229
2432
  log(error instanceof Error ? error.message : String(error), "error");
2433
+ if (error instanceof Error) {
2434
+ console.error("Error details:");
2435
+ console.error(error.stack || error.message);
2436
+ if (error.message.includes("Command failed:")) {
2437
+ const cmdOutput = error.message.split("Command failed:")[1];
2438
+ if (cmdOutput) {
2439
+ console.error("Command output:", cmdOutput.trim());
2440
+ }
2441
+ }
2442
+ }
2230
2443
  process.exit(1);
2231
2444
  }
2232
2445
  });
@@ -2253,7 +2466,7 @@ async function run() {
2253
2466
  const content = await regenerateChangelog(regenerateOptions);
2254
2467
  await writeChangelog(
2255
2468
  content,
2256
- path7.resolve(options.projectDir, options.output),
2469
+ path8.resolve(options.projectDir, options.output),
2257
2470
  options.dryRun
2258
2471
  );
2259
2472
  if (!options.dryRun) {