Skip to content

Chore/sc 138087/usb env command#902

Open
hugomontero wants to merge 5 commits intochore/sc-138087/clean-upfrom
chore/sc-138087/usb-env-command
Open

Chore/sc 138087/usb env command#902
hugomontero wants to merge 5 commits intochore/sc-138087/clean-upfrom
chore/sc-138087/usb-env-command

Conversation

@hugomontero
Copy link
Contributor

Description

How to Test

Related Issues / Discussions

Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA
  • Problem and solution clearly stated
  • Tests have been provided
  • Docs have been updated
  • CI is passing

@hugomontero hugomontero force-pushed the chore/sc-138087/usb-env-command branch from 175ae7f to a3e278d Compare February 6, 2026 18:23
@hugomontero hugomontero force-pushed the chore/sc-138087/clean-up branch from 7d4b883 to b2c6811 Compare February 6, 2026 20:40
@hugomontero hugomontero force-pushed the chore/sc-138087/usb-env-command branch from a3e278d to a309449 Compare February 6, 2026 20:44
@hugomontero hugomontero marked this pull request as ready for review February 6, 2026 21:36
@hugomontero hugomontero requested a review from Copilot February 6, 2026 22:05
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 env CLI command wired to UsbCommand.getEnv() and updates USB help output.
  • Adds unit tests for environment variable output formatting and updates e2e help command list.
  • Bumps particle-usb dependency 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.

Comment on lines +158 to +164
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');
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

_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).

Copilot uses AI. Check for mistakes.
Comment on lines +137 to +145
expect(cleanOutput).to.deep.equal([
'',
'Device: 0123456789abcdef (P2)',
`${os.EOL}Environment Variables:`,
' Firmware:',
' FOO=bar',
' TEST=baz',
''
]);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Comment on lines 42 to 44
' network-interfaces Gets the network configuration of the device',
' env Gets environment variables from a device',
''
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
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.

1 participant