From 5c3a2835402f007ef7b50fb156802d79e383bccc Mon Sep 17 00:00:00 2001 From: "Morley, Jonathan" Date: Thu, 28 Jul 2022 10:33:17 -0400 Subject: [PATCH] support recursive writing of yarn.lock files --- package.json | 5 +- pnpm-lock.yaml | 135 +++++++++++++++++++++++++++++++------------ src/npm/v1/index.ts | 1 - src/pnpm/index.ts | 55 +++++++++++++++++- src/yarn/v1/index.ts | 16 ++++- 5 files changed, 172 insertions(+), 40 deletions(-) diff --git a/package.json b/package.json index 05dfcff..421f332 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cvent/pnpm-lock-export", - "version": "0.2.4", + "version": "0.3.0", "description": "A utility for converting pnpm-lock.yaml to other lockfile formats", "main": "dist/src/index.js", "files": [ @@ -21,10 +21,13 @@ "author": "Jonathan Morley ", "license": "MIT", "dependencies": { + "@manypkg/get-packages": "^1.1.3", "@pnpm/lockfile-file": "^5.1.4", "@pnpm/lockfile-utils": "^4.1.0", "@pnpm/logger": "^4.0.0", + "@pnpm/prune-lockfile": "^4.0.12", "@pnpm/read-project-manifest": "^3.0.6", + "@pnpm/types": "^8.4.0", "argparse": "^2.0.1", "dependency-path": "^9.2.3" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 03b337b..402994f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,12 +1,15 @@ lockfileVersion: 5.4 specifiers: + '@manypkg/get-packages': ^1.1.3 '@pnpm/lockfile-file': ^5.1.4 '@pnpm/lockfile-types': ^4.2.0 '@pnpm/lockfile-utils': ^4.1.0 '@pnpm/logger': ^4.0.0 + '@pnpm/prune-lockfile': ^4.0.12 '@pnpm/read-project-manifest': ^3.0.6 '@pnpm/registry-mock': ^2.20.0 + '@pnpm/types': ^8.4.0 '@swc/core': ^1.2.218 '@swc/jest': ^0.2.22 '@tsconfig/node16-strictest': ^1.0.0 @@ -24,10 +27,13 @@ specifiers: typescript: ^4.7.4 dependencies: + '@manypkg/get-packages': 1.1.3 '@pnpm/lockfile-file': 5.1.4_@pnpm+logger@4.0.0 '@pnpm/lockfile-utils': 4.1.0 '@pnpm/logger': 4.0.0 + '@pnpm/prune-lockfile': 4.0.12 '@pnpm/read-project-manifest': 3.0.6 + '@pnpm/types': 8.4.0 argparse: 2.0.1 dependency-path: 9.2.3 @@ -331,6 +337,13 @@ packages: '@babel/helper-plugin-utils': 7.18.9 dev: true + /@babel/runtime/7.18.9: + resolution: {integrity: sha512-lkqXDcvlFT5rvEjiu6+QYO+1GXrEHRo2LOtS7E4GtX5ESIZOgepqsZBVIj6Pv+a6zqsya9VCgiK1KAK4BvJDAw==} + engines: {node: '>=6.9.0'} + dependencies: + regenerator-runtime: 0.13.9 + dev: false + /@babel/template/7.18.6: resolution: {integrity: sha512-JoDWzPe+wgBsTTgdnIma3iHNFC7YVJoPssVBDjiHfNlyt4YcunDtcDOUmfVDfCK5MfdsaIoX9PkijPhjH3nYUw==} engines: {node: '>=6.9.0'} @@ -370,6 +383,10 @@ packages: resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==} dev: true + /@changesets/types/4.1.0: + resolution: {integrity: sha512-LDQvVDv5Kb50ny2s25Fhm3d9QSZimsoUGBsUioj6MC3qbMUCuC8GPIvk/M6IvXx3lYhAs0lwWUQLb+VIEUCECw==} + dev: false + /@eslint/eslintrc/1.3.0: resolution: {integrity: sha512-UWW0TMTmk2d7hLcWD1/e2g5HDM/HQ3csaLSqXCfqwh4uNDuNqlaKWXmEsL4Cs41Z0KnILNvwbHAah3C2yt06kw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -688,18 +705,36 @@ packages: '@jridgewell/sourcemap-codec': 1.4.14 dev: true + /@manypkg/find-root/1.1.0: + resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} + dependencies: + '@babel/runtime': 7.18.9 + '@types/node': 12.20.55 + find-up: 4.1.0 + fs-extra: 8.1.0 + dev: false + + /@manypkg/get-packages/1.1.3: + resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==} + dependencies: + '@babel/runtime': 7.18.9 + '@changesets/types': 4.1.0 + '@manypkg/find-root': 1.1.0 + fs-extra: 8.1.0 + globby: 11.1.0 + read-yaml-file: 1.1.0 + dev: false + /@nodelib/fs.scandir/2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} dependencies: '@nodelib/fs.stat': 2.0.5 run-parallel: 1.2.0 - dev: true /@nodelib/fs.stat/2.0.5: resolution: {integrity: sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==} engines: {node: '>= 8'} - dev: true /@nodelib/fs.walk/1.2.8: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} @@ -707,7 +742,6 @@ packages: dependencies: '@nodelib/fs.scandir': 2.1.5 fastq: 1.13.0 - dev: true /@pnpm/constants/6.1.0: resolution: {integrity: sha512-L6AiU3OXv9kjKGTJN9j8n1TeJGDcLX9atQlZvAkthlvbXjvKc5SKNWESc/eXhr5nEfuMWhQhiKHDJCpYejmeCQ==} @@ -772,6 +806,13 @@ packages: dependencies: '@pnpm/types': 8.4.0 + /@pnpm/lockfile-types/4.3.0: + resolution: {integrity: sha512-D60rgOn+7J6i1vYQMNYKggRE3gmQzi1jNrj7u1eLSee5KuGs/j5bavZrrRwrDPe16QMtutKlUO9OQIf+FCvatA==} + engines: {node: '>=14.6'} + dependencies: + '@pnpm/types': 8.4.0 + dev: false + /@pnpm/lockfile-utils/4.1.0: resolution: {integrity: sha512-agNVkmv0aTlPll1QgHUdWNT31pN+qOz0Da+VFGfVOnPbk0BngFMo/vbqUj1FH8kePN53j8MfVP6ruaFBNOFIbA==} engines: {node: '>=14.6'} @@ -802,6 +843,17 @@ packages: semver: 7.3.7 dev: false + /@pnpm/prune-lockfile/4.0.12: + resolution: {integrity: sha512-TXBiYBdUKzBBAS6OR91kklkebXKGjMAB6Wa8wrgosMkSPUbTdjMtqfENMCeavI0iGrUm8ktZTnYmvA+SKzRMvA==} + engines: {node: '>=14.6'} + dependencies: + '@pnpm/constants': 6.1.0 + '@pnpm/lockfile-types': 4.3.0 + '@pnpm/types': 8.4.0 + dependency-path: 9.2.3 + ramda: 0.28.0 + dev: false + /@pnpm/read-project-manifest/3.0.6: resolution: {integrity: sha512-nKFODeo/K7kLSLXMJcGywANaiyL9JlLQHKG3SWJaAjkP3QBgYWqqXhGWx8ZPsk5z9k0RL0gPEpt3wod8FAbTPg==} engines: {node: '>=14.6'} @@ -1096,6 +1148,10 @@ packages: resolution: {integrity: sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==} dev: true + /@types/node/12.20.55: + resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} + dev: false + /@types/node/16.11.45: resolution: {integrity: sha512-3rKg/L5x0rofKuuUt5zlXzOnKyIHXmIu5R8A0TuNDMF2062/AOIDBciFIjToLEJ/9F9DzkHNot+BpNsMI1OLdQ==} dev: true @@ -1490,7 +1546,6 @@ packages: resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} dependencies: sprintf-js: 1.0.3 - dev: true /argparse/2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} @@ -1502,7 +1557,6 @@ packages: /array-union/2.1.0: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} engines: {node: '>=8'} - dev: true /asn1/0.2.6: resolution: {integrity: sha512-ix/FxPn0MDjeyJ7i/yoHGFt/EX6LyNbxSEhPPXODPL+KB0VPk86UYfL0lMdy+KCnv+fmvIzySwaK5COwqVbWTQ==} @@ -1665,7 +1719,6 @@ packages: engines: {node: '>=8'} dependencies: fill-range: 7.0.1 - dev: true /browser-process-hrtime/1.0.0: resolution: {integrity: sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==} @@ -2109,7 +2162,6 @@ packages: engines: {node: '>=8'} dependencies: path-type: 4.0.0 - dev: true /doctrine/3.0.0: resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} @@ -2354,7 +2406,6 @@ packages: resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} engines: {node: '>=4'} hasBin: true - dev: true /esquery/1.4.0: resolution: {integrity: sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==} @@ -2497,7 +2548,6 @@ packages: glob-parent: 5.1.2 merge2: 1.4.1 micromatch: 4.0.5 - dev: true /fast-json-stable-stringify/2.1.0: resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} @@ -2519,7 +2569,6 @@ packages: resolution: {integrity: sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw==} dependencies: reusify: 1.0.4 - dev: true /fb-watchman/2.0.1: resolution: {integrity: sha512-DkPJKQeY6kKwmuMretBhr7G6Vodr7bFwDYTXIkfG1gjvNpaxBTQV3PbXg6bR1c1UP4jPOX0jHUbbHANL9vRjVg==} @@ -2539,7 +2588,6 @@ packages: engines: {node: '>=8'} dependencies: to-regex-range: 5.0.1 - dev: true /finalhandler/1.2.0: resolution: {integrity: sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==} @@ -2562,7 +2610,6 @@ packages: dependencies: locate-path: 5.0.0 path-exists: 4.0.0 - dev: true /flat-cache/3.0.4: resolution: {integrity: sha512-dm9s5Pw7Jc0GvMYbshN6zchCA9RgQlzzEZX3vylR9IqFfS8XciblUXOKfW6SiuJ0e13eDYZoZV5wdrev7P3Nwg==} @@ -2603,6 +2650,15 @@ packages: engines: {node: '>= 0.6'} dev: true + /fs-extra/8.1.0: + resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} + engines: {node: '>=6 <7 || >=8'} + dependencies: + graceful-fs: 4.2.10 + jsonfile: 4.0.0 + universalify: 0.1.2 + dev: false + /fs.realpath/1.0.0: resolution: {integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=} @@ -2679,7 +2735,6 @@ packages: engines: {node: '>= 6'} dependencies: is-glob: 4.0.3 - dev: true /glob-parent/6.0.2: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} @@ -2741,7 +2796,6 @@ packages: ignore: 5.2.0 merge2: 1.4.1 slash: 3.0.0 - dev: true /graceful-fs/4.2.10: resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==} @@ -2862,7 +2916,6 @@ packages: /ignore/5.2.0: resolution: {integrity: sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==} engines: {node: '>= 4'} - dev: true /import-fresh/3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} @@ -2920,7 +2973,6 @@ packages: /is-extglob/2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} - dev: true /is-fullwidth-code-point/1.0.0: resolution: {integrity: sha512-1pqUqRjkhPJ9miNq9SwMfdvi6lBJcd6eFxvfaivQhaH3SgisfiuudvFntdKOmxuee/77l+FPjKrQjWvmPjWrRw==} @@ -2945,12 +2997,10 @@ packages: engines: {node: '>=0.10.0'} dependencies: is-extglob: 2.1.1 - dev: true /is-number/7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} - dev: true /is-path-cwd/2.2.0: resolution: {integrity: sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==} @@ -3498,7 +3548,6 @@ packages: dependencies: argparse: 1.0.10 esprima: 4.0.1 - dev: true /js-yaml/4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} @@ -3579,6 +3628,12 @@ packages: engines: {node: '>=6'} hasBin: true + /jsonfile/4.0.0: + resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + optionalDependencies: + graceful-fs: 4.2.10 + dev: false + /jsonparse/1.3.1: resolution: {integrity: sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==} engines: {'0': node >= 0.2.0} @@ -3671,7 +3726,6 @@ packages: engines: {node: '>=8'} dependencies: p-locate: 4.1.0 - dev: true /lockfile/1.0.4: resolution: {integrity: sha512-cvbTwETRfsFh4nHsL1eGWapU1XFi5Ot9E85sWAwia7Y7EgB7vfqcZhTKZ+l7hCGxSPoushMv5GKhT5PdLv03WA==} @@ -3821,7 +3875,6 @@ packages: /merge2/1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} - dev: true /methods/1.1.2: resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==} @@ -3834,7 +3887,6 @@ packages: dependencies: braces: 3.0.2 picomatch: 2.3.1 - dev: true /mime-db/1.52.0: resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} @@ -4115,7 +4167,6 @@ packages: engines: {node: '>=6'} dependencies: p-try: 2.2.0 - dev: true /p-limit/3.1.0: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} @@ -4129,7 +4180,6 @@ packages: engines: {node: '>=8'} dependencies: p-limit: 2.3.0 - dev: true /p-map/4.0.0: resolution: {integrity: sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==} @@ -4141,7 +4191,6 @@ packages: /p-try/2.2.0: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} - dev: true /parent-module/1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} @@ -4176,7 +4225,6 @@ packages: /path-exists/4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} - dev: true /path-is-absolute/1.0.1: resolution: {integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18=} @@ -4201,7 +4249,6 @@ packages: /path-type/4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - dev: true /performance-now/2.1.0: resolution: {integrity: sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==} @@ -4214,13 +4261,17 @@ packages: /picomatch/2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - dev: true /pify/3.0.0: resolution: {integrity: sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==} engines: {node: '>=4'} dev: true + /pify/4.0.1: + resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} + engines: {node: '>=6'} + dev: false + /pino-std-serializers/3.2.0: resolution: {integrity: sha512-EqX4pwDPrt3MuOAAUBMU0Tk5kR/YcCM5fNPEzgCO2zJ5HfX0vbiH9HbJglnyeQsN96Kznae6MWD47pZB5avTrg==} dev: true @@ -4343,7 +4394,6 @@ packages: /queue-microtask/1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} - dev: true /quick-format-unescaped/4.0.4: resolution: {integrity: sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==} @@ -4372,6 +4422,16 @@ packages: resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==} dev: true + /read-yaml-file/1.1.0: + resolution: {integrity: sha512-VIMnQi/Z4HT2Fxuwg5KrY174U1VdUIASQVWXXyqtNRtxSr9IYkn1rsI6Tb6HsrHCmB7gVpNwX6JxPTHcH6IoTA==} + engines: {node: '>=6'} + dependencies: + graceful-fs: 4.2.10 + js-yaml: 3.14.1 + pify: 4.0.1 + strip-bom: 3.0.0 + dev: false + /read-yaml-file/2.1.0: resolution: {integrity: sha512-UkRNRIwnhG+y7hpqnycCL/xbTk7+ia9VuVTC0S+zVbwd65DI9eUpRMfsWIGrCWxTU/mi+JW8cHQCrv+zfCbEPQ==} engines: {node: '>=10.13'} @@ -4400,6 +4460,10 @@ packages: util-deprecate: 1.0.2 dev: false + /regenerator-runtime/0.13.9: + resolution: {integrity: sha512-p3VT+cOEgxFsRRA9X4lkI1E+k2/CtnKtU4gcxyaCUreilL/vqI6CdZ3wxVUx3UOUg+gnUOQQcRI7BmSI656MYA==} + dev: false + /regexpp/3.2.0: resolution: {integrity: sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==} engines: {node: '>=8'} @@ -4526,7 +4590,6 @@ packages: /reusify/1.0.4: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - dev: true /rfc4648/1.5.2: resolution: {integrity: sha512-tLOizhR6YGovrEBLatX1sdcuhoSCXddw3mqNVAcKxGJ+J0hFeJ+SjeWCv5UPA/WU3YzWPPuCVYgXBKZUPGpKtg==} @@ -4563,7 +4626,6 @@ packages: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: queue-microtask: 1.2.3 - dev: true /safe-buffer/5.1.2: resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==} @@ -4679,7 +4741,6 @@ packages: /slash/3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} - dev: true /slide/1.1.6: resolution: {integrity: sha512-NwrtjCg+lZoqhFU8fOwl4ay2ei8PaqCBOUV3/ektPY9trO1yQ1oXEfmHAhKArUVUr/hOHvy5f6AdP17dCM0zMw==} @@ -4740,8 +4801,7 @@ packages: dev: false /sprintf-js/1.0.3: - resolution: {integrity: sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=} - dev: true + resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} /sshpk/1.17.0: resolution: {integrity: sha512-/9HIEs1ZXGhSPE8X6Ccm7Nam1z8KcoCqPdI7ecm1N33EzAetWahvQWVqLZtaZQ+IDKX4IyA2o0gBzqIMkAagHQ==} @@ -4836,6 +4896,11 @@ packages: ansi-regex: 5.0.1 dev: true + /strip-bom/3.0.0: + resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} + engines: {node: '>=4'} + dev: false + /strip-bom/4.0.0: resolution: {integrity: sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==} engines: {node: '>=8'} @@ -4967,7 +5032,6 @@ packages: engines: {node: '>=8.0'} dependencies: is-number: 7.0.0 - dev: true /toidentifier/1.0.1: resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} @@ -5126,7 +5190,6 @@ packages: /universalify/0.1.2: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} engines: {node: '>= 4.0.0'} - dev: true /unix-crypt-td-js/1.1.4: resolution: {integrity: sha512-8rMeVYWSIyccIJscb9NdCfZKSRBKYTeVnwmiRYT2ulE3qd1RaDQ0xQDP+rI3ccIWbhu/zuo5cgN8z73belNZgw==} diff --git a/src/npm/v1/index.ts b/src/npm/v1/index.ts index 95e41a2..9f2fe21 100644 --- a/src/npm/v1/index.ts +++ b/src/npm/v1/index.ts @@ -9,7 +9,6 @@ import { parse as parseDepPath } from 'dependency-path'; import type { Dependencies, Dependency, PackageLock } from './types'; import { parseLockfile } from '../../pnpm'; - export async function convert(lockfileDir: string): Promise { const lock = await parseLockfile(lockfileDir); diff --git a/src/pnpm/index.ts b/src/pnpm/index.ts index d84ded2..fe2e893 100644 --- a/src/pnpm/index.ts +++ b/src/pnpm/index.ts @@ -1,5 +1,14 @@ -import { Lockfile, readWantedLockfile } from '@pnpm/lockfile-file'; +import { + getLockfileImporterId, + Lockfile, + ProjectSnapshot, + readWantedLockfile, + writeWantedLockfile, +} from '@pnpm/lockfile-file'; import { parse as parseDepPath } from 'dependency-path'; +import { DEPENDENCIES_FIELDS } from '@pnpm/types'; +import { pruneSharedLockfile } from '@pnpm/prune-lockfile'; +import { getPackages } from '@manypkg/get-packages'; const LATEST_SUPPORTED_PNPM_LOCK_VERSION = 5.4; @@ -30,3 +39,47 @@ export function depPathFromDependency([name, version]: [string, string]): Return return parseDepPath(`/${name}/${version}`); } } + +export async function workspaceProjectPaths(lockfileDir: string): Promise> { + return new Set( + await getPackages(lockfileDir).then(({ root, packages }) => { + return packages.map(({ dir }) => dir).filter((pkg) => pkg !== root.dir); + }) + ); +} + +// From https://github.com/pnpm/pnpm/blob/main/packages/make-dedicated-lockfile/src/index.ts +export async function makeDedicatedLockfile(lockfileDir: string, projectDir: string): Promise { + const lockfile = await parseLockfile(lockfileDir); + + const allImporters = lockfile.importers; + lockfile.importers = {}; + const baseImporterId = getLockfileImporterId(lockfileDir, projectDir); + for (const [importerId, importer] of Object.entries(allImporters)) { + if (importerId.startsWith(`${baseImporterId}/`)) { + const newImporterId = importerId.slice(baseImporterId.length + 1); + lockfile.importers[newImporterId] = projectSnapshotWithoutLinkedDeps(importer); + continue; + } + if (importerId === baseImporterId) { + lockfile.importers['.'] = projectSnapshotWithoutLinkedDeps(importer); + } + } + const dedicatedLockfile = pruneSharedLockfile(lockfile); + + await writeWantedLockfile(projectDir, dedicatedLockfile); +} + +// From https://github.com/pnpm/pnpm/blob/main/packages/make-dedicated-lockfile/src/index.ts +function projectSnapshotWithoutLinkedDeps(projectSnapshot: ProjectSnapshot) { + const newProjectSnapshot: ProjectSnapshot = { + specifiers: projectSnapshot.specifiers, + }; + for (const depField of DEPENDENCIES_FIELDS) { + if (projectSnapshot[depField] == null) continue; + newProjectSnapshot[depField] = Object.fromEntries( + Object.entries(projectSnapshot[depField] ?? {}).filter((entry) => !entry[1].startsWith('link:')) + ); + } + return newProjectSnapshot; +} diff --git a/src/yarn/v1/index.ts b/src/yarn/v1/index.ts index 2c90f26..a605576 100644 --- a/src/yarn/v1/index.ts +++ b/src/yarn/v1/index.ts @@ -5,7 +5,7 @@ import type { TarballResolution } from '@pnpm/lockfile-types'; import { nameVerFromPkgSnapshot, pkgSnapshotToResolution } from '@pnpm/lockfile-utils'; import type { Package, YarnLock } from './types'; -import { depPathFromDependency, parseLockfile } from '../../pnpm'; +import { depPathFromDependency, makeDedicatedLockfile, parseLockfile, workspaceProjectPaths } from '../../pnpm'; export async function convert(lockfileDir: string): Promise { const lock = await parseLockfile(lockfileDir); @@ -67,3 +67,17 @@ export async function write(lockfileDir: string): Promise { .then(serialize) .then((lock) => writeFile(path.join(lockfileDir, 'yarn.lock'), lock)); } + +export async function writeRecursive(lockfileDir: string): Promise { + const packages = await workspaceProjectPaths(lockfileDir); + + // Make and convert lockfiles for workspace packages, + // and dedicated lockfiles for all workspace packages + await Promise.all([ + write(lockfileDir), + ...Array.from(packages).map(async (pkgDir) => { + await makeDedicatedLockfile(lockfileDir, pkgDir); + await write(pkgDir); + }), + ]); +}