-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22554 from storybookjs/fix/reduce-package-install…
…-noise CLI: Reduce installation noise and improve error handling
- Loading branch information
Showing
16 changed files
with
556 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,15 @@ | ||
import { NPMProxy } from './NPMProxy'; | ||
|
||
// mock createLogStream | ||
jest.mock('../utils', () => ({ | ||
createLogStream: jest.fn(() => ({ | ||
logStream: '', | ||
readLogFile: jest.fn(), | ||
moveLogFile: jest.fn(), | ||
removeLogFile: jest.fn(), | ||
})), | ||
})); | ||
|
||
describe('NPM Proxy', () => { | ||
let npmProxy: NPMProxy; | ||
|
||
|
@@ -426,4 +436,50 @@ describe('NPM Proxy', () => { | |
`); | ||
}); | ||
}); | ||
|
||
describe('parseErrors', () => { | ||
it('should parse npm errors', () => { | ||
const NPM_ERROR_SAMPLE = ` | ||
npm ERR! code ERESOLVE | ||
npm ERR! ERESOLVE unable to resolve dependency tree | ||
npm ERR! | ||
npm ERR! While resolving: [email protected] | ||
npm ERR! Found: react@undefined | ||
npm ERR! node_modules/react | ||
npm ERR! react@"30" from the root project | ||
npm ERR! | ||
npm ERR! Could not resolve dependency: | ||
npm ERR! peer react@"^16.8.0 || ^17.0.0 || ^18.0.0" from @storybook/[email protected] | ||
npm ERR! node_modules/@storybook/react | ||
npm ERR! dev @storybook/react@"^7.1.0-alpha.17" from the root project | ||
npm ERR! | ||
npm ERR! Fix the upstream dependency conflict, or retry | ||
npm ERR! this command with --force or --legacy-peer-deps | ||
npm ERR! to accept an incorrect (and potentially broken) dependency resolution. | ||
npm ERR! | ||
npm ERR! | ||
npm ERR! For a full report see: | ||
npm ERR! /Users/yannbraga/.npm/_logs/2023-05-12T08_38_18_464Z-eresolve-report.txt | ||
npm ERR! A complete log of this run can be found in: | ||
npm ERR! /Users/yannbraga/.npm/_logs/2023-05-12T08_38_18_464Z-debug-0.log | ||
`; | ||
|
||
expect(npmProxy.parseErrorFromLogs(NPM_ERROR_SAMPLE)).toEqual( | ||
'NPM error ERESOLVE - Dependency resolution error.' | ||
); | ||
}); | ||
|
||
it('should show unknown npm error', () => { | ||
const NPM_ERROR_SAMPLE = ` | ||
npm ERR! | ||
npm ERR! While resolving: [email protected] | ||
npm ERR! Found: react@undefined | ||
npm ERR! node_modules/react | ||
npm ERR! react@"30" from the root project | ||
`; | ||
|
||
expect(npmProxy.parseErrorFromLogs(NPM_ERROR_SAMPLE)).toEqual(`NPM error`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -375,4 +375,30 @@ describe('NPM Proxy', () => { | |
`); | ||
}); | ||
}); | ||
|
||
describe('parseErrors', () => { | ||
it('should parse pnpm errors', () => { | ||
const PNPM_ERROR_SAMPLE = ` | ||
ERR_PNPM_NO_MATCHING_VERSION No matching version found for [email protected] | ||
This error happened while installing a direct dependency of /Users/yannbraga/open-source/sandboxes/react-vite/default-js/before-storybook | ||
The latest release of react is "18.2.0". | ||
`; | ||
|
||
expect(pnpmProxy.parseErrorFromLogs(PNPM_ERROR_SAMPLE)).toEqual( | ||
'PNPM error ERR_PNPM_NO_MATCHING_VERSION No matching version found for [email protected]' | ||
); | ||
}); | ||
|
||
it('should show unknown pnpm error', () => { | ||
const PNPM_ERROR_SAMPLE = ` | ||
This error happened while installing a direct dependency of /Users/yannbraga/open-source/sandboxes/react-vite/default-js/before-storybook | ||
The latest release of react is "18.2.0". | ||
`; | ||
|
||
expect(pnpmProxy.parseErrorFromLogs(PNPM_ERROR_SAMPLE)).toEqual(`PNPM error`); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.