diff --git a/fixtures/pnpm/multi-lockfile/.npmrc b/fixtures/pnpm/multi-lockfile/.npmrc new file mode 100644 index 0000000..e94a5d2 --- /dev/null +++ b/fixtures/pnpm/multi-lockfile/.npmrc @@ -0,0 +1,13 @@ +# npm / pnpm settings here + +# as a library, we want to make sure we explicitly handle peers, +# and not rely on hidden behavior of package-managers. +auto-install-peers=false + +# we never want to use packages from the registry over what's in the workspace +prefer-workspaces-packages=true + +# default is true, we do this to try to have more isolation +# since we test with incompatible sets of TS types. +shared-workspace-lockfile=false + diff --git a/fixtures/pnpm/multi-lockfile/package.json b/fixtures/pnpm/multi-lockfile/package.json new file mode 100644 index 0000000..352055c --- /dev/null +++ b/fixtures/pnpm/multi-lockfile/package.json @@ -0,0 +1,3 @@ +{ + "private": true +} diff --git a/fixtures/pnpm/multi-lockfile/packages/a/package.json b/fixtures/pnpm/multi-lockfile/packages/a/package.json new file mode 100644 index 0000000..2330fc5 --- /dev/null +++ b/fixtures/pnpm/multi-lockfile/packages/a/package.json @@ -0,0 +1,4 @@ +{ + "name": "a", + "version": "0.0.1" +} diff --git a/fixtures/pnpm/multi-lockfile/packages/b/package.json b/fixtures/pnpm/multi-lockfile/packages/b/package.json new file mode 100644 index 0000000..3a2f015 --- /dev/null +++ b/fixtures/pnpm/multi-lockfile/packages/b/package.json @@ -0,0 +1,4 @@ +{ + "name": "b", + "version": "0.0.1" +} diff --git a/fixtures/pnpm/multi-lockfile/packages/c/package.json b/fixtures/pnpm/multi-lockfile/packages/c/package.json new file mode 100644 index 0000000..8681fed --- /dev/null +++ b/fixtures/pnpm/multi-lockfile/packages/c/package.json @@ -0,0 +1,5 @@ +{ + "name": "c", + "version": "0.0.1" +} + diff --git a/fixtures/pnpm/multi-lockfile/pnpm-workspace.yaml b/fixtures/pnpm/multi-lockfile/pnpm-workspace.yaml new file mode 100644 index 0000000..a084e41 --- /dev/null +++ b/fixtures/pnpm/multi-lockfile/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - './packages/*' diff --git a/fixtures/pnpm/single-package/package.json b/fixtures/pnpm/single-package/package.json new file mode 100644 index 0000000..cd5da30 --- /dev/null +++ b/fixtures/pnpm/single-package/package.json @@ -0,0 +1,4 @@ +{ + "name": "foo-package", + "version": "0.0.1" +} diff --git a/fixtures/pnpm/single-package/pnpm-workspace.yaml b/fixtures/pnpm/single-package/pnpm-workspace.yaml new file mode 100644 index 0000000..4de91a3 --- /dev/null +++ b/fixtures/pnpm/single-package/pnpm-workspace.yaml @@ -0,0 +1,2 @@ +packages: + - '.' diff --git a/package.json b/package.json index 9f82e61..9a19fd5 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "test": "vitest" }, "dependencies": { - "@ef4/lerna-changelog": "^2.0.0", + "@ef4/lerna-changelog": "^2.1.0", + "@manypkg/get-packages": "^2.2.0", "@npmcli/package-json": "^5.0.0", "@octokit/rest": "^19.0.8", "@types/fs-extra": "^9.0.12", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 61040e4..e13d580 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,93 +4,98 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false -dependencies: - '@ef4/lerna-changelog': - specifier: ^2.0.0 - version: 2.0.0 - '@npmcli/package-json': - specifier: ^5.0.0 - version: 5.0.0 - '@octokit/rest': - specifier: ^19.0.8 - version: 19.0.13 - '@types/fs-extra': - specifier: ^9.0.12 - version: 9.0.13 - '@types/js-yaml': - specifier: ^4.0.5 - version: 4.0.9 - '@types/semver': - specifier: ^7.3.6 - version: 7.5.5 - '@types/yargs': - specifier: ^17.0.3 - version: 17.0.31 - assert-never: - specifier: ^1.2.1 - version: 1.2.1 - chalk: - specifier: ^4.1.1 - version: 4.1.2 - cli-highlight: - specifier: ^2.1.11 - version: 2.1.11 - execa: - specifier: ^4.0.3 - version: 4.1.0 - fs-extra: - specifier: ^10.0.0 - version: 10.1.0 - js-yaml: - specifier: ^4.1.0 - version: 4.1.0 - latest-version: - specifier: ^5.0.0 - version: 5.1.0 - parse-github-repo-url: - specifier: ^1.4.1 - version: 1.4.1 - semver: - specifier: ^7.3.5 - version: 7.5.4 - yargs: - specifier: ^17.0.1 - version: 17.7.2 - -devDependencies: - '@types/npmcli__package-json': - specifier: ^4.0.3 - version: 4.0.3 - '@types/parse-github-repo-url': - specifier: ^1.4.2 - version: 1.4.2 - '@typescript-eslint/eslint-plugin': - specifier: ^6.13.2 - version: 6.13.2(@typescript-eslint/parser@6.13.2)(eslint@8.55.0)(typescript@5.2.2) - '@typescript-eslint/parser': - specifier: ^6.13.2 - version: 6.13.2(eslint@8.55.0)(typescript@5.2.2) - eslint: - specifier: ^8.55.0 - version: 8.55.0 - eslint-config-prettier: - specifier: ^9.1.0 - version: 9.1.0(eslint@8.55.0) - eslint-plugin-n: - specifier: ^16.3.1 - version: 16.3.1(eslint@8.55.0) - eslint-plugin-prettier: - specifier: ^5.0.1 - version: 5.0.1(eslint-config-prettier@9.1.0)(eslint@8.55.0)(prettier@3.1.0) - prettier: - specifier: ^3.1.0 - version: 3.1.0 - typescript: - specifier: ^5.2.2 - version: 5.2.2 - vitest: - specifier: ^1.0.1 - version: 1.0.1 +importers: + + .: + dependencies: + '@ef4/lerna-changelog': + specifier: ^2.1.0 + version: 2.1.0 + '@manypkg/get-packages': + specifier: ^2.2.0 + version: 2.2.0 + '@npmcli/package-json': + specifier: ^5.0.0 + version: 5.0.0 + '@octokit/rest': + specifier: ^19.0.8 + version: 19.0.13 + '@types/fs-extra': + specifier: ^9.0.12 + version: 9.0.13 + '@types/js-yaml': + specifier: ^4.0.5 + version: 4.0.9 + '@types/semver': + specifier: ^7.3.6 + version: 7.5.5 + '@types/yargs': + specifier: ^17.0.3 + version: 17.0.31 + assert-never: + specifier: ^1.2.1 + version: 1.2.1 + chalk: + specifier: ^4.1.1 + version: 4.1.2 + cli-highlight: + specifier: ^2.1.11 + version: 2.1.11 + execa: + specifier: ^4.0.3 + version: 4.1.0 + fs-extra: + specifier: ^10.0.0 + version: 10.1.0 + js-yaml: + specifier: ^4.1.0 + version: 4.1.0 + latest-version: + specifier: ^5.0.0 + version: 5.1.0 + parse-github-repo-url: + specifier: ^1.4.1 + version: 1.4.1 + semver: + specifier: ^7.3.5 + version: 7.5.4 + yargs: + specifier: ^17.0.1 + version: 17.7.2 + devDependencies: + '@types/npmcli__package-json': + specifier: ^4.0.3 + version: 4.0.3 + '@types/parse-github-repo-url': + specifier: ^1.4.2 + version: 1.4.2 + '@typescript-eslint/eslint-plugin': + specifier: ^6.13.2 + version: 6.13.2(@typescript-eslint/parser@6.13.2)(eslint@8.55.0)(typescript@5.2.2) + '@typescript-eslint/parser': + specifier: ^6.13.2 + version: 6.13.2(eslint@8.55.0)(typescript@5.2.2) + eslint: + specifier: ^8.55.0 + version: 8.55.0 + eslint-config-prettier: + specifier: ^9.1.0 + version: 9.1.0(eslint@8.55.0) + eslint-plugin-n: + specifier: ^16.3.1 + version: 16.3.1(eslint@8.55.0) + eslint-plugin-prettier: + specifier: ^5.0.1 + version: 5.0.1(eslint-config-prettier@9.1.0)(eslint@8.55.0)(prettier@3.1.0) + prettier: + specifier: ^3.1.0 + version: 3.1.0 + typescript: + specifier: ^5.2.2 + version: 5.2.2 + vitest: + specifier: ^1.0.1 + version: 1.0.1 packages: @@ -99,11 +104,12 @@ packages: engines: {node: '>=0.10.0'} dev: true - /@ef4/lerna-changelog@2.0.0: - resolution: {integrity: sha512-dCT3wMC501ZQqFwroxuDrktSm8tgrmMO67S7hRbJqRbbUarkYd0KVZPyW+O569lVBdEVTGTWWMNmPgGrD9IQjA==} + /@ef4/lerna-changelog@2.1.0: + resolution: {integrity: sha512-c6301SsWdOBrTGEkQmDTK5dDJUX2+03kN6UYZhewkqih3vy3HZxp1G1eJPVPd5EQpaLRptxFsMtgDcsabPZmRg==} engines: {node: 12.* || 14.* || >= 16} hasBin: true dependencies: + '@manypkg/get-packages': 2.2.0 chalk: 4.1.2 cli-highlight: 2.1.11 execa: 5.1.1 @@ -399,18 +405,43 @@ packages: resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} dev: true + /@manypkg/find-root@2.2.1: + resolution: {integrity: sha512-34NlypD5mmTY65cFAK7QPgY5Tzt0qXR4ZRXdg97xAlkiLuwXUPBEXy5Hsqzd+7S2acsLxUz6Cs50rlDZQr4xUA==} + engines: {node: '>=14.18.0'} + dependencies: + '@manypkg/tools': 1.1.0 + find-up: 4.1.0 + fs-extra: 8.1.0 + dev: false + + /@manypkg/get-packages@2.2.0: + resolution: {integrity: sha512-B5p5BXMwhGZKi/syEEAP1eVg5DZ/9LP+MZr0HqfrHLgu9fq0w4ZwH8yVen4JmjrxI2dWS31dcoswYzuphLaRxg==} + engines: {node: '>=14.18.0'} + dependencies: + '@manypkg/find-root': 2.2.1 + '@manypkg/tools': 1.1.0 + dev: false + + /@manypkg/tools@1.1.0: + resolution: {integrity: sha512-SkAyKAByB9l93Slyg8AUHGuM2kjvWioUTCckT/03J09jYnfEzMO/wSXmEhnKGYs6qx9De8TH4yJCl0Y9lRgnyQ==} + engines: {node: '>=14.18.0'} + dependencies: + fs-extra: 8.1.0 + globby: 11.1.0 + jju: 1.4.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==} @@ -418,7 +449,6 @@ packages: dependencies: '@nodelib/fs.scandir': 2.1.5 fastq: 1.15.0 - dev: true /@npmcli/fs@1.1.1: resolution: {integrity: sha512-8KG5RD0GVP4ydEzRn/I4BNDuxDtqVbOdm8675T49OIG/NGhaK0pjPX7ZcDlvKYbA+ulvVK3ztfcF4uBdOxuJbQ==} @@ -1041,13 +1071,18 @@ packages: resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} dev: false + /argparse@1.0.10: + resolution: {integrity: sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==} + dependencies: + sprintf-js: 1.0.3 + dev: false + /argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} /array-union@2.1.0: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} engines: {node: '>=8'} - dev: true /assert-never@1.2.1: resolution: {integrity: sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw==} @@ -1093,7 +1128,6 @@ packages: engines: {node: '>=8'} dependencies: fill-range: 7.0.1 - dev: true /builtin-modules@3.3.0: resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} @@ -1328,7 +1362,6 @@ packages: engines: {node: '>=8'} dependencies: path-type: 4.0.0 - dev: true /doctrine@3.0.0: resolution: {integrity: sha512-yS+Q5i3hBf7GBkd4KG8a7eBNNWNGLTaEwwYWUijIYM7zrlYDM0BFXHjjPWlWZ1Rg7UaddZeIDmi9jF3HmqiQ2w==} @@ -1550,6 +1583,12 @@ packages: eslint-visitor-keys: 3.4.3 dev: true + /esprima@4.0.1: + resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==} + engines: {node: '>=4'} + hasBin: true + dev: false + /esquery@1.5.0: resolution: {integrity: sha512-YQLXUplAwJgCydQ78IMJywZCceoqk1oH01OERdSAJc/7U2AylwjhSCLDEtqwg811idIS/9fIU5GjG73IgjKMVg==} engines: {node: '>=0.10'} @@ -1650,7 +1689,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==} @@ -1664,7 +1702,6 @@ packages: resolution: {integrity: sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==} dependencies: reusify: 1.0.4 - dev: true /file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} @@ -1678,7 +1715,14 @@ packages: engines: {node: '>=8'} dependencies: to-regex-range: 5.0.1 - dev: true + + /find-up@4.1.0: + resolution: {integrity: sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==} + engines: {node: '>=8'} + dependencies: + locate-path: 5.0.0 + path-exists: 4.0.0 + dev: false /find-up@5.0.0: resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} @@ -1718,6 +1762,15 @@ packages: universalify: 2.0.1 dev: false + /fs-extra@8.1.0: + resolution: {integrity: sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==} + engines: {node: '>=6 <7 || >=8'} + dependencies: + graceful-fs: 4.2.11 + jsonfile: 4.0.0 + universalify: 0.1.2 + dev: false + /fs-minipass@2.1.0: resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} engines: {node: '>= 8'} @@ -1782,7 +1835,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==} @@ -1830,7 +1882,6 @@ packages: ignore: 5.3.0 merge2: 1.4.1 slash: 3.0.0 - dev: true /got@9.6.0: resolution: {integrity: sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q==} @@ -1949,7 +2000,6 @@ packages: /ignore@5.3.0: resolution: {integrity: sha512-g7dmpshy+gD7mh88OC9NwSGTKoc3kyLAZQRU1mt53Aw/vnvfXnbC+F/7F7QoYVKbV+KNvJx8wArewKy1vXMtlg==} engines: {node: '>= 4'} - dev: true /import-fresh@3.3.0: resolution: {integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==} @@ -2016,7 +2066,6 @@ packages: /is-extglob@2.1.1: resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} engines: {node: '>=0.10.0'} - dev: true /is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} @@ -2028,7 +2077,6 @@ packages: engines: {node: '>=0.10.0'} dependencies: is-extglob: 2.1.1 - dev: true /is-inside-container@1.0.0: resolution: {integrity: sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==} @@ -2045,7 +2093,6 @@ packages: /is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} - dev: true /is-path-inside@3.0.3: resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} @@ -2090,6 +2137,18 @@ packages: '@pkgjs/parseargs': 0.11.0 dev: false + /jju@1.4.0: + resolution: {integrity: sha512-8wb9Yw966OSxApiCt0K3yNJL8pnNeIv+OEq2YMidz4FKP6nonSRoOXc80iXY4JaN2FC11B9qsNmDsm+ZOfMROA==} + dev: false + + /js-yaml@3.14.1: + resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} + hasBin: true + dependencies: + argparse: 1.0.10 + esprima: 4.0.1 + dev: false + /js-yaml@4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} hasBin: true @@ -2121,6 +2180,12 @@ packages: resolution: {integrity: sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==} dev: true + /jsonfile@4.0.0: + resolution: {integrity: sha512-m6F1R3z8jjlf2imQHS2Qez5sjKWQzbuuhuJ/FKYFRZvPE3PuHcSMVZzfsLhGVOkfd20obL5SWEBew5ShlquNxg==} + optionalDependencies: + graceful-fs: 4.2.11 + dev: false + /jsonfile@6.1.0: resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==} dependencies: @@ -2164,6 +2229,13 @@ packages: pkg-types: 1.0.3 dev: true + /locate-path@5.0.0: + resolution: {integrity: sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==} + engines: {node: '>=8'} + dependencies: + p-locate: 4.1.0 + dev: false + /locate-path@6.0.0: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} @@ -2240,7 +2312,6 @@ packages: /merge2@1.4.1: resolution: {integrity: sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==} engines: {node: '>= 8'} - dev: true /micromatch@4.0.5: resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==} @@ -2248,7 +2319,6 @@ packages: dependencies: braces: 3.0.2 picomatch: 2.3.1 - dev: true /mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} @@ -2511,6 +2581,13 @@ packages: engines: {node: '>=6'} dev: false + /p-limit@2.3.0: + resolution: {integrity: sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==} + engines: {node: '>=6'} + dependencies: + p-try: 2.2.0 + dev: false + /p-limit@3.1.0: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} engines: {node: '>=10'} @@ -2525,6 +2602,13 @@ packages: yocto-queue: 1.0.0 dev: true + /p-locate@4.1.0: + resolution: {integrity: sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==} + engines: {node: '>=8'} + dependencies: + p-limit: 2.3.0 + dev: false + /p-locate@5.0.0: resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} engines: {node: '>=10'} @@ -2546,6 +2630,11 @@ packages: aggregate-error: 3.1.0 dev: false + /p-try@2.2.0: + resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} + engines: {node: '>=6'} + dev: false + /package-json@6.5.0: resolution: {integrity: sha512-k3bdm2n25tkyxcjSKzB5x8kfVxlMdgsbPr0GkZcwHsLpba6cBjqCt1KlcChKEvxHIcTB1FVMuwoijZ26xex5MQ==} engines: {node: '>=8'} @@ -2584,7 +2673,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: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} @@ -2614,7 +2702,6 @@ packages: /path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} - dev: true /pathe@1.1.1: resolution: {integrity: sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==} @@ -2631,7 +2718,11 @@ packages: /picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - dev: true + + /pify@4.0.1: + resolution: {integrity: sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==} + engines: {node: '>=6'} + dev: false /pkg-types@1.0.3: resolution: {integrity: sha512-nN7pYi0AQqJnoLPC9eHFQ8AcyaixBUOwvqc5TDnIKCMEE6I0y8P7OKA7fPexsXGCGxQDl/cmrLAp26LhcwxZ4A==} @@ -2723,7 +2814,6 @@ packages: /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} - dev: true /rc@1.2.8: resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} @@ -2739,6 +2829,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.11 + js-yaml: 3.14.1 + pify: 4.0.1 + strip-bom: 3.0.0 + dev: false + /registry-auth-token@4.2.2: resolution: {integrity: sha512-PC5ZysNb42zpFME6D/XlIgtNGdTl8bBOCw90xQLVMpzuuubJKYDWFAEuUNc+Cn8Z8724tg2SDhDRrkVEsqfDMg==} engines: {node: '>=6.0.0'} @@ -2790,7 +2890,6 @@ packages: /reusify@1.0.4: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - dev: true /rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} @@ -2829,7 +2928,6 @@ packages: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: queue-microtask: 1.2.3 - dev: true /safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} @@ -2873,7 +2971,6 @@ packages: /slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} - dev: true /smart-buffer@4.2.0: resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==} @@ -2926,6 +3023,10 @@ packages: resolution: {integrity: sha512-eWN+LnM3GR6gPu35WxNgbGl8rmY1AEmoMDvL/QD6zYmPWgywxWqJWNdLGT+ke8dKNWrcYgYjPpG5gbTfghP8rw==} dev: false + /sprintf-js@1.0.3: + resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} + dev: false + /ssri@8.0.1: resolution: {integrity: sha512-97qShzy1AiyxvPNIkLWoGua7xoQzzPjQ0HAH4B0rWKo7SZ6USuPcrUiAFrws0UH8RrbWmgq3LMTObhPIHbbBeQ==} engines: {node: '>= 8'} @@ -2972,6 +3073,11 @@ packages: ansi-regex: 6.0.1 dev: false + /strip-bom@3.0.0: + resolution: {integrity: sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==} + engines: {node: '>=4'} + dev: false + /strip-final-newline@2.0.0: resolution: {integrity: sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==} engines: {node: '>=6'} @@ -3074,7 +3180,6 @@ packages: engines: {node: '>=8.0'} dependencies: is-number: 7.0.0 - dev: true /tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} @@ -3140,6 +3245,11 @@ packages: resolution: {integrity: sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==} dev: false + /universalify@0.1.2: + resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} + engines: {node: '>= 4.0.0'} + dev: false + /universalify@2.0.1: resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} engines: {node: '>= 10.0.0'} diff --git a/src/interdep.test.ts b/src/interdep.test.ts index 3dfc74c..a30a6cb 100644 --- a/src/interdep.test.ts +++ b/src/interdep.test.ts @@ -54,5 +54,93 @@ describe('interdep', function () { `, ); }); + + describe('pnpm/fixtures/single-package', function () { + it('can load the workspaces', function () { + const answer = getPackages('./fixtures/pnpm/single-package'); + + expect(Array(...answer.keys())).toMatchInlineSnapshot(` + [ + "foo-package", + ] + `); + + expect(answer.get('foo-package')).toMatchInlineSnapshot( + { + pkg: expect.any(Object), + version: expect.any(String), + }, + ` + { + "isDependencyOf": Map {}, + "isPeerDependencyOf": Map {}, + "pkg": Any, + "pkgJSONPath": "./fixtures/pnpm/single-package/package.json", + "version": Any, + } + `, + ); + }); + }); + + describe('pnpm/fixtures/multi-lockfile', function () { + it('can load the workspaces', function () { + const answer = getPackages('./fixtures/pnpm/multi-lockfile'); + + expect(Array(...answer.keys())).toMatchInlineSnapshot(` + [ + "a", + "b", + "c", + ] + `); + + expect(answer.get('a')).toMatchInlineSnapshot( + { + pkg: expect.any(Object), + version: expect.any(String), + }, + ` + { + "isDependencyOf": Map {}, + "isPeerDependencyOf": Map {}, + "pkg": Any, + "pkgJSONPath": "./fixtures/pnpm/multi-lockfile/packages/a/package.json", + "version": Any, + } + `, + ); + expect(answer.get('b')).toMatchInlineSnapshot( + { + pkg: expect.any(Object), + version: expect.any(String), + }, + ` + { + "isDependencyOf": Map {}, + "isPeerDependencyOf": Map {}, + "pkg": Any, + "pkgJSONPath": "./fixtures/pnpm/multi-lockfile/packages/b/package.json", + "version": Any, + } + `, + ); + expect(answer.get('c')).toMatchInlineSnapshot( + { + pkg: expect.any(Object), + version: expect.any(String), + }, + ` + { + "isDependencyOf": Map {}, + "isPeerDependencyOf": Map {}, + "pkg": Any, + "pkgJSONPath": "./fixtures/pnpm/multi-lockfile/packages/c/package.json", + "version": Any, + } + `, + ); + }); + }); }); }); diff --git a/src/interdep.ts b/src/interdep.ts index 5513db3..699e203 100644 --- a/src/interdep.ts +++ b/src/interdep.ts @@ -1,8 +1,8 @@ -import { resolve, relative, join } from 'path'; +import { relative, join } from 'path'; import fsExtra from 'fs-extra'; -import execa from 'execa'; +import { getPackagesSync } from '@manypkg/get-packages'; -const { readJSONSync, existsSync } = fsExtra; +const { readJSONSync } = fsExtra; export type Range = `workspace:${string}`; export interface PkgEntry { @@ -31,26 +31,13 @@ export function getPackages(rootDir: string): Map { }); } - if (!existsSync(join(rootDir, './pnpm-workspace.yaml'))) { - const result = execa.sync('npm', ['query', '.workspace'], { cwd: rootDir }); - const resultParsed = JSON.parse(result.stdout); - const locations = resultParsed.map((i: any) => i.location); + const { packages: workspaces, rootPackage } = getPackagesSync(rootDir); - for (const location of locations) { - loadPackage(resolve(location, 'package.json')); - } - - loadPackage(join(rootDir, './package.json')); - } else { - const result = execa.sync(`pnpm`, ['m', 'ls', '--json', '--depth=-1'], { - cwd: rootDir, - }); - const workspaceJson = JSON.parse(result.stdout); - - workspaceJson - .filter((item: any) => item.name && item.path) - .forEach((item: any) => loadPackage(join(item.path, 'package.json'))); + workspaces.forEach((item) => loadPackage(join(item.dir, 'package.json'))); + if (rootPackage?.dir) { + loadPackage(join(rootPackage.dir, 'package.json')); } + return packages; }