Skip to content

Commit

Permalink
Merge pull request #28816 from storybookjs/yann/improve-yarn-errors
Browse files Browse the repository at this point in the history
CLI: Parse more Yarn Berry errors
  • Loading branch information
yannbf authored Aug 6, 2024
2 parents 9a3d6fc + 4ca1752 commit c0d3fdf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 36 deletions.
9 changes: 9 additions & 0 deletions code/core/src/common/js-package-manager/Yarn2Proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ describe('Yarn 2 Proxy', () => {
expect(yarn2Proxy.parseErrorFromLogs(YARN2_ERROR_SAMPLE)).toMatchInlineSnapshot(
`
"YARN2 error
YN0002: MISSING_PEER_DEPENDENCY
-> before-storybook@workspace:. doesn't provide @testing-library/dom (p1ac37), requested by @testing-library/user-event.
YN0002: MISSING_PEER_DEPENDENCY
-> before-storybook@workspace:. doesn't provide eslint (p1f657), requested by eslint-plugin-storybook.
YN0086: EXPLAIN_PEER_DEPENDENCIES_CTA
-> Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code.
YN0014: YARN_IMPORT_FAILED
-> Failed to import certain dependencies
Expand Down
59 changes: 23 additions & 36 deletions code/core/src/common/js-package-manager/Yarn2Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,73 +12,60 @@ import type { PackageJson } from './PackageJson';
import type { InstallationMetadata, PackageMetadata } from './types';
import { parsePackageData } from './util';

// more info at https://yarnpkg.com/advanced/error-codes
const CRITICAL_YARN2_ERROR_CODES = {
YN0001: 'EXCEPTION',
YN0009: 'BUILD_FAILED',
YN0010: 'RESOLVER_NOT_FOUND',
YN0011: 'FETCHER_NOT_FOUND',
YN0012: 'LINKER_NOT_FOUND',
YN0014: 'YARN_IMPORT_FAILED',
YN0015: 'REMOTE_INVALID',
YN0016: 'REMOTE_NOT_FOUND',
YN0020: 'MISSING_LOCKFILE_ENTRY',
YN0021: 'WORKSPACE_NOT_FOUND',
YN0028: 'FROZEN_LOCKFILE_EXCEPTION',
YN0030: 'FETCH_FAILED',
YN0046: 'AUTOMERGE_FAILED_TO_PARSE',
YN0062: 'INCOMPATIBLE_OS',
YN0063: 'INCOMPATIBLE_CPU',
YN0071: 'NM_CANT_INSTALL_EXTERNAL_SOFT_LINK',
YN0072: 'NM_PRESERVE_SYMLINKS_REQUIRED',
YN0075: 'PROLOG_INSTANTIATION_ERROR',
YN0076: 'INCOMPATIBLE_ARCHITECTURE',
YN0078: 'RESOLUTION_MISMATCH',
YN0081: 'NETWORK_UNSAFE_HTTP',
YN0082: 'RESOLUTION_FAILED',
YN0083: 'AUTOMERGE_GIT_ERROR',
};

// Keep the codes here, they might be helpful in the future
const YARN2_ERROR_CODES = {
...CRITICAL_YARN2_ERROR_CODES,
YN0000: 'UNNAMED',
YN0002: 'MISSING_PEER_DEPENDENCY',
YN0003: 'CYCLIC_DEPENDENCIES',
YN0004: 'DISABLED_BUILD_SCRIPTS',
YN0005: 'BUILD_DISABLED',
YN0006: 'SOFT_LINK_BUILD',
YN0007: 'MUST_BUILD',
YN0008: 'MUST_REBUILD',
YN0009: 'BUILD_FAILED',
YN0010: 'RESOLVER_NOT_FOUND',
YN0011: 'FETCHER_NOT_FOUND',
YN0012: 'LINKER_NOT_FOUND',
YN0013: 'FETCH_NOT_CACHED',
YN0017: 'RESOLUTION_PACK',
YN0014: 'YARN_IMPORT_FAILED',
YN0015: 'REMOTE_INVALID',
YN0016: 'REMOTE_NOT_FOUND',
YN0018: 'CACHE_CHECKSUM_MISMATCH',
YN0019: 'UNUSED_CACHE_ENTRY',
YN0020: 'MISSING_LOCKFILE_ENTRY',
YN0022: 'TOO_MANY_MATCHING_WORKSPACES',
YN0023: 'CONSTRAINTS_MISSING_DEPENDENCY',
YN0024: 'CONSTRAINTS_INCOMPATIBLE_DEPENDENCY',
YN0025: 'CONSTRAINTS_EXTRANEOUS_DEPENDENCY',
YN0026: 'CONSTRAINTS_INVALID_DEPENDENCY',
YN0027: 'CANT_SUGGEST_RESOLUTIONS',
YN0028: 'FROZEN_LOCKFILE_EXCEPTION',
YN0029: 'CROSS_DRIVE_VIRTUAL_LOCAL',
YN0030: 'FETCH_FAILED',
YN0031: 'DANGEROUS_NODE_MODULES',
YN0032: 'NODE_GYP_INJECTED',
YN0035: 'NETWORK_ERROR',
YN0046: 'AUTOMERGE_FAILED_TO_PARSE',
YN0047: 'AUTOMERGE_IMMUTABLE',
YN0048: 'AUTOMERGE_SUCCESS',
YN0049: 'AUTOMERGE_REQUIRED',
YN0050: 'DEPRECATED_CLI_SETTINGS',
YN0059: 'INVALID_RANGE_PEER_DEPENDENCY',
YN0060: 'INCOMPATIBLE_PEER_DEPENDENCY',
YN0061: 'DEPRECATED_PACKAGE',
YN0068: 'UNUSED_PACKAGE_EXTENSION',
YN0062: 'INCOMPATIBLE_OS',
YN0063: 'INCOMPATIBLE_CPU',
YN0069: 'REDUNDANT_PACKAGE_EXTENSION',
YN0071: 'NM_CANT_INSTALL_EXTERNAL_SOFT_LINK',
YN0072: 'NM_PRESERVE_SYMLINKS_REQUIRED',
YN0074: 'NM_HARDLINKS_MODE_DOWNGRADED',
YN0075: 'PROLOG_INSTANTIATION_ERROR',
YN0076: 'INCOMPATIBLE_ARCHITECTURE',
YN0077: 'GHOST_ARCHITECTURE',
YN0078: 'RESOLUTION_MISMATCH',
YN0080: 'NETWORK_DISABLED',
YN0085: 'UPDATED_RESOLUTION_RECORD',
YN0081: 'NETWORK_UNSAFE_HTTP',
YN0082: 'RESOLUTION_FAILED',
YN0083: 'AUTOMERGE_GIT_ERROR',
YN0086: 'EXPLAIN_PEER_DEPENDENCIES_CTA',
YN0087: 'MIGRATION_SUCCESS',
YN0088: 'VERSION_NOTICE',
YN0089: 'TIPS_NOTICE',
YN0090: 'OFFLINE_MODE_ENABLED',
};

Expand Down

0 comments on commit c0d3fdf

Please sign in to comment.