@settlemint/sdk-utils 2.4.0-prf263ce2b → 2.4.0-prf3423261
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/dist/environment.cjs +5 -5
- package/dist/environment.cjs.map +1 -1
- package/dist/environment.js +5 -5
- package/dist/environment.js.map +1 -1
- package/dist/filesystem.cjs +79 -79
- package/dist/filesystem.cjs.map +1 -1
- package/dist/filesystem.js +79 -79
- package/dist/filesystem.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/json.cjs +1 -1
- package/dist/json.cjs.map +1 -1
- package/dist/json.js +1 -1
- package/dist/json.js.map +1 -1
- package/dist/package-manager.cjs +79 -79
- package/dist/package-manager.cjs.map +1 -1
- package/dist/package-manager.js +79 -79
- package/dist/package-manager.js.map +1 -1
- package/dist/validation.cjs +4 -4
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.js +4 -4
- package/dist/validation.js.map +1 -1
- package/package.json +4 -2
package/dist/filesystem.cjs
CHANGED
|
@@ -84,84 +84,6 @@ async function exists(path$1) {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/json.ts
|
|
89
|
-
/**
|
|
90
|
-
* Attempts to parse a JSON string into a typed value, returning a default value if parsing fails.
|
|
91
|
-
*
|
|
92
|
-
* @param value - The JSON string to parse
|
|
93
|
-
* @param defaultValue - The value to return if parsing fails or results in null/undefined
|
|
94
|
-
* @returns The parsed JSON value as type T, or the default value if parsing fails
|
|
95
|
-
*
|
|
96
|
-
* @example
|
|
97
|
-
* import { tryParseJson } from "@settlemint/sdk-utils";
|
|
98
|
-
*
|
|
99
|
-
* const config = tryParseJson<{ port: number }>(
|
|
100
|
-
* '{"port": 3000}',
|
|
101
|
-
* { port: 8080 }
|
|
102
|
-
* );
|
|
103
|
-
* // Returns: { port: 3000 }
|
|
104
|
-
*
|
|
105
|
-
* const invalid = tryParseJson<string[]>(
|
|
106
|
-
* 'invalid json',
|
|
107
|
-
* []
|
|
108
|
-
* );
|
|
109
|
-
* // Returns: []
|
|
110
|
-
*/
|
|
111
|
-
function tryParseJson(value, defaultValue = null) {
|
|
112
|
-
try {
|
|
113
|
-
const parsed = JSON.parse(value);
|
|
114
|
-
if (parsed === undefined || parsed === null) {
|
|
115
|
-
return defaultValue;
|
|
116
|
-
}
|
|
117
|
-
return parsed;
|
|
118
|
-
} catch (err) {
|
|
119
|
-
return defaultValue;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Extracts a JSON object from a string.
|
|
124
|
-
*
|
|
125
|
-
* @param value - The string to extract the JSON object from
|
|
126
|
-
* @returns The parsed JSON object, or null if no JSON object is found
|
|
127
|
-
* @throws {Error} If the input string is too long (longer than 5000 characters)
|
|
128
|
-
* @example
|
|
129
|
-
* import { extractJsonObject } from "@settlemint/sdk-utils";
|
|
130
|
-
*
|
|
131
|
-
* const json = extractJsonObject<{ port: number }>(
|
|
132
|
-
* 'port info: {"port": 3000}',
|
|
133
|
-
* );
|
|
134
|
-
* // Returns: { port: 3000 }
|
|
135
|
-
*/
|
|
136
|
-
function extractJsonObject(value) {
|
|
137
|
-
if (value.length > 5e3) {
|
|
138
|
-
throw new Error("Input too long");
|
|
139
|
-
}
|
|
140
|
-
const result = /\{([\s\S]*)\}/.exec(value);
|
|
141
|
-
if (!result) {
|
|
142
|
-
return null;
|
|
143
|
-
}
|
|
144
|
-
return tryParseJson(result[0]);
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Converts a value to a JSON stringifiable format.
|
|
148
|
-
*
|
|
149
|
-
* @param value - The value to convert
|
|
150
|
-
* @returns The JSON stringifiable value
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* import { makeJsonStringifiable } from "@settlemint/sdk-utils";
|
|
154
|
-
*
|
|
155
|
-
* const json = makeJsonStringifiable<{ amount: bigint }>({ amount: BigInt(1000) });
|
|
156
|
-
* // Returns: '{"amount":"1000"}'
|
|
157
|
-
*/
|
|
158
|
-
function makeJsonStringifiable(value) {
|
|
159
|
-
if (value === undefined || value === null) {
|
|
160
|
-
return value;
|
|
161
|
-
}
|
|
162
|
-
return tryParseJson(JSON.stringify(value, (_, value$1) => typeof value$1 === "bigint" ? value$1.toString() : value$1));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
87
|
//#endregion
|
|
166
88
|
//#region ../../node_modules/balanced-match/index.js
|
|
167
89
|
var require_balanced_match = __commonJS({ "../../node_modules/balanced-match/index.js"(exports, module) {
|
|
@@ -6680,6 +6602,84 @@ const glob = Object.assign(glob_, {
|
|
|
6680
6602
|
});
|
|
6681
6603
|
glob.glob = glob;
|
|
6682
6604
|
|
|
6605
|
+
//#endregion
|
|
6606
|
+
//#region src/json.ts
|
|
6607
|
+
/**
|
|
6608
|
+
* Attempts to parse a JSON string into a typed value, returning a default value if parsing fails.
|
|
6609
|
+
*
|
|
6610
|
+
* @param value - The JSON string to parse
|
|
6611
|
+
* @param defaultValue - The value to return if parsing fails or results in null/undefined
|
|
6612
|
+
* @returns The parsed JSON value as type T, or the default value if parsing fails
|
|
6613
|
+
*
|
|
6614
|
+
* @example
|
|
6615
|
+
* import { tryParseJson } from "@settlemint/sdk-utils";
|
|
6616
|
+
*
|
|
6617
|
+
* const config = tryParseJson<{ port: number }>(
|
|
6618
|
+
* '{"port": 3000}',
|
|
6619
|
+
* { port: 8080 }
|
|
6620
|
+
* );
|
|
6621
|
+
* // Returns: { port: 3000 }
|
|
6622
|
+
*
|
|
6623
|
+
* const invalid = tryParseJson<string[]>(
|
|
6624
|
+
* 'invalid json',
|
|
6625
|
+
* []
|
|
6626
|
+
* );
|
|
6627
|
+
* // Returns: []
|
|
6628
|
+
*/
|
|
6629
|
+
function tryParseJson(value, defaultValue = null) {
|
|
6630
|
+
try {
|
|
6631
|
+
const parsed = JSON.parse(value);
|
|
6632
|
+
if (parsed === undefined || parsed === null) {
|
|
6633
|
+
return defaultValue;
|
|
6634
|
+
}
|
|
6635
|
+
return parsed;
|
|
6636
|
+
} catch (_err) {
|
|
6637
|
+
return defaultValue;
|
|
6638
|
+
}
|
|
6639
|
+
}
|
|
6640
|
+
/**
|
|
6641
|
+
* Extracts a JSON object from a string.
|
|
6642
|
+
*
|
|
6643
|
+
* @param value - The string to extract the JSON object from
|
|
6644
|
+
* @returns The parsed JSON object, or null if no JSON object is found
|
|
6645
|
+
* @throws {Error} If the input string is too long (longer than 5000 characters)
|
|
6646
|
+
* @example
|
|
6647
|
+
* import { extractJsonObject } from "@settlemint/sdk-utils";
|
|
6648
|
+
*
|
|
6649
|
+
* const json = extractJsonObject<{ port: number }>(
|
|
6650
|
+
* 'port info: {"port": 3000}',
|
|
6651
|
+
* );
|
|
6652
|
+
* // Returns: { port: 3000 }
|
|
6653
|
+
*/
|
|
6654
|
+
function extractJsonObject(value) {
|
|
6655
|
+
if (value.length > 5e3) {
|
|
6656
|
+
throw new Error("Input too long");
|
|
6657
|
+
}
|
|
6658
|
+
const result = /\{([\s\S]*)\}/.exec(value);
|
|
6659
|
+
if (!result) {
|
|
6660
|
+
return null;
|
|
6661
|
+
}
|
|
6662
|
+
return tryParseJson(result[0]);
|
|
6663
|
+
}
|
|
6664
|
+
/**
|
|
6665
|
+
* Converts a value to a JSON stringifiable format.
|
|
6666
|
+
*
|
|
6667
|
+
* @param value - The value to convert
|
|
6668
|
+
* @returns The JSON stringifiable value
|
|
6669
|
+
*
|
|
6670
|
+
* @example
|
|
6671
|
+
* import { makeJsonStringifiable } from "@settlemint/sdk-utils";
|
|
6672
|
+
*
|
|
6673
|
+
* const json = makeJsonStringifiable<{ amount: bigint }>({ amount: BigInt(1000) });
|
|
6674
|
+
* // Returns: '{"amount":"1000"}'
|
|
6675
|
+
*/
|
|
6676
|
+
function makeJsonStringifiable(value) {
|
|
6677
|
+
if (value === undefined || value === null) {
|
|
6678
|
+
return value;
|
|
6679
|
+
}
|
|
6680
|
+
return tryParseJson(JSON.stringify(value, (_, value$1) => typeof value$1 === "bigint" ? value$1.toString() : value$1));
|
|
6681
|
+
}
|
|
6682
|
+
|
|
6683
6683
|
//#endregion
|
|
6684
6684
|
//#region src/filesystem/mono-repo.ts
|
|
6685
6685
|
/**
|
|
@@ -6746,7 +6746,7 @@ async function findMonoRepoPackages(projectDir) {
|
|
|
6746
6746
|
}));
|
|
6747
6747
|
const allPaths = packagePaths.flat();
|
|
6748
6748
|
return allPaths.length === 0 ? [projectDir] : [monoRepoRoot, ...allPaths];
|
|
6749
|
-
} catch (
|
|
6749
|
+
} catch (_error) {
|
|
6750
6750
|
return [projectDir];
|
|
6751
6751
|
}
|
|
6752
6752
|
}
|