From 07b47ad58c85b8f54712f902b3b2c9b729fac448 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Sun, 30 Oct 2022 10:34:55 -0400 Subject: [PATCH] deps: update corepack to 0.15.0 PR-URL: https://github.com/nodejs/node/pull/45235 Reviewed-By: Antoine du Hamel Reviewed-By: Mohammed Keyvanzadeh Reviewed-By: Moshe Atlow --- deps/corepack/CHANGELOG.md | 15 +++ deps/corepack/README.md | 50 ++++++---- deps/corepack/dist/corepack.js | 166 +++++++++++++++++++++++---------- deps/corepack/package.json | 2 +- 4 files changed, 168 insertions(+), 65 deletions(-) diff --git a/deps/corepack/CHANGELOG.md b/deps/corepack/CHANGELOG.md index 8b66751f0f4b7a..6c4d6a21f0cd6f 100644 --- a/deps/corepack/CHANGELOG.md +++ b/deps/corepack/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## [0.15.0](https://github.com/nodejs/corepack/compare/v0.14.2...v0.15.0) (2022-10-28) + + +### Features + +* add support for configurable registries and applicable auth options ([#186](https://github.com/nodejs/corepack/issues/186)) ([662ae90](https://github.com/nodejs/corepack/commit/662ae9057c7360cb05e9476914e611a9bf0074db)) +* update package manager versions ([#193](https://github.com/nodejs/corepack/issues/193)) ([0ec3a73](https://github.com/nodejs/corepack/commit/0ec3a7384729c5cf4ac566d91f1a4bb74e08a64f)) +* when strict checking is off, treat like transparent ([#197](https://github.com/nodejs/corepack/issues/197)) ([5eadc50](https://github.com/nodejs/corepack/commit/5eadc50192e205c60bfb1cad91854e9014a747b8)) + + +### Bug Fixes + +* **doc:** add package configuration instruction to readme ([#188](https://github.com/nodejs/corepack/issues/188)) ([0b7abb9](https://github.com/nodejs/corepack/commit/0b7abb9833d332bad97902260d31652482c274a0)) +* recreate cache folder if necessary ([#200](https://github.com/nodejs/corepack/issues/200)) ([7b5f2f9](https://github.com/nodejs/corepack/commit/7b5f2f9fcb24fe3fe517a96deaac7f32854f3124)) + ## [0.14.2](https://github.com/nodejs/corepack/compare/v0.14.1...v0.14.2) (2022-09-24) ### Features diff --git a/deps/corepack/README.md b/deps/corepack/README.md index 8ba03a760f2906..8d76baea4bbf8d 100644 --- a/deps/corepack/README.md +++ b/deps/corepack/README.md @@ -36,6 +36,8 @@ We do acknowledge the irony and overhead of using npm to install Corepack, which ## Usage +### When Building Packages + 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. @@ -44,6 +46,18 @@ Just use your package managers as you usually would. Run `yarn install` in Yarn - **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. +### When Authoring Packages + +Set your package's manager with the `packageManager` field in `package.json`: + +```json +{ + "packageManager": "yarn@3.2.3+sha224.953c8233f7a92884eee2de69a1b92d1f2ec1655e66d08071ba9a02fa" +} +``` + +Here, `yarn` is the name of the package manager, specified at version `3.2.3`, along with the SHA-224 hash of this version for validation. `packageManager@x.y.z` is required. The hash is optional but strongly recommended as a security practice. Permitted values for the package manager are `yarn`, `npm`, and `pnpm`. + ## Known Good Releases When running Corepack within projects that don't list a supported package @@ -120,8 +134,17 @@ This command will retrieve the given package manager from the specified archive manager versions that will be required for the projects you'll run, using `corepack hydrate`). -- `COREPACK_ENABLE_STRICT` can be set to `0` to prevent Corepack from checking +- `COREPACK_ENABLE_STRICT` can be set to `0` to prevent Corepack from throwing error + if the package manager does not correspond to the one defined for the current project. + This means that if a user is using the package manager specified in the current project, + it will use the version specified by the project's `packageManager` field. + But if the user is using other package manager different from the one specified + for the current project, it will use the system-wide package manager version. + +- `COREPACK_ENABLE_PROJECT_SPEC` can be set to `0` to prevent Corepack from checking if the package manager corresponds to the one defined for the current project. + This means that it will always use the system-wide package manager regardless of + what is being specified in the project's `packageManager` field. - `COREPACK_HOME` can be set in order to define where Corepack should install the package managers. By default it is set to `%LOCALAPPDATA%\node\corepack` @@ -129,29 +152,22 @@ This command will retrieve the given package manager from the specified archive - `COREPACK_ROOT` 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`). -- `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` are supported through [`node-proxy-agent`](https://github.com/TooTallNate/node-proxy-agent). +- `COREPACK_NPM_REGISTRY` sets the registry base url used when retrieving package managers from npm. Default value is `https://registry.npmjs.org` -## Contributing +- `COREPACK_NPM_TOKEN` sets a Bearer token authorization header when connecting to a npm type registry. -If you want to build corepack yourself, you can build the project like this: +- `COREPACK_NPM_USERNAME` and `COREPACK_NPM_PASSWORD` to set a Basic authorization header when connecting to a npm type registry. Note that both environment variables are required and as plain text. If you want to send an empty password, explicitly set `COREPACK_NPM_PASSWORD` to an empty string. -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 +- `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` are supported through [`node-proxy-agent`](https://github.com/TooTallNate/node-proxy-agent). + +## Contributing -You can also run the tests with `yarn jest` (still no install needed). +See [`CONTRIBUTING.md`](./CONTRIBUTING.md). ## Design -Various tidbits about Corepack's design are explained in more details in [DESIGN.md](/DESIGN.md). +See [`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. +See [`LICENSE.md`](./LICENSE.md). diff --git a/deps/corepack/dist/corepack.js b/deps/corepack/dist/corepack.js index aff9562e4e4187..3ec24032fa4940 100755 --- a/deps/corepack/dist/corepack.js +++ b/deps/corepack/dist/corepack.js @@ -15471,7 +15471,7 @@ EnableCommand.usage = clipanion__WEBPACK_IMPORTED_MODULE_6__.Command.Usage({ By default it will locate the install directory by running the equivalent of \`which corepack\`, but this can be tweaked by explicitly passing the install directory via the \`--install-directory\` flag. `, examples: [[ - `Enable all shims, putting them next to the \`corepath\` binary`, + `Enable all shims, putting them next to the \`corepack\` binary`, `$0 enable`, ], [ `Enable all shims, putting them in the specified directory`, @@ -15496,26 +15496,29 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "HydrateCommand": () => (/* binding */ HydrateCommand) /* harmony export */ }); -/* harmony import */ var clipanion__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! clipanion */ "./.yarn/__virtual__/clipanion-virtual-72ec1bc418/4/.yarn/berry/cache/clipanion-npm-3.1.0-ced87dbbea-9.zip/node_modules/clipanion/lib/advanced/index.js"); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! path */ "path"); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _folderUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../folderUtils */ "./sources/folderUtils.ts"); -/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../types */ "./sources/types.ts"); +/* harmony import */ var clipanion__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! clipanion */ "./.yarn/__virtual__/clipanion-virtual-72ec1bc418/4/.yarn/berry/cache/clipanion-npm-3.1.0-ced87dbbea-9.zip/node_modules/clipanion/lib/advanced/index.js"); +/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fs/promises */ "fs/promises"); +/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ "path"); +/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _folderUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../folderUtils */ "./sources/folderUtils.ts"); +/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../types */ "./sources/types.ts"); -class HydrateCommand extends clipanion__WEBPACK_IMPORTED_MODULE_3__.Command { + +class HydrateCommand extends clipanion__WEBPACK_IMPORTED_MODULE_4__.Command { constructor() { super(...arguments); - this.activate = clipanion__WEBPACK_IMPORTED_MODULE_3__.Option.Boolean(`--activate`, false, { + this.activate = clipanion__WEBPACK_IMPORTED_MODULE_4__.Option.Boolean(`--activate`, false, { description: `If true, this release will become the default one for this package manager`, }); - this.fileName = clipanion__WEBPACK_IMPORTED_MODULE_3__.Option.String(); + this.fileName = clipanion__WEBPACK_IMPORTED_MODULE_4__.Option.String(); } async execute() { - const installFolder = _folderUtils__WEBPACK_IMPORTED_MODULE_1__.getInstallFolder(); - const fileName = path__WEBPACK_IMPORTED_MODULE_0___default().resolve(this.context.cwd, this.fileName); + const installFolder = _folderUtils__WEBPACK_IMPORTED_MODULE_2__.getInstallFolder(); + const fileName = path__WEBPACK_IMPORTED_MODULE_1___default().resolve(this.context.cwd, this.fileName); const archiveEntries = new Map(); let hasShortEntries = false; const { default: tar } = await Promise.resolve(/*! import() eager */).then(__webpack_require__.t.bind(__webpack_require__, /*! tar */ "../../../.yarn/berry/cache/tar-npm-6.1.11-e6ac3cba9c-9.zip/node_modules/tar/index.js", 19)); @@ -15532,15 +15535,17 @@ class HydrateCommand extends clipanion__WEBPACK_IMPORTED_MODULE_3__.Command { } } }); if (hasShortEntries || archiveEntries.size < 1) - throw new clipanion__WEBPACK_IMPORTED_MODULE_3__.UsageError(`Invalid archive format; did it get generated by 'corepack prepare'?`); + throw new clipanion__WEBPACK_IMPORTED_MODULE_4__.UsageError(`Invalid archive format; did it get generated by 'corepack prepare'?`); for (const [name, references] of archiveEntries) { for (const reference of references) { - if (!(0,_types__WEBPACK_IMPORTED_MODULE_2__.isSupportedPackageManager)(name)) - throw new clipanion__WEBPACK_IMPORTED_MODULE_3__.UsageError(`Unsupported package manager '${name}'`); + if (!(0,_types__WEBPACK_IMPORTED_MODULE_3__.isSupportedPackageManager)(name)) + throw new clipanion__WEBPACK_IMPORTED_MODULE_4__.UsageError(`Unsupported package manager '${name}'`); if (this.activate) this.context.stdout.write(`Hydrating ${name}@${reference} for immediate activation...\n`); else this.context.stdout.write(`Hydrating ${name}@${reference}...\n`); + // Recreate the folder in case it was deleted somewhere else: + await (0,fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir)(installFolder, { recursive: true }); await tar.x({ file: fileName, cwd: installFolder }, [`${name}/${reference}`]); if (this.activate) { await this.context.engine.activatePackageManager({ name, reference }); @@ -15553,7 +15558,7 @@ class HydrateCommand extends clipanion__WEBPACK_IMPORTED_MODULE_3__.Command { HydrateCommand.paths = [ [`hydrate`], ]; -HydrateCommand.usage = clipanion__WEBPACK_IMPORTED_MODULE_3__.Command.Usage({ +HydrateCommand.usage = clipanion__WEBPACK_IMPORTED_MODULE_4__.Command.Usage({ description: `Import a package manager into the cache`, details: ` This command unpacks a package manager archive into the cache. The archive must have been generated by the \`corepack prepare\` command - no other will work. @@ -15578,47 +15583,50 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "PrepareCommand": () => (/* binding */ PrepareCommand) /* harmony export */ }); -/* harmony import */ var clipanion__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! clipanion */ "./.yarn/__virtual__/clipanion-virtual-72ec1bc418/4/.yarn/berry/cache/clipanion-npm-3.1.0-ced87dbbea-9.zip/node_modules/clipanion/lib/advanced/index.js"); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! path */ "path"); -/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _folderUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../folderUtils */ "./sources/folderUtils.ts"); -/* harmony import */ var _specUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../specUtils */ "./sources/specUtils.ts"); +/* harmony import */ var clipanion__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! clipanion */ "./.yarn/__virtual__/clipanion-virtual-72ec1bc418/4/.yarn/berry/cache/clipanion-npm-3.1.0-ced87dbbea-9.zip/node_modules/clipanion/lib/advanced/index.js"); +/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! fs/promises */ "fs/promises"); +/* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(fs_promises__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! path */ "path"); +/* harmony import */ var path__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _folderUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../folderUtils */ "./sources/folderUtils.ts"); +/* harmony import */ var _specUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../specUtils */ "./sources/specUtils.ts"); + -class PrepareCommand extends clipanion__WEBPACK_IMPORTED_MODULE_3__.Command { +class PrepareCommand extends clipanion__WEBPACK_IMPORTED_MODULE_4__.Command { constructor() { super(...arguments); - this.activate = clipanion__WEBPACK_IMPORTED_MODULE_3__.Option.Boolean(`--activate`, false, { + this.activate = clipanion__WEBPACK_IMPORTED_MODULE_4__.Option.Boolean(`--activate`, false, { description: `If true, this release will become the default one for this package manager`, }); - this.all = clipanion__WEBPACK_IMPORTED_MODULE_3__.Option.Boolean(`--all`, false, { + this.all = clipanion__WEBPACK_IMPORTED_MODULE_4__.Option.Boolean(`--all`, false, { description: `If true, all available default package managers will be installed`, }); - this.json = clipanion__WEBPACK_IMPORTED_MODULE_3__.Option.Boolean(`--json`, false, { + this.json = clipanion__WEBPACK_IMPORTED_MODULE_4__.Option.Boolean(`--json`, false, { description: `If true, the output will be the path of the generated tarball`, }); - this.output = clipanion__WEBPACK_IMPORTED_MODULE_3__.Option.String(`-o,--output`, { + this.output = clipanion__WEBPACK_IMPORTED_MODULE_4__.Option.String(`-o,--output`, { description: `If true, the installed package managers will also be stored in a tarball`, tolerateBoolean: true, }); - this.specs = clipanion__WEBPACK_IMPORTED_MODULE_3__.Option.Rest(); + this.specs = clipanion__WEBPACK_IMPORTED_MODULE_4__.Option.Rest(); } async execute() { if (this.all && this.specs.length > 0) - throw new clipanion__WEBPACK_IMPORTED_MODULE_3__.UsageError(`The --all option cannot be used along with an explicit package manager specification`); + throw new clipanion__WEBPACK_IMPORTED_MODULE_4__.UsageError(`The --all option cannot be used along with an explicit package manager specification`); const specs = this.all ? await this.context.engine.getDefaultDescriptors() : this.specs; const installLocations = []; if (specs.length === 0) { - const lookup = await _specUtils__WEBPACK_IMPORTED_MODULE_2__.loadSpec(this.context.cwd); + const lookup = await _specUtils__WEBPACK_IMPORTED_MODULE_3__.loadSpec(this.context.cwd); switch (lookup.type) { case `NoProject`: - throw new clipanion__WEBPACK_IMPORTED_MODULE_3__.UsageError(`Couldn't find a project in the local directory - please explicit the package manager to pack, or run this command from a valid project`); + throw new clipanion__WEBPACK_IMPORTED_MODULE_4__.UsageError(`Couldn't find a project in the local directory - please explicit the package manager to pack, or run this command from a valid project`); case `NoSpec`: - throw new clipanion__WEBPACK_IMPORTED_MODULE_3__.UsageError(`The local project doesn't feature a 'packageManager' field - please explicit the package manager to pack, or update the manifest to reference it`); + throw new clipanion__WEBPACK_IMPORTED_MODULE_4__.UsageError(`The local project doesn't feature a 'packageManager' field - please explicit the package manager to pack, or update the manifest to reference it`); default: { specs.push(lookup.spec); } @@ -15626,11 +15634,11 @@ class PrepareCommand extends clipanion__WEBPACK_IMPORTED_MODULE_3__.Command { } for (const request of specs) { const spec = typeof request === `string` - ? _specUtils__WEBPACK_IMPORTED_MODULE_2__.parseSpec(request, `CLI arguments`, { enforceExactVersion: false }) + ? _specUtils__WEBPACK_IMPORTED_MODULE_3__.parseSpec(request, `CLI arguments`, { enforceExactVersion: false }) : request; const resolved = await this.context.engine.resolveDescriptor(spec, { allowTags: true }); if (resolved === null) - throw new clipanion__WEBPACK_IMPORTED_MODULE_3__.UsageError(`Failed to successfully resolve '${spec.range}' to a valid ${spec.name} release`); + throw new clipanion__WEBPACK_IMPORTED_MODULE_4__.UsageError(`Failed to successfully resolve '${spec.range}' to a valid ${spec.name} release`); if (!this.json) { if (this.activate) { this.context.stdout.write(`Preparing ${spec.name}@${spec.range} for immediate activation...\n`); @@ -15649,13 +15657,15 @@ class PrepareCommand extends clipanion__WEBPACK_IMPORTED_MODULE_3__.Command { const outputName = typeof this.output === `string` ? this.output : `corepack.tgz`; - const baseInstallFolder = _folderUtils__WEBPACK_IMPORTED_MODULE_1__.getInstallFolder(); - const outputPath = path__WEBPACK_IMPORTED_MODULE_0___default().resolve(this.context.cwd, outputName); + const baseInstallFolder = _folderUtils__WEBPACK_IMPORTED_MODULE_2__.getInstallFolder(); + const outputPath = path__WEBPACK_IMPORTED_MODULE_1___default().resolve(this.context.cwd, outputName); if (!this.json) - this.context.stdout.write(`Packing the selected tools in ${path__WEBPACK_IMPORTED_MODULE_0___default().basename(outputPath)}...\n`); + this.context.stdout.write(`Packing the selected tools in ${path__WEBPACK_IMPORTED_MODULE_1___default().basename(outputPath)}...\n`); const { default: tar } = await Promise.resolve(/*! import() eager */).then(__webpack_require__.t.bind(__webpack_require__, /*! tar */ "../../../.yarn/berry/cache/tar-npm-6.1.11-e6ac3cba9c-9.zip/node_modules/tar/index.js", 19)); - await tar.c({ gzip: true, cwd: baseInstallFolder, file: path__WEBPACK_IMPORTED_MODULE_0___default().resolve(outputPath) }, installLocations.map(location => { - return path__WEBPACK_IMPORTED_MODULE_0___default().relative(baseInstallFolder, location); + // Recreate the folder in case it was deleted somewhere else: + await (0,fs_promises__WEBPACK_IMPORTED_MODULE_0__.mkdir)(baseInstallFolder, { recursive: true }); + await tar.c({ gzip: true, cwd: baseInstallFolder, file: path__WEBPACK_IMPORTED_MODULE_1___default().resolve(outputPath) }, installLocations.map(location => { + return path__WEBPACK_IMPORTED_MODULE_1___default().relative(baseInstallFolder, location); })); if (this.json) { this.context.stdout.write(`${JSON.stringify(outputPath)}\n`); @@ -15669,7 +15679,7 @@ class PrepareCommand extends clipanion__WEBPACK_IMPORTED_MODULE_3__.Command { PrepareCommand.paths = [ [`prepare`], ]; -PrepareCommand.usage = clipanion__WEBPACK_IMPORTED_MODULE_3__.Command.Usage({ +PrepareCommand.usage = clipanion__WEBPACK_IMPORTED_MODULE_4__.Command.Usage({ description: `Generate a package manager archive`, details: ` This command makes sure that the specified package managers are installed in the local cache. Calling this command explicitly unless you operate in an environment without network access (in which case you'd have to call \`prepare\` while building your image, to make sure all tools are available for later use). @@ -15728,6 +15738,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _fsUtils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./fsUtils */ "./sources/fsUtils.ts"); /* harmony import */ var _httpUtils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./httpUtils */ "./sources/httpUtils.ts"); /* harmony import */ var _nodeUtils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./nodeUtils */ "./sources/nodeUtils.ts"); +/* harmony import */ var _npmRegistryUtils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./npmRegistryUtils */ "./sources/npmRegistryUtils.ts"); var __asyncValues = (undefined && undefined.__asyncValues) || function (o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; @@ -15745,11 +15756,11 @@ var __asyncValues = (undefined && undefined.__asyncValues) || function (o) { + async function fetchLatestStableVersion(spec) { switch (spec.type) { case `npm`: { - const { [`dist-tags`]: { latest }, versions: { [latest]: { dist: { shasum } } } } = await _httpUtils__WEBPACK_IMPORTED_MODULE_8__.fetchAsJson(`https://registry.npmjs.org/${spec.package}`); - return `${latest}+sha1.${shasum}`; + return await _npmRegistryUtils__WEBPACK_IMPORTED_MODULE_10__.fetchLatestStableVersion(spec.package); } case `url`: { const data = await _httpUtils__WEBPACK_IMPORTED_MODULE_8__.fetchAsJson(spec.url); @@ -15763,8 +15774,7 @@ async function fetchLatestStableVersion(spec) { async function fetchAvailableTags(spec) { switch (spec.type) { case `npm`: { - const data = await _httpUtils__WEBPACK_IMPORTED_MODULE_8__.fetchAsJson(`https://registry.npmjs.org/${spec.package}`, { headers: { [`Accept`]: `application/vnd.npm.install-v1+json` } }); - return data[`dist-tags`]; + return await _npmRegistryUtils__WEBPACK_IMPORTED_MODULE_10__.fetchAvailableTags(spec.package); } case `url`: { const data = await _httpUtils__WEBPACK_IMPORTED_MODULE_8__.fetchAsJson(spec.url); @@ -15778,8 +15788,7 @@ async function fetchAvailableTags(spec) { async function fetchAvailableVersions(spec) { switch (spec.type) { case `npm`: { - const data = await _httpUtils__WEBPACK_IMPORTED_MODULE_8__.fetchAsJson(`https://registry.npmjs.org/${spec.package}`, { headers: { [`Accept`]: `application/vnd.npm.install-v1+json` } }); - return Object.keys(data.versions); + return await _npmRegistryUtils__WEBPACK_IMPORTED_MODULE_10__.fetchAvailableVersions(spec.package); } case `url`: { const data = await _httpUtils__WEBPACK_IMPORTED_MODULE_8__.fetchAsJson(spec.url); @@ -16309,6 +16318,67 @@ function loadMainModule(id) { } +/***/ }), + +/***/ "./sources/npmRegistryUtils.ts": +/*!*************************************!*\ + !*** ./sources/npmRegistryUtils.ts ***! + \*************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "DEFAULT_HEADERS": () => (/* binding */ DEFAULT_HEADERS), +/* harmony export */ "DEFAULT_NPM_REGISTRY_URL": () => (/* binding */ DEFAULT_NPM_REGISTRY_URL), +/* harmony export */ "fetchAsJson": () => (/* binding */ fetchAsJson), +/* harmony export */ "fetchAvailableTags": () => (/* binding */ fetchAvailableTags), +/* harmony export */ "fetchAvailableVersions": () => (/* binding */ fetchAvailableVersions), +/* harmony export */ "fetchLatestStableVersion": () => (/* binding */ fetchLatestStableVersion) +/* harmony export */ }); +/* harmony import */ var clipanion__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! clipanion */ "./.yarn/__virtual__/clipanion-virtual-72ec1bc418/4/.yarn/berry/cache/clipanion-npm-3.1.0-ced87dbbea-9.zip/node_modules/clipanion/lib/advanced/index.js"); +/* harmony import */ var _httpUtils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./httpUtils */ "./sources/httpUtils.ts"); + + +// load abbreviated metadata as that's all we need for these calls +// see: https://github.com/npm/registry/blob/cfe04736f34db9274a780184d1cdb2fb3e4ead2a/docs/responses/package-metadata.md +const DEFAULT_HEADERS = { + [`Accept`]: `application/vnd.npm.install-v1+json`, +}; +const DEFAULT_NPM_REGISTRY_URL = `https://registry.npmjs.org`; +async function fetchAsJson(packageName) { + const npmRegistryUrl = process.env.COREPACK_NPM_REGISTRY || DEFAULT_NPM_REGISTRY_URL; + if (process.env.COREPACK_ENABLE_NETWORK === `0`) + throw new clipanion__WEBPACK_IMPORTED_MODULE_1__.UsageError(`Network access disabled by the environment; can't reach npm repository ${npmRegistryUrl}`); + const headers = Object.assign({}, DEFAULT_HEADERS); + if (`COREPACK_NPM_TOKEN` in process.env) { + headers.authorization = `Bearer ${process.env.COREPACK_NPM_TOKEN}`; + } + else if (`COREPACK_NPM_USERNAME` in process.env + && `COREPACK_NPM_PASSWORD` in process.env) { + const encodedCreds = Buffer.from(`${process.env.COREPACK_NPM_USERNAME}:${process.env.COREPACK_NPM_PASSWORD}`, `utf8`).toString(`base64`); + headers.authorization = `Basic ${encodedCreds}`; + } + return _httpUtils__WEBPACK_IMPORTED_MODULE_0__.fetchAsJson(`${npmRegistryUrl}/${packageName}`, { headers }); +} +async function fetchLatestStableVersion(packageName) { + const metadata = await fetchAsJson(packageName); + const { latest } = metadata[`dist-tags`]; + if (latest === undefined) + throw new Error(`${packageName} does not have a "latest" tag.`); + const { shasum } = metadata.versions[latest].dist; + return `${latest}+sha1.${shasum}`; +} +async function fetchAvailableTags(packageName) { + const metadata = await fetchAsJson(packageName); + return metadata[`dist-tags`]; +} +async function fetchAvailableVersions(packageName) { + const metadata = await fetchAsJson(packageName); + return Object.keys(metadata.versions); +} + + /***/ }), /***/ "./sources/semverUtils.ts": @@ -16432,8 +16502,10 @@ function parseSpec(raw, source, { enforceExactVersion = true } = {}) { async function findProjectSpec(initialCwd, locator, { transparent = false } = {}) { // A locator is a valid descriptor (but not the other way around) const fallbackLocator = { name: locator.name, range: locator.reference }; - if (process.env.COREPACK_ENABLE_STRICT === `0`) + if (process.env.COREPACK_ENABLE_PROJECT_SPEC === `0`) return fallbackLocator; + if (process.env.COREPACK_ENABLE_STRICT === `0`) + transparent = true; while (true) { const result = await loadSpec(initialCwd); switch (result.type) { @@ -17027,7 +17099,7 @@ const supportsColor = { /***/ ((module) => { "use strict"; -module.exports = JSON.parse('{"definitions":{"npm":{"default":"8.19.2+sha1.db90e88584d065f51b069ab46b4f02f5cf4898b7","fetchLatestFrom":{"type":"npm","package":"npm"},"transparent":{"commands":[["npm","init"],["npx"]]},"ranges":{"*":{"url":"https://registry.npmjs.org/npm/-/npm-{}.tgz","bin":{"npm":"./bin/npm-cli.js","npx":"./bin/npx-cli.js"},"registry":{"type":"npm","package":"npm"}}}},"pnpm":{"default":"7.12.2+sha1.9908aafac1fa95c4d09f6f4916e98440804dd203","fetchLatestFrom":{"type":"npm","package":"pnpm"},"transparent":{"commands":[["pnpm","init"],["pnpx"],["pnpm","dlx"]]},"ranges":{"<6.0.0":{"url":"https://registry.npmjs.org/pnpm/-/pnpm-{}.tgz","bin":{"pnpm":"./bin/pnpm.js","pnpx":"./bin/pnpx.js"},"registry":{"type":"npm","package":"pnpm"}},">=6.0.0":{"url":"https://registry.npmjs.org/pnpm/-/pnpm-{}.tgz","bin":{"pnpm":"./bin/pnpm.cjs","pnpx":"./bin/pnpx.cjs"},"registry":{"type":"npm","package":"pnpm"}}}},"yarn":{"default":"1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447","fetchLatestFrom":{"type":"npm","package":"yarn"},"transparent":{"default":"3.2.3+sha224.953c8233f7a92884eee2de69a1b92d1f2ec1655e66d08071ba9a02fa","commands":[["yarn","dlx"]]},"ranges":{"<2.0.0":{"url":"https://registry.yarnpkg.com/yarn/-/yarn-{}.tgz","bin":{"yarn":"./bin/yarn.js","yarnpkg":"./bin/yarn.js"},"registry":{"type":"npm","package":"yarn"}},">=2.0.0":{"name":"yarn","url":"https://repo.yarnpkg.com/{}/packages/yarnpkg-cli/bin/yarn.js","bin":["yarn","yarnpkg"],"registry":{"type":"url","url":"https://repo.yarnpkg.com/tags","fields":{"tags":"latest","versions":"tags"}}}}}}}'); +module.exports = JSON.parse('{"definitions":{"npm":{"default":"8.19.2+sha1.db90e88584d065f51b069ab46b4f02f5cf4898b7","fetchLatestFrom":{"type":"npm","package":"npm"},"transparent":{"commands":[["npm","init"],["npx"]]},"ranges":{"*":{"url":"https://registry.npmjs.org/npm/-/npm-{}.tgz","bin":{"npm":"./bin/npm-cli.js","npx":"./bin/npx-cli.js"},"registry":{"type":"npm","package":"npm"}}}},"pnpm":{"default":"7.14.0+sha1.2baf3a7e8a7fc865b349f94fe8f656b24f21449c","fetchLatestFrom":{"type":"npm","package":"pnpm"},"transparent":{"commands":[["pnpm","init"],["pnpx"],["pnpm","dlx"]]},"ranges":{"<6.0.0":{"url":"https://registry.npmjs.org/pnpm/-/pnpm-{}.tgz","bin":{"pnpm":"./bin/pnpm.js","pnpx":"./bin/pnpx.js"},"registry":{"type":"npm","package":"pnpm"}},">=6.0.0":{"url":"https://registry.npmjs.org/pnpm/-/pnpm-{}.tgz","bin":{"pnpm":"./bin/pnpm.cjs","pnpx":"./bin/pnpx.cjs"},"registry":{"type":"npm","package":"pnpm"}}}},"yarn":{"default":"1.22.19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447","fetchLatestFrom":{"type":"npm","package":"yarn"},"transparent":{"default":"3.2.4+sha224.e61785c1cff5bae29570238b7718845a9d00788f5b6f32e472c908dc","commands":[["yarn","dlx"]]},"ranges":{"<2.0.0":{"url":"https://registry.yarnpkg.com/yarn/-/yarn-{}.tgz","bin":{"yarn":"./bin/yarn.js","yarnpkg":"./bin/yarn.js"},"registry":{"type":"npm","package":"yarn"}},">=2.0.0":{"name":"yarn","url":"https://repo.yarnpkg.com/{}/packages/yarnpkg-cli/bin/yarn.js","bin":["yarn","yarnpkg"],"registry":{"type":"url","url":"https://repo.yarnpkg.com/tags","fields":{"tags":"latest","versions":"tags"}}}}}}}'); /***/ }), @@ -17038,7 +17110,7 @@ module.exports = JSON.parse('{"definitions":{"npm":{"default":"8.19.2+sha1.db90e /***/ ((module) => { "use strict"; -module.exports = JSON.parse('{"name":"corepack","version":"0.14.2","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","packageManager":"yarn@4.0.0-rc.15+sha224.7fa5c1d1875b041cea8fcbf9a364667e398825364bf5c5c8cd5f6601","devDependencies":{"@babel/core":"^7.14.3","@babel/plugin-transform-modules-commonjs":"^7.14.0","@babel/preset-typescript":"^7.13.0","@types/debug":"^4.1.5","@types/jest":"^29.0.0","@types/node":"^18.0.0","@types/semver":"^7.1.0","@types/tar":"^6.0.0","@types/which":"^2.0.0","@typescript-eslint/eslint-plugin":"^5.0.0","@typescript-eslint/parser":"^5.0.0","@yarnpkg/eslint-config":"^1.0.0-rc.5","@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":"^8.0.0","eslint-plugin-arca":"^0.15.0","jest":"^29.0.0","nock":"^13.0.4","proxy-agent":"^5.0.0","semver":"^7.1.3","supports-color":"^9.0.0","tar":"^6.0.1","terser-webpack-plugin":"^5.1.2","ts-loader":"^9.0.0","ts-node":"^10.0.0","typescript":"^4.3.2","v8-compile-cache":"^2.3.0","webpack":"^5.38.1","webpack-cli":"^4.0.0","which":"^2.0.2"},"scripts":{"build":"rm -rf dist shims && webpack && ts-node ./mkshims.ts","corepack":"ts-node ./sources/_entryPoint.ts","lint":"yarn eslint","prepack":"yarn build","postpack":"rm -rf dist shims","typecheck":"tsc --noEmit","test":"yarn jest"},"files":["dist","shims","LICENSE.md"],"publishConfig":{"bin":{"corepack":"./dist/corepack.js","pnpm":"./dist/pnpm.js","pnpx":"./dist/pnpx.js","yarn":"./dist/yarn.js","yarnpkg":"./dist/yarnpkg.js"},"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"]},"resolutions":{"vm2":"patch:vm2@npm:3.9.9#.yarn/patches/vm2-npm-3.9.9-03fd1f4dc5.patch"}}'); +module.exports = JSON.parse('{"name":"corepack","version":"0.15.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","packageManager":"yarn@4.0.0-rc.15+sha224.7fa5c1d1875b041cea8fcbf9a364667e398825364bf5c5c8cd5f6601","devDependencies":{"@babel/core":"^7.14.3","@babel/plugin-transform-modules-commonjs":"^7.14.0","@babel/preset-typescript":"^7.13.0","@types/debug":"^4.1.5","@types/jest":"^29.0.0","@types/node":"^18.0.0","@types/semver":"^7.1.0","@types/tar":"^6.0.0","@types/which":"^2.0.0","@typescript-eslint/eslint-plugin":"^5.0.0","@typescript-eslint/parser":"^5.0.0","@yarnpkg/eslint-config":"^1.0.0-rc.5","@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":"^8.0.0","eslint-plugin-arca":"^0.15.0","jest":"^29.0.0","nock":"^13.0.4","proxy-agent":"^5.0.0","semver":"^7.1.3","supports-color":"^9.0.0","tar":"^6.0.1","terser-webpack-plugin":"^5.1.2","ts-loader":"^9.0.0","ts-node":"^10.0.0","typescript":"^4.3.2","v8-compile-cache":"^2.3.0","webpack":"^5.38.1","webpack-cli":"^4.0.0","which":"^2.0.2"},"scripts":{"build":"rm -rf dist shims && webpack && ts-node ./mkshims.ts","corepack":"ts-node ./sources/_entryPoint.ts","lint":"yarn eslint","prepack":"yarn build","postpack":"rm -rf dist shims","typecheck":"tsc --noEmit","test":"yarn jest"},"files":["dist","shims","LICENSE.md"],"publishConfig":{"bin":{"corepack":"./dist/corepack.js","pnpm":"./dist/pnpm.js","pnpx":"./dist/pnpx.js","yarn":"./dist/yarn.js","yarnpkg":"./dist/yarnpkg.js"},"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"]},"resolutions":{"vm2":"patch:vm2@npm:3.9.9#.yarn/patches/vm2-npm-3.9.9-03fd1f4dc5.patch"}}'); /***/ }) diff --git a/deps/corepack/package.json b/deps/corepack/package.json index b7edd6bfeed749..7c80c5562ab471 100644 --- a/deps/corepack/package.json +++ b/deps/corepack/package.json @@ -1,6 +1,6 @@ { "name": "corepack", - "version": "0.14.2", + "version": "0.15.0", "homepage": "https://github.com/nodejs/corepack#readme", "bugs": { "url": "https://github.com/nodejs/corepack/issues"