@reliverse/rempts 1.7.13 → 1.7.15
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.
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from "@reliverse/pathkit";
|
|
2
2
|
import { re } from "@reliverse/relico";
|
|
3
|
+
import fs from "@reliverse/relifso";
|
|
3
4
|
import { relinka } from "@reliverse/relinka";
|
|
4
5
|
import { loadConfig } from "c12";
|
|
5
|
-
import fs from "fs-extra";
|
|
6
6
|
import termkit from "terminal-kit";
|
|
7
7
|
const { terminal: term } = termkit;
|
|
8
8
|
let state = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import path from "@reliverse/pathkit";
|
|
2
2
|
import { reliArgParser } from "@reliverse/reliarg";
|
|
3
3
|
import { re } from "@reliverse/relico";
|
|
4
|
+
import fs from "@reliverse/relifso";
|
|
4
5
|
import { relinka, relinkaConfig, relinkaShutdown } from "@reliverse/relinka";
|
|
5
|
-
import fs from "fs-extra";
|
|
6
6
|
import process from "node:process";
|
|
7
7
|
import { readPackageJSON } from "pkg-types";
|
|
8
8
|
function buildExampleArgs(args) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Command } from "./launcher-types.js";
|
|
2
|
-
export declare function loadCommand(
|
|
2
|
+
export declare function loadCommand(cmdPath: string): Promise<Command>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { resolve } from "@reliverse/pathkit";
|
|
2
|
+
import fs from "@reliverse/relifso";
|
|
1
3
|
import { relinka } from "@reliverse/relinka";
|
|
2
4
|
import { createJiti } from "jiti";
|
|
3
5
|
const jiti = createJiti(import.meta.url, {
|
|
@@ -5,14 +7,45 @@ const jiti = createJiti(import.meta.url, {
|
|
|
5
7
|
fsCache: true,
|
|
6
8
|
sourceMaps: true
|
|
7
9
|
});
|
|
8
|
-
export async function loadCommand(
|
|
10
|
+
export async function loadCommand(cmdPath) {
|
|
9
11
|
try {
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
12
|
+
const normalizedPath = cmdPath.replace(/^\.\//, "");
|
|
13
|
+
const resolvedPath = normalizedPath.startsWith("../") ? resolve(process.cwd(), normalizedPath) : resolve(process.cwd(), normalizedPath);
|
|
14
|
+
if (!resolvedPath.endsWith("cmd.ts") && !resolvedPath.endsWith("cmd.js")) {
|
|
15
|
+
const possiblePaths = [
|
|
16
|
+
resolve(resolvedPath, "cmd.ts"),
|
|
17
|
+
resolve(resolvedPath, "cmd.js")
|
|
18
|
+
];
|
|
19
|
+
for (const path of possiblePaths) {
|
|
20
|
+
if (await fs.pathExists(path)) {
|
|
21
|
+
relinka("verbose", `Loading command from: ${path}`);
|
|
22
|
+
const cmd2 = await jiti.import(path, { default: true });
|
|
23
|
+
relinka("verbose", `Successfully loaded command from: ${path}`);
|
|
24
|
+
return cmd2;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
throw new Error(
|
|
28
|
+
`No command file found in ${resolvedPath}. Expected to find either:
|
|
29
|
+
- ${possiblePaths[0]}
|
|
30
|
+
- ${possiblePaths[1]}
|
|
31
|
+
Please ensure one of these files exists and exports a default command.`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
relinka("verbose", `Loading command from: ${resolvedPath}`);
|
|
35
|
+
const cmd = await jiti.import(resolvedPath, { default: true });
|
|
36
|
+
relinka("verbose", `Successfully loaded command from: ${resolvedPath}`);
|
|
13
37
|
return cmd;
|
|
14
38
|
} catch (error) {
|
|
15
|
-
|
|
16
|
-
|
|
39
|
+
if (error instanceof Error && error.message.includes("No command file found")) {
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
relinka("error", `Failed to load command from ${cmdPath}:`, error);
|
|
43
|
+
throw new Error(
|
|
44
|
+
`Failed to load command from ${cmdPath}:
|
|
45
|
+
- Make sure the file exists and is accessible
|
|
46
|
+
- Ensure the file exports a default command
|
|
47
|
+
- Check that the file is a valid TypeScript/JavaScript module
|
|
48
|
+
Original error: ${error instanceof Error ? error.message : String(error)}`
|
|
49
|
+
);
|
|
17
50
|
}
|
|
18
51
|
}
|
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"@reliverse/pathkit": "^1.2.1",
|
|
5
5
|
"@reliverse/reliarg": "^1.0.3",
|
|
6
6
|
"@reliverse/relico": "^1.1.2",
|
|
7
|
+
"@reliverse/relifso": "^1.3.1",
|
|
7
8
|
"@reliverse/relinka": "^1.4.7",
|
|
8
9
|
"@reliverse/runtime": "^1.0.3",
|
|
9
10
|
"ansi-escapes": "^7.0.0",
|
|
@@ -11,7 +12,6 @@
|
|
|
11
12
|
"cli-spinners": "^3.2.0",
|
|
12
13
|
"detect-package-manager": "^3.0.2",
|
|
13
14
|
"figlet": "^1.8.1",
|
|
14
|
-
"fs-extra": "^11.3.0",
|
|
15
15
|
"gradient-string": "^3.0.0",
|
|
16
16
|
"jiti": "^2.4.2",
|
|
17
17
|
"log-update": "^6.1.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"name": "@reliverse/rempts",
|
|
31
31
|
"type": "module",
|
|
32
|
-
"version": "1.7.
|
|
32
|
+
"version": "1.7.15",
|
|
33
33
|
"author": "reliverse",
|
|
34
34
|
"bugs": {
|
|
35
35
|
"email": "blefnk@gmail.com",
|