* 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
* 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
* 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
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.
* 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).
**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`
* 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.
* 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"
* 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
* 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
* 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
* 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
* 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
* 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
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`.