Chore/sc 138087/usb env command#902
Chore/sc 138087/usb env command#902hugomontero wants to merge 5 commits intochore/sc-138087/clean-upfrom
Conversation
175ae7f to
a3e278d
Compare
7d4b883 to
b2c6811
Compare
a3e278d to
a309449
Compare
There was a problem hiding this comment.
Pull request overview
Adds a new particle usb env subcommand to retrieve and display environment variables from a USB-connected device, leveraging newer particle-usb functionality.
Changes:
- Introduces
usb envCLI command wired toUsbCommand.getEnv()and updates USB help output. - Adds unit tests for environment variable output formatting and updates e2e help command list.
- Bumps
particle-usbdependency to^4.1.0(and updates shrinkwrap, including protobuf dependency).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/e2e/help.e2e.js | Adds usb env to the “all commands” help coverage list. |
| src/cmd/usb.js | Implements getEnv() and formatting helpers for env var output. |
| src/cmd/usb.test.js | Adds unit tests for _formatEnvOutput() behavior. |
| src/cli/usb.js | Registers the new usb env command with examples/options. |
| src/cli/usb.test.js | Updates top-level usb help expectations to include env. |
| package.json | Bumps particle-usb dependency version. |
| npm-shrinkwrap.json | Locks updated particle-usb and transitive dependency versions. |
Files not reviewed (1)
- npm-shrinkwrap.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| push(chalk.bold(`${os.EOL}Environment Variables:`)); | ||
|
|
||
| const { appVars, systemVars } = this._groupEnvVars(entries); | ||
|
|
||
| this._renderEnvGroup(output, ' Firmware:', appVars, 'green'); | ||
| appVars.length > 0 && systemVars.length > 0 && push(''); | ||
| this._renderEnvGroup(output, ' Cloud:', systemVars, 'cyan'); |
There was a problem hiding this comment.
_formatEnvOutput() pushes a string that begins with os.EOL ("\nEnvironment Variables:"). Since callers print each element with console.log(line), embedding a newline inside a single “line” will produce an extra blank line and make output harder to reason about (and can behave oddly on Windows with \r\n). Prefer pushing an empty string as its own array element (or reusing the existing push('')) and then pushing 'Environment Variables:' as a standalone line (which would also let you drop the os dependency here).
| expect(cleanOutput).to.deep.equal([ | ||
| '', | ||
| 'Device: 0123456789abcdef (P2)', | ||
| `${os.EOL}Environment Variables:`, | ||
| ' Firmware:', | ||
| ' FOO=bar', | ||
| ' TEST=baz', | ||
| '' | ||
| ]); |
There was a problem hiding this comment.
These unit tests currently assert the header line as ${os.EOL}Environment Variables: (i.e., a single array element containing a leading newline). Because _formatEnvOutput() is consumed by iterating output.forEach(line => console.log(line)), a newline embedded inside a single element is likely unintended and will print as multiple terminal lines from one console.log call. If you change the formatter to emit a blank line as its own element and then 'Environment Variables:' as a separate element, update these expectations accordingly and you can remove the os import from this test file too.
| ' network-interfaces Gets the network configuration of the device', | ||
| ' env Gets environment variables from a device', | ||
| '' |
There was a problem hiding this comment.
The new usb env subcommand is added to the top-level help text, but there are no CLI parsing/help tests specifically for usb env (unlike other subcommands in this file, e.g. usb network-interfaces). Add a describe('Handles usb env Command' ...) block to verify argument parsing (devices..., --all) and --help output/examples, so regressions in the command definition are caught.
Description
How to Test
Related Issues / Discussions
Completeness