@pnpm/lockfile.make-dedicated-lockfile 1000.0.28
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/LICENSE +22 -0
- package/README.md +28 -0
- package/bin/make-dedicated-lockfile.js +2 -0
- package/lib/bin.d.ts +1 -0
- package/lib/bin.js +13 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +83 -0
- package/package.json +62 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
|
|
4
|
+
Copyright (c) 2016-2026 Zoltan Kochan and other contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @pnpm/make-dedicated-lockfile
|
|
2
|
+
|
|
3
|
+
> Creates a dedicated lockfile for a subset of workspace projects
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pnpm/make-dedicated-lockfile)
|
|
6
|
+
|
|
7
|
+
**This package is deprecated. Please use the [pnpm deploy] command instead.**
|
|
8
|
+
|
|
9
|
+
[pnpm deploy]: https://pnpm.io/cli/deploy
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pnpm add @pnpm/make-dedicated-lockfile
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
Open the directory of the workspace project that you want to create a dedicated lockfile for.
|
|
20
|
+
|
|
21
|
+
Run `make-dedicated-lockfile` in the terminal.
|
|
22
|
+
|
|
23
|
+
A new lockfile will be generated, using dependencies from the shared workspace lockfile but
|
|
24
|
+
only those that are related to the project in the current working directory or subdirectories.
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
MIT
|
package/lib/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/bin.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
import { findWorkspaceDir } from '@pnpm/workspace.root-finder';
|
|
3
|
+
import { makeDedicatedLockfile } from './index.js';
|
|
4
|
+
main();
|
|
5
|
+
async function main() {
|
|
6
|
+
const projectDir = process.cwd();
|
|
7
|
+
const lockfileDir = await findWorkspaceDir(projectDir);
|
|
8
|
+
if (!lockfileDir) {
|
|
9
|
+
throw new PnpmError('WORKSPACE_NOT_FOUND', 'Cannot create a dedicated lockfile for a project that is not in a workspace.');
|
|
10
|
+
}
|
|
11
|
+
await makeDedicatedLockfile(lockfileDir, projectDir);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=bin.js.map
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function makeDedicatedLockfile(lockfileDir: string, projectDir: string): Promise<void>;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import pnpmExec from '@pnpm/exec';
|
|
3
|
+
import { getLockfileImporterId, readWantedLockfile, writeWantedLockfile, } from '@pnpm/lockfile.fs';
|
|
4
|
+
import { pruneSharedLockfile } from '@pnpm/lockfile.pruner';
|
|
5
|
+
import { createExportableManifest } from '@pnpm/releasing.exportable-manifest';
|
|
6
|
+
import { DEPENDENCIES_FIELDS } from '@pnpm/types';
|
|
7
|
+
import { readProjectManifest } from '@pnpm/workspace.project-manifest-reader';
|
|
8
|
+
import { pickBy } from 'ramda';
|
|
9
|
+
import { renameOverwrite } from 'rename-overwrite';
|
|
10
|
+
export async function makeDedicatedLockfile(lockfileDir, projectDir) {
|
|
11
|
+
const lockfile = await readWantedLockfile(lockfileDir, { ignoreIncompatible: false });
|
|
12
|
+
if (lockfile == null) {
|
|
13
|
+
throw new Error('no lockfile found');
|
|
14
|
+
}
|
|
15
|
+
const allImporters = lockfile.importers;
|
|
16
|
+
lockfile.importers = {};
|
|
17
|
+
const baseImporterId = getLockfileImporterId(lockfileDir, projectDir);
|
|
18
|
+
for (const [importerId, importer] of Object.entries(allImporters)) {
|
|
19
|
+
if (importerId.startsWith(`${baseImporterId}/`)) {
|
|
20
|
+
const newImporterId = importerId.slice(baseImporterId.length + 1);
|
|
21
|
+
lockfile.importers[newImporterId] = projectSnapshotWithoutLinkedDeps(importer);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
if (importerId === baseImporterId) {
|
|
25
|
+
lockfile.importers['.'] = projectSnapshotWithoutLinkedDeps(importer);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const dedicatedLockfile = pruneSharedLockfile(lockfile);
|
|
29
|
+
await writeWantedLockfile(projectDir, dedicatedLockfile);
|
|
30
|
+
const { manifest, writeProjectManifest } = await readProjectManifest(projectDir);
|
|
31
|
+
const publishManifest = await createExportableManifest(projectDir, manifest, {
|
|
32
|
+
// Since @pnpm/lockfile.make-dedicated-lockfile is deprecated, avoid supporting new
|
|
33
|
+
// features like pnpm catalogs. Passing in an empty catalog object
|
|
34
|
+
// intentionally.
|
|
35
|
+
catalogs: {},
|
|
36
|
+
});
|
|
37
|
+
await writeProjectManifest(publishManifest);
|
|
38
|
+
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
|
+
let modulesRenamed = false;
|
|
42
|
+
try {
|
|
43
|
+
await renameOverwrite(modulesDir, tmp);
|
|
44
|
+
await renameOverwrite(tmp, tempModulesDir);
|
|
45
|
+
modulesRenamed = true;
|
|
46
|
+
}
|
|
47
|
+
catch (err) { // eslint-disable-line
|
|
48
|
+
if (err['code'] !== 'ENOENT')
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
await pnpmExec.default([
|
|
53
|
+
'install',
|
|
54
|
+
'--frozen-lockfile',
|
|
55
|
+
'--lockfile-dir=.',
|
|
56
|
+
'--fix-lockfile',
|
|
57
|
+
'--filter=.',
|
|
58
|
+
'--no-link-workspace-packages',
|
|
59
|
+
'--config.dedupe-peer-dependents=false', // TODO: remove this. It should work without it
|
|
60
|
+
], {
|
|
61
|
+
cwd: projectDir,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
if (modulesRenamed) {
|
|
66
|
+
await renameOverwrite(tempModulesDir, tmp);
|
|
67
|
+
await renameOverwrite(tmp, modulesDir);
|
|
68
|
+
}
|
|
69
|
+
await writeProjectManifest(manifest);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function projectSnapshotWithoutLinkedDeps(projectSnapshot) {
|
|
73
|
+
const newProjectSnapshot = {
|
|
74
|
+
specifiers: projectSnapshot.specifiers,
|
|
75
|
+
};
|
|
76
|
+
for (const depField of DEPENDENCIES_FIELDS) {
|
|
77
|
+
if (projectSnapshot[depField] == null)
|
|
78
|
+
continue;
|
|
79
|
+
newProjectSnapshot[depField] = pickBy((depVersion) => !depVersion.startsWith('link:'), projectSnapshot[depField]);
|
|
80
|
+
}
|
|
81
|
+
return newProjectSnapshot;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnpm/lockfile.make-dedicated-lockfile",
|
|
3
|
+
"version": "1000.0.28",
|
|
4
|
+
"description": "Creates a dedicated lockfile for a subset of workspace projects",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pnpm",
|
|
7
|
+
"pnpm11",
|
|
8
|
+
"make-dedicated-lockfile"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"funding": "https://opencollective.com/pnpm",
|
|
12
|
+
"repository": "https://github.com/pnpm/pnpm/tree/main/lockfile/make-dedicated-lockfile",
|
|
13
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/lockfile/make-dedicated-lockfile#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "lib/index.js",
|
|
19
|
+
"types": "lib/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./lib/index.js"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"lib",
|
|
25
|
+
"!*.map",
|
|
26
|
+
"bin"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@pnpm/exec": "^2.0.0",
|
|
30
|
+
"ramda": "npm:@pnpm/ramda@0.28.1",
|
|
31
|
+
"rename-overwrite": "^7.0.0",
|
|
32
|
+
"@pnpm/lockfile.pruner": "1001.0.17",
|
|
33
|
+
"@pnpm/error": "1000.0.5",
|
|
34
|
+
"@pnpm/logger": "1001.0.1",
|
|
35
|
+
"@pnpm/lockfile.fs": "1001.1.21",
|
|
36
|
+
"@pnpm/releasing.exportable-manifest": "1000.1.7",
|
|
37
|
+
"@pnpm/types": "1000.9.0",
|
|
38
|
+
"@pnpm/workspace.project-manifest-reader": "1001.1.4",
|
|
39
|
+
"@pnpm/workspace.root-finder": "1000.1.3"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/ramda": "0.29.12",
|
|
43
|
+
"execa": "npm:safe-execa@0.3.0",
|
|
44
|
+
"@pnpm/lockfile.make-dedicated-lockfile": "1000.0.28",
|
|
45
|
+
"@pnpm/test-fixtures": "1000.0.0"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=22.13"
|
|
49
|
+
},
|
|
50
|
+
"jest": {
|
|
51
|
+
"preset": "@pnpm/jest-config"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
55
|
+
"_test": "cross-env NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules --disable-warning=ExperimentalWarning --disable-warning=DEP0169\" jest",
|
|
56
|
+
"test": "pnpm run compile && pnpm run _test",
|
|
57
|
+
"compile": "tsgo --build && pnpm run lint --fix"
|
|
58
|
+
},
|
|
59
|
+
"bin": {
|
|
60
|
+
"lockfile.make-dedicated-lockfile": "./bin/make-dedicated-lockfile.js"
|
|
61
|
+
}
|
|
62
|
+
}
|