From 5d72814b69314c5f6b75b63e96f6367ce5f881c0 Mon Sep 17 00:00:00 2001 From: Diogo Mendes Matsubara Date: Mon, 20 Jan 2025 12:07:52 +0100 Subject: [PATCH] fix: pass env var to cargo.isPublished() cargo.isPublished() checks if the crate is already published in a given registry, without the env vars, it'll check against crates.io instead of estuary --- dist/build-crates-debian-main.js | 7 +++++-- dist/build-crates-standalone-main.js | 7 +++++-- dist/bump-crates-main.js | 7 +++++-- dist/publish-crates-cargo-main.js | 9 ++++++--- dist/publish-crates-debian-main.js | 7 +++++-- dist/publish-crates-eclipse-main.js | 7 +++++-- dist/publish-crates-github-main.js | 7 +++++-- dist/publish-crates-homebrew-main.js | 7 +++++-- src/cargo.ts | 7 +++++-- src/publish-crates-cargo.ts | 2 +- 10 files changed, 47 insertions(+), 20 deletions(-) diff --git a/dist/build-crates-debian-main.js b/dist/build-crates-debian-main.js index 5cac7e0..690c050 100644 --- a/dist/build-crates-debian-main.js +++ b/dist/build-crates-debian-main.js @@ -128252,9 +128252,12 @@ function toDebianVersion(version, revision) { * Check if Package is already published in crates.io * @param pkg Package to check. */ -function isPublished(pkg) { +function isPublished(pkg, env) { + const options = { + env + }; // Hackish but crates.io doesn't have a stable api anyway. - const results = sh(`cargo search ${pkg.name}`); + const results = sh(`cargo search ${pkg.name}`, options); if (!results) { return false; } diff --git a/dist/build-crates-standalone-main.js b/dist/build-crates-standalone-main.js index 308d8c4..b3d5b10 100644 --- a/dist/build-crates-standalone-main.js +++ b/dist/build-crates-standalone-main.js @@ -128236,9 +128236,12 @@ function toDebianVersion(version, revision) { * Check if Package is already published in crates.io * @param pkg Package to check. */ -function isPublished(pkg) { +function isPublished(pkg, env) { + const options = { + env + }; // Hackish but crates.io doesn't have a stable api anyway. - const results = sh(`cargo search ${pkg.name}`); + const results = sh(`cargo search ${pkg.name}`, options); if (!results) { return false; } diff --git a/dist/bump-crates-main.js b/dist/bump-crates-main.js index db8c061..9433789 100644 --- a/dist/bump-crates-main.js +++ b/dist/bump-crates-main.js @@ -81487,9 +81487,12 @@ function toDebianVersion(version, revision) { * Check if Package is already published in crates.io * @param pkg Package to check. */ -function isPublished(pkg) { +function isPublished(pkg, env) { + const options = { + env + }; // Hackish but crates.io doesn't have a stable api anyway. - const results = sh(`cargo search ${pkg.name}`); + const results = sh(`cargo search ${pkg.name}`, options); if (!results) { return false; } diff --git a/dist/publish-crates-cargo-main.js b/dist/publish-crates-cargo-main.js index 8a62255..3371137 100644 --- a/dist/publish-crates-cargo-main.js +++ b/dist/publish-crates-cargo-main.js @@ -81372,9 +81372,12 @@ function toDebianVersion(version, revision) { * Check if Package is already published in crates.io * @param pkg Package to check. */ -function isPublished(pkg) { +function isPublished(pkg, env) { + const options = { + env + }; // Hackish but crates.io doesn't have a stable api anyway. - const results = (0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)(`cargo search ${pkg.name}`); + const results = (0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)(`cargo search ${pkg.name}`, options); if (!results) { return false; } @@ -81709,7 +81712,7 @@ function publish(path, env, allowDirty = false) { }; for (const package_ of _cargo__WEBPACK_IMPORTED_MODULE_3__/* .packagesOrdered */ .r4(path)) { // Crates.io won't allow packages to be published with the same version - if (!_cargo__WEBPACK_IMPORTED_MODULE_3__/* .isPublished */ .s9(package_) && (package_.publish === undefined || package_.publish)) { + if (!_cargo__WEBPACK_IMPORTED_MODULE_3__/* .isPublished */ .s9(package_, env) && (package_.publish === undefined || package_.publish)) { const command = ["cargo", "publish", "--manifest-path", package_.manifestPath]; if (allowDirty) { command.push("--allow-dirty"); diff --git a/dist/publish-crates-debian-main.js b/dist/publish-crates-debian-main.js index 00bf7ad..dd0d796 100644 --- a/dist/publish-crates-debian-main.js +++ b/dist/publish-crates-debian-main.js @@ -128231,9 +128231,12 @@ function toDebianVersion(version, revision) { * Check if Package is already published in crates.io * @param pkg Package to check. */ -function isPublished(pkg) { +function isPublished(pkg, env) { + const options = { + env + }; // Hackish but crates.io doesn't have a stable api anyway. - const results = sh(`cargo search ${pkg.name}`); + const results = sh(`cargo search ${pkg.name}`, options); if (!results) { return false; } diff --git a/dist/publish-crates-eclipse-main.js b/dist/publish-crates-eclipse-main.js index f547905..884f475 100644 --- a/dist/publish-crates-eclipse-main.js +++ b/dist/publish-crates-eclipse-main.js @@ -128312,9 +128312,12 @@ function toDebianVersion(version, revision) { * Check if Package is already published in crates.io * @param pkg Package to check. */ -function isPublished(pkg) { +function isPublished(pkg, env) { + const options = { + env + }; // Hackish but crates.io doesn't have a stable api anyway. - const results = sh(`cargo search ${pkg.name}`); + const results = sh(`cargo search ${pkg.name}`, options); if (!results) { return false; } diff --git a/dist/publish-crates-github-main.js b/dist/publish-crates-github-main.js index 0ebb6f9..cfe0791 100644 --- a/dist/publish-crates-github-main.js +++ b/dist/publish-crates-github-main.js @@ -128312,9 +128312,12 @@ function toDebianVersion(version, revision) { * Check if Package is already published in crates.io * @param pkg Package to check. */ -function isPublished(pkg) { +function isPublished(pkg, env) { + const options = { + env + }; // Hackish but crates.io doesn't have a stable api anyway. - const results = sh(`cargo search ${pkg.name}`); + const results = sh(`cargo search ${pkg.name}`, options); if (!results) { return false; } diff --git a/dist/publish-crates-homebrew-main.js b/dist/publish-crates-homebrew-main.js index b47fce7..bd0b30d 100644 --- a/dist/publish-crates-homebrew-main.js +++ b/dist/publish-crates-homebrew-main.js @@ -128216,9 +128216,12 @@ function toDebianVersion(version, revision) { * Check if Package is already published in crates.io * @param pkg Package to check. */ -function isPublished(pkg) { +function isPublished(pkg, env) { + const options = { + env + }; // Hackish but crates.io doesn't have a stable api anyway. - const results = sh(`cargo search ${pkg.name}`); + const results = sh(`cargo search ${pkg.name}`, options); if (!results) { return false; } diff --git a/src/cargo.ts b/src/cargo.ts index 1c4fbea..73976c2 100644 --- a/src/cargo.ts +++ b/src/cargo.ts @@ -392,9 +392,12 @@ export function toDebianVersion(version: string, revision?: number): string { * Check if Package is already published in crates.io * @param pkg Package to check. */ -export function isPublished(pkg: Package): boolean { +export function isPublished(pkg: Package, env: NodeJS.ProcessEnv): boolean { + const options = { + env + } // Hackish but crates.io doesn't have a stable api anyway. - const results = sh(`cargo search ${pkg.name}`); + const results = sh(`cargo search ${pkg.name}`, options); if (!results) { return false; } diff --git a/src/publish-crates-cargo.ts b/src/publish-crates-cargo.ts index 4691b65..323fedd 100644 --- a/src/publish-crates-cargo.ts +++ b/src/publish-crates-cargo.ts @@ -150,7 +150,7 @@ function publish(path: string, env: NodeJS.ProcessEnv, allowDirty: boolean = fal for (const package_ of cargo.packagesOrdered(path)) { // Crates.io won't allow packages to be published with the same version - if (!cargo.isPublished(package_) && (package_.publish === undefined || package_.publish)) { + if (!cargo.isPublished(package_, env) && (package_.publish === undefined || package_.publish)) { const command = ["cargo", "publish", "--manifest-path", package_.manifestPath]; if (allowDirty) { command.push("--allow-dirty");