@kaiord/cli 4.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 +30 -9
- package/package.json +5 -4
package/dist/bin/kaiord.js
CHANGED
|
@@ -153,10 +153,12 @@ init_esm_shims();
|
|
|
153
153
|
import {
|
|
154
154
|
createDefaultProviders,
|
|
155
155
|
FitParsingError as FitParsingError3,
|
|
156
|
+
GarminParsingError,
|
|
156
157
|
KrdValidationError as KrdValidationError3,
|
|
157
158
|
ToleranceExceededError as ToleranceExceededError3
|
|
158
159
|
} from "@kaiord/core";
|
|
159
160
|
import { createFitProviders } from "@kaiord/fit";
|
|
161
|
+
import { createGarminProviders } from "@kaiord/garmin";
|
|
160
162
|
import { createTcxProviders } from "@kaiord/tcx";
|
|
161
163
|
import { createZwoProviders } from "@kaiord/zwo";
|
|
162
164
|
|
|
@@ -171,9 +173,10 @@ import { z as z2 } from "zod";
|
|
|
171
173
|
init_esm_shims();
|
|
172
174
|
import { extname } from "path";
|
|
173
175
|
import { z } from "zod";
|
|
174
|
-
var fileFormatSchema = z.enum(["fit", "krd", "tcx", "zwo"]);
|
|
176
|
+
var fileFormatSchema = z.enum(["fit", "gcn", "krd", "tcx", "zwo"]);
|
|
175
177
|
var EXTENSION_TO_FORMAT = {
|
|
176
178
|
".fit": "fit",
|
|
179
|
+
".gcn": "gcn",
|
|
177
180
|
".krd": "krd",
|
|
178
181
|
".tcx": "tcx",
|
|
179
182
|
".zwo": "zwo"
|
|
@@ -305,7 +308,7 @@ var ERROR_PATTERNS = [
|
|
|
305
308
|
title: "Invalid argument",
|
|
306
309
|
suggestions: [
|
|
307
310
|
"Use --input-format to explicitly specify the format.",
|
|
308
|
-
"Supported formats: fit, krd, tcx, zwo"
|
|
311
|
+
"Supported formats: fit, gcn, krd, tcx, zwo"
|
|
309
312
|
]
|
|
310
313
|
}
|
|
311
314
|
];
|
|
@@ -717,7 +720,7 @@ var loadFileAsKrd = async (filePath, format, providers) => {
|
|
|
717
720
|
const detectedFormat = format || detectFormat(filePath);
|
|
718
721
|
if (!detectedFormat) {
|
|
719
722
|
throw new Error(
|
|
720
|
-
`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`
|
|
721
724
|
);
|
|
722
725
|
}
|
|
723
726
|
const fileData = await readFile2(filePath, detectedFormat);
|
|
@@ -742,6 +745,12 @@ var convertToKrd = async (data, format, providers) => {
|
|
|
742
745
|
}
|
|
743
746
|
return providers.convertZwiftToKrd({ zwiftString: data });
|
|
744
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
|
+
}
|
|
745
754
|
if (format === "krd") {
|
|
746
755
|
if (typeof data !== "string") {
|
|
747
756
|
throw new Error("KRD input must be string");
|
|
@@ -760,6 +769,9 @@ var convertFromKrd = async (krd, format, providers) => {
|
|
|
760
769
|
if (format === "zwo") {
|
|
761
770
|
return providers.convertKrdToZwift({ krd });
|
|
762
771
|
}
|
|
772
|
+
if (format === "gcn") {
|
|
773
|
+
return providers.convertKrdToGarmin({ krd });
|
|
774
|
+
}
|
|
763
775
|
if (format === "krd") {
|
|
764
776
|
return JSON.stringify(krd, null, 2);
|
|
765
777
|
}
|
|
@@ -776,7 +788,7 @@ var executeSingleFileConversion = async (options, providers, logger) => {
|
|
|
776
788
|
const inputFormat = options.inputFormat || detectFormat(options.input);
|
|
777
789
|
if (!inputFormat) {
|
|
778
790
|
const error = new Error(
|
|
779
|
-
`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`
|
|
780
792
|
);
|
|
781
793
|
error.name = "InvalidArgumentError";
|
|
782
794
|
throw error;
|
|
@@ -789,7 +801,7 @@ var executeSingleFileConversion = async (options, providers, logger) => {
|
|
|
789
801
|
const outputFormat = options.outputFormat || detectFormat(options.output);
|
|
790
802
|
if (!outputFormat) {
|
|
791
803
|
const error = new Error(
|
|
792
|
-
`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`
|
|
793
805
|
);
|
|
794
806
|
error.name = "InvalidArgumentError";
|
|
795
807
|
throw error;
|
|
@@ -1013,6 +1025,7 @@ var convertCommand = async (options) => {
|
|
|
1013
1025
|
const providers = createDefaultProviders(
|
|
1014
1026
|
{
|
|
1015
1027
|
fit: createFitProviders(logger),
|
|
1028
|
+
garmin: createGarminProviders(logger),
|
|
1016
1029
|
tcx: createTcxProviders(logger),
|
|
1017
1030
|
zwo: createZwoProviders(logger)
|
|
1018
1031
|
},
|
|
@@ -1042,6 +1055,8 @@ var convertCommand = async (options) => {
|
|
|
1042
1055
|
exitCode = ExitCode.PERMISSION_DENIED;
|
|
1043
1056
|
} else if (error instanceof FitParsingError3) {
|
|
1044
1057
|
exitCode = ExitCode.PARSING_ERROR;
|
|
1058
|
+
} else if (error instanceof GarminParsingError) {
|
|
1059
|
+
exitCode = ExitCode.PARSING_ERROR;
|
|
1045
1060
|
} else if (error instanceof KrdValidationError3) {
|
|
1046
1061
|
exitCode = ExitCode.VALIDATION_ERROR;
|
|
1047
1062
|
} else if (error instanceof ToleranceExceededError3) {
|
|
@@ -1061,6 +1076,7 @@ init_esm_shims();
|
|
|
1061
1076
|
init_esm_shims();
|
|
1062
1077
|
import { createDefaultProviders as createDefaultProviders2 } from "@kaiord/core";
|
|
1063
1078
|
import { createFitProviders as createFitProviders2 } from "@kaiord/fit";
|
|
1079
|
+
import { createGarminProviders as createGarminProviders2 } from "@kaiord/garmin";
|
|
1064
1080
|
import { createTcxProviders as createTcxProviders2 } from "@kaiord/tcx";
|
|
1065
1081
|
import { createZwoProviders as createZwoProviders2 } from "@kaiord/zwo";
|
|
1066
1082
|
|
|
@@ -1258,6 +1274,7 @@ var diffCommand = async (options) => {
|
|
|
1258
1274
|
const providers = createDefaultProviders2(
|
|
1259
1275
|
{
|
|
1260
1276
|
fit: createFitProviders2(logger),
|
|
1277
|
+
garmin: createGarminProviders2(logger),
|
|
1261
1278
|
tcx: createTcxProviders2(logger),
|
|
1262
1279
|
zwo: createZwoProviders2(logger)
|
|
1263
1280
|
},
|
|
@@ -1330,6 +1347,7 @@ import {
|
|
|
1330
1347
|
validateRoundTrip
|
|
1331
1348
|
} from "@kaiord/core";
|
|
1332
1349
|
import { createFitProviders as createFitProviders3 } from "@kaiord/fit";
|
|
1350
|
+
import { createGarminProviders as createGarminProviders3 } from "@kaiord/garmin";
|
|
1333
1351
|
import { createTcxProviders as createTcxProviders3 } from "@kaiord/tcx";
|
|
1334
1352
|
import { createZwoProviders as createZwoProviders3 } from "@kaiord/zwo";
|
|
1335
1353
|
import { readFile as fsReadFile2 } from "fs/promises";
|
|
@@ -1404,6 +1422,7 @@ var validateCommand = async (options) => {
|
|
|
1404
1422
|
const providers = createDefaultProviders3(
|
|
1405
1423
|
{
|
|
1406
1424
|
fit: createFitProviders3(logger),
|
|
1425
|
+
garmin: createGarminProviders3(logger),
|
|
1407
1426
|
tcx: createTcxProviders3(logger),
|
|
1408
1427
|
zwo: createZwoProviders3(logger)
|
|
1409
1428
|
},
|
|
@@ -1536,11 +1555,11 @@ var main = async () => {
|
|
|
1536
1555
|
description: "Output directory for batch conversion"
|
|
1537
1556
|
}).option("input-format", {
|
|
1538
1557
|
type: "string",
|
|
1539
|
-
choices: ["fit", "krd", "tcx", "zwo"],
|
|
1558
|
+
choices: ["fit", "gcn", "krd", "tcx", "zwo"],
|
|
1540
1559
|
description: "Override input format detection"
|
|
1541
1560
|
}).option("output-format", {
|
|
1542
1561
|
type: "string",
|
|
1543
|
-
choices: ["fit", "krd", "tcx", "zwo"],
|
|
1562
|
+
choices: ["fit", "gcn", "krd", "tcx", "zwo"],
|
|
1544
1563
|
description: "Override output format detection"
|
|
1545
1564
|
}).example(
|
|
1546
1565
|
"$0 convert -i workout.fit -o workout.krd",
|
|
@@ -1618,11 +1637,11 @@ var main = async () => {
|
|
|
1618
1637
|
demandOption: true
|
|
1619
1638
|
}).option("format1", {
|
|
1620
1639
|
type: "string",
|
|
1621
|
-
choices: ["fit", "krd", "tcx", "zwo"],
|
|
1640
|
+
choices: ["fit", "gcn", "krd", "tcx", "zwo"],
|
|
1622
1641
|
description: "Override format detection for first file"
|
|
1623
1642
|
}).option("format2", {
|
|
1624
1643
|
type: "string",
|
|
1625
|
-
choices: ["fit", "krd", "tcx", "zwo"],
|
|
1644
|
+
choices: ["fit", "gcn", "krd", "tcx", "zwo"],
|
|
1626
1645
|
description: "Override format detection for second file"
|
|
1627
1646
|
}).example(
|
|
1628
1647
|
"$0 diff --file1 workout1.fit --file2 workout2.fit",
|
|
@@ -1678,6 +1697,8 @@ var main = async () => {
|
|
|
1678
1697
|
const errorName = error.name;
|
|
1679
1698
|
if (errorName === "FitParsingError") {
|
|
1680
1699
|
process.exit(ExitCode.PARSING_ERROR);
|
|
1700
|
+
} else if (errorName === "GarminParsingError") {
|
|
1701
|
+
process.exit(ExitCode.PARSING_ERROR);
|
|
1681
1702
|
} else if (errorName === "KrdValidationError") {
|
|
1682
1703
|
process.exit(ExitCode.VALIDATION_ERROR);
|
|
1683
1704
|
} else if (errorName === "ToleranceExceededError") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kaiord/cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Command-line interface for Kaiord workout file conversion",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -43,10 +43,11 @@
|
|
|
43
43
|
"winston": "^3.11.0",
|
|
44
44
|
"yargs": "^18.0.0",
|
|
45
45
|
"zod": "^3.22.4",
|
|
46
|
-
"@kaiord/core": "^4.
|
|
46
|
+
"@kaiord/core": "^4.1.0",
|
|
47
|
+
"@kaiord/zwo": "^4.0.0",
|
|
47
48
|
"@kaiord/fit": "^4.0.0",
|
|
48
|
-
"@kaiord/
|
|
49
|
-
"@kaiord/
|
|
49
|
+
"@kaiord/garmin": "^4.1.0",
|
|
50
|
+
"@kaiord/tcx": "^4.0.0"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@types/yargs": "^17.0.32",
|