Skip to content

Commit

Permalink
fix: load toml-cli only once
Browse files Browse the repository at this point in the history
  • Loading branch information
diogomatsubara committed Oct 17, 2024
1 parent ddf2a56 commit ef066a8
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 53 deletions.
4 changes: 1 addition & 3 deletions __tests__/cargo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import * as https from "https";

import { sh } from "../src/command";
import * as cargo from "../src/cargo";
import { TOML } from "../src/toml";

const toml = await TOML.init();
import { toml } from "../src/toml";

const SHA_ZENOH: string = "9ecc9031ac34f6ae0f8e5b996999277b02b3038e";
const SHA_ZENOH_KOTLIN: string = "6ba9cf6e058c959614bd7f1f4148e8fa39ef1681";
Expand Down
11 changes: 6 additions & 5 deletions dist/build-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127283,7 +127283,6 @@ var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_tom



const toml = await _toml__WEBPACK_IMPORTED_MODULE_4__/* .TOML.init */ .f.init();
/**
* Uses the cargo-metadata command to list all packages in a Cargo workspace or crate.
* @param path Path to the Cargo workspace or crate.
Expand Down Expand Up @@ -127461,7 +127460,7 @@ async function configRegistry(path, name, index) {
function packagesDebian(path) {
const result = [];
for (const package_ of packages(path)) {
const manifestRaw = toml.get(package_.manifestPath);
const manifestRaw = _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.get */ .V.get(package_.manifestPath);
const manifest = ("workspace" in manifestRaw ? manifestRaw["workspace"] : manifestRaw);
if ("metadata" in manifest.package && "deb" in manifest.package.metadata) {
result.push(package_);
Expand Down Expand Up @@ -127508,7 +127507,7 @@ function hostTarget() {
}
function buildDebian(path, target, version) {
for (const package_ of packagesDebian(path)) {
const manifest = toml.get(package_.manifestPath);
const manifest = _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.get */ .V.get(package_.manifestPath);
if ("variants" in manifest.package.metadata.deb) {
for (const variant in manifest.package.metadata.deb.variants) {
(0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)(`cargo deb --no-build --no-strip \
Expand Down Expand Up @@ -127555,7 +127554,7 @@ function isPublished(pkg) {
}

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } }, 1);
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

Expand Down Expand Up @@ -127683,6 +127682,7 @@ const gitEnv = {
"use strict";
__nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "V": () => (/* binding */ toml),
/* harmony export */ "f": () => (/* binding */ TOML)
/* harmony export */ });
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(73292);
Expand Down Expand Up @@ -127712,9 +127712,10 @@ class TOML {
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(path, (0,_command__WEBPACK_IMPORTED_MODULE_1__/* .exec */ .G)("toml", ["unset", path, query]));
}
}
const toml = await TOML.init();

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });
} catch(e) { __webpack_async_result__(e); } }, 1);

/***/ }),

Expand Down
11 changes: 6 additions & 5 deletions dist/build-crates-standalone-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127267,7 +127267,6 @@ var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_tom



const toml = await _toml__WEBPACK_IMPORTED_MODULE_4__/* .TOML.init */ .f.init();
/**
* Uses the cargo-metadata command to list all packages in a Cargo workspace or crate.
* @param path Path to the Cargo workspace or crate.
Expand Down Expand Up @@ -127481,7 +127480,7 @@ async function installBinaryCached(name) {
}
}
function build(path, target) {
const crossManifest = toml.get((0,path__WEBPACK_IMPORTED_MODULE_1__.join)(path, "Cross.toml"));
const crossManifest = _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.get */ .V.get((0,path__WEBPACK_IMPORTED_MODULE_1__.join)(path, "Cross.toml"));
(0,_command__WEBPACK_IMPORTED_MODULE_5__.sh)(`rustup target add ${target}`, { cwd: path });
const command = target in crossManifest.target ? ["cross"] : ["cargo"];
command.push("build", "--release", "--bins", "--lib", "--target", target);
Expand Down Expand Up @@ -127539,7 +127538,7 @@ function isPublished(pkg) {
}

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } }, 1);
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

Expand Down Expand Up @@ -127696,8 +127695,9 @@ function describe(path = process.cwd()) {
"use strict";
__nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "f": () => (/* binding */ TOML)
/* harmony export */ "V": () => (/* binding */ toml)
/* harmony export */ });
/* unused harmony export TOML */
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(73292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(28121);
Expand Down Expand Up @@ -127725,9 +127725,10 @@ class TOML {
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(path, (0,_command__WEBPACK_IMPORTED_MODULE_1__/* .exec */ .G)("toml", ["unset", path, query]));
}
}
const toml = await TOML.init();

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });
} catch(e) { __webpack_async_result__(e); } }, 1);

/***/ }),

Expand Down
27 changes: 14 additions & 13 deletions dist/bump-crates-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -80989,7 +80989,6 @@ var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_tom



const toml = await _toml__WEBPACK_IMPORTED_MODULE_4__/* .TOML.init */ .f.init();
/**
* Uses the cargo-metadata command to list all packages in a Cargo workspace or crate.
* @param path Path to the Cargo workspace or crate.
Expand Down Expand Up @@ -81049,12 +81048,12 @@ function* packagesOrdered(path) {
async function bump(path, version) {
_actions_core__WEBPACK_IMPORTED_MODULE_2__.startGroup(`Bumping package versions in ${path} to ${version}`);
const manifestPath = `${path}/Cargo.toml`;
const manifestRaw = toml.get(manifestPath);
const manifestRaw = _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.get */ .V.get(manifestPath);
if ("workspace" in manifestRaw) {
await toml.set(manifestPath, ["workspace", "package", "version"], version);
await _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.set */ .V.set(manifestPath, ["workspace", "package", "version"], version);
}
else {
await toml.set(manifestPath, ["package", "version"], version);
await _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.set */ .V.set(manifestPath, ["package", "version"], version);
}
_actions_core__WEBPACK_IMPORTED_MODULE_2__.endGroup();
}
Expand All @@ -81078,7 +81077,7 @@ async function bump(path, version) {
async function bumpDependencies(path, pattern, version, _branch) {
_actions_core__WEBPACK_IMPORTED_MODULE_2__.startGroup(`Bumping ${pattern} dependencies in ${path} to ${version}`);
const manifestPath = `${path}/Cargo.toml`;
const manifestRaw = toml.get(manifestPath);
const manifestRaw = _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.get */ .V.get(manifestPath);
let manifest;
let prefix;
if ("workspace" in manifestRaw) {
Expand All @@ -81091,20 +81090,20 @@ async function bumpDependencies(path, pattern, version, _branch) {
}
for (const dep in manifest.dependencies) {
if (pattern.test(dep)) {
await toml.set(manifestPath, prefix.concat("dependencies", dep, "version"), version);
await _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.set */ .V.set(manifestPath, prefix.concat("dependencies", dep, "version"), version);
// FIXME(fuzzypixelz): Previously, we set the branch of the git source in dependencies,
// but as all dependencies are assumed to be on crates.io anyway, this is not necessary.
// Still, the API of all related actions/workflows should be updated to reflect this.
//
// if (branch != undefined) {
// await toml.set(manifestPath, prefix.concat("dependencies", dep, "branch"), branch);
// }
await toml.unset(manifestPath, prefix.concat("dependencies", dep, "git"));
await toml.unset(manifestPath, prefix.concat("dependencies", dep, "branch"));
await _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.unset */ .V.unset(manifestPath, prefix.concat("dependencies", dep, "git"));
await _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.unset */ .V.unset(manifestPath, prefix.concat("dependencies", dep, "branch"));
}
}
for (const package_ of packages(path)) {
const manifest = toml.get(package_.manifestPath);
const manifest = _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.get */ .V.get(package_.manifestPath);
if ("metadata" in manifest.package &&
"deb" in manifest.package.metadata &&
"depends" in manifest.package.metadata.deb &&
Expand All @@ -81113,7 +81112,7 @@ async function bumpDependencies(path, pattern, version, _branch) {
const deb = manifest.package.metadata.deb;
const depends = deb.depends.replaceAll(/\(=[^\(\)]+\)/g, `(=${_cargo__WEBPACK_IMPORTED_MODULE_7__/* .toDebianVersion */ .$l(version)})`);
_actions_core__WEBPACK_IMPORTED_MODULE_2__.info(`Changing ${deb.depends} to ${depends} in ${package_.name}`);
await toml.set(package_.manifestPath, ["package", "metadata", "deb", "depends"], depends);
await _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.set */ .V.set(package_.manifestPath, ["package", "metadata", "deb", "depends"], depends);
}
}
_actions_core__WEBPACK_IMPORTED_MODULE_2__.endGroup();
Expand Down Expand Up @@ -81261,7 +81260,7 @@ function isPublished(pkg) {
}

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } }, 1);
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

Expand Down Expand Up @@ -81388,8 +81387,9 @@ const gitEnv = {
"use strict";
__nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "f": () => (/* binding */ TOML)
/* harmony export */ "V": () => (/* binding */ toml)
/* harmony export */ });
/* unused harmony export TOML */
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(3292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(8121);
Expand Down Expand Up @@ -81417,9 +81417,10 @@ class TOML {
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(path, (0,_command__WEBPACK_IMPORTED_MODULE_1__/* .exec */ .G)("toml", ["unset", path, query]));
}
}
const toml = await TOML.init();

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });
} catch(e) { __webpack_async_result__(e); } }, 1);

/***/ }),

Expand Down
19 changes: 10 additions & 9 deletions dist/publish-crates-cargo-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -80878,7 +80878,6 @@ var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_tom



const toml = await _toml__WEBPACK_IMPORTED_MODULE_4__/* .TOML.init */ .f.init();
/**
* Uses the cargo-metadata command to list all packages in a Cargo workspace or crate.
* @param path Path to the Cargo workspace or crate.
Expand Down Expand Up @@ -81018,7 +81017,7 @@ async function bumpDependencies(path, pattern, version, _branch) {
async function setRegistry(path, pattern, registry) {
_actions_core__WEBPACK_IMPORTED_MODULE_2__.startGroup(`Changing ${pattern} dependencies' registry ${registry}`);
const manifestPath = `${path}/Cargo.toml`;
const manifestRaw = toml.get(manifestPath);
const manifestRaw = _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.get */ .V.get(manifestPath);
let manifest;
let prefix;
if ("workspace" in manifestRaw) {
Expand All @@ -81031,10 +81030,10 @@ async function setRegistry(path, pattern, registry) {
}
for (const dep in manifest.dependencies) {
if (pattern.test(dep)) {
await toml.set(manifestPath, prefix.concat("dependencies", dep, "registry"), registry);
await _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.set */ .V.set(manifestPath, prefix.concat("dependencies", dep, "registry"), registry);
// NOTE: Only one of `git` or `registry` is allowed, otherwise the specification is ambiguous
await toml.unset(manifestPath, prefix.concat("dependencies", dep, "git"));
await toml.unset(manifestPath, prefix.concat("dependencies", dep, "branch"));
await _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.unset */ .V.unset(manifestPath, prefix.concat("dependencies", dep, "git"));
await _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.unset */ .V.unset(manifestPath, prefix.concat("dependencies", dep, "branch"));
}
}
_actions_core__WEBPACK_IMPORTED_MODULE_2__.endGroup();
Expand All @@ -81047,7 +81046,7 @@ async function setRegistry(path, pattern, registry) {
*/
async function configRegistry(path, name, index) {
const configPath = `${path}/.cargo/config.toml`;
await toml.set(configPath, ["registries", name, "index"], index);
await _toml__WEBPACK_IMPORTED_MODULE_4__/* .toml.set */ .V.set(configPath, ["registries", name, "index"], index);
}
/**
* Returns a list of all workspace packages which contain Debian package metadata.
Expand Down Expand Up @@ -81150,7 +81149,7 @@ function isPublished(pkg) {
}

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } }, 1);
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

Expand Down Expand Up @@ -81498,8 +81497,9 @@ __webpack_async_result__();
"use strict";
__nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "f": () => (/* binding */ TOML)
/* harmony export */ "V": () => (/* binding */ toml)
/* harmony export */ });
/* unused harmony export TOML */
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(3292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(8121);
Expand Down Expand Up @@ -81527,9 +81527,10 @@ class TOML {
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(path, (0,_command__WEBPACK_IMPORTED_MODULE_1__/* .exec */ .G)("toml", ["unset", path, query]));
}
}
const toml = await TOML.init();

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });
} catch(e) { __webpack_async_result__(e); } }, 1);

/***/ }),

Expand Down
7 changes: 4 additions & 3 deletions dist/publish-crates-debian-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127262,7 +127262,6 @@ var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_tom



const toml = await _toml__WEBPACK_IMPORTED_MODULE_4__/* .TOML.init */ .f.init();
/**
* Uses the cargo-metadata command to list all packages in a Cargo workspace or crate.
* @param path Path to the Cargo workspace or crate.
Expand Down Expand Up @@ -127534,7 +127533,7 @@ function isPublished(pkg) {
}

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } }, 1);
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

Expand Down Expand Up @@ -127838,6 +127837,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "f": () => (/* binding */ TOML)
/* harmony export */ });
/* unused harmony export toml */
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(73292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(28121);
Expand Down Expand Up @@ -127865,9 +127865,10 @@ class TOML {
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(path, (0,_command__WEBPACK_IMPORTED_MODULE_1__/* .exec */ .G)("toml", ["unset", path, query]));
}
}
const toml = await TOML.init();

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });
} catch(e) { __webpack_async_result__(e); } }, 1);

/***/ }),

Expand Down
7 changes: 4 additions & 3 deletions dist/publish-crates-eclipse-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127343,7 +127343,6 @@ var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_tom



const toml = await _toml__WEBPACK_IMPORTED_MODULE_4__/* .TOML.init */ .f.init();
/**
* Uses the cargo-metadata command to list all packages in a Cargo workspace or crate.
* @param path Path to the Cargo workspace or crate.
Expand Down Expand Up @@ -127615,7 +127614,7 @@ function isPublished(pkg) {
}

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } }, 1);
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

Expand Down Expand Up @@ -127944,6 +127943,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "f": () => (/* binding */ TOML)
/* harmony export */ });
/* unused harmony export toml */
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(73292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(28121);
Expand Down Expand Up @@ -127971,9 +127971,10 @@ class TOML {
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(path, (0,_command__WEBPACK_IMPORTED_MODULE_1__/* .exec */ .G)("toml", ["unset", path, query]));
}
}
const toml = await TOML.init();

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });
} catch(e) { __webpack_async_result__(e); } }, 1);

/***/ }),

Expand Down
7 changes: 4 additions & 3 deletions dist/publish-crates-github-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -127343,7 +127343,6 @@ var __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_tom



const toml = await _toml__WEBPACK_IMPORTED_MODULE_4__/* .TOML.init */ .f.init();
/**
* Uses the cargo-metadata command to list all packages in a Cargo workspace or crate.
* @param path Path to the Cargo workspace or crate.
Expand Down Expand Up @@ -127615,7 +127614,7 @@ function isPublished(pkg) {
}

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } }, 1);
} catch(e) { __webpack_async_result__(e); } });

/***/ }),

Expand Down Expand Up @@ -127884,6 +127883,7 @@ __nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __we
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "f": () => (/* binding */ TOML)
/* harmony export */ });
/* unused harmony export toml */
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(73292);
/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _command__WEBPACK_IMPORTED_MODULE_1__ = __nccwpck_require__(28121);
Expand Down Expand Up @@ -127911,9 +127911,10 @@ class TOML {
await fs_promises__WEBPACK_IMPORTED_MODULE_0__.writeFile(path, (0,_command__WEBPACK_IMPORTED_MODULE_1__/* .exec */ .G)("toml", ["unset", path, query]));
}
}
const toml = await TOML.init();

__webpack_async_result__();
} catch(e) { __webpack_async_result__(e); } });
} catch(e) { __webpack_async_result__(e); } }, 1);

/***/ }),

Expand Down
Loading

0 comments on commit ef066a8

Please sign in to comment.