From 3a476efe2ca839d4f3a4ef61daeda35c8c94f619 Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Fri, 7 Jul 2023 14:19:04 +0200 Subject: [PATCH] Downgrade yarnpkg packages and support virtual files properly --- code/lib/cli/package.json | 4 +- .../cli/src/js-package-manager/Yarn2Proxy.ts | 16 +++----- code/yarn.lock | 39 +++++++------------ 3 files changed, 22 insertions(+), 37 deletions(-) diff --git a/code/lib/cli/package.json b/code/lib/cli/package.json index be0d002ced16..04bf3f9914e2 100644 --- a/code/lib/cli/package.json +++ b/code/lib/cli/package.json @@ -65,8 +65,8 @@ "@storybook/telemetry": "7.1.0-beta.1", "@storybook/types": "7.1.0-beta.1", "@types/semver": "^7.3.4", - "@yarnpkg/fslib": "3.0.0-rc.46", - "@yarnpkg/libzip": "3.0.0-rc.46", + "@yarnpkg/fslib": "2.10.3", + "@yarnpkg/libzip": "2.3.0", "chalk": "^4.1.0", "commander": "^6.2.1", "cross-spawn": "^7.0.3", diff --git a/code/lib/cli/src/js-package-manager/Yarn2Proxy.ts b/code/lib/cli/src/js-package-manager/Yarn2Proxy.ts index dc4c80159680..a4d4484f554e 100644 --- a/code/lib/cli/src/js-package-manager/Yarn2Proxy.ts +++ b/code/lib/cli/src/js-package-manager/Yarn2Proxy.ts @@ -2,8 +2,8 @@ import dedent from 'ts-dedent'; import { sync as findUpSync, sync as syncFindUp } from 'find-up'; import { existsSync, readFileSync } from 'fs'; import path from 'path'; -import { PosixFS } from '@yarnpkg/fslib'; -import { getLibzipSync, ZipOpenFS } from '@yarnpkg/libzip'; +import { PosixFS, VirtualFS, ZipOpenFS } from '@yarnpkg/fslib'; +import { getLibzipSync } from '@yarnpkg/libzip'; import semver from 'semver'; import { createLogStream } from '../utils'; import { JsPackageManager } from './JsPackageManager'; @@ -142,16 +142,12 @@ export class Yarn2Proxy extends JsPackageManager { libzip: getLibzipSync(), }); - const crossFs = new PosixFS(zipOpenFs); + const virtualFs = new VirtualFS({ baseFs: zipOpenFs }); + const crossFs = new PosixFS(virtualFs); - // On Windows "crossFs.readJsonSync" does not resolve virtual paths. Unknown bug - if (process.platform === 'win32' && !!pnpApi.VERSIONS.resolveVirtual) { - const virtualPath = path.join(pkg.packageLocation, 'package.json'); - const physicalPath = pnpApi.resolveVirtual(virtualPath); - return crossFs.readJsonSync(physicalPath); - } + const virtualPath = path.join(pkg.packageLocation, 'package.json'); - return crossFs.readJsonSync(path.join(pkg.packageLocation, 'package.json') as any); + return crossFs.readJsonSync(virtualPath); } catch (error) { if (error.code !== 'MODULE_NOT_FOUND') { console.error('Error while fetching package version in Yarn PnP mode:', error); diff --git a/code/yarn.lock b/code/yarn.lock index 7a0c69c10d4e..b9323f6d6269 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6001,8 +6001,8 @@ __metadata: "@types/puppeteer-core": ^2.1.0 "@types/semver": ^7.3.4 "@types/util-deprecate": ^1.0.0 - "@yarnpkg/fslib": 3.0.0-rc.46 - "@yarnpkg/libzip": 3.0.0-rc.46 + "@yarnpkg/fslib": 2.10.3 + "@yarnpkg/libzip": 2.3.0 boxen: ^5.1.2 chalk: ^4.1.0 commander: ^6.2.1 @@ -9717,34 +9717,23 @@ __metadata: languageName: node linkType: hard -"@yarnpkg/fslib@npm:3.0.0-rc.46": - version: 3.0.0-rc.46 - resolution: "@yarnpkg/fslib@npm:3.0.0-rc.46" +"@yarnpkg/fslib@npm:2.10.3": + version: 2.10.3 + resolution: "@yarnpkg/fslib@npm:2.10.3" dependencies: - tslib: ^2.4.0 - checksum: 6b768a511ef65fe2d503580bc5e1b8810c61b0e37b05672f4dcfcdca4c9f515bd08cb26f269f65a56efe6f3ebdba26489f8ac09e4882aa58d3eede50ee472fdc + "@yarnpkg/libzip": ^2.3.0 + tslib: ^1.13.0 + checksum: c4fbbed99e801f17c381204e9699d9ea4fb51b14e99968985f477bdbc7b02b61e026860173f3f46bd60d9f46ae6a06f420a3edb3c02c3a45ae83779095928094 languageName: node linkType: hard -"@yarnpkg/fslib@npm:^3.0.0-rc.46": - version: 3.0.0-rc.48 - resolution: "@yarnpkg/fslib@npm:3.0.0-rc.48" - dependencies: - tslib: ^2.4.0 - checksum: e4c8f640f002047efe915e656537f7057f39de9276ccef602289c9968a5b257ba3f78e8face02f17a28e9e28f055c8c8b64f4f29558c9c6bc0318029cb8c027b - languageName: node - linkType: hard - -"@yarnpkg/libzip@npm:3.0.0-rc.46": - version: 3.0.0-rc.46 - resolution: "@yarnpkg/libzip@npm:3.0.0-rc.46" +"@yarnpkg/libzip@npm:2.3.0, @yarnpkg/libzip@npm:^2.3.0": + version: 2.3.0 + resolution: "@yarnpkg/libzip@npm:2.3.0" dependencies: "@types/emscripten": ^1.39.6 - "@yarnpkg/fslib": ^3.0.0-rc.46 - tslib: ^2.4.0 - peerDependencies: - "@yarnpkg/fslib": ^3.0.0-rc.46 - checksum: 6217994646e25d64a04e8ad34693fdadeee57979bb61f44031537758950206219c3e201f9c7d6fa724296dcfa2e26072289cb00e5d8bb7232176eea8e2b87841 + tslib: ^1.13.0 + checksum: 0c2361ccb002e28463ed98541f3bdaab54f52aad6a2080666c2a9ea605ebd9cdfb7b0340b1db6f105820d05bcb803cdfb3ce755a8f6034657298c291bf884f81 languageName: node linkType: hard @@ -29518,7 +29507,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^1.10.0, tslib@npm:^1.8.1, tslib@npm:^1.9.0, tslib@npm:^1.9.3": +"tslib@npm:^1.10.0, tslib@npm:^1.13.0, tslib@npm:^1.8.1, tslib@npm:^1.9.0, tslib@npm:^1.9.3": version: 1.14.1 resolution: "tslib@npm:1.14.1" checksum: 69ae09c49eea644bc5ebe1bca4fa4cc2c82b7b3e02f43b84bd891504edf66dbc6b2ec0eef31a957042de2269139e4acff911e6d186a258fb14069cd7f6febce2