Skip to content

Commit

Permalink
fix: pass env var to cargo.isPublished()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
diogomatsubara committed Jan 20, 2025
1 parent 11a5db9 commit 5d72814
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 20 deletions.
7 changes: 5 additions & 2 deletions dist/build-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions dist/build-crates-standalone-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions dist/bump-crates-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
9 changes: 6 additions & 3 deletions dist/publish-crates-cargo-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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");
Expand Down
7 changes: 5 additions & 2 deletions dist/publish-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions dist/publish-crates-eclipse-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions dist/publish-crates-github-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions dist/publish-crates-homebrew-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 5 additions & 2 deletions src/cargo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/publish-crates-cargo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 5d72814

Please sign in to comment.