@assethub/cli 0.1.4 → 0.1.5
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/index.js +31 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -14,26 +14,32 @@ const defaultPartExtractorName = 'V1.5';
|
|
|
14
14
|
const partExtractorOptions = [
|
|
15
15
|
{
|
|
16
16
|
publicName: 'Part Extractor V3',
|
|
17
|
+
apiValue: 'ah_part_extractor_v3',
|
|
17
18
|
aliases: ['part extractor v3', 'v3'],
|
|
18
19
|
},
|
|
19
20
|
{
|
|
20
21
|
publicName: 'V1',
|
|
22
|
+
apiValue: 'ah_part_extractor_v5',
|
|
21
23
|
aliases: ['v1', '1'],
|
|
22
24
|
},
|
|
23
25
|
{
|
|
24
26
|
publicName: 'V1.5 alpha',
|
|
27
|
+
apiValue: 'ah_part_extractor_v55',
|
|
25
28
|
aliases: ['v1.5 alpha', 'v1.5-alpha', '1.5 alpha', '1.5-alpha'],
|
|
26
29
|
},
|
|
27
30
|
{
|
|
28
31
|
publicName: 'V1.5',
|
|
32
|
+
apiValue: 'ah_part_extractor_v65',
|
|
29
33
|
aliases: ['v1.5', '1.5', 'latest', 'default'],
|
|
30
34
|
},
|
|
31
35
|
{
|
|
32
36
|
publicName: 'V2.0 alpha',
|
|
37
|
+
apiValue: 'ah_part_extractor_v20_alpha',
|
|
33
38
|
aliases: ['v2.0 alpha', 'v2 alpha', 'v2.0-alpha', 'v2-alpha', '2.0 alpha'],
|
|
34
39
|
},
|
|
35
40
|
{
|
|
36
41
|
publicName: 'V2.1 alpha',
|
|
42
|
+
apiValue: 'ah_part_extractor_v21_alpha',
|
|
37
43
|
aliases: ['v2.1 alpha', 'v2.1-alpha', '2.1 alpha'],
|
|
38
44
|
},
|
|
39
45
|
];
|
|
@@ -41,13 +47,14 @@ const partExtractorPublicNames = partExtractorOptions
|
|
|
41
47
|
.map(option => option.publicName)
|
|
42
48
|
.join(', ');
|
|
43
49
|
const normalizePartExtractorName = (value) => value.trim().toLowerCase().replace(/\s+/g, ' ');
|
|
44
|
-
const
|
|
45
|
-
[normalizePartExtractorName(option.publicName), option
|
|
50
|
+
const partExtractorByInput = new Map(partExtractorOptions.flatMap(option => [
|
|
51
|
+
[normalizePartExtractorName(option.publicName), option],
|
|
46
52
|
...option.aliases.map(alias => [
|
|
47
53
|
normalizePartExtractorName(alias),
|
|
48
|
-
option
|
|
54
|
+
option,
|
|
49
55
|
]),
|
|
50
56
|
]));
|
|
57
|
+
const partExtractorPublicNameByApiValue = new Map(partExtractorOptions.map(option => [option.apiValue, option.publicName]));
|
|
51
58
|
const isInternalPartExtractorId = (value) => value.trim().includes('_');
|
|
52
59
|
const execFileAsync = promisify(execFile);
|
|
53
60
|
const usage = `AssetHub CLI
|
|
@@ -173,18 +180,29 @@ const resolvePartExtractorPublicName = (value) => {
|
|
|
173
180
|
if (isInternalPartExtractorId(value)) {
|
|
174
181
|
throw new Error(`Internal part extractor IDs are not accepted by the public CLI. Use one of: ${partExtractorPublicNames}.`);
|
|
175
182
|
}
|
|
176
|
-
const
|
|
177
|
-
if (
|
|
183
|
+
const option = partExtractorByInput.get(normalizePartExtractorName(value));
|
|
184
|
+
if (option == null) {
|
|
178
185
|
throw new Error(`Unknown part extractor: ${value}. Use one of: ${partExtractorPublicNames}.`);
|
|
179
186
|
}
|
|
180
|
-
return publicName;
|
|
187
|
+
return option.publicName;
|
|
181
188
|
};
|
|
182
|
-
const
|
|
189
|
+
const resolvePartExtractorApiValue = (value) => {
|
|
190
|
+
if (isInternalPartExtractorId(value)) {
|
|
191
|
+
throw new Error(`Internal part extractor IDs are not accepted by the public CLI. Use one of: ${partExtractorPublicNames}.`);
|
|
192
|
+
}
|
|
193
|
+
const option = partExtractorByInput.get(normalizePartExtractorName(value));
|
|
194
|
+
if (option == null) {
|
|
195
|
+
throw new Error(`Unknown part extractor: ${value}. Use one of: ${partExtractorPublicNames}.`);
|
|
196
|
+
}
|
|
197
|
+
return option.apiValue;
|
|
198
|
+
};
|
|
199
|
+
const resolvePartExtractorForAnalyze = (flags) => resolvePartExtractorApiValue(getPartExtractorFlag(flags) ?? defaultPartExtractorName);
|
|
183
200
|
const publicPartExtractorName = (value) => {
|
|
184
201
|
if (value == null) {
|
|
185
202
|
return null;
|
|
186
203
|
}
|
|
187
|
-
return (
|
|
204
|
+
return (partExtractorPublicNameByApiValue.get(value) ??
|
|
205
|
+
(isInternalPartExtractorId(value) ? 'Unknown' : value));
|
|
188
206
|
};
|
|
189
207
|
const sanitizeProductionOutput = (value) => {
|
|
190
208
|
if (Array.isArray(value)) {
|
|
@@ -1131,11 +1149,12 @@ const resolvePartExtractorFromMission = async (ctx, orderId, missionId) => {
|
|
|
1131
1149
|
throw new Error('Could not infer the part extractor from the mission. Pass --part-extractor with one of: ' +
|
|
1132
1150
|
partExtractorPublicNames);
|
|
1133
1151
|
}
|
|
1134
|
-
|
|
1152
|
+
const publicName = publicPartExtractorName(mission.agentVersion);
|
|
1153
|
+
if (publicName == null || publicName === 'Unknown') {
|
|
1135
1154
|
throw new Error('Could not infer the public part extractor from the mission. Pass --part-extractor with one of: ' +
|
|
1136
1155
|
partExtractorPublicNames);
|
|
1137
1156
|
}
|
|
1138
|
-
return
|
|
1157
|
+
return resolvePartExtractorApiValue(publicName);
|
|
1139
1158
|
};
|
|
1140
1159
|
const redactUrl = (value) => {
|
|
1141
1160
|
try {
|
|
@@ -1444,7 +1463,7 @@ const commandProduction = async (subcommand, positionals, ctx) => {
|
|
|
1444
1463
|
const partExtractorFlag = getPartExtractorFlag(ctx.flags);
|
|
1445
1464
|
const agentVersion = partExtractorFlag == null
|
|
1446
1465
|
? await resolvePartExtractorFromMission(ctx, orderId, missionId)
|
|
1447
|
-
:
|
|
1466
|
+
: resolvePartExtractorApiValue(partExtractorFlag);
|
|
1448
1467
|
const executed = await ctx.client.v1.executeProduction({
|
|
1449
1468
|
orderId,
|
|
1450
1469
|
missionId,
|
|
@@ -1515,7 +1534,7 @@ const commandParts = async (subcommand, ctx) => {
|
|
|
1515
1534
|
const partExtractorFlag = getPartExtractorFlag(ctx.flags);
|
|
1516
1535
|
const agentVersion = partExtractorFlag == null
|
|
1517
1536
|
? await resolvePartExtractorFromMission(ctx, orderId, missionId)
|
|
1518
|
-
:
|
|
1537
|
+
: resolvePartExtractorApiValue(partExtractorFlag);
|
|
1519
1538
|
const partExtractionMode = getFlag(ctx.flags, 'part-extraction-mode');
|
|
1520
1539
|
if (partExtractionMode != null &&
|
|
1521
1540
|
partExtractionMode !== 'fast' &&
|