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

Use yargs instead of deprecated optimist in 4.x release #1658

Closed
4 tasks done
ShintaroOkuda opened this issue Mar 6, 2020 · 7 comments
Closed
4 tasks done

Use yargs instead of deprecated optimist in 4.x release #1658

ShintaroOkuda opened this issue Mar 6, 2020 · 7 comments

Comments

@ShintaroOkuda
Copy link

Before filing issues, please check the following points first:

We are using the latest handlebars 4.7.3, but we noticed that one of the dependencies optimist is deprecated. There is a ticket to switch to yargs instead (#1179) and it was closed with the merged PR (#1180). However, the merged PR is not in 4.x release yet. Please fix this in 4.x release.

@nknapp
Copy link
Collaborator

nknapp commented Mar 7, 2020

I think it may break the cli, so I'd rather not update in the 4.x branch.

I am sometimes working on 5.0 in the master, but since this is all voluntary work and I have a lot of other duties, I cannot tell when it with be ready.

@karlhorky
Copy link

karlhorky commented Mar 14, 2020

Moving from optimist to minimist or yargs would also allow for easier mitigation of the SNYK-JS-MINIMIST-559764 security vulnerability (which requires minimist@0.2.1, which does not fit optimist's semver range of minimist@~0.0.1).

This would be something I would imagine that Handlebars would want to backport to the 4.x branch.

An alternative that I have proposed is to relax the dependencies in optimist, but since it's deprecated, I think there's a high chance it will not receive any fixes anymore:

https://github.com/substack/node-optimist/pull/150


Edit: Workaround below, using Yarn: #1658 (comment)

@nknapp
Copy link
Collaborator

nknapp commented Mar 17, 2020

OK, I think we can give it a shot. The yargs API really seems to be like the optimist API. Does anybody want to create a PR for 4.x?

I would really feel better if there were some more tests verifying that the CLI still works the same after the migration.

There is currently only one here. It would be cool to have some test using different parameters.

Create some tests, check that they work with optimist, then migrate to yargs and see if they still work.

Could anybody do that?

@karlhorky
Copy link

karlhorky commented Mar 25, 2020

If you use Yarn, here's a workaround for now until this is fixed (maybe with #1662):

Add the following resolution to your package.json and run yarn.

  "resolutions": {
    "**/optimist/minimist": "0.2.1"
  }

This will force all versions of optimist to use minimist@0.2.1, regardless of which package is depending on optimist.

@fabb
Copy link
Contributor

fabb commented Mar 27, 2020

The latest optimist version (0.6.1, released 6 years ago) depends on a vulnerable version range of minimist which causes npm audit errors in projects that depend on handlebars directly or indirectly. A removal of optimist would be very appreciated, thank you!

@nknapp
Copy link
Collaborator

nknapp commented Mar 28, 2020

See #1661

@nknapp nknapp closed this as completed Mar 28, 2020
fabb pushed a commit to fabb/handlebars.js that referenced this issue Mar 29, 2020
…ed code from master to latest yargs (`.option` calls).

```
4.x:
found 188 vulnerabilities (169 low, 4 moderate, 14 high, 1 critical) in 5815 scanned packages

4.x with this PR:
found 32 vulnerabilities (17 low, 1 moderate, 13 high, 1 critical) in 5829 scanned packages
```
aorinevo pushed a commit to aorinevo/handlebars.js that referenced this issue Mar 29, 2020
closes handlebars-lang#1658
adapted code from master to latest yargs (`.option` calls).

```
4.x:
found 188 vulnerabilities (169 low, 4 moderate, 14 high, 1 critical) in 5815 scanned packages

4.x with this PR:
found 32 vulnerabilities (17 low, 1 moderate, 13 high, 1 critical) in 5829 scanned packages
```
ErisDS pushed a commit to ErisDS/handlebars.js that referenced this issue Mar 31, 2020
closes handlebars-lang#1658

- adapted code from master to latest yargs (`.option` calls).

```
4.x:
found 188 vulnerabilities (169 low, 4 moderate, 14 high, 1 critical) in 5815 scanned packages

4.x with this PR:
found 32 vulnerabilities (17 low, 1 moderate, 13 high, 1 critical) in 5829 scanned packages
```
ErisDS pushed a commit to ErisDS/handlebars.js that referenced this issue Mar 31, 2020
closes handlebars-lang#1658

- adapted code from master to latest yargs (`.option` calls).

```
4.x:
found 188 vulnerabilities (169 low, 4 moderate, 14 high, 1 critical) in 5815 scanned packages

4.x with this PR:
found 32 vulnerabilities (17 low, 1 moderate, 13 high, 1 critical) in 5829 scanned packages
```
@ErisDS
Copy link
Collaborator

ErisDS commented Apr 1, 2020

Released in 4.7.4

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

No branches or pull requests

5 participants