**Summary**
Follow up to #4238. We were always passing the `registry` key in
registry overrides but its value was `undefined` when an override
was not in place. `Object.assign` doesn't care about that though
so we were overriding the registry all the time, mostly with
`undefined`.
**Test plan**
Added new test case.
**Summary**
The change introduced in 96c215c1ce caused tests to fail on node 7 as react-scripts is not compatible with it. This patch adds `--ignore-engines` flag to suppress the warning.
**Test plan**
Tests should pass on Node 7.
* chore(tests): Don't output coverage on regular test runs
**Summary**
We output a long coverage summary in both CI and local tests which
just adds noise to the output, especially when tests are failing
and one is trying to figure out what is wrong. Since this
information is not used by any automatic tooling, it is better to
disable it for now. This PR keeps the option with `test-coverage`
script for people who still want it.
**Test plan**
When running `yarn test` you should not see a long coverage table
at the end after the patch.
* some fixes
* Revert "some fixes"
This reverts commit 75ca538995.
**Summary**
Looking at two solutions introduced in #3393 and #3756, the first one doesn't support win32, while the second does, sticking with the second one more beneficial and supports a wider range of OS.
Removed the stuff introduced in #3393 keeping only #3756.
#3756 also introduced config file normalization, so probably second argument to getOption is obsolete, will discover that and submit another PR if that's the case.
**Test plan**
Modified tests appropriately.
**Summary**
Sometimes Yarn saturates the network and sometimes the network itself
has issues, especially on CI and Yarn reports this as a warning. This
should be a simple info message unless it actually completely fails.
This also fixes a flaky integration test with react-scripts.
**Test plan**
`react-scripts` integration test should not be flaky anymore.
**Summary**
Fixes#4546. Previous behavior was that if `.npmrc` or `.yarnrc` contained and `http-proxy` but not an `https-proxy`, HTTPS requests would "fall back" to the `http-proxy`.
This is not always the desired behavior; See #4546 sometimes one protocol needs a proxy and the other does not.
This PR adds the ability to set the `https-proxy` to `false` which will cause Yarn to not use an HTTPS proxy (and not fall-back to the HTTP proxy). This allows the code to treat `undefined` as the setting not being specified (which will fall back to http-proxy) and `false` as the setting being specified, but set to false (which will not use a proxy).
**Test plan**
Tested manually on Windows with Fiddler.
I have no idea how to test this since requests go through the mock http requester when running tests. Suggestions welcome!
**Summary**
Extra command-line arguments to scripts were not being escaped correctly. This patch adds robust shell quoting logic for both Windows and Linux/macOS.
**Test plan**
On *nix, create a `package.json` containing `"scripts":{"echo":"echo"}`. Run `yarn run -s echo -- '$X \"blah\"'`. Expect to observe ` \blah\` prior to this patch, and `$X \"blah\"` after it.
Testing on Windows should be similar, but may require fancier escaping to get the arguments into yarn in the first place. (I don't have access to a Windows box to verify the exact procedure to follow, sorry—but I did confirm that my automated tests succeed in AppVeyor.)
**Summary**
implements #792 - addresses a command line flag --registry to specify a registry that overides yarn/npm configuration for installing dependencies.
**Test plan**
Added new tests.
**Summary**
Fixes#4550. The optimization introduced in #4488 should only
apply to flat installations since even if a single pattern can
satisfy all resolved versions, it is not guaranteed that it is
strict enough for resolving correctly for all patterns under all
circumstances.
**Test plan**
Manual verification.
**Summary**
This is a failing test-case for issue #2636. It tests that bundled dependencies are not correctly being included in the archive created by `yarn pack`.
**Test plan**
Changing the behavior of `pack` to include the bundled dependencies should make this failing test-case pass.
**Summary**
I removed the *.gz from the default .yarnclean generated by the `yarn autoclean --init` command.
**Test plan**
I tested by hand and launch `yarn test` and didn't find a test case for the autoclean --init option. If needed I could write a test case to check the default .yarnclean file content against the constant DEFAULT_FILTER.
I hope it resolve half the issue #4450 :)
**Summary**
This addresses some of the windows issues regarding running yarn in gitbash and friends envrionment.
with this fix I keep the behavior introduced 5 months ago in yarnpkg/yarn#3245, but try to do a better job detecting when to use winpty out of the box, in order make `piping` of output work with yarn.
Before this fix:
```shell
$ yarn --version
1.1.0
$ yarn --version | cat
1.1.0
$ yarn init
yarn init v1.1.0
error An unexpected error occurred: "Can't answer a question unless a user TTY".
info If you think this is a bug, please open a bug report with the information provided in "D:\\workspace\\yarn\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/init for documentation about this command.
```
Piping works for simple commands, but interactive commands only work with an environment set to something. This prohibits scripts/tools around yarn that uses pipe, which is quite common to do in an unix like environment, but theses tools cannot work in windows' unix like environment.
WinPTY seems to be the savior here, but we need to only run yarn through winpty when a tty actually needs to be allocated.
Previous attempts to solve this problem like:
- yarnpkg/yarn#2230
- yarnpkg/yarn#2243
Did not address the use cases of piping, so they essentially broke that behavior.
Then yarnpkg/yarn#3245 fixed that, but now you have to use `YARN_FORCE_WINPTY=1` environment variable in order for `yarn init` and `yarn upgrade-interactive` to work and that's alright, but if you export that variable then piping is broken yet again because the variable will also be set in the piped command, and we haven't solved any problem.
I suggest we keep the environment variable behavior but open up for better detection when to use winpty out of the box.
This fix detects if the winpty binary is in path, and only use it if stdin is in fact a TTY: `test -t 1`.
**Test plan**
The output of running:
- `yarn init`
- `yarn upgrade-interactive`
- `yarn --version | cat`
Without having the `YARN_FORCE_WINPTY=1` environment variable set.
```shell
$ ./bin/yarn init
yarn init v1.1.0
question name (yarn):
$ ./bin/yarn upgrade-interactive
yarn upgrade-interactive v1.1.0
info Color legend :
"<red>" : Major Update backward-incompatible updates
"<yellow>" : Minor Update backward-compatible features
"<green>" : Patch Update backward-compatible bug fixes
? Choose which packages to update. (Press <space> to select, <a> to toggle all, <i> to inverse selection)
devDependencies
name range from to url
>( ) babel-core ^6.24.1 6.24.1 ❯ 6.26.0 https://babeljs.io/
( ) babylon ^6.5.0 6.17.1 ❯ 6.18.0 https://babeljs.io/
( ) eslint ^4.3.0 4.3.0 ❯ 4.7.2 http://eslint.org
( ) eslint-config-fb-strict ^20.1.0-delta.3 20.1.0-delta.3 ❯ 20.1.0-echo.1 https://github.com/facebook/jest#readme
( ) eslint-plugin-babel ^4.0.0 4.1.1 ❯ 4.1.2 https://github.com/babel/eslint-plugin-babel#readme
( ) eslint-plugin-flowtype ^2.35.0 2.35.0 ❯ 2.36.0 https://github.com/gajus/eslint-plugin-flowtype#readme
( ) eslint-plugin-jasmine ^2.6.2 2.6.2 ❯ 2.8.4 https://github.com/tlvince/eslint-plugin-jasmine
( ) eslint-plugin-prettier ^2.1.2 2.1.2 ❯ 2.3.1 https://github.com/prettier/eslint-plugin-prettier#readme
( ) eslint-plugin-react ^7.1.0 7.1.0 ❯ 7.4.0 https://github.com/yannickcr/eslint-plugin-react
( ) eslint-plugin-yarn-internal file:scripts/eslint-rules 0.0.0 ❯ exotic file:scripts/eslint-rules
( ) gulp-sourcemaps ^2.2.0 2.6.0 ❯ 2.6.1 http://github.com/gulp-sourcemaps/gulp-sourcemaps
( ) prettier ^1.5.2 1.5.2 ❯ 1.7.2 https://prettier.io
( ) webpack ^2.1.0-beta.25 2.6.0 ❯ 2.7.0 https://github.com/webpack/webpack
dependencies
name range from to url
( ) babel-runtime ^6.0.0 6.23.0 ❯ 6.26.0 https://github.com/babel/babel/tree/master/packages/babel-runtime
( ) commander ^2.9.0 2.9.0 ❯ 2.11.0 https://github.com/tj/commander.js#readme
( ) debug ^2.2.0 2.6.8 ❯ 2.6.9 https://github.com/visionmedia/debug#readme
( ) gunzip-maybe ^1.4.0 1.4.0 ❯ 1.4.1 https://github.com/mafintosh/gunzip-maybe
( ) inquirer ^3.0.1 3.0.6 ❯ 3.3.0 https://github.com/SBoudrias/Inquirer.js#readme
( ) node-emoji ^1.6.1 1.6.1 ❯ 1.8.1 https://github.com/omnidan/node-emoji#readme
( ) request ^2.81.0 2.81.0 ❯ 2.83.0 https://github.com/request/request#readme
( ) rimraf ^2.5.0 2.6.1 ❯ 2.6.2 https://github.com/isaacs/rimraf#readme
( ) semver ^5.1.0 5.3.0 ❯ 5.4.1 https://github.com/npm/node-semver#readme
( ) tar-fs ^1.15.1 1.15.2 ❯ 1.15.3 https://github.com/mafintosh/tar-fs
( ) uuid ^3.0.1 3.0.1 ❯ 3.1.0 https://github.com/kelektiv/node-uuid#readme
$ ./bin/yarn --version | cat
1.1.0
$
```
And importantly when running the interactive commands through a pipe, it will correctly fail by saying you not are running the interactive commands in a TTY:
```shell
$ ./bin/yarn init | cat
yarn init v1.1.0
error An unexpected error occurred: "Can't answer a question unless a user TTY".
info If you think this is a bug, please open a bug report with the information provided in "D:\\workspace\\yarn\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/init for documentation about this command.
$ ./bin/yarn upgrade-interactive | cat
yarn upgrade-interactive v1.1.0
info Color legend :
"<red>" : Major Update backward-incompatible updates
"<yellow>" : Minor Update backward-compatible features
"<green>" : Patch Update backward-compatible bug fixes
Done in 1.43s.
Error: Can't answer a question unless a user TTY
at D:\workspace\yarn\lib\reporters\console\console-reporter.js:487:31
at Generator.next (<anonymous>)
at step (D:\workspace\yarn\node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
at D:\workspace\yarn\node_modules\babel-runtime\helpers\asyncToGenerator.js:35:14
at Promise (<anonymous>)
at F (D:\workspace\yarn\node_modules\core-js\library\modules\_export.js:35:28)
at D:\workspace\yarn\node_modules\babel-runtime\helpers\asyncToGenerator.js:14:12
at ConsoleReporter.prompt (D:\workspace\yarn\lib\reporters\console\console-reporter.js:518:7)
at Object.<anonymous> (D:\workspace\yarn\lib\cli\commands\upgrade-interactive.js:116:38)
at Generator.next (<anonymous>)
```
**Summary**
Fixes#4557. Also adds `yarn config current` that lists the current
configuration as JSON for testing purposes.
**Test plan**
Added integration tests.
**Summary**
Follow up to #4486 which reverted the while loop that waits on
potential multiple copies of the same file. This seems to have
some random breakages and needs more investigation for optimizing.
**Test plan**
N/A
**Summary**
Fixes#4547 by testing each version against all ranges individually, rather than munging the patterns together to get a single range.
**Test plan**
Existing tests, plus a regression test to repro #4547: "manifest optimization respects versions with alternation"
Move publish, prepublish and prepare hooks to run before tar ball is
created.
Also switch the order of prepare to be consistent with
https://docs.npmjs.com/misc/scripts
**Summary**
Refs #3751. Changes `reporter.warn` to `reporter.verbose` for the message "The case-insensitive file ${dest} shouldn't be copied twice in one bulk copy".
**Test plan**
Manual verification.
**Summary**
Yarn 1.1.0 release failed due to a bug in npm@5:
https://github.com/npm/npm/issues/16723. This patch uses `npx` to
force using `np@4` when publishing in `update-npm.sh`.
**Test plan**
CircleCI
**Summary**
Fixes#2652. Adds a `yarn global dir` command that prints the output
of the global installation folder that houses the global `node_modules`.
**Test plan**
Manual verification.
**Summary**
Fixes#3780, and makes the failing test from #3779 passing.
As a final step of package resolution, for each dependency we check whether any version satisfies all resolved version ranges.
**Test plan**
Fixes an existing (failing) test: "unbound transitive dependencies should not conflict with top level dependency"
**Summary**
This is a bugfix for the following error which happens on master
```
❯ yarn outdated
yarn outdated v1.0.2
error An unexpected error occurred: "this.format.stripColor is not a function".
info If you think this is a bug, please open a bug report with the information provided in "/Users/danieltschinder/Documents/ResearchGate/PHP/community/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/outdated for documentation about this command.
```
chalk 2.0 removed stripColor see https://github.com/chalk/chalk/releases/tag/v2.0.0 and this wasn't respected in #4482
**Test plan**
Manual verification.
**Summary**
Fixes#4501, refs #4490, refs #4284. Yarn now warns when it
detects it is running in a Node version that is not fully
supported and warns the user about this. This is different than
the hard Node 4+ check in the entry file since in that case,
Yarn wouldn't run at all due to syntax incompatibilities. This
warning is to signal that users may encounter unexpected errors
but are allowed to use Yarn if they wish. It also adds a new
flag to suppress this warning: `--no-node-version-check`.
**Test plan**
Since we cannot add unsupported Node versions to our CI and
spoof the Node version internally, this has to be tested
manually, which I did.
**Summary**
Fixes#4457, partially handles #4470. `.yarnrc` argument passing logic was not aligned with
how `commander` works. Even more, `commander`'s boolean logic was
also not used correctly. This patch fixes both, allowing use of
boolean type CLI options both ways (enable/disable) both from the
command line and `.yarnrc` file.
**Test plan**
Added new integration test for getting args from `.yarnrc`.
**Summary**
Lockfile parser fails when the lockfile had Windows-style line
endings with an "Invalid token" error. This is default on Windows
and, say when editing the file using vim, it is not obvious or
trivial that the file endings are in Windows-style. This patch
makes the parser tolareate potential "\r" chars before "\n" while
keeping the existing parsing logic the same.
**Test plan**
Added three new unit tests.
* Fix: always use origin/master instead of master for homebrew
**Summary**
Fixes#3415. The old homebrew update script updated the repo
from remote but did not update the local `master` branch, thus
had the potential for conflicts and mismatches. This patch
forces it to use `origin/master` instead and uses the latest
up-to-date version from the source.
**Test plan**
N/A
* Stay on master
**Summary**
Fixes#2226. Better emulates `npm_config_argv` by passing
`process.argv.slice(2)` as the `original` portion and both the
command name and the script name in `cooked` portion.
**Test case**
Added integration tests.
**Summary**
FORCE_COLOR environment variable allows to force yarn to use
colors. This makes some of tests fail because of comparing
colorized output with plain strings.
For example, if you run a test in environment where
FORCE_COLOR is set you get this failure:
```
FAIL __tests__\index.js
● should add package
expect(received).toEqual(expected)
Expected value to equal:
"success Saved lockfile."
Received:
success Saved lockfile."
```
**Test plan**
Run tests in an environment where `FORCE_COLOR` is enabled. They should pass.
**Summary**
Fixes#4331. Supersedes #3290. Uses the newly added `fs.copyFile`
on Node 8.5 hen available and falls back to the old buffer based
method otherwise. This patch also refactors the file copy code a
bit making it more efficient. Here are the durations on my computer
with [this package.json](c0ded8b82b/perf/project/alottafiles/package.json):
| master | w/o copyFile | w/ copyFile |
| - | - | - |
| ~23s | ~19s | ~14s |
This is with `yarn.lock` in place and w/o `node_modules`.
**Test plan**
CI should pass.
**Summary**
Fixes#4343. Currently there is no way to remove the package prefix inside `.yarnrc` file, this PR add support for `save-exact` in `.yarnrc` as discussed in #4343. Full credit goes to @jambonrose
```
save-exact true
```
One small thing, should `yarn` be backwards compatible with the old behavior which is `save-prefix ''`? We can just add an extra check here for do this. What do you think @BYK?
```js
} else if (exact || Boolean(this.config.getOption('save-exact')) || Boolean(this.config.getOption('save-prefix'))) {
```
**Test plan**
New unit test.
**Summary**
Fixes#4446, fixes#4433, fixes#2688, fixes#2387. Follow up to #3803. The fix in #3893 was
too aggressive, allowing only top-level dependencies to be used in
peer dependency resolution which was incorrect. This patch allows
resolving peer dependencies from the same or higher levels in the
dependency tree.
**Test plan**
Additional unit and integration tests.
**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.