@pnpm/lifecycle
Advanced tools
Comparing version 4.2.0 to 5.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 }); | ||
@@ -18,23 +10,21 @@ const read_package_json_1 = require("@pnpm/read-package-json"); | ||
exports.default = runLifecycleHook_1.default; | ||
function runPostinstallHooks(opts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const pkg = yield read_package_json_1.fromDir(opts.pkgRoot); | ||
const scripts = pkg && pkg.scripts || {}; | ||
if (!scripts.install) { | ||
yield checkBindingGyp(opts.pkgRoot, scripts); | ||
} | ||
if (scripts.preinstall) { | ||
yield runLifecycleHook_1.default('preinstall', pkg, opts); | ||
} | ||
if (scripts.install) { | ||
yield runLifecycleHook_1.default('install', pkg, opts); | ||
} | ||
if (scripts.postinstall) { | ||
yield runLifecycleHook_1.default('postinstall', pkg, opts); | ||
} | ||
if (opts.prepare && scripts.prepare) { | ||
yield runLifecycleHook_1.default('prepare', pkg, opts); | ||
} | ||
return !!scripts.preinstall || !!scripts.install || !!scripts.postinstall; | ||
}); | ||
async function runPostinstallHooks(opts) { | ||
const pkg = await read_package_json_1.fromDir(opts.pkgRoot); | ||
const scripts = pkg && pkg.scripts || {}; | ||
if (!scripts.install) { | ||
await checkBindingGyp(opts.pkgRoot, scripts); | ||
} | ||
if (scripts.preinstall) { | ||
await runLifecycleHook_1.default('preinstall', pkg, opts); | ||
} | ||
if (scripts.install) { | ||
await runLifecycleHook_1.default('install', pkg, opts); | ||
} | ||
if (scripts.postinstall) { | ||
await runLifecycleHook_1.default('postinstall', pkg, opts); | ||
} | ||
if (opts.prepare && scripts.prepare) { | ||
await runLifecycleHook_1.default('prepare', pkg, opts); | ||
} | ||
return !!scripts.preinstall || !!scripts.install || !!scripts.postinstall; | ||
} | ||
@@ -46,9 +36,7 @@ exports.runPostinstallHooks = runPostinstallHooks; | ||
*/ | ||
function checkBindingGyp(root, scripts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (yield exists(path.join(root, 'binding.gyp'))) { | ||
scripts['install'] = 'node-gyp rebuild'; // tslint:disable-line:no-string-literal | ||
} | ||
}); | ||
async function checkBindingGyp(root, scripts) { | ||
if (await exists(path.join(root, 'binding.gyp'))) { | ||
scripts['install'] = 'node-gyp rebuild'; // tslint:disable-line:no-string-literal | ||
} | ||
} | ||
//# sourceMappingURL=index.js.map |
"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 }); | ||
@@ -14,63 +6,61 @@ const core_loggers_1 = require("@pnpm/core-loggers"); | ||
function noop() { } // tslint:disable-line:no-empty | ||
function runLifecycleHook(stage, pkg, opts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const optional = opts.optional === true; | ||
if (opts.stdio !== 'inherit') { | ||
core_loggers_1.lifecycleLogger.debug({ | ||
depPath: opts.depPath, | ||
optional, | ||
script: pkg.scripts[stage], | ||
stage, | ||
wd: opts.pkgRoot, | ||
}); | ||
} | ||
return lifecycle(pkg, stage, opts.pkgRoot, { | ||
config: opts.rawNpmConfig, | ||
dir: opts.rootNodeModulesDir, | ||
log: { | ||
clearProgress: noop, | ||
info: noop, | ||
level: opts.stdio === 'inherit' ? undefined : 'silent', | ||
pause: noop, | ||
resume: noop, | ||
showProgress: noop, | ||
silly: npmLog, | ||
verbose: npmLog, | ||
warn: noop, | ||
}, | ||
runConcurrently: true, | ||
stdio: opts.stdio || 'pipe', | ||
unsafePerm: opts.unsafePerm, | ||
async function runLifecycleHook(stage, pkg, opts) { | ||
const optional = opts.optional === true; | ||
if (opts.stdio !== 'inherit') { | ||
core_loggers_1.lifecycleLogger.debug({ | ||
depPath: opts.depPath, | ||
optional, | ||
script: pkg.scripts[stage], | ||
stage, | ||
wd: opts.pkgRoot, | ||
}); | ||
function npmLog(prefix, logid, stdtype, line) { | ||
switch (stdtype) { | ||
case 'stdout': | ||
case 'stderr': | ||
core_loggers_1.lifecycleLogger.debug({ | ||
depPath: opts.depPath, | ||
line: line.toString(), | ||
stage, | ||
stdio: stdtype, | ||
wd: opts.pkgRoot, | ||
}); | ||
} | ||
return lifecycle(pkg, stage, opts.pkgRoot, { | ||
config: opts.rawNpmConfig, | ||
dir: opts.rootNodeModulesDir, | ||
log: { | ||
clearProgress: noop, | ||
info: noop, | ||
level: opts.stdio === 'inherit' ? undefined : 'silent', | ||
pause: noop, | ||
resume: noop, | ||
showProgress: noop, | ||
silly: npmLog, | ||
verbose: npmLog, | ||
warn: noop, | ||
}, | ||
runConcurrently: true, | ||
stdio: opts.stdio || 'pipe', | ||
unsafePerm: opts.unsafePerm, | ||
}); | ||
function npmLog(prefix, logid, stdtype, line) { | ||
switch (stdtype) { | ||
case 'stdout': | ||
case 'stderr': | ||
core_loggers_1.lifecycleLogger.debug({ | ||
depPath: opts.depPath, | ||
line: line.toString(), | ||
stage, | ||
stdio: stdtype, | ||
wd: opts.pkgRoot, | ||
}); | ||
return; | ||
case 'Returned: code:': | ||
if (opts.stdio === 'inherit') { | ||
// Preventing the pnpm reporter from overriding the project's script output | ||
return; | ||
case 'Returned: code:': | ||
if (opts.stdio === 'inherit') { | ||
// Preventing the pnpm reporter from overriding the project's script output | ||
return; | ||
} | ||
const code = arguments[3]; | ||
core_loggers_1.lifecycleLogger.debug({ | ||
depPath: opts.depPath, | ||
exitCode: code, | ||
optional, | ||
stage, | ||
wd: opts.pkgRoot, | ||
}); | ||
return; | ||
} | ||
} | ||
const code = arguments[3]; | ||
core_loggers_1.lifecycleLogger.debug({ | ||
depPath: opts.depPath, | ||
exitCode: code, | ||
optional, | ||
stage, | ||
wd: opts.pkgRoot, | ||
}); | ||
return; | ||
} | ||
}); | ||
} | ||
} | ||
exports.default = runLifecycleHook; | ||
//# sourceMappingURL=runLifecycleHook.js.map |
"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 run_groups_1 = require("run-groups"); | ||
const runLifecycleHook_1 = require("./runLifecycleHook"); | ||
function runLifecycleHooksConcurrently(stages, importers, childConcurrency, opts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const importersByBuildIndex = new Map(); | ||
for (const importer of importers) { | ||
if (!importersByBuildIndex.has(importer.buildIndex)) { | ||
importersByBuildIndex.set(importer.buildIndex, [importer]); | ||
async function runLifecycleHooksConcurrently(stages, importers, childConcurrency, opts) { | ||
const importersByBuildIndex = new Map(); | ||
for (const importer of importers) { | ||
if (!importersByBuildIndex.has(importer.buildIndex)) { | ||
importersByBuildIndex.set(importer.buildIndex, [importer]); | ||
} | ||
else { | ||
importersByBuildIndex.get(importer.buildIndex).push(importer); | ||
} | ||
} | ||
const sortedBuildIndexes = Array.from(importersByBuildIndex.keys()).sort(); | ||
const groups = sortedBuildIndexes.map((buildIndex) => { | ||
const importers = importersByBuildIndex.get(buildIndex); | ||
return importers.map((importer) => async () => { | ||
const runLifecycleHookOpts = { | ||
depPath: importer.prefix, | ||
pkgRoot: importer.prefix, | ||
rawNpmConfig: opts.rawNpmConfig, | ||
rootNodeModulesDir: importer.modulesDir, | ||
stdio: opts.stdio, | ||
unsafePerm: opts.unsafePerm, | ||
}; | ||
for (const stage of stages) { | ||
if (!importer.pkg.scripts || !importer.pkg.scripts[stage]) | ||
continue; | ||
await runLifecycleHook_1.default(stage, importer.pkg, runLifecycleHookOpts); | ||
} | ||
else { | ||
importersByBuildIndex.get(importer.buildIndex).push(importer); | ||
} | ||
} | ||
const sortedBuildIndexes = Array.from(importersByBuildIndex.keys()).sort(); | ||
const groups = sortedBuildIndexes.map((buildIndex) => { | ||
const importers = importersByBuildIndex.get(buildIndex); | ||
return importers.map((importer) => () => __awaiter(this, void 0, void 0, function* () { | ||
const runLifecycleHookOpts = { | ||
depPath: importer.prefix, | ||
pkgRoot: importer.prefix, | ||
rawNpmConfig: opts.rawNpmConfig, | ||
rootNodeModulesDir: importer.modulesDir, | ||
stdio: opts.stdio, | ||
unsafePerm: opts.unsafePerm, | ||
}; | ||
for (const stage of stages) { | ||
if (!importer.pkg.scripts || !importer.pkg.scripts[stage]) | ||
continue; | ||
yield runLifecycleHook_1.default(stage, importer.pkg, runLifecycleHookOpts); | ||
} | ||
})); | ||
}); | ||
yield run_groups_1.default(childConcurrency, groups); | ||
}); | ||
await run_groups_1.default(childConcurrency, groups); | ||
} | ||
exports.default = runLifecycleHooksConcurrently; | ||
//# sourceMappingURL=runLifecycleHooksConcurrently.js.map |
{ | ||
"name": "@pnpm/lifecycle", | ||
"version": "4.2.0", | ||
"version": "5.0.0", | ||
"description": "Package lifecycle hook runner", | ||
@@ -11,3 +11,3 @@ "main": "lib/index.js", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=8" | ||
}, | ||
@@ -38,8 +38,8 @@ "scripts": { | ||
"dependencies": { | ||
"@pnpm/core-loggers": "2.0.0", | ||
"@pnpm/read-package-json": "1.1.1", | ||
"@pnpm/types": "2.0.0", | ||
"@pnpm/core-loggers": "3.0.0", | ||
"@pnpm/read-package-json": "2.0.0", | ||
"@pnpm/types": "3.0.0", | ||
"@zkochan/npm-lifecycle": "2.2.0", | ||
"path-exists": "3.0.0", | ||
"run-groups": "1.0.0" | ||
"run-groups": "2.0.0" | ||
}, | ||
@@ -51,14 +51,14 @@ "devDependencies": { | ||
"@types/load-json-file": "2.0.7", | ||
"@types/node": "10.12.18", | ||
"@types/node": "11.9.5", | ||
"@types/rimraf": "2.0.2", | ||
"@types/tape": "4.2.33", | ||
"json-append": "1.1.1", | ||
"load-json-file": "5.1.0", | ||
"load-json-file": "5.2.0", | ||
"mos": "2.0.0-alpha.3", | ||
"mos-plugin-readme": "1.0.4", | ||
"rimraf": "2.6.3", | ||
"tape": "4.9.2", | ||
"ts-node": "7.0.1", | ||
"tslint": "5.12.0", | ||
"typescript": "3.2.2" | ||
"tape": "4.10.1", | ||
"ts-node": "8.0.3", | ||
"tslint": "5.13.1", | ||
"typescript": "3.3.3333" | ||
}, | ||
@@ -65,0 +65,0 @@ "mos": { |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
14790
173
+ Added@pnpm/core-loggers@3.0.0(transitive)
+ Added@pnpm/read-package-json@2.0.0(transitive)
+ Added@pnpm/types@3.0.0(transitive)
+ Addedp-limit@2.2.0(transitive)
+ Addedrun-groups@2.0.0(transitive)
- Removed@pnpm/core-loggers@2.0.0(transitive)
- Removed@pnpm/read-package-json@1.1.1(transitive)
- Removed@pnpm/types@2.0.0(transitive)
- Removedp-limit@2.1.0(transitive)
- Removedrun-groups@1.0.0(transitive)
Updated@pnpm/core-loggers@3.0.0
Updated@pnpm/types@3.0.0
Updatedrun-groups@2.0.0