@pnpm/lockfile.make-dedicated-lockfile 1100.0.40 → 1100.0.42
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/CHANGELOG.md +32 -0
- package/bin/make-dedicated-lockfile.js +1 -1
- package/lib/index.js +65 -21
- package/package.json +9 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @pnpm/make-dedicated-lockfile
|
|
2
2
|
|
|
3
|
+
## 1100.0.42
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed the `make-dedicated-lockfile` command failing to start with `ReferenceError: require is not defined in ES module scope`.
|
|
8
|
+
|
|
9
|
+
- `make-dedicated-lockfile` now restores `package.json` when it cannot move the original `node_modules` back to its place. The error then names `.tmp_node_modules`, where the original `node_modules` was left. The command refuses to run while that directory exists, so a retry cannot overwrite it.
|
|
10
|
+
|
|
11
|
+
- `make-dedicated-lockfile` no longer removes fields such as `main` and `types` from the `publishConfig` of the project's `package.json`.
|
|
12
|
+
|
|
13
|
+
- `make-dedicated-lockfile` keeps workspace dependencies linked in the dedicated lockfile [#3442](https://github.com/pnpm/pnpm/issues/3442).
|
|
14
|
+
|
|
15
|
+
- Updated dependencies:
|
|
16
|
+
- @pnpm/error@1100.2.0
|
|
17
|
+
- @pnpm/lockfile.fs@1100.2.9
|
|
18
|
+
- @pnpm/lockfile.pruner@1100.0.25
|
|
19
|
+
- @pnpm/releasing.exportable-manifest@1100.3.3
|
|
20
|
+
- @pnpm/types@1102.1.1
|
|
21
|
+
- @pnpm/workspace.project-manifest-reader@1100.1.0
|
|
22
|
+
- @pnpm/workspace.root-finder@1100.1.0
|
|
23
|
+
|
|
24
|
+
## 1100.0.41
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies:
|
|
29
|
+
- @pnpm/lockfile.fs@1100.2.8
|
|
30
|
+
- @pnpm/lockfile.pruner@1100.0.24
|
|
31
|
+
- @pnpm/releasing.exportable-manifest@1100.3.2
|
|
32
|
+
- @pnpm/workspace.project-manifest-reader@1100.0.29
|
|
33
|
+
- @pnpm/workspace.root-finder@1100.0.9
|
|
34
|
+
|
|
3
35
|
## 1100.0.40
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
2
|
+
import {} from '../lib/bin.js'
|
package/lib/index.js
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import path from 'node:path';
|
|
3
|
+
import util from 'node:util';
|
|
4
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
5
|
import { pnpmExec } from '@pnpm/exec';
|
|
3
6
|
import { getLockfileImporterId, readWantedLockfile, writeWantedLockfile, } from '@pnpm/lockfile.fs';
|
|
4
7
|
import { pruneSharedLockfile } from '@pnpm/lockfile.pruner';
|
|
5
8
|
import { createExportableManifest } from '@pnpm/releasing.exportable-manifest';
|
|
6
9
|
import { DEPENDENCIES_FIELDS } from '@pnpm/types';
|
|
7
10
|
import { readProjectManifest } from '@pnpm/workspace.project-manifest-reader';
|
|
8
|
-
import { pickBy } from 'ramda';
|
|
9
11
|
import { renameOverwrite } from 'rename-overwrite';
|
|
10
12
|
export async function makeDedicatedLockfile(lockfileDir, projectDir) {
|
|
13
|
+
const tempModulesDir = path.join(projectDir, '.tmp_node_modules');
|
|
14
|
+
if (fs.existsSync(tempModulesDir)) {
|
|
15
|
+
throw new PnpmError('STAGED_MODULES_DIR_EXISTS', `${tempModulesDir} already exists`, {
|
|
16
|
+
hint: 'It holds the node_modules of an earlier run that could not be moved back. Restore or remove it, then run the command again.',
|
|
17
|
+
});
|
|
18
|
+
}
|
|
11
19
|
const lockfile = await readWantedLockfile(lockfileDir, { ignoreIncompatible: false });
|
|
12
20
|
if (lockfile == null) {
|
|
13
21
|
throw new Error('no lockfile found');
|
|
@@ -18,11 +26,11 @@ export async function makeDedicatedLockfile(lockfileDir, projectDir) {
|
|
|
18
26
|
for (const [importerId, importer] of Object.entries(allImporters)) {
|
|
19
27
|
if (importerId.startsWith(`${baseImporterId}/`)) {
|
|
20
28
|
const newImporterId = importerId.slice(baseImporterId.length + 1);
|
|
21
|
-
lockfile.importers[newImporterId] =
|
|
29
|
+
lockfile.importers[newImporterId] = importer;
|
|
22
30
|
continue;
|
|
23
31
|
}
|
|
24
32
|
if (importerId === baseImporterId) {
|
|
25
|
-
lockfile.importers['.'] =
|
|
33
|
+
lockfile.importers['.'] = importer;
|
|
26
34
|
}
|
|
27
35
|
}
|
|
28
36
|
const dedicatedLockfile = pruneSharedLockfile(lockfile);
|
|
@@ -34,20 +42,18 @@ export async function makeDedicatedLockfile(lockfileDir, projectDir) {
|
|
|
34
42
|
// intentionally.
|
|
35
43
|
catalogs: {},
|
|
36
44
|
});
|
|
37
|
-
await writeProjectManifest(publishManifest);
|
|
45
|
+
await writeProjectManifest(withWorkspaceDependencies(manifest, publishManifest));
|
|
38
46
|
const modulesDir = path.join(projectDir, 'node_modules');
|
|
39
|
-
const tmp = path.join(projectDir, 'tmp_node_modules');
|
|
40
|
-
const tempModulesDir = path.join(projectDir, 'node_modules/.tmp');
|
|
41
47
|
let modulesRenamed = false;
|
|
42
48
|
try {
|
|
43
|
-
await renameOverwrite(modulesDir,
|
|
44
|
-
await renameOverwrite(tmp, tempModulesDir);
|
|
49
|
+
await renameOverwrite(modulesDir, tempModulesDir);
|
|
45
50
|
modulesRenamed = true;
|
|
46
51
|
}
|
|
47
52
|
catch (err) { // eslint-disable-line
|
|
48
53
|
if (err['code'] !== 'ENOENT')
|
|
49
54
|
throw err;
|
|
50
55
|
}
|
|
56
|
+
const errors = [];
|
|
51
57
|
try {
|
|
52
58
|
await pnpmExec([
|
|
53
59
|
'install',
|
|
@@ -55,29 +61,67 @@ export async function makeDedicatedLockfile(lockfileDir, projectDir) {
|
|
|
55
61
|
'--lockfile-dir=.',
|
|
56
62
|
'--fix-lockfile',
|
|
57
63
|
'--filter=.',
|
|
58
|
-
'--no-link-workspace-packages',
|
|
59
64
|
'--config.dedupe-peer-dependents=false', // TODO: remove this. It should work without it
|
|
60
65
|
], {
|
|
61
66
|
cwd: projectDir,
|
|
62
67
|
});
|
|
63
68
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
catch (err) {
|
|
70
|
+
errors.push(err);
|
|
71
|
+
}
|
|
72
|
+
let modulesRestored = !modulesRenamed;
|
|
73
|
+
if (modulesRenamed) {
|
|
74
|
+
try {
|
|
75
|
+
await renameOverwrite(tempModulesDir, modulesDir);
|
|
76
|
+
modulesRestored = true;
|
|
68
77
|
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
errors.push(err);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
try {
|
|
69
83
|
await writeProjectManifest(manifest);
|
|
70
84
|
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
errors.push(err);
|
|
87
|
+
}
|
|
88
|
+
if (errors.length === 1) {
|
|
89
|
+
throw errors[0];
|
|
90
|
+
}
|
|
91
|
+
if (errors.length > 1) {
|
|
92
|
+
const failures = errors.map((err) => util.types.isNativeError(err) ? err.message : String(err));
|
|
93
|
+
throw new PnpmError('MAKE_DEDICATED_LOCKFILE_FAILED', `Creating the dedicated lockfile in ${projectDir} failed:\n${failures.join('\n')}`, {
|
|
94
|
+
cause: new AggregateError(errors, undefined, { cause: errors[0] }),
|
|
95
|
+
hint: modulesRestored ? undefined : `The original node_modules is still in ${tempModulesDir}.`,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
71
98
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
99
|
+
/**
|
|
100
|
+
* The exportable manifest replaces `workspace:` specifiers with the version
|
|
101
|
+
* range a published copy would use, which the install would then look up in
|
|
102
|
+
* the registry. The dedicated lockfile keeps the workspace project linked, so
|
|
103
|
+
* its specifier stays as declared.
|
|
104
|
+
*/
|
|
105
|
+
function withWorkspaceDependencies(manifest, publishManifest) {
|
|
106
|
+
const result = { ...publishManifest };
|
|
107
|
+
for (const depField of [...DEPENDENCIES_FIELDS, 'peerDependencies']) {
|
|
108
|
+
const deps = manifest[depField];
|
|
109
|
+
if (deps == null || result[depField] == null)
|
|
78
110
|
continue;
|
|
79
|
-
|
|
111
|
+
let updatedDeps;
|
|
112
|
+
for (const [depName, spec] of Object.entries(deps)) {
|
|
113
|
+
const isWorkspace = depField === 'peerDependencies' ? spec.includes('workspace:') : spec.startsWith('workspace:');
|
|
114
|
+
if (isWorkspace) {
|
|
115
|
+
if (updatedDeps == null) {
|
|
116
|
+
updatedDeps = { ...result[depField] };
|
|
117
|
+
}
|
|
118
|
+
updatedDeps[depName] = spec;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (updatedDeps != null) {
|
|
122
|
+
result[depField] = updatedDeps;
|
|
123
|
+
}
|
|
80
124
|
}
|
|
81
|
-
return
|
|
125
|
+
return result;
|
|
82
126
|
}
|
|
83
127
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/lockfile.make-dedicated-lockfile",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.42",
|
|
4
4
|
"description": "Creates a dedicated lockfile for a subset of workspace projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -32,23 +32,21 @@
|
|
|
32
32
|
"lockfile.make-dedicated-lockfile": "./bin/make-dedicated-lockfile.js"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@pnpm/error": "1100.
|
|
35
|
+
"@pnpm/error": "1100.2.0",
|
|
36
36
|
"@pnpm/exec": "^4.0.0",
|
|
37
|
-
"@pnpm/lockfile.fs": "1100.2.
|
|
38
|
-
"@pnpm/lockfile.pruner": "1100.0.
|
|
37
|
+
"@pnpm/lockfile.fs": "1100.2.9",
|
|
38
|
+
"@pnpm/lockfile.pruner": "1100.0.25",
|
|
39
39
|
"@pnpm/logger": "1100.0.0",
|
|
40
|
-
"@pnpm/releasing.exportable-manifest": "1100.3.
|
|
41
|
-
"@pnpm/types": "1102.1.
|
|
42
|
-
"@pnpm/workspace.project-manifest-reader": "1100.0
|
|
43
|
-
"@pnpm/workspace.root-finder": "1100.0
|
|
44
|
-
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
40
|
+
"@pnpm/releasing.exportable-manifest": "1100.3.3",
|
|
41
|
+
"@pnpm/types": "1102.1.1",
|
|
42
|
+
"@pnpm/workspace.project-manifest-reader": "1100.1.0",
|
|
43
|
+
"@pnpm/workspace.root-finder": "1100.1.0",
|
|
45
44
|
"rename-overwrite": "^7.0.1"
|
|
46
45
|
},
|
|
47
46
|
"devDependencies": {
|
|
48
47
|
"@jest/globals": "30.4.1",
|
|
49
|
-
"@pnpm/lockfile.make-dedicated-lockfile": "1100.0.
|
|
48
|
+
"@pnpm/lockfile.make-dedicated-lockfile": "1100.0.42",
|
|
50
49
|
"@pnpm/test-fixtures": "1100.0.1",
|
|
51
|
-
"@types/ramda": "0.32.0",
|
|
52
50
|
"execa": "npm:safe-execa@0.3.0"
|
|
53
51
|
},
|
|
54
52
|
"engines": {
|