deps: add corepack

Corepack provides shims for Yarn and pnpm in order to soften the
developer experience when working on Node projects.

Refs: https://github.com/nodejs/node/issues/15244
Refs: https://github.com/nodejs/TSC/issues/904

PR-URL: https://github.com/nodejs/node/pull/39608
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Maël Nison 2020-09-28 17:35:09 +02:00 committed by James M Snell
parent f581f6da94
commit 46598b88bf
No known key found for this signature in database
GPG Key ID: 7341B15C070877AC
74 changed files with 16600 additions and 27 deletions

1
.gitignore vendored
View File

@ -62,6 +62,7 @@ _UpgradeReport_Files/
*.wixobj
/tools/msvs/genfiles/
/npm.wxs
/corepack.wxs
/tools/msvs/msi/Release/
/tools/msvs/msi/obj/
/tools/msvs/msi/x64/

11
LICENSE
View File

@ -625,6 +625,17 @@ The externally maintained libraries used by Node.js are:
USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
- corepack, located at deps/corepack, is licensed as follows:
"""
**Copyright © Corepack contributors**
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"""
- OpenSSL, located at deps/openssl, is licensed as follows:
"""
Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.

View File

@ -1054,6 +1054,14 @@ endif
# Builds the macOS installer for releases.
pkg: $(PKG)
corepack-update:
rm -rf /tmp/node-corepack-clone
git clone 'https://github.com/nodejs/corepack.git' /tmp/node-corepack-clone
cd /tmp/node-corepack-clone && yarn pack
rm -rf deps/corepack && mkdir -p deps/corepack
cd deps/corepack && tar xf /tmp/node-corepack-clone/package.tgz --strip-components=1
chmod +x deps/corepack/shims/*
# Note: this is strictly for release builds on release machines only.
pkg-upload: pkg
ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)"

7
deps/corepack/LICENSE.md vendored Normal file
View File

@ -0,0 +1,7 @@
**Copyright © Corepack contributors**
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

147
deps/corepack/README.md vendored Normal file
View File

@ -0,0 +1,147 @@
# <img src="./icon.svg" height="25" /> corepack
Corepack is a zero-runtime-dependency Node script that acts as a bridge between Node projects and the package managers they are intended to be used with during development. In practical terms, **Corepack will let you use Yarn and pnpm without having to install them** - just like what currently happens with npm, which is shipped by Node by default.
**Important:** At the moment, Corepack only covers Yarn and pnpm. Given that we have little control on the npm project, we prefer to focus on the Yarn and pnpm use cases. As a result, Corepack doesn't have any effect at all on the way you use npm.
## How to Install
### Default Installs
Corepack isn't intended to be installed manually. While it's certainly possible, we're working with the Node TSC to provide Corepack by default starting from Node 15, thus ensuring that all package managers can be used with little to no friction.
### Manual Installs
<details>
<summary>Click here to see how to install Corepack using npm</summary>
First uninstall your global Yarn and pnpm binaries (just leave npm). In general, you'd do this by running the following command:
```shell
npm uninstall -g yarn pnpm
# That should be enough, but if you installed Yarn without going through npm it might
# be more tedious - for example, you might need to run `brew uninstall yarn` as well.
```
Then install Corepack:
```shell
npm install -g corepack
```
We do acknowledge the irony and overhead of using npm to install Corepack, which is at least part of why the preferred option is to use the Corepack version that will be distributed along with Node itself.
</details>
### Prebuilt Binaries
<details>
<summary>Click here to see how to download prebuilt Corepack Node distributions</summary>
We have a few prebuilt Node binaries (based on the [following branch](https://github.com/arcanis/node/tree/mael/pmm)) that you can just download, unpack somewhere, and add to your `PATH` environment variable.
1. Go to [this page](https://github.com/arcanis/pmm/actions?query=workflow%3ABuild)
2. Open the latest build (the one at the top)
3. Download the right artifact (Linux or Darwin)
4. Unzip the artifact, then untar it
5. Add the `node-v15.0.0-nightlyYYYY-MM-DDXXXX-linux-x64/bin` directory to your `$PATH`
</details>
## Usage
Just use your package managers as you usually would. Run `yarn install` in Yarn projects, `pnpm install` in pnpm projects, and `npm` in npm projects. Corepack will catch these calls, and depending on the situation:
- **If the local project is configured for the package manager you're using**, Corepack will silently download and cache the latest compatible version.
- **If the local project is configured for a different package manager**, Corepack will request you to run the command again using the right package manager - thus avoiding corruptions of your install artifacts.
- **If the local project isn't configured for any package manager**, Corepack will assume that you know what you're doing, and will use whatever package manager version has been pinned as "known good release". Check the relevant section for more details.
## Known Good Releases
When running Yarn or pnpm within projects that don't list a supported package manager, Corepack will default to a set of Known Good Releases. In a way, you can compare this to Node, where each version ships with a specific version of npm.
The Known Good Releases can be updated system-wide using the `--activate` flag from the `corepack prepare` and `corepack hydrate` commands.
## Offline Workflow
The utility commands detailed in the next section.
- Either you can use the network while building your container image, in which case you'll simply run `corepack prepare` to make sure that your image includes the Last Known Good release for the specified package manager.
- If you want to have *all* Last Known Good releases for all package managers, just use the `--all` flag which will do just that.
- Or you're publishing your project to a system where the network is unavailable, in which case you'll preemptively generate a package manager archive from your local computer (using `corepack prepare -o`) before storing it somewhere your container will be able to access (for example within your repository). After that it'll just be a matter of running `corepack hydrate <path/to/corepack.tgz>` to setup the cache.
## Utility Commands
### `corepack <binary name>[@<version>] [... args]`
This meta-command runs the specified package manager in the local folder. You can use it to force an install to run with a given version, which can be useful when looking for regressions.
Note that those commands still check whether the local project is configured for the given package manager (ie you won't be able to run `corepack yarn install` on a project where the `packageManager` field references `pnpm`).
### `corepack enable [... name]`
| Option | Description |
| --- | --- |
| `--install-directory` | Add the shims to the specified location |
This command will detect where Node is installed and will create shims next to it for each of the specified package managers (or all of them if the command is called without parameters). Note that the npm shims will not be installed unless explicitly requested, as npm is currently distributed with Node through other means.
### `corepack disable [... name]`
| Option | Description |
| --- | --- |
| `--install-directory` | Remove the shims to the specified location |
This command will detect where Node is installed and will remove the shims from there.
### `corepack prepare [... name@version]`
| Option | Description |
| --- | --- |
| `--all` | Prepare the "Last Known Good" version of all supported package managers |
| `-o,--output` | Also generate an archive containing the package managers |
| `--activate` | Also update the "Last Known Good" release |
This command will download the given package managers (or the one configured for the local project if no argument is passed in parameter) and store it within the Corepack cache. If the `-o,--output` flag is set (optionally with a path as parameter), an archive will also be generated that can be used by the `corepack hydrate` command.
### `corepack hydrate <path/to/corepack.tgz>`
| Option | Description |
| --- | --- |
| `--activate` | Also update the "Last Known Good" release |
This command will retrieve the given package manager from the specified archive and will install it within the Corepack cache, ready to be used without further network interaction.
## Environment Variables
- `COREPACK_ENABLED` has no functional impact on Corepack itself; it's automatically being set in your environment by Corepack when it shells out to the underlying package managers, so that they can feature-detect its presence (useful for commands like `yarn init`).
## Contributing
If you want to build corepack yourself, you can build the project like this:
1. Clone this repository
2. Run `yarn build` (no need for `yarn install`)
3. The `dist/` directory now contains the corepack build and the shims
4. Call `node ./dist/corepack --help` and behold
You can also run the tests with `yarn jest` (still no install needed).
## Design
Various tidbits about Corepack's design are explained in more details in [DESIGN.md](/DESIGN.md).
## License (MIT)
> **Copyright © Corepack contributors**
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

14865
deps/corepack/dist/corepack.js vendored Executable file

File diff suppressed because it is too large Load Diff

2
deps/corepack/dist/npm.js vendored Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./corepack').runMain(['npm', ...process.argv.slice(2)]);

2
deps/corepack/dist/npx.js vendored Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./corepack').runMain(['npx', ...process.argv.slice(2)]);

2
deps/corepack/dist/pnpm.js vendored Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./corepack').runMain(['pnpm', ...process.argv.slice(2)]);

2
deps/corepack/dist/pnpx.js vendored Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./corepack').runMain(['pnpx', ...process.argv.slice(2)]);

424
deps/corepack/dist/vcc.js vendored Normal file
View File

@ -0,0 +1,424 @@
#!/usr/bin/env node
/* eslint-disable */
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ "./.yarn/cache/v8-compile-cache-npm-2.3.0-961375f150-adb0a271ea.zip/node_modules/v8-compile-cache/v8-compile-cache.js":
/*!****************************************************************************************************************************!*\
!*** ./.yarn/cache/v8-compile-cache-npm-2.3.0-961375f150-adb0a271ea.zip/node_modules/v8-compile-cache/v8-compile-cache.js ***!
\****************************************************************************************************************************/
/***/ (function(module, exports) {
'use strict';
const Module = require('module');
const crypto = require('crypto');
const fs = require('fs');
const path = require('path');
const vm = require('vm');
const os = require('os');
const hasOwnProperty = Object.prototype.hasOwnProperty;
//------------------------------------------------------------------------------
// FileSystemBlobStore
//------------------------------------------------------------------------------
class FileSystemBlobStore {
constructor(directory, prefix) {
const name = prefix ? slashEscape(prefix + '.') : '';
this._blobFilename = path.join(directory, name + 'BLOB');
this._mapFilename = path.join(directory, name + 'MAP');
this._lockFilename = path.join(directory, name + 'LOCK');
this._directory = directory;
this._load();
}
has(key, invalidationKey) {
if (hasOwnProperty.call(this._memoryBlobs, key)) {
return this._invalidationKeys[key] === invalidationKey;
} else if (hasOwnProperty.call(this._storedMap, key)) {
return this._storedMap[key][0] === invalidationKey;
}
return false;
}
get(key, invalidationKey) {
if (hasOwnProperty.call(this._memoryBlobs, key)) {
if (this._invalidationKeys[key] === invalidationKey) {
return this._memoryBlobs[key];
}
} else if (hasOwnProperty.call(this._storedMap, key)) {
const mapping = this._storedMap[key];
if (mapping[0] === invalidationKey) {
return this._storedBlob.slice(mapping[1], mapping[2]);
}
}
}
set(key, invalidationKey, buffer) {
this._invalidationKeys[key] = invalidationKey;
this._memoryBlobs[key] = buffer;
this._dirty = true;
}
delete(key) {
if (hasOwnProperty.call(this._memoryBlobs, key)) {
this._dirty = true;
delete this._memoryBlobs[key];
}
if (hasOwnProperty.call(this._invalidationKeys, key)) {
this._dirty = true;
delete this._invalidationKeys[key];
}
if (hasOwnProperty.call(this._storedMap, key)) {
this._dirty = true;
delete this._storedMap[key];
}
}
isDirty() {
return this._dirty;
}
save() {
const dump = this._getDump();
const blobToStore = Buffer.concat(dump[0]);
const mapToStore = JSON.stringify(dump[1]);
try {
mkdirpSync(this._directory);
fs.writeFileSync(this._lockFilename, 'LOCK', {flag: 'wx'});
} catch (error) {
// Swallow the exception if we fail to acquire the lock.
return false;
}
try {
fs.writeFileSync(this._blobFilename, blobToStore);
fs.writeFileSync(this._mapFilename, mapToStore);
} finally {
fs.unlinkSync(this._lockFilename);
}
return true;
}
_load() {
try {
this._storedBlob = fs.readFileSync(this._blobFilename);
this._storedMap = JSON.parse(fs.readFileSync(this._mapFilename));
} catch (e) {
this._storedBlob = Buffer.alloc(0);
this._storedMap = {};
}
this._dirty = false;
this._memoryBlobs = {};
this._invalidationKeys = {};
}
_getDump() {
const buffers = [];
const newMap = {};
let offset = 0;
function push(key, invalidationKey, buffer) {
buffers.push(buffer);
newMap[key] = [invalidationKey, offset, offset + buffer.length];
offset += buffer.length;
}
for (const key of Object.keys(this._memoryBlobs)) {
const buffer = this._memoryBlobs[key];
const invalidationKey = this._invalidationKeys[key];
push(key, invalidationKey, buffer);
}
for (const key of Object.keys(this._storedMap)) {
if (hasOwnProperty.call(newMap, key)) continue;
const mapping = this._storedMap[key];
const buffer = this._storedBlob.slice(mapping[1], mapping[2]);
push(key, mapping[0], buffer);
}
return [buffers, newMap];
}
}
//------------------------------------------------------------------------------
// NativeCompileCache
//------------------------------------------------------------------------------
class NativeCompileCache {
constructor() {
this._cacheStore = null;
this._previousModuleCompile = null;
}
setCacheStore(cacheStore) {
this._cacheStore = cacheStore;
}
install() {
const self = this;
const hasRequireResolvePaths = typeof require.resolve.paths === 'function';
this._previousModuleCompile = Module.prototype._compile;
Module.prototype._compile = function(content, filename) {
const mod = this;
function require(id) {
return mod.require(id);
}
// https://github.com/nodejs/node/blob/v10.15.3/lib/internal/modules/cjs/helpers.js#L28
function resolve(request, options) {
return Module._resolveFilename(request, mod, false, options);
}
require.resolve = resolve;
// https://github.com/nodejs/node/blob/v10.15.3/lib/internal/modules/cjs/helpers.js#L37
// resolve.resolve.paths was added in v8.9.0
if (hasRequireResolvePaths) {
resolve.paths = function paths(request) {
return Module._resolveLookupPaths(request, mod, true);
};
}
require.main = process.mainModule;
// Enable support to add extra extension types
require.extensions = Module._extensions;
require.cache = Module._cache;
const dirname = path.dirname(filename);
const compiledWrapper = self._moduleCompile(filename, content);
// We skip the debugger setup because by the time we run, node has already
// done that itself.
// `Buffer` is included for Electron.
// See https://github.com/zertosh/v8-compile-cache/pull/10#issuecomment-518042543
const args = [mod.exports, require, mod, filename, dirname, process, global, Buffer];
return compiledWrapper.apply(mod.exports, args);
};
}
uninstall() {
Module.prototype._compile = this._previousModuleCompile;
}
_moduleCompile(filename, content) {
// https://github.com/nodejs/node/blob/v7.5.0/lib/module.js#L511
// Remove shebang
var contLen = content.length;
if (contLen >= 2) {
if (content.charCodeAt(0) === 35/*#*/ &&
content.charCodeAt(1) === 33/*!*/) {
if (contLen === 2) {
// Exact match
content = '';
} else {
// Find end of shebang line and slice it off
var i = 2;
for (; i < contLen; ++i) {
var code = content.charCodeAt(i);
if (code === 10/*\n*/ || code === 13/*\r*/) break;
}
if (i === contLen) {
content = '';
} else {
// Note that this actually includes the newline character(s) in the
// new output. This duplicates the behavior of the regular
// expression that was previously used to replace the shebang line
content = content.slice(i);
}
}
}
}
// create wrapper function
var wrapper = Module.wrap(content);
var invalidationKey = crypto
.createHash('sha1')
.update(content, 'utf8')
.digest('hex');
var buffer = this._cacheStore.get(filename, invalidationKey);
var script = new vm.Script(wrapper, {
filename: filename,
lineOffset: 0,
displayErrors: true,
cachedData: buffer,
produceCachedData: true,
});
if (script.cachedDataProduced) {
this._cacheStore.set(filename, invalidationKey, script.cachedData);
} else if (script.cachedDataRejected) {
this._cacheStore.delete(filename);
}
var compiledWrapper = script.runInThisContext({
filename: filename,
lineOffset: 0,
columnOffset: 0,
displayErrors: true,
});
return compiledWrapper;
}
}
//------------------------------------------------------------------------------
// utilities
//
// https://github.com/substack/node-mkdirp/blob/f2003bb/index.js#L55-L98
// https://github.com/zertosh/slash-escape/blob/e7ebb99/slash-escape.js
//------------------------------------------------------------------------------
function mkdirpSync(p_) {
_mkdirpSync(path.resolve(p_), 0o777);
}
function _mkdirpSync(p, mode) {
try {
fs.mkdirSync(p, mode);
} catch (err0) {
if (err0.code === 'ENOENT') {
_mkdirpSync(path.dirname(p));
_mkdirpSync(p);
} else {
try {
const stat = fs.statSync(p);
if (!stat.isDirectory()) { throw err0; }
} catch (err1) {
throw err0;
}
}
}
}
function slashEscape(str) {
const ESCAPE_LOOKUP = {
'\\': 'zB',
':': 'zC',
'/': 'zS',
'\x00': 'z0',
'z': 'zZ',
};
const ESCAPE_REGEX = /[\\:/\x00z]/g; // eslint-disable-line no-control-regex
return str.replace(ESCAPE_REGEX, match => ESCAPE_LOOKUP[match]);
}
function supportsCachedData() {
const script = new vm.Script('""', {produceCachedData: true});
// chakracore, as of v1.7.1.0, returns `false`.
return script.cachedDataProduced === true;
}
function getCacheDir() {
const v8_compile_cache_cache_dir = process.env.V8_COMPILE_CACHE_CACHE_DIR;
if (v8_compile_cache_cache_dir) {
return v8_compile_cache_cache_dir;
}
// Avoid cache ownership issues on POSIX systems.
const dirname = typeof process.getuid === 'function'
? 'v8-compile-cache-' + process.getuid()
: 'v8-compile-cache';
const version = typeof process.versions.v8 === 'string'
? process.versions.v8
: typeof process.versions.chakracore === 'string'
? 'chakracore-' + process.versions.chakracore
: 'node-' + process.version;
const cacheDir = path.join(os.tmpdir(), dirname, version);
return cacheDir;
}
function getMainName() {
// `require.main.filename` is undefined or null when:
// * node -e 'require("v8-compile-cache")'
// * node -r 'v8-compile-cache'
// * Or, requiring from the REPL.
const mainName = require.main && typeof require.main.filename === 'string'
? require.main.filename
: process.cwd();
return mainName;
}
//------------------------------------------------------------------------------
// main
//------------------------------------------------------------------------------
if (!process.env.DISABLE_V8_COMPILE_CACHE && supportsCachedData()) {
const cacheDir = getCacheDir();
const prefix = getMainName();
const blobStore = new FileSystemBlobStore(cacheDir, prefix);
const nativeCompileCache = new NativeCompileCache();
nativeCompileCache.setCacheStore(blobStore);
nativeCompileCache.install();
process.once('exit', () => {
if (blobStore.isDirty()) {
blobStore.save();
}
nativeCompileCache.uninstall();
});
}
module.exports.__TEST__ = {
FileSystemBlobStore,
NativeCompileCache,
mkdirpSync,
slashEscape,
supportsCachedData,
getCacheDir,
getMainName,
};
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/
/******/ // startup
/******/ // Load entry module and return exports
/******/ // This entry module doesn't tell about it's top-level declarations so it can't be inlined
/******/ var __webpack_exports__ = __webpack_require__("./.yarn/cache/v8-compile-cache-npm-2.3.0-961375f150-adb0a271ea.zip/node_modules/v8-compile-cache/v8-compile-cache.js");
/******/ var __webpack_export_target__ = exports;
/******/ for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
/******/ if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, "__esModule", { value: true });
/******/
/******/ })()
;

2
deps/corepack/dist/yarn.js vendored Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./corepack').runMain(['yarn', ...process.argv.slice(2)]);

2
deps/corepack/dist/yarnpkg.js vendored Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env node
require('./corepack').runMain(['yarnpkg', ...process.argv.slice(2)]);

93
deps/corepack/package.json vendored Normal file
View File

@ -0,0 +1,93 @@
{
"name": "corepack",
"version": "0.9.0",
"homepage": "https://github.com/nodejs/corepack#readme",
"bugs": {
"url": "https://github.com/nodejs/corepack/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/nodejs/corepack.git"
},
"license": "MIT",
"bin": {
"corepack": "./dist/corepack.js",
"pnpm": "./dist/pnpm.js",
"pnpx": "./dist/pnpx.js",
"yarn": "./dist/yarn.js",
"yarnpkg": "./dist/yarnpkg.js"
},
"packageManager": "yarn@3.0.0",
"devDependencies": {
"@babel/core": "^7.14.3",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-decorators": "^7.14.2",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
"@babel/plugin-transform-modules-commonjs": "^7.14.0",
"@babel/preset-typescript": "^7.13.0",
"@types/debug": "^4.1.5",
"@types/jest": "^26.0.23",
"@types/node": "^13.9.2",
"@types/semver": "^7.1.0",
"@types/tar": "^4.0.3",
"@types/which": "^1.3.2",
"@typescript-eslint/eslint-plugin": "^2.0.0",
"@typescript-eslint/parser": "^4.2.0",
"@yarnpkg/eslint-config": "^0.1.0",
"@yarnpkg/fslib": "^2.1.0",
"@zkochan/cmd-shim": "^5.0.0",
"babel-plugin-dynamic-import-node": "^2.3.3",
"clipanion": "^3.0.1",
"debug": "^4.1.1",
"eslint": "^7.10.0",
"eslint-plugin-arca": "^0.9.5",
"jest": "^26.0.0",
"nock": "^13.0.4",
"semver": "^7.1.3",
"supports-color": "^7.1.0",
"tar": "^6.0.1",
"terser-webpack-plugin": "^5.1.2",
"ts-loader": "^8.0.2",
"ts-node": "^8.10.2",
"typescript": "^4.3.2",
"v8-compile-cache": "^2.3.0",
"webpack": "^5.38.1",
"webpack-cli": "^3.3.11",
"which": "^2.0.2"
},
"scripts": {
"build": "rm -rf dist && webpack && ts-node ./mkshims.ts",
"corepack": "ts-node ./sources/main.ts",
"prepack": "node ./.yarn/releases/*.*js build",
"postpack": "rm -rf dist shims",
"test": "yarn jest"
},
"files": [
"dist",
"shims",
"LICENSE.md"
],
"publishConfig": {
"executableFiles": [
"./dist/npm.js",
"./dist/npx.js",
"./dist/pnpm.js",
"./dist/pnpx.js",
"./dist/yarn.js",
"./dist/yarnpkg.js",
"./dist/corepack.js",
"./shims/npm",
"./shims/npm.ps1",
"./shims/npx",
"./shims/npx.ps1",
"./shims/pnpm",
"./shims/pnpm.ps1",
"./shims/pnpx",
"./shims/pnpx.ps1",
"./shims/yarn",
"./shims/yarn.ps1",
"./shims/yarnpkg",
"./shims/yarnpkg.ps1"
]
}
}

12
deps/corepack/shims/corepack vendored Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../dist/corepack.js" "$@"
else
exec node "$basedir/../dist/corepack.js" "$@"
fi

7
deps/corepack/shims/corepack.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\dist\corepack.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\dist\corepack.js" %*
)

28
deps/corepack/shims/corepack.ps1 vendored Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../dist/corepack.js" $args
} else {
& "$basedir/node$exe" "$basedir/../dist/corepack.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../dist/corepack.js" $args
} else {
& "node$exe" "$basedir/../dist/corepack.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/nodewin/corepack vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/node_modules/corepack/dist/corepack.js" "$@"
else
exec node "$basedir/node_modules/corepack/dist/corepack.js" "$@"
fi

View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\node_modules\corepack\dist\corepack.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\node_modules\corepack\dist\corepack.js" %*
)

View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/node_modules/corepack/dist/corepack.js" $args
} else {
& "$basedir/node$exe" "$basedir/node_modules/corepack/dist/corepack.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/node_modules/corepack/dist/corepack.js" $args
} else {
& "node$exe" "$basedir/node_modules/corepack/dist/corepack.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/nodewin/npm vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/node_modules/corepack/dist/npm.js" "$@"
else
exec node "$basedir/node_modules/corepack/dist/npm.js" "$@"
fi

7
deps/corepack/shims/nodewin/npm.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\node_modules\corepack\dist\npm.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\node_modules\corepack\dist\npm.js" %*
)

28
deps/corepack/shims/nodewin/npm.ps1 vendored Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/node_modules/corepack/dist/npm.js" $args
} else {
& "$basedir/node$exe" "$basedir/node_modules/corepack/dist/npm.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/node_modules/corepack/dist/npm.js" $args
} else {
& "node$exe" "$basedir/node_modules/corepack/dist/npm.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/nodewin/npx vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/node_modules/corepack/dist/npx.js" "$@"
else
exec node "$basedir/node_modules/corepack/dist/npx.js" "$@"
fi

7
deps/corepack/shims/nodewin/npx.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\node_modules\corepack\dist\npx.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\node_modules\corepack\dist\npx.js" %*
)

28
deps/corepack/shims/nodewin/npx.ps1 vendored Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/node_modules/corepack/dist/npx.js" $args
} else {
& "$basedir/node$exe" "$basedir/node_modules/corepack/dist/npx.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/node_modules/corepack/dist/npx.js" $args
} else {
& "node$exe" "$basedir/node_modules/corepack/dist/npx.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/nodewin/pnpm vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/node_modules/corepack/dist/pnpm.js" "$@"
else
exec node "$basedir/node_modules/corepack/dist/pnpm.js" "$@"
fi

7
deps/corepack/shims/nodewin/pnpm.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\node_modules\corepack\dist\pnpm.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\node_modules\corepack\dist\pnpm.js" %*
)

28
deps/corepack/shims/nodewin/pnpm.ps1 vendored Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/node_modules/corepack/dist/pnpm.js" $args
} else {
& "$basedir/node$exe" "$basedir/node_modules/corepack/dist/pnpm.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/node_modules/corepack/dist/pnpm.js" $args
} else {
& "node$exe" "$basedir/node_modules/corepack/dist/pnpm.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/nodewin/pnpx vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/node_modules/corepack/dist/pnpx.js" "$@"
else
exec node "$basedir/node_modules/corepack/dist/pnpx.js" "$@"
fi

7
deps/corepack/shims/nodewin/pnpx.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\node_modules\corepack\dist\pnpx.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\node_modules\corepack\dist\pnpx.js" %*
)

28
deps/corepack/shims/nodewin/pnpx.ps1 vendored Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/node_modules/corepack/dist/pnpx.js" $args
} else {
& "$basedir/node$exe" "$basedir/node_modules/corepack/dist/pnpx.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/node_modules/corepack/dist/pnpx.js" $args
} else {
& "node$exe" "$basedir/node_modules/corepack/dist/pnpx.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/nodewin/vcc vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/node_modules/corepack/dist/vcc.js" "$@"
else
exec node "$basedir/node_modules/corepack/dist/vcc.js" "$@"
fi

7
deps/corepack/shims/nodewin/vcc.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\node_modules\corepack\dist\vcc.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\node_modules\corepack\dist\vcc.js" %*
)

28
deps/corepack/shims/nodewin/vcc.ps1 vendored Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/node_modules/corepack/dist/vcc.js" $args
} else {
& "$basedir/node$exe" "$basedir/node_modules/corepack/dist/vcc.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/node_modules/corepack/dist/vcc.js" $args
} else {
& "node$exe" "$basedir/node_modules/corepack/dist/vcc.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/nodewin/yarn vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/node_modules/corepack/dist/yarn.js" "$@"
else
exec node "$basedir/node_modules/corepack/dist/yarn.js" "$@"
fi

7
deps/corepack/shims/nodewin/yarn.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\node_modules\corepack\dist\yarn.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\node_modules\corepack\dist\yarn.js" %*
)

28
deps/corepack/shims/nodewin/yarn.ps1 vendored Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/node_modules/corepack/dist/yarn.js" $args
} else {
& "$basedir/node$exe" "$basedir/node_modules/corepack/dist/yarn.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/node_modules/corepack/dist/yarn.js" $args
} else {
& "node$exe" "$basedir/node_modules/corepack/dist/yarn.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/nodewin/yarnpkg vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/node_modules/corepack/dist/yarnpkg.js" "$@"
else
exec node "$basedir/node_modules/corepack/dist/yarnpkg.js" "$@"
fi

View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\node_modules\corepack\dist\yarnpkg.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\node_modules\corepack\dist\yarnpkg.js" %*
)

28
deps/corepack/shims/nodewin/yarnpkg.ps1 vendored Normal file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/node_modules/corepack/dist/yarnpkg.js" $args
} else {
& "$basedir/node$exe" "$basedir/node_modules/corepack/dist/yarnpkg.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/node_modules/corepack/dist/yarnpkg.js" $args
} else {
& "node$exe" "$basedir/node_modules/corepack/dist/yarnpkg.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/npm vendored Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../dist/npm.js" "$@"
else
exec node "$basedir/../dist/npm.js" "$@"
fi

7
deps/corepack/shims/npm.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\dist\npm.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\dist\npm.js" %*
)

28
deps/corepack/shims/npm.ps1 vendored Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../dist/npm.js" $args
} else {
& "$basedir/node$exe" "$basedir/../dist/npm.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../dist/npm.js" $args
} else {
& "node$exe" "$basedir/../dist/npm.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/npx vendored Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../dist/npx.js" "$@"
else
exec node "$basedir/../dist/npx.js" "$@"
fi

7
deps/corepack/shims/npx.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\dist\npx.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\dist\npx.js" %*
)

28
deps/corepack/shims/npx.ps1 vendored Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../dist/npx.js" $args
} else {
& "$basedir/node$exe" "$basedir/../dist/npx.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../dist/npx.js" $args
} else {
& "node$exe" "$basedir/../dist/npx.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/pnpm vendored Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../dist/pnpm.js" "$@"
else
exec node "$basedir/../dist/pnpm.js" "$@"
fi

7
deps/corepack/shims/pnpm.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\dist\pnpm.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\dist\pnpm.js" %*
)

28
deps/corepack/shims/pnpm.ps1 vendored Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../dist/pnpm.js" $args
} else {
& "$basedir/node$exe" "$basedir/../dist/pnpm.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../dist/pnpm.js" $args
} else {
& "node$exe" "$basedir/../dist/pnpm.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/pnpx vendored Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../dist/pnpx.js" "$@"
else
exec node "$basedir/../dist/pnpx.js" "$@"
fi

7
deps/corepack/shims/pnpx.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\dist\pnpx.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\dist\pnpx.js" %*
)

28
deps/corepack/shims/pnpx.ps1 vendored Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../dist/pnpx.js" $args
} else {
& "$basedir/node$exe" "$basedir/../dist/pnpx.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../dist/pnpx.js" $args
} else {
& "node$exe" "$basedir/../dist/pnpx.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/yarn vendored Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../dist/yarn.js" "$@"
else
exec node "$basedir/../dist/yarn.js" "$@"
fi

7
deps/corepack/shims/yarn.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\dist\yarn.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\dist\yarn.js" %*
)

28
deps/corepack/shims/yarn.ps1 vendored Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../dist/yarn.js" $args
} else {
& "$basedir/node$exe" "$basedir/../dist/yarn.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../dist/yarn.js" $args
} else {
& "node$exe" "$basedir/../dist/yarn.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

12
deps/corepack/shims/yarnpkg vendored Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../dist/yarnpkg.js" "$@"
else
exec node "$basedir/../dist/yarnpkg.js" "$@"
fi

7
deps/corepack/shims/yarnpkg.cmd vendored Normal file
View File

@ -0,0 +1,7 @@
@IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\dist\yarnpkg.js" %*
) ELSE (
@SETLOCAL
@SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\dist\yarnpkg.js" %*
)

28
deps/corepack/shims/yarnpkg.ps1 vendored Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../dist/yarnpkg.js" $args
} else {
& "$basedir/node$exe" "$basedir/../dist/yarnpkg.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../dist/yarnpkg.js" $args
} else {
& "node$exe" "$basedir/../dist/yarnpkg.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

119
doc/api/corepack.md Normal file
View File

@ -0,0 +1,119 @@
# Corepack
<!-- introduced_in=REPLACEME -->
<!-- type=misc -->
> Stability: 1 - Experimental
_[Corepack][]_ is an experimental tool to help with
managing versions of your package managers. It exposes binary proxies for
each [supported package manager][] that, when called, will identify whatever
package manager is configured for the current project, transparently install
it if needed, and finally run it without requiring explicit user interactions.
This feature simplifies two core workflows:
* It eases new contributor onboarding, since they won't have to follow
system-specific installation processes anymore just to have the package
manager you want them to.
* It allows you to ensure that everyone in your team will use exactly the
package manager version you intend them to, without them having to
manually synchronize it each time you need to make an update.
## Workflows
### Enabling the feature
Due to its experimental status, Corepack currently needs to be explicitly
enabled to have any effect. To do that simply run [`corepack enable`][], which
will set up the symlinks in your environment, next to the `node` binary
(and overwrite the existing symlinks if necessary).
From this point forward, any call to the [supported binaries][] will work
without further setup. Should you experience a problem, just run
[`corepack disable`][] to remove the proxies from your system (and consider
opening up an issue on the [Corepack repository][] to let us know).
### Configuring a package
The Corepack proxies will find the closest [`package.json`][] file in your
current directory hierarchy to extract its [`"packageManager"`][] property.
If the value corresponds to a [supported package manager][], Corepack will make
sure that all calls to the relevant binaries are run against the requested
version, downloading it on demand if needed, and aborting if it cannot be
successfully retrieved.
### Upgrading the global versions
When running outside of an existing project (for example when running
`yarn init`), Corepack will by default use predefined versions roughly
corresponding to the latest stable releases from each tool. Those versions can
be easily overriden by running the [`corepack prepare`][] command along with the
package manager version you wish to set:
```bash
corepack prepare yarn@x.y.z --activate
```
### Offline workflow
Many production environments don't have network access. Since Corepack
usually downloads the package manager releases straight from their registries,
it can conflict with such environments. To avoid that happening, call the
[`corepack prepare`][] command while you still have network access (typically at
the same time you're preparing your deploy image). This will ensure that the
required package managers are available even without network access.
The `prepare` command has [various flags][], consult the detailed
[Corepack documentation][] for more information on the matter.
## Supported package managers
The following binaries are provided through Corepack:
| Package manager | Binary names |
| --------------- | -------------- |
| [Yarn][] | `yarn`, `yarnpkg` |
| [pnpm][] | `pnpm`, `pnpx` |
## Common questions
### How does Corepack currently interact with npm?
While Corepack could easily support npm like any other package manager, its
shims aren't currently enabled by default. This has a few consequences:
* It's always possible to run a `npm` command within a project configured to
be used with another package manager, since Corepack cannot intercept it.
* While `npm` is a valid option in the [`"packageManager"`][] property, the
lack of shim will cause the global npm to be used.
### Running `npm install -g yarn` doesn't work
npm prevents accidentally overriding the Corepack binaries when doing a global
install. To avoid this problem, consider one of the following options:
* Don't run this command anymore; Corepack will provide the package manager
binaries anyway and will ensure that the requested versions are always
available, so installing the package managers explicitly isn't needed anymore.
* Add the `--force` to `npm install`; this will tell npm that it's fine to
override binaries, but you'll erase the Corepack ones in the process (should
that happen, run [`corepack enable`][] again to add them back).
[Corepack]: https://github.com/nodejs/corepack
[Corepack documentation]: https://github.com/nodejs/corepack#readme
[Corepack repository]: https://github.com/nodejs/corepack
[Yarn]: https://yarnpkg.com
[`"packageManager"`]: packages.md#packages_packagemanager
[`corepack disable`]: https://github.com/nodejs/corepack#corepack-disable--name
[`corepack enable`]: https://github.com/nodejs/corepack#corepack-enable--name
[`corepack prepare`]: https://github.com/nodejs/corepack#corepack-prepare--nameversion
[`package.json`]: packages.md#packages_node_js_package_json_field_definitions
[pnpm]: https://pnpm.js.org
[supported binaries]: #corepack_supported_package_managers
[supported package manager]: #corepack_supported_package_managers
[various flags]: https://github.com/nodejs/corepack#utility-commands

View File

@ -21,6 +21,7 @@
* [Cluster](cluster.md)
* [Command-line options](cli.md)
* [Console](console.md)
* [Corepack](corepack.md)
* [Crypto](crypto.md)
* [Debugger](debugger.md)
* [Deprecated APIs](deprecations.md)

View File

@ -156,6 +156,21 @@ For completeness there is also `--input-type=commonjs`, for explicitly running
string input as CommonJS. This is the default behavior if `--input-type` is
unspecified.
## Determining package manager
> Stability: 1 - Experimental
While all Node.js projects are expected to be installable by all package
managers once published, their development teams are often required to use one
specific package manager. To make this process easier, Node.js ships with a
tool called [Corepack][] that aims to make all package managers transparently
available in your environment - provided you have Node.js installed.
By default Corepack won't enforce any specific package manager and will use
the generic "Last Known Good" versions associated with each Node.js release,
but you can improve this experience by setting the [`"packageManager"`][] field
in your project's `package.json`.
## Package entry points
In a packages `package.json` file, two fields can define entry points for a
@ -1008,6 +1023,8 @@ The following fields in `package.json` files are used in Node.js:
by package managers as the name of the package.
* [`"main"`][] - The default module when loading the package, if exports is not
specified, and in versions of Node.js prior to the introduction of exports.
* [`"packageManager"`][] - The package manager recommended when contributing to
the package. Leveraged by the [Corepack][] shims.
* [`"type"`][] - The package type determining whether to load `.js` files as
CommonJS or ES modules.
* [`"exports"`][] - Package exports and conditional exports. When present,
@ -1067,6 +1084,30 @@ require('./path/to/directory'); // This resolves to ./path/to/directory/main.js.
When a package has an [`"exports"`][] field, this will take precedence over the
`"main"` field when importing the package by name.
### `"packageManager"`
<!-- YAML
added: REPLACEME
-->
> Stability: 1 - Experimental
* Type: {string}
```json
{
"packageManager": "<package manager name>@<version>"
}
```
The `"packageManager"` field defines which package manager is expected to be
used when working on the current project. It can set to any of the
[supported package managers][], and will ensure that your teams use the exact
same package manager versions without having to install anything else than
Node.js.
This field is currently experimental and needs to be opted-in; check the
[Corepack][] page for details about the procedure.
### `"type"`
<!-- YAML
added: v12.0.0
@ -1199,6 +1240,7 @@ This field defines [subpath imports][] for the current package.
[Babel]: https://babeljs.io/
[CommonJS]: modules.md
[Conditional exports]: #packages_conditional_exports
[Corepack]: corepack.md
[ES module]: esm.md
[ES modules]: esm.md
[Node.js documentation for this section]: https://github.com/nodejs/node/blob/HEAD/doc/api/packages.md#conditions-definitions
@ -1206,6 +1248,7 @@ This field defines [subpath imports][] for the current package.
[`"imports"`]: #packages_imports
[`"main"`]: #packages_main
[`"name"`]: #packages_name
[`"packageManager"`]: #packages_packagemanager
[`"type"`]: #packages_type
[`ERR_PACKAGE_PATH_NOT_EXPORTED`]: errors.md#errors_err_package_path_not_exported
[`esm`]: https://github.com/standard-things/esm#readme
@ -1215,5 +1258,6 @@ This field defines [subpath imports][] for the current package.
[subpath exports]: #packages_subpath_exports
[subpath imports]: #packages_subpath_imports
[subpath patterns]: #packages_subpath_patterns
[supported package managers]: corepack.md#corepack_supported_package_managers
[the dual CommonJS/ES module packages section]: #packages_dual_commonjs_es_module_packages
[the full specifier path]: esm.md#esm_mandatory_file_extensions

View File

@ -0,0 +1,18 @@
'use strict';
require('../common');
const path = require('path');
const assert = require('assert');
const corepackPathPackageJson = path.resolve(
__dirname,
'..',
'..',
'deps',
'corepack',
'package.json'
);
const pkg = require(corepackPathPackageJson);
assert(pkg.version.match(/^\d+\.\d+\.\d+$/),
`unexpected version number: ${pkg.version}`);

View File

@ -0,0 +1,63 @@
'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const path = require('path');
const exec = require('child_process').exec;
const assert = require('assert');
const fs = require('fs');
const fixtures = require('../common/fixtures');
const tmpdir = require('../common/tmpdir');
tmpdir.refresh();
const npmSandbox = path.join(tmpdir.path, 'npm-sandbox');
fs.mkdirSync(npmSandbox);
const homeDir = path.join(tmpdir.path, 'home');
fs.mkdirSync(homeDir);
const installDir = path.join(tmpdir.path, 'install-dir');
fs.mkdirSync(installDir);
const corepackYarnPath = path.join(
__dirname,
'..',
'..',
'deps',
'corepack',
'dist',
'yarn.js'
);
const pkgContent = JSON.stringify({
dependencies: {
'package-name': fixtures.path('packages/main')
}
});
const pkgPath = path.join(installDir, 'package.json');
fs.writeFileSync(pkgPath, pkgContent);
const env = { ...process.env,
PATH: path.dirname(process.execPath),
NPM_CONFIG_PREFIX: path.join(npmSandbox, 'npm-prefix'),
NPM_CONFIG_TMP: path.join(npmSandbox, 'npm-tmp'),
HOME: homeDir };
exec(`${process.execPath} ${corepackYarnPath} install`, {
cwd: installDir,
env: env
}, common.mustCall(handleExit));
function handleExit(error, stdout, stderr) {
const code = error ? error.code : 0;
const signalCode = error ? error.signal : null;
if (code !== 0) {
process.stderr.write(stderr);
}
assert.strictEqual(code, 0, `yarn install got error code ${code}`);
assert.strictEqual(signalCode, null, `unexpected signal: ${signalCode}`);
assert(fs.existsSync(`${installDir}/node_modules/package-name`));
}

View File

@ -79,8 +79,8 @@ def uninstall(paths, dst):
for path in paths:
try_remove(path, dst)
def npm_files(action):
target_path = 'lib/node_modules/npm/'
def package_files(action, name, bins):
target_path = 'lib/node_modules/' + name + '/'
# don't install npm if the target path is a symlink, it probably means
# that a dev version of npm is installed there
@ -88,28 +88,37 @@ def npm_files(action):
# npm has a *lot* of files and it'd be a pain to maintain a fixed list here
# so we walk its source directory instead...
for dirname, subdirs, basenames in os.walk('deps/npm', topdown=True):
root = 'deps/' + name
for dirname, subdirs, basenames in os.walk(root, topdown=True):
subdirs[:] = [subdir for subdir in subdirs if subdir != 'test']
paths = [os.path.join(dirname, basename) for basename in basenames]
action(paths, target_path + dirname[9:] + '/')
action(paths, target_path + dirname[len(root) + 1:] + '/')
# create/remove symlink
link_path = abspath(install_path, 'bin/npm')
if action == uninstall:
action([link_path], 'bin/npm')
elif action == install:
try_symlink('../lib/node_modules/npm/bin/npm-cli.js', link_path)
else:
assert 0 # unhandled action type
# create/remove symlinks
for bin_name, bin_target in bins.items():
link_path = abspath(install_path, 'bin/' + bin_name)
if action == uninstall:
action([link_path], 'bin/' + bin_name)
elif action == install:
try_symlink('../lib/node_modules/' + name + '/' + bin_target, link_path)
else:
assert 0 # unhandled action type
# create/remove symlink
link_path = abspath(install_path, 'bin/npx')
if action == uninstall:
action([link_path], 'bin/npx')
elif action == install:
try_symlink('../lib/node_modules/npm/bin/npx-cli.js', link_path)
else:
assert 0 # unhandled action type
def npm_files(action):
package_files(action, 'npm', {
'npm': 'bin/npm-cli.js',
'npx': 'bin/npx-cli.js',
})
def corepack_files(action):
package_files(action, 'corepack', {
'corepack': 'dist/corepack.js',
# Not the default just yet:
# 'yarn': 'dist/yarn.js',
# 'yarnpkg': 'dist/yarn.js',
# 'pnpm': 'dist/pnpm.js',
# 'pnpx': 'dist/pnpx.js',
})
def subdir_files(path, dest, action):
ret = {}
@ -152,7 +161,9 @@ def files(action):
else:
action(['doc/node.1'], 'share/man/man1/')
if 'true' == variables.get('node_install_npm'): npm_files(action)
if 'true' == variables.get('node_install_npm'):
npm_files(action)
corepack_files(action)
headers(action)

View File

@ -59,6 +59,7 @@ fi
addlicense "libuv" "deps/uv" "$(cat "${rootdir}"/deps/uv/LICENSE)"
addlicense "llhttp" "deps/llhttp" "$(cat deps/llhttp/LICENSE-MIT)"
addlicense "corepack" "deps/corepack" "$(cat "${rootdir}"/deps/corepack/LICENSE.md)"
addlicense "OpenSSL" "deps/openssl" \
"$(sed -e '/^ \*\/$/,$d' -e '/^ [^*].*$/d' -e '/\/\*.*$/d' -e '/^$/d' -e 's/^[/ ]\* *//' "${rootdir}"/deps/openssl/openssl/LICENSE)"
addlicense "Punycode.js" "lib/punycode.js" \

View File

@ -18,6 +18,9 @@
<String Id="npm_Title">npm-Paketmanager</String>
<String Id="npm_Description">Installiert npm, den empfohlenen Paketmanager für [ProductName].</String>
<String Id="corepack_Title">corepack manager</String>
<String Id="corepack_Description">Install corepack, the universal package manager for [ProductName].</String>
<String Id="DocumentationShortcuts_Title">Link zur Online-Dokumentation</String>
<String Id="DocumentationShortcuts_Description">Fügt Startmenü-Einträge zur Online-Dokumentation von [ProductName] [FullVersion] und zur [ProductName]-Website hinzu.</String>

View File

@ -26,6 +26,9 @@
<String Id="npm_Title">npm package manager</String>
<String Id="npm_Description">Install npm, the recommended package manager for [ProductName].</String>
<String Id="corepack_Title">corepack manager</String>
<String Id="corepack_Description">Install corepack, the universal package manager for [ProductName].</String>
<String Id="DocumentationShortcuts_Title">Online documentation shortcuts</String>
<String Id="DocumentationShortcuts_Description">Add start menu entries that link the online documentation for [ProductName] [FullVersion] and the [ProductName] website.</String>

View File

@ -18,6 +18,9 @@
<String Id="npm_Title">npm package manager</String>
<String Id="npm_Description">Installa npm, il package manager raccomandato per [ProductName].</String>
<String Id="corepack_Title">corepack manager</String>
<String Id="corepack_Description">Installa corepack, il package manager universale per [ProductName].</String>
<String Id="DocumentationShortcuts_Title">Collegamenti alla documentazione online</String>
<String Id="DocumentationShortcuts_Description">Aggiunge i collegamenti al menu start alla documentazione online per [ProductName] [FullVersion] e per il sito web di [ProductName].</String>

View File

@ -18,6 +18,9 @@
<String Id="npm_Title">npm 包管理器</String>
<String Id="npm_Description">安装 npm [ProductName] 的推荐包管理器。</String>
<String Id="corepack_Title">corepack manager</String>
<String Id="corepack_Description">Install corepack, the universal package manager for [ProductName].</String>
<String Id="DocumentationShortcuts_Title">在线文档的快捷方式</String>
<String Id="DocumentationShortcuts_Description">在开始菜单内添加 [ProductName] [FullVersion] 的在线文档链接和 [ProductName] 的网站链接。</String>

View File

@ -16,33 +16,33 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<OutputPath>..\..\..\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;ProgramFilesFolderId=ProgramFilesFolder</DefineConstants>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;CorepackSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\corepack\;ProgramFilesFolderId=ProgramFilesFolder</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<OutputPath>..\..\..\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;ProgramFilesFolderId=ProgramFilesFolder</DefineConstants>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;CorepackSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\corepack\;ProgramFilesFolderId=ProgramFilesFolder</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
<OutputPath>..\..\..\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;CorepackSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\corepack\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
<Cultures>en-US</Cultures>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
<OutputPath>..\..\..\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;CorepackSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\corepack\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|arm64' ">
<OutputPath>..\..\..\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;CorepackSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\corepack\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|arm64' ">
<OutputPath>..\..\..\</OutputPath>
<IntermediateOutputPath>obj\$(Configuration)\</IntermediateOutputPath>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
<DefineConstants>Debug;ProductVersion=$(NodeVersion);FullVersion=$(FullVersion);DistTypeDir=$(DistTypeDir);NoETW=$(NoETW);NpmSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm\;CorepackSourceDir=..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\corepack\;ProgramFilesFolderId=ProgramFiles64Folder</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<EnableProjectHarvesting>True</EnableProjectHarvesting>
@ -52,6 +52,9 @@
<Compile Include="..\..\..\npm.wxs">
<Link>npm.wxs</Link>
</Compile>
<Compile Include="..\..\..\corepack.wxs">
<Link>corepack.wxs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<WixExtension Include="WixUIExtension">
@ -85,6 +88,8 @@
<Target Name="BeforeBuild">
<HeatDirectory ToolPath="$(WixToolPath)" Directory="..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\npm" PreprocessorVariable="var.NpmSourceDir" DirectoryRefId="NodeModulesFolder" ComponentGroupName="NpmSourceFiles" GenerateGuidsNow="true" SuppressFragments="false" OutputFile="..\..\..\npm.wxs" RunAsSeparateProcess="true">
</HeatDirectory>
<HeatDirectory ToolPath="$(WixToolPath)" Directory="..\..\..\Release\node-v$(FullVersion)-win-$(Platform)\node_modules\corepack" PreprocessorVariable="var.CorepackSourceDir" DirectoryRefId="NodeModulesFolder" ComponentGroupName="CorepackSourceFiles" GenerateGuidsNow="true" SuppressFragments="false" OutputFile="..\..\..\corepack.wxs" RunAsSeparateProcess="true">
</HeatDirectory>
</Target>
<PropertyGroup>
<PostBuildEvent>move "!(TargetPath)" "$(TargetDir)\$(TargetFileName)"

View File

@ -89,6 +89,15 @@
</Feature>
</Feature>
<Feature Id="corepack"
Level="1"
Title="!(loc.corepack_Title)"
Description="!(loc.corepack_Description)">
<ComponentRef Id="CorepackCmdScript"/>
<ComponentRef Id="CorepackBashScript"/>
<ComponentGroupRef Id="CorepackSourceFiles"/>
</Feature>
<Feature Id="npm"
Level="1"
Title="!(loc.npm_Title)"
@ -226,6 +235,14 @@
</DirectoryRef>
<DirectoryRef Id="INSTALLDIR">
<Component Id="CorepackCmdScript">
<File Id="corepack.cmd" KeyPath="yes" Source="$(var.CorepackSourceDir)\shims\nodewin\corepack.cmd"/>
</Component>
<Component Id="CorepackBashScript">
<File Id="corepack.sh" KeyPath="yes" Source="$(var.CorepackSourceDir)\shims\nodewin\corepack"/>
</Component>
<Component Id="NpmCmdScript">
<File Id="npm.cmd" KeyPath="yes" Source="$(var.NpmSourceDir)\bin\npm.cmd"/>
</Component>

View File

@ -2,5 +2,8 @@
# TODO Can this be done inside the .pmdoc?
# TODO Can we extract $PREFIX from the installer?
cd /usr/local/bin || exit
ln -sf ../lib/node_modules/npm/bin/npm-cli.js npm
ln -sf ../lib/node_modules/npm/bin/npx-cli.js npx
ln -sf ../lib/node_modules/corepack/dist/corepack.js corepack

View File

@ -405,6 +405,8 @@ copy /Y ..\CHANGELOG.md %TARGET_NAME%\ > nul
if errorlevel 1 echo Cannot copy CHANGELOG.md && goto package_error
robocopy ..\deps\npm %TARGET_NAME%\node_modules\npm /e /xd test > nul
if errorlevel 8 echo Cannot copy npm package && goto package_error
robocopy ..\deps\corepack %TARGET_NAME%\node_modules\corepack /e /xd test > nul
if errorlevel 8 echo Cannot copy corepack package && goto package_error
copy /Y ..\deps\npm\bin\npm %TARGET_NAME%\ > nul
if errorlevel 1 echo Cannot copy npm && goto package_error
copy /Y ..\deps\npm\bin\npm.cmd %TARGET_NAME%\ > nul
@ -413,6 +415,10 @@ copy /Y ..\deps\npm\bin\npx %TARGET_NAME%\ > nul
if errorlevel 1 echo Cannot copy npx && goto package_error
copy /Y ..\deps\npm\bin\npx.cmd %TARGET_NAME%\ > nul
if errorlevel 1 echo Cannot copy npx.cmd && goto package_error
copy /Y ..\deps\corepack\shims\nodewin\corepack %TARGET_NAME%\ > nul
if errorlevel 1 echo Cannot copy corepack && goto package_error
copy /Y ..\deps\corepack\shims\nodewin\corepack.cmd %TARGET_NAME%\ > nul
if errorlevel 1 echo Cannot copy corepack.cmd && goto package_error
copy /Y ..\tools\msvs\nodevars.bat %TARGET_NAME%\ > nul
if errorlevel 1 echo Cannot copy nodevars.bat && goto package_error
copy /Y ..\tools\msvs\install_tools\*.* %TARGET_NAME%\ > nul