@pnpm/server
Advanced tools
Comparing version 3.0.0-0 to 3.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const got = require("got"); | ||
const fetch_1 = require("@pnpm/fetch"); | ||
const p_limit_1 = require("p-limit"); | ||
@@ -8,3 +8,3 @@ const uuid = require("uuid"); | ||
const remotePrefix = initOpts.remotePrefix; | ||
const limitedFetch = fetch.bind(null, p_limit_1.default(initOpts.concurrency || 100)); | ||
const limitedFetch = limitFetch.bind(null, p_limit_1.default(initOpts.concurrency || 100)); | ||
return new Promise((resolve, reject) => { | ||
@@ -55,21 +55,25 @@ resolve({ | ||
exports.default = default_1; | ||
function fetch(limit, url, body) { | ||
function limitFetch(limit, url, body) { | ||
return limit(async () => { | ||
try { | ||
const response = await got(url, { | ||
body: JSON.stringify(body), | ||
headers: { 'Content-Type': 'application/json' }, | ||
method: 'POST', | ||
retries: () => { | ||
return 100; | ||
}, | ||
}); | ||
if (!response.body) { | ||
return undefined; | ||
} | ||
return JSON.parse(response.body); | ||
// TODO: the http://unix: should be also supported by the fetcher | ||
// but it fails with node-fetch-unix as of v2.3.0 | ||
if (url.startsWith('http://unix:')) { | ||
url = url.replace('http://unix:', 'unix:'); | ||
} | ||
catch (e) { | ||
throw JSON.parse(e.response.body); | ||
const response = await fetch_1.default(url, { | ||
body: JSON.stringify(body), | ||
headers: { 'Content-Type': 'application/json' }, | ||
method: 'POST', | ||
retry: { | ||
retries: 100, | ||
}, | ||
}); | ||
if (!response.ok) { | ||
throw await response.json(); | ||
} | ||
const json = await response.json(); | ||
if (json.error) { | ||
throw json.error; | ||
} | ||
return json; | ||
}); | ||
@@ -76,0 +80,0 @@ } |
@@ -42,24 +42,38 @@ "use strict"; | ||
case '/requestPackage': { | ||
body = await bodyPromise; | ||
const pkgResponse = await store.requestPackage(body.wantedDependency, body.options); | ||
if (pkgResponse['fetchingRawManifest']) { // tslint:disable-line | ||
rawManifestPromises[body.msgId] = pkgResponse['fetchingRawManifest']; // tslint:disable-line | ||
pkgResponse.body['fetchingRawManifestInProgress'] = true; // tslint:disable-line | ||
try { | ||
body = await bodyPromise; | ||
const pkgResponse = await store.requestPackage(body.wantedDependency, body.options); | ||
if (pkgResponse['fetchingRawManifest']) { // tslint:disable-line | ||
rawManifestPromises[body.msgId] = pkgResponse['fetchingRawManifest']; // tslint:disable-line | ||
pkgResponse.body['fetchingRawManifestInProgress'] = true; // tslint:disable-line | ||
} | ||
if (pkgResponse['fetchingFiles']) { // tslint:disable-line | ||
filesPromises[body.msgId] = pkgResponse['fetchingFiles']; // tslint:disable-line | ||
} | ||
res.end(JSON.stringify(pkgResponse.body)); | ||
} | ||
if (pkgResponse['fetchingFiles']) { // tslint:disable-line | ||
filesPromises[body.msgId] = pkgResponse['fetchingFiles']; // tslint:disable-line | ||
catch (err) { | ||
res.end(JSON.stringify({ | ||
error: Object.assign({ message: err.message }, JSON.parse(JSON.stringify(err))), | ||
})); | ||
} | ||
res.end(JSON.stringify(pkgResponse.body)); | ||
break; | ||
} | ||
case '/fetchPackage': { | ||
body = await bodyPromise; | ||
const pkgResponse = store.fetchPackage(body.options); | ||
if (pkgResponse['fetchingRawManifest']) { // tslint:disable-line | ||
rawManifestPromises[body.msgId] = pkgResponse['fetchingRawManifest']; // tslint:disable-line | ||
try { | ||
body = await bodyPromise; | ||
const pkgResponse = store.fetchPackage(body.options); | ||
if (pkgResponse['fetchingRawManifest']) { // tslint:disable-line | ||
rawManifestPromises[body.msgId] = pkgResponse['fetchingRawManifest']; // tslint:disable-line | ||
} | ||
if (pkgResponse['fetchingFiles']) { // tslint:disable-line | ||
filesPromises[body.msgId] = pkgResponse['fetchingFiles']; // tslint:disable-line | ||
} | ||
res.end(JSON.stringify({ inStoreLocation: pkgResponse.inStoreLocation })); | ||
} | ||
if (pkgResponse['fetchingFiles']) { // tslint:disable-line | ||
filesPromises[body.msgId] = pkgResponse['fetchingFiles']; // tslint:disable-line | ||
catch (err) { | ||
res.end(JSON.stringify({ | ||
error: Object.assign({ message: err.message }, JSON.parse(JSON.stringify(err))), | ||
})); | ||
} | ||
res.end(JSON.stringify({ inStoreLocation: pkgResponse.inStoreLocation })); | ||
break; | ||
@@ -66,0 +80,0 @@ } |
{ | ||
"name": "@pnpm/server", | ||
"version": "3.0.0-0", | ||
"version": "3.0.0", | ||
"description": "A pnpm installer server", | ||
@@ -36,9 +36,10 @@ "main": "lib/index.js", | ||
"@pnpm/logger": "2.1.0", | ||
"@pnpm/npm-resolver": "3.0.0-1", | ||
"@pnpm/package-requester": "7.0.0-0", | ||
"@pnpm/package-store": "4.0.0-0", | ||
"@pnpm/npm-resolver": "3.0.0", | ||
"@pnpm/package-requester": "7.0.0", | ||
"@pnpm/package-store": "4.0.0", | ||
"@pnpm/server": "link:", | ||
"@pnpm/tarball-fetcher": "3.0.0-1", | ||
"@pnpm/tarball-fetcher": "3.0.0", | ||
"@pnpm/tslint-config": "0.0.0", | ||
"@types/mz": "0.0.32", | ||
"@types/node-fetch": "2.1.6", | ||
"@types/tape": "4.2.33", | ||
@@ -49,6 +50,7 @@ "is-port-reachable": "2.0.0", | ||
"mz": "2.7.0", | ||
"node-fetch": "2.3.0", | ||
"rimraf": "2.6.3", | ||
"rimraf-then": "1.0.1", | ||
"tape": "4.10.1", | ||
"ts-node": "7.0.1", | ||
"ts-node": "8.0.3", | ||
"tslint": "5.13.1", | ||
@@ -66,8 +68,7 @@ "typescript": "3.3.3333" | ||
"dependencies": { | ||
"@pnpm/store-controller-types": "3.0.0-0", | ||
"@pnpm/types": "2.0.0", | ||
"@types/got": "8.3.4", | ||
"@pnpm/fetch": "1.0.0", | ||
"@pnpm/store-controller-types": "3.0.0", | ||
"@pnpm/types": "3.0.0", | ||
"@types/node": "11.9.5", | ||
"@types/uuid": "3.4.4", | ||
"got": "8.3.2", | ||
"p-limit": "2.2.0", | ||
@@ -74,0 +75,0 @@ "uuid": "3.3.2" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
28017
8
350
1
1
21
+ Added@pnpm/fetch@1.0.0
+ Added@pnpm/fetch@1.0.0(transitive)
+ Added@pnpm/resolver-base@3.0.0(transitive)
+ Added@pnpm/store-controller-types@3.0.0(transitive)
+ Added@pnpm/types@3.0.0(transitive)
+ Added@zeit/fetch-retry@4.0.0(transitive)
+ Addedasync-retry@1.3.3(transitive)
+ Addeddebug@3.2.7(transitive)
+ Addedms@2.1.3(transitive)
+ Addednode-fetch@2.3.0(transitive)
+ Addednode-fetch-unix@2.3.0(transitive)
+ Addedretry@0.13.1(transitive)
- Removed@types/got@8.3.4
- Removedgot@8.3.2
- Removed@pnpm/resolver-base@2.1.0(transitive)
- Removed@pnpm/store-controller-types@3.0.0-0(transitive)
- Removed@pnpm/types@2.0.0(transitive)
- Removed@sindresorhus/is@0.7.0(transitive)
- Removed@types/got@8.3.4(transitive)
- Removedcacheable-request@2.1.4(transitive)
- Removedclone-response@1.0.2(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddecompress-response@3.3.0(transitive)
- Removedduplexer3@0.1.5(transitive)
- Removedfrom2@2.3.0(transitive)
- Removedget-stream@3.0.0(transitive)
- Removedgot@8.3.2(transitive)
- Removedhas-symbol-support-x@1.4.2(transitive)
- Removedhas-to-string-tag-x@1.4.1(transitive)
- Removedhttp-cache-semantics@3.8.1(transitive)
- Removedinto-stream@3.1.0(transitive)
- Removedis-object@1.0.2(transitive)
- Removedis-plain-obj@1.1.0(transitive)
- Removedis-retry-allowed@1.2.0(transitive)
- Removedisurl@1.0.0(transitive)
- Removedjson-buffer@3.0.0(transitive)
- Removedkeyv@3.0.0(transitive)
- Removedlowercase-keys@1.0.01.0.1(transitive)
- Removedmimic-response@1.0.1(transitive)
- Removednormalize-url@2.0.1(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedp-cancelable@0.4.1(transitive)
- Removedp-finally@1.0.0(transitive)
- Removedp-is-promise@1.1.0(transitive)
- Removedp-timeout@2.0.1(transitive)
- Removedpify@3.0.0(transitive)
- Removedprepend-http@2.0.0(transitive)
- Removedquery-string@5.1.1(transitive)
- Removedresponselike@1.0.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsort-keys@2.0.0(transitive)
- Removedstrict-uri-encode@1.1.0(transitive)
- Removedtimed-out@4.0.1(transitive)
- Removedurl-parse-lax@3.0.0(transitive)
- Removedurl-to-options@1.0.1(transitive)
Updated@pnpm/types@3.0.0