Skip to content

Commit

Permalink
Downgrade yarnpkg packages and support virtual files properly
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Jul 7, 2023
1 parent 1f782f3 commit 3a476ef
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 37 deletions.
4 changes: 2 additions & 2 deletions code/lib/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 6 additions & 10 deletions code/lib/cli/src/js-package-manager/Yarn2Proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
Expand Down
39 changes: 14 additions & 25 deletions code/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3a476ef

Please sign in to comment.