**Summary**
Fixes#4429. Apparently there's an advice on the internet to use
`null` as the package version to install the latest version and
even worse, some people are using this. This patch makes sure
the version is at least a string (albeit an empty one) when
fixing the manifest.
**Test plan**
Added new integration test.
**Summary**
Fixes#4445. The bug was introduced in
https://github.com/yarnpkg/yarn/pull/3976/files#diff-7066979f95168f7bb59e4f9cfb3ba8fcR211
with an incomplete package optional check. This caused many transient
dependencies to be ignored at linking stage when `--ignore-optional`
flag is passed. This patch fixes the check to combine the flag with
the package's actual optional mark.
**Test plan**
Manually verified #4445 is resolved. Also added a unit test.
**Summary**
Fixed incorrect documentation for global add deprecated message
**Test plan**
Run `yarn add -g left-pad` and follow the suggested command on the console. It should work.
**Summary**
Fixes#746. Unfortunately, neither Node, nor many systems come with
built-in DNS caching so the many parallel requests that Yarn makes
sometimes overwhelm the DNS servers, and most of the time, for the
very same domain(s). Even worse, we pay the DNS look up cost for
each request, which is quite sad at best. This patch introduces
the `dnscache` module which intercepts all DNS look ups and answers
them from an in-memory cache when possible. This applies to the
built-in `http` and `https` modules, used by `request`.
**Test plan**
Existing tests should pass, and hopefully be faster. Total number of
DNS look ups should decrease dramatically.
**Summary**
Fixes#2530. This patch replaces the 2-byte progress bar characters with `-` and `#` wrapped in a pair of `[` and `]` symbols to make it looks like a progress bar on the console with "simple", one-byte characters.
The reason for preferring one-byte characters is the inconsistent width calculation on certain terminal emulators causing the calculated progress bar width to overflow the available terminal width, causing the progress bar to split into multiple lines.
It now looks like this:

**Test plan**
Manual verification and updating of existing test snapshots.
**Summary**
Follow up to #4431. `isFakeRoot` didn't have any tests and it was broken from the start. #4431 solved it and it was merged to be included in 1.0.2 without tests. This patch adds the missing tests for this function.
**Test plan**
Added new tests, duh :D
**Summary**
A combination of changes have caused `yarn upgrade-interactive` to exit with a promise rejection.
In short, I believe it has always been a problem, but #3995 exposed it to the prompt.
The child rejection inside of [upgrade-interactive](https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/upgrade-interactive.js#L152) is fine, as it was handled by the `Promise.race` condition; however, rejecting at the parent level inside of [console-reporter](https://github.com/yarnpkg/yarn/blob/master/src/reporters/console/console-reporter.js#L458) causes[ loud-rejection](https://github.com/sindresorhus/loud-rejection) to handle this.
I believe @arcanis 's PR #4283 is what would allow us not to hook into `SIGINT` inside of the console reporter and allow the reporter to cleanly close itself.
**Test Plan**
Will work on some scenarios! This PR needs some more verification on my end ... @BYK @torifat @arcanis please jump in and provide any feedback you think could be helpful! Opened early for visibility :)
**Summary**
Fixes#4430.
`fakeroot` detection was added in #3924 (7a053e2ca0); it actually tests the exact opposite though.
**Test plan**
For testing this I added the line
```JavaScript
console.log("isFakeRoot", isFakeRoot());
```
I then tried the lines
```
./yarn global add
sudo ./yarn global add
fakeroot ./yarn global add
```
I also tried if `ROOT_USER` is now correct in [user-home-dir.js](0ef3bf1f03/src/util/user-home-dir.js) for these 3 commands.
```JavaScript
console.log("ROOT_USER", ROOT_USER);
```
Will also follow up with unit tests.
**Summary**
This PR fixes the error message for hash mismatches where the actual and expected hashes were swapped in the error message.
**Test plan**
Manual verification.
**Summary**
Fixes#4395
This PR fixes a bug that causes `colorizedDiff` to append a period at the end of the return value if the `from`/`to` versions are identical. If they do happen to be identical, then it will simply return the `from` value.
**Test plan**
I am currently testing that, given identical `from`/`to` versions, it returns the `from` (or `to`) version. I've not added unit tests to cover when the versions differ in any way, nor am I testing that the returned string is formatted correctly (e.g., if `from = '1.0.0'` and `to = '1.0.1'`, the result should be `1.0.1` with the trailing one being formatted to green)
**Summary**
Fixes#3922. Certain commands in yarn should always produce an
output, regardless of the silent status. This makes
`reporter.inspect` for console reporter to always produce an
output. It also forces the output of `yarn config get` to override
silent mode.
**Test plan**
Should add integration tests.
* Chore: fix flaky add tests by using separate cache
**Summary**
This PR fixes some test flakiness, especially in the
"should add package with frozzen-lockfile option" tests
where we get `ENOENT` errors from cache. This is most
likely because multiple `add` tests are run concurrently
causing cache corruption. This PR makes all `execCommand`
invocations use a separate cache.
**Test plan**
Tests should not be flaky anymore.
* lol, fix tests
**Summary**
Fixes#4366. NPM registry encodes the `/` in scoped package names for meta look ups but not for tarball download URLs so Yarn was not sending authentication headers for the tarball downloads breaking scoped packages. This patch fixes it.
**Test plan**
Updated tests.
**Summary**
We've been using `node -p -e` where `-e` is redundant since
it is implied by `-p`: https://nodejs.org/api/cli.html#cli_p_print_script
This patch removes those extra `-e`s.
**Test plan**
All bundles should build on CI without errors.
**Summary**
Fixes#4383. This patch makes argument parsing a bit tidier, and
starts supporting `yarn --silent custom-script` style commands as
initiall intended by #4152.
**Test plan**
Existing unit tests. Should ideally add a few more.
**Summary**
Fix for https://github.com/yarnpkg/yarn/issues/4357.
The issue is that when a dependency (dep A) defined in resolutions (includes dep A, dep B) depends on another resolution (dep B), then it expects to match its own nested dep B to the top level resolution dep B. So the first part of this fix is "don't run resolutions map check when it's in flat mode", which is what threw the invariant warning. Second part of the fix is that we still want that nested dependency (dep B) of a resolution (dep A) to be resolved correctly. `--flat` mode solves this by [collapsing all versions](https://github.com/yarnpkg/yarn/blob/master/src/cli/commands/install.js#L558) after the resolver is done. For resolutions, I'm adding a delay queue for requests with resolutions but no manifests found yet so that they will be resolved later.
**Test plan**
Added tests in resolutions
**Summary**
Currently running `yarn -v` displays the yarn version number but `yarn -h` says otherwise:
```
$ yarn -h
Usage: yarn [command] [flags]
Options:
-h, --help output usage information
--version output the version number
-v, --verbose output verbose messages on internal operations
$ yarn -v
1.0.1
```
this PR fixes `yarn -h` to use `-v` as version number. Output of `yarn -h` with this PR:
```
$ ./bin/yarn -h
Usage: yarn [command] [flags]
Options:
-h, --help output usage information
-v, --version output the version number
--verbose output verbose messages on internal operations
```
**Summary**
Fixes#4345. This patch triggers the `help` command with `-h` or
`--help` only when the command name is known to `yarn` and the flag
is set immediately after the command name itself.
**Test plan**
Should add unit tests.
**Summary**
The exotic `file-resolver` checks for `.` and `..`, but the regex is missing the escape on the `.`, so *any* two characters count as a file. This includes single-character scope names, like `@s/packagename`.
This issue was introduced in https://github.com/yarnpkg/yarn/pull/4257.
**Test plan**
I wasn't sure how packages should be named in `__tests__/fixtures/install/resolutions/exotic-version`, so I have not added add a single-character scoped package reference to test.
I don't know of any single-character scopes in the public registry to use as reference, the way `left-pad-1.1.1.tgz` is mirrored in there. Could I just copy `leftpad-1.1.1.tgz` as `@s/leftpad-1.1.1.tgz` and use that?
* Fix: Make sure global prefix folder is writeable when selecting it
**Summary**
Fixes#4320 and fixes#4323. We were using `fs.access` when selecting
the global prefix folder automatically which only checks for permissions
but not actual writeability. This caused issues on Heroku where one of
our first tries had the correct permissions but was on a read-only
file system.
**Test plan**
Existing cache folder fallback tests should be enough for now. We should
move the core of those tests for the newly added `fs.getFirstWriteableFolder`
method.
* Fix wrong error message template used from getGlobalPrefix
* Better error message
* Add process.execPath as a last resort
* Add back $DESTDIR support removed from #3721
* Fix DESTDIR typo
* Fix skippedFolder error
* don't use rimraf to remove a file
* Don't use process.execPath
* Defer write checks for global prefix
* flow type
* Just warn when a proper global folder cannot be found, instead of failing
* Add TODO about inconsistent npm-registry code
* Keep the old behavior
* Update fs.js
**Summary**
Looks like bumping the version on npm invalidated a cache that
revealed the new API response from npm for yarn. Now the
`scripts` field always exists even if it is empty.
**Test plan**
CI should pass.
**Summary**
Fixes#4167. We use `$GIT_SSH_COMMAND` which overrides `$GIT_SSH`
and causes issues on some systems, where a different `ssh`
executable like `plink` is used. This patch makes our batch-mode
enforcement smarter and more respectful and adds support for `plink`.
**Test Plan**
Unit tests.
**Summary**
Fixes#4287. Throws a specific error when `child.spawn` cannot find
the executable and handles this error properly in all `git` invocations.
**Test plan**
Existing tests.
* Fix: make sure all extracted tarballs are r/w enabled
**Summary**
Fixes: #992. This issue was supposed to be fixed by #2826 but it
was not setting directory permissions wide enough. This patch uses
the `readable` and `writable` options provided by the `tar-fs`
package which essentially sets everything to `0o777`.
**Test plan**
N/A
* fewer perms
* make upgrade and upgrade-interactive compatible with workspaces
* lint
* flow
* feedback from @arcanis
* fix flow
* remove lockfile pattern for normal upgrade interactive
**Summary**
Follow up to #4286, which accidentally made `getRandomPort()` function obsolete and caused a lint warning.
**Test plan**
Existing integration tests.
* Refactors the network mutex implementation
* Improves the mutex to abort when they hang (better debug)
* Update index.js
* Update integration.js
* Feedbacks