1754 Commits

Author SHA1 Message Date
Burak Yigit Kaya
b777ff97a9 Fix: Handle null versions in package.json
**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.
2017-09-14 20:24:21 +01:00
Burak Yiğit Kaya
ef8185b015 Fix: incorrect optional ignore in nested dependencies (#4448)
**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.
2017-09-14 17:30:18 +01:00
Chaitanya Kumar Kamatham
cf3a5f2146 Fix: inaccurate message when using -g with add (#4449)
**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.
2017-09-14 15:13:10 +01:00
Burak Yiğit Kaya
738df577c8 Update: add DNS caching to request manager (#4447)
**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.
2017-09-14 02:59:44 +01:00
Kay.L
72bdb82317 Fix: use simpler charaters for progress bar to avoid overflows (#4317)
**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:
![new progress bar chars](https://i.imgur.com/d8XA4yS.gif)

**Test plan**

Manual verification and updating of existing test snapshots.
2017-09-13 23:59:02 +01:00
Martin
78a5f3379f Chore: Add test for isFakeRoot (#4435)
**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
2017-09-13 22:16:34 +01:00
Orta
975d880023 Update: Bolds the titles in a list (#4406)
**Summary**

Not substantial. It makes it easier to differentiate the items in a list vs the hint. Here is the before:

![screen shot 2017-09-11 at 3 18 25 pm](https://user-images.githubusercontent.com/49038/30292973-0431c13c-9706-11e7-95da-f32452154004.png)

and the after:

![screen shot 2017-09-11 at 3 20 57 pm](https://user-images.githubusercontent.com/49038/30292985-1133c164-9706-11e7-813e-c26f422f068d.png)


**Test plan**

Existing unit tests.
2017-09-13 22:09:22 +01:00
Burak Yigit Kaya
5786d3a555 v1.0.2 v1.0.2 2017-09-13 17:26:40 +01:00
Nick Olinger
27f6d09b81 Fix: don't throw when user exits from upgrade-interactive (#4434)
**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 :)
2017-09-13 17:23:56 +01:00
Martin
61f64ff3b4 Fix: fakeroot detection is broken (inversed) (#4431)
**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.
2017-09-13 16:20:43 +01:00
Peter Dotchev
5386c41979 Fix: actual and expected hashes are swapped (#4416)
**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.
2017-09-13 13:01:44 +01:00
Jeff Held
274a26a3d3 Fix: Diffing identical versions should not include extra period at end (#4428)
**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)
2017-09-13 11:08:36 +01:00
Burak Yiğit Kaya
52ef037c79 Fix: always output reporter.inspect values and config get result (#4419)
**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.
2017-09-12 18:47:49 +01:00
Burak Yiğit Kaya
ccf5812b9b Chore: fix flaky add tests by using separate cache (#4418)
* 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
2017-09-12 09:19:33 -07:00
Karolis Narkevicius
939a130194 Fix: allow / in addition to %2f in the url for scope checks (#4367)
**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.
2017-09-12 15:36:28 +01:00
Burak Yiğit Kaya
eafd2287ff Chore: add missing cache packages for tests (#4414) 2017-09-12 14:12:19 +01:00
Burak Yiğit Kaya
3f94e774bf Chore: fix misues of -p in node infocations (#4415)
**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.
2017-09-12 14:11:40 +01:00
Burak Yiğit Kaya
cb3c7fe9a5 Fix: fix incorrect argument parsing (#4384)
**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.
2017-09-12 13:41:02 +01:00
kaylieEB
4e3ecf8a38 Fix: Include pull requests in git ref search (#4411)
**Summary**

Fixes https://github.com/yarnpkg/yarn/issues/4369, a regression from previous refactor.
Include `pull` requests in ref search and test for it later when it's called by github resolver.

*BEFORE*
![before](https://user-images.githubusercontent.com/18429494/30309691-7aeabe2e-9741-11e7-8e34-c75413b83d99.png)


*AFTER*
![after](https://user-images.githubusercontent.com/18429494/30309693-7dcc3528-9741-11e7-8a74-bc7585fd6177.png)

**Test plan**

Added a unit test in `git/git-ref-resolver.js`
2017-09-12 10:54:57 +01:00
Burak Yiğit Kaya
1fde50aeb5 Fix: yarn bin should produce output even when silent (#4408)
**Summary**

Fixes #4371.

**Test plan**

Manual verification: `yarn --silent bin` or `YARN_SILENT=1 yarn bin` should produce output.
2017-09-12 07:49:04 +01:00
kaylieEB
c76a8bb280 Fix: Allow resolver to delay resolutions for nested dependencies (#4372)
**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
2017-09-11 20:55:58 +01:00
Burak Yiğit Kaya
5bc24775e3 Fix: add back -L shortcut for yarn upgrade (#4401)
**Summary**

Fixes #4397.

**Test plan**

Manual verification.
2017-09-11 18:00:33 +01:00
Burak Yiğit Kaya
23713e57d6 Chore: add instructions about using local builds (#4386) 2017-09-11 06:25:13 +03:00
Burak Yiğit Kaya
bcaf845e87 Fix: don't generate a lockfile when --frozen-lockfile is used (#4385)
**Summary**

Fixes #4344.

**Test plan**

Added new test.
2017-09-11 00:22:19 +03:00
Mark Yu
b33fe264db Fix: argument -v is for version not verbose (#4362)
**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

```
2017-09-09 00:28:19 +03:00
Burak Yiğit Kaya
85281cb134 Fix: only switch to help mode for valid commands (#4355)
**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.
2017-09-09 00:26:02 +03:00
Burak Yiğit Kaya
b5e37906dd Fix: remove the accept header from tar fetcher requests (#4351)
**Summary**

Fixes #3833. Removes `accept` header from tar requests as @arcanis suggested since `application/octet` wasn't ensuring any valid tar file and `npm` client does not send this header anyway.

**Test plan**

Run `yarn add http://prerelease.componentone.com/wijmo5/npm-images/C1Wijmo-Enterprise-Eval-System-5.20172.328.tgz`

It fails without the patch, installs correctly with the patch.
2017-09-09 00:25:38 +03:00
Burak Yiğit Kaya
161f97e702 Fix: support protocol-relative registry URLs (#4347)
**Summary**

Fixes matching protocol-relative registry URLs from config.
Reported here: https://github.com/yarnpkg/yarn/pull/3987#discussion_r137624001

**Test plan**

Added one new test.
2017-09-09 00:25:04 +03:00
Burak Yiğit Kaya
d3f223c331 Fix: fix support for registry URLs without trailing slash (#4350)
**Summary**

Fixes #4339. Also fixes handling of upper-case registry names.

**Test plan**

Added unit tests for `NpmRegistry.prototype.getRequestUrl()`.
2017-09-08 11:31:13 +01:00
Dylan Greene
6295408a74 Fix: Fix regex so single-character @scopes can work again (#4338)
**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?
2017-09-08 07:54:29 +03:00
Maël Nison
5ea8ea7f9c 1.0.1 v1.0.1 2017-09-07 14:19:44 +01:00
Aditya Vohra
aeb89c0684 Add npm_lifecycle_script to env in makeEnv (#4330)
* Add npm_lifecycle_script to env in makeEnv

* Update execute-lifecycle-script.js
2017-09-07 14:10:34 +01:00
Burak Yiğit Kaya
03a16d0549 Fix: More resillient global and cache folder determination (#4325)
* 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
2017-09-07 11:47:25 +01:00
kaylieEB
739933e353 Add inline comments to improve readability of PR #4278 (#4318)
* add comments

* rewording
2017-09-06 14:19:34 +01:00
Connor Chase
cddb2bc378 Chore: Better grammer on README (#4211) 2017-09-06 11:20:50 +03:00
Burak Yiğit Kaya
0b807b48b0 Chore: fix info tests (#4316)
**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.
2017-09-05 20:19:44 +03:00
Maël Nison
7fbd78f1c2 1.0.0 v1.0.0 2017-09-05 15:11:12 +01:00
Burak Yiğit Kaya
73921a6eb5 Fix: respect GIT_SSH env variable when calling Git and support plink (#4302)
**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.
2017-09-05 13:29:53 +03:00
Maël Nison
49de069009 Fixes yarn why when using workspaces (#4304) 2017-09-05 11:01:00 +01:00
Burak Yiğit Kaya
b8f8b7c3b8 Fix: show better error messages when Git is not found (#4312)
**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.
2017-09-05 10:24:41 +01:00
Burak Yiğit Kaya
de7cefc312 Fix: make sure all extracted tarballs are r/w enabled (#4301)
* 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
2017-09-04 22:08:06 +01:00
kaylieEB
da2b909605 Fix 4263: Make upgrade and upgrade-interactive compatible with workspaces (#4278)
* make upgrade and upgrade-interactive compatible with workspaces

* lint

* flow

* feedback from @arcanis

* fix flow

* remove lockfile pattern for normal upgrade interactive
2017-09-04 22:07:13 +01:00
Burak Yiğit Kaya
9ba68a4d2d Chore: use the orphaned getRandomPort function in tests (#4303)
**Summary**

Follow up to #4286, which accidentally made `getRandomPort()` function obsolete and caused a lint warning.

**Test plan**

Existing integration tests.
2017-09-04 21:55:40 +03:00
Maël Nison
a22287e083 Prevent linking binaries from workspaces (#4288) 2017-09-04 18:35:10 +01:00
Maël Nison
593e243364 Fix: Always close the reporter before exiting (#4283)
* Prevents the memory controls from hanging the process

* Update base-reporter.js

* Adds a test
2017-09-04 18:07:47 +01:00
Maël Nison
ce69264945 Refactors the network mutex implementation (#4286)
* Refactors the network mutex implementation

* Improves the mutex to abort when they hang (better debug)

* Update index.js

* Update integration.js

* Feedbacks
2017-09-04 15:41:05 +01:00
Carl Rosell
4bb34e2c47 Fix #4214: Align column headers for upgrade-interactive command (#4268)
Summary
Fix for issue #4214 by using the first suggested solution from the issue itself. For more info see the issue 😃
2017-08-29 10:50:42 -07:00
Maël Nison
d500ef2271 Disables linking transitive dependencies on global installs (#4265)
* Disables linking transitive dependencies on global installs

* Update package-linker.js

* Update global.js

* Update global.js
2017-08-29 13:47:38 +01:00
Jeff Valore
915e775c66 rename clean to autoclean, add tests (#4252)
* rename clean to autoclean, add tests

* fix tests. expect statements were not being run.
2017-08-29 11:16:42 +01:00
kaylieEB
b4c35168b4 Fix #3697 Improve error handling when tarball fetcher receives bad hash (#4240)
* test

* alter commit message

* update snapshot

* review feedback

* move to unlink files in all failed blocks

* lint

* Update tarball-fetcher.js
2017-08-29 10:49:12 +01:00