2214 Commits

Author SHA1 Message Date
Zoran Regvart
fb03788279 fix(pnp): make sure that the package locator is fetched with a trailing slash (#6882)
* fix(pnp): make sure that the package locator is...

... fetched with a trailing slash

I could not get P'n'P working on a project using `critical`[1] and
traced it down to a lookup of a package locator without a trailing
slash.

A `require('resolve').sync('fg-loadcss')` from `inline-critical`[2]
would fail to resolve as the `locatorsByLocations` lookup in `.pnp.js`
would be using a key without a trailing slash, i.e.:

```
"../../.cache/yarn/v4/npm-inline-critical-4.0.7-3ffba6a869f39215c8bb00ed2dd6b872e7f98adc/node_modules/inline-critical"
```

`findPackageLocator` is invoked with `location` parameter (notice no
trailing slash):

```
location = "/home/zregvart/.cache/yarn/v4/npm-inline-critical-4.0.7-3ffba6a869f39215c8bb00ed2dd6b872e7f98adc/node_modules/inline-critical"
```

from `resolveToUnqualified` with parameters:

```
request = "fg-loadcss/package.json"
issuer = "/home/zregvart/.cache/yarn/v4/npm-inline-critical-4.0.7-3ffba6a869f39215c8bb00ed2dd6b872e7f98adc/node_modules/inline-critical"
```

All starting from `loadNodeModulesSync` in `resolve`'s `sync.js`[3]
that ends up having `absoluteStart` without the trailing slash.

Not sure if this is the most correct way of fixing this issue, by just
ensuring that the trailing slash needed for the lookup is added if
missing.

All tests from `yarn test` and from `packages/pkg-tests`
`yarn jest yarn.test.js` pass, so it seems like a start.

This is how to reproduce:

package.json:
```json
{
  "name": "require-failure",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "install": "node --require ./.pnp.js index.js"
  },
  "devDependencies": {
    "critical": "^1.3.4"
  },
  "installConfig": {
    "pnp": true
  }
}
```

index.js:
```javascript
require('critical').generate({
  inline: true,
  html: '<!DOCTYPE html><html><head><link rel="stylesheet" href="site.css"></head><body><h1>Hello</h1></body></html>'
});
```

site.css:
```css
h1 { font-weight: bold; }
```

Not sure how to create a package test from that example (sorry).

[1] https://github.com/addyosmani/critical
[2] 340db21f6a/index.js (L32)
[3] 254bb4029d/lib/sync.js (L52)

* Update CHANGELOG.md
2019-01-14 15:09:57 +00:00
Pascal Berger
c2283af55e Improve rendering of Chocolatey package description (#6899)
* Improve rendering of Chocolatey package description

* Update yarn.nuspec
2019-01-14 15:03:02 +00:00
Travis Hoover
1aee5202b0 Fixing dynamic require missing from webpack (#6908)
* Fixing dynamic require missing from webpack

When running `yarn pack` with a bundledDependency yarn was throwing
an error: An unexpected error occurred: "Cannot find module \".\"".

This was due to yarn's cli.js being transpiled to on line 110321:

```
var thePackage = !(function webpackMissingModule() { var e = new Error("Cannot find module \".\""); e.code = 'MODULE_NOT_FOUND'; throw e; }());
```

This line comes from e849d3e2f0/lib/pkg.js (L20)
and is a dynamic require. This commit impements a fix for this based on the guidence from https://github.com/webpack/webpack/issues/4175#issuecomment-450746682

This code was originally added with #5966

* Update CHANGELOG.md
2019-01-14 14:59:14 +00:00
Billy Vong
94f83d661f feat(policies): Use github access token when requesting releases (#6912)
* feat(policies): Use github access token when requesting releases

If the environment variable `GITHUB_TOKEN` is defined, append `?access_token=<GITHUB_TOKEN>` when requesting yarn releases from GitHub.

Closes https://github.com/yarnpkg/yarn/issues/6905

* fix lint

* Update CHANGELOG.md
2019-01-14 14:53:22 +00:00
Maël Nison
6c41eb1401 Fixes PnP detection across workspaces (#6878)
* Fixes PnP detection across workspaces

* Update CHANGELOG.md
2019-01-07 11:10:15 +00:00
Ryan Patterson
b1f21a8027 Show problem path in invariant message (#6868)
Sometimes, `yarn add` will fail unexpectedly, and it leaves the cache in an invalid state. To cause your yarn cache to become corrupted:

```
$ yarn add antd@3.11.6
yarn add v1.12.3
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
error https://registry.yarnpkg.com/event-stream/-/event-stream-3.3.6.tgz: Extracting tar content of undefined failed, the file appears to be corrupt: "Unexpected end of data"
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

$ yarn cache list
yarn cache v1.12.3
error An unexpected error occurred: "There should only be one folder in a package cache (got  )".
info If you think this is a bug, please open a bug report with the information provided in "/Users/rpatterson/Projects/chess2/www2/client/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/cache for documentation about this command.
```

Note that the error message provides no information about how to resolve the error. This commit adds the problem path to the invariant message. Deleting this problem path will allow `yarn cache list` to work properly again.

The root cause of this issue is yarn#6805 which has been closed. This commit does not resolve the issue, so that issue should likely be reopened.
2019-01-04 12:46:46 +00:00
Maël Nison
960141d62d Update CHANGELOG.md 2019-01-04 12:31:57 +00:00
Robert Jackson
c1261c9ff8 Fix generated .pnp.js compatibility with Node 6. (#6871)
* Fix generated .pnp.js compatibility with Node 6.

Prior to these changes the generated `.pnp.js` file would use trailing
commas for function invocations which is not allowed (and generates a
parse error) under Node 6.

This removes the offending trailing commas...

* Update lint config for src/util/generate-pnp-map-api.tpl.js.

This file does not get transpiled down for Node 4 compat like other
files, so we cannot use `"trailingComma": "all"` configuration (the
default prettier config for this repo).
2019-01-04 12:30:54 +00:00
Jon Wolfe
d7811e41fa Fix Chocolatey log spam & bad nodejs-lts requirement (#6475)
**Summary**

Fixes #6439 

The chocolately install has always been full of log spam due to an incorrectly written `/l*v` flag, but those logs are also unneeded since the output has no useful info so I just removed them (this can be reversed to just fix the flag if y'all really want it back).

This also removes the bad `nodejs-lts` nuget dependency added in #5925. It now has no dependency, and instead logs out to inform the user to install node if it's missing.

**Test plan**

* `choco uninstall yarn`
* Replace the `{VERSION}` and `{CHECKSUM}` placeholders manually or do a full build (I manually replaced)
* `.\chocolateyinstall.ps1`
2018-12-20 21:45:37 -08:00
Maël Nison
526d9bfcdb Update CHANGELOG.md 2018-12-18 16:27:12 +00:00
Maël Nison
8c44bf35f5 1.14.0-0 2018-12-18 15:59:29 +00:00
Maël Nison
dd167f1ed6 v1.13.0 v1.13.0 2018-12-18 15:59:24 +00:00
Andrey Vetlugin
0f0520380a Return semantic exit code for audit (#6819) 2018-12-18 15:57:55 +00:00
Maël Nison
f3fb1102ff Stops unplugging packages when the install scripts are disabled (#6820)
* Stops unplugging packages when the install scripts are disabled

* Update CHANGELOG.md
2018-12-14 19:00:38 +00:00
Maël Nison
1cf0490304 Implements the pnp hook for the resolve package (#6816)
* Implements the pnp hook for the `resolve` package

* Updates the changelog
2018-12-14 16:19:51 +00:00
Maël Nison
024e9febe8 Properly reports network errors (#6817)
* Properly reports network errors

* Updates the changelog

* Fixes flow
2018-12-14 16:19:11 +00:00
Glavin Wiechert
e987790821 Add custom headers to tarball fetcher (#6756)
* Add custom headers to tarball fetcher

* Remove requestUrl argument from requestHeaders method

* Load custom headers for tarball request from yarn config
2018-12-11 15:25:18 +00:00
ExE Boss
5419606c52 chore(pacakge): Update @zkochan/cmd-shim to version 3.1.0 (#6804) 2018-12-09 23:22:47 +00:00
Daniel Lo Nigro
c45fc99443 Check for Chocolatey version using "choco list" instead of OneGet (#6754) 2018-12-06 19:40:06 -08:00
Greg Hurrell
723fc3ef7f Add missing apostrophe in error message (#6732)
* Add missing apostrophe in error message

* Update npm-registry.js
2018-12-05 00:40:11 +00:00
Noah Pendleton
fcf6298d8f Use hammer emoji for install/reinstall stage (#6749)
Switch from page_with_curl (📃) to hammer (🔨) emoji for this stage.
2018-12-05 00:38:06 +00:00
Maël Nison
011a634d78 Implements optional peer dependencies (#6671)
* Implements optional peer dependencies

* Implements the new peerDependenciesMeta field

* Runs prettier

* Updates the changelog

* Fixes flow
2018-12-03 13:57:35 +01:00
Maël Nison
066f0c8106 Fixes how signals are forwarded (#6747) 2018-12-03 12:47:16 +01:00
Pablo Núñez
d8171345b5 Add Azure Pipelines badge to README.md (#6720) 2018-11-26 13:03:29 +00:00
Maël Nison
77f04c3497 Fixes dependencies using bins from their own dependencies (#6712) 2018-11-21 14:32:50 +00:00
Rowan Lonsdale
0d4861052f Check for existence of .bin dir in pnp dependencies before adding to PATH. (#6711)
* Check PnP dep has `.bin` dir before adding to `PATH`

* Update CHANGELOG

* Update CHANGELOG.md
2018-11-21 14:12:00 +00:00
Maël Nison
158da6c628 Implements "yarn self set" (#6673)
* Implements "yarn self set"

* Adds support for nightlies

* Updates changelog

* Renames "yarn self set" into "yarn policies set-version"
2018-11-20 20:13:04 +00:00
Maël Nison
7f41910330 Set up CI with Azure Pipelines (#6495)
* Set up CI with Azure Pipelines

* Update azure-pipelines.yml

* Update azure-pipelines.yml

* Update package.json

* Adds debug

* Tries using bash

* Tweaks timeouts

* Fixes various things related to the win32 compat

* I get the same 22 failed tests with/without the delay.

* Fix makeFakeBinary for win32.

It needs the ".cmd" extension, otherwise it's ignored.
Remove #!/bin/sh and instead add @echo off to clean output
Use errorCode 0 so we get output and not a Command failed

* Check custom output instead of versions.

Running fake binaries there was no way to get local versions of node or yarn. Am I missing something?

* Remove quotes from echo (not removed in Windows).
Replace ; by /n as the former doesn't actually break statements in Windows batch files.

* Some tweaks

* Fixes syntax

* Fixes tests on Windows

* Adds test reporting

* Fixes things (?)

* Fixes indent

* Always run the test result publishing

* Fixes yml

* Use node scripts to avoid Windows interoperability issues.

* Fixes the "must use the same Node as Yarn itself" test

* Fixes escaping from within the tests

* Removes the accidental .only flag

* Fixes a test on Windows

* Add support for different drives in Windows.

So if code is in D: but temporary folder is in C:, don't try to find a relative path but stay on the absolute one.

* No need to getPackageLocation

* Add support for environment and arguments by using a custom solution instead of cmd-shim.

* Missing escape on path in pnpapi test.

* Some cleaning

* Runs tests on all three platforms

* Fixes write paths

* Fixes normalizePath

* Disables pkg-tests from CircleCI (moved to Azure)

* Increase Windows timeouts and better name Test results (#6680)

* Increase timeout in Windows, we're seeing tests failing randomly and others close to default 5 sec.

* Distinguish tests published from each job.

* Pass name as vmImage is not available

* Remove unnecessary detect unfinished tests.

* Using strategy var instead of parameter

* Use variables instead of strategy

* Revert "Disables pkg-tests from CircleCI (moved to Azure)"

This reverts commit 8f724620b6.
2018-11-14 22:10:44 +00:00
Maël Nison
e7ffb52825 Fixes the resolution when a package has an invalid "main" but a valid… (#6682)
* Fixes the resolution when a package has an invalid "main" but a valid "index.js"

* Update CHANGELOG.md

* Fixes the resolution when a package has an invalid "main" but a valid "index.js"
2018-11-14 22:06:00 +00:00
renovate[bot]
8317ddf840 chore(deps): update dependency eslint-plugin-relay to ^0.0.28 (#6133) 2018-11-13 23:00:16 +00:00
Linus Heckemann
9049e6e48f chore: Remove stats.json (#6653)
**Summary**

Seems to be some sort of IDE metadata erroneously introduced in
7ff626c726 (#5934)

**Test plan**

Existing tests.
2018-11-12 15:41:27 +00:00
Maël Nison
09ceb0e594 Update CHANGELOG.md 2018-11-07 16:06:25 +00:00
Jeff Valore
f8e42c563f fix(audit) Report vulnerabilities in workspace package dependencies (#6639)
* added failing test for #6625

* fix(audit): Add workspaceAggregator dependencies to root manifest to be audited.

This change takes the packages that are included as part of the workspace and adds them to what is
sent to the npm audit api.

fixes #6625

* update changelog for PR 6639
2018-11-07 12:34:49 +00:00
Maël Nison
124a2ef643 Exposes pnpapi through resolveToUnqualified (#6643)
* Exposes pnpapi through resolveToUnqualified

* Update CHANGELOG.md
2018-11-07 12:32:36 +00:00
Maël Nison
1ceabe85b1 Tries a fix for Windows 2018-11-06 15:59:52 +00:00
Maël Nison
85660f79bf Precompiles inquirer for Node 4 compat (#6640) 2018-11-06 15:16:50 +00:00
Maël Nison
a40f3fc981 Update CHANGELOG.md 2018-11-05 17:02:07 +00:00
Philipp Feigl
5539fa23d1 Fixes potential freeze on win+node10 interactive upgrades (#5949) (#6635)
* Fixes potential freeze on win+node10 interactive upgrades (#5949)

There is a potential freeze when running interactive upgrades after selecting the options.
This boiles down to a problem in the `inquirer` library which is used internally to provide the possible options.
Updating `inquirer`to the latest version fixes the problem.

* Update CHANGELOG.md
2018-11-05 16:44:47 +00:00
Maël Nison
7977c422ed Uses NODE_OPTIONS with PnP instead of CLI args (#6629)
* Uses NODE_OPTIONS when spawning a process

* Adds an additional test

* Update CHANGELOG.md
2018-11-05 16:40:46 +00:00
Yoad Snapir
4e3b2f6112 fix: Use cmdshim instead of symlink on win32 in base-fetcher (#6621)
* fix: Use cmdshim instead of symlink on win32 in base-fetcher

* Update CHANGELOG

* Bumps the cache key

* Use cmdShim.ifExists to handle missing src like symlink (ignores)

* Update CHANGELOG.md
2018-11-05 12:17:13 +00:00
Maël Nison
4177b081dc Stop copying .bin folders (#6628)
* Stops copying the .bin folder from the cache

* Adds a test
2018-11-03 12:42:08 -07:00
Maël Nison
b62e9e4701 Fixes the resolve shim for liftoff (#6623)
* Fixes the resolve shim for liftoff

* Update CHANGELOG.md
2018-11-01 20:18:58 -07:00
Jack Zhao
4b8e49e7af fix audit for packages without name (#6611)
* fix audit for packages without name

* add test

* fix bad dependency version

* fix bad dependency version

* Update audit.js

* Update CHANGELOG.md
2018-11-01 09:30:08 -07:00
Maël Nison
97834002c7 Fixes Node 10 CI on OSX (#6580)
* Update config.yml

* Update config.yml

* Update config.yml
2018-10-25 13:24:33 +01:00
Maël Nison
daac3a0d2b Bumps the changelog 2018-10-24 17:48:24 +01:00
Hidde Boomsma
af72e6a1f7 Support Darwin bash in bin/yarn (#6568)
* Support Darwin bash in bin/yarn

If the yarn binary is a symlink the `basepath` is not correctly resolved on OSX/Darwin.

For example take the following structure:
```
vendor/yarnpkg/yarn
vendor/bin/yarn -> ../yarnpkg/yarn/bin/yarn
```

And run yarn:
```
$ yarn
internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module '/Users/yarnpkg/yarn/bin/yarn.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
```
Since the symlink is not resolved the relative path in the symlink leads to the wrong path.

This PR, fixes that issue.

* Update CHANGELOG.md
2018-10-23 15:11:15 +01:00
Maël Nison
f6d0a5b85a Implements require.resolve's paths options (#6565)
* Update generate-pnp-map-api.tpl.js

* Updates the changelog

* Adds tests

* Scopes the option tests to >=8.9.0
2018-10-23 15:06:30 +01:00
Krzysztof Zbudniewek
b8a565e562 feat(auth): Support two factor authentication for NPM accounts (#6555)
* feat(auth): Support two factor authentication for npm accounts

Fix #4904

* Add basic tests

* Rename OneTimePasswordRequiredError to OneTimePasswordError

Cause it's also thrown when one-time password is invalid.

* Remove misleading config parameter from getOneTimePassword

* Don't reimplement setOtp in npm-registry.js tests

* Update CHANGELOG.md
2018-10-22 15:03:29 +01:00
Bertrand Marron
5876b301ae Anchor package.json files to the package’s root (#6562)
* Anchor files to the package’s root

npm pack bases paths from the `files` array from the package’s
root. This updates yarn pack to behave in the same way.

* Update CHANGELOG.md
2018-10-22 13:26:15 +01:00
Mark Stacey
04b23e4f02 test: Default nonInteractive to true in cli tests to prevent timeouts (#6559)
The last three tests in `__tests__/commands/publish.js` were regularly timing
out locally, yet they were doing fine on CI. They were apparently running in
interactive mode, and were waiting for user input after `publish` was called
(to set the next version number).

Setting `nonInteractive` to false by default in `__tests__/commands/_helpers`
ensures that all command tests run in non-interactive mode unless otherwise
specified. This prevents this problem from occuring again, at least among the
tests that use this helper.

Note that this change won't improve tests on CI, as this problem never
affected CI. The tests were running in non-interactive mode on CI
already due to an `isCi` check in `config.js`.
2018-10-22 12:12:52 +01:00