@reliverse/rempts 1.7.45 → 1.7.47
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-npm/bin/mod.mjs +146 -5
- package/package.json +7 -9
package/dist-npm/bin/mod.mjs
CHANGED
|
@@ -3119,17 +3119,96 @@ const jiti = createJiti(import.meta.url, {
|
|
|
3119
3119
|
});
|
|
3120
3120
|
const COMMAND_EXTENSIONS = [".ts", ".js"];
|
|
3121
3121
|
const COMMAND_FILENAMES = ["cmd.ts", "cmd.js"];
|
|
3122
|
-
const getCallerDirectory = () => {
|
|
3122
|
+
const getCallerDirectory = async () => {
|
|
3123
3123
|
const stack = new Error().stack?.split("\n") ?? [];
|
|
3124
|
+
const cwd = process$1.cwd();
|
|
3125
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
3126
|
+
relinka("verbose", "Stack trace for getCallerDirectory:");
|
|
3127
|
+
stack.forEach((line, index) => {
|
|
3128
|
+
relinka("verbose", ` [${index}]: ${line.trim()}`);
|
|
3129
|
+
});
|
|
3130
|
+
}
|
|
3124
3131
|
for (const line of stack) {
|
|
3125
3132
|
const match = /\((.*):(\d+):(\d+)\)/.exec(line) || /at (.*):(\d+):(\d+)/.exec(line);
|
|
3126
3133
|
if (match?.[1]) {
|
|
3127
3134
|
const filePath = match[1];
|
|
3128
|
-
if (
|
|
3129
|
-
|
|
3135
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
3136
|
+
relinka("verbose", `Checking file path: ${filePath}`);
|
|
3137
|
+
}
|
|
3138
|
+
if (!filePath.includes("node_modules") && !filePath.includes("command-runner") && !filePath.includes("command-typed") && !filePath.includes("launcher-mod") && !filePath.includes("launcher-types") && !filePath.includes("mod.mjs") && // Skip compiled output
|
|
3139
|
+
!filePath.includes("mod.js") && // Skip compiled output
|
|
3140
|
+
!filePath.includes("mod.ts")) {
|
|
3141
|
+
try {
|
|
3142
|
+
const fileDir = dirname(filePath);
|
|
3143
|
+
const resolvedFileDir = resolve(fileDir);
|
|
3144
|
+
const resolvedCwd = resolve(cwd);
|
|
3145
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
3146
|
+
relinka("verbose", `File dir: ${fileDir}, resolved: ${resolvedFileDir}, cwd: ${resolvedCwd}`);
|
|
3147
|
+
}
|
|
3148
|
+
if (resolvedFileDir !== resolvedCwd && !resolvedFileDir.startsWith(resolvedCwd)) {
|
|
3149
|
+
relinka("verbose", `Using caller directory: ${fileDir}`);
|
|
3150
|
+
return fileDir;
|
|
3151
|
+
}
|
|
3152
|
+
if (resolvedFileDir === resolvedCwd) {
|
|
3153
|
+
let currentDir2 = fileDir;
|
|
3154
|
+
while (currentDir2 !== dirname(currentDir2)) {
|
|
3155
|
+
try {
|
|
3156
|
+
const packageJsonPath = resolve(currentDir2, "package.json");
|
|
3157
|
+
if (await fs.pathExists(packageJsonPath)) {
|
|
3158
|
+
const cwdPackageJsonPath = resolve(cwd, "package.json");
|
|
3159
|
+
if (await fs.pathExists(cwdPackageJsonPath)) {
|
|
3160
|
+
const callerPackageJson = await fs.readFile(packageJsonPath, "utf-8");
|
|
3161
|
+
const cwdPackageJson = await fs.readFile(cwdPackageJsonPath, "utf-8");
|
|
3162
|
+
if (callerPackageJson !== cwdPackageJson) {
|
|
3163
|
+
relinka("verbose", `Found different package.json at: ${currentDir2}, using caller directory: ${fileDir}`);
|
|
3164
|
+
return fileDir;
|
|
3165
|
+
}
|
|
3166
|
+
}
|
|
3167
|
+
break;
|
|
3168
|
+
}
|
|
3169
|
+
} catch {
|
|
3170
|
+
}
|
|
3171
|
+
currentDir2 = dirname(currentDir2);
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
} catch {
|
|
3175
|
+
continue;
|
|
3176
|
+
}
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
let currentDir = cwd;
|
|
3181
|
+
while (currentDir !== dirname(currentDir)) {
|
|
3182
|
+
try {
|
|
3183
|
+
const packageJsonPath = resolve(currentDir, "package.json");
|
|
3184
|
+
if (await fs.pathExists(packageJsonPath)) {
|
|
3185
|
+
relinka("verbose", `Found package.json at: ${currentDir}`);
|
|
3186
|
+
return currentDir;
|
|
3130
3187
|
}
|
|
3188
|
+
} catch {
|
|
3131
3189
|
}
|
|
3190
|
+
currentDir = dirname(currentDir);
|
|
3132
3191
|
}
|
|
3192
|
+
try {
|
|
3193
|
+
const possibleCommandPaths = [
|
|
3194
|
+
resolve(cwd, "src", "build", "cmd.ts"),
|
|
3195
|
+
resolve(cwd, "src", "build", "cmd.js"),
|
|
3196
|
+
resolve(cwd, "src-ts", "build", "cmd.ts"),
|
|
3197
|
+
resolve(cwd, "src-ts", "build", "cmd.js"),
|
|
3198
|
+
resolve(cwd, "build", "cmd.ts"),
|
|
3199
|
+
resolve(cwd, "build", "cmd.js"),
|
|
3200
|
+
resolve(cwd, "app", "build", "cmd.ts"),
|
|
3201
|
+
resolve(cwd, "app", "build", "cmd.js")
|
|
3202
|
+
];
|
|
3203
|
+
for (const path of possibleCommandPaths) {
|
|
3204
|
+
if (await fs.pathExists(path)) {
|
|
3205
|
+
relinka("verbose", `Found command file at: ${path}, using cwd: ${cwd}`);
|
|
3206
|
+
return cwd;
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
} catch {
|
|
3210
|
+
}
|
|
3211
|
+
relinka("verbose", `No suitable caller found, using cwd: ${cwd}`);
|
|
3133
3212
|
return process$1.cwd();
|
|
3134
3213
|
};
|
|
3135
3214
|
const tryLoadCommand = async (path) => {
|
|
@@ -3151,6 +3230,39 @@ const generateCandidatePaths = async (resolvedPath) => {
|
|
|
3151
3230
|
}
|
|
3152
3231
|
return [resolvedPath];
|
|
3153
3232
|
};
|
|
3233
|
+
const generateAlternativePaths = async (cmdPath, callerDir) => {
|
|
3234
|
+
const normalizedCmdPath = cmdPath.replace(/^\.\//, "");
|
|
3235
|
+
const paths = [];
|
|
3236
|
+
const commonCommandLocations = [
|
|
3237
|
+
// Direct command file
|
|
3238
|
+
resolve(callerDir, `${normalizedCmdPath}.ts`),
|
|
3239
|
+
resolve(callerDir, `${normalizedCmdPath}.js`),
|
|
3240
|
+
// Command in cmd subdirectory
|
|
3241
|
+
resolve(callerDir, normalizedCmdPath, "cmd.ts"),
|
|
3242
|
+
resolve(callerDir, normalizedCmdPath, "cmd.js"),
|
|
3243
|
+
// Command in app subdirectory
|
|
3244
|
+
resolve(callerDir, "app", normalizedCmdPath, "cmd.ts"),
|
|
3245
|
+
resolve(callerDir, "app", normalizedCmdPath, "cmd.js"),
|
|
3246
|
+
// Command in src subdirectory
|
|
3247
|
+
resolve(callerDir, "src", normalizedCmdPath, "cmd.ts"),
|
|
3248
|
+
resolve(callerDir, "src", normalizedCmdPath, "cmd.js"),
|
|
3249
|
+
// Command in src-ts subdirectory
|
|
3250
|
+
resolve(callerDir, "src-ts", normalizedCmdPath, "cmd.ts"),
|
|
3251
|
+
resolve(callerDir, "src-ts", normalizedCmdPath, "cmd.js"),
|
|
3252
|
+
// Command in bin subdirectory
|
|
3253
|
+
resolve(callerDir, "bin", normalizedCmdPath, "cmd.ts"),
|
|
3254
|
+
resolve(callerDir, "bin", normalizedCmdPath, "cmd.js"),
|
|
3255
|
+
// Command in bin/app subdirectory (common for CLI tools)
|
|
3256
|
+
resolve(callerDir, "bin", "app", normalizedCmdPath, "cmd.ts"),
|
|
3257
|
+
resolve(callerDir, "bin", "app", normalizedCmdPath, "cmd.js")
|
|
3258
|
+
];
|
|
3259
|
+
for (const path of commonCommandLocations) {
|
|
3260
|
+
if (await fs.pathExists(path)) {
|
|
3261
|
+
paths.push(path);
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
return paths;
|
|
3265
|
+
};
|
|
3154
3266
|
const createCommandNotFoundError = (cmdPath, searchedPaths) => new Error(
|
|
3155
3267
|
`No command file found for "${cmdPath}". Expected to find either:
|
|
3156
3268
|
- A valid command file at the specified path
|
|
@@ -3172,13 +3284,42 @@ Original error: ${originalError instanceof Error ? originalError.message : Strin
|
|
|
3172
3284
|
);
|
|
3173
3285
|
async function loadCommand(cmdPath) {
|
|
3174
3286
|
try {
|
|
3175
|
-
const callerDir = getCallerDirectory();
|
|
3287
|
+
const callerDir = await getCallerDirectory();
|
|
3176
3288
|
const normalizedPath = cmdPath.replace(/^\.\//, "");
|
|
3177
3289
|
const resolvedPath = resolve(callerDir, normalizedPath);
|
|
3290
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
3291
|
+
relinka("verbose", `Loading command: ${cmdPath}`);
|
|
3292
|
+
relinka("verbose", `Caller directory: ${callerDir}`);
|
|
3293
|
+
relinka("verbose", `Normalized path: ${normalizedPath}`);
|
|
3294
|
+
relinka("verbose", `Resolved path: ${resolvedPath}`);
|
|
3295
|
+
}
|
|
3178
3296
|
const candidatePaths = await generateCandidatePaths(resolvedPath);
|
|
3297
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
3298
|
+
relinka("verbose", `Candidate paths: ${candidatePaths.join(", ")}`);
|
|
3299
|
+
}
|
|
3179
3300
|
for (const path of candidatePaths) {
|
|
3180
3301
|
const command = await tryLoadCommand(path);
|
|
3181
|
-
if (command)
|
|
3302
|
+
if (command) {
|
|
3303
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
3304
|
+
relinka("verbose", `Successfully loaded command from: ${path}`);
|
|
3305
|
+
}
|
|
3306
|
+
return command;
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
if (callerDir !== process$1.cwd()) {
|
|
3310
|
+
const alternativePaths = await generateAlternativePaths(cmdPath, callerDir);
|
|
3311
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
3312
|
+
relinka("verbose", `Trying alternative paths: ${alternativePaths.join(", ")}`);
|
|
3313
|
+
}
|
|
3314
|
+
for (const path of alternativePaths) {
|
|
3315
|
+
const command = await tryLoadCommand(path);
|
|
3316
|
+
if (command) {
|
|
3317
|
+
if (process$1.env.NODE_ENV === "development") {
|
|
3318
|
+
relinka("verbose", `Successfully loaded command from alternative path: ${path}`);
|
|
3319
|
+
}
|
|
3320
|
+
return command;
|
|
3321
|
+
}
|
|
3322
|
+
}
|
|
3182
3323
|
}
|
|
3183
3324
|
throw createCommandNotFoundError(cmdPath, candidatePaths);
|
|
3184
3325
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reliverse/rempts",
|
|
3
3
|
"author": "reliverse",
|
|
4
|
-
"version": "1.7.
|
|
4
|
+
"version": "1.7.47",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "./dist-npm/bin/mod.mjs",
|
|
@@ -36,16 +36,14 @@
|
|
|
36
36
|
],
|
|
37
37
|
"description": "@reliverse/rempts is a modern, type-safe toolkit for building delightful cli experiences. it's fast, flexible, and made for developer happiness. file-based commands keep things simple.",
|
|
38
38
|
"scripts": {
|
|
39
|
-
"
|
|
40
|
-
"prepack": "unbuild",
|
|
41
|
-
"pub": "bun run build && bun publish",
|
|
39
|
+
"pub": "bun unbuild && bun publish",
|
|
42
40
|
"dev": "node -e 'console.log(`👉 bun dev:[prompts,modern,classic]`)'",
|
|
43
41
|
"dev:prompts": "bun example/prompts/mod.ts",
|
|
44
42
|
"dev:modern": "bun example/launcher/modern.ts",
|
|
45
43
|
"dev:classic": "bun example/launcher/classic.ts",
|
|
46
44
|
"dev:trpc": "bun example/trpc-orpc/commander/main.ts",
|
|
47
45
|
"latest": "bun update --latest && bun check",
|
|
48
|
-
"check": "tsc --noEmit && biome check --fix --unsafe
|
|
46
|
+
"check": "tsc --noEmit && biome check --fix --unsafe",
|
|
49
47
|
"agg": "rse tools --tool agg --input src/libs/core/core-impl --out src/libs/core/core-main.ts --recursive --named --strip src/libs/core",
|
|
50
48
|
"tests": "bun test ./.tests"
|
|
51
49
|
},
|
|
@@ -56,7 +54,7 @@
|
|
|
56
54
|
"@orpc/server": "^1.8.3",
|
|
57
55
|
"@reliverse/pathkit": "^1.3.4",
|
|
58
56
|
"@reliverse/reliarg": "^1.0.3",
|
|
59
|
-
"@reliverse/relico": "^1.3.
|
|
57
|
+
"@reliverse/relico": "^1.3.5",
|
|
60
58
|
"@reliverse/relifso": "^1.4.5",
|
|
61
59
|
"@reliverse/relinka": "^1.5.5",
|
|
62
60
|
"@reliverse/runtime": "^1.0.3",
|
|
@@ -67,7 +65,7 @@
|
|
|
67
65
|
"cli-spinners": "^3.2.0",
|
|
68
66
|
"commander": "^14.0.0",
|
|
69
67
|
"detect-package-manager": "^3.0.2",
|
|
70
|
-
"effect": "^3.17.
|
|
68
|
+
"effect": "^3.17.9",
|
|
71
69
|
"enquirer": "^2.4.1",
|
|
72
70
|
"figlet": "^1.8.2",
|
|
73
71
|
"gradient-string": "^3.0.0",
|
|
@@ -91,9 +89,9 @@
|
|
|
91
89
|
"zod-to-json-schema": "^3.24.6"
|
|
92
90
|
},
|
|
93
91
|
"devDependencies": {
|
|
94
|
-
"@biomejs/biome": "2.2.0",
|
|
92
|
+
"@biomejs/biome": "^2.2.0",
|
|
95
93
|
"@orpc/contract": "^1.8.3",
|
|
96
|
-
"@reliverse/dler": "1.7.
|
|
94
|
+
"@reliverse/dler": "1.7.96",
|
|
97
95
|
"@reliverse/rse": "^1.7.12",
|
|
98
96
|
"@total-typescript/ts-reset": "^0.6.1",
|
|
99
97
|
"@types/bun": "^1.2.20",
|