@releasekit/version 0.2.0-next.9 → 0.3.0-next.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/LICENSE +21 -0
- package/dist/{chunk-7F6RMN2K.js → chunk-4OGOAITO.js} +129 -265
- package/dist/cli.cjs +145 -282
- package/dist/cli.js +1 -1
- package/dist/index.cjs +124 -259
- package/dist/index.d.cts +0 -3
- package/dist/index.d.ts +0 -3
- package/dist/index.js +1 -1
- package/package.json +40 -31
package/dist/cli.cjs
CHANGED
|
@@ -98,7 +98,7 @@ var import_commander = require("commander");
|
|
|
98
98
|
var import_config = require("@releasekit/config");
|
|
99
99
|
|
|
100
100
|
// src/types.ts
|
|
101
|
-
function toVersionConfig(config) {
|
|
101
|
+
function toVersionConfig(config, gitConfig) {
|
|
102
102
|
if (!config) {
|
|
103
103
|
return {
|
|
104
104
|
tagTemplate: "v{version}",
|
|
@@ -107,7 +107,8 @@ function toVersionConfig(config) {
|
|
|
107
107
|
sync: true,
|
|
108
108
|
packages: [],
|
|
109
109
|
updateInternalDependencies: "minor",
|
|
110
|
-
versionPrefix: ""
|
|
110
|
+
versionPrefix: "",
|
|
111
|
+
baseBranch: gitConfig?.branch
|
|
111
112
|
};
|
|
112
113
|
}
|
|
113
114
|
return {
|
|
@@ -126,57 +127,28 @@ function toVersionConfig(config) {
|
|
|
126
127
|
releaseType: bp.releaseType
|
|
127
128
|
})),
|
|
128
129
|
defaultReleaseType: config.defaultReleaseType,
|
|
129
|
-
skipHooks: config.skipHooks,
|
|
130
130
|
mismatchStrategy: config.mismatchStrategy,
|
|
131
131
|
versionPrefix: config.versionPrefix ?? "",
|
|
132
132
|
prereleaseIdentifier: config.prereleaseIdentifier,
|
|
133
|
-
baseBranch:
|
|
133
|
+
baseBranch: gitConfig?.branch,
|
|
134
134
|
cargo: config.cargo
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// src/config.ts
|
|
139
139
|
function loadConfig(options) {
|
|
140
|
-
const
|
|
141
|
-
return toVersionConfig(
|
|
140
|
+
const fullConfig = (0, import_config.loadConfig)(options);
|
|
141
|
+
return toVersionConfig(fullConfig.version, fullConfig.git);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
// src/core/versionEngine.ts
|
|
145
|
-
var
|
|
145
|
+
var import_node_process2 = require("process");
|
|
146
146
|
var import_get_packages = require("@manypkg/get-packages");
|
|
147
147
|
|
|
148
148
|
// src/errors/gitError.ts
|
|
149
149
|
init_baseError();
|
|
150
150
|
var GitError = class extends BaseVersionError {
|
|
151
151
|
};
|
|
152
|
-
function createGitError(code, details) {
|
|
153
|
-
const messages = {
|
|
154
|
-
["NOT_GIT_REPO" /* NOT_GIT_REPO */]: "Not a git repository",
|
|
155
|
-
["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: "Failed to create new version",
|
|
156
|
-
["NO_FILES" /* NO_FILES */]: "No files specified for commit",
|
|
157
|
-
["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: "Commit message is required",
|
|
158
|
-
["GIT_ERROR" /* GIT_ERROR */]: "Git operation failed",
|
|
159
|
-
["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: "Git tag already exists"
|
|
160
|
-
};
|
|
161
|
-
const suggestions = {
|
|
162
|
-
["NOT_GIT_REPO" /* NOT_GIT_REPO */]: [
|
|
163
|
-
"Initialize git repository with: git init",
|
|
164
|
-
"Ensure you are in the correct directory"
|
|
165
|
-
],
|
|
166
|
-
["TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */]: [
|
|
167
|
-
"Delete the existing tag: git tag -d <tag-name>",
|
|
168
|
-
"Use a different version by incrementing manually",
|
|
169
|
-
"Check if this version was already released"
|
|
170
|
-
],
|
|
171
|
-
["GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */]: void 0,
|
|
172
|
-
["NO_FILES" /* NO_FILES */]: void 0,
|
|
173
|
-
["NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */]: void 0,
|
|
174
|
-
["GIT_ERROR" /* GIT_ERROR */]: void 0
|
|
175
|
-
};
|
|
176
|
-
const baseMessage = messages[code];
|
|
177
|
-
const fullMessage = details ? `${baseMessage}: ${details}` : baseMessage;
|
|
178
|
-
return new GitError(fullMessage, code, suggestions[code]);
|
|
179
|
-
}
|
|
180
152
|
|
|
181
153
|
// src/errors/versionError.ts
|
|
182
154
|
init_baseError();
|
|
@@ -401,13 +373,83 @@ var path6 = __toESM(require("path"), 1);
|
|
|
401
373
|
init_commandExecutor();
|
|
402
374
|
var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
|
|
403
375
|
var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
|
|
376
|
+
function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
|
|
377
|
+
try {
|
|
378
|
+
const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
|
|
379
|
+
const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
|
|
380
|
+
const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
|
|
381
|
+
return commits.map((commit) => {
|
|
382
|
+
const [hash, ...messageParts] = commit.split("|||");
|
|
383
|
+
const message = messageParts.join("|||").trim();
|
|
384
|
+
const entry = parseCommitMessage(message);
|
|
385
|
+
if (entry && hash) {
|
|
386
|
+
return { hash: hash.trim(), entry };
|
|
387
|
+
}
|
|
388
|
+
return null;
|
|
389
|
+
}).filter((item) => item !== null);
|
|
390
|
+
} catch (error) {
|
|
391
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
392
|
+
log(`Error extracting all commits with hash: ${errorMessage}`, "error");
|
|
393
|
+
return [];
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
|
|
397
|
+
try {
|
|
398
|
+
const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
|
|
399
|
+
cwd: projectDir,
|
|
400
|
+
encoding: "utf8"
|
|
401
|
+
}).toString().trim();
|
|
402
|
+
if (!output) {
|
|
403
|
+
return false;
|
|
404
|
+
}
|
|
405
|
+
const changedFiles = output.split("\n");
|
|
406
|
+
return changedFiles.some((file) => {
|
|
407
|
+
return packageDirs.some((pkgDir) => {
|
|
408
|
+
if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
const normalizedFile = file.replace(/\\/g, "/");
|
|
412
|
+
const normalizedPkgDir = pkgDir.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
413
|
+
return normalizedFile.startsWith(normalizedPkgDir);
|
|
414
|
+
});
|
|
415
|
+
});
|
|
416
|
+
} catch (error) {
|
|
417
|
+
log(
|
|
418
|
+
`Error checking if commit ${commitHash} touches packages: ${error instanceof Error ? error.message : String(error)}`,
|
|
419
|
+
"debug"
|
|
420
|
+
);
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function extractRepoLevelChangelogEntries(projectDir, revisionRange, packageDirs, sharedPackageDirs = []) {
|
|
425
|
+
try {
|
|
426
|
+
const allCommits = extractAllChangelogEntriesWithHash(projectDir, revisionRange);
|
|
427
|
+
const repoLevelCommits = allCommits.filter((commit) => {
|
|
428
|
+
const touchesPackage = commitTouchesAnyPackage(projectDir, commit.hash, packageDirs, sharedPackageDirs);
|
|
429
|
+
return !touchesPackage;
|
|
430
|
+
});
|
|
431
|
+
if (repoLevelCommits.length > 0) {
|
|
432
|
+
log(
|
|
433
|
+
`Found ${repoLevelCommits.length} repo-level commit(s) (including shared packages: ${sharedPackageDirs.join(", ")})`,
|
|
434
|
+
"debug"
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
return repoLevelCommits.map((c) => c.entry);
|
|
438
|
+
} catch (error) {
|
|
439
|
+
log(`Error extracting repo-level commits: ${error instanceof Error ? error.message : String(error)}`, "warning");
|
|
440
|
+
return [];
|
|
441
|
+
}
|
|
442
|
+
}
|
|
404
443
|
function extractChangelogEntriesFromCommits(projectDir, revisionRange) {
|
|
444
|
+
return extractCommitsFromGitLog(projectDir, revisionRange, true);
|
|
445
|
+
}
|
|
446
|
+
function extractCommitsFromGitLog(projectDir, revisionRange, filterToPath) {
|
|
405
447
|
try {
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
).toString();
|
|
448
|
+
const args = ["log", revisionRange, "--pretty=format:%B---COMMIT_DELIMITER---", "--no-merges"];
|
|
449
|
+
if (filterToPath) {
|
|
450
|
+
args.push("--", ".");
|
|
451
|
+
}
|
|
452
|
+
const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
|
|
411
453
|
const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
|
|
412
454
|
return commits.map((commit) => parseCommitMessage(commit)).filter((entry) => entry !== null);
|
|
413
455
|
} catch (error) {
|
|
@@ -504,162 +546,6 @@ function extractIssueIds(body) {
|
|
|
504
546
|
init_baseError();
|
|
505
547
|
init_commandExecutor();
|
|
506
548
|
|
|
507
|
-
// src/git/commands.ts
|
|
508
|
-
var import_node_process = require("process");
|
|
509
|
-
init_commandExecutor();
|
|
510
|
-
|
|
511
|
-
// src/git/repository.ts
|
|
512
|
-
var import_node_fs = require("fs");
|
|
513
|
-
var import_node_path2 = require("path");
|
|
514
|
-
init_commandExecutor();
|
|
515
|
-
function isGitRepository(directory) {
|
|
516
|
-
const gitDir = (0, import_node_path2.join)(directory, ".git");
|
|
517
|
-
if (!(0, import_node_fs.existsSync)(gitDir)) {
|
|
518
|
-
return false;
|
|
519
|
-
}
|
|
520
|
-
const stats = (0, import_node_fs.statSync)(gitDir);
|
|
521
|
-
if (!stats.isDirectory()) {
|
|
522
|
-
return false;
|
|
523
|
-
}
|
|
524
|
-
try {
|
|
525
|
-
execSync("git", ["rev-parse", "--is-inside-work-tree"], { cwd: directory });
|
|
526
|
-
return true;
|
|
527
|
-
} catch (_error) {
|
|
528
|
-
return false;
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
function getCurrentBranch() {
|
|
532
|
-
const result = execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
533
|
-
return result.toString().trim();
|
|
534
|
-
}
|
|
535
|
-
|
|
536
|
-
// src/git/commands.ts
|
|
537
|
-
async function gitAdd(files) {
|
|
538
|
-
return execAsync("git", ["add", ...files]);
|
|
539
|
-
}
|
|
540
|
-
async function gitCommit(options) {
|
|
541
|
-
const args = ["commit"];
|
|
542
|
-
if (options.amend) {
|
|
543
|
-
args.push("--amend");
|
|
544
|
-
}
|
|
545
|
-
if (options.author) {
|
|
546
|
-
args.push("--author", options.author);
|
|
547
|
-
}
|
|
548
|
-
if (options.date) {
|
|
549
|
-
args.push("--date", options.date);
|
|
550
|
-
}
|
|
551
|
-
if (options.skipHooks) {
|
|
552
|
-
args.push("--no-verify");
|
|
553
|
-
}
|
|
554
|
-
args.push("-m", options.message);
|
|
555
|
-
return execAsync("git", args);
|
|
556
|
-
}
|
|
557
|
-
async function createGitTag(options) {
|
|
558
|
-
const { tag, message = "" } = options;
|
|
559
|
-
const args = ["tag", "-a", "-m", message, tag];
|
|
560
|
-
try {
|
|
561
|
-
return await execAsync("git", args);
|
|
562
|
-
} catch (error) {
|
|
563
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
564
|
-
if (errorMessage.includes("already exists")) {
|
|
565
|
-
throw createGitError(
|
|
566
|
-
"TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
|
|
567
|
-
`Tag '${tag}' already exists in the repository. Please use a different version or delete the existing tag first.`
|
|
568
|
-
);
|
|
569
|
-
}
|
|
570
|
-
throw createGitError("GIT_ERROR" /* GIT_ERROR */, errorMessage);
|
|
571
|
-
}
|
|
572
|
-
}
|
|
573
|
-
async function gitProcess(options) {
|
|
574
|
-
const { files, nextTag, commitMessage, skipHooks, dryRun } = options;
|
|
575
|
-
if (!isGitRepository((0, import_node_process.cwd)())) {
|
|
576
|
-
throw createGitError("NOT_GIT_REPO" /* NOT_GIT_REPO */);
|
|
577
|
-
}
|
|
578
|
-
try {
|
|
579
|
-
if (!dryRun) {
|
|
580
|
-
await gitAdd(files);
|
|
581
|
-
await gitCommit({
|
|
582
|
-
message: commitMessage,
|
|
583
|
-
skipHooks
|
|
584
|
-
});
|
|
585
|
-
if (nextTag) {
|
|
586
|
-
const tagMessage = `New Version ${nextTag} generated at ${(/* @__PURE__ */ new Date()).toISOString()}`;
|
|
587
|
-
await createGitTag({
|
|
588
|
-
tag: nextTag,
|
|
589
|
-
message: tagMessage
|
|
590
|
-
});
|
|
591
|
-
}
|
|
592
|
-
} else {
|
|
593
|
-
log("[DRY RUN] Would add files:", "info");
|
|
594
|
-
for (const file of files) {
|
|
595
|
-
log(` - ${file}`, "info");
|
|
596
|
-
}
|
|
597
|
-
log(`[DRY RUN] Would commit with message: "${commitMessage}"`, "info");
|
|
598
|
-
if (nextTag) {
|
|
599
|
-
log(`[DRY RUN] Would create tag: ${nextTag}`, "info");
|
|
600
|
-
}
|
|
601
|
-
}
|
|
602
|
-
} catch (err) {
|
|
603
|
-
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
604
|
-
if (errorMessage.includes("already exists") && nextTag) {
|
|
605
|
-
log(`Tag '${nextTag}' already exists in the repository.`, "error");
|
|
606
|
-
throw createGitError(
|
|
607
|
-
"TAG_ALREADY_EXISTS" /* TAG_ALREADY_EXISTS */,
|
|
608
|
-
`Tag '${nextTag}' already exists in the repository. Please use a different version or delete the existing tag first.`
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
log(`Git process error: ${errorMessage}`, "error");
|
|
612
|
-
if (err instanceof Error && err.stack) {
|
|
613
|
-
console.error("Git process stack trace:");
|
|
614
|
-
console.error(err.stack);
|
|
615
|
-
}
|
|
616
|
-
throw createGitError("GIT_PROCESS_ERROR" /* GIT_PROCESS_ERROR */, errorMessage);
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
async function createGitCommitAndTag(files, nextTag, commitMessage, skipHooks, dryRun) {
|
|
620
|
-
try {
|
|
621
|
-
if (!files || files.length === 0) {
|
|
622
|
-
throw createGitError("NO_FILES" /* NO_FILES */);
|
|
623
|
-
}
|
|
624
|
-
if (!commitMessage) {
|
|
625
|
-
throw createGitError("NO_COMMIT_MESSAGE" /* NO_COMMIT_MESSAGE */);
|
|
626
|
-
}
|
|
627
|
-
setCommitMessage(commitMessage);
|
|
628
|
-
if (nextTag) {
|
|
629
|
-
addTag(nextTag);
|
|
630
|
-
}
|
|
631
|
-
await gitProcess({
|
|
632
|
-
files,
|
|
633
|
-
nextTag,
|
|
634
|
-
commitMessage,
|
|
635
|
-
skipHooks,
|
|
636
|
-
dryRun
|
|
637
|
-
});
|
|
638
|
-
if (!dryRun) {
|
|
639
|
-
log(`Created tag: ${nextTag}`, "success");
|
|
640
|
-
}
|
|
641
|
-
} catch (error) {
|
|
642
|
-
if (error instanceof GitError) {
|
|
643
|
-
throw error;
|
|
644
|
-
}
|
|
645
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
646
|
-
log(`Failed to create git commit and tag: ${errorMessage}`, "error");
|
|
647
|
-
if (error instanceof Error) {
|
|
648
|
-
console.error("Git operation error details:");
|
|
649
|
-
console.error(error.stack || error.message);
|
|
650
|
-
if (errorMessage.includes("Command failed:")) {
|
|
651
|
-
const cmdOutput = errorMessage.split("Command failed:")[1];
|
|
652
|
-
if (cmdOutput) {
|
|
653
|
-
console.error("Git command output:", cmdOutput.trim());
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
} else {
|
|
657
|
-
console.error("Unknown git error:", error);
|
|
658
|
-
}
|
|
659
|
-
throw new GitError(`Git operation failed: ${errorMessage}`, "GIT_ERROR" /* GIT_ERROR */);
|
|
660
|
-
}
|
|
661
|
-
}
|
|
662
|
-
|
|
663
549
|
// src/git/tagsAndBranches.ts
|
|
664
550
|
var import_git_semver_tags = require("git-semver-tags");
|
|
665
551
|
var import_semver = __toESM(require("semver"), 1);
|
|
@@ -708,8 +594,8 @@ To fix this:
|
|
|
708
594
|
let result = template.replace(/\$\{version\}/g, version).replace(/\$\{packageName\}/g, packageName || "");
|
|
709
595
|
if (additionalContext) {
|
|
710
596
|
for (const [key, value] of Object.entries(additionalContext)) {
|
|
711
|
-
const placeholder = `\${${key}}`;
|
|
712
|
-
result = result.replace(new RegExp(placeholder
|
|
597
|
+
const placeholder = `${key ? `\${${key}}` : ""}`;
|
|
598
|
+
result = result.replace(new RegExp(escapeRegExp(placeholder), "g"), value);
|
|
713
599
|
}
|
|
714
600
|
}
|
|
715
601
|
return result;
|
|
@@ -908,16 +794,16 @@ async function getLatestTagForPackage(packageName, versionPrefix, options) {
|
|
|
908
794
|
}
|
|
909
795
|
|
|
910
796
|
// src/package/packageManagement.ts
|
|
911
|
-
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
912
|
-
var import_node_path4 = __toESM(require("path"), 1);
|
|
913
|
-
|
|
914
|
-
// src/cargo/cargoHandler.ts
|
|
915
797
|
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
916
798
|
var import_node_path3 = __toESM(require("path"), 1);
|
|
799
|
+
|
|
800
|
+
// src/cargo/cargoHandler.ts
|
|
801
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
802
|
+
var import_node_path2 = __toESM(require("path"), 1);
|
|
917
803
|
var import_config2 = require("@releasekit/config");
|
|
918
804
|
var TOML = __toESM(require("smol-toml"), 1);
|
|
919
805
|
function getCargoInfo(cargoPath) {
|
|
920
|
-
if (!
|
|
806
|
+
if (!import_node_fs.default.existsSync(cargoPath)) {
|
|
921
807
|
log(`Cargo.toml file not found at: ${cargoPath}`, "error");
|
|
922
808
|
throw new Error(`Cargo.toml file not found at: ${cargoPath}`);
|
|
923
809
|
}
|
|
@@ -931,7 +817,7 @@ function getCargoInfo(cargoPath) {
|
|
|
931
817
|
name: cargo.package.name,
|
|
932
818
|
version: cargo.package.version || "0.0.0",
|
|
933
819
|
path: cargoPath,
|
|
934
|
-
dir:
|
|
820
|
+
dir: import_node_path2.default.dirname(cargoPath),
|
|
935
821
|
content: cargo
|
|
936
822
|
};
|
|
937
823
|
} catch (error) {
|
|
@@ -957,7 +843,7 @@ function updateCargoVersion(cargoPath, version, dryRun = false) {
|
|
|
957
843
|
cargo.package.version = version;
|
|
958
844
|
}
|
|
959
845
|
const updatedContent = TOML.stringify(cargo);
|
|
960
|
-
|
|
846
|
+
import_node_fs.default.writeFileSync(cargoPath, updatedContent);
|
|
961
847
|
}
|
|
962
848
|
addPackageUpdate(packageName, version, cargoPath);
|
|
963
849
|
log(`${dryRun ? "[DRY RUN] Would update" : "Updated"} Cargo.toml at ${cargoPath} to version ${version}`, "success");
|
|
@@ -977,12 +863,12 @@ function updatePackageVersion(packagePath, version, dryRun = false) {
|
|
|
977
863
|
return;
|
|
978
864
|
}
|
|
979
865
|
try {
|
|
980
|
-
const packageContent =
|
|
866
|
+
const packageContent = import_node_fs2.default.readFileSync(packagePath, "utf8");
|
|
981
867
|
const packageJson = JSON.parse(packageContent);
|
|
982
868
|
const packageName = packageJson.name;
|
|
983
869
|
if (!dryRun) {
|
|
984
870
|
packageJson.version = version;
|
|
985
|
-
|
|
871
|
+
import_node_fs2.default.writeFileSync(packagePath, `${JSON.stringify(packageJson, null, 2)}
|
|
986
872
|
`);
|
|
987
873
|
}
|
|
988
874
|
addPackageUpdate(packageName, version, packagePath);
|
|
@@ -1002,13 +888,21 @@ function updatePackageVersion(packagePath, version, dryRun = false) {
|
|
|
1002
888
|
// src/package/packageProcessor.ts
|
|
1003
889
|
var fs5 = __toESM(require("fs"), 1);
|
|
1004
890
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
1005
|
-
var import_node_process3 = require("process");
|
|
1006
891
|
|
|
1007
892
|
// src/core/versionCalculator.ts
|
|
1008
|
-
var
|
|
893
|
+
var import_node_process = require("process");
|
|
1009
894
|
var import_conventional_recommended_bump = require("conventional-recommended-bump");
|
|
1010
895
|
var import_semver3 = __toESM(require("semver"), 1);
|
|
1011
896
|
|
|
897
|
+
// src/git/repository.ts
|
|
898
|
+
var import_node_fs3 = require("fs");
|
|
899
|
+
var import_node_path4 = require("path");
|
|
900
|
+
init_commandExecutor();
|
|
901
|
+
function getCurrentBranch() {
|
|
902
|
+
const result = execSync("git", ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
903
|
+
return result.toString().trim();
|
|
904
|
+
}
|
|
905
|
+
|
|
1012
906
|
// src/utils/manifestHelpers.ts
|
|
1013
907
|
var import_node_fs4 = __toESM(require("fs"), 1);
|
|
1014
908
|
var import_node_path5 = __toESM(require("path"), 1);
|
|
@@ -1066,13 +960,13 @@ var import_semver2 = __toESM(require("semver"), 1);
|
|
|
1066
960
|
|
|
1067
961
|
// src/git/tagVerification.ts
|
|
1068
962
|
init_commandExecutor();
|
|
1069
|
-
function verifyTag(tagName,
|
|
963
|
+
function verifyTag(tagName, cwd3) {
|
|
1070
964
|
if (!tagName || tagName.trim() === "") {
|
|
1071
965
|
return { exists: false, reachable: false, error: "Empty tag name" };
|
|
1072
966
|
}
|
|
1073
967
|
try {
|
|
1074
968
|
execSync("git", ["rev-parse", "--verify", tagName], {
|
|
1075
|
-
cwd:
|
|
969
|
+
cwd: cwd3,
|
|
1076
970
|
stdio: "ignore"
|
|
1077
971
|
});
|
|
1078
972
|
return { exists: true, reachable: true };
|
|
@@ -1169,11 +1063,11 @@ var VersionMismatchError = class extends Error {
|
|
|
1169
1063
|
this.name = "VersionMismatchError";
|
|
1170
1064
|
}
|
|
1171
1065
|
};
|
|
1172
|
-
async function getBestVersionSource(tagName, packageVersion,
|
|
1066
|
+
async function getBestVersionSource(tagName, packageVersion, cwd3, mismatchStrategy = "error", strictReachable = false) {
|
|
1173
1067
|
if (!tagName?.trim()) {
|
|
1174
1068
|
return packageVersion ? { source: "package", version: packageVersion, reason: "No git tag provided" } : { source: "initial", version: "0.1.0", reason: "No git tag or package version available" };
|
|
1175
1069
|
}
|
|
1176
|
-
const verification = verifyTag(tagName,
|
|
1070
|
+
const verification = verifyTag(tagName, cwd3);
|
|
1177
1071
|
if (!verification.exists || !verification.reachable) {
|
|
1178
1072
|
if (strictReachable) {
|
|
1179
1073
|
throw new Error(
|
|
@@ -1328,7 +1222,7 @@ async function calculateVersion(config, options) {
|
|
|
1328
1222
|
const escapedTagPattern = escapeRegExp3(tagSearchPattern);
|
|
1329
1223
|
let versionSource;
|
|
1330
1224
|
if (pkgPath) {
|
|
1331
|
-
const packageDir = pkgPath || (0,
|
|
1225
|
+
const packageDir = pkgPath || (0, import_node_process.cwd)();
|
|
1332
1226
|
const manifestResult = getVersionFromManifests(packageDir);
|
|
1333
1227
|
const packageVersion = manifestResult.manifestFound && manifestResult.version ? manifestResult.version : void 0;
|
|
1334
1228
|
versionSource = await getBestVersionSource(
|
|
@@ -1391,7 +1285,7 @@ async function calculateVersion(config, options) {
|
|
|
1391
1285
|
const releaseTypeFromCommits = recommendedBump && "releaseType" in recommendedBump ? recommendedBump.releaseType : void 0;
|
|
1392
1286
|
const currentVersion = getCurrentVersionFromSource2();
|
|
1393
1287
|
if (versionSource && versionSource.source === "git") {
|
|
1394
|
-
const checkPath = pkgPath || (0,
|
|
1288
|
+
const checkPath = pkgPath || (0, import_node_process.cwd)();
|
|
1395
1289
|
const commitsLength = getCommitsLength(checkPath, versionSource.version);
|
|
1396
1290
|
if (commitsLength === 0) {
|
|
1397
1291
|
log(
|
|
@@ -1477,7 +1371,6 @@ var PackageProcessor = class {
|
|
|
1477
1371
|
tagTemplate;
|
|
1478
1372
|
commitMessageTemplate;
|
|
1479
1373
|
dryRun;
|
|
1480
|
-
skipHooks;
|
|
1481
1374
|
getLatestTag;
|
|
1482
1375
|
config;
|
|
1483
1376
|
// Config for version calculation
|
|
@@ -1488,7 +1381,6 @@ var PackageProcessor = class {
|
|
|
1488
1381
|
this.tagTemplate = options.tagTemplate;
|
|
1489
1382
|
this.commitMessageTemplate = options.commitMessageTemplate || "";
|
|
1490
1383
|
this.dryRun = options.dryRun || false;
|
|
1491
|
-
this.skipHooks = options.skipHooks || false;
|
|
1492
1384
|
this.getLatestTag = options.getLatestTag;
|
|
1493
1385
|
this.config = options.config;
|
|
1494
1386
|
this.fullConfig = options.fullConfig;
|
|
@@ -1591,6 +1483,19 @@ var PackageProcessor = class {
|
|
|
1591
1483
|
revisionRange = "HEAD";
|
|
1592
1484
|
}
|
|
1593
1485
|
changelogEntries = extractChangelogEntriesFromCommits(pkgPath, revisionRange);
|
|
1486
|
+
const allPackageDirs = packages.map((p) => p.dir);
|
|
1487
|
+
const sharedPackageNames = ["config", "core", "@releasekit/config", "@releasekit/core"];
|
|
1488
|
+
const sharedPackageDirs = packages.filter((p) => sharedPackageNames.includes(p.packageJson.name)).map((p) => p.dir);
|
|
1489
|
+
const repoLevelEntries = extractRepoLevelChangelogEntries(
|
|
1490
|
+
pkgPath,
|
|
1491
|
+
revisionRange,
|
|
1492
|
+
allPackageDirs,
|
|
1493
|
+
sharedPackageDirs
|
|
1494
|
+
);
|
|
1495
|
+
if (repoLevelEntries.length > 0) {
|
|
1496
|
+
log(`Adding ${repoLevelEntries.length} repo-level commit(s) to ${name} changelog`, "debug");
|
|
1497
|
+
changelogEntries = [...repoLevelEntries, ...changelogEntries];
|
|
1498
|
+
}
|
|
1594
1499
|
if (changelogEntries.length === 0) {
|
|
1595
1500
|
changelogEntries = [
|
|
1596
1501
|
{
|
|
@@ -1678,19 +1583,12 @@ var PackageProcessor = class {
|
|
|
1678
1583
|
this.tagTemplate,
|
|
1679
1584
|
this.fullConfig.packageSpecificTags
|
|
1680
1585
|
);
|
|
1681
|
-
const tagMessage = `chore(release): ${name} ${nextVersion}`;
|
|
1682
1586
|
addTag(packageTag);
|
|
1683
1587
|
tags.push(packageTag);
|
|
1684
|
-
if (
|
|
1685
|
-
try {
|
|
1686
|
-
await createGitTag({ tag: packageTag, message: tagMessage });
|
|
1687
|
-
log(`Created tag: ${packageTag}`, "success");
|
|
1688
|
-
} catch (tagError) {
|
|
1689
|
-
log(`Failed to create tag ${packageTag} for ${name}: ${tagError.message}`, "error");
|
|
1690
|
-
log(tagError.stack || "No stack trace available", "error");
|
|
1691
|
-
}
|
|
1692
|
-
} else {
|
|
1588
|
+
if (this.dryRun) {
|
|
1693
1589
|
log(`[DRY RUN] Would create tag: ${packageTag}`, "info");
|
|
1590
|
+
} else {
|
|
1591
|
+
log(`Version ${nextVersion} prepared (tag: ${packageTag})`, "success");
|
|
1694
1592
|
}
|
|
1695
1593
|
updatedPackagesInfo.push({ name, version: nextVersion, path: pkgPath });
|
|
1696
1594
|
}
|
|
@@ -1698,34 +1596,15 @@ var PackageProcessor = class {
|
|
|
1698
1596
|
log("No packages required a version update.", "info");
|
|
1699
1597
|
return { updatedPackages: [], tags };
|
|
1700
1598
|
}
|
|
1701
|
-
const filesToCommit = [];
|
|
1702
|
-
for (const info of updatedPackagesInfo) {
|
|
1703
|
-
const packageJsonPath = import_node_path6.default.join(info.path, "package.json");
|
|
1704
|
-
if (fs5.existsSync(packageJsonPath)) {
|
|
1705
|
-
filesToCommit.push(packageJsonPath);
|
|
1706
|
-
}
|
|
1707
|
-
const cargoEnabled = this.fullConfig.cargo?.enabled !== false;
|
|
1708
|
-
if (cargoEnabled) {
|
|
1709
|
-
const cargoPaths = this.fullConfig.cargo?.paths;
|
|
1710
|
-
if (cargoPaths && cargoPaths.length > 0) {
|
|
1711
|
-
for (const cargoPath of cargoPaths) {
|
|
1712
|
-
const resolvedCargoPath = import_node_path6.default.resolve(info.path, cargoPath, "Cargo.toml");
|
|
1713
|
-
if (fs5.existsSync(resolvedCargoPath)) {
|
|
1714
|
-
filesToCommit.push(resolvedCargoPath);
|
|
1715
|
-
}
|
|
1716
|
-
}
|
|
1717
|
-
} else {
|
|
1718
|
-
const cargoTomlPath = import_node_path6.default.join(info.path, "Cargo.toml");
|
|
1719
|
-
if (fs5.existsSync(cargoTomlPath)) {
|
|
1720
|
-
filesToCommit.push(cargoTomlPath);
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
1599
|
const packageNames = updatedPackagesInfo.map((p) => p.name).join(", ");
|
|
1726
1600
|
const representativeVersion = updatedPackagesInfo[0]?.version || "multiple";
|
|
1727
1601
|
let commitMessage = this.commitMessageTemplate || "chore(release): publish packages";
|
|
1728
|
-
const
|
|
1602
|
+
const MAX_COMMIT_MSG_LENGTH = 1e4;
|
|
1603
|
+
if (commitMessage.length > MAX_COMMIT_MSG_LENGTH) {
|
|
1604
|
+
log("Commit message template too long, truncating", "warning");
|
|
1605
|
+
commitMessage = commitMessage.slice(0, MAX_COMMIT_MSG_LENGTH);
|
|
1606
|
+
}
|
|
1607
|
+
const placeholderRegex = /\$\{[^{}$]{1,1000}\}/;
|
|
1729
1608
|
if (updatedPackagesInfo.length === 1 && placeholderRegex.test(commitMessage)) {
|
|
1730
1609
|
const packageName = updatedPackagesInfo[0].name;
|
|
1731
1610
|
commitMessage = formatCommitMessage(commitMessage, representativeVersion, packageName);
|
|
@@ -1733,21 +1612,7 @@ var PackageProcessor = class {
|
|
|
1733
1612
|
commitMessage = `chore(release): ${packageNames} ${representativeVersion}`;
|
|
1734
1613
|
}
|
|
1735
1614
|
setCommitMessage(commitMessage);
|
|
1736
|
-
if (
|
|
1737
|
-
try {
|
|
1738
|
-
await gitAdd(filesToCommit);
|
|
1739
|
-
await gitCommit({ message: commitMessage, skipHooks: this.skipHooks });
|
|
1740
|
-
log(`Created commit for targeted release: ${packageNames}`, "success");
|
|
1741
|
-
} catch (commitError) {
|
|
1742
|
-
log("Failed to create commit for targeted release.", "error");
|
|
1743
|
-
console.error(commitError);
|
|
1744
|
-
(0, import_node_process3.exit)(1);
|
|
1745
|
-
}
|
|
1746
|
-
} else {
|
|
1747
|
-
log("[DRY RUN] Would add files:", "info");
|
|
1748
|
-
for (const file of filesToCommit) {
|
|
1749
|
-
log(` - ${file}`, "info");
|
|
1750
|
-
}
|
|
1615
|
+
if (this.dryRun) {
|
|
1751
1616
|
log(`[DRY RUN] Would commit with message: "${commitMessage}"`, "info");
|
|
1752
1617
|
}
|
|
1753
1618
|
return {
|
|
@@ -1798,7 +1663,6 @@ function createSyncStrategy(config) {
|
|
|
1798
1663
|
commitMessage = `chore(release): v\${version}`,
|
|
1799
1664
|
prereleaseIdentifier,
|
|
1800
1665
|
dryRun,
|
|
1801
|
-
skipHooks,
|
|
1802
1666
|
mainPackage
|
|
1803
1667
|
} = config;
|
|
1804
1668
|
const formattedPrefix = formatVersionPrefix(versionPrefix || "v");
|
|
@@ -1948,7 +1812,13 @@ function createSyncStrategy(config) {
|
|
|
1948
1812
|
config.packageSpecificTags || false
|
|
1949
1813
|
);
|
|
1950
1814
|
const formattedCommitMessage = formatCommitMessage(commitMessage, nextVersion, commitPackageName, void 0);
|
|
1951
|
-
|
|
1815
|
+
addTag(nextTag);
|
|
1816
|
+
setCommitMessage(formattedCommitMessage);
|
|
1817
|
+
if (!dryRun) {
|
|
1818
|
+
log(`Version ${nextVersion} prepared (tag: ${nextTag})`, "success");
|
|
1819
|
+
} else {
|
|
1820
|
+
log(`Would create tag: ${nextTag}`, "info");
|
|
1821
|
+
}
|
|
1952
1822
|
} catch (error) {
|
|
1953
1823
|
if (BaseVersionError.isVersionError(error)) {
|
|
1954
1824
|
log(`Synced Strategy failed: ${error.message} (${error.code})`, "error");
|
|
@@ -1963,14 +1833,7 @@ function createSyncStrategy(config) {
|
|
|
1963
1833
|
function createSingleStrategy(config) {
|
|
1964
1834
|
return async (packages) => {
|
|
1965
1835
|
try {
|
|
1966
|
-
const {
|
|
1967
|
-
mainPackage,
|
|
1968
|
-
versionPrefix,
|
|
1969
|
-
tagTemplate,
|
|
1970
|
-
commitMessage = `chore(release): \${version}`,
|
|
1971
|
-
dryRun,
|
|
1972
|
-
skipHooks
|
|
1973
|
-
} = config;
|
|
1836
|
+
const { mainPackage, versionPrefix, tagTemplate, commitMessage = `chore(release): \${version}`, dryRun } = config;
|
|
1974
1837
|
let packageName;
|
|
1975
1838
|
if (mainPackage) {
|
|
1976
1839
|
packageName = mainPackage;
|
|
@@ -2090,9 +1953,10 @@ function createSingleStrategy(config) {
|
|
|
2090
1953
|
log(`Updated package ${packageName} to version ${nextVersion}`, "success");
|
|
2091
1954
|
const tagName = formatTag(nextVersion, formattedPrefix, packageName, tagTemplate, config.packageSpecificTags);
|
|
2092
1955
|
const commitMsg = formatCommitMessage(commitMessage, nextVersion, packageName);
|
|
1956
|
+
addTag(tagName);
|
|
1957
|
+
setCommitMessage(commitMsg);
|
|
2093
1958
|
if (!dryRun) {
|
|
2094
|
-
|
|
2095
|
-
log(`Created tag: ${tagName}`, "success");
|
|
1959
|
+
log(`Version ${nextVersion} prepared (tag: ${tagName})`, "success");
|
|
2096
1960
|
} else {
|
|
2097
1961
|
log(`Would create tag: ${tagName}`, "info");
|
|
2098
1962
|
}
|
|
@@ -2117,7 +1981,6 @@ function createAsyncStrategy(config) {
|
|
|
2117
1981
|
tagTemplate: config.tagTemplate,
|
|
2118
1982
|
commitMessageTemplate: config.commitMessage || "",
|
|
2119
1983
|
dryRun: config.dryRun || false,
|
|
2120
|
-
skipHooks: config.skipHooks || false,
|
|
2121
1984
|
getLatestTag: dependencies.getLatestTag,
|
|
2122
1985
|
fullConfig: config,
|
|
2123
1986
|
// Extract common version configuration properties
|
|
@@ -2205,13 +2068,13 @@ var VersionEngine = class {
|
|
|
2205
2068
|
if (this.workspaceCache) {
|
|
2206
2069
|
return this.workspaceCache;
|
|
2207
2070
|
}
|
|
2208
|
-
const pkgsResult = (0, import_get_packages.getPackagesSync)((0,
|
|
2071
|
+
const pkgsResult = (0, import_get_packages.getPackagesSync)((0, import_node_process2.cwd)());
|
|
2209
2072
|
if (!pkgsResult || !pkgsResult.packages) {
|
|
2210
2073
|
throw createVersionError("PACKAGES_NOT_FOUND" /* PACKAGES_NOT_FOUND */);
|
|
2211
2074
|
}
|
|
2212
2075
|
if (!pkgsResult.root) {
|
|
2213
2076
|
log("Root path is undefined in packages result, setting to current working directory", "warning");
|
|
2214
|
-
pkgsResult.root = (0,
|
|
2077
|
+
pkgsResult.root = (0, import_node_process2.cwd)();
|
|
2215
2078
|
}
|
|
2216
2079
|
if (this.config.packages && this.config.packages.length > 0) {
|
|
2217
2080
|
const originalCount = pkgsResult.packages.length;
|