mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-01 10:42:28 -05:00
fix: catalogs exception when running pnpm outdated with --compatible flag (#8825)
close #8566
This commit is contained in:
6
.changeset/weak-peaches-sip.md
Normal file
6
.changeset/weak-peaches-sip.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/outdated": patch
|
||||
pnpm: patch
|
||||
---
|
||||
|
||||
Fix an exception when running `pnpm update --interactive` if catalogs are used.
|
||||
2
__fixtures__/has-outdated-deps-using-npm-alias/.gitignore
vendored
Normal file
2
__fixtures__/has-outdated-deps-using-npm-alias/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
!**/node_modules/**/*
|
||||
!/node_modules/
|
||||
1
__fixtures__/has-outdated-deps-using-npm-alias/.npmrc
Normal file
1
__fixtures__/has-outdated-deps-using-npm-alias/.npmrc
Normal file
@@ -0,0 +1 @@
|
||||
shared-workspace-lockfile=false
|
||||
22
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.modules.yaml
generated
vendored
Normal file
22
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.modules.yaml
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
hoistPattern:
|
||||
- '*'
|
||||
hoistedDependencies: {}
|
||||
included:
|
||||
dependencies: true
|
||||
devDependencies: true
|
||||
optionalDependencies: true
|
||||
injectedDeps: {}
|
||||
layoutVersion: 5
|
||||
nodeLinker: isolated
|
||||
packageManager: pnpm@9.9.0
|
||||
pendingBuilds: []
|
||||
prunedAt: Sun, 01 Dec 2024 19:56:24 GMT
|
||||
publicHoistPattern:
|
||||
- '*eslint*'
|
||||
- '*prettier*'
|
||||
registries:
|
||||
default: https://registry.npmjs.org/
|
||||
skipped: []
|
||||
storeDir: /Users/gluxon/Library/pnpm/store/v3
|
||||
virtualStoreDir: .pnpm
|
||||
virtualStoreDirMaxLength: 120
|
||||
9
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.pnpm/is-negative@1.0.0/node_modules/is-negative/index.js
generated
vendored
Normal file
9
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.pnpm/is-negative@1.0.0/node_modules/is-negative/index.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function (n) {
|
||||
if (typeof n !== 'number') {
|
||||
throw new TypeError('Expected a number');
|
||||
}
|
||||
|
||||
return n < 0;
|
||||
};
|
||||
21
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.pnpm/is-negative@1.0.0/node_modules/is-negative/license
generated
vendored
Normal file
21
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.pnpm/is-negative@1.0.0/node_modules/is-negative/license
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) Kevin Martensson <kevinmartensson@gmail.com> (github.com/kevva)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
29
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.pnpm/is-negative@1.0.0/node_modules/is-negative/package.json
generated
vendored
Normal file
29
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.pnpm/is-negative@1.0.0/node_modules/is-negative/package.json
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "is-negative",
|
||||
"version": "1.0.0",
|
||||
"description": "Test if a number is negative",
|
||||
"license": "MIT",
|
||||
"repository": "kevva/is-negative",
|
||||
"author": {
|
||||
"name": "Kevin Martensson",
|
||||
"email": "kevinmartensson@gmail.com",
|
||||
"url": "github.com/kevva"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"negative",
|
||||
"number",
|
||||
"test"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^0.0.4"
|
||||
}
|
||||
}
|
||||
31
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.pnpm/is-negative@1.0.0/node_modules/is-negative/readme.md
generated
vendored
Normal file
31
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.pnpm/is-negative@1.0.0/node_modules/is-negative/readme.md
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# is-negative [](https://travis-ci.org/kevva/is-negative)
|
||||
|
||||
> Test if a number is positive
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save is-negative
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var isNegative = require('is-negative');
|
||||
|
||||
isNegative(-1);
|
||||
//=> true
|
||||
|
||||
isNegative(1);
|
||||
//=> false
|
||||
|
||||
isNegative(0);
|
||||
//=> false
|
||||
```
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Kevin Martensson](http://github.com/kevva)
|
||||
23
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.pnpm/lock.yaml
generated
vendored
Normal file
23
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/.pnpm/lock.yaml
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
is-negative-alias:
|
||||
specifier: npm:is-negative@^1.0.0
|
||||
version: is-negative@1.0.0
|
||||
|
||||
packages:
|
||||
|
||||
is-negative@1.0.0:
|
||||
resolution: {integrity: sha512-1aKMsFUc7vYQGzt//8zhkjRWPoYkajY/I5MJEvrc0pDoHXrW7n5ri8DYxhy3rR+Dk0QFl7GjHHsZU1sppQrWtw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
snapshots:
|
||||
|
||||
is-negative@1.0.0: {}
|
||||
1
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/is-negative-alias
generated
vendored
Symbolic link
1
__fixtures__/has-outdated-deps-using-npm-alias/node_modules/is-negative-alias
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
.pnpm/is-negative@1.0.0/node_modules/is-negative
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"is-negative-alias": "npm:is-negative@^1.0.0"
|
||||
}
|
||||
}
|
||||
23
__fixtures__/has-outdated-deps-using-npm-alias/pnpm-lock.yaml
generated
Normal file
23
__fixtures__/has-outdated-deps-using-npm-alias/pnpm-lock.yaml
generated
Normal file
@@ -0,0 +1,23 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
is-negative-alias:
|
||||
specifier: npm:is-negative@^1.0.0
|
||||
version: is-negative@1.0.0
|
||||
|
||||
packages:
|
||||
|
||||
is-negative@1.0.0:
|
||||
resolution: {integrity: sha512-1aKMsFUc7vYQGzt//8zhkjRWPoYkajY/I5MJEvrc0pDoHXrW7n5ri8DYxhy3rR+Dk0QFl7GjHHsZU1sppQrWtw==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
snapshots:
|
||||
|
||||
is-negative@1.0.0: {}
|
||||
@@ -155,7 +155,7 @@ export async function outdated (
|
||||
|
||||
const latestManifest = await opts.getLatestManifest(
|
||||
name,
|
||||
opts.compatible ? (allDeps[name] ?? 'latest') : 'latest'
|
||||
opts.compatible ? (pref ?? 'latest') : 'latest'
|
||||
)
|
||||
|
||||
if (latestManifest == null) return
|
||||
|
||||
@@ -18,6 +18,7 @@ const hasMajorOutdatedDepsFixture = f.find('has-major-outdated-deps')
|
||||
const hasNoLockfileFixture = f.find('has-no-lockfile')
|
||||
const withPnpmUpdateIgnore = f.find('with-pnpm-update-ignore')
|
||||
const hasOutdatedDepsUsingCatalogProtocol = f.find('has-outdated-deps-using-catalog-protocol')
|
||||
const hasOutdatedDepsUsingNpmAlias = f.find('has-outdated-deps-using-npm-alias')
|
||||
|
||||
const REGISTRY_URL = `http://localhost:${REGISTRY_MOCK_PORT}`
|
||||
|
||||
@@ -409,6 +410,25 @@ test('pnpm outdated: catalog protocol', async () => {
|
||||
`)
|
||||
})
|
||||
|
||||
test('pnpm outdated: --compatible works with npm aliases', async () => {
|
||||
const { output, exitCode } = await outdated.handler({
|
||||
...OUTDATED_OPTIONS,
|
||||
compatible: true,
|
||||
dir: hasOutdatedDepsUsingNpmAlias,
|
||||
})
|
||||
|
||||
// Although is-negative@2.1.0 is the latest version at the time of writing,
|
||||
// the "compatible: true" option above should make pnpm to only find 1.0.1.
|
||||
expect(exitCode).toBe(1)
|
||||
expect(stripAnsi(output)).toBe(`\
|
||||
┌─────────────┬─────────┬────────┐
|
||||
│ Package │ Current │ Latest │
|
||||
├─────────────┼─────────┼────────┤
|
||||
│ is-negative │ 1.0.0 │ 1.0.1 │
|
||||
└─────────────┴─────────┴────────┘
|
||||
`)
|
||||
})
|
||||
|
||||
test('pnpm outdated: support --sortField option', async () => {
|
||||
tempDir()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user