@storm-software/config-tools 1.190.21 → 1.190.22

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.
@@ -1,47 +0,0 @@
1
- import {
2
- writeError
3
- } from "./chunk-O76J367J.js";
4
-
5
- // src/utilities/toml.ts
6
- import TOML from "@ltd/j-toml";
7
- function parseCargoTomlWithTree(tree, projectRoot, projectName) {
8
- const cargoTomlString = tree.read(`${projectRoot}/Cargo.toml`)?.toString();
9
- if (!cargoTomlString) {
10
- writeError(`Cannot find a Cargo.toml file in the ${projectName}`);
11
- throw new Error();
12
- }
13
- return parseCargoToml(cargoTomlString);
14
- }
15
- function parseCargoToml(cargoString) {
16
- if (!cargoString) {
17
- throw new Error("Cargo.toml is empty");
18
- }
19
- return TOML.parse(cargoString, {
20
- x: { comment: true }
21
- });
22
- }
23
- function stringifyCargoToml(cargoToml) {
24
- const tomlString = TOML.stringify(cargoToml, {
25
- newlineAround: "section"
26
- });
27
- if (Array.isArray(tomlString)) {
28
- return tomlString.join("\n");
29
- }
30
- return tomlString;
31
- }
32
- function modifyCargoTable(toml, section, key, value) {
33
- toml[section] ??= TOML.Section({});
34
- toml[section][key] = typeof value === "object" && !Array.isArray(value) ? TOML.inline(value) : typeof value === "function" ? value() : value;
35
- }
36
- function modifyCargoNestedTable(toml, section, key, value) {
37
- toml[section] ??= {};
38
- toml[section][key] = TOML.Section(value);
39
- }
40
-
41
- export {
42
- parseCargoTomlWithTree,
43
- parseCargoToml,
44
- stringifyCargoToml,
45
- modifyCargoTable,
46
- modifyCargoNestedTable
47
- };