@settlemint/sdk-utils 2.3.8 → 2.3.11-prc833123c
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/README.md +91 -80
- package/dist/environment.cjs +4501 -3924
- package/dist/environment.cjs.map +1 -1
- package/dist/environment.d.cts +7 -31
- package/dist/environment.d.ts +7 -31
- package/dist/environment.js +4501 -3924
- package/dist/environment.js.map +1 -1
- package/dist/filesystem.d.cts +1 -17
- package/dist/filesystem.d.ts +1 -17
- package/dist/http.d.cts +0 -4
- package/dist/http.d.ts +0 -4
- package/dist/index.d.cts +0 -4
- package/dist/index.d.ts +0 -4
- package/dist/json.d.cts +0 -1
- package/dist/json.d.ts +0 -1
- package/dist/logging.d.cts +2 -3
- package/dist/logging.d.ts +2 -3
- package/dist/package-manager.d.cts +1 -16
- package/dist/package-manager.d.ts +1 -16
- package/dist/retry.d.cts +0 -1
- package/dist/retry.d.ts +0 -1
- package/dist/runtime.d.cts +0 -1
- package/dist/runtime.d.ts +0 -1
- package/dist/string.d.cts +0 -1
- package/dist/string.d.ts +0 -1
- package/dist/terminal.d.cts +1 -20
- package/dist/terminal.d.ts +1 -20
- package/dist/url.d.cts +0 -1
- package/dist/url.d.ts +0 -1
- package/dist/validation.cjs +4503 -3925
- package/dist/validation.cjs.map +1 -1
- package/dist/validation.d.cts +8 -30
- package/dist/validation.d.ts +8 -30
- package/dist/validation.js +4503 -3926
- package/dist/validation.js.map +1 -1
- package/package.json +1 -1
package/dist/filesystem.d.cts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
import { PathLike } from "node:fs";
|
|
2
2
|
|
|
3
3
|
//#region src/filesystem/project-root.d.ts
|
|
4
|
-
|
|
5
|
-
* Finds the root directory of the current project by locating the nearest package.json file
|
|
6
|
-
*
|
|
7
|
-
* @param fallbackToCwd - If true, will return the current working directory if no package.json is found
|
|
8
|
-
* @param cwd - The directory to start searching for the package.json file from (defaults to process.cwd())
|
|
9
|
-
* @returns Promise that resolves to the absolute path of the project root directory
|
|
10
|
-
* @throws Will throw an error if no package.json is found in the directory tree
|
|
11
|
-
* @example
|
|
12
|
-
* import { projectRoot } from "@settlemint/sdk-utils/filesystem";
|
|
13
|
-
*
|
|
14
|
-
* // Get project root path
|
|
15
|
-
* const rootDir = await projectRoot();
|
|
16
|
-
* console.log(`Project root is at: ${rootDir}`);
|
|
17
|
-
*/
|
|
4
|
+
|
|
18
5
|
/**
|
|
19
6
|
* Finds the root directory of the current project by locating the nearest package.json file
|
|
20
7
|
*
|
|
@@ -30,7 +17,6 @@ import { PathLike } from "node:fs";
|
|
|
30
17
|
* console.log(`Project root is at: ${rootDir}`);
|
|
31
18
|
*/
|
|
32
19
|
declare function projectRoot(fallbackToCwd?: boolean, cwd?: string): Promise<string>;
|
|
33
|
-
|
|
34
20
|
//#endregion
|
|
35
21
|
//#region src/filesystem/exists.d.ts
|
|
36
22
|
/**
|
|
@@ -47,7 +33,6 @@ declare function projectRoot(fallbackToCwd?: boolean, cwd?: string): Promise<str
|
|
|
47
33
|
* }
|
|
48
34
|
*/
|
|
49
35
|
declare function exists(path: PathLike): Promise<boolean>;
|
|
50
|
-
|
|
51
36
|
//#endregion
|
|
52
37
|
//#region src/filesystem/mono-repo.d.ts
|
|
53
38
|
/**
|
|
@@ -74,7 +59,6 @@ declare function findMonoRepoRoot(startDir: string): Promise<string | null>;
|
|
|
74
59
|
* console.log(packages); // Output: ["/path/to/your/project/packages/core", "/path/to/your/project/packages/ui"]
|
|
75
60
|
*/
|
|
76
61
|
declare function findMonoRepoPackages(projectDir: string): Promise<string[]>;
|
|
77
|
-
|
|
78
62
|
//#endregion
|
|
79
63
|
export { exists, findMonoRepoPackages, findMonoRepoRoot, projectRoot };
|
|
80
64
|
//# sourceMappingURL=filesystem.d.cts.map
|
package/dist/filesystem.d.ts
CHANGED
|
@@ -1,20 +1,7 @@
|
|
|
1
1
|
import { PathLike } from "node:fs";
|
|
2
2
|
|
|
3
3
|
//#region src/filesystem/project-root.d.ts
|
|
4
|
-
|
|
5
|
-
* Finds the root directory of the current project by locating the nearest package.json file
|
|
6
|
-
*
|
|
7
|
-
* @param fallbackToCwd - If true, will return the current working directory if no package.json is found
|
|
8
|
-
* @param cwd - The directory to start searching for the package.json file from (defaults to process.cwd())
|
|
9
|
-
* @returns Promise that resolves to the absolute path of the project root directory
|
|
10
|
-
* @throws Will throw an error if no package.json is found in the directory tree
|
|
11
|
-
* @example
|
|
12
|
-
* import { projectRoot } from "@settlemint/sdk-utils/filesystem";
|
|
13
|
-
*
|
|
14
|
-
* // Get project root path
|
|
15
|
-
* const rootDir = await projectRoot();
|
|
16
|
-
* console.log(`Project root is at: ${rootDir}`);
|
|
17
|
-
*/
|
|
4
|
+
|
|
18
5
|
/**
|
|
19
6
|
* Finds the root directory of the current project by locating the nearest package.json file
|
|
20
7
|
*
|
|
@@ -30,7 +17,6 @@ import { PathLike } from "node:fs";
|
|
|
30
17
|
* console.log(`Project root is at: ${rootDir}`);
|
|
31
18
|
*/
|
|
32
19
|
declare function projectRoot(fallbackToCwd?: boolean, cwd?: string): Promise<string>;
|
|
33
|
-
|
|
34
20
|
//#endregion
|
|
35
21
|
//#region src/filesystem/exists.d.ts
|
|
36
22
|
/**
|
|
@@ -47,7 +33,6 @@ declare function projectRoot(fallbackToCwd?: boolean, cwd?: string): Promise<str
|
|
|
47
33
|
* }
|
|
48
34
|
*/
|
|
49
35
|
declare function exists(path: PathLike): Promise<boolean>;
|
|
50
|
-
|
|
51
36
|
//#endregion
|
|
52
37
|
//#region src/filesystem/mono-repo.d.ts
|
|
53
38
|
/**
|
|
@@ -74,7 +59,6 @@ declare function findMonoRepoRoot(startDir: string): Promise<string | null>;
|
|
|
74
59
|
* console.log(packages); // Output: ["/path/to/your/project/packages/core", "/path/to/your/project/packages/ui"]
|
|
75
60
|
*/
|
|
76
61
|
declare function findMonoRepoPackages(projectDir: string): Promise<string[]>;
|
|
77
|
-
|
|
78
62
|
//#endregion
|
|
79
63
|
export { exists, findMonoRepoPackages, findMonoRepoRoot, projectRoot };
|
|
80
64
|
//# sourceMappingURL=filesystem.d.ts.map
|
package/dist/http.d.cts
CHANGED
|
@@ -15,10 +15,8 @@
|
|
|
15
15
|
* const response = await fetchWithRetry("https://api.example.com/data");
|
|
16
16
|
*/
|
|
17
17
|
declare function fetchWithRetry(input: RequestInfo | URL, init?: RequestInit, maxRetries?: number, initialSleepTime?: number): Promise<Response>;
|
|
18
|
-
|
|
19
18
|
//#endregion
|
|
20
19
|
//#region src/http/graphql-fetch-with-retry.d.ts
|
|
21
|
-
|
|
22
20
|
/**
|
|
23
21
|
* Executes a GraphQL request with automatic retries using exponential backoff and jitter.
|
|
24
22
|
* Only retries on server errors (5xx), rate limits (429), timeouts (408), and network errors.
|
|
@@ -50,14 +48,12 @@ declare function fetchWithRetry(input: RequestInfo | URL, init?: RequestInit, ma
|
|
|
50
48
|
* );
|
|
51
49
|
*/
|
|
52
50
|
declare function graphqlFetchWithRetry<Data>(input: RequestInfo | URL, init?: RequestInit, maxRetries?: number, initialSleepTime?: number): Promise<Data>;
|
|
53
|
-
|
|
54
51
|
//#endregion
|
|
55
52
|
//#region src/http/headers.d.ts
|
|
56
53
|
type MaybeLazy<T> = T | (() => T);
|
|
57
54
|
declare function appendHeaders(headers: MaybeLazy<HeadersInit> | undefined, additionalHeaders: Record<string, string | undefined>): [string, string][] | Headers | {
|
|
58
55
|
[x: string]: string;
|
|
59
56
|
};
|
|
60
|
-
|
|
61
57
|
//#endregion
|
|
62
58
|
export { appendHeaders, fetchWithRetry, graphqlFetchWithRetry };
|
|
63
59
|
//# sourceMappingURL=http.d.cts.map
|
package/dist/http.d.ts
CHANGED
|
@@ -15,10 +15,8 @@
|
|
|
15
15
|
* const response = await fetchWithRetry("https://api.example.com/data");
|
|
16
16
|
*/
|
|
17
17
|
declare function fetchWithRetry(input: RequestInfo | URL, init?: RequestInit, maxRetries?: number, initialSleepTime?: number): Promise<Response>;
|
|
18
|
-
|
|
19
18
|
//#endregion
|
|
20
19
|
//#region src/http/graphql-fetch-with-retry.d.ts
|
|
21
|
-
|
|
22
20
|
/**
|
|
23
21
|
* Executes a GraphQL request with automatic retries using exponential backoff and jitter.
|
|
24
22
|
* Only retries on server errors (5xx), rate limits (429), timeouts (408), and network errors.
|
|
@@ -50,14 +48,12 @@ declare function fetchWithRetry(input: RequestInfo | URL, init?: RequestInit, ma
|
|
|
50
48
|
* );
|
|
51
49
|
*/
|
|
52
50
|
declare function graphqlFetchWithRetry<Data>(input: RequestInfo | URL, init?: RequestInit, maxRetries?: number, initialSleepTime?: number): Promise<Data>;
|
|
53
|
-
|
|
54
51
|
//#endregion
|
|
55
52
|
//#region src/http/headers.d.ts
|
|
56
53
|
type MaybeLazy<T> = T | (() => T);
|
|
57
54
|
declare function appendHeaders(headers: MaybeLazy<HeadersInit> | undefined, additionalHeaders: Record<string, string | undefined>): [string, string][] | Headers | {
|
|
58
55
|
[x: string]: string;
|
|
59
56
|
};
|
|
60
|
-
|
|
61
57
|
//#endregion
|
|
62
58
|
export { appendHeaders, fetchWithRetry, graphqlFetchWithRetry };
|
|
63
59
|
//# sourceMappingURL=http.d.ts.map
|
package/dist/index.d.cts
CHANGED
|
@@ -50,7 +50,6 @@ declare function extractJsonObject<T>(value: string): T | null;
|
|
|
50
50
|
* // Returns: '{"amount":"1000"}'
|
|
51
51
|
*/
|
|
52
52
|
declare function makeJsonStringifiable<T>(value: unknown): T;
|
|
53
|
-
|
|
54
53
|
//#endregion
|
|
55
54
|
//#region src/retry.d.ts
|
|
56
55
|
/**
|
|
@@ -67,7 +66,6 @@ declare function makeJsonStringifiable<T>(value: unknown): T;
|
|
|
67
66
|
* const result = await retryWhenFailed(() => readFile("/path/to/file.txt"), 3, 1_000);
|
|
68
67
|
*/
|
|
69
68
|
declare function retryWhenFailed<T>(fn: () => Promise<T>, maxRetries?: number, initialSleepTime?: number, stopOnError?: (error: Error) => boolean): Promise<T>;
|
|
70
|
-
|
|
71
69
|
//#endregion
|
|
72
70
|
//#region src/string.d.ts
|
|
73
71
|
/**
|
|
@@ -123,7 +121,6 @@ declare function replaceUnderscoresAndHyphensWithSpaces(s: string): string;
|
|
|
123
121
|
* // Returns: "Hello, wor..."
|
|
124
122
|
*/
|
|
125
123
|
declare function truncate(value: string, maxLength: number): string;
|
|
126
|
-
|
|
127
124
|
//#endregion
|
|
128
125
|
//#region src/url.d.ts
|
|
129
126
|
/**
|
|
@@ -141,7 +138,6 @@ declare function truncate(value: string, maxLength: number): string;
|
|
|
141
138
|
* ```
|
|
142
139
|
*/
|
|
143
140
|
declare function extractBaseUrlBeforeSegment(baseUrl: string, pathSegment: string): string;
|
|
144
|
-
|
|
145
141
|
//#endregion
|
|
146
142
|
export { camelCaseToWords, capitalizeFirstLetter, extractBaseUrlBeforeSegment, extractJsonObject, makeJsonStringifiable, replaceUnderscoresAndHyphensWithSpaces, retryWhenFailed, truncate, tryParseJson };
|
|
147
143
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -50,7 +50,6 @@ declare function extractJsonObject<T>(value: string): T | null;
|
|
|
50
50
|
* // Returns: '{"amount":"1000"}'
|
|
51
51
|
*/
|
|
52
52
|
declare function makeJsonStringifiable<T>(value: unknown): T;
|
|
53
|
-
|
|
54
53
|
//#endregion
|
|
55
54
|
//#region src/retry.d.ts
|
|
56
55
|
/**
|
|
@@ -67,7 +66,6 @@ declare function makeJsonStringifiable<T>(value: unknown): T;
|
|
|
67
66
|
* const result = await retryWhenFailed(() => readFile("/path/to/file.txt"), 3, 1_000);
|
|
68
67
|
*/
|
|
69
68
|
declare function retryWhenFailed<T>(fn: () => Promise<T>, maxRetries?: number, initialSleepTime?: number, stopOnError?: (error: Error) => boolean): Promise<T>;
|
|
70
|
-
|
|
71
69
|
//#endregion
|
|
72
70
|
//#region src/string.d.ts
|
|
73
71
|
/**
|
|
@@ -123,7 +121,6 @@ declare function replaceUnderscoresAndHyphensWithSpaces(s: string): string;
|
|
|
123
121
|
* // Returns: "Hello, wor..."
|
|
124
122
|
*/
|
|
125
123
|
declare function truncate(value: string, maxLength: number): string;
|
|
126
|
-
|
|
127
124
|
//#endregion
|
|
128
125
|
//#region src/url.d.ts
|
|
129
126
|
/**
|
|
@@ -141,7 +138,6 @@ declare function truncate(value: string, maxLength: number): string;
|
|
|
141
138
|
* ```
|
|
142
139
|
*/
|
|
143
140
|
declare function extractBaseUrlBeforeSegment(baseUrl: string, pathSegment: string): string;
|
|
144
|
-
|
|
145
141
|
//#endregion
|
|
146
142
|
export { camelCaseToWords, capitalizeFirstLetter, extractBaseUrlBeforeSegment, extractJsonObject, makeJsonStringifiable, replaceUnderscoresAndHyphensWithSpaces, retryWhenFailed, truncate, tryParseJson };
|
|
147
143
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/json.d.cts
CHANGED
|
@@ -50,7 +50,6 @@ declare function extractJsonObject<T>(value: string): T | null;
|
|
|
50
50
|
* // Returns: '{"amount":"1000"}'
|
|
51
51
|
*/
|
|
52
52
|
declare function makeJsonStringifiable<T>(value: unknown): T;
|
|
53
|
-
|
|
54
53
|
//#endregion
|
|
55
54
|
export { extractJsonObject, makeJsonStringifiable, tryParseJson };
|
|
56
55
|
//# sourceMappingURL=json.d.cts.map
|
package/dist/json.d.ts
CHANGED
|
@@ -50,7 +50,6 @@ declare function extractJsonObject<T>(value: string): T | null;
|
|
|
50
50
|
* // Returns: '{"amount":"1000"}'
|
|
51
51
|
*/
|
|
52
52
|
declare function makeJsonStringifiable<T>(value: unknown): T;
|
|
53
|
-
|
|
54
53
|
//#endregion
|
|
55
54
|
export { extractJsonObject, makeJsonStringifiable, tryParseJson };
|
|
56
55
|
//# sourceMappingURL=json.d.ts.map
|
package/dist/logging.d.cts
CHANGED
|
@@ -47,7 +47,8 @@ declare function createLogger(options?: LoggerOptions): Logger;
|
|
|
47
47
|
/**
|
|
48
48
|
* Default logger instance with standard configuration
|
|
49
49
|
*/
|
|
50
|
-
declare const logger: Logger;
|
|
50
|
+
declare const logger: Logger;
|
|
51
|
+
//#endregion
|
|
51
52
|
//#region src/logging/request-logger.d.ts
|
|
52
53
|
/**
|
|
53
54
|
* Logs the request and duration of a fetch call (> 500ms is logged as warn, otherwise info)
|
|
@@ -57,7 +58,6 @@ declare const logger: Logger; //#endregion
|
|
|
57
58
|
* @returns The fetch function
|
|
58
59
|
*/
|
|
59
60
|
declare function requestLogger(logger: Logger, name: string, fn: typeof fetch): (...args: Parameters<typeof fetch>) => Promise<Response>;
|
|
60
|
-
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/logging/mask-tokens.d.ts
|
|
63
63
|
/**
|
|
@@ -73,7 +73,6 @@ declare function requestLogger(logger: Logger, name: string, fn: typeof fetch):
|
|
|
73
73
|
* const masked = maskTokens("Token: sm_pat_****"); // "Token: ***"
|
|
74
74
|
*/
|
|
75
75
|
declare const maskTokens: (output: string) => string;
|
|
76
|
-
|
|
77
76
|
//#endregion
|
|
78
77
|
export { LogLevel, Logger, LoggerOptions, createLogger, maskTokens, requestLogger };
|
|
79
78
|
//# sourceMappingURL=logging.d.cts.map
|
package/dist/logging.d.ts
CHANGED
|
@@ -47,7 +47,8 @@ declare function createLogger(options?: LoggerOptions): Logger;
|
|
|
47
47
|
/**
|
|
48
48
|
* Default logger instance with standard configuration
|
|
49
49
|
*/
|
|
50
|
-
declare const logger: Logger;
|
|
50
|
+
declare const logger: Logger;
|
|
51
|
+
//#endregion
|
|
51
52
|
//#region src/logging/request-logger.d.ts
|
|
52
53
|
/**
|
|
53
54
|
* Logs the request and duration of a fetch call (> 500ms is logged as warn, otherwise info)
|
|
@@ -57,7 +58,6 @@ declare const logger: Logger; //#endregion
|
|
|
57
58
|
* @returns The fetch function
|
|
58
59
|
*/
|
|
59
60
|
declare function requestLogger(logger: Logger, name: string, fn: typeof fetch): (...args: Parameters<typeof fetch>) => Promise<Response>;
|
|
60
|
-
|
|
61
61
|
//#endregion
|
|
62
62
|
//#region src/logging/mask-tokens.d.ts
|
|
63
63
|
/**
|
|
@@ -73,7 +73,6 @@ declare function requestLogger(logger: Logger, name: string, fn: typeof fetch):
|
|
|
73
73
|
* const masked = maskTokens("Token: sm_pat_****"); // "Token: ***"
|
|
74
74
|
*/
|
|
75
75
|
declare const maskTokens: (output: string) => string;
|
|
76
|
-
|
|
77
76
|
//#endregion
|
|
78
77
|
export { LogLevel, Logger, LoggerOptions, createLogger, maskTokens, requestLogger };
|
|
79
78
|
//# sourceMappingURL=logging.d.ts.map
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { AgentName } from "package-manager-detector";
|
|
2
2
|
|
|
3
3
|
//#region src/package-manager/download-and-extract.d.ts
|
|
4
|
-
|
|
5
|
-
* Formats a directory path by removing trailing slashes and whitespace
|
|
6
|
-
*
|
|
7
|
-
* @param targetDir - The directory path to format
|
|
8
|
-
* @returns The formatted directory path
|
|
9
|
-
* @example
|
|
10
|
-
* import { formatTargetDir } from "@settlemint/sdk-utils/package-manager";
|
|
11
|
-
*
|
|
12
|
-
* const formatted = formatTargetDir("/path/to/dir/ "); // "/path/to/dir"
|
|
13
|
-
*/
|
|
4
|
+
|
|
14
5
|
/**
|
|
15
6
|
* Formats a directory path by removing trailing slashes and whitespace
|
|
16
7
|
*
|
|
@@ -45,7 +36,6 @@ declare function isEmpty(path: string): Promise<boolean>;
|
|
|
45
36
|
* await emptyDir("/path/to/dir"); // Removes all contents except .git
|
|
46
37
|
*/
|
|
47
38
|
declare function emptyDir(dir: string): Promise<void>;
|
|
48
|
-
|
|
49
39
|
//#endregion
|
|
50
40
|
//#region src/package-manager/get-package-manager.d.ts
|
|
51
41
|
/**
|
|
@@ -60,7 +50,6 @@ declare function emptyDir(dir: string): Promise<void>;
|
|
|
60
50
|
* console.log(`Using ${packageManager}`);
|
|
61
51
|
*/
|
|
62
52
|
declare function getPackageManager(targetDir?: string): Promise<AgentName>;
|
|
63
|
-
|
|
64
53
|
//#endregion
|
|
65
54
|
//#region src/package-manager/get-package-manager-executable.d.ts
|
|
66
55
|
/**
|
|
@@ -78,7 +67,6 @@ declare function getPackageManagerExecutable(targetDir?: string): Promise<{
|
|
|
78
67
|
command: string;
|
|
79
68
|
args: string[];
|
|
80
69
|
}>;
|
|
81
|
-
|
|
82
70
|
//#endregion
|
|
83
71
|
//#region src/package-manager/install-dependencies.d.ts
|
|
84
72
|
/**
|
|
@@ -98,7 +86,6 @@ declare function getPackageManagerExecutable(targetDir?: string): Promise<{
|
|
|
98
86
|
* await installDependencies(["express", "cors"]);
|
|
99
87
|
*/
|
|
100
88
|
declare function installDependencies(pkgs: string | string[], cwd?: string): Promise<void>;
|
|
101
|
-
|
|
102
89
|
//#endregion
|
|
103
90
|
//#region src/package-manager/is-package-installed.d.ts
|
|
104
91
|
/**
|
|
@@ -115,7 +102,6 @@ declare function installDependencies(pkgs: string | string[], cwd?: string): Pro
|
|
|
115
102
|
* console.log(`@settlemint/sdk-utils is installed: ${isInstalled}`);
|
|
116
103
|
*/
|
|
117
104
|
declare function isPackageInstalled(name: string, path?: string): Promise<boolean>;
|
|
118
|
-
|
|
119
105
|
//#endregion
|
|
120
106
|
//#region src/package-manager/set-name.d.ts
|
|
121
107
|
/**
|
|
@@ -131,7 +117,6 @@ declare function isPackageInstalled(name: string, path?: string): Promise<boolea
|
|
|
131
117
|
* await setName("my-new-project-name");
|
|
132
118
|
*/
|
|
133
119
|
declare function setName(name: string, path?: string): Promise<void>;
|
|
134
|
-
|
|
135
120
|
//#endregion
|
|
136
121
|
export { emptyDir, formatTargetDir, getPackageManager, getPackageManagerExecutable, installDependencies, isEmpty, isPackageInstalled, setName };
|
|
137
122
|
//# sourceMappingURL=package-manager.d.cts.map
|
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { AgentName } from "package-manager-detector";
|
|
2
2
|
|
|
3
3
|
//#region src/package-manager/download-and-extract.d.ts
|
|
4
|
-
|
|
5
|
-
* Formats a directory path by removing trailing slashes and whitespace
|
|
6
|
-
*
|
|
7
|
-
* @param targetDir - The directory path to format
|
|
8
|
-
* @returns The formatted directory path
|
|
9
|
-
* @example
|
|
10
|
-
* import { formatTargetDir } from "@settlemint/sdk-utils/package-manager";
|
|
11
|
-
*
|
|
12
|
-
* const formatted = formatTargetDir("/path/to/dir/ "); // "/path/to/dir"
|
|
13
|
-
*/
|
|
4
|
+
|
|
14
5
|
/**
|
|
15
6
|
* Formats a directory path by removing trailing slashes and whitespace
|
|
16
7
|
*
|
|
@@ -45,7 +36,6 @@ declare function isEmpty(path: string): Promise<boolean>;
|
|
|
45
36
|
* await emptyDir("/path/to/dir"); // Removes all contents except .git
|
|
46
37
|
*/
|
|
47
38
|
declare function emptyDir(dir: string): Promise<void>;
|
|
48
|
-
|
|
49
39
|
//#endregion
|
|
50
40
|
//#region src/package-manager/get-package-manager.d.ts
|
|
51
41
|
/**
|
|
@@ -60,7 +50,6 @@ declare function emptyDir(dir: string): Promise<void>;
|
|
|
60
50
|
* console.log(`Using ${packageManager}`);
|
|
61
51
|
*/
|
|
62
52
|
declare function getPackageManager(targetDir?: string): Promise<AgentName>;
|
|
63
|
-
|
|
64
53
|
//#endregion
|
|
65
54
|
//#region src/package-manager/get-package-manager-executable.d.ts
|
|
66
55
|
/**
|
|
@@ -78,7 +67,6 @@ declare function getPackageManagerExecutable(targetDir?: string): Promise<{
|
|
|
78
67
|
command: string;
|
|
79
68
|
args: string[];
|
|
80
69
|
}>;
|
|
81
|
-
|
|
82
70
|
//#endregion
|
|
83
71
|
//#region src/package-manager/install-dependencies.d.ts
|
|
84
72
|
/**
|
|
@@ -98,7 +86,6 @@ declare function getPackageManagerExecutable(targetDir?: string): Promise<{
|
|
|
98
86
|
* await installDependencies(["express", "cors"]);
|
|
99
87
|
*/
|
|
100
88
|
declare function installDependencies(pkgs: string | string[], cwd?: string): Promise<void>;
|
|
101
|
-
|
|
102
89
|
//#endregion
|
|
103
90
|
//#region src/package-manager/is-package-installed.d.ts
|
|
104
91
|
/**
|
|
@@ -115,7 +102,6 @@ declare function installDependencies(pkgs: string | string[], cwd?: string): Pro
|
|
|
115
102
|
* console.log(`@settlemint/sdk-utils is installed: ${isInstalled}`);
|
|
116
103
|
*/
|
|
117
104
|
declare function isPackageInstalled(name: string, path?: string): Promise<boolean>;
|
|
118
|
-
|
|
119
105
|
//#endregion
|
|
120
106
|
//#region src/package-manager/set-name.d.ts
|
|
121
107
|
/**
|
|
@@ -131,7 +117,6 @@ declare function isPackageInstalled(name: string, path?: string): Promise<boolea
|
|
|
131
117
|
* await setName("my-new-project-name");
|
|
132
118
|
*/
|
|
133
119
|
declare function setName(name: string, path?: string): Promise<void>;
|
|
134
|
-
|
|
135
120
|
//#endregion
|
|
136
121
|
export { emptyDir, formatTargetDir, getPackageManager, getPackageManagerExecutable, installDependencies, isEmpty, isPackageInstalled, setName };
|
|
137
122
|
//# sourceMappingURL=package-manager.d.ts.map
|
package/dist/retry.d.cts
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* const result = await retryWhenFailed(() => readFile("/path/to/file.txt"), 3, 1_000);
|
|
14
14
|
*/
|
|
15
15
|
declare function retryWhenFailed<T>(fn: () => Promise<T>, maxRetries?: number, initialSleepTime?: number, stopOnError?: (error: Error) => boolean): Promise<T>;
|
|
16
|
-
|
|
17
16
|
//#endregion
|
|
18
17
|
export { retryWhenFailed };
|
|
19
18
|
//# sourceMappingURL=retry.d.cts.map
|
package/dist/retry.d.ts
CHANGED
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* const result = await retryWhenFailed(() => readFile("/path/to/file.txt"), 3, 1_000);
|
|
14
14
|
*/
|
|
15
15
|
declare function retryWhenFailed<T>(fn: () => Promise<T>, maxRetries?: number, initialSleepTime?: number, stopOnError?: (error: Error) => boolean): Promise<T>;
|
|
16
|
-
|
|
17
16
|
//#endregion
|
|
18
17
|
export { retryWhenFailed };
|
|
19
18
|
//# sourceMappingURL=retry.d.ts.map
|
package/dist/runtime.d.cts
CHANGED
|
@@ -29,7 +29,6 @@ declare const runsInBrowser: boolean;
|
|
|
29
29
|
* Boolean indicating if code is currently running in a server environment
|
|
30
30
|
*/
|
|
31
31
|
declare const runsOnServer: boolean;
|
|
32
|
-
|
|
33
32
|
//#endregion
|
|
34
33
|
export { ensureBrowser, ensureServer, runsInBrowser, runsOnServer };
|
|
35
34
|
//# sourceMappingURL=runtime.d.cts.map
|
package/dist/runtime.d.ts
CHANGED
|
@@ -29,7 +29,6 @@ declare const runsInBrowser: boolean;
|
|
|
29
29
|
* Boolean indicating if code is currently running in a server environment
|
|
30
30
|
*/
|
|
31
31
|
declare const runsOnServer: boolean;
|
|
32
|
-
|
|
33
32
|
//#endregion
|
|
34
33
|
export { ensureBrowser, ensureServer, runsInBrowser, runsOnServer };
|
|
35
34
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/string.d.cts
CHANGED
|
@@ -52,7 +52,6 @@ declare function replaceUnderscoresAndHyphensWithSpaces(s: string): string;
|
|
|
52
52
|
* // Returns: "Hello, wor..."
|
|
53
53
|
*/
|
|
54
54
|
declare function truncate(value: string, maxLength: number): string;
|
|
55
|
-
|
|
56
55
|
//#endregion
|
|
57
56
|
export { camelCaseToWords, capitalizeFirstLetter, replaceUnderscoresAndHyphensWithSpaces, truncate };
|
|
58
57
|
//# sourceMappingURL=string.d.cts.map
|
package/dist/string.d.ts
CHANGED
|
@@ -52,7 +52,6 @@ declare function replaceUnderscoresAndHyphensWithSpaces(s: string): string;
|
|
|
52
52
|
* // Returns: "Hello, wor..."
|
|
53
53
|
*/
|
|
54
54
|
declare function truncate(value: string, maxLength: number): string;
|
|
55
|
-
|
|
56
55
|
//#endregion
|
|
57
56
|
export { camelCaseToWords, capitalizeFirstLetter, replaceUnderscoresAndHyphensWithSpaces, truncate };
|
|
58
57
|
//# sourceMappingURL=string.d.ts.map
|
package/dist/terminal.d.cts
CHANGED
|
@@ -2,16 +2,7 @@ import { SpawnOptionsWithoutStdio } from "node:child_process";
|
|
|
2
2
|
import { Spinner } from "yocto-spinner";
|
|
3
3
|
|
|
4
4
|
//#region src/terminal/ascii.d.ts
|
|
5
|
-
|
|
6
|
-
* Prints the SettleMint ASCII art logo to the console in magenta color.
|
|
7
|
-
* Used for CLI branding and visual identification.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* import { ascii } from "@settlemint/sdk-utils/terminal";
|
|
11
|
-
*
|
|
12
|
-
* // Prints the SettleMint logo
|
|
13
|
-
* ascii();
|
|
14
|
-
*/
|
|
5
|
+
|
|
15
6
|
/**
|
|
16
7
|
* Prints the SettleMint ASCII art logo to the console in magenta color.
|
|
17
8
|
* Used for CLI branding and visual identification.
|
|
@@ -23,7 +14,6 @@ import { Spinner } from "yocto-spinner";
|
|
|
23
14
|
* ascii();
|
|
24
15
|
*/
|
|
25
16
|
declare const ascii: () => void;
|
|
26
|
-
|
|
27
17
|
//#endregion
|
|
28
18
|
//#region src/terminal/cancel.d.ts
|
|
29
19
|
/**
|
|
@@ -45,7 +35,6 @@ declare class CancelError extends Error {}
|
|
|
45
35
|
* cancel("An error occurred");
|
|
46
36
|
*/
|
|
47
37
|
declare const cancel: (msg: string) => never;
|
|
48
|
-
|
|
49
38
|
//#endregion
|
|
50
39
|
//#region src/terminal/execute-command.d.ts
|
|
51
40
|
/**
|
|
@@ -90,7 +79,6 @@ declare class CommandError extends Error {
|
|
|
90
79
|
* await executeCommand("npm", ["install"], { silent: true });
|
|
91
80
|
*/
|
|
92
81
|
declare function executeCommand(command: string, args: string[], options?: ExecuteCommandOptions): Promise<string[]>;
|
|
93
|
-
|
|
94
82
|
//#endregion
|
|
95
83
|
//#region src/terminal/intro.d.ts
|
|
96
84
|
/**
|
|
@@ -105,7 +93,6 @@ declare function executeCommand(command: string, args: string[], options?: Execu
|
|
|
105
93
|
* intro("Starting deployment...");
|
|
106
94
|
*/
|
|
107
95
|
declare const intro: (msg: string) => void;
|
|
108
|
-
|
|
109
96
|
//#endregion
|
|
110
97
|
//#region src/terminal/list.d.ts
|
|
111
98
|
/**
|
|
@@ -129,7 +116,6 @@ declare const intro: (msg: string) => void;
|
|
|
129
116
|
* ]);
|
|
130
117
|
*/
|
|
131
118
|
declare function list(title: string, items: Array<string | string[]>): void;
|
|
132
|
-
|
|
133
119
|
//#endregion
|
|
134
120
|
//#region src/terminal/note.d.ts
|
|
135
121
|
/**
|
|
@@ -149,7 +135,6 @@ declare function list(title: string, items: Array<string | string[]>): void;
|
|
|
149
135
|
* note("Low disk space remaining", "warn");
|
|
150
136
|
*/
|
|
151
137
|
declare const note: (message: string, level?: "info" | "warn") => void;
|
|
152
|
-
|
|
153
138
|
//#endregion
|
|
154
139
|
//#region src/terminal/outro.d.ts
|
|
155
140
|
/**
|
|
@@ -164,7 +149,6 @@ declare const note: (message: string, level?: "info" | "warn") => void;
|
|
|
164
149
|
* outro("Deployment completed successfully!");
|
|
165
150
|
*/
|
|
166
151
|
declare const outro: (msg: string) => void;
|
|
167
|
-
|
|
168
152
|
//#endregion
|
|
169
153
|
//#region src/terminal/spinner.d.ts
|
|
170
154
|
/**
|
|
@@ -208,7 +192,6 @@ interface SpinnerOptions<R> {
|
|
|
208
192
|
* });
|
|
209
193
|
*/
|
|
210
194
|
declare const spinner: <R>(options: SpinnerOptions<R>) => Promise<R>;
|
|
211
|
-
|
|
212
195
|
//#endregion
|
|
213
196
|
//#region src/terminal/table.d.ts
|
|
214
197
|
/**
|
|
@@ -227,7 +210,6 @@ declare const spinner: <R>(options: SpinnerOptions<R>) => Promise<R>;
|
|
|
227
210
|
* table("My Table", data);
|
|
228
211
|
*/
|
|
229
212
|
declare function table(title: string, data: unknown[]): void;
|
|
230
|
-
|
|
231
213
|
//#endregion
|
|
232
214
|
//#region src/logging/mask-tokens.d.ts
|
|
233
215
|
/**
|
|
@@ -243,7 +225,6 @@ declare function table(title: string, data: unknown[]): void;
|
|
|
243
225
|
* const masked = maskTokens("Token: sm_pat_****"); // "Token: ***"
|
|
244
226
|
*/
|
|
245
227
|
declare const maskTokens: (output: string) => string;
|
|
246
|
-
|
|
247
228
|
//#endregion
|
|
248
229
|
export { CancelError, CommandError, ExecuteCommandOptions, SpinnerError, SpinnerOptions, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table };
|
|
249
230
|
//# sourceMappingURL=terminal.d.cts.map
|
package/dist/terminal.d.ts
CHANGED
|
@@ -2,16 +2,7 @@ import { SpawnOptionsWithoutStdio } from "node:child_process";
|
|
|
2
2
|
import { Spinner } from "yocto-spinner";
|
|
3
3
|
|
|
4
4
|
//#region src/terminal/ascii.d.ts
|
|
5
|
-
|
|
6
|
-
* Prints the SettleMint ASCII art logo to the console in magenta color.
|
|
7
|
-
* Used for CLI branding and visual identification.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* import { ascii } from "@settlemint/sdk-utils/terminal";
|
|
11
|
-
*
|
|
12
|
-
* // Prints the SettleMint logo
|
|
13
|
-
* ascii();
|
|
14
|
-
*/
|
|
5
|
+
|
|
15
6
|
/**
|
|
16
7
|
* Prints the SettleMint ASCII art logo to the console in magenta color.
|
|
17
8
|
* Used for CLI branding and visual identification.
|
|
@@ -23,7 +14,6 @@ import { Spinner } from "yocto-spinner";
|
|
|
23
14
|
* ascii();
|
|
24
15
|
*/
|
|
25
16
|
declare const ascii: () => void;
|
|
26
|
-
|
|
27
17
|
//#endregion
|
|
28
18
|
//#region src/terminal/cancel.d.ts
|
|
29
19
|
/**
|
|
@@ -45,7 +35,6 @@ declare class CancelError extends Error {}
|
|
|
45
35
|
* cancel("An error occurred");
|
|
46
36
|
*/
|
|
47
37
|
declare const cancel: (msg: string) => never;
|
|
48
|
-
|
|
49
38
|
//#endregion
|
|
50
39
|
//#region src/terminal/execute-command.d.ts
|
|
51
40
|
/**
|
|
@@ -90,7 +79,6 @@ declare class CommandError extends Error {
|
|
|
90
79
|
* await executeCommand("npm", ["install"], { silent: true });
|
|
91
80
|
*/
|
|
92
81
|
declare function executeCommand(command: string, args: string[], options?: ExecuteCommandOptions): Promise<string[]>;
|
|
93
|
-
|
|
94
82
|
//#endregion
|
|
95
83
|
//#region src/terminal/intro.d.ts
|
|
96
84
|
/**
|
|
@@ -105,7 +93,6 @@ declare function executeCommand(command: string, args: string[], options?: Execu
|
|
|
105
93
|
* intro("Starting deployment...");
|
|
106
94
|
*/
|
|
107
95
|
declare const intro: (msg: string) => void;
|
|
108
|
-
|
|
109
96
|
//#endregion
|
|
110
97
|
//#region src/terminal/list.d.ts
|
|
111
98
|
/**
|
|
@@ -129,7 +116,6 @@ declare const intro: (msg: string) => void;
|
|
|
129
116
|
* ]);
|
|
130
117
|
*/
|
|
131
118
|
declare function list(title: string, items: Array<string | string[]>): void;
|
|
132
|
-
|
|
133
119
|
//#endregion
|
|
134
120
|
//#region src/terminal/note.d.ts
|
|
135
121
|
/**
|
|
@@ -149,7 +135,6 @@ declare function list(title: string, items: Array<string | string[]>): void;
|
|
|
149
135
|
* note("Low disk space remaining", "warn");
|
|
150
136
|
*/
|
|
151
137
|
declare const note: (message: string, level?: "info" | "warn") => void;
|
|
152
|
-
|
|
153
138
|
//#endregion
|
|
154
139
|
//#region src/terminal/outro.d.ts
|
|
155
140
|
/**
|
|
@@ -164,7 +149,6 @@ declare const note: (message: string, level?: "info" | "warn") => void;
|
|
|
164
149
|
* outro("Deployment completed successfully!");
|
|
165
150
|
*/
|
|
166
151
|
declare const outro: (msg: string) => void;
|
|
167
|
-
|
|
168
152
|
//#endregion
|
|
169
153
|
//#region src/terminal/spinner.d.ts
|
|
170
154
|
/**
|
|
@@ -208,7 +192,6 @@ interface SpinnerOptions<R> {
|
|
|
208
192
|
* });
|
|
209
193
|
*/
|
|
210
194
|
declare const spinner: <R>(options: SpinnerOptions<R>) => Promise<R>;
|
|
211
|
-
|
|
212
195
|
//#endregion
|
|
213
196
|
//#region src/terminal/table.d.ts
|
|
214
197
|
/**
|
|
@@ -227,7 +210,6 @@ declare const spinner: <R>(options: SpinnerOptions<R>) => Promise<R>;
|
|
|
227
210
|
* table("My Table", data);
|
|
228
211
|
*/
|
|
229
212
|
declare function table(title: string, data: unknown[]): void;
|
|
230
|
-
|
|
231
213
|
//#endregion
|
|
232
214
|
//#region src/logging/mask-tokens.d.ts
|
|
233
215
|
/**
|
|
@@ -243,7 +225,6 @@ declare function table(title: string, data: unknown[]): void;
|
|
|
243
225
|
* const masked = maskTokens("Token: sm_pat_****"); // "Token: ***"
|
|
244
226
|
*/
|
|
245
227
|
declare const maskTokens: (output: string) => string;
|
|
246
|
-
|
|
247
228
|
//#endregion
|
|
248
229
|
export { CancelError, CommandError, ExecuteCommandOptions, SpinnerError, SpinnerOptions, ascii, cancel, executeCommand, intro, list, maskTokens, note, outro, spinner, table };
|
|
249
230
|
//# sourceMappingURL=terminal.d.ts.map
|
package/dist/url.d.cts
CHANGED