@pd4castr/cli 1.12.0 → 1.13.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/index.js +38 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -339,7 +339,7 @@ __name(getEnv, "getEnv");
|
|
|
339
339
|
// package.json
|
|
340
340
|
var package_default = {
|
|
341
341
|
name: "@pd4castr/cli",
|
|
342
|
-
version: "1.
|
|
342
|
+
version: "1.13.0",
|
|
343
343
|
description: "CLI tool for creating, testing, and publishing pd4castr models",
|
|
344
344
|
license: "MIT",
|
|
345
345
|
main: "dist/index.js",
|
|
@@ -539,7 +539,6 @@ __name(registerFetchCommand, "registerFetchCommand");
|
|
|
539
539
|
// src/commands/init/handle-action.ts
|
|
540
540
|
import path6 from "path";
|
|
541
541
|
import * as inquirer from "@inquirer/prompts";
|
|
542
|
-
import { ExecaError as ExecaError2 } from "execa";
|
|
543
542
|
import ora2 from "ora";
|
|
544
543
|
import tiged from "tiged";
|
|
545
544
|
|
|
@@ -592,16 +591,26 @@ async function handleAction2() {
|
|
|
592
591
|
await fetchTemplate(template, projectName);
|
|
593
592
|
spinner.succeed("Template fetched successfully");
|
|
594
593
|
} catch (error) {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
594
|
+
if (isDegitError(error)) {
|
|
595
|
+
spinner.fail(formatErrorMessage(DEGIT_CODE_MAP[error.code]));
|
|
596
|
+
} else {
|
|
597
|
+
spinner.fail(formatErrorMessage("UNKNOWN_ERROR"));
|
|
598
|
+
if (error instanceof Error) {
|
|
599
|
+
console.error(error.stack ?? error.message);
|
|
600
|
+
}
|
|
600
601
|
}
|
|
601
602
|
process.exit(1);
|
|
602
603
|
}
|
|
603
604
|
}
|
|
604
605
|
__name(handleAction2, "handleAction");
|
|
606
|
+
var DEGIT_CODE_MAP = {
|
|
607
|
+
COULD_NOT_DOWNLOAD: "TEMPLATE_DOWNLOAD_FAILED",
|
|
608
|
+
COULD_NOT_FETCH: "TEMPLATE_DOWNLOAD_FAILED",
|
|
609
|
+
MISSING_REF: "TEMPLATE_NOT_FOUND",
|
|
610
|
+
BAD_SRC: "TEMPLATE_NOT_FOUND",
|
|
611
|
+
BAD_REF: "TEMPLATE_NOT_FOUND",
|
|
612
|
+
DEST_NOT_EMPTY: "DEST_NOT_EMPTY"
|
|
613
|
+
};
|
|
605
614
|
async function fetchTemplate(template, projectName) {
|
|
606
615
|
const templatePath = getTemplatePath(templates[template]);
|
|
607
616
|
const fetcher = tiged(templatePath, {
|
|
@@ -612,6 +621,20 @@ async function fetchTemplate(template, projectName) {
|
|
|
612
621
|
await fetcher.clone(destination);
|
|
613
622
|
}
|
|
614
623
|
__name(fetchTemplate, "fetchTemplate");
|
|
624
|
+
function isDegitError(error) {
|
|
625
|
+
return error instanceof Error && "code" in error && typeof error.code === "string" && error.code in DEGIT_CODE_MAP;
|
|
626
|
+
}
|
|
627
|
+
__name(isDegitError, "isDegitError");
|
|
628
|
+
var ERROR_MESSAGES = {
|
|
629
|
+
TEMPLATE_DOWNLOAD_FAILED: "Failed to download template. Check your internet connection and try again.",
|
|
630
|
+
TEMPLATE_NOT_FOUND: "Failed to download template. Please try again or report this issue if it persists.",
|
|
631
|
+
DEST_NOT_EMPTY: "Destination directory is not empty.",
|
|
632
|
+
UNKNOWN_ERROR: "An unexpected error occurred. Please try again or report this issue if it persists."
|
|
633
|
+
};
|
|
634
|
+
function formatErrorMessage(code) {
|
|
635
|
+
return `${ERROR_MESSAGES[code]} [CODE:${code}]`;
|
|
636
|
+
}
|
|
637
|
+
__name(formatErrorMessage, "formatErrorMessage");
|
|
615
638
|
|
|
616
639
|
// src/commands/init/index.ts
|
|
617
640
|
function registerInitCommand(program2) {
|
|
@@ -620,7 +643,7 @@ function registerInitCommand(program2) {
|
|
|
620
643
|
__name(registerInitCommand, "registerInitCommand");
|
|
621
644
|
|
|
622
645
|
// src/commands/login/handle-action.ts
|
|
623
|
-
import { ExecaError as
|
|
646
|
+
import { ExecaError as ExecaError2 } from "execa";
|
|
624
647
|
import ora3 from "ora";
|
|
625
648
|
import { ZodError as ZodError3 } from "zod";
|
|
626
649
|
|
|
@@ -736,7 +759,7 @@ async function handleAction3() {
|
|
|
736
759
|
} else if (error instanceof Error) {
|
|
737
760
|
spinner.fail(error.message);
|
|
738
761
|
}
|
|
739
|
-
if (error instanceof Error && error.cause instanceof
|
|
762
|
+
if (error instanceof Error && error.cause instanceof ExecaError2) {
|
|
740
763
|
console.error(error.cause.shortMessage);
|
|
741
764
|
} else if (error instanceof Error && error.cause) {
|
|
742
765
|
console.error(error.cause);
|
|
@@ -753,7 +776,7 @@ function registerLoginCommand(program2) {
|
|
|
753
776
|
__name(registerLoginCommand, "registerLoginCommand");
|
|
754
777
|
|
|
755
778
|
// src/commands/logout/handle-action.ts
|
|
756
|
-
import { ExecaError as
|
|
779
|
+
import { ExecaError as ExecaError3 } from "execa";
|
|
757
780
|
import ora4 from "ora";
|
|
758
781
|
import { ZodError as ZodError4 } from "zod";
|
|
759
782
|
async function handleAction4() {
|
|
@@ -776,7 +799,7 @@ async function handleAction4() {
|
|
|
776
799
|
} else if (error instanceof Error) {
|
|
777
800
|
spinner.fail(error.message);
|
|
778
801
|
}
|
|
779
|
-
if (error instanceof Error && error.cause instanceof
|
|
802
|
+
if (error instanceof Error && error.cause instanceof ExecaError3) {
|
|
780
803
|
console.error(error.cause.shortMessage);
|
|
781
804
|
} else if (error instanceof Error && error.cause) {
|
|
782
805
|
console.error(error.cause);
|
|
@@ -793,7 +816,7 @@ function registerLogoutCommand(program2) {
|
|
|
793
816
|
__name(registerLogoutCommand, "registerLogoutCommand");
|
|
794
817
|
|
|
795
818
|
// src/commands/publish/handle-action.ts
|
|
796
|
-
import { ExecaError as
|
|
819
|
+
import { ExecaError as ExecaError4 } from "execa";
|
|
797
820
|
import express2 from "express";
|
|
798
821
|
import { HTTPError as HTTPError3 } from "ky";
|
|
799
822
|
import ora5 from "ora";
|
|
@@ -1960,7 +1983,7 @@ async function handleAction5(options) {
|
|
|
1960
1983
|
} else if (error instanceof Error) {
|
|
1961
1984
|
spinner.fail(error.message);
|
|
1962
1985
|
}
|
|
1963
|
-
if (error instanceof Error && error.cause instanceof
|
|
1986
|
+
if (error instanceof Error && error.cause instanceof ExecaError4) {
|
|
1964
1987
|
console.error(error.cause.stderr);
|
|
1965
1988
|
} else if (error instanceof Error && error.cause) {
|
|
1966
1989
|
console.error(error.cause);
|
|
@@ -1984,7 +2007,7 @@ __name(registerPublishCommand, "registerPublishCommand");
|
|
|
1984
2007
|
|
|
1985
2008
|
// src/commands/test/handle-action.ts
|
|
1986
2009
|
import path16 from "path";
|
|
1987
|
-
import { ExecaError as
|
|
2010
|
+
import { ExecaError as ExecaError5 } from "execa";
|
|
1988
2011
|
import express3 from "express";
|
|
1989
2012
|
import ora6 from "ora";
|
|
1990
2013
|
import { ZodError as ZodError6 } from "zod";
|
|
@@ -2115,7 +2138,7 @@ ${clickHereLink} to view output (${fileLink})
|
|
|
2115
2138
|
} else if (error instanceof Error) {
|
|
2116
2139
|
spinner.fail(error.message);
|
|
2117
2140
|
}
|
|
2118
|
-
if (error instanceof Error && error.cause instanceof
|
|
2141
|
+
if (error instanceof Error && error.cause instanceof ExecaError5) {
|
|
2119
2142
|
console.error(error.cause.stderr);
|
|
2120
2143
|
} else if (error instanceof Error && error.cause) {
|
|
2121
2144
|
console.error(error.cause);
|