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

Add a CLI option to disable the progress bar on web-ext sign #2625

Merged
merged 6 commits into from
Feb 3, 2023

Conversation

Cimbali
Copy link
Contributor

@Cimbali Cimbali commented Jan 26, 2023

Fixes #2429 and fixes #2154 (though with a CLI option and not an environment variable.)

Help output:

> web-ext sign --help
web-ext sign

Sign the extension so it can be installed in Firefox

Options:
      --version             Show version number                                                                                                               [boolean]
  -s, --source-dir          Web extension source directory.                                 [string] [required] [default: "/path/to/webexts/markdown-viewer"]
  -a, --artifacts-dir       Directory where artifacts will be saved.      [string] [required] [default: "/path/to/webexts/markdown-viewer/web-ext-artifacts"]
  -v, --verbose             Show verbose output                                                                                                               [boolean]
  -i, --ignore-files        A list of glob patterns to define which files should be ignored. (Example: --ignore-files=path/to/first.js path/to/second.js "**/*.log")
                                                                                                                                                                [array]
      --no-input            Disable all features that require standard input                                                                                  [boolean]
  -c, --config              Path to a CommonJS config file to set option defaults                                                                              [string]
      --config-discovery    Discover config files in home directory and working directory. Disable with --no-config-discovery.                [boolean] [default: true]
      --amo-base-url        Signing API URL prefix - only used with `use-submission-api`            [string] [required] [default: "https://addons.mozilla.org/api/v5/"]
      --api-key             API key (JWT issuer) from addons.mozilla.org                                                                            [string] [required]
      --api-secret          API secret (JWT secret) from addons.mozilla.org                                                                         [string] [required]
      --api-url-prefix      Signing API URL prefix                                                   [string] [required] [default: "https://addons.mozilla.org/api/v4"]
      --api-proxy           Use a proxy to access the signing API. Example: https://yourproxy:6000                                                             [string]
      --use-submission-api  Sign using the addon submission API                                                                                               [boolean]
      --id                  A custom ID for the extension. This has no effect if the extension already declares an explicit ID in its manifest.                [string]
      --timeout             Number of milliseconds to wait before giving up                                                                                    [number]
      --quiet               Quieter signing process by hiding progress bars                                                                                   [boolean]
      --channel             The channel for which to sign the addon. Either 'listed' or 'unlisted'                                                             [string]
      --amo-metadata        Path to a JSON file containing an object with metadata to be passed to the API. See https://addons-server.readthedocs.io/en/latest/topics/a
                            pi/addons.html for details. Only used with `use-submission-api`                                                                    [string]
  -h, --help                Show help                                                                                                                         [boolean]

Failed signing without --quiet, has the “Validating add-on” progress bar:

> web-ext sign $API_CREDS
Building web extension from /path/to/webexts/markdown-viewer
Validating add-on [...................................................................................................................................................]
Validation results: https://addons.mozilla.org/en-US/developers/upload/1a507954c8ac4453acdf6d8dd93fc311
Your add-on failed validation and could not be signed
FAIL

WebExtError: The extension could not be signed
    at file:///path/to/web-ext/lib/cmd/sign.js:152:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Program.execute (file:///path/to/web-ext/lib/program.js:265:7)
    at async file:///path/to/web-ext/bin/web-ext.js:13:1

Failed signing with --quiet, there is no “Validating add-on” progress bar:

> web-ext sign --quiet $API_CREDS
Building web extension from /path/to/webexts/markdown-viewer
Validation results: https://addons.mozilla.org/en-US/developers/upload/46a042fc9c5a4200b7510f3bad774c3d
Your add-on failed validation and could not be signed
FAIL

WebExtError: The extension could not be signed
    at file:///path/to/web-ext/lib/cmd/sign.js:152:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Program.execute (file:///path/to/web-ext/lib/program.js:265:7)
    at async file:///path/to/web-ext/bin/web-ext.js:13:1

@Cimbali
Copy link
Contributor Author

Cimbali commented Jan 26, 2023

Now with progress bar automatically disabled when stdin is non-TTY:

> cat | web-ext sign --channel=unlisted `cat ../api_creds.txt` 
Building web extension from /path/to/webexts/markdown-viewer
Validation results: https://addons.mozilla.org/en-US/developers/upload/8045e4c2190d4909abda815ac27d2bad
Your add-on failed validation and could not be signed
FAIL

WebExtError: The extension could not be signed
    at file:///path/to/web-ext/lib/cmd/sign.js:153:13
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Program.execute (file:///path/to/web-ext/lib/program.js:265:7)
    at async file:///path/to/web-ext/bin/web-ext.js:13:1

@luckyrat
Copy link

This can work alongside the --verbose flag, yes?

If so, perhaps it would be better called --no-progress rather than --quiet since being "verbose" and "quiet" at the same time is potentially confusing.

@Cimbali
Copy link
Contributor Author

Cimbali commented Jan 31, 2023

The option can certainly be renamed --no-progress or --no-progress-bars or anything deemed appropriate.

I think @rpl (probably) should review at some point?

@willdurand
Copy link
Member

willdurand commented Feb 1, 2023

Since the value of the CLI flag is passed to a disableProgressBar attribute, I would probably rename the flag to --disable-progress-bar.

@willdurand willdurand self-requested a review February 1, 2023 21:23
src/cmd/sign.js Outdated Show resolved Hide resolved
@Cimbali
Copy link
Contributor Author

Cimbali commented Feb 1, 2023

Updated as requested @willdurand

Copy link
Member

@willdurand willdurand left a comment

Choose a reason for hiding this comment

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

Looking good, thanks.

src/program.js Outdated Show resolved Hide resolved
Co-authored-by: William Durand <will+git@drnd.me>
@willdurand willdurand self-requested a review February 2, 2023 15:02
@willdurand willdurand closed this Feb 2, 2023
@willdurand willdurand reopened this Feb 2, 2023
@willdurand
Copy link
Member

I closed and re-opened this PR on purpose to trigger CI jobs (don't ask...)

@willdurand
Copy link
Member

One more thing to fix apparently:

> web-ext@7.5.0 prettier-ci /home/circleci/web-ext
> prettier --list-different '**' || (echo '

This failure means you did not run `npm run prettier-dev` before committing

' && exit 1)

tests/unit/test-cmd/test.sign.js


This failure means you did not run `npm run prettier-dev` before committing

@Cimbali
Copy link
Contributor Author

Cimbali commented Feb 2, 2023

Done. The prettier-dev step might be worth mentioning in the README.

@willdurand willdurand closed this Feb 3, 2023
@willdurand willdurand reopened this Feb 3, 2023
@willdurand willdurand changed the title Implement a quiet option on web-ext sign Add a CLI option to disable the progress bar on web-ext sign Feb 3, 2023
@willdurand willdurand merged commit 58a5631 into mozilla:master Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants