@kaiord/cli 3.0.0 → 4.1.0
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/bin/kaiord.js +68 -17
- package/package.json +6 -3
package/dist/bin/kaiord.js
CHANGED
|
@@ -151,11 +151,16 @@ init_esm_shims();
|
|
|
151
151
|
// src/commands/convert/index.ts
|
|
152
152
|
init_esm_shims();
|
|
153
153
|
import {
|
|
154
|
+
createDefaultProviders,
|
|
154
155
|
FitParsingError as FitParsingError3,
|
|
156
|
+
GarminParsingError,
|
|
155
157
|
KrdValidationError as KrdValidationError3,
|
|
156
158
|
ToleranceExceededError as ToleranceExceededError3
|
|
157
159
|
} from "@kaiord/core";
|
|
158
|
-
import {
|
|
160
|
+
import { createFitProviders } from "@kaiord/fit";
|
|
161
|
+
import { createGarminProviders } from "@kaiord/garmin";
|
|
162
|
+
import { createTcxProviders } from "@kaiord/tcx";
|
|
163
|
+
import { createZwoProviders } from "@kaiord/zwo";
|
|
159
164
|
|
|
160
165
|
// src/utils/config-loader.ts
|
|
161
166
|
init_esm_shims();
|
|
@@ -168,9 +173,10 @@ import { z as z2 } from "zod";
|
|
|
168
173
|
init_esm_shims();
|
|
169
174
|
import { extname } from "path";
|
|
170
175
|
import { z } from "zod";
|
|
171
|
-
var fileFormatSchema = z.enum(["fit", "krd", "tcx", "zwo"]);
|
|
176
|
+
var fileFormatSchema = z.enum(["fit", "gcn", "krd", "tcx", "zwo"]);
|
|
172
177
|
var EXTENSION_TO_FORMAT = {
|
|
173
178
|
".fit": "fit",
|
|
179
|
+
".gcn": "gcn",
|
|
174
180
|
".krd": "krd",
|
|
175
181
|
".tcx": "tcx",
|
|
176
182
|
".zwo": "zwo"
|
|
@@ -302,7 +308,7 @@ var ERROR_PATTERNS = [
|
|
|
302
308
|
title: "Invalid argument",
|
|
303
309
|
suggestions: [
|
|
304
310
|
"Use --input-format to explicitly specify the format.",
|
|
305
|
-
"Supported formats: fit, krd, tcx, zwo"
|
|
311
|
+
"Supported formats: fit, gcn, krd, tcx, zwo"
|
|
306
312
|
]
|
|
307
313
|
}
|
|
308
314
|
];
|
|
@@ -714,7 +720,7 @@ var loadFileAsKrd = async (filePath, format, providers) => {
|
|
|
714
720
|
const detectedFormat = format || detectFormat(filePath);
|
|
715
721
|
if (!detectedFormat) {
|
|
716
722
|
throw new Error(
|
|
717
|
-
`Unable to detect format for file: ${filePath}. Supported formats: .fit, .krd, .tcx, .zwo`
|
|
723
|
+
`Unable to detect format for file: ${filePath}. Supported formats: .fit, .gcn, .krd, .tcx, .zwo`
|
|
718
724
|
);
|
|
719
725
|
}
|
|
720
726
|
const fileData = await readFile2(filePath, detectedFormat);
|
|
@@ -739,6 +745,12 @@ var convertToKrd = async (data, format, providers) => {
|
|
|
739
745
|
}
|
|
740
746
|
return providers.convertZwiftToKrd({ zwiftString: data });
|
|
741
747
|
}
|
|
748
|
+
if (format === "gcn") {
|
|
749
|
+
if (typeof data !== "string") {
|
|
750
|
+
throw new Error("GCN input must be string");
|
|
751
|
+
}
|
|
752
|
+
return providers.convertGarminToKrd({ gcnString: data });
|
|
753
|
+
}
|
|
742
754
|
if (format === "krd") {
|
|
743
755
|
if (typeof data !== "string") {
|
|
744
756
|
throw new Error("KRD input must be string");
|
|
@@ -757,6 +769,9 @@ var convertFromKrd = async (krd, format, providers) => {
|
|
|
757
769
|
if (format === "zwo") {
|
|
758
770
|
return providers.convertKrdToZwift({ krd });
|
|
759
771
|
}
|
|
772
|
+
if (format === "gcn") {
|
|
773
|
+
return providers.convertKrdToGarmin({ krd });
|
|
774
|
+
}
|
|
760
775
|
if (format === "krd") {
|
|
761
776
|
return JSON.stringify(krd, null, 2);
|
|
762
777
|
}
|
|
@@ -773,7 +788,7 @@ var executeSingleFileConversion = async (options, providers, logger) => {
|
|
|
773
788
|
const inputFormat = options.inputFormat || detectFormat(options.input);
|
|
774
789
|
if (!inputFormat) {
|
|
775
790
|
const error = new Error(
|
|
776
|
-
`Unable to detect input format from file: ${options.input}. Supported formats: .fit, .krd, .tcx, .zwo`
|
|
791
|
+
`Unable to detect input format from file: ${options.input}. Supported formats: .fit, .gcn, .krd, .tcx, .zwo`
|
|
777
792
|
);
|
|
778
793
|
error.name = "InvalidArgumentError";
|
|
779
794
|
throw error;
|
|
@@ -786,7 +801,7 @@ var executeSingleFileConversion = async (options, providers, logger) => {
|
|
|
786
801
|
const outputFormat = options.outputFormat || detectFormat(options.output);
|
|
787
802
|
if (!outputFormat) {
|
|
788
803
|
const error = new Error(
|
|
789
|
-
`Unable to detect output format from file: ${options.output}. Supported formats: .fit, .krd, .tcx, .zwo`
|
|
804
|
+
`Unable to detect output format from file: ${options.output}. Supported formats: .fit, .gcn, .krd, .tcx, .zwo`
|
|
790
805
|
);
|
|
791
806
|
error.name = "InvalidArgumentError";
|
|
792
807
|
throw error;
|
|
@@ -1007,7 +1022,15 @@ var convertCommand = async (options) => {
|
|
|
1007
1022
|
});
|
|
1008
1023
|
}
|
|
1009
1024
|
try {
|
|
1010
|
-
const providers =
|
|
1025
|
+
const providers = createDefaultProviders(
|
|
1026
|
+
{
|
|
1027
|
+
fit: createFitProviders(logger),
|
|
1028
|
+
garmin: createGarminProviders(logger),
|
|
1029
|
+
tcx: createTcxProviders(logger),
|
|
1030
|
+
zwo: createZwoProviders(logger)
|
|
1031
|
+
},
|
|
1032
|
+
logger
|
|
1033
|
+
);
|
|
1011
1034
|
if (isBatchMode(validatedOptions.input)) {
|
|
1012
1035
|
return await executeBatchConversion(validatedOptions, providers, logger);
|
|
1013
1036
|
} else {
|
|
@@ -1032,6 +1055,8 @@ var convertCommand = async (options) => {
|
|
|
1032
1055
|
exitCode = ExitCode.PERMISSION_DENIED;
|
|
1033
1056
|
} else if (error instanceof FitParsingError3) {
|
|
1034
1057
|
exitCode = ExitCode.PARSING_ERROR;
|
|
1058
|
+
} else if (error instanceof GarminParsingError) {
|
|
1059
|
+
exitCode = ExitCode.PARSING_ERROR;
|
|
1035
1060
|
} else if (error instanceof KrdValidationError3) {
|
|
1036
1061
|
exitCode = ExitCode.VALIDATION_ERROR;
|
|
1037
1062
|
} else if (error instanceof ToleranceExceededError3) {
|
|
@@ -1049,7 +1074,11 @@ init_esm_shims();
|
|
|
1049
1074
|
|
|
1050
1075
|
// src/commands/diff/index.ts
|
|
1051
1076
|
init_esm_shims();
|
|
1052
|
-
import {
|
|
1077
|
+
import { createDefaultProviders as createDefaultProviders2 } from "@kaiord/core";
|
|
1078
|
+
import { createFitProviders as createFitProviders2 } from "@kaiord/fit";
|
|
1079
|
+
import { createGarminProviders as createGarminProviders2 } from "@kaiord/garmin";
|
|
1080
|
+
import { createTcxProviders as createTcxProviders2 } from "@kaiord/tcx";
|
|
1081
|
+
import { createZwoProviders as createZwoProviders2 } from "@kaiord/zwo";
|
|
1053
1082
|
|
|
1054
1083
|
// src/commands/diff/comparators.ts
|
|
1055
1084
|
init_esm_shims();
|
|
@@ -1057,8 +1086,8 @@ init_esm_shims();
|
|
|
1057
1086
|
// src/commands/diff/compare-steps.ts
|
|
1058
1087
|
init_esm_shims();
|
|
1059
1088
|
var compareSteps = (krd1, krd2) => {
|
|
1060
|
-
const workout1 = krd1.extensions?.
|
|
1061
|
-
const workout2 = krd2.extensions?.
|
|
1089
|
+
const workout1 = krd1.extensions?.structured_workout;
|
|
1090
|
+
const workout2 = krd2.extensions?.structured_workout;
|
|
1062
1091
|
const steps1 = workout1?.steps || [];
|
|
1063
1092
|
const steps2 = workout2?.steps || [];
|
|
1064
1093
|
const differences = [];
|
|
@@ -1242,7 +1271,15 @@ var diffCommand = async (options) => {
|
|
|
1242
1271
|
});
|
|
1243
1272
|
}
|
|
1244
1273
|
try {
|
|
1245
|
-
const providers =
|
|
1274
|
+
const providers = createDefaultProviders2(
|
|
1275
|
+
{
|
|
1276
|
+
fit: createFitProviders2(logger),
|
|
1277
|
+
garmin: createGarminProviders2(logger),
|
|
1278
|
+
tcx: createTcxProviders2(logger),
|
|
1279
|
+
zwo: createZwoProviders2(logger)
|
|
1280
|
+
},
|
|
1281
|
+
logger
|
|
1282
|
+
);
|
|
1246
1283
|
logger.debug("Loading files for comparison", {
|
|
1247
1284
|
file1: validatedOptions.file1,
|
|
1248
1285
|
file2: validatedOptions.file2
|
|
@@ -1304,11 +1341,15 @@ var diffCommand = async (options) => {
|
|
|
1304
1341
|
// src/commands/validate.ts
|
|
1305
1342
|
init_esm_shims();
|
|
1306
1343
|
import {
|
|
1344
|
+
createDefaultProviders as createDefaultProviders3,
|
|
1307
1345
|
createToleranceChecker,
|
|
1308
1346
|
toleranceConfigSchema,
|
|
1309
1347
|
validateRoundTrip
|
|
1310
1348
|
} from "@kaiord/core";
|
|
1311
|
-
import {
|
|
1349
|
+
import { createFitProviders as createFitProviders3 } from "@kaiord/fit";
|
|
1350
|
+
import { createGarminProviders as createGarminProviders3 } from "@kaiord/garmin";
|
|
1351
|
+
import { createTcxProviders as createTcxProviders3 } from "@kaiord/tcx";
|
|
1352
|
+
import { createZwoProviders as createZwoProviders3 } from "@kaiord/zwo";
|
|
1312
1353
|
import { readFile as fsReadFile2 } from "fs/promises";
|
|
1313
1354
|
import ora3 from "ora";
|
|
1314
1355
|
import { z as z5 } from "zod";
|
|
@@ -1378,7 +1419,15 @@ var validateCommand = async (options) => {
|
|
|
1378
1419
|
config: toleranceConfig
|
|
1379
1420
|
});
|
|
1380
1421
|
}
|
|
1381
|
-
const providers =
|
|
1422
|
+
const providers = createDefaultProviders3(
|
|
1423
|
+
{
|
|
1424
|
+
fit: createFitProviders3(logger),
|
|
1425
|
+
garmin: createGarminProviders3(logger),
|
|
1426
|
+
tcx: createTcxProviders3(logger),
|
|
1427
|
+
zwo: createZwoProviders3(logger)
|
|
1428
|
+
},
|
|
1429
|
+
logger
|
|
1430
|
+
);
|
|
1382
1431
|
const toleranceChecker = toleranceConfig ? createToleranceChecker(toleranceConfig) : providers.toleranceChecker;
|
|
1383
1432
|
const roundTripValidator = validateRoundTrip(
|
|
1384
1433
|
providers.fitReader,
|
|
@@ -1506,11 +1555,11 @@ var main = async () => {
|
|
|
1506
1555
|
description: "Output directory for batch conversion"
|
|
1507
1556
|
}).option("input-format", {
|
|
1508
1557
|
type: "string",
|
|
1509
|
-
choices: ["fit", "krd", "tcx", "zwo"],
|
|
1558
|
+
choices: ["fit", "gcn", "krd", "tcx", "zwo"],
|
|
1510
1559
|
description: "Override input format detection"
|
|
1511
1560
|
}).option("output-format", {
|
|
1512
1561
|
type: "string",
|
|
1513
|
-
choices: ["fit", "krd", "tcx", "zwo"],
|
|
1562
|
+
choices: ["fit", "gcn", "krd", "tcx", "zwo"],
|
|
1514
1563
|
description: "Override output format detection"
|
|
1515
1564
|
}).example(
|
|
1516
1565
|
"$0 convert -i workout.fit -o workout.krd",
|
|
@@ -1588,11 +1637,11 @@ var main = async () => {
|
|
|
1588
1637
|
demandOption: true
|
|
1589
1638
|
}).option("format1", {
|
|
1590
1639
|
type: "string",
|
|
1591
|
-
choices: ["fit", "krd", "tcx", "zwo"],
|
|
1640
|
+
choices: ["fit", "gcn", "krd", "tcx", "zwo"],
|
|
1592
1641
|
description: "Override format detection for first file"
|
|
1593
1642
|
}).option("format2", {
|
|
1594
1643
|
type: "string",
|
|
1595
|
-
choices: ["fit", "krd", "tcx", "zwo"],
|
|
1644
|
+
choices: ["fit", "gcn", "krd", "tcx", "zwo"],
|
|
1596
1645
|
description: "Override format detection for second file"
|
|
1597
1646
|
}).example(
|
|
1598
1647
|
"$0 diff --file1 workout1.fit --file2 workout2.fit",
|
|
@@ -1648,6 +1697,8 @@ var main = async () => {
|
|
|
1648
1697
|
const errorName = error.name;
|
|
1649
1698
|
if (errorName === "FitParsingError") {
|
|
1650
1699
|
process.exit(ExitCode.PARSING_ERROR);
|
|
1700
|
+
} else if (errorName === "GarminParsingError") {
|
|
1701
|
+
process.exit(ExitCode.PARSING_ERROR);
|
|
1651
1702
|
} else if (errorName === "KrdValidationError") {
|
|
1652
1703
|
process.exit(ExitCode.VALIDATION_ERROR);
|
|
1653
1704
|
} else if (errorName === "ToleranceExceededError") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaiord/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Command-line interface for Kaiord workout file conversion",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -43,8 +43,11 @@
|
|
|
43
43
|
"winston": "^3.11.0",
|
|
44
44
|
"yargs": "^18.0.0",
|
|
45
45
|
"zod": "^3.22.4",
|
|
46
|
-
"@kaiord/
|
|
47
|
-
"@kaiord/
|
|
46
|
+
"@kaiord/core": "^4.1.0",
|
|
47
|
+
"@kaiord/zwo": "^4.0.0",
|
|
48
|
+
"@kaiord/fit": "^4.0.0",
|
|
49
|
+
"@kaiord/garmin": "^4.1.0",
|
|
50
|
+
"@kaiord/tcx": "^4.0.0"
|
|
48
51
|
},
|
|
49
52
|
"devDependencies": {
|
|
50
53
|
"@types/yargs": "^17.0.32",
|