fix(smartcli): Improve CLI argument parsing, update deps and tests

This commit is contained in:
2025-10-28 06:27:29 +00:00
parent 44296dc57a
commit 6efd6232d1
8 changed files with 12248 additions and 3216 deletions
+10
View File
@@ -1,5 +1,15 @@
# Changelog
## 2025-10-27 - 4.0.13 - fix(smartcli)
Improve CLI argument parsing, update deps and tests
- Enhance startParse() to filter runtime executables and script paths (node, deno, bun, tsx, ts-node) so commands are detected correctly across runtimes.
- Switch path import to node:path in plugins for ESM compatibility.
- Bump various dependencies and devDependencies (including @push.rocks/lik, @push.rocks/smartlog, @push.rocks/smartpromise, @push.rocks/smartrx, yargs-parser, @git.zone tooling) and add packageManager field.
- Replace / reorganize tests: add/modify test/test.node+deno+bun.ts, adjust test script to use --verbose.
- Add deno.lock and include many resolved npm dependencies.
- Add LICENSE file (MIT).
## 2025-04-01 - 4.0.12 - fix(docs)
Update documentation with comprehensive usage examples, improved command alias descriptions, and detailed configuration instructions
Generated
+7233
View File
File diff suppressed because it is too large Load Diff
+12 -12
View File
@@ -7,7 +7,7 @@
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(tstest test/ --web)",
"test": "(tstest test/ --verbose)",
"build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
},
@@ -36,19 +36,18 @@
},
"homepage": "https://code.foss.global/push.rocks/smartcli",
"dependencies": {
"@push.rocks/lik": "^6.0.15",
"@push.rocks/smartlog": "^3.0.6",
"@push.rocks/lik": "^6.2.2",
"@push.rocks/smartlog": "^3.1.10",
"@push.rocks/smartobject": "^1.0.12",
"@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartrx": "^3.0.3",
"yargs-parser": "21.1.1"
"@push.rocks/smartpromise": "^4.2.3",
"@push.rocks/smartrx": "^3.0.10",
"yargs-parser": "22.0.0"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.80",
"@git.zone/tsrun": "^1.2.42",
"@git.zone/tstest": "^1.0.90",
"@push.rocks/tapbundle": "^5.0.23",
"@types/node": "^20.12.12"
"@git.zone/tsbuild": "^2.6.8",
"@git.zone/tsrun": "^1.6.2",
"@git.zone/tstest": "^2.7.0",
"@types/node": "^24.9.1"
},
"files": [
"ts/**/*",
@@ -64,5 +63,6 @@
],
"browserslist": [
"last 1 chrome versions"
]
],
"packageManager": "pnpm@10.18.1+sha512.77a884a165cbba2d8d1c19e3b4880eee6d2fcabd0d879121e282196b80042351d5eb3ca0935fa599da1dc51265cc68816ad2bddd2a2de5ea9fdf92adbec7cd34"
}
+4980 -3199
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,4 +1,4 @@
import { tap, expect } from '@push.rocks/tapbundle';
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as smartrx from '@push.rocks/smartrx';
import * as smartcli from '../ts/index.js';
+1 -1
View File
@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartcli',
version: '4.0.12',
version: '4.0.13',
description: 'A library that simplifies building reactive command-line applications using observables, with robust support for commands, arguments, options, aliases, and asynchronous operation management.'
}
+10 -2
View File
@@ -123,11 +123,16 @@ export class Smartcli {
* start the process of evaluating commands
*/
public startParse(): void {
const parsedYArgs = plugins.yargsParser(process.argv);
const parsedYArgs = plugins.yargsParser([...process.argv]);
// lets handle commands
// Filter out runtime executable and script path from arguments
// Node.js: ["/path/to/node", "/path/to/script.js", ...args]
// Deno: ["deno", "/path/to/script.ts", ...args]
// Bun: ["/path/to/bun", "/path/to/script.ts", ...args]
let counter = 0;
let foundCommand = false;
const runtimeNames = ['node', 'deno', 'bun', 'tsx', 'ts-node'];
parsedYArgs._ = parsedYArgs._.filter((commandPartArg) => {
counter++;
if (typeof commandPartArg === 'number') {
@@ -135,7 +140,10 @@ export class Smartcli {
}
if (counter <= 2 && !foundCommand) {
const isPath = commandPartArg.startsWith('/');
foundCommand = !isPath;
const isRuntimeExecutable = runtimeNames.some(name =>
commandPartArg === name || commandPartArg.endsWith(`/${name}`)
);
foundCommand = !isPath && !isRuntimeExecutable;
return foundCommand;
} else {
return true;
+1 -1
View File
@@ -1,7 +1,7 @@
// @pushrocks scope
import * as smartlog from '@push.rocks/smartlog';
import * as lik from '@push.rocks/lik';
import * as path from 'path';
import * as path from 'node:path';
import * as smartparam from '@push.rocks/smartobject';
import * as smartpromise from '@push.rocks/smartpromise';
import * as smartrx from '@push.rocks/smartrx';