Compare commits

...

3 Commits

Author SHA1 Message Date
jkunz 8852bd5c86 v4.0.21
Default (tags) / security (push) Failing after 1s
Default (tags) / test (push) Failing after 1s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2026-04-30 14:29:50 +00:00
jkunz 6279f2cbad fix(smartcli): tighten command parsing and error handling while updating build and package configuration 2026-04-30 14:29:50 +00:00
jkunz e3f5616320 fix(core): Remove flawed safety check in getUserArgs and debug log
- Fixed bug where CLI with no args would return entire argv including node path
- Removed debug 'Wanted command: ...' log from startParse()
2026-01-12 01:22:25 +00:00
11 changed files with 4381 additions and 5268 deletions
+28
View File
@@ -0,0 +1,28 @@
{
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartcli",
"description": "A library that simplifies building reactive command-line applications using observables, with robust support for commands, arguments, options, aliases, and asynchronous operation management.",
"npmPackagename": "@push.rocks/smartcli",
"license": "MIT",
"projectDomain": "push.rocks"
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
},
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
}
}
+8
View File
@@ -1,5 +1,13 @@
# Changelog # Changelog
## 2026-04-30 - 4.0.21 - fix(smartcli)
tighten command parsing and error handling while updating build and package configuration
- throw an explicit error when triggering an unregistered command instead of failing on an undefined subject
- make the cli version property optional to align with current typing expectations
- update tests to use explicit argv input and export the tap startup call for runtime compatibility
- enable stricter TypeScript configuration and refresh build, dependency, and package metadata files
## 2025-10-28 - 4.0.19 - fix(license) ## 2025-10-28 - 4.0.19 - fix(license)
Update license files and add local tool settings Update license files and add local tool settings
Generated
+2170 -2829
View File
File diff suppressed because it is too large Load Diff
+12 -6
View File
@@ -1,9 +1,5 @@
{ {
"npmci": { "@git.zone/cli": {
"npmGlobalTools": [],
"npmAccesslevel": "public"
},
"gitzone": {
"projectType": "npm", "projectType": "npm",
"module": { "module": {
"githost": "code.foss.global", "githost": "code.foss.global",
@@ -26,9 +22,19 @@
"node.js", "node.js",
"development tool" "development tool"
] ]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
} }
}, },
"tsdoc": { "@git.zone/tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
},
"@ship.zone/szci": {
"npmGlobalTools": []
} }
} }
+13 -10
View File
@@ -1,14 +1,14 @@
{ {
"name": "@push.rocks/smartcli", "name": "@push.rocks/smartcli",
"private": false, "private": false,
"version": "4.0.19", "version": "4.0.21",
"description": "A library that simplifies building reactive command-line applications using observables, with robust support for commands, arguments, options, aliases, and asynchronous operation management.", "description": "A library that simplifies building reactive command-line applications using observables, with robust support for commands, arguments, options, aliases, and asynchronous operation management.",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module", "type": "module",
"scripts": { "scripts": {
"test": "(tstest test/ --verbose)", "test": "(tstest test/ --verbose)",
"build": "(tsbuild --web --allowimplicitany)", "build": "tsbuild --web",
"buildDocs": "tsdoc" "buildDocs": "tsdoc"
}, },
"repository": { "repository": {
@@ -32,22 +32,23 @@
"author": "Lossless GmbH <office@lossless.com> (https://lossless.com)", "author": "Lossless GmbH <office@lossless.com> (https://lossless.com)",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://gitlab.com/pushrocks/smartcli/issues" "url": "https://code.foss.global/push.rocks/smartcli/issues"
}, },
"homepage": "https://code.foss.global/push.rocks/smartcli", "homepage": "https://code.foss.global/push.rocks/smartcli",
"dependencies": { "dependencies": {
"@push.rocks/lik": "^6.2.2", "@push.rocks/lik": "^6.4.1",
"@push.rocks/smartlog": "^3.1.10", "@push.rocks/smartlog": "^3.2.2",
"@push.rocks/smartobject": "^1.0.12", "@push.rocks/smartobject": "^1.0.12",
"@push.rocks/smartpromise": "^4.2.3", "@push.rocks/smartpromise": "^4.2.3",
"@push.rocks/smartrx": "^3.0.10", "@push.rocks/smartrx": "^3.0.10",
"yargs-parser": "22.0.0" "yargs-parser": "22.0.0"
}, },
"devDependencies": { "devDependencies": {
"@git.zone/tsbuild": "^2.6.8", "@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsrun": "^1.6.2", "@git.zone/tsrun": "^2.0.3",
"@git.zone/tstest": "^2.7.0", "@git.zone/tstest": "^3.6.3",
"@types/node": "^24.9.1" "@types/node": "^25.6.0",
"@types/yargs-parser": "^21.0.3"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
@@ -58,11 +59,13 @@
"dist_ts_web/**/*", "dist_ts_web/**/*",
"assets/**/*", "assets/**/*",
"cli.js", "cli.js",
".smartconfig.json",
"LICENSE",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
], ],
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
], ],
"packageManager": "pnpm@10.18.1+sha512.77a884a165cbba2d8d1c19e3b4880eee6d2fcabd0d879121e282196b80042351d5eb3ca0935fa599da1dc51265cc68816ad2bddd2a2de5ea9fdf92adbec7cd34" "packageManager": "pnpm@10.28.2"
} }
+2137 -2403
View File
File diff suppressed because it is too large Load Diff
+2 -6
View File
@@ -16,11 +16,7 @@ tap.test('should add an command', async (toolsArg) => {
awesomeCommandSubject.subscribe(() => { awesomeCommandSubject.subscribe(() => {
done.resolve(); done.resolve();
}); });
console.log(process.argv); smartCliTestObject.startParse(['node', 'test.js', 'awesome']);
process.argv.splice(2, 0, 'awesome');
console.log(process.argv);
// Pass process.argv explicitly for testing (bypasses Deno.args in Deno environments)
smartCliTestObject.startParse(process.argv);
await done.promise; await done.promise;
}); });
@@ -40,4 +36,4 @@ tap.test('should accept a command', async () => {
expect(hasExecuted).toBeTrue(); expect(hasExecuted).toBeTrue();
}); });
tap.start(); export default tap.start();
+1 -1
View File
@@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@push.rocks/smartcli', name: '@push.rocks/smartcli',
version: '4.0.19', version: '4.0.21',
description: 'A library that simplifies building reactive command-line applications using observables, with robust support for commands, arguments, options, aliases, and asynchronous operation management.' description: 'A library that simplifies building reactive command-line applications using observables, with robust support for commands, arguments, options, aliases, and asynchronous operation management.'
} }
+4 -2
View File
@@ -18,7 +18,7 @@ export class Smartcli {
*/ */
public parseCompleted = plugins.smartpromise.defer<any>(); public parseCompleted = plugins.smartpromise.defer<any>();
public version: string; public version?: string;
/** /**
* map of all Trigger/Observable objects to keep track * map of all Trigger/Observable objects to keep track
@@ -65,6 +65,9 @@ export class Smartcli {
*/ */
public triggerCommand(commandNameArg: string, argvObject: any) { public triggerCommand(commandNameArg: string, argvObject: any) {
const triggerSubject = this.getCommandSubject(commandNameArg); const triggerSubject = this.getCommandSubject(commandNameArg);
if (!triggerSubject) {
throw new Error(`No smartcli command registered for ${commandNameArg}`);
}
triggerSubject.next(argvObject); triggerSubject.next(argvObject);
return triggerSubject; return triggerSubject;
} }
@@ -136,7 +139,6 @@ export class Smartcli {
console.log(this.version || 'unknown version'); console.log(this.version || 'unknown version');
return; return;
} }
console.log(`Wanted command: ${wantedCommand}`);
for (const command of this.commandObservableMap.getArray()) { for (const command of this.commandObservableMap.getArray()) {
if (!wantedCommand) { if (!wantedCommand) {
const standardCommand = this.commandObservableMap.findSync((commandArg) => { const standardCommand = this.commandObservableMap.findSync((commandArg) => {
+1 -6
View File
@@ -63,14 +63,9 @@ export function getUserArgs(argv?: string[]): string[] {
offset = Math.min(2, a.length); offset = Math.min(2, a.length);
} }
// Safety: if offset would skip all elements and array is not empty, don't skip anything
// This handles edge cases like test environments with unusual argv setups
if (offset >= a.length && a.length > 0) {
offset = 0;
}
// Note: we intentionally avoid path/URL heuristics on argv[1] so we don't // Note: we intentionally avoid path/URL heuristics on argv[1] so we don't
// accidentally drop the first user arg when it's a path-like value in compiled mode. // accidentally drop the first user arg when it's a path-like value in compiled mode.
// When offset >= a.length, this correctly returns an empty array (no user args).
return a.slice(offset); return a.slice(offset);
} }
+4 -4
View File
@@ -5,10 +5,10 @@
"target": "ES2022", "target": "ES2022",
"module": "NodeNext", "module": "NodeNext",
"moduleResolution": "NodeNext", "moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true, "esModuleInterop": true,
"verbatimModuleSyntax": true "verbatimModuleSyntax": true,
"types": ["node"]
}, },
"exclude": [ "exclude": ["dist_*/**/*.d.ts"]
"dist_*/**/*.d.ts"
]
} }