Skip to content

Update CLI implementation with modern tooling and conventions#1456

Open
relu91 wants to merge 31 commits intoeclipse-thingweb:masterfrom
relu91:cli-enachements
Open

Update CLI implementation with modern tooling and conventions#1456
relu91 wants to merge 31 commits intoeclipse-thingweb:masterfrom
relu91:cli-enachements

Conversation

@relu91
Copy link
Member

@relu91 relu91 commented Nov 28, 2025

I know that this PR will be long to review, but it has been sitting on my pc for a while, and it is time to push the changes. The primary goal was to get rid of the VM2 module, which is now deprecated and audited as a critical security risk. I used the opportunity to completely revise the implementation and make it:

  1. Hopefully easier to maintain
  2. More useful and self-explanatory

In summary, this PR delivers a significant refactor and several quality-of-life improvements to the cli module, primarily focusing on simplifying configuration, execution, and improving code organization.

Key Changes and Improvements

  • Configuration Unification: Environment variables are now consistently treated as configuration parameters, simplifying how settings are managed and loaded for the CLI execution.
    • ⚠️ Breaking Change: Now you should prefix every env with NODE_WOT_ and the cli automatically map that variable to a property in the configuration schema (e.g., WOT_SERVIENT_SERVIENT_CLIENTONLY -> servient.clientOnly)
  • Execution Simplification: Simplified the CLI script execution flow; now we simply require the files, avoiding dependence from virtual machines or complicated compilation steps. Virtualization can always be achieved with other means.
    • ⚠️ Breaking Change: This drops support for running remote scripts from the Default Servient Thing, a feature that was rarely used and controversial due to security concerns.
  • Major Refactoring and Testing:
    • Completed a major refactor of configuration building, configuration sync with the JSON schema, and logging organization.
    • Improved test coverage for the new configuration and parsing functionalities.
  • MQTT Fix : Allows for optional URI in the MQTT Server configuration.
  • Audit fix: Now, when you install node-wot, you should not see any audit warnings.

Open Point for Discussion

Given the extensive changes and the focus on the primary user experience:

  • Should we rename the CLI tool? The current name, wot-servient, is potentially surprising for regular users as it differs from the package name. I propose renaming it to node-wot to align with the project name and make it feel less surprising.

cli.ts log now enables by default error and warning messages.
As a result the responsibility of managing the initial
configuration for logging has been moved outside the
DefaultServient.
WARNING: Drops support for running remote scripts from the Default
Servient Thing. This feature was rarely used and controversial due to
security implications. Users wanting to run remote scripts can easily
implement this feature in their own Servient by extending the CLI
Servient.
now envs are treated as config parameters
@relu91
Copy link
Member Author

relu91 commented Dec 1, 2025

There is a small problem in the CLI tests due to some file shared across different unit tests. I'll fix them asap. They should not require changes to the business logic of the new CLI.

Copy link
Member

@danielpeintner danielpeintner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: I did not fully check nor run it locally, but I would like to make some comments:

  • THANK YOU for the effort. I think it is very helpful to get rid of VM2
  • I am surprised that no file has been removed (can it be?)
  • some more comments, see below

@egekorkan
Copy link
Member

Should we rename the CLI tool? The current name, wot-servient, is potentially surprising for regular users as it differs from the package name. I propose renaming it to node-wot to align with the project name and make it feel less surprising.

I like this :) I could not review the rest of the PR yet...

@danielpeintner
Copy link
Member

Should we rename the CLI tool? The current name, wot-servient, is potentially surprising for regular users as it differs from the package name. I propose renaming it to node-wot to align with the project name and make it feel less surprising.

I like this :) I could not review the rest of the PR yet...

I am fine with changing it. IF WE DO IT, we should publish first a node-wot version and increase the major version to make it clear it is a breaking change.

Co-authored-by: danielpeintner <daniel.peintner@gmail.com>
@relu91
Copy link
Member Author

relu91 commented Jan 7, 2026

I am fine with changing it. IF WE DO IT, we should publish first a node-wot version and increase the major version to make it clear it is a breaking change.

Given that we already have two other breaking changes in this PR, it makes sense to target a major version increase anyway. If we can discuss this in the next committer meeting.

@relu91 relu91 added the Discuss in Committer Meeting Labels issues and PRs that should be discussed in our regular Thingweb Committer Meeting. label Jan 7, 2026
@relu91 relu91 removed the Discuss in Committer Meeting Labels issues and PRs that should be discussed in our regular Thingweb Committer Meeting. label Jan 9, 2026
Copy link
Member

@danielpeintner danielpeintner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor issue

@danielpeintner
Copy link
Member

@relu91 mentioned on Telegram that vm2 efforts revived
patriksimek/vm2#533 (comment)

Honestly, I don't know which path to go is best... in any case.. even if we would stick to vm2 we should take over some changes Cristiano did in this PR...

@relu91
Copy link
Member Author

relu91 commented Jan 12, 2026

As stated offline, I think we can leave vm2 for now. We can re-introduce it if we get real feedback from our users to have isolation between wot scripts and the current Node.js project. So far, the usage has been limited.

@danielpeintner
Copy link
Member

@relu91 I think we can finally move on with this PR ... 🎉
Unfortunately, there are some conflicts that need to be resolved.

@relu91
Copy link
Member Author

relu91 commented Feb 18, 2026

@danielpeintner sadly, I had to re-generate package lock :/ Let me know if you are ok to merge it with these unrelated changes, or if I should try to rebase the whole history from main. That's probably why CI is failing due to coap?

@danielpeintner
Copy link
Member

Either way is fine for me. We should just manage to get a clean CI run with the right dependencies (versions)

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 93.70079% with 24 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.16%. Comparing base (2fd12dd) to head (eb18a6a).
⚠️ Report is 35 commits behind head on master.

Files with missing lines Patch % Lines
packages/binding-mqtt/src/mqtt-broker-server.ts 25.00% 6 Missing ⚠️
packages/cli/src/configuration.ts 95.45% 6 Missing ⚠️
packages/cli/src/executor.ts 90.19% 5 Missing ⚠️
packages/cli/src/parsers/config-file-parser.ts 90.32% 3 Missing ⚠️
packages/cli/src/utils/load-env-variables.ts 91.17% 3 Missing ⚠️
packages/cli/src/parsers/config-params-parser.ts 97.56% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1456      +/-   ##
==========================================
+ Coverage   77.99%   78.16%   +0.17%     
==========================================
  Files          86       91       +5     
  Lines       15904    15811      -93     
  Branches     1509     1532      +23     
==========================================
- Hits        12404    12359      -45     
+ Misses       3479     3429      -50     
- Partials       21       23       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@danielpeintner danielpeintner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments

@relu91
Copy link
Member Author

relu91 commented Mar 3, 2026

Thank you @danielpeintner ! I think all your comments make sense. It was an open point for discussion, and I forgot to properly align all the naming conventions. Since we settled for renaming wot-servient to simply node-wot, I would simply stick with node-wot everywhere with no servient postfix, okay?

@relu91 relu91 requested a review from mkovatsc as a code owner March 3, 2026 11:48
@relu91
Copy link
Member Author

relu91 commented Mar 3, 2026

Done, notice that I removed packages/cli/wot-servient.conf.json.md as it could go out of sync easly. Now the source of truth is the JSON schema, we can reintroduce a reference file once we tackle the problem of good documentation for node-wot.

@relu91 relu91 requested a review from danielpeintner March 3, 2026 11:50
Copy link
Member

@danielpeintner danielpeintner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much @relu91 !!🎉
Looks good to me!

@egekorkan @JKRhb others
do we want to take a final quick look in tomorrows committer call and merge?

Copy link
Member

@egekorkan egekorkan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@relu91 could not get the linking to work to make node-wot available as a command. npm run link does not work and the instructions are to use the npm package but not what developer should do. bin folder is generated under cli so I can of course do an alias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants