@storm-software/config-tools 1.190.119 → 1.190.121
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 +1 -1
- package/bin/config.cjs +1213 -1558
- package/bin/config.mjs +1271 -0
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/config-file/get-config-file.cjs +67 -28
- package/dist/config-file/get-config-file.d.cts +5 -5
- package/dist/config-file/{get-config-file.d.ts → get-config-file.d.mts} +7 -5
- package/dist/config-file/get-config-file.mjs +66 -0
- package/dist/config-file/index.cjs +4 -29
- package/dist/config-file/index.d.cts +2 -3
- package/dist/config-file/index.d.mts +4 -0
- package/dist/config-file/index.mjs +5 -0
- package/dist/create-storm-config.cjs +115 -34
- package/dist/create-storm-config.d.cts +5 -5
- package/dist/{create-storm-config.d.ts → create-storm-config.d.mts} +7 -5
- package/dist/create-storm-config.mjs +113 -0
- package/dist/env/get-env.cjs +202 -11
- package/dist/env/get-env.d.cts +5 -5
- package/dist/env/{get-env.d.ts → get-env.d.mts} +7 -5
- package/dist/env/get-env.mjs +203 -0
- package/dist/env/index.cjs +7 -18
- package/dist/env/index.d.cts +3 -4
- package/dist/env/index.d.mts +5 -0
- package/dist/env/index.mjs +6 -0
- package/dist/env/set-env.cjs +230 -11
- package/dist/env/set-env.d.cts +8 -8
- package/dist/env/{set-env.d.ts → set-env.d.mts} +10 -8
- package/dist/env/set-env.mjs +231 -0
- package/dist/get-config.cjs +46 -34
- package/dist/get-config.d.cts +18 -18
- package/dist/{get-config.d.ts → get-config.d.mts} +20 -18
- package/dist/get-config.mjs +46 -0
- package/dist/index.cjs +98 -201
- package/dist/index.d.cts +27 -28
- package/dist/index.d.mts +29 -0
- package/dist/index.mjs +26 -0
- package/dist/logger/chalk.cjs +43 -6
- package/dist/logger/chalk.d.cts +18 -17
- package/dist/logger/chalk.d.mts +37 -0
- package/dist/logger/chalk.mjs +43 -0
- package/dist/logger/console-icons.cjs +18 -8
- package/dist/logger/console-icons.d.cts +5 -8
- package/dist/logger/console-icons.d.mts +7 -0
- package/dist/logger/console-icons.mjs +20 -0
- package/dist/logger/console.cjs +195 -37
- package/dist/logger/console.d.cts +25 -25
- package/dist/logger/{console.d.ts → console.d.mts} +27 -25
- package/dist/logger/console.mjs +185 -0
- package/dist/logger/create-logger.cjs +34 -14
- package/dist/logger/create-logger.d.cts +5 -6
- package/dist/logger/{create-logger.d.ts → create-logger.d.mts} +7 -6
- package/dist/logger/create-logger.mjs +34 -0
- package/dist/logger/format-timestamp.cjs +14 -6
- package/dist/logger/format-timestamp.d.cts +3 -2
- package/dist/logger/{format-timestamp.d.ts → format-timestamp.d.mts} +5 -2
- package/dist/logger/format-timestamp.mjs +16 -0
- package/dist/logger/get-log-level.cjs +54 -11
- package/dist/logger/get-log-level.d.cts +4 -5
- package/dist/logger/{get-log-level.d.ts → get-log-level.d.mts} +6 -5
- package/dist/logger/get-log-level.mjs +54 -0
- package/dist/logger/index.cjs +29 -61
- package/dist/logger/index.d.cts +8 -10
- package/dist/logger/index.d.mts +10 -0
- package/dist/logger/index.mjs +11 -0
- package/dist/logger/is-unicode-supported.cjs +8 -6
- package/dist/logger/is-unicode-supported.d.cts +3 -2
- package/dist/logger/is-unicode-supported.d.mts +6 -0
- package/dist/logger/is-unicode-supported.mjs +10 -0
- package/dist/types.cjs +29 -8
- package/dist/types.d.cts +39 -41
- package/dist/types.d.mts +53 -0
- package/dist/types.mjs +30 -0
- package/dist/utilities/apply-workspace-tokens.cjs +37 -13
- package/dist/utilities/apply-workspace-tokens.d.cts +4 -5
- package/dist/utilities/{apply-workspace-tokens.d.ts → apply-workspace-tokens.d.mts} +6 -5
- package/dist/utilities/apply-workspace-tokens.mjs +37 -0
- package/dist/utilities/colors.cjs +98 -12
- package/dist/utilities/colors.d.cts +4 -4
- package/dist/utilities/{colors.d.ts → colors.d.mts} +6 -4
- package/dist/utilities/colors.mjs +97 -0
- package/dist/utilities/correct-paths.cjs +201 -32
- package/dist/utilities/correct-paths.d.cts +4 -4
- package/dist/utilities/{correct-paths.d.ts → correct-paths.d.mts} +6 -4
- package/dist/utilities/correct-paths.mjs +190 -0
- package/dist/utilities/file-path-utils.cjs +48 -11
- package/dist/utilities/file-path-utils.d.cts +15 -14
- package/dist/utilities/{file-path-utils.d.ts → file-path-utils.d.mts} +17 -14
- package/dist/utilities/file-path-utils.mjs +48 -0
- package/dist/utilities/find-up.cjs +17 -6
- package/dist/utilities/find-up.d.cts +3 -2
- package/dist/utilities/{find-up.d.ts → find-up.d.mts} +5 -2
- package/dist/utilities/find-up.mjs +19 -0
- package/dist/utilities/find-workspace-root.cjs +72 -10
- package/dist/utilities/find-workspace-root.d.cts +3 -2
- package/dist/utilities/{find-workspace-root.d.ts → find-workspace-root.d.mts} +5 -2
- package/dist/utilities/find-workspace-root.mjs +73 -0
- package/dist/utilities/get-default-config.cjs +73 -11
- package/dist/utilities/get-default-config.d.cts +4 -4
- package/dist/utilities/{get-default-config.d.ts → get-default-config.d.mts} +6 -4
- package/dist/utilities/get-default-config.mjs +74 -0
- package/dist/utilities/index.cjs +49 -109
- package/dist/utilities/index.d.cts +10 -14
- package/dist/utilities/index.d.mts +12 -0
- package/dist/utilities/index.mjs +13 -0
- package/dist/utilities/process-handler.cjs +38 -18
- package/dist/utilities/process-handler.d.cts +4 -4
- package/dist/utilities/process-handler.d.mts +9 -0
- package/dist/utilities/process-handler.mjs +38 -0
- package/dist/utilities/run.cjs +64 -10
- package/dist/utilities/run.d.cts +5 -6
- package/dist/utilities/{run.d.ts → run.d.mts} +7 -6
- package/dist/utilities/run.mjs +64 -0
- package/dist/utilities/toml.cjs +37 -24
- package/dist/utilities/toml.d.cts +148 -147
- package/dist/utilities/toml.d.mts +192 -0
- package/dist/utilities/toml.mjs +33 -0
- package/package.json +106 -158
- package/bin/config.js +0 -1616
- package/dist/chunk-24B36RDB.cjs +0 -81
- package/dist/chunk-27N3QEX5.js +0 -40
- package/dist/chunk-2AVLCXLT.js +0 -0
- package/dist/chunk-2RLMTBVZ.js +0 -233
- package/dist/chunk-2WBD2G3E.cjs +0 -38
- package/dist/chunk-3COHMHPU.cjs +0 -1
- package/dist/chunk-4Q45WJYQ.js +0 -165
- package/dist/chunk-5C7PIENF.js +0 -92
- package/dist/chunk-5J2SS4QU.js +0 -83
- package/dist/chunk-65SWKEHV.cjs +0 -1
- package/dist/chunk-6Y623TCS.cjs +0 -40
- package/dist/chunk-7PV6L7I7.cjs +0 -1
- package/dist/chunk-7QBTVNMR.cjs +0 -30
- package/dist/chunk-BDATZ3UB.cjs +0 -233
- package/dist/chunk-BZRTSWH4.cjs +0 -395
- package/dist/chunk-D3FRXXDE.js +0 -947
- package/dist/chunk-DTGT4OI3.cjs +0 -14
- package/dist/chunk-EC2KPWRG.cjs +0 -24
- package/dist/chunk-EENQN6N2.js +0 -40
- package/dist/chunk-ENI4UUSK.cjs +0 -35
- package/dist/chunk-FJNXECWU.js +0 -395
- package/dist/chunk-FMDVBSP6.cjs +0 -83
- package/dist/chunk-G2MK47WL.js +0 -14
- package/dist/chunk-HFS7WJVW.js +0 -81
- package/dist/chunk-HVVJHTFS.js +0 -36
- package/dist/chunk-IWD6YQKX.cjs +0 -1
- package/dist/chunk-IWQRXQ4N.cjs +0 -84
- package/dist/chunk-JK4TT5IV.js +0 -35
- package/dist/chunk-JWLDCEBZ.cjs +0 -70
- package/dist/chunk-JZAYHDV3.js +0 -8
- package/dist/chunk-KSMN3HSC.js +0 -38
- package/dist/chunk-L6UNTUC4.js +0 -0
- package/dist/chunk-LOY6ICHZ.cjs +0 -36
- package/dist/chunk-MBG2FTBL.cjs +0 -47
- package/dist/chunk-MQG74XF7.js +0 -102
- package/dist/chunk-MSAQEGBK.cjs +0 -92
- package/dist/chunk-NJFLUTGH.cjs +0 -25
- package/dist/chunk-PCYB64MB.cjs +0 -40
- package/dist/chunk-RALMUN5C.js +0 -30
- package/dist/chunk-RRKB32OH.js +0 -0
- package/dist/chunk-RUKM6FCF.js +0 -25
- package/dist/chunk-SIW7AXUG.js +0 -56
- package/dist/chunk-SLICWTO2.cjs +0 -165
- package/dist/chunk-SO3FWVXC.js +0 -84
- package/dist/chunk-SXPH7ILL.js +0 -70
- package/dist/chunk-T7YISGRS.cjs +0 -102
- package/dist/chunk-TZZRLM5J.cjs +0 -947
- package/dist/chunk-UJ77IBHD.cjs +0 -233
- package/dist/chunk-UKGRDKIH.js +0 -0
- package/dist/chunk-V3GMJ4TX.js +0 -233
- package/dist/chunk-WQJYIPSL.cjs +0 -8
- package/dist/chunk-YBVOKYAM.cjs +0 -56
- package/dist/chunk-YX4736HU.js +0 -47
- package/dist/chunk-ZFNAUMQS.js +0 -24
- package/dist/config-file/get-config-file.js +0 -28
- package/dist/config-file/index.d.ts +0 -3
- package/dist/config-file/index.js +0 -29
- package/dist/create-storm-config.js +0 -35
- package/dist/env/get-env.js +0 -11
- package/dist/env/index.d.ts +0 -4
- package/dist/env/index.js +0 -18
- package/dist/env/set-env.js +0 -11
- package/dist/get-config.js +0 -34
- package/dist/index.d.ts +0 -28
- package/dist/index.js +0 -201
- package/dist/logger/chalk.d.ts +0 -34
- package/dist/logger/chalk.js +0 -6
- package/dist/logger/console-icons.d.ts +0 -8
- package/dist/logger/console-icons.js +0 -8
- package/dist/logger/console.js +0 -37
- package/dist/logger/create-logger.js +0 -14
- package/dist/logger/format-timestamp.js +0 -6
- package/dist/logger/get-log-level.js +0 -11
- package/dist/logger/index.d.ts +0 -10
- package/dist/logger/index.js +0 -61
- package/dist/logger/is-unicode-supported.d.ts +0 -3
- package/dist/logger/is-unicode-supported.js +0 -6
- package/dist/types.d.ts +0 -53
- package/dist/types.js +0 -8
- package/dist/utilities/apply-workspace-tokens.js +0 -13
- package/dist/utilities/colors.js +0 -12
- package/dist/utilities/correct-paths.js +0 -32
- package/dist/utilities/file-path-utils.js +0 -11
- package/dist/utilities/find-up.js +0 -6
- package/dist/utilities/find-workspace-root.js +0 -10
- package/dist/utilities/get-default-config.js +0 -11
- package/dist/utilities/index.d.ts +0 -14
- package/dist/utilities/index.js +0 -109
- package/dist/utilities/process-handler.d.ts +0 -7
- package/dist/utilities/process-handler.js +0 -18
- package/dist/utilities/run.js +0 -10
- package/dist/utilities/toml.d.ts +0 -189
- package/dist/utilities/toml.js +0 -24
|
@@ -1,189 +1,190 @@
|
|
|
1
|
+
//#region src/utilities/toml.d.ts
|
|
1
2
|
interface CargoToml {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
workspace?: {
|
|
4
|
+
members: string[];
|
|
5
|
+
};
|
|
6
|
+
package: any;
|
|
7
|
+
dependencies?: Record<string, string | {
|
|
8
|
+
version: string;
|
|
9
|
+
features?: string[];
|
|
10
|
+
optional?: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
"dev-dependencies"?: Record<string, string | {
|
|
13
|
+
version: string;
|
|
14
|
+
features: string[];
|
|
15
|
+
}>;
|
|
16
|
+
[key: string]: any;
|
|
16
17
|
}
|
|
17
18
|
interface CargoMetadata {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
packages: Package[];
|
|
20
|
+
workspace_members: string[];
|
|
21
|
+
resolve: Resolve;
|
|
22
|
+
target_directory: string;
|
|
23
|
+
version: number;
|
|
24
|
+
workspace_root: string;
|
|
25
|
+
metadata: Metadata2;
|
|
25
26
|
}
|
|
26
27
|
interface Package {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
28
|
+
name: string;
|
|
29
|
+
version: string;
|
|
30
|
+
id: string;
|
|
31
|
+
license: string;
|
|
32
|
+
license_file: string;
|
|
33
|
+
description: string;
|
|
34
|
+
source: any;
|
|
35
|
+
dependencies: Dependency[];
|
|
36
|
+
targets: Target[];
|
|
37
|
+
features: Features;
|
|
38
|
+
manifest_path: string;
|
|
39
|
+
metadata: Metadata;
|
|
40
|
+
/**
|
|
41
|
+
* From the docs:
|
|
42
|
+
* "List of registries to which this package may be published.
|
|
43
|
+
* Publishing is unrestricted if null, and forbidden if an empty array."
|
|
44
|
+
*
|
|
45
|
+
* Additional observation:
|
|
46
|
+
* false can be used by the end user but it will be converted to an empty
|
|
47
|
+
* array in the cargo metadata output.
|
|
48
|
+
*/
|
|
49
|
+
publish?: string[] | boolean | null;
|
|
50
|
+
authors: string[];
|
|
51
|
+
categories: string[];
|
|
52
|
+
default_run: any;
|
|
53
|
+
rust_version: string;
|
|
54
|
+
keywords: string[];
|
|
55
|
+
readme: string;
|
|
56
|
+
repository: string;
|
|
57
|
+
homepage: string;
|
|
58
|
+
documentation: string;
|
|
59
|
+
edition: string;
|
|
60
|
+
links: any;
|
|
60
61
|
}
|
|
61
62
|
interface Dependency {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
name: string;
|
|
64
|
+
source: string;
|
|
65
|
+
req: string;
|
|
66
|
+
kind: any;
|
|
67
|
+
rename: any;
|
|
68
|
+
optional: boolean;
|
|
69
|
+
uses_default_features: boolean;
|
|
70
|
+
features: any[];
|
|
71
|
+
target: string;
|
|
72
|
+
path: string;
|
|
73
|
+
registry: any;
|
|
74
|
+
workspace: boolean;
|
|
74
75
|
}
|
|
75
76
|
interface Target {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
kind: string[];
|
|
78
|
+
crate_types: string[];
|
|
79
|
+
name: string;
|
|
80
|
+
src_path: string;
|
|
81
|
+
edition: string;
|
|
82
|
+
"required-features": string[];
|
|
83
|
+
doc: boolean;
|
|
84
|
+
doctest: boolean;
|
|
85
|
+
test: boolean;
|
|
85
86
|
}
|
|
86
87
|
interface Features {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
default: string[];
|
|
89
|
+
feat1: any[];
|
|
90
|
+
feat2: any[];
|
|
90
91
|
}
|
|
91
92
|
interface Metadata {
|
|
92
|
-
|
|
93
|
+
docs: Docs;
|
|
93
94
|
}
|
|
94
95
|
interface Docs {
|
|
95
|
-
|
|
96
|
+
rs: Rs;
|
|
96
97
|
}
|
|
97
98
|
interface Rs {
|
|
98
|
-
|
|
99
|
+
"all-features": boolean;
|
|
99
100
|
}
|
|
100
101
|
interface Resolve {
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
nodes: Node[];
|
|
103
|
+
root: string;
|
|
103
104
|
}
|
|
104
105
|
interface Node {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
id: string;
|
|
107
|
+
dependencies: string[];
|
|
108
|
+
deps: Dep[];
|
|
109
|
+
features: string[];
|
|
109
110
|
}
|
|
110
111
|
interface Dep {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
name: string;
|
|
113
|
+
pkg: string;
|
|
114
|
+
dep_kinds: DepKind[];
|
|
114
115
|
}
|
|
115
116
|
interface DepKind {
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
kind: any;
|
|
118
|
+
target: string;
|
|
118
119
|
}
|
|
119
120
|
interface Metadata2 {
|
|
120
|
-
|
|
121
|
+
docs: Docs2;
|
|
121
122
|
}
|
|
122
123
|
interface Docs2 {
|
|
123
|
-
|
|
124
|
+
rs: Rs2;
|
|
124
125
|
}
|
|
125
126
|
interface Rs2 {
|
|
126
|
-
|
|
127
|
+
"all-features": boolean;
|
|
127
128
|
}
|
|
128
129
|
/**
|
|
129
130
|
* Virtual file system tree.
|
|
130
131
|
*/
|
|
131
132
|
interface Tree {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Root of the workspace. All paths are relative to this.
|
|
135
|
+
*/
|
|
136
|
+
root: string;
|
|
137
|
+
/**
|
|
138
|
+
* Read the contents of a file.
|
|
139
|
+
* @param filePath A path to a file.
|
|
140
|
+
*/
|
|
141
|
+
read(filePath: string): Buffer | null;
|
|
142
|
+
/**
|
|
143
|
+
* Read the contents of a file as string.
|
|
144
|
+
* @param filePath A path to a file.
|
|
145
|
+
* @param encoding the encoding for the result
|
|
146
|
+
*/
|
|
147
|
+
read(filePath: string, encoding: BufferEncoding): string | null;
|
|
148
|
+
/**
|
|
149
|
+
* Update the contents of a file or create a new file.
|
|
150
|
+
*/
|
|
151
|
+
write(filePath: string, content: Buffer | string, options?: any): void;
|
|
152
|
+
/**
|
|
153
|
+
* Check if a file exists.
|
|
154
|
+
*/
|
|
155
|
+
exists(filePath: string): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Delete the file.
|
|
158
|
+
*/
|
|
159
|
+
delete(filePath: string): void;
|
|
160
|
+
/**
|
|
161
|
+
* Rename the file or the folder.
|
|
162
|
+
*/
|
|
163
|
+
rename(from: string, to: string): void;
|
|
164
|
+
/**
|
|
165
|
+
* Check if this is a file or not.
|
|
166
|
+
*/
|
|
167
|
+
isFile(filePath: string): boolean;
|
|
168
|
+
/**
|
|
169
|
+
* Returns the list of children of a folder.
|
|
170
|
+
*/
|
|
171
|
+
children(dirPath: string): string[];
|
|
172
|
+
/**
|
|
173
|
+
* Returns the list of currently recorded changes.
|
|
174
|
+
*/
|
|
175
|
+
listChanges(): any[];
|
|
176
|
+
/**
|
|
177
|
+
* Changes permissions of a file.
|
|
178
|
+
* @param filePath A path to a file.
|
|
179
|
+
* @param mode The permission to be granted on the file, given as a string (e.g `755`) or octal integer (e.g `0o755`).
|
|
180
|
+
* See https://nodejs.org/api/fs.html#fs_file_modes.
|
|
181
|
+
*/
|
|
182
|
+
changePermissions(filePath: string, mode: string): void;
|
|
182
183
|
}
|
|
183
184
|
declare function parseCargoTomlWithTree(tree: Tree, projectRoot: string, projectName: string): CargoToml;
|
|
184
185
|
declare function parseCargoToml(cargoString?: string): CargoToml;
|
|
185
186
|
declare function stringifyCargoToml(cargoToml: CargoToml): string;
|
|
186
187
|
declare function modifyCargoTable(toml: CargoToml, section: string, key: string, value: string | object | any[] | (() => any)): void;
|
|
187
188
|
declare function modifyCargoNestedTable(toml: CargoToml, section: string, key: string, value: object): void;
|
|
188
|
-
|
|
189
|
-
export {
|
|
189
|
+
//#endregion
|
|
190
|
+
export { CargoMetadata, CargoToml, Dep, DepKind, Dependency, Docs, Docs2, Features, Metadata, Metadata2, Node, Package, Resolve, Rs, Rs2, Target, Tree, modifyCargoNestedTable, modifyCargoTable, parseCargoToml, parseCargoTomlWithTree, stringifyCargoToml };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
//#region src/utilities/toml.d.ts
|
|
4
|
+
interface CargoToml {
|
|
5
|
+
workspace?: {
|
|
6
|
+
members: string[];
|
|
7
|
+
};
|
|
8
|
+
package: any;
|
|
9
|
+
dependencies?: Record<string, string | {
|
|
10
|
+
version: string;
|
|
11
|
+
features?: string[];
|
|
12
|
+
optional?: boolean;
|
|
13
|
+
}>;
|
|
14
|
+
"dev-dependencies"?: Record<string, string | {
|
|
15
|
+
version: string;
|
|
16
|
+
features: string[];
|
|
17
|
+
}>;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
interface CargoMetadata {
|
|
21
|
+
packages: Package[];
|
|
22
|
+
workspace_members: string[];
|
|
23
|
+
resolve: Resolve;
|
|
24
|
+
target_directory: string;
|
|
25
|
+
version: number;
|
|
26
|
+
workspace_root: string;
|
|
27
|
+
metadata: Metadata2;
|
|
28
|
+
}
|
|
29
|
+
interface Package {
|
|
30
|
+
name: string;
|
|
31
|
+
version: string;
|
|
32
|
+
id: string;
|
|
33
|
+
license: string;
|
|
34
|
+
license_file: string;
|
|
35
|
+
description: string;
|
|
36
|
+
source: any;
|
|
37
|
+
dependencies: Dependency[];
|
|
38
|
+
targets: Target[];
|
|
39
|
+
features: Features;
|
|
40
|
+
manifest_path: string;
|
|
41
|
+
metadata: Metadata;
|
|
42
|
+
/**
|
|
43
|
+
* From the docs:
|
|
44
|
+
* "List of registries to which this package may be published.
|
|
45
|
+
* Publishing is unrestricted if null, and forbidden if an empty array."
|
|
46
|
+
*
|
|
47
|
+
* Additional observation:
|
|
48
|
+
* false can be used by the end user but it will be converted to an empty
|
|
49
|
+
* array in the cargo metadata output.
|
|
50
|
+
*/
|
|
51
|
+
publish?: string[] | boolean | null;
|
|
52
|
+
authors: string[];
|
|
53
|
+
categories: string[];
|
|
54
|
+
default_run: any;
|
|
55
|
+
rust_version: string;
|
|
56
|
+
keywords: string[];
|
|
57
|
+
readme: string;
|
|
58
|
+
repository: string;
|
|
59
|
+
homepage: string;
|
|
60
|
+
documentation: string;
|
|
61
|
+
edition: string;
|
|
62
|
+
links: any;
|
|
63
|
+
}
|
|
64
|
+
interface Dependency {
|
|
65
|
+
name: string;
|
|
66
|
+
source: string;
|
|
67
|
+
req: string;
|
|
68
|
+
kind: any;
|
|
69
|
+
rename: any;
|
|
70
|
+
optional: boolean;
|
|
71
|
+
uses_default_features: boolean;
|
|
72
|
+
features: any[];
|
|
73
|
+
target: string;
|
|
74
|
+
path: string;
|
|
75
|
+
registry: any;
|
|
76
|
+
workspace: boolean;
|
|
77
|
+
}
|
|
78
|
+
interface Target {
|
|
79
|
+
kind: string[];
|
|
80
|
+
crate_types: string[];
|
|
81
|
+
name: string;
|
|
82
|
+
src_path: string;
|
|
83
|
+
edition: string;
|
|
84
|
+
"required-features": string[];
|
|
85
|
+
doc: boolean;
|
|
86
|
+
doctest: boolean;
|
|
87
|
+
test: boolean;
|
|
88
|
+
}
|
|
89
|
+
interface Features {
|
|
90
|
+
default: string[];
|
|
91
|
+
feat1: any[];
|
|
92
|
+
feat2: any[];
|
|
93
|
+
}
|
|
94
|
+
interface Metadata {
|
|
95
|
+
docs: Docs;
|
|
96
|
+
}
|
|
97
|
+
interface Docs {
|
|
98
|
+
rs: Rs;
|
|
99
|
+
}
|
|
100
|
+
interface Rs {
|
|
101
|
+
"all-features": boolean;
|
|
102
|
+
}
|
|
103
|
+
interface Resolve {
|
|
104
|
+
nodes: Node[];
|
|
105
|
+
root: string;
|
|
106
|
+
}
|
|
107
|
+
interface Node {
|
|
108
|
+
id: string;
|
|
109
|
+
dependencies: string[];
|
|
110
|
+
deps: Dep[];
|
|
111
|
+
features: string[];
|
|
112
|
+
}
|
|
113
|
+
interface Dep {
|
|
114
|
+
name: string;
|
|
115
|
+
pkg: string;
|
|
116
|
+
dep_kinds: DepKind[];
|
|
117
|
+
}
|
|
118
|
+
interface DepKind {
|
|
119
|
+
kind: any;
|
|
120
|
+
target: string;
|
|
121
|
+
}
|
|
122
|
+
interface Metadata2 {
|
|
123
|
+
docs: Docs2;
|
|
124
|
+
}
|
|
125
|
+
interface Docs2 {
|
|
126
|
+
rs: Rs2;
|
|
127
|
+
}
|
|
128
|
+
interface Rs2 {
|
|
129
|
+
"all-features": boolean;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Virtual file system tree.
|
|
133
|
+
*/
|
|
134
|
+
interface Tree {
|
|
135
|
+
/**
|
|
136
|
+
* Root of the workspace. All paths are relative to this.
|
|
137
|
+
*/
|
|
138
|
+
root: string;
|
|
139
|
+
/**
|
|
140
|
+
* Read the contents of a file.
|
|
141
|
+
* @param filePath A path to a file.
|
|
142
|
+
*/
|
|
143
|
+
read(filePath: string): Buffer | null;
|
|
144
|
+
/**
|
|
145
|
+
* Read the contents of a file as string.
|
|
146
|
+
* @param filePath A path to a file.
|
|
147
|
+
* @param encoding the encoding for the result
|
|
148
|
+
*/
|
|
149
|
+
read(filePath: string, encoding: BufferEncoding): string | null;
|
|
150
|
+
/**
|
|
151
|
+
* Update the contents of a file or create a new file.
|
|
152
|
+
*/
|
|
153
|
+
write(filePath: string, content: Buffer | string, options?: any): void;
|
|
154
|
+
/**
|
|
155
|
+
* Check if a file exists.
|
|
156
|
+
*/
|
|
157
|
+
exists(filePath: string): boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Delete the file.
|
|
160
|
+
*/
|
|
161
|
+
delete(filePath: string): void;
|
|
162
|
+
/**
|
|
163
|
+
* Rename the file or the folder.
|
|
164
|
+
*/
|
|
165
|
+
rename(from: string, to: string): void;
|
|
166
|
+
/**
|
|
167
|
+
* Check if this is a file or not.
|
|
168
|
+
*/
|
|
169
|
+
isFile(filePath: string): boolean;
|
|
170
|
+
/**
|
|
171
|
+
* Returns the list of children of a folder.
|
|
172
|
+
*/
|
|
173
|
+
children(dirPath: string): string[];
|
|
174
|
+
/**
|
|
175
|
+
* Returns the list of currently recorded changes.
|
|
176
|
+
*/
|
|
177
|
+
listChanges(): any[];
|
|
178
|
+
/**
|
|
179
|
+
* Changes permissions of a file.
|
|
180
|
+
* @param filePath A path to a file.
|
|
181
|
+
* @param mode The permission to be granted on the file, given as a string (e.g `755`) or octal integer (e.g `0o755`).
|
|
182
|
+
* See https://nodejs.org/api/fs.html#fs_file_modes.
|
|
183
|
+
*/
|
|
184
|
+
changePermissions(filePath: string, mode: string): void;
|
|
185
|
+
}
|
|
186
|
+
declare function parseCargoTomlWithTree(tree: Tree, projectRoot: string, projectName: string): CargoToml;
|
|
187
|
+
declare function parseCargoToml(cargoString?: string): CargoToml;
|
|
188
|
+
declare function stringifyCargoToml(cargoToml: CargoToml): string;
|
|
189
|
+
declare function modifyCargoTable(toml: CargoToml, section: string, key: string, value: string | object | any[] | (() => any)): void;
|
|
190
|
+
declare function modifyCargoNestedTable(toml: CargoToml, section: string, key: string, value: object): void;
|
|
191
|
+
//#endregion
|
|
192
|
+
export { CargoMetadata, CargoToml, Dep, DepKind, Dependency, Docs, Docs2, Features, Metadata, Metadata2, Node, Package, Resolve, Rs, Rs2, Target, Tree, modifyCargoNestedTable, modifyCargoTable, parseCargoToml, parseCargoTomlWithTree, stringifyCargoToml };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import "node:path";
|
|
2
|
+
import "node:url";
|
|
3
|
+
import.meta.url;
|
|
4
|
+
import { writeError } from "../logger/console.mjs";
|
|
5
|
+
import TOML from "@ltd/j-toml";
|
|
6
|
+
//#region src/utilities/toml.ts
|
|
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) throw new Error("Cargo.toml is empty");
|
|
17
|
+
return TOML.parse(cargoString, { x: { comment: true } });
|
|
18
|
+
}
|
|
19
|
+
function stringifyCargoToml(cargoToml) {
|
|
20
|
+
const tomlString = TOML.stringify(cargoToml, { newlineAround: "section" });
|
|
21
|
+
if (Array.isArray(tomlString)) return tomlString.join("\n");
|
|
22
|
+
return tomlString;
|
|
23
|
+
}
|
|
24
|
+
function modifyCargoTable(toml, section, key, value) {
|
|
25
|
+
toml[section] ??= TOML.Section({});
|
|
26
|
+
toml[section][key] = typeof value === "object" && !Array.isArray(value) ? TOML.inline(value) : typeof value === "function" ? value() : value;
|
|
27
|
+
}
|
|
28
|
+
function modifyCargoNestedTable(toml, section, key, value) {
|
|
29
|
+
toml[section] ??= {};
|
|
30
|
+
toml[section][key] = TOML.Section(value);
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { modifyCargoNestedTable, modifyCargoTable, parseCargoToml, parseCargoTomlWithTree, stringifyCargoToml };
|