@pnpm/node.fetcher 0.0.0-20230605-20230605142810

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
4
+ Copyright (c) 2016-2023 Zoltan Kochan and other contributors
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @pnpm/node.fetcher
2
+
3
+ > Node.js artifacts fetcher
4
+
5
+ Downloads and extracts the right Node.js artifact for the active platform and architecture.
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@pnpm/node.fetcher.svg)](https://www.npmjs.com/package/@pnpm/node.fetcher)
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ pnpm add @pnpm/node.fetcher
13
+ ```
14
+
15
+ ## License
16
+
17
+ MIT
@@ -0,0 +1,4 @@
1
+ export declare function getNodeTarball(nodeVersion: string, nodeMirror: string, processPlatform: string, processArch: string): {
2
+ pkgName: string;
3
+ tarball: string;
4
+ };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNodeTarball = void 0;
4
+ const normalizeArch_1 = require("./normalizeArch");
5
+ function getNodeTarball(nodeVersion, nodeMirror, processPlatform, processArch) {
6
+ const platform = processPlatform === 'win32' ? 'win' : processPlatform;
7
+ const arch = (0, normalizeArch_1.getNormalizedArch)(processPlatform, processArch, nodeVersion);
8
+ const extension = platform === 'win' ? 'zip' : 'tar.gz';
9
+ const pkgName = `node-v${nodeVersion}-${platform}-${arch}`;
10
+ return {
11
+ pkgName,
12
+ tarball: `${nodeMirror}v${nodeVersion}/${pkgName}.${extension}`,
13
+ };
14
+ }
15
+ exports.getNodeTarball = getNodeTarball;
16
+ //# sourceMappingURL=getNodeTarball.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getNodeTarball.js","sourceRoot":"","sources":["../src/getNodeTarball.ts"],"names":[],"mappings":";;;AAAA,mDAAmD;AAEnD,SAAgB,cAAc,CAC5B,WAAmB,EACnB,UAAkB,EAClB,eAAuB,EACvB,WAAmB;IAEnB,MAAM,QAAQ,GAAG,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAA;IACtE,MAAM,IAAI,GAAG,IAAA,iCAAiB,EAAC,eAAe,EAAE,WAAW,EAAE,WAAW,CAAC,CAAA;IACzE,MAAM,SAAS,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAA;IACvD,MAAM,OAAO,GAAG,SAAS,WAAW,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAA;IAC1D,OAAO;QACL,OAAO;QACP,OAAO,EAAE,GAAG,UAAU,IAAI,WAAW,IAAI,OAAO,IAAI,SAAS,EAAE;KAChE,CAAA;AACH,CAAC;AAdD,wCAcC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ import { type FetchFromRegistry, type RetryTimeoutOptions } from '@pnpm/fetching-types';
2
+ export interface FetchNodeOptions {
3
+ cafsDir: string;
4
+ fetchTimeout?: number;
5
+ nodeMirrorBaseUrl?: string;
6
+ retry?: RetryTimeoutOptions;
7
+ }
8
+ export declare function fetchNode(fetch: FetchFromRegistry, version: string, targetDir: string, opts: FetchNodeOptions): Promise<void>;
package/lib/index.js ADDED
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.fetchNode = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const error_1 = require("@pnpm/error");
10
+ const pick_fetcher_1 = require("@pnpm/pick-fetcher");
11
+ const create_cafs_store_1 = require("@pnpm/create-cafs-store");
12
+ const tarball_fetcher_1 = require("@pnpm/tarball-fetcher");
13
+ const adm_zip_1 = __importDefault(require("adm-zip"));
14
+ const rename_overwrite_1 = __importDefault(require("rename-overwrite"));
15
+ const tempy_1 = __importDefault(require("tempy"));
16
+ const detect_libc_1 = require("detect-libc");
17
+ const getNodeTarball_1 = require("./getNodeTarball");
18
+ async function fetchNode(fetch, version, targetDir, opts) {
19
+ if (await (0, detect_libc_1.isNonGlibcLinux)()) {
20
+ throw new error_1.PnpmError('MUSL', 'The current system uses the "MUSL" C standard library. Node.js currently has prebuilt artifacts only for the "glibc" libc, so we can install Node.js only for glibc');
21
+ }
22
+ const nodeMirrorBaseUrl = opts.nodeMirrorBaseUrl ?? 'https://nodejs.org/download/release/';
23
+ const { tarball, pkgName } = (0, getNodeTarball_1.getNodeTarball)(version, nodeMirrorBaseUrl, process.platform, process.arch);
24
+ if (tarball.endsWith('.zip')) {
25
+ await downloadAndUnpackZip(fetch, tarball, targetDir, pkgName);
26
+ return;
27
+ }
28
+ const getAuthHeader = () => undefined;
29
+ const fetchers = (0, tarball_fetcher_1.createTarballFetcher)(fetch, getAuthHeader, {
30
+ retry: opts.retry,
31
+ timeout: opts.fetchTimeout,
32
+ // These are not needed for fetching Node.js
33
+ rawConfig: {},
34
+ unsafePerm: false,
35
+ });
36
+ const cafs = (0, create_cafs_store_1.createCafsStore)(opts.cafsDir);
37
+ const fetchTarball = (0, pick_fetcher_1.pickFetcher)(fetchers, { tarball });
38
+ const { filesIndex } = await fetchTarball(cafs, { tarball }, {
39
+ lockfileDir: process.cwd(),
40
+ });
41
+ await cafs.importPackage(targetDir, {
42
+ filesResponse: {
43
+ filesIndex: await (0, tarball_fetcher_1.waitForFilesIndex)(filesIndex),
44
+ fromStore: false,
45
+ },
46
+ force: true,
47
+ });
48
+ }
49
+ exports.fetchNode = fetchNode;
50
+ async function downloadAndUnpackZip(fetchFromRegistry, zipUrl, targetDir, pkgName) {
51
+ const response = await fetchFromRegistry(zipUrl);
52
+ const tmp = path_1.default.join(tempy_1.default.directory(), 'pnpm.zip');
53
+ const dest = fs_1.default.createWriteStream(tmp);
54
+ await new Promise((resolve, reject) => {
55
+ response.body.pipe(dest).on('error', reject).on('close', resolve);
56
+ });
57
+ const zip = new adm_zip_1.default(tmp);
58
+ const nodeDir = path_1.default.dirname(targetDir);
59
+ zip.extractAllTo(nodeDir, true);
60
+ await (0, rename_overwrite_1.default)(path_1.default.join(nodeDir, pkgName), targetDir);
61
+ await fs_1.default.promises.unlink(tmp);
62
+ }
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,uCAAuC;AAMvC,qDAAgD;AAChD,+DAAyD;AACzD,2DAA+E;AAC/E,sDAA4B;AAC5B,wEAA8C;AAC9C,kDA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E;QAClC,aAAa,EAAE;YACb,UAAU,EAAE,MAAM,IAAA,mCAAiB,EAAC,UAAwB,CAAC;YAC7D,SAAS,EAAE,KAAK;SACjB;QACD,KAAK,EAAE,IAAI;KACZ,CAAC,CAAA;AACJ,CAAC;AA9BD,8BA8BC;AAED,KAAK,UAAU,oBAAoB,CACjC,iBAAoC,EACpC,MAAc,EACd,SAAiB,EACjB,OAAe;IAEf,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,CAAA;IAChD,MAAM,GAAG,GAAG,cAAI,CAAC,IAAI,CAAC,eAAK,CAAC,SAAS,EAAE,EAAE,UAAU,CAAC,CAAA;IACpD,MAAM,IAAI,GAAG,YAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAA;IACtC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpC,QAAQ,CAAC,IAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IACpE,CAAC,CAAC,CAAA;IACF,MAAM,GAAG,GAAG,IAAI,iBAAM,CAAC,GAAG,CAAC,CAAA;IAC3B,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACvC,GAAG,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;IAC/B,MAAM,IAAA,0BAAe,EAAC,cAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,CAAA;IAC7D,MAAM,YAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAC/B,CAAC"}
@@ -0,0 +1 @@
1
+ export declare function getNormalizedArch(platform: string, arch: string, nodeVersion?: string): string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getNormalizedArch = void 0;
4
+ function getNormalizedArch(platform, arch, nodeVersion) {
5
+ if (nodeVersion) {
6
+ const nodeMajorVersion = +nodeVersion.split('.')[0];
7
+ if ((platform === 'darwin' && arch === 'arm64' && (nodeMajorVersion < 16))) {
8
+ return 'x64';
9
+ }
10
+ }
11
+ if (platform === 'win32' && arch === 'ia32') {
12
+ return 'x86';
13
+ }
14
+ if (arch === 'arm') {
15
+ return 'armv7l';
16
+ }
17
+ return arch;
18
+ }
19
+ exports.getNormalizedArch = getNormalizedArch;
20
+ //# sourceMappingURL=normalizeArch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeArch.js","sourceRoot":"","sources":["../src/normalizeArch.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB,CAAE,QAAgB,EAAE,IAAY,EAAE,WAAoB;IACrF,IAAI,WAAW,EAAE;QACf,MAAM,gBAAgB,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAA;QACnD,IAAI,CAAC,QAAQ,KAAK,QAAQ,IAAI,IAAI,KAAK,OAAO,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC,CAAC,EAAE;YAC1E,OAAO,KAAK,CAAA;SACb;KACF;IACD,IAAI,QAAQ,KAAK,OAAO,IAAI,IAAI,KAAK,MAAM,EAAE;QAC3C,OAAO,KAAK,CAAA;KACb;IACD,IAAI,IAAI,KAAK,KAAK,EAAE;QAClB,OAAO,QAAQ,CAAA;KAChB;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAdD,8CAcC"}
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@pnpm/node.fetcher",
3
+ "version": "0.0.0-20230605-20230605142810",
4
+ "description": "Node.js artifacts fetcher",
5
+ "funding": "https://opencollective.com/pnpm",
6
+ "main": "lib/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "files": [
9
+ "lib",
10
+ "!*.map"
11
+ ],
12
+ "exports": {
13
+ ".": "./lib/index.js"
14
+ },
15
+ "engines": {
16
+ "node": ">=16.14"
17
+ },
18
+ "repository": "https://github.com/pnpm/pnpm/blob/main/env/node.fetcher",
19
+ "keywords": [
20
+ "pnpm8",
21
+ "pnpm",
22
+ "env",
23
+ "node.js"
24
+ ],
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/pnpm/pnpm/issues"
28
+ },
29
+ "homepage": "https://github.com/pnpm/pnpm/blob/main/env/node.fetcher#readme",
30
+ "dependencies": {
31
+ "adm-zip": "^0.5.10",
32
+ "detect-libc": "^2.0.1",
33
+ "rename-overwrite": "^4.0.3",
34
+ "tempy": "^1.0.1",
35
+ "@pnpm/error": "0.0.0-20230605-20230605142810",
36
+ "@pnpm/create-cafs-store": "4.0.2",
37
+ "@pnpm/fetcher-base": "14.0.1",
38
+ "@pnpm/fetching-types": "5.0.0",
39
+ "@pnpm/tarball-fetcher": "0.0.0-20230605-20230605142810",
40
+ "@pnpm/pick-fetcher": "2.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/adm-zip": "^0.5.0",
44
+ "node-fetch": "npm:@pnpm/node-fetch@1.0.0",
45
+ "@pnpm/cafs-types": "2.0.0",
46
+ "@pnpm/prepare": "0.0.0-20230605-20230605142810",
47
+ "@pnpm/node.fetcher": "0.0.0-20230605-20230605142810"
48
+ },
49
+ "scripts": {
50
+ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
51
+ "_test": "jest",
52
+ "test": "pnpm run compile && pnpm run _test",
53
+ "compile": "tsc --build && pnpm run lint --fix"
54
+ }
55
+ }