From 4ca175232c1a7f9b18b55f1f8a7077e0a47d6d77 Mon Sep 17 00:00:00 2001 From: Yann Braga Date: Tue, 6 Aug 2024 11:41:00 +0200 Subject: [PATCH] CLI: Parse more Yarn Berry errors --- .../js-package-manager/Yarn2Proxy.test.ts | 9 +++ .../common/js-package-manager/Yarn2Proxy.ts | 59 ++++++++----------- 2 files changed, 32 insertions(+), 36 deletions(-) diff --git a/code/core/src/common/js-package-manager/Yarn2Proxy.test.ts b/code/core/src/common/js-package-manager/Yarn2Proxy.test.ts index 4e4441aedb4d..c7265e12f18b 100644 --- a/code/core/src/common/js-package-manager/Yarn2Proxy.test.ts +++ b/code/core/src/common/js-package-manager/Yarn2Proxy.test.ts @@ -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 for details, where is the six-letter p-prefixed code. + YN0014: YARN_IMPORT_FAILED -> Failed to import certain dependencies diff --git a/code/core/src/common/js-package-manager/Yarn2Proxy.ts b/code/core/src/common/js-package-manager/Yarn2Proxy.ts index 05156d146130..5036afed4345 100644 --- a/code/core/src/common/js-package-manager/Yarn2Proxy.ts +++ b/code/core/src/common/js-package-manager/Yarn2Proxy.ts @@ -12,36 +12,9 @@ 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', @@ -49,36 +22,50 @@ const YARN2_ERROR_CODES = { 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', };