@reliverse/rempts 1.7.26 → 1.7.28

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.
@@ -318,41 +318,13 @@ export async function runMain(command, parserOptions = {}) {
318
318
  }
319
319
  try {
320
320
  if (!parserOptions.fileBasedCmds && !command.commands) {
321
- let callerDir = process.cwd();
322
- let callerFile;
323
- try {
324
- const err = new Error();
325
- const stack = err.stack?.split("\n");
326
- if (stack) {
327
- for (const line of stack) {
328
- const match = /\((.*):(\d+):(\d+)\)/.exec(line) || /at (.*):(\d+):(\d+)/.exec(line);
329
- if (match?.[1] && !match[1].includes("launcher-mod")) {
330
- callerFile = match[1];
331
- break;
332
- }
333
- }
334
- }
335
- if (callerFile) {
336
- callerDir = path.dirname(callerFile);
337
- if (parserOptions.fileBasedCmds?.enable) {
338
- const rel = path.relative(process.cwd(), callerFile);
339
- if (/app[/][^/]+[/]cmd\.(ts|js)$/.test(rel)) {
340
- relinka(
341
- "error",
342
- `runMain() should not be called from a file-based subcommand: ${rel}
343
- This can cause recursion or unexpected behavior.
344
- Move your runMain() call to your main CLI entry file.`
345
- );
346
- process.exit(1);
347
- }
348
- }
349
- }
350
- } catch (_e) {
351
- }
352
- const defaultCmdsRoot = path.resolve(callerDir, "app");
321
+ const mainEntry = process.argv[1] ? path.dirname(path.resolve(process.argv[1])) : process.cwd();
322
+ const defaultCmdsRoot = path.join(mainEntry, "src", "app");
323
+ const exists = await fs.pathExists(defaultCmdsRoot);
324
+ const finalCmdsRoot = exists ? defaultCmdsRoot : path.join(mainEntry, "app");
353
325
  parserOptions.fileBasedCmds = {
354
326
  enable: true,
355
- cmdsRootPath: defaultCmdsRoot
327
+ cmdsRootPath: finalCmdsRoot
356
328
  };
357
329
  }
358
330
  const rawArgv = process.argv.slice(2);
@@ -11,6 +11,7 @@ export type BaseArgDefinition = {
11
11
  default?: any;
12
12
  allowed?: any[];
13
13
  dependencies?: string[];
14
+ useTsType?: unknown;
14
15
  };
15
16
  export type PositionalArgDefinition = BaseArgDefinition & {
16
17
  type: "positional";
@@ -138,7 +139,9 @@ export type Command<A extends ArgDefinitions = EmptyArgs> = {
138
139
  onLauncherExit?: () => void | Promise<void>;
139
140
  };
140
141
  export type InferArgTypes<A extends ArgDefinitions> = {
141
- [K in keyof A]: A[K] extends PositionalArgDefinition ? string : A[K] extends BooleanArgDefinition ? boolean : A[K] extends StringArgDefinition ? string : A[K] extends NumberArgDefinition ? number : A[K] extends {
142
+ [K in keyof A]: A[K] extends {
143
+ useTsType: infer T;
144
+ } ? T : A[K] extends PositionalArgDefinition ? string : A[K] extends BooleanArgDefinition ? boolean : A[K] extends StringArgDefinition ? string : A[K] extends NumberArgDefinition ? number : A[K] extends {
142
145
  type: "array";
143
146
  } ? string[] : never;
144
147
  };
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "license": "MIT",
30
30
  "name": "@reliverse/rempts",
31
31
  "type": "module",
32
- "version": "1.7.26",
32
+ "version": "1.7.28",
33
33
  "author": "reliverse",
34
34
  "bugs": {
35
35
  "email": "blefnk@gmail.com",