@releasekit/publish 0.2.0-next.9 → 0.2.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/README.md +13 -1
- package/dist/{chunk-Y7Y6GQ6R.js → chunk-H7AKSLZP.js} +223 -96
- package/dist/cli.cjs +243 -118
- package/dist/cli.js +1 -1
- package/dist/index.cjs +237 -112
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/package.json +38 -28
package/dist/cli.cjs
CHANGED
|
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
));
|
|
25
25
|
|
|
26
26
|
// src/cli.ts
|
|
27
|
-
var
|
|
27
|
+
var import_core13 = require("@releasekit/core");
|
|
28
28
|
var import_commander = require("commander");
|
|
29
29
|
|
|
30
30
|
// src/config.ts
|
|
@@ -52,7 +52,9 @@ function getDefaultConfig() {
|
|
|
52
52
|
push: true,
|
|
53
53
|
pushMethod: "auto",
|
|
54
54
|
remote: "origin",
|
|
55
|
-
branch: "main"
|
|
55
|
+
branch: "main",
|
|
56
|
+
httpsTokenEnv: void 0,
|
|
57
|
+
skipHooks: false
|
|
56
58
|
},
|
|
57
59
|
githubRelease: {
|
|
58
60
|
enabled: true,
|
|
@@ -100,7 +102,9 @@ function toPublishConfig(config) {
|
|
|
100
102
|
push: config.git.push ?? defaults.git.push,
|
|
101
103
|
pushMethod: config.git.pushMethod ?? defaults.git.pushMethod,
|
|
102
104
|
remote: config.git.remote ?? defaults.git.remote,
|
|
103
|
-
branch: config.git.branch ?? defaults.git.branch
|
|
105
|
+
branch: config.git.branch ?? defaults.git.branch,
|
|
106
|
+
httpsTokenEnv: config.git.httpsTokenEnv ?? defaults.git.httpsTokenEnv,
|
|
107
|
+
skipHooks: config.git.skipHooks ?? defaults.git.skipHooks
|
|
104
108
|
} : defaults.git,
|
|
105
109
|
githubRelease: {
|
|
106
110
|
enabled: config.githubRelease?.enabled ?? defaults.githubRelease.enabled,
|
|
@@ -261,8 +265,20 @@ var import_core3 = require("@releasekit/core");
|
|
|
261
265
|
// src/utils/exec.ts
|
|
262
266
|
var import_node_child_process = require("child_process");
|
|
263
267
|
var import_core2 = require("@releasekit/core");
|
|
268
|
+
function redactArg(arg) {
|
|
269
|
+
try {
|
|
270
|
+
const url = new URL(arg);
|
|
271
|
+
if (url.username || url.password) {
|
|
272
|
+
url.username = url.username ? "***" : "";
|
|
273
|
+
url.password = url.password ? "***" : "";
|
|
274
|
+
return url.toString();
|
|
275
|
+
}
|
|
276
|
+
} catch {
|
|
277
|
+
}
|
|
278
|
+
return arg;
|
|
279
|
+
}
|
|
264
280
|
async function execCommand(file, args, options = {}) {
|
|
265
|
-
const displayCommand = options.label ?? [file, ...args].join(" ");
|
|
281
|
+
const displayCommand = options.label ?? [file, ...args.map(redactArg)].join(" ");
|
|
266
282
|
if (options.dryRun) {
|
|
267
283
|
(0, import_core2.info)(`[DRY RUN] Would execute: ${displayCommand}`);
|
|
268
284
|
return { stdout: "", stderr: "", exitCode: 0 };
|
|
@@ -318,7 +334,7 @@ function detectNpmAuth() {
|
|
|
318
334
|
if (process.env.ACTIONS_ID_TOKEN_REQUEST_URL) {
|
|
319
335
|
return "oidc";
|
|
320
336
|
}
|
|
321
|
-
if (process.env.NPM_TOKEN) {
|
|
337
|
+
if (process.env.NPM_TOKEN || process.env.NODE_AUTH_TOKEN) {
|
|
322
338
|
return "token";
|
|
323
339
|
}
|
|
324
340
|
return null;
|
|
@@ -527,8 +543,9 @@ function topologicalSort(crates) {
|
|
|
527
543
|
var path2 = __toESM(require("path"), 1);
|
|
528
544
|
var import_core4 = require("@releasekit/core");
|
|
529
545
|
async function runGitCommitStage(ctx) {
|
|
530
|
-
const { input, cliOptions, cwd } = ctx;
|
|
546
|
+
const { input, config, cliOptions, cwd } = ctx;
|
|
531
547
|
const dryRun = cliOptions.dryRun;
|
|
548
|
+
const skipHooks = config.git.skipHooks ?? false;
|
|
532
549
|
if (!input.commitMessage) {
|
|
533
550
|
(0, import_core4.info)("No commit message provided, skipping git commit");
|
|
534
551
|
return;
|
|
@@ -550,8 +567,13 @@ async function runGitCommitStage(ctx) {
|
|
|
550
567
|
`git add failed: ${error instanceof Error ? error.message : String(error)}`
|
|
551
568
|
);
|
|
552
569
|
}
|
|
570
|
+
const commitArgs = ["commit"];
|
|
571
|
+
if (skipHooks) {
|
|
572
|
+
commitArgs.push("--no-verify");
|
|
573
|
+
}
|
|
574
|
+
commitArgs.push("-m", input.commitMessage);
|
|
553
575
|
try {
|
|
554
|
-
await execCommand("git",
|
|
576
|
+
await execCommand("git", commitArgs, {
|
|
555
577
|
cwd,
|
|
556
578
|
dryRun,
|
|
557
579
|
label: `git commit -m "${input.commitMessage}"`
|
|
@@ -589,6 +611,18 @@ async function runGitCommitStage(ctx) {
|
|
|
589
611
|
|
|
590
612
|
// src/stages/git-push.ts
|
|
591
613
|
var import_core5 = require("@releasekit/core");
|
|
614
|
+
function toGithubAuthedUrl(remoteUrl, token) {
|
|
615
|
+
try {
|
|
616
|
+
const url = new URL(remoteUrl);
|
|
617
|
+
if (url.protocol !== "https:") return void 0;
|
|
618
|
+
if (url.host !== "github.com") return void 0;
|
|
619
|
+
url.username = "x-access-token";
|
|
620
|
+
url.password = token;
|
|
621
|
+
return url.toString();
|
|
622
|
+
} catch {
|
|
623
|
+
return void 0;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
592
626
|
async function runGitPushStage(ctx) {
|
|
593
627
|
const { config, cliOptions, cwd, output } = ctx;
|
|
594
628
|
const dryRun = cliOptions.dryRun;
|
|
@@ -609,16 +643,26 @@ async function runGitPushStage(ctx) {
|
|
|
609
643
|
pushMethod = "https";
|
|
610
644
|
}
|
|
611
645
|
}
|
|
646
|
+
const httpsTokenEnv = config.git.httpsTokenEnv;
|
|
647
|
+
const httpsToken = httpsTokenEnv ? process.env[httpsTokenEnv] : void 0;
|
|
612
648
|
try {
|
|
649
|
+
let pushRemote = remote;
|
|
650
|
+
if (pushMethod === "https" && httpsToken) {
|
|
651
|
+
const remoteUrlResult = await execCommand("git", ["remote", "get-url", remote], { cwd, dryRun: false });
|
|
652
|
+
const authed = toGithubAuthedUrl(remoteUrlResult.stdout.trim(), httpsToken);
|
|
653
|
+
if (authed) {
|
|
654
|
+
pushRemote = authed;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
613
657
|
if (output.git.committed) {
|
|
614
|
-
await execCommand("git", ["push",
|
|
658
|
+
await execCommand("git", ["push", pushRemote, branch], {
|
|
615
659
|
cwd,
|
|
616
660
|
dryRun,
|
|
617
661
|
label: `git push ${remote} ${branch}`
|
|
618
662
|
});
|
|
619
663
|
}
|
|
620
664
|
if (output.git.tags.length > 0) {
|
|
621
|
-
await execCommand("git", ["push",
|
|
665
|
+
await execCommand("git", ["push", pushRemote, "--tags"], {
|
|
622
666
|
cwd,
|
|
623
667
|
dryRun,
|
|
624
668
|
label: `git push ${remote} --tags`
|
|
@@ -679,7 +723,9 @@ async function runGithubReleaseStage(ctx) {
|
|
|
679
723
|
if (!firstTag) return;
|
|
680
724
|
const tagsToRelease = config.githubRelease.perPackage ? tags : [firstTag];
|
|
681
725
|
for (const tag of tagsToRelease) {
|
|
682
|
-
const
|
|
726
|
+
const MAX_TAG_LENGTH = 1e3;
|
|
727
|
+
const truncatedTag = tag.length > MAX_TAG_LENGTH ? tag.slice(0, MAX_TAG_LENGTH) : tag;
|
|
728
|
+
const versionMatch = truncatedTag.match(/(\d{1,20}\.\d{1,20}\.\d{1,20}(?:[-+.]?[a-zA-Z0-9.-]{0,100})?)$/);
|
|
683
729
|
const version = versionMatch?.[1] ?? "";
|
|
684
730
|
const isPreRel = config.githubRelease.prerelease === "auto" ? version ? isPrerelease(version) : false : config.githubRelease.prerelease;
|
|
685
731
|
const result = {
|
|
@@ -721,16 +767,82 @@ async function runGithubReleaseStage(ctx) {
|
|
|
721
767
|
}
|
|
722
768
|
|
|
723
769
|
// src/stages/npm-publish.ts
|
|
724
|
-
var
|
|
725
|
-
var
|
|
726
|
-
var
|
|
770
|
+
var fs6 = __toESM(require("fs"), 1);
|
|
771
|
+
var path5 = __toESM(require("path"), 1);
|
|
772
|
+
var import_core8 = require("@releasekit/core");
|
|
727
773
|
|
|
728
|
-
// src/utils/
|
|
774
|
+
// src/utils/npm-env.ts
|
|
729
775
|
var fs4 = __toESM(require("fs"), 1);
|
|
776
|
+
var os = __toESM(require("os"), 1);
|
|
730
777
|
var path3 = __toESM(require("path"), 1);
|
|
778
|
+
var import_core7 = require("@releasekit/core");
|
|
779
|
+
function writeTempNpmrc(contents) {
|
|
780
|
+
const dir = fs4.mkdtempSync(path3.join(os.tmpdir(), "releasekit-npmrc-"));
|
|
781
|
+
const npmrcPath = path3.join(dir, ".npmrc");
|
|
782
|
+
fs4.writeFileSync(npmrcPath, contents, "utf-8");
|
|
783
|
+
return {
|
|
784
|
+
npmrcPath,
|
|
785
|
+
cleanup: () => {
|
|
786
|
+
try {
|
|
787
|
+
fs4.rmSync(dir, { recursive: true, force: true });
|
|
788
|
+
} catch {
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function createNpmSubprocessIsolation(options) {
|
|
794
|
+
const { authMethod, registryUrl } = options;
|
|
795
|
+
const baseEnv = {};
|
|
796
|
+
if (!authMethod) return { env: baseEnv, cleanup: () => {
|
|
797
|
+
} };
|
|
798
|
+
const token = process.env.NPM_TOKEN ?? process.env.NODE_AUTH_TOKEN;
|
|
799
|
+
const registryHost = (() => {
|
|
800
|
+
try {
|
|
801
|
+
return new URL(registryUrl).host;
|
|
802
|
+
} catch {
|
|
803
|
+
return "registry.npmjs.org";
|
|
804
|
+
}
|
|
805
|
+
})();
|
|
806
|
+
const lines = [`registry=${registryUrl}`];
|
|
807
|
+
if (authMethod === "oidc") {
|
|
808
|
+
lines.push("always-auth=false");
|
|
809
|
+
}
|
|
810
|
+
if (authMethod === "token" && token) {
|
|
811
|
+
lines.push(`//${registryHost}/:_authToken=${token}`);
|
|
812
|
+
}
|
|
813
|
+
lines.push("");
|
|
814
|
+
const { npmrcPath, cleanup } = writeTempNpmrc(lines.join("\n"));
|
|
815
|
+
(0, import_core7.debug)(`Using isolated npm userconfig: ${npmrcPath}`);
|
|
816
|
+
const isOidc = authMethod === "oidc";
|
|
817
|
+
return {
|
|
818
|
+
env: {
|
|
819
|
+
...baseEnv,
|
|
820
|
+
// Ensure npm and tools that read npm_config_* pick up our temp file
|
|
821
|
+
NPM_CONFIG_USERCONFIG: npmrcPath,
|
|
822
|
+
npm_config_userconfig: npmrcPath,
|
|
823
|
+
// Auth-specific hardening
|
|
824
|
+
...isOidc ? {
|
|
825
|
+
// Prevent setup-node's always-auth from forcing token lookups
|
|
826
|
+
NPM_CONFIG_ALWAYS_AUTH: "false",
|
|
827
|
+
npm_config_always_auth: "false",
|
|
828
|
+
// Explicitly prevent token-based publishing from being selected implicitly
|
|
829
|
+
NODE_AUTH_TOKEN: void 0,
|
|
830
|
+
NPM_TOKEN: void 0
|
|
831
|
+
} : {
|
|
832
|
+
// Ensure CLIs that expect NODE_AUTH_TOKEN can still work
|
|
833
|
+
NODE_AUTH_TOKEN: token
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
cleanup
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
// src/utils/package-manager.ts
|
|
841
|
+
var fs5 = __toESM(require("fs"), 1);
|
|
842
|
+
var path4 = __toESM(require("path"), 1);
|
|
731
843
|
function detectPackageManager(cwd) {
|
|
732
|
-
if (
|
|
733
|
-
if (
|
|
844
|
+
if (fs5.existsSync(path4.join(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
845
|
+
if (fs5.existsSync(path4.join(cwd, "yarn.lock"))) return "yarn";
|
|
734
846
|
return "npm";
|
|
735
847
|
}
|
|
736
848
|
function buildPublishCommand(pm, packageName, _packageDir, options) {
|
|
@@ -759,7 +871,7 @@ async function runNpmPublishStage(ctx) {
|
|
|
759
871
|
const { input, config, cliOptions, cwd } = ctx;
|
|
760
872
|
const dryRun = cliOptions.dryRun;
|
|
761
873
|
if (!config.npm.enabled) {
|
|
762
|
-
(0,
|
|
874
|
+
(0, import_core8.info)("NPM publishing disabled in config");
|
|
763
875
|
return;
|
|
764
876
|
}
|
|
765
877
|
const authMethod = config.npm.auth === "auto" ? detectNpmAuth() : config.npm.auth;
|
|
@@ -767,107 +879,117 @@ async function runNpmPublishStage(ctx) {
|
|
|
767
879
|
throw createPublishError("NPM_AUTH_ERROR" /* NPM_AUTH_ERROR */, "No NPM authentication method detected");
|
|
768
880
|
}
|
|
769
881
|
const useProvenance = config.npm.provenance && authMethod === "oidc";
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
(
|
|
788
|
-
|
|
882
|
+
const npmIsolation = createNpmSubprocessIsolation({
|
|
883
|
+
authMethod,
|
|
884
|
+
registryUrl: config.npm.registry
|
|
885
|
+
});
|
|
886
|
+
try {
|
|
887
|
+
for (const update of input.updates) {
|
|
888
|
+
const result = {
|
|
889
|
+
packageName: update.packageName,
|
|
890
|
+
version: update.newVersion,
|
|
891
|
+
registry: "npm",
|
|
892
|
+
success: false,
|
|
893
|
+
skipped: false
|
|
894
|
+
};
|
|
895
|
+
const pkgJsonPath = path5.resolve(cwd, update.filePath);
|
|
896
|
+
try {
|
|
897
|
+
const pkgContent = fs6.readFileSync(pkgJsonPath, "utf-8");
|
|
898
|
+
const pkgJson = JSON.parse(pkgContent);
|
|
899
|
+
if (pkgJson.private) {
|
|
900
|
+
result.skipped = true;
|
|
901
|
+
result.success = true;
|
|
902
|
+
result.reason = "Package is private";
|
|
903
|
+
ctx.output.npm.push(result);
|
|
904
|
+
(0, import_core8.debug)(`Skipping private package: ${update.packageName}`);
|
|
905
|
+
continue;
|
|
906
|
+
}
|
|
907
|
+
} catch {
|
|
908
|
+
if (update.filePath.endsWith("Cargo.toml")) {
|
|
909
|
+
result.skipped = true;
|
|
910
|
+
result.success = true;
|
|
911
|
+
result.reason = "Not an npm package";
|
|
912
|
+
ctx.output.npm.push(result);
|
|
913
|
+
continue;
|
|
914
|
+
}
|
|
789
915
|
}
|
|
790
|
-
|
|
791
|
-
|
|
916
|
+
const { file: viewFile, args: viewArgs } = buildViewCommand(
|
|
917
|
+
ctx.packageManager,
|
|
918
|
+
update.packageName,
|
|
919
|
+
update.newVersion
|
|
920
|
+
);
|
|
921
|
+
const viewResult = await execCommandSafe(viewFile, viewArgs, {
|
|
922
|
+
cwd,
|
|
923
|
+
dryRun: false,
|
|
924
|
+
// Always check, even in dry-run
|
|
925
|
+
env: npmIsolation.env
|
|
926
|
+
});
|
|
927
|
+
if (viewResult.exitCode === 0 && viewResult.stdout.trim()) {
|
|
928
|
+
result.alreadyPublished = true;
|
|
792
929
|
result.skipped = true;
|
|
793
930
|
result.success = true;
|
|
794
|
-
result.reason = "
|
|
931
|
+
result.reason = "Already published";
|
|
795
932
|
ctx.output.npm.push(result);
|
|
933
|
+
(0, import_core8.warn)(`${update.packageName}@${update.newVersion} is already published, skipping`);
|
|
796
934
|
continue;
|
|
797
935
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
ctx.packageManager,
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
cwd,
|
|
806
|
-
dryRun: false
|
|
807
|
-
// Always check, even in dry-run
|
|
808
|
-
});
|
|
809
|
-
if (viewResult.exitCode === 0 && viewResult.stdout.trim()) {
|
|
810
|
-
result.alreadyPublished = true;
|
|
811
|
-
result.skipped = true;
|
|
812
|
-
result.success = true;
|
|
813
|
-
result.reason = "Already published";
|
|
814
|
-
ctx.output.npm.push(result);
|
|
815
|
-
(0, import_core7.warn)(`${update.packageName}@${update.newVersion} is already published, skipping`);
|
|
816
|
-
continue;
|
|
817
|
-
}
|
|
818
|
-
const distTag = getDistTag(update.newVersion, config.npm.tag);
|
|
819
|
-
const pkgDir = path4.dirname(path4.resolve(cwd, update.filePath));
|
|
820
|
-
const { file: pubFile, args: pubArgs } = buildPublishCommand(ctx.packageManager, update.packageName, pkgDir, {
|
|
821
|
-
access: config.npm.access,
|
|
822
|
-
tag: distTag,
|
|
823
|
-
provenance: useProvenance,
|
|
824
|
-
noGitChecks: true
|
|
825
|
-
});
|
|
826
|
-
try {
|
|
827
|
-
await execCommand(pubFile, pubArgs, {
|
|
828
|
-
cwd,
|
|
829
|
-
dryRun,
|
|
830
|
-
label: `npm publish ${update.packageName}@${update.newVersion}`
|
|
936
|
+
const distTag = getDistTag(update.newVersion, config.npm.tag);
|
|
937
|
+
const pkgDir = path5.dirname(path5.resolve(cwd, update.filePath));
|
|
938
|
+
const { file: pubFile, args: pubArgs } = buildPublishCommand(ctx.packageManager, update.packageName, pkgDir, {
|
|
939
|
+
access: config.npm.access,
|
|
940
|
+
tag: distTag,
|
|
941
|
+
provenance: useProvenance,
|
|
942
|
+
noGitChecks: true
|
|
831
943
|
});
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
944
|
+
try {
|
|
945
|
+
await execCommand(pubFile, pubArgs, {
|
|
946
|
+
cwd,
|
|
947
|
+
dryRun,
|
|
948
|
+
label: `npm publish ${update.packageName}@${update.newVersion}`,
|
|
949
|
+
env: npmIsolation.env
|
|
950
|
+
});
|
|
951
|
+
result.success = true;
|
|
952
|
+
if (!dryRun) {
|
|
953
|
+
(0, import_core8.success)(`Published ${update.packageName}@${update.newVersion} to npm`);
|
|
954
|
+
}
|
|
955
|
+
} catch (error) {
|
|
956
|
+
result.reason = error instanceof Error ? error.message : String(error);
|
|
957
|
+
(0, import_core8.warn)(`Failed to publish ${update.packageName}: ${result.reason}`);
|
|
835
958
|
}
|
|
836
|
-
|
|
837
|
-
result.reason = error instanceof Error ? error.message : String(error);
|
|
838
|
-
(0, import_core7.warn)(`Failed to publish ${update.packageName}: ${result.reason}`);
|
|
959
|
+
ctx.output.npm.push(result);
|
|
839
960
|
}
|
|
840
|
-
|
|
961
|
+
} finally {
|
|
962
|
+
npmIsolation.cleanup();
|
|
841
963
|
}
|
|
842
964
|
}
|
|
843
965
|
|
|
844
966
|
// src/stages/prepare.ts
|
|
845
|
-
var
|
|
846
|
-
var
|
|
847
|
-
var
|
|
967
|
+
var fs7 = __toESM(require("fs"), 1);
|
|
968
|
+
var path6 = __toESM(require("path"), 1);
|
|
969
|
+
var import_core9 = require("@releasekit/core");
|
|
848
970
|
async function runPrepareStage(ctx) {
|
|
849
971
|
const { input, config, cliOptions, cwd } = ctx;
|
|
850
972
|
if (config.npm.enabled && config.npm.copyFiles.length > 0) {
|
|
851
973
|
for (const update of input.updates) {
|
|
852
|
-
const pkgDir =
|
|
974
|
+
const pkgDir = path6.dirname(path6.resolve(cwd, update.filePath));
|
|
853
975
|
for (const file of config.npm.copyFiles) {
|
|
854
|
-
const src =
|
|
855
|
-
const dest =
|
|
856
|
-
if (!
|
|
857
|
-
(0,
|
|
976
|
+
const src = path6.resolve(cwd, file);
|
|
977
|
+
const dest = path6.join(pkgDir, file);
|
|
978
|
+
if (!fs7.existsSync(src)) {
|
|
979
|
+
(0, import_core9.debug)(`Source file not found, skipping copy: ${src}`);
|
|
858
980
|
continue;
|
|
859
981
|
}
|
|
860
|
-
if (
|
|
861
|
-
(0,
|
|
982
|
+
if (path6.resolve(path6.dirname(src)) === path6.resolve(pkgDir)) {
|
|
983
|
+
(0, import_core9.debug)(`Skipping copy of ${file} - same directory as source`);
|
|
862
984
|
continue;
|
|
863
985
|
}
|
|
864
986
|
if (cliOptions.dryRun) {
|
|
865
|
-
(0,
|
|
987
|
+
(0, import_core9.info)(`[DRY RUN] Would copy ${src} \u2192 ${dest}`);
|
|
866
988
|
continue;
|
|
867
989
|
}
|
|
868
990
|
try {
|
|
869
|
-
|
|
870
|
-
(0,
|
|
991
|
+
fs7.copyFileSync(src, dest);
|
|
992
|
+
(0, import_core9.debug)(`Copied ${file} \u2192 ${pkgDir}`);
|
|
871
993
|
} catch (error) {
|
|
872
994
|
throw createPublishError(
|
|
873
995
|
"FILE_COPY_ERROR" /* FILE_COPY_ERROR */,
|
|
@@ -879,26 +1001,26 @@ async function runPrepareStage(ctx) {
|
|
|
879
1001
|
}
|
|
880
1002
|
if (config.cargo.enabled) {
|
|
881
1003
|
for (const update of input.updates) {
|
|
882
|
-
const pkgDir =
|
|
883
|
-
const cargoPath =
|
|
884
|
-
if (!
|
|
1004
|
+
const pkgDir = path6.dirname(path6.resolve(cwd, update.filePath));
|
|
1005
|
+
const cargoPath = path6.join(pkgDir, "Cargo.toml");
|
|
1006
|
+
if (!fs7.existsSync(cargoPath)) {
|
|
885
1007
|
continue;
|
|
886
1008
|
}
|
|
887
1009
|
if (cliOptions.dryRun) {
|
|
888
|
-
(0,
|
|
1010
|
+
(0, import_core9.info)(`[DRY RUN] Would update ${cargoPath} to version ${update.newVersion}`);
|
|
889
1011
|
continue;
|
|
890
1012
|
}
|
|
891
1013
|
updateCargoVersion(cargoPath, update.newVersion);
|
|
892
|
-
(0,
|
|
1014
|
+
(0, import_core9.debug)(`Updated ${cargoPath} to version ${update.newVersion}`);
|
|
893
1015
|
}
|
|
894
1016
|
}
|
|
895
1017
|
}
|
|
896
1018
|
|
|
897
1019
|
// src/stages/verify.ts
|
|
898
|
-
var
|
|
1020
|
+
var import_core11 = require("@releasekit/core");
|
|
899
1021
|
|
|
900
1022
|
// src/utils/retry.ts
|
|
901
|
-
var
|
|
1023
|
+
var import_core10 = require("@releasekit/core");
|
|
902
1024
|
async function withRetry(fn, options, shouldRetry) {
|
|
903
1025
|
let lastError;
|
|
904
1026
|
let delay = options.initialDelay;
|
|
@@ -911,7 +1033,7 @@ async function withRetry(fn, options, shouldRetry) {
|
|
|
911
1033
|
throw error;
|
|
912
1034
|
}
|
|
913
1035
|
if (attempt < options.maxAttempts) {
|
|
914
|
-
(0,
|
|
1036
|
+
(0, import_core10.debug)(`Attempt ${attempt}/${options.maxAttempts} failed, retrying in ${delay}ms...`);
|
|
915
1037
|
await sleep(delay);
|
|
916
1038
|
delay = Math.floor(delay * options.backoffMultiplier);
|
|
917
1039
|
}
|
|
@@ -937,7 +1059,7 @@ async function runVerifyStage(ctx) {
|
|
|
937
1059
|
attempts: 0
|
|
938
1060
|
};
|
|
939
1061
|
if (cliOptions.dryRun) {
|
|
940
|
-
(0,
|
|
1062
|
+
(0, import_core11.info)(`[DRY RUN] Would verify ${pkg.packageName}@${pkg.version} on npm`);
|
|
941
1063
|
result.verified = true;
|
|
942
1064
|
ctx.output.verification.push(result);
|
|
943
1065
|
continue;
|
|
@@ -953,12 +1075,12 @@ async function runVerifyStage(ctx) {
|
|
|
953
1075
|
if (viewResult.exitCode !== 0 || !viewResult.stdout.trim()) {
|
|
954
1076
|
throw new Error(`${pkg.packageName}@${pkg.version} not yet available on npm`);
|
|
955
1077
|
}
|
|
956
|
-
(0,
|
|
1078
|
+
(0, import_core11.debug)(`Verified ${pkg.packageName}@${pkg.version} on npm`);
|
|
957
1079
|
}, config.verify.npm);
|
|
958
1080
|
result.verified = true;
|
|
959
|
-
(0,
|
|
1081
|
+
(0, import_core11.success)(`Verified ${pkg.packageName}@${pkg.version} on npm`);
|
|
960
1082
|
} catch {
|
|
961
|
-
(0,
|
|
1083
|
+
(0, import_core11.warn)(`Failed to verify ${pkg.packageName}@${pkg.version} on npm after ${result.attempts} attempts`);
|
|
962
1084
|
}
|
|
963
1085
|
ctx.output.verification.push(result);
|
|
964
1086
|
}
|
|
@@ -974,7 +1096,7 @@ async function runVerifyStage(ctx) {
|
|
|
974
1096
|
attempts: 0
|
|
975
1097
|
};
|
|
976
1098
|
if (cliOptions.dryRun) {
|
|
977
|
-
(0,
|
|
1099
|
+
(0, import_core11.info)(`[DRY RUN] Would verify ${crate.packageName}@${crate.version} on crates.io`);
|
|
978
1100
|
result.verified = true;
|
|
979
1101
|
ctx.output.verification.push(result);
|
|
980
1102
|
continue;
|
|
@@ -986,12 +1108,12 @@ async function runVerifyStage(ctx) {
|
|
|
986
1108
|
if (!response.ok) {
|
|
987
1109
|
throw new Error(`${crate.packageName}@${crate.version} not yet available on crates.io`);
|
|
988
1110
|
}
|
|
989
|
-
(0,
|
|
1111
|
+
(0, import_core11.debug)(`Verified ${crate.packageName}@${crate.version} on crates.io`);
|
|
990
1112
|
}, config.verify.cargo);
|
|
991
1113
|
result.verified = true;
|
|
992
|
-
(0,
|
|
1114
|
+
(0, import_core11.success)(`Verified ${crate.packageName}@${crate.version} on crates.io`);
|
|
993
1115
|
} catch {
|
|
994
|
-
(0,
|
|
1116
|
+
(0, import_core11.warn)(`Failed to verify ${crate.packageName}@${crate.version} on crates.io after ${result.attempts} attempts`);
|
|
995
1117
|
}
|
|
996
1118
|
ctx.output.verification.push(result);
|
|
997
1119
|
}
|
|
@@ -1037,7 +1159,10 @@ async function runPipeline(input, config, options) {
|
|
|
1037
1159
|
};
|
|
1038
1160
|
try {
|
|
1039
1161
|
await runPrepareStage(ctx);
|
|
1040
|
-
if (!options.skipGit) {
|
|
1162
|
+
if (options.skipGitCommit && !options.skipGit) {
|
|
1163
|
+
ctx.output.git.committed = !!input.commitMessage;
|
|
1164
|
+
ctx.output.git.tags = [...input.tags];
|
|
1165
|
+
} else if (!options.skipGit) {
|
|
1041
1166
|
await runGitCommitStage(ctx);
|
|
1042
1167
|
}
|
|
1043
1168
|
if (!options.skipPublish) {
|
|
@@ -1066,8 +1191,8 @@ async function runPipeline(input, config, options) {
|
|
|
1066
1191
|
}
|
|
1067
1192
|
|
|
1068
1193
|
// src/stages/input.ts
|
|
1069
|
-
var
|
|
1070
|
-
var
|
|
1194
|
+
var fs8 = __toESM(require("fs"), 1);
|
|
1195
|
+
var import_core12 = require("@releasekit/core");
|
|
1071
1196
|
var import_zod = require("zod");
|
|
1072
1197
|
var VersionChangelogEntrySchema = import_zod.z.object({
|
|
1073
1198
|
type: import_zod.z.string(),
|
|
@@ -1100,7 +1225,7 @@ async function parseInput(inputPath) {
|
|
|
1100
1225
|
let raw;
|
|
1101
1226
|
if (inputPath) {
|
|
1102
1227
|
try {
|
|
1103
|
-
raw =
|
|
1228
|
+
raw = fs8.readFileSync(inputPath, "utf-8");
|
|
1104
1229
|
} catch {
|
|
1105
1230
|
throw createPublishError("INPUT_PARSE_ERROR" /* INPUT_PARSE_ERROR */, `Could not read file: ${inputPath}`);
|
|
1106
1231
|
}
|
|
@@ -1120,7 +1245,7 @@ async function parseInput(inputPath) {
|
|
|
1120
1245
|
${issues}`);
|
|
1121
1246
|
}
|
|
1122
1247
|
if (result.data.updates.length === 0) {
|
|
1123
|
-
(0,
|
|
1248
|
+
(0, import_core12.info)("No package updates in version output \u2014 pipeline will be a no-op");
|
|
1124
1249
|
}
|
|
1125
1250
|
return result.data;
|
|
1126
1251
|
}
|
|
@@ -1135,8 +1260,8 @@ async function readStdin() {
|
|
|
1135
1260
|
// src/cli.ts
|
|
1136
1261
|
var program = new import_commander.Command();
|
|
1137
1262
|
program.name("releasekit-publish").description("Publish packages to registries with git tagging and GitHub releases").version("0.1.0").option("--input <path>", "Path to version output JSON (default: stdin)").option("--config <path>", "Path to releasekit config").option("--registry <type>", "Registry to publish to (npm, cargo, all)", "all").option("--npm-auth <method>", "NPM auth method (oidc, token, auto)", "auto").option("--dry-run", "Simulate all operations", false).option("--skip-git", "Skip git commit/tag/push", false).option("--skip-publish", "Skip registry publishing", false).option("--skip-github-release", "Skip GitHub Release creation", false).option("--skip-verification", "Skip post-publish verification", false).option("--json", "Output results as JSON", false).option("--verbose", "Verbose logging", false).action(async (options) => {
|
|
1138
|
-
if (options.verbose) (0,
|
|
1139
|
-
if (options.json) (0,
|
|
1263
|
+
if (options.verbose) (0, import_core13.setLogLevel)("debug");
|
|
1264
|
+
if (options.json) (0, import_core13.setJsonMode)(true);
|
|
1140
1265
|
try {
|
|
1141
1266
|
const config = loadConfig({ configPath: options.config });
|
|
1142
1267
|
const input = await parseInput(options.input);
|
|
@@ -1173,14 +1298,14 @@ program.name("releasekit-publish").description("Publish packages to registries w
|
|
|
1173
1298
|
2
|
|
1174
1299
|
)
|
|
1175
1300
|
);
|
|
1176
|
-
process.exit(
|
|
1301
|
+
process.exit(import_core13.EXIT_CODES.PUBLISH_ERROR);
|
|
1177
1302
|
}
|
|
1178
1303
|
if (BasePublishError.isPublishError(err)) {
|
|
1179
1304
|
err.logError();
|
|
1180
|
-
process.exit(
|
|
1305
|
+
process.exit(import_core13.EXIT_CODES.PUBLISH_ERROR);
|
|
1181
1306
|
}
|
|
1182
1307
|
console.error(err instanceof Error ? err.message : String(err));
|
|
1183
|
-
process.exit(
|
|
1308
|
+
process.exit(import_core13.EXIT_CODES.GENERAL_ERROR);
|
|
1184
1309
|
}
|
|
1185
1310
|
});
|
|
1186
1311
|
program.parse();
|