* 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
* 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).
* 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
* 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
* 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
* refactor(lockfile): remove string concatenation from parsing code
Replace all instances of building strings incrementally using += with more efficient methods.
* fix(lockfile): prevent infinite loop when parsing a
Fix bug where yarn could get into an infinite loop when parsing a corrupted lockfile with an
unterminated string.
* Environment variable prefixes should start at the beginning, not in the middle of an environment variable. This fixes this example:
SOME_YARN_CONFIG=123 yarn config list | grep some
'some-yarn-config':
{ 'some-yarn-config':
* Update CHANGELOG.md
* Fix: handle empty bin strings
When the package.json of a dependency sets `bin` to an empty string,
do not normalize it. This prevents creating a symlink to the
dependency's root directory within the `.bin` directory if bin-links
are enabled
* Add an entry to the changelog
* Add a test to make sure empty binlinks aren't created
Test was suggested/provided by @rally25rs
* Fix empty bin string test on Windows
When `install`ing in a repo with a dependency that specifies `"flat:: true`, but without the `--flat` flag or `"flat": true` in your own package.json, you get an error: `The package undefined@undefined requires a flat dependency graph. Add \`"flat": true\` to your package.json and try again.`
This was occuring because the relevant error message, `flatGlobalError` was expecting two variables for interpolation: the package name and the package version.
This fix changes that to one variable (to be consistent with other uses) and passes the appropriate values in to the message.
* WIP: audit command added. sends data to registry.
* code cleanup
* WIP: Added Audit command. No tests. Existing test fail.
* Print audit summary when no problems found
* Don't send package version to audit API if it is not in the manifest.
* Add audit functions to json-reporter
* WIP: First successful audit command test
* added more audit tests
* feat(audit): Initial addition of yarn audit command and --audit flag
Added "yarn audit" command which copies the behavior of "npm audit". Unline npm, yarn does not
automatically run "audit" during "add/install/upgrade" commands. Since this would cause an
additional network call, it broke all existing unit tests to add this feature and have it run
automatically. In the interest of getting an initial release in the hands of our users the
"add/install/upgrade" commands accept a "--audit" flag that will enable the audit. If you want audit
to always execute, you can add "--*.audit true" to .yarnrc
fix#5808
* gzip the JSON sent to npm audit API to reduce payload
* fix audit test for gzip data
* Update install.js
* removed audit correction suggestions due to them being unreliable
* Updates the changelog
* Initial pnp implementation
* Adds the pnp-env directory for quick checks
* Improves the "yarn node" command so that it works with pnp
Branch: yarn-node-pnp
* Adds the pnp tests to the pkg-tests testsuite
Branch: pkg-tests
* Fixes various issues with the pnp map generation
Branch: pnp-map-improvements
* Remove the scriptsPrependNodePath option
Branch: lifecycle-wrappers-remove-option
* Adds tests to ensure that the lifecycle scripts are called with the right binaries
Branch: lifecycle-wrappers-tests
* Fixes linting
Branch: lifecycle-wrappers-flowlint
* Improve the error message when an optional required dependency hasn't been installed
Branch: lifecycle-wrappers-improve-pnp-error
* Implements lifecycle wrappers
Branch: lifecycle-wrappers-main
* Adds .pnp.js files to the gitignore
* Fallbacks to the toplevel dependencies when a transitive dependency cannot be resolved
* Fixes an issue inside the pkg-tests helper
Branch: pkg-tests-helper-definition
* Improves the fixtures so that they also return info about their dev and peer dependencies
Branch: dev-peer-fixtures
* Finishes to hide plugnplay behind a yarnrc option (`plugnplay-experimental`)
Branch: option-plugnplay-experimental
* Adds failing tests for pnp peer dependencies
Branch: pnp-peer-dependencies-failing
* Prettifies the generated pnp files
* Adds the plugnplay flag to the integrity check
* Removes the pnp file at link-time if installing with pnp disabled
* Improves pnp maps compatibility
* Prevents "yarn check" from checking the node_modules existence when under pnp
* Adds a missing package to the request cache
* Fixes tests
Branch: pnp-fix-tests
* Reimplements the resolution to correctly account for peer dependencies
Branch: better-faster-stronger
* Externalizes the creation of proxy scripts
Branch: portable-proxy-scripts
* Implements support for `yarn run` within pnp-enabled installations
Branch: pnp-yarn-run
* Makes it possible for dependency binaries to require their own dependencies
Branch: pnp-yarn-run-dependencies
* Moves the pnp embed api into its own file
* Adds the test folder to Jest error messages
Branch: jest-better-message
* Improves peer dependency tests
Branch: peer-deps-tests
* Adds tests for require.resolve
Branch: require-resolve-tests
* Refactors the pnp file
Branch: pnp-file-refactoring
* Updates the build-webpack script to include a custom resolver
Branch: webpack-resolver
* Fixes tests
Branch: fix-tests
* Generates virtual when using peer dependencies
Branch: virtual-packages
* Refactors the generated pnp files to use the newly generated maps
Branch: pnp-refactor-find
* Implements Module._findPath
Branch: module-findpath
* Adds tests for workspaces
Branch: workspace-tests
* Fixes top level detection
Branch: fix-top-level-detection
* Implements workspaces support in pnp
Branch: pnp-workspaces
* Automatically adds workspaces as dependencies of the top-level
Branch: auto-workspace-dependencies
* Updates the cache path to include the 'node_modules' string
Branch: node-modules-cache
* Prevents pnp from bootstrapping when running non-pnp-installed scripts
Branch: fix-npm-run
* Installs peer dependencies symlinks inside a project folder
Branch: per-project-virtual-deps
* Adds a sample application that showcases webpack, babel, react, jest
Branch: sample-app
* Ignores the .pnp directory
Branch: ignore-pnp
* Implements a blacklist that throws nicer errors when a package is required through a realpath'd path.
Branch: location-blacklist
* Changes the order the locations are matched to package locators
Branch: location-to-locator-match-order
* Automatically adds packages as dependencies of themselves if possible
Branch: implicit-self
* Updates the node resolution
Branch: node-resolution-improvements
* Ensures that binaries are set as executable in the cache
Branch: chmod-bins
* Disables integrity checks when running under pnp
Branch: pnp-no-integrity
* Makes the .pnp.js file an actual executable that can be used as a resolution server
Branch: pnp-executable
* Removes pnp-env
* Fixes a few tests
* Fixes snapshots
* Fixes the lockfile not being written when using pnp
Branch: fix-lockfile
* Fixes the `yarn node` command being incorrectly forwarded arguments
Branch: fix-yarn-node
* Uses symlinks instead of a script for bin indirection to allow calling them directly through Node
Branch: bin-symlinks
* Adds a `yarn bin <name>` command that returns the path of the specified bin on the disk
Branch: yarn-bin-name
* Implements an --into option to yarn node/yarn run
Branch: opt-into
* Implements the `--pnp` option
Branch: pnp-option
* Adds new tests for checking that packages are correctly locked
Branch: lock-tests
* Bugfixes
This diff ships with two fixes:
- Fixes calling a pnp script from a non-pnp scripts
- Fixes relative requires from binaries
It also adds tests for all those cases
Branch: bugfixes
* Fixes workspace registration
Branch: workspace-registration-fix
* Uses --enable-pnp (alias --pnp) and --disable-pnp
Branch: instalconfig-pnp
* Adds the issuer into the error messages when requesting a package one shouldn't have access to.
Branch: via-issuer
* Implements extendedQualifiedPathResolution
Branch: extended-qualified-path-resolution
* Changes the return of the pnp daemon to return json data
* Implements custom shebangs for the pnp file
* Changes the return of the pnp-exposed functions to return null with builtins
* Various fixes & improvements
* Adds a test, prettier, fixes a test
* Don't iterate on the registries
* Renames YARN_PLUGNPLAY_EXPERIMENTAL into YARN_PLUGNPLAY_OVERRIDE
* Avoids touching the .pnp.js file when it doesn't need to change
* Reworks the cache path to contain the "node_modules/<pkg-name>" string
* Shims resolve#isCore
* Improves error messages
* Fixes the environment cast to allow passing false/0
* Implements a pnp blacklist settings
* Fixes the fallback resolution to use _resolveFilename instead of _finePath
* Fixes fallback relative path resolution
* Implements require.cache
* Prevents pnp from being enabled on Windows
* Removes absolute paths from the pnp files
* Implements a super basic offline cache integration
* feat(pnp): eject package command (#92)
* test(pnp): support ejecting packages
* feat(pnp): eject package command
* test(pnp): use fs.readdir instead of fs.readdirSync
* test(pnp): do not expect specific error message
* refactor(pnp): move eject logic to package linker
* fix(pnp): change ejected folder to .pnp/ejected/pkgName-pkgVersion/node_modules/pkgName
* fix(pnp): do not re-eject package
* test(pnp): do not rely on installConfig
* Fixes yarn bin
* Preserves the node_modules components in zip paths
* Fixes the offline cache
* Adds a VERSIONS field into the generated resolver
* Exposes the "extensions" option to "resolveRequest"
* Renames yarn eject into yarn unplug
* Tweaks yarn unplug
* Removes packageMainEntry from the package information
* Makes "unplug" print the list of unplugged packages
* Unplugs postinstall packages automatically
* Renames things
* Adds a warning on Windows to notify that PnP settings are ignored at the moment
* Fixes the default shebang
* Exports pnpapi
* Reworks the resolve shim to only affect liftoff
* Guards the pnp file against fs extensions
* Fixes the resolve shim
* Fixes a broken test
* Re-enables the focus tests
* Stops relying on bash for test scripts
* Fixes nohoist
* Revert "Fixes a broken test"
This reverts commit 84358aa507.
* Ensures that the getPackageInformation function returns an absolute path