Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sc 118580/binary inspect bundle #642

Merged
merged 13 commits into from
May 26, 2023

Conversation

keeramis
Copy link
Contributor

Description

Adds support to bundle assets and application binary from the project folder

Usage

npm start -- binary inspect /path/to/bundle.zip

Example

$ npm start -- binary inspect /path/to/bundle.zip 

> particle-cli@3.10.2 start
> node ./src/index.js binary inspect /path/to/bundle.zip

app.bin
 CRC is ok (7fa30408)
 Compiled for argon
 This is an application module number 2 at version 6
 It is firmware for product id 12 at version 3
 It depends on a system module number 1 at version 4006
It depends on assets:
 cat.txt in bundle (hash b0f0d8ff8cc965a7b70b07e0c6b4c028f132597196ae9c70c620cb9e41344106)
 house.txt in bundle (hash a78fb0e7df9977ffd3102395254ae92dd332b46a616e75ff4701e75f91dd60d3)
 water.txt in bundle (hash 3b0c25d6b8af66da115b30018ae94fbe3f04ac056fa60d1150131128baf8c591)

All the other legacy use cases should be supported as-is.

How to Test

  1. Pull down the branch: git pull && git checkout feature/sc-118580/binary-inspect-bundle
  2. Run nvm use
  3. Reinstall dependencies: npm run reinstall
  4. Run tests: npm test

Related Issues / Discussions

https://app.shortcut.com/particle/story/118580/extract-and-analyze-asset-information-from-binary-inspect-command

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

@keeramis keeramis force-pushed the feature/sc-118580/binary-inspect-bundle branch from be01162 to cbceafa Compare May 24, 2023 14:39
@keeramis keeramis requested a review from monkbroc May 24, 2023 15:21

const INVALID_SUFFIX_SIZE = 65535;
const DEFAULT_PRODUCT_ID = 65535;
const DEFAULT_PRODUCT_VERSION = 65535;
let tmpDir;
Copy link
Contributor Author

@keeramis keeramis May 24, 2023

Choose a reason for hiding this comment

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

I am creating a temporary directory on-the-spot and deleting it at the end of the operation. I tried using the test/lib/env.js directory, however, the e2e tests are unable to pick up the env.js module if I am using relative path and they fail with error

particle-cli-3.10.2.tgz
  Binary Commands
    ✓ Shows `help` content (3548ms)
    ✓ Shows `help` content when run without arguments (352ms)
    ✓ Shows `help` content when run with `--help` flag (363ms)
    Binary Inspect Subcommand
stdout Cannot find module '../../test/lib/env'
Require stack:
- /Users/keerthyamisagadda/code/particle-cli/test/__fixtures__/pkg/node_modules/particle-cli/src/cmd/binary.js
- /Users/keerthyamisagadda/code/particle-cli/test/__fixtures__/pkg/node_modules/particle-cli/src/cli/binary.js
- /Users/keerthyamisagadda/code/particle-cli/test/__fixtures__/pkg/node_modules/particle-cli/src/cli/index.js
- /Users/keerthyamisagadda/code/particle-cli/test/__fixtures__/pkg/node_modules/particle-cli/src/app/cli.js
- /Users/keerthyamisagadda/code/particle-cli/test/__fixtures__/pkg/node_modules/particle-cli/src/index.js

Is it recommended to use the test/ directories from the source file? Any recommendations are appreciated if the current implementation looks unfavorable.


const parser = new Parser();
async _checkFile(file) {
// TODO: what happens if this is removed? What kind of error do we get?
Copy link
Member

Choose a reason for hiding this comment

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

Can you check what happens without the file existance check for binary inspect on a .bin and on a .zip? If the error is reasonable, remove this function. If not, keep it and remove the comment.

@keeramis keeramis merged commit 6707856 into master May 26, 2023
@monkbroc monkbroc deleted the feature/sc-118580/binary-inspect-bundle branch January 19, 2024 19:40
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.

2 participants