@pnpm/lockfile.fs 1100.1.2 → 1100.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/read.d.ts +15 -1
- package/lib/read.js +22 -5
- package/package.json +13 -10
package/lib/read.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { LockfileObject } from '@pnpm/lockfile.types';
|
|
1
|
+
import type { LockfileFile, LockfileObject } from '@pnpm/lockfile.types';
|
|
2
2
|
import type { ProjectId } from '@pnpm/types';
|
|
3
3
|
export declare function readCurrentLockfile(pnpmInternalDir: string, opts: {
|
|
4
4
|
wantedVersions?: string[];
|
|
@@ -19,6 +19,20 @@ export declare function readWantedLockfile(pkgPath: string, opts: {
|
|
|
19
19
|
useGitBranchLockfile?: boolean;
|
|
20
20
|
mergeGitBranchLockfiles?: boolean;
|
|
21
21
|
}): Promise<LockfileObject | null>;
|
|
22
|
+
/**
|
|
23
|
+
* Read the wanted lockfile in its on-disk shape ({@link LockfileFile}),
|
|
24
|
+
* skipping the conversion to the in-memory {@link LockfileObject}.
|
|
25
|
+
*
|
|
26
|
+
* Use this when the caller needs the exact serialized form — e.g. to
|
|
27
|
+
* forward the lockfile to a server that speaks the on-disk format —
|
|
28
|
+
* rather than the in-process representation.
|
|
29
|
+
*/
|
|
30
|
+
export declare function readWantedLockfileFile(pkgPath: string, opts: {
|
|
31
|
+
wantedVersions?: string[];
|
|
32
|
+
ignoreIncompatible: boolean;
|
|
33
|
+
useGitBranchLockfile?: boolean;
|
|
34
|
+
mergeGitBranchLockfiles?: boolean;
|
|
35
|
+
}): Promise<LockfileFile | null>;
|
|
22
36
|
export declare function wantedLockfileHasMergeConflictsSync(pkgPath: string): boolean;
|
|
23
37
|
export declare function createLockfileObject(importerIds: ProjectId[], opts: {
|
|
24
38
|
lockfileVersion: string;
|
package/lib/read.js
CHANGED
|
@@ -11,7 +11,7 @@ import stripBom from 'strip-bom';
|
|
|
11
11
|
import { LockfileBreakingChangeError } from './errors/index.js';
|
|
12
12
|
import { getGitBranchLockfileNames } from './gitBranchLockfile.js';
|
|
13
13
|
import { autofixMergeConflicts, isDiff } from './gitMergeFile.js';
|
|
14
|
-
import { convertToLockfileObject } from './lockfileFormatConverters.js';
|
|
14
|
+
import { convertToLockfileFile, convertToLockfileObject } from './lockfileFormatConverters.js';
|
|
15
15
|
import { getWantedLockfileName } from './lockfileName.js';
|
|
16
16
|
import { lockfileLogger as logger } from './logger.js';
|
|
17
17
|
import { extractMainDocument } from './yamlDocuments.js';
|
|
@@ -28,6 +28,17 @@ export async function readWantedLockfileAndAutofixConflicts(pkgPath, opts) {
|
|
|
28
28
|
export async function readWantedLockfile(pkgPath, opts) {
|
|
29
29
|
return (await _readWantedLockfile(pkgPath, opts)).lockfile;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Read the wanted lockfile in its on-disk shape ({@link LockfileFile}),
|
|
33
|
+
* skipping the conversion to the in-memory {@link LockfileObject}.
|
|
34
|
+
*
|
|
35
|
+
* Use this when the caller needs the exact serialized form — e.g. to
|
|
36
|
+
* forward the lockfile to a server that speaks the on-disk format —
|
|
37
|
+
* rather than the in-process representation.
|
|
38
|
+
*/
|
|
39
|
+
export async function readWantedLockfileFile(pkgPath, opts) {
|
|
40
|
+
return (await _readWantedLockfile(pkgPath, opts)).lockfileFile;
|
|
41
|
+
}
|
|
31
42
|
export function wantedLockfileHasMergeConflictsSync(pkgPath) {
|
|
32
43
|
try {
|
|
33
44
|
const lockfileRawContent = stripBom(fs.readFileSync(path.join(pkgPath, WANTED_LOCKFILE), 'utf8'));
|
|
@@ -52,6 +63,7 @@ opts) {
|
|
|
52
63
|
}
|
|
53
64
|
return {
|
|
54
65
|
lockfile: null,
|
|
66
|
+
lockfileFile: null,
|
|
55
67
|
hadConflicts: false,
|
|
56
68
|
};
|
|
57
69
|
}
|
|
@@ -60,13 +72,16 @@ opts) {
|
|
|
60
72
|
if (!lockfileRawContent.trim()) {
|
|
61
73
|
return {
|
|
62
74
|
lockfile: null,
|
|
75
|
+
lockfileFile: null,
|
|
63
76
|
hadConflicts: false,
|
|
64
77
|
};
|
|
65
78
|
}
|
|
66
79
|
let lockfile;
|
|
80
|
+
let lockfileFile;
|
|
67
81
|
let hadConflicts;
|
|
68
82
|
try {
|
|
69
|
-
|
|
83
|
+
lockfileFile = yaml.load(lockfileRawContent);
|
|
84
|
+
lockfile = convertToLockfileObject(lockfileFile);
|
|
70
85
|
hadConflicts = false;
|
|
71
86
|
}
|
|
72
87
|
catch (err) {
|
|
@@ -75,6 +90,7 @@ opts) {
|
|
|
75
90
|
}
|
|
76
91
|
hadConflicts = true;
|
|
77
92
|
lockfile = autofixMergeConflicts(lockfileRawContent);
|
|
93
|
+
lockfileFile = convertToLockfileFile(lockfile);
|
|
78
94
|
logger.info({
|
|
79
95
|
message: `Merge conflict detected in ${WANTED_LOCKFILE} and successfully merged`,
|
|
80
96
|
prefix,
|
|
@@ -96,7 +112,7 @@ opts) {
|
|
|
96
112
|
}
|
|
97
113
|
return true;
|
|
98
114
|
})) {
|
|
99
|
-
return { lockfile, hadConflicts };
|
|
115
|
+
return { lockfile, lockfileFile, hadConflicts };
|
|
100
116
|
}
|
|
101
117
|
}
|
|
102
118
|
if (opts.ignoreIncompatible) {
|
|
@@ -104,7 +120,7 @@ opts) {
|
|
|
104
120
|
message: `Ignoring not compatible lockfile at ${lockfilePath}`,
|
|
105
121
|
prefix,
|
|
106
122
|
});
|
|
107
|
-
return { lockfile: null, hadConflicts: false };
|
|
123
|
+
return { lockfile: null, lockfileFile: null, hadConflicts: false };
|
|
108
124
|
}
|
|
109
125
|
throw new LockfileBreakingChangeError(lockfilePath);
|
|
110
126
|
}
|
|
@@ -134,13 +150,14 @@ async function _readWantedLockfile(pkgPath, opts) {
|
|
|
134
150
|
lockfileNames.unshift(gitBranchLockfileName);
|
|
135
151
|
}
|
|
136
152
|
}
|
|
137
|
-
let result = { lockfile: null, hadConflicts: false };
|
|
153
|
+
let result = { lockfile: null, lockfileFile: null, hadConflicts: false };
|
|
138
154
|
/* eslint-disable no-await-in-loop */
|
|
139
155
|
for (const lockfileName of lockfileNames) {
|
|
140
156
|
result = await _read(path.join(pkgPath, lockfileName), pkgPath, { ...opts, autofixMergeConflicts: true });
|
|
141
157
|
if (result.lockfile) {
|
|
142
158
|
if (opts.mergeGitBranchLockfiles) {
|
|
143
159
|
result.lockfile = await _mergeGitBranchLockfiles(result.lockfile, pkgPath, pkgPath, opts);
|
|
160
|
+
result.lockfileFile = result.lockfile ? convertToLockfileFile(result.lockfile) : null;
|
|
144
161
|
}
|
|
145
162
|
break;
|
|
146
163
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/lockfile.fs",
|
|
3
|
-
"version": "1100.1.
|
|
3
|
+
"version": "1100.1.3",
|
|
4
4
|
"description": "Read/write pnpm-lock.yaml files",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -10,7 +10,10 @@
|
|
|
10
10
|
],
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"funding": "https://opencollective.com/pnpm",
|
|
13
|
-
"repository":
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/pnpm/pnpm/tree/main/lockfile/fs"
|
|
16
|
+
},
|
|
14
17
|
"homepage": "https://github.com/pnpm/pnpm/tree/main/lockfile/fs#readme",
|
|
15
18
|
"bugs": {
|
|
16
19
|
"url": "https://github.com/pnpm/pnpm/issues"
|
|
@@ -36,13 +39,13 @@
|
|
|
36
39
|
"write-file-atomic": "^7.0.1",
|
|
37
40
|
"@pnpm/constants": "1100.0.0",
|
|
38
41
|
"@pnpm/error": "1100.0.0",
|
|
39
|
-
"@pnpm/
|
|
40
|
-
"@pnpm/
|
|
41
|
-
"@pnpm/lockfile.
|
|
42
|
+
"@pnpm/deps.path": "1100.0.6",
|
|
43
|
+
"@pnpm/lockfile.types": "1100.0.9",
|
|
44
|
+
"@pnpm/lockfile.utils": "1100.0.11",
|
|
45
|
+
"@pnpm/types": "1101.3.0",
|
|
42
46
|
"@pnpm/object.key-sorting": "1100.0.0",
|
|
43
|
-
"@pnpm/
|
|
44
|
-
"@pnpm/lockfile.
|
|
45
|
-
"@pnpm/deps.path": "1100.0.5"
|
|
47
|
+
"@pnpm/network.git-utils": "1100.0.1",
|
|
48
|
+
"@pnpm/lockfile.merger": "1100.0.9"
|
|
46
49
|
},
|
|
47
50
|
"peerDependencies": {
|
|
48
51
|
"@pnpm/logger": "^1001.0.1"
|
|
@@ -57,8 +60,8 @@
|
|
|
57
60
|
"tempy": "3.0.0",
|
|
58
61
|
"write-yaml-file": "^6.0.0",
|
|
59
62
|
"yaml-tag": "1.1.0",
|
|
60
|
-
"@pnpm/
|
|
61
|
-
"@pnpm/
|
|
63
|
+
"@pnpm/logger": "1100.0.0",
|
|
64
|
+
"@pnpm/lockfile.fs": "1100.1.3"
|
|
62
65
|
},
|
|
63
66
|
"engines": {
|
|
64
67
|
"node": ">=22.13"
|