New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pnpm/lockfile-file

Package Overview
Dependencies
Maintainers
3
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnpm/lockfile-file - npm Package Compare versions

Comparing version 3.0.18 to 3.1.0

lib/gitMergeFile.d.ts

11

CHANGELOG.md
# @pnpm/lockfile-file
## 3.1.0
### Minor Changes
- 3776b5a52: New function added that reads the lockfile and autofixes any merge conflicts.
### Patch Changes
- Updated dependencies [3776b5a52]
- @pnpm/merge-lockfile-changes@1.0.0
## 3.0.18

@@ -4,0 +15,0 @@

@@ -6,2 +6,9 @@ import { Lockfile } from '@pnpm/lockfile-types';

}): Promise<Lockfile | null>;
export declare function readWantedLockfileAndAutofixConflicts(pkgPath: string, opts: {
wantedVersion?: number;
ignoreIncompatible: boolean;
}): Promise<{
lockfile: Lockfile | null;
hadConflicts: boolean;
}>;
export declare function readWantedLockfile(pkgPath: string, opts: {

@@ -8,0 +15,0 @@ wantedVersion?: number;

50

lib/read.js

@@ -6,23 +6,31 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createLockfileObject = exports.readWantedLockfile = exports.readCurrentLockfile = void 0;
exports.createLockfileObject = exports.readWantedLockfile = exports.readWantedLockfileAndAutofixConflicts = exports.readCurrentLockfile = void 0;
const constants_1 = require("@pnpm/constants");
const types_1 = require("@pnpm/types");
const read_yaml_file_1 = __importDefault(require("read-yaml-file"));
const errors_1 = require("./errors");
const gitMergeFile_1 = require("./gitMergeFile");
const logger_1 = __importDefault(require("./logger"));
const yaml = require("js-yaml");
const path = require("path");
function readCurrentLockfile(virtualStoreDir, opts) {
const stripBom = require("strip-bom");
const fs = require("mz/fs");
async function readCurrentLockfile(virtualStoreDir, opts) {
const lockfilePath = path.join(virtualStoreDir, 'lock.yaml');
return _read(lockfilePath, virtualStoreDir, opts);
return (await _read(lockfilePath, virtualStoreDir, opts)).lockfile;
}
exports.readCurrentLockfile = readCurrentLockfile;
function readWantedLockfile(pkgPath, opts) {
function readWantedLockfileAndAutofixConflicts(pkgPath, opts) {
const lockfilePath = path.join(pkgPath, constants_1.WANTED_LOCKFILE);
return _read(lockfilePath, pkgPath, opts);
return _read(lockfilePath, pkgPath, { ...opts, autofixMergeConflicts: true });
}
exports.readWantedLockfileAndAutofixConflicts = readWantedLockfileAndAutofixConflicts;
async function readWantedLockfile(pkgPath, opts) {
const lockfilePath = path.join(pkgPath, constants_1.WANTED_LOCKFILE);
return (await _read(lockfilePath, pkgPath, opts)).lockfile;
}
exports.readWantedLockfile = readWantedLockfile;
async function _read(lockfilePath, prefix, opts) {
let lockfile;
let lockfileRawContent;
try {
lockfile = await read_yaml_file_1.default(lockfilePath);
lockfileRawContent = stripBom(await fs.readFile(lockfilePath, 'utf8'));
}

@@ -33,4 +41,24 @@ catch (err) {

}
return null;
return {
lockfile: null,
hadConflicts: false,
};
}
let lockfile;
let hadConflicts;
try {
lockfile = yaml.safeLoad(lockfileRawContent);
hadConflicts = false;
}
catch (err) {
if (!opts.autofixMergeConflicts || !gitMergeFile_1.isDiff(lockfileRawContent)) {
throw err;
}
hadConflicts = true;
lockfile = gitMergeFile_1.autofixMergeConflicts(lockfileRawContent);
logger_1.default.info({
message: `Merge conflict detected in ${constants_1.WANTED_LOCKFILE} and successfully merged`,
prefix: path.dirname(lockfilePath),
});
}
/* eslint-disable @typescript-eslint/dot-notation */

@@ -61,3 +89,3 @@ if (typeof (lockfile === null || lockfile === void 0 ? void 0 : lockfile['specifiers']) !== 'undefined') {

}
return lockfile;
return { lockfile, hadConflicts };
}

@@ -70,3 +98,3 @@ }

});
return null;
return { lockfile: null, hadConflicts: false };
}

@@ -73,0 +101,0 @@ throw new errors_1.LockfileBreakingChangeError(lockfilePath);

{
"name": "@pnpm/lockfile-file",
"version": "3.0.18",
"version": "3.1.0",
"description": "Read/write pnpm-lock.yaml files",

@@ -52,2 +52,3 @@ "main": "lib/index.js",

"@pnpm/lockfile-types": "2.1.1",
"@pnpm/merge-lockfile-changes": "^1.0.0",
"@pnpm/types": "6.3.1",

@@ -59,3 +60,3 @@ "@zkochan/rimraf": "^1.0.0",

"ramda": "^0.27.1",
"read-yaml-file": "^2.0.0",
"strip-bom": "^4.0.0",
"write-file-atomic": "^3.0.3"

@@ -62,0 +63,0 @@ },

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