@pnpm/server
Advanced tools
Comparing version 2.0.2 to 3.0.0-0
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const got = require("got"); | ||
const pLimit = require("p-limit"); | ||
const p_limit_1 = require("p-limit"); | ||
const uuid = require("uuid"); | ||
function default_1(initOpts) { | ||
const remotePrefix = initOpts.remotePrefix; | ||
const limitedFetch = fetch.bind(null, pLimit(initOpts.concurrency || 100)); | ||
const limitedFetch = fetch.bind(null, p_limit_1.default(initOpts.concurrency || 100)); | ||
return new Promise((resolve, reject) => { | ||
resolve({ | ||
close: () => __awaiter(this, void 0, void 0, function* () { return; }), | ||
close: async () => { return; }, | ||
fetchPackage: fetchPackage.bind(null, remotePrefix, limitedFetch), | ||
findPackageUsages: (searchQueries) => __awaiter(this, void 0, void 0, function* () { | ||
findPackageUsages: async (searchQueries) => { | ||
return limitedFetch(`${remotePrefix}/findPackageUsages`, { searchQueries }); | ||
}), | ||
getPackageLocation: (packageId, packageName, opts) => __awaiter(this, void 0, void 0, function* () { | ||
}, | ||
getPackageLocation: async (packageId, packageName, opts) => { | ||
return limitedFetch(`${remotePrefix}/getPackageLocation`, { | ||
@@ -30,5 +22,5 @@ opts, | ||
}); | ||
}), | ||
importPackage: (from, to, opts) => __awaiter(this, void 0, void 0, function* () { | ||
yield limitedFetch(`${remotePrefix}/importPackage`, { | ||
}, | ||
importPackage: async (from, to, opts) => { | ||
await limitedFetch(`${remotePrefix}/importPackage`, { | ||
from, | ||
@@ -38,23 +30,23 @@ opts, | ||
}); | ||
}), | ||
prune: () => __awaiter(this, void 0, void 0, function* () { | ||
yield limitedFetch(`${remotePrefix}/prune`, {}); | ||
}), | ||
}, | ||
prune: async () => { | ||
await limitedFetch(`${remotePrefix}/prune`, {}); | ||
}, | ||
requestPackage: requestPackage.bind(null, remotePrefix, limitedFetch), | ||
saveState: () => __awaiter(this, void 0, void 0, function* () { | ||
yield limitedFetch(`${remotePrefix}/saveState`, {}); | ||
}), | ||
saveState: async () => { | ||
await limitedFetch(`${remotePrefix}/saveState`, {}); | ||
}, | ||
stop: () => limitedFetch(`${remotePrefix}/stop`, {}), | ||
updateConnections: (prefix, opts) => __awaiter(this, void 0, void 0, function* () { | ||
yield limitedFetch(`${remotePrefix}/updateConnections`, { | ||
updateConnections: async (prefix, opts) => { | ||
await limitedFetch(`${remotePrefix}/updateConnections`, { | ||
opts, | ||
prefix, | ||
}); | ||
}), | ||
upload: (builtPkgLocation, opts) => __awaiter(this, void 0, void 0, function* () { | ||
yield limitedFetch(`${remotePrefix}/upload`, { | ||
}, | ||
upload: async (builtPkgLocation, opts) => { | ||
await limitedFetch(`${remotePrefix}/upload`, { | ||
builtPkgLocation, | ||
opts, | ||
}); | ||
}), | ||
}, | ||
}); | ||
@@ -65,5 +57,5 @@ }); | ||
function fetch(limit, url, body) { | ||
return limit(() => __awaiter(this, void 0, void 0, function* () { | ||
return limit(async () => { | ||
try { | ||
const response = yield got(url, { | ||
const response = await got(url, { | ||
body: JSON.stringify(body), | ||
@@ -84,3 +76,3 @@ headers: { 'Content-Type': 'application/json' }, | ||
} | ||
})); | ||
}); | ||
} | ||
@@ -87,0 +79,0 @@ function requestPackage(remotePrefix, limitedFetch, // tslint:disable-line |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -18,3 +10,3 @@ const logger_1 = require("@pnpm/logger"); | ||
const lock = lock_1.default(); | ||
const server = http.createServer((req, res) => __awaiter(this, void 0, void 0, function* () { | ||
const server = http.createServer(async (req, res) => { | ||
if (req.method !== 'POST') { | ||
@@ -32,3 +24,3 @@ res.statusCode = 405; // Method Not Allowed | ||
}); | ||
req.on('end', () => __awaiter(this, void 0, void 0, function* () { | ||
req.on('end', async () => { | ||
try { | ||
@@ -46,3 +38,3 @@ if (body.length > 0) { | ||
} | ||
})); | ||
}); | ||
}); | ||
@@ -53,4 +45,4 @@ try { | ||
case '/requestPackage': { | ||
body = yield bodyPromise; | ||
const pkgResponse = yield store.requestPackage(body.wantedDependency, body.options); | ||
body = await bodyPromise; | ||
const pkgResponse = await store.requestPackage(body.wantedDependency, body.options); | ||
if (pkgResponse['fetchingRawManifest']) { // tslint:disable-line | ||
@@ -67,3 +59,3 @@ rawManifestPromises[body.msgId] = pkgResponse['fetchingRawManifest']; // tslint:disable-line | ||
case '/fetchPackage': { | ||
body = yield bodyPromise; | ||
body = await bodyPromise; | ||
const pkgResponse = store.fetchPackage(body.options); | ||
@@ -80,4 +72,4 @@ if (pkgResponse['fetchingRawManifest']) { // tslint:disable-line | ||
case '/packageFilesResponse': | ||
body = yield bodyPromise; | ||
const filesResponse = yield filesPromises[body.msgId]; | ||
body = await bodyPromise; | ||
const filesResponse = await filesPromises[body.msgId]; | ||
delete filesPromises[body.msgId]; | ||
@@ -87,4 +79,4 @@ res.end(JSON.stringify(filesResponse)); | ||
case '/rawManifestResponse': | ||
body = yield bodyPromise; | ||
const manifestResponse = yield rawManifestPromises[body.msgId]; | ||
body = await bodyPromise; | ||
const manifestResponse = await rawManifestPromises[body.msgId]; | ||
delete rawManifestPromises[body.msgId]; | ||
@@ -94,4 +86,4 @@ res.end(JSON.stringify(manifestResponse)); | ||
case '/updateConnections': | ||
body = yield bodyPromise; | ||
yield store.updateConnections(body.prefix, body.opts); | ||
body = await bodyPromise; | ||
await store.updateConnections(body.prefix, body.opts); | ||
res.end(JSON.stringify('OK')); | ||
@@ -105,8 +97,8 @@ break; | ||
case '/saveState': | ||
yield store.saveState(); | ||
await store.saveState(); | ||
res.end(JSON.stringify('OK')); | ||
break; | ||
case '/importPackage': | ||
const importPackageBody = (yield bodyPromise); // tslint:disable-line:no-any | ||
yield store.importPackage(importPackageBody.from, importPackageBody.to, importPackageBody.opts); | ||
const importPackageBody = (await bodyPromise); // tslint:disable-line:no-any | ||
await store.importPackage(importPackageBody.from, importPackageBody.to, importPackageBody.opts); | ||
res.end(JSON.stringify('OK')); | ||
@@ -121,4 +113,4 @@ break; | ||
} | ||
const uploadBody = (yield bodyPromise); // tslint:disable-line:no-any | ||
yield lock(uploadBody.builtPkgLocation, () => store.upload(uploadBody.builtPkgLocation, uploadBody.opts)); | ||
const uploadBody = (await bodyPromise); // tslint:disable-line:no-any | ||
await lock(uploadBody.builtPkgLocation, () => store.upload(uploadBody.builtPkgLocation, uploadBody.opts)); | ||
res.end(JSON.stringify('OK')); | ||
@@ -133,3 +125,3 @@ break; | ||
logger_1.storeLogger.info('Got request to stop the server'); | ||
yield close(); | ||
await close(); | ||
res.end(JSON.stringify('OK')); | ||
@@ -139,4 +131,4 @@ logger_1.storeLogger.info('Server stopped'); | ||
case '/getPackageLocation': { | ||
const { packageId, packageName, opts } = (yield bodyPromise); // tslint:disable-line:no-any | ||
const pkgLocation = yield store.getPackageLocation(packageId, packageName, opts); | ||
const { packageId, packageName, opts } = (await bodyPromise); // tslint:disable-line:no-any | ||
const pkgLocation = await store.getPackageLocation(packageId, packageName, opts); | ||
res.end(JSON.stringify(pkgLocation)); | ||
@@ -146,4 +138,4 @@ break; | ||
case '/findPackageUsages': | ||
body = yield bodyPromise; | ||
res.end(JSON.stringify(yield store.findPackageUsages(body.searchQueries))); | ||
body = await bodyPromise; | ||
res.end(JSON.stringify(await store.findPackageUsages(body.searchQueries))); | ||
break; | ||
@@ -162,3 +154,3 @@ default: | ||
} | ||
})); | ||
}); | ||
let listener; | ||
@@ -165,0 +157,0 @@ if (opts.path) { |
{ | ||
"name": "@pnpm/server", | ||
"version": "2.0.2", | ||
"version": "3.0.0-0", | ||
"description": "A pnpm installer server", | ||
@@ -11,3 +11,3 @@ "main": "lib/index.js", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=8" | ||
}, | ||
@@ -37,7 +37,7 @@ "scripts": { | ||
"@pnpm/logger": "2.1.0", | ||
"@pnpm/npm-resolver": "2.2.7", | ||
"@pnpm/package-requester": "6.1.0", | ||
"@pnpm/package-store": "3.1.0", | ||
"@pnpm/npm-resolver": "3.0.0-1", | ||
"@pnpm/package-requester": "7.0.0-0", | ||
"@pnpm/package-store": "4.0.0-0", | ||
"@pnpm/server": "link:", | ||
"@pnpm/tarball-fetcher": "2.0.10", | ||
"@pnpm/tarball-fetcher": "3.0.0-1", | ||
"@pnpm/tslint-config": "0.0.0", | ||
@@ -52,6 +52,6 @@ "@types/mz": "0.0.32", | ||
"rimraf-then": "1.0.1", | ||
"tape": "4.9.2", | ||
"tape": "4.10.1", | ||
"ts-node": "7.0.1", | ||
"tslint": "5.12.0", | ||
"typescript": "3.2.2" | ||
"tslint": "5.13.1", | ||
"typescript": "3.3.3333" | ||
}, | ||
@@ -67,12 +67,11 @@ "mos": { | ||
"dependencies": { | ||
"@pnpm/store-controller-types": "2.1.0", | ||
"@pnpm/store-controller-types": "3.0.0-0", | ||
"@pnpm/types": "2.0.0", | ||
"@types/got": "8.3.4", | ||
"@types/node": "10.12.18", | ||
"@types/p-limit": "2.0.0", | ||
"@types/node": "11.9.5", | ||
"@types/uuid": "3.4.4", | ||
"got": "8.3.2", | ||
"p-limit": "2.1.0", | ||
"p-limit": "2.2.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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
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
9
26554
332
2
+ Added@pnpm/store-controller-types@3.0.0-0(transitive)
+ Added@types/node@11.9.5(transitive)
+ Addedp-limit@2.2.0(transitive)
- Removed@types/p-limit@2.0.0
- Removed@pnpm/store-controller-types@2.1.0(transitive)
- Removed@types/node@10.12.18(transitive)
- Removed@types/p-limit@2.0.0(transitive)
- Removedp-limit@2.1.0(transitive)
Updated@types/node@11.9.5
Updatedp-limit@2.2.0