Socket
Socket
Sign inDemoInstall

@pnpm/prepare-package

Package Overview
Dependencies
Maintainers
2
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnpm/prepare-package - npm Package Compare versions

Comparing version 4.0.0 to 4.0.1

6

lib/index.d.ts

@@ -1,3 +0,5 @@

export declare function preparePackage(opts: {
export interface PreparePackageOptions {
rawConfig: object;
}, pkgDir: string): Promise<void>;
unsafePerm?: boolean;
}
export declare function preparePackage(opts: PreparePackageOptions, pkgDir: string): Promise<void>;

@@ -7,8 +7,7 @@ "use strict";

exports.preparePackage = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const error_1 = require("@pnpm/error");
const npm_lifecycle_1 = __importDefault(require("@pnpm/npm-lifecycle"));
const lifecycle_1 = require("@pnpm/lifecycle");
const read_package_json_1 = require("@pnpm/read-package-json");
const rimraf_1 = __importDefault(require("@zkochan/rimraf"));
const execa_1 = __importDefault(require("execa"));
const preferred_pm_1 = __importDefault(require("preferred-pm"));

@@ -25,20 +24,27 @@ const omit_1 = __importDefault(require("ramda/src/omit"));

const manifest = await (0, read_package_json_1.safeReadPackageJsonFromDir)(pkgDir);
if (manifest?.scripts == null || !packageShouldBeBuilt(manifest.scripts))
if (manifest?.scripts == null || !packageShouldBeBuilt(manifest, pkgDir))
return;
const pm = (await (0, preferred_pm_1.default)(pkgDir))?.name ?? 'npm';
// We can't prepare a package without running its lifecycle scripts.
// An alternative solution could be to throw an exception.
const config = (0, omit_1.default)(['ignore-scripts'], opts.rawConfig);
const env = npm_lifecycle_1.default.makeEnv(manifest, { config });
const execOpts = { cwd: pkgDir, env, extendEnv: true };
const execOpts = {
depPath: `${manifest.name}@${manifest.version}`,
pkgRoot: pkgDir,
// We can't prepare a package without running its lifecycle scripts.
// An alternative solution could be to throw an exception.
rawConfig: (0, omit_1.default)(['ignore-scripts'], opts.rawConfig),
rootModulesDir: pkgDir,
unsafePerm: Boolean(opts.unsafePerm),
};
try {
await (0, execa_1.default)(pm, ['install'], execOpts);
const installScriptName = `${pm}-install`;
manifest.scripts[installScriptName] = `${pm} install`;
await (0, lifecycle_1.runLifecycleHook)(installScriptName, manifest, execOpts);
for (const scriptName of PREPUBLISH_SCRIPTS) {
if (manifest.scripts[scriptName] == null || manifest.scripts[scriptName] === '')
continue;
await (0, execa_1.default)(pm, ['run', scriptName], execOpts);
await (0, lifecycle_1.runLifecycleHook)(scriptName, manifest, execOpts);
}
}
catch (err) { // eslint-disable-line
throw new error_1.PnpmError('PREPARE_PKG_FAILURE', err.shortMessage ?? err.message);
err.code = 'ERR_PNPM_PREPARE_PACKAGE';
throw err;
}

@@ -48,8 +54,14 @@ await (0, rimraf_1.default)(path_1.default.join(pkgDir, 'node_modules'));

exports.preparePackage = preparePackage;
function packageShouldBeBuilt(packageScripts) {
return [
...PREPUBLISH_SCRIPTS,
'prepare',
].some((scriptName) => packageScripts[scriptName] != null && packageScripts[scriptName] !== '');
function packageShouldBeBuilt(manifest, pkgDir) {
if (manifest.scripts == null)
return false;
const scripts = manifest.scripts;
if (scripts.prepare != null && scripts.prepare !== '')
return true;
const hasPrepublishScript = PREPUBLISH_SCRIPTS.some((scriptName) => scripts[scriptName] != null && scripts[scriptName] !== '');
if (!hasPrepublishScript)
return false;
const mainFile = manifest.main ?? 'index.js';
return !fs_1.default.existsSync(path_1.default.join(pkgDir, mainFile));
}
//# sourceMappingURL=index.js.map
{
"name": "@pnpm/prepare-package",
"version": "4.0.0",
"version": "4.0.1",
"description": "Prepares a Git-hosted package",

@@ -25,8 +25,7 @@ "main": "lib/index.js",

"dependencies": {
"@pnpm/npm-lifecycle": "^2.0.0",
"@zkochan/rimraf": "^2.1.2",
"execa": "npm:safe-execa@^0.1.2",
"execa": "npm:safe-execa@0.1.2",
"preferred-pm": "^3.0.3",
"ramda": "npm:@pnpm/ramda@0.28.1",
"@pnpm/error": "4.0.0",
"@pnpm/lifecycle": "14.1.4",
"@pnpm/read-package-json": "7.0.4"

@@ -39,3 +38,3 @@ },

"@pnpm/prepare": "0.0.59",
"@pnpm/prepare-package": "4.0.0",
"@pnpm/prepare-package": "4.0.1",
"@pnpm/test-fixtures": "0.0.28",

@@ -42,0 +41,0 @@ "@pnpm/types": "8.10.0"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc