Commit Graph

578 Commits

Author SHA1 Message Date
Raido Kuli
e0bf5873a6 fix: Use wanted package repository URL and homepage from npm (#4792)
**Summary**

Fixes #4650.

Problem is that Verdaccio (and probably Sinopia2) both are affected as they do not return "repository" nor "homepage" in top level data structure.

**Test plan**

Added new test cases. Also, manually tested with and without https://github.com/verdaccio/verdaccio as registry.
2017-11-07 10:39:16 +00:00
Burak Yiğit Kaya
c5e2dc59fe test: Fix flaky tests after #4811 due to bad assumptions (#4852)
**Summary**

Tests started failing on Travis after #4811, somewhat randomly, due to them expecting the unwrapped
output. This PR fixes those expectations and moves normalize-manifest tests to snapshots since
that's easier than updating 40+ JSON files by hand.

**Test plan**

Tests should pass on all platforms and CI and locally.
2017-11-06 11:33:53 +00:00
kaylieEB
002ce4ad70 chore(build): Replace preset-node-5 and babel-preset-es2015-node4 w/ babel-preset-env (#4374)
**Summary**
Replace [babel-preset-node 5](https://github.com/leebenson/babel-preset-node5) and [babel-preset-es2015-node4](https://github.com/jbach/babel-preset-es2015-node4) with babel-preset-env since the first two packages are deprecated and no longer maintained.

The downside is that `preset-env` is has the comprehensive list of plugins for each environment type, whereas previously packages only selected a few that we were using, so our build size increased. I'm curious to see why @yarnpkg/core 's thoughts are on this, and happy to close the PR if we'd rather stick with the old packages.

**Test plan**
Builds should build and tests should pass since there weren't any code changes 😃
2017-11-02 17:23:25 +00:00
sth
e70c067dff chore(config): Use config.production instead of isProduction() (#4824)
**Summary**

[config.js](389e02979a/src/config.js (L336)) determines if yarn runs in a production environment and sets a `production` config variable accordingly. The list command wants to know if it runs in a production environment and uses `isProduction()` to do so, which does look at environment variables, slightly different than the code in `config.js`, leading to inconsistencies in some corner cases. It should just use `config.production` instead.

`isProduction()` isn't used anywhere else and `config.production` should always be preferred, so I removed the whole function. I planned to adapt the tests of `isProduction()` for `config.production`, but the [existing tests](389e02979a/__tests__/integration.js (L82)) for `config.production` already cover all those cases.

**Test plan**
The existing tests for the `list` command still pass when they use `config.production`.
2017-11-02 10:56:37 +00:00
Calvin
b1f0e49a41 fix(cli): Display warning when adding a package already in project (#4810)
* Display warning when trying to add a package already in "dependency" to "devDependencies" or vice versa.

* Add positive and negative tests for moduleAlreadyInManifest warning

* tidy up code
2017-11-01 16:25:40 +00:00
Pierre Neter
7d40146357 feat(config): Add custom config for init private flag (#4377)
**Summary**

Here is a small custom; I add this because it relates to https://yarnpkg.com/en/docs/cli/init#toc-setting-defaults-for-yarn-init. I discovered this was necessary while writing introduces for this flag.

**Test plan**

New init and config tests.
2017-11-01 11:06:10 +00:00
Krzysztof Zbudniewek
262d7d875d fix(info): Use version from latest dist-tag instead of the highest one (#4797)
* fix(info): Use version from `latest` dist-tag instead of the highest one

Fixes #3947. By default, package `version` was set by sorting all the versions and getting the highest
one. Now it's provided via package `latest` dist-tag.

* Fix linter issues by shortening the test description

* Manually mock request

* Add scenario comment from #4804
2017-10-31 21:06:21 +00:00
Jeff Valore
1c845bd2dc fix(resolution): use registry latest if it satisfies requested semver range (#4804)
* fix(resolution): use registry latest if it satisfies requested semver range

Fixes #3560

**Summary**

Mimic behavior in NPM; use the `latest` version in registry if it
satisfies the semver range requests.

Otherwise fallback to `semver.maxSatisfying()`

**Test Plan**

Added unit test to verify behavior.

* fix eslint line len, additional field check
2017-10-31 11:49:34 -04:00
kaylieEB
4e75cb9c56 fix(resolver): Fix --frozen-lockfile flag with duplicate top level resolution (#4793)
**Summary**

Fixes #4778.

In this particular issue, the same pattern `babel-runtime@^6.26.0` was [defined in both devDependencies](https://github.com/kompot/yarn-frozen-lockfile-bug/blob/master/package.json#L80) and [resolutions field](https://github.com/kompot/yarn-frozen-lockfile-bug/blob/master/package.json#L130). Since resolutions feature was only intended for nested dependencies, it previously didn't take into account when the same exact pattern existed as a top level dependency. And it happens so that after the package resolver phase, [integrity checker looks at top level patterns](https://github.com/yarnpkg/yarn/blob/master/src/integrity-checker.js#L364-L367), so install failed.

The solution was to add top level raw patterns to resolutions map, and only remove them if they're transitive patterns

**Test plan**

Added a new test case in resolutions

*BEFORE*
<img width="618" alt="screen shot 2017-10-28 at 11 07 52 am" src="https://user-images.githubusercontent.com/18429494/32137218-621a19b8-bbd0-11e7-87a3-4acd43a44a69.png">

*AFTER*
<img width="538" alt="screen shot 2017-10-28 at 11 10 13 am" src="https://user-images.githubusercontent.com/18429494/32137229-9b828f1e-bbd0-11e7-90a2-1464c28fcab4.png">
2017-10-31 10:22:30 +00:00
Krzysztof Zbudniewek
4f41887d36 fix(git-spawn): Set GIT_SSH_VARIANT (#4806)
**Summary**

Fixes #4729.
Previous version in #4805.

Manually specify `GIT_SSH_VARIANT` in order to get package download via `git+ssh` with a non-standard port when using `plink.exe` working.

Without `GIT_SSH_VARIANT` set properly, Git won't convert `-p` into `-P` and `plink.exe` will throw an error about unknown `-p` parameter.

**Test plan**

*Before:*
![virtualbox_msedge_-_win10_30_10_2017_16_35_24](https://user-images.githubusercontent.com/5042328/32179804-9a87c676-bd90-11e7-86d0-09380d61eadf.png)

*After:*
![virtualbox_msedge_-_win10_30_10_2017_19_07_15](https://user-images.githubusercontent.com/5042328/32187512-9bcb980e-bda5-11e7-96ea-27a513837d6e.png)

Also got `git-spawn.js` test suite updated for testing `GIT_SSH_VARIANT`.
2017-10-31 09:10:09 +00:00
Carlos Ravelo
9b0e7bbd8f fix(linker): Fix yarn removing linked deps during link stage (#4757)
**Summary**

 Actual fix: changed fs.readlink to fs.realpath when checking if a symlink is a linked dependency in package-linker.js This fixes yarn removing linked deps when installing or updating.

Fixes #3288, fixes #4770, fixes #4635, fixes #4603.

Potential fix for #3202.

**Test plan**

See https://github.com/yarnpkg/yarn/issues/3288#issuecomment-335955366 for repro steps.
See https://github.com/yarnpkg/yarn/issues/3288#issuecomment-338503103 for my explanation of the problem.

With a real world test scenario this works, but I'm unable to have it break from a unit test. I added a test in the integration suite but with the bug added back in it still passes because both generated paths are identical. I would like some help with the unit test.
2017-10-26 07:35:35 -07:00
Johannes Emerich
7beaad07b0 fix(resolver): Add general support for git-over-protocol URLs (#4759)
**Summary**

Yarn can not handle the `git+https://` dependency format correctly, as described for various versions in #1625. The problem is present in Yarn 1.2.1.

A related problem for `git+ssh://` has been described in #573 and fixed in #3425.

This PR extends the solution from #3425 to use the Git fetcher for any [Git-over-protocol](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols) URLs.

**Test plan**

Extended the `package-request` unit tests to verify that the correct remote type (git) is used for `git+https://`, while the tarball remote type continues to be used for regular HTTP(S) URLs.
2017-10-26 04:38:09 -07:00
Jeff Valore
359b161ae5 feat(config): Allow JSON "//" comments in package.json resolutions (#4779)
Fixes #4774

**Summary**

Previously package.json comments were being ignored for "dependencies",
"devDependencies", "optionalDependencies".

This change adds "resolutions" to the sections that will ignore
comments.

**Test Plan**

Added unit test to make sure warning is not printed for a comment in a
resolution.
2017-10-26 02:41:17 -07:00
Josh Kelley
1ccb710169 Allow ${HOME} in .npmrc to work in Windows (#4693)
* Allow ${HOME} in .npmrc to work in Windows

Windows doesn't set the HOME environment variable by default, but NPM
has logic to set process.env.HOME based on the current OS home
directory.  See
fb28e5868a/lib/config/defaults.js (L81)

Yarn doesn't do this, so configs such as `prefix =
${HOME}/.npm-packages` that work for NPM will cause Yarn to refuse to
run.  This commit updates Yarn's behavior to be closer to NPM's.

Unlike NPM, this commit only sets HOME if it's not already set, to avoid
potentially incompatible changes with existing Yarn users.

* Revert "Allow ${HOME} in .npmrc to work in Windows"

This reverts commit 436422d5b90ccd52e6bad67720b54d7f7c59a44f.

* Allow ${HOME} in .npmrc to work in Windows

Windows doesn't set the HOME environment variable by default, but NPM
has logic to set process.env.HOME based on the current OS home
directory.  See
fb28e5868a/lib/config/defaults.js (L81)

Yarn doesn't do this, so configs such as `prefix =
${HOME}/.npm-packages` that work for NPM will cause Yarn to refuse to
run.  This commit updates Yarn's behavior to be closer to NPM's, by
using a custom/modified environment when processing NPM configurations.

Add a Flow type `Env` to represent a set of environment variables.

* Ensure environment is restored after test

(A separate `describe` block seems like overkill.)
2017-10-24 11:18:59 -07:00
Jeff Valore
3d6a03935e fix(upgrade): Let outdated filter correctly when called from upgrade. (#4763)
Fixes #4735

Upgrade was calling outdated in a way that would not filter packages that did not need
an upgrade. The led to potential backdate of package if a beta version was in use. Yarn would
backdate to the "older" latest.

Summary

Some older upgrade code I had written had a code path to have getOutdatedPackages() return all packages, not just ones that were actually outdated. My belief had been that it wouldn't cause an issue because upgrading to the same version would just do nothing... but it turns out if you are on a beta version of a package, this would cause upgrade --latest to backdate you to the actual latest.

So for example if you were currently at beta 1.0.3-0 and the registry had latest 1.0.1 then yarn upgrade --latest would backdate you to 1.0.1.

This PR reinstates the filter that only returns versions if the current is less-than the latest, which would in the above example leave the user at 1.0.3-0

Test plan

Added a unit test that would have failed previously, but passes with this PR change.
2017-10-23 16:16:30 -07:00
John Gozde
58ae45ee73 fix(linker): use lockfileFolder when creating bin links (#4730)
**Summary**

Fixes #4706, fixes #4359, refs #4513. `this.config.cwd` was being used as the root for bin link paths, rather than `this.config.lockfileFolder`.

**Test plan**

- Added tests for `add` and `remove` commands (#4706)
- Added test for `install` command (#4359)
2017-10-20 00:54:57 +01:00
Jeff Valore
95a3aa9538 Do not convert empty string to cwd path. (#4700)
* [#4695] Do not convert empty string to cwd path.

* added test file for config.js
2017-10-16 11:24:00 +01:00
Lewis Zhang
de26f05c1f chore(tests): Fix typo s/genereate/generate (#4716) 2017-10-16 11:19:36 +01:00
Maël Nison
86c4aff938 Adds an extra test for the yarn path feature (#4680) 2017-10-12 11:10:53 +01:00
Burak Yiğit Kaya
f60269f762 fix(resolver): Fix incorrect peer dependency res. from different trees (#4687)
**Summary**

Fixes #4539. Yarn was resolving peer dependencies from the closest level where the peer dependency was requested
but it was not checking if the peer dependency was in the same subtree. This was causing incorrect
peer dependency resolutions and package duplication when  an unrelated subtree has a depedency
satisfying the required peer dependency at the same tree level.

**Test plan**

Added new install integration test that fails without the fix.
2017-10-11 23:48:28 +01:00
Jeff Valore
5e564c6879 Upgrade transient deps during upgrades. (#4636)
* [#4476] Upgrade transient deps during upgrades.

* Rename 'transient' to 'transitive'

* dont upgrade direct deps unless requested, add verbose upgrade logging

* upgrade-interactive reuse lockfile cleaning from upgrade.js
2017-10-11 17:26:22 +01:00
yerguden
80e7c39f60 fix(init): prevent init command from traversing up (#4464)
**Summary**

Fixes #4441.

**Test plan**

Added new test case.
2017-10-11 12:55:38 +01:00
Daniel Tschinder
77f5e40c6a compare current version against latest and not wanted version in outdated command (#4519)
**Summary**
`current` and `wanted` version might be the same but `latest` is a new major version
and as current and wanted are compared against each other it results in most outdated entries being white instead of the proper color

Here a before/after screenshot:

![bildschirmfoto 2017-09-22 um 13 41 56](https://user-images.githubusercontent.com/231804/30743120-9efa6824-9f9c-11e7-9f17-7b511597e13b.png)
2017-10-10 11:55:58 -07:00
Burak Yiğit Kaya
2718d7491c fix(config): Relay exit code when using yarn-path from yarnrc (#4669)
**Summary**

Follow up to #4204. We forgot to relay the exit code of the
newly spawned yarn instance when using `yarn-path` which is
causing false negatives especially when using `yarn run`. This
patch relays the exit code of the spawned process.

**Test plan**

Added a new test that fails without the fix.
2017-10-09 21:12:02 +01:00
John Gozde
7323861f08 Fix: workspace support in several commands (#4654)
* Use lockfileFolder for CLI check

* Make "upgrade" work inside workspace packages

Executes "fetchRequestFromCwd" in actual cwd, which ensures
"outdated" and "upgrade" commands in workspace packages
operate on the correct dependencies and preserve unrelated lockfile
entries.

* Support workspaces in outdated and upgrade-interactive
2017-10-09 19:04:43 +01:00
Burak Yiğit Kaya
850e71f491 fix(git): Refactor Git URL resolution code & remove hash from URL (#4657)
**Summary**

This PR is triggered by https://git.io/vdzI2. It refactors the
code to allow more hosted Git expansions (like GitLab) in a more
flexible way. It also prefers `url.parse` over regular expressions
and removes any hasehs in `GitUrl.repository` results.

**Test plan**

Existing tests should pass along with the hash removal correction.
2017-10-08 17:39:10 +01:00
Burak Yiğit Kaya
69004e9a71 fix(config): Don't override registry with undefined by default (#4643)
**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.
2017-10-06 11:53:29 +01:00
Burak Yiğit Kaya
9c2bbca921 chore(resolver): Minor improvements in resolver code and tests (#4644)
* chore(resolver): Minor improvements in resolver code and tests

**Summary**

This is a follow up to #4484 and #4478 which improves the code
around those areas a bit and removes a now-unnecessary `while`
loop.

**Test plan**

Existing tests should pass.

* Fix logic
2017-10-06 11:51:43 +01:00
Nikhil Motiani
633b28168d fix(resolver): parentNames is missing in package warning breadcrumbs (#4484)
**Summary**

Bugfix for #4480. Change suggested by @BYK 

**Test plan**
Running yarn on local.

_**Before Changes**_
```bash
warning node-uuid@1.4.8: Use uuid module instead
```

_**After Changes**_
```bash
warning raven > node-uuid@1.4.8: Use uuid module instead
```
2017-10-05 16:46:09 +01:00
Valerii Iatsko
972166c166 chore(tests): Make integration tests passing on Node 7 (#4606)
**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.
2017-10-05 16:41:31 +01:00
Maël Nison
e28603481f Improves the workspaces (#4630) 2017-10-05 15:58:44 +01:00
Valerii Iatsko
3178e076d4 chore(utils): replace last expandPath with resolveWithHome (#4605)
**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.
2017-10-04 20:51:27 +01:00
Phil Quinn
4a0898e683 Add ability to upgrade based on pattern (#4610) 2017-10-04 12:27:33 +01:00
Phil Quinn
03f1ecc6ee Add ability to filter yarn list with pattern (#4609) 2017-10-04 12:26:33 +01:00
Ryan Hendrickson
38790e81de fix(run): improve escaping for script arguments (#4135)
**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.)
2017-10-03 17:56:45 +01:00
Liran Tal
6b5756374f feat(configuration): add custom registry cli flag (#4238)
**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.
2017-10-03 17:16:59 +01:00
Cameron Hunter
e3004ab371 chore(tests): Add failing test-case for issue #2636 (#4598)
**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.
2017-10-03 13:42:43 +01:00
Phil Quinn
4638161a7f Fix: allow package without manifest to be removed (fixes #4310) (#4599) 2017-10-03 11:16:32 +01:00
Phil Quinn
1276e3ff44 Feature: Add ability to filter yarn cache (fixes #3200) (#4571) 2017-10-03 11:05:16 +01:00
Burak Yiğit Kaya
8580a5831e Fix: always prefer CLI options over env for --prod (#4572)
**Summary**

Fixes #4557. Also adds `yarn config current` that lists the current
configuration as JSON for testing purposes.

**Test plan**

Added integration tests.
2017-09-28 20:16:58 +01:00
Matt Mulder
391eadeed3 Fix: respect patterns with "||" in the range during optimizeResolutions (#4562)
**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"
2017-09-28 00:13:13 +01:00
Burak Yigit Kaya
19b09975e9 Chore: fix tests after the new release 2017-09-25 11:13:18 +01:00
Matt Mulder
4020ccd0a3 Fix: unbound transitive dependencies should not conflict with top level dependency (#4488)
**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"
2017-09-22 14:12:42 +01:00
Kay.L
085064d662 Fix: Upgrade Chalk to take advantage of the latest (colour) fixes (#4482)
**Summary*

Fixes #4424. The latest Chalk has fixes to Windows 10 / MacOS and more would improve the color detection in different env.

https://github.com/chalk/supports-color/blob/master/index.js#L48
https://github.com/chalk/supports-color/blob/master/index.js#L78

**Test plan**

Existing and updated tests. Also manual verification.
2017-09-21 12:39:16 +01:00
Burak Yiğit Kaya
002d39c9b1 Fix: fix argument parsing and .yarrc argument passing (#4498)
**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`.
2017-09-20 01:51:12 +01:00
Burak Yiğit Kaya
e52e8b18c9 Fix: make lockfile parser tolerant to CRLF (#4495)
**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.
2017-09-19 10:18:29 +01:00
Burak Yiğit Kaya
d64512c632 Fix: Better npm_config_argv emulation (#4479)
**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.
2017-09-18 22:07:28 +01:00
Aleksei Gusev
3124c91c99 Chore: Free tests from FORCE_COLOR environment variable dependency (#4381)
**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.
2017-09-18 16:55:27 +01:00
Ahmed El Gabri
0e16ee9a3e Feature: Support save-exact true (#4471)
**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.
2017-09-17 01:47:27 +01:00
Burak Yiğit Kaya
96c215c1ce Fix: Resolve peerDependencies from all higher levels, not just root (#4478)
**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.
2017-09-16 11:16:17 +01:00