Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 42 additions & 41 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions .yarn/versions/57a58394.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
releases:
"@yarnpkg/cli": patch
"@yarnpkg/core": patch
"@yarnpkg/fslib": major
"@yarnpkg/plugin-patch": patch
"@yarnpkg/pnp": patch
"@yarnpkg/pnpify": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-exec"
- "@yarnpkg/plugin-file"
- "@yarnpkg/plugin-git"
- "@yarnpkg/plugin-github"
- "@yarnpkg/plugin-http"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-link"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- vscode-zipfs
- "@yarnpkg/builder"
- "@yarnpkg/doctor"
- "@yarnpkg/extensions"
- "@yarnpkg/libzip"
- "@yarnpkg/nm"
- "@yarnpkg/sdks"
- "@yarnpkg/shell"
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Yarn now accepts sponsorships! Please give a look at our [OpenCollective](https:
- Yarn will no longer remove the old Yarn 2.x `.pnp.js` file when migrating.
- The `pnpDataPath` option has been removed to adhere to our new [PnP specification](https://yarnpkg.com/advanced/pnp-spec). For consistency, all PnP files will now be hardcoded to a single value so that third-party tools can implement the PnP specification without relying on the Yarn configuration.
- The `ZipFS` and `ZipOpenFS` classes have been moved from `@yarnpkg/fslib` to `@yarnpkg/libzip`. They no longer need or accept the `libzip` parameter.
- Yarn now assumes that the `fs.lutimes` bindings are always available (which is true for all supported Node versions).

### **API Changes**

Expand Down Expand Up @@ -58,6 +59,8 @@ The following changes only affect people writing Yarn plugins:
- `Link{Resolver,Fetcher}` have been renamed to `Portal{Resolver,Fetcher}`
- `RawLink{Resolver,Fetcher}` have been renamed to `Link{Resolver,Fetcher}`

- `FakeFS` classes are now required to implement `lutimes{Sync,Promise}`.

### Installs

- The `pnpm` linker avoids creating symlinks that lead to loops on the file system, by moving them higher up in the directory structure.
Expand Down
8 changes: 1 addition & 7 deletions packages/plugin-patch/sources/tools/apply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@ async function preserveTime(baseFs: FakeFS<PortablePath>, p: PortablePath, cb: (
if (typeof result !== `undefined`)
p = result;

if (baseFs.lutimesPromise) {
await baseFs.lutimesPromise(p, stat.atime, stat.mtime);
} else if (!stat.isSymbolicLink()) {
await baseFs.utimesPromise(p, stat.atime, stat.mtime);
} else {
throw new Error(`Cannot preserve the time values of a symlink`);
}
await baseFs.lutimesPromise(p, stat.atime, stat.mtime);
}

export async function applyPatchFile(effects: ParsedPatchFile, {baseFs = new NodeFS(), dryRun = false, version = null}: {baseFs?: FakeFS<PortablePath>, dryRun?: boolean, version?: string | null} = {}) {
Expand Down
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/tgzUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export async function extractArchiveTo<T extends FakeFS<PortablePath>>(tgz: Buff
targetFs.mkdirpSync(ppath.dirname(mappedPath), {chmod: 0o755, utimes: [constants.SAFE_TIME, constants.SAFE_TIME]});

targetFs.symlinkSync((entry as any).linkpath, mappedPath);
targetFs.lutimesSync?.(mappedPath, constants.SAFE_TIME, constants.SAFE_TIME);
targetFs.lutimesSync(mappedPath, constants.SAFE_TIME, constants.SAFE_TIME);
} break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/yarnpkg-core/sources/worker-zip/index.js

Large diffs are not rendered by default.

16 changes: 4 additions & 12 deletions packages/yarnpkg-fslib/sources/FakeFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ export abstract class FakeFS<P extends Path> {
abstract utimesPromise(p: P, atime: Date | string | number, mtime: Date | string | number): Promise<void>;
abstract utimesSync(p: P, atime: Date | string | number, mtime: Date | string | number): void;

lutimesPromise?(p: P, atime: Date | string | number, mtime: Date | string | number): Promise<void>;
lutimesSync?(p: P, atime: Date | string | number, mtime: Date | string | number): void;
abstract lutimesPromise(p: P, atime: Date | string | number, mtime: Date | string | number): Promise<void>;
abstract lutimesSync(p: P, atime: Date | string | number, mtime: Date | string | number): void;

abstract readFilePromise(p: FSPath<P>, encoding?: null): Promise<Buffer>;
abstract readFilePromise(p: FSPath<P>, encoding: BufferEncoding): Promise<string>;
Expand Down Expand Up @@ -731,11 +731,7 @@ export abstract class FakeFS<P extends Path> {
if (typeof result !== `undefined`)
p = result;

if (this.lutimesPromise) {
await this.lutimesPromise(p, stat.atime, stat.mtime);
} else if (!stat.isSymbolicLink()) {
await this.utimesPromise(p, stat.atime, stat.mtime);
}
await this.lutimesPromise(p, stat.atime, stat.mtime);
}

async preserveTimeSync(p: P, cb: () => P | void) {
Expand All @@ -745,11 +741,7 @@ export abstract class FakeFS<P extends Path> {
if (typeof result !== `undefined`)
p = result;

if (this.lutimesSync) {
this.lutimesSync(p, stat.atime, stat.mtime);
} else if (!stat.isSymbolicLink()) {
this.utimesSync(p, stat.atime, stat.mtime);
}
this.lutimesSync(p, stat.atime, stat.mtime);
}
}

Expand Down
16 changes: 16 additions & 0 deletions packages/yarnpkg-fslib/sources/MountFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,22 @@ export class MountFS<MountedFS extends MountableFS> extends BasePortableFakeFS {
});
}

async lutimesPromise(p: PortablePath, atime: Date | string | number, mtime: Date | string | number) {
return await this.makeCallPromise(p, async () => {
return await this.baseFs.lutimesPromise(p, atime, mtime);
}, async (mountFs, {subPath}) => {
return await mountFs.lutimesPromise(subPath, atime, mtime);
});
}

lutimesSync(p: PortablePath, atime: Date | string | number, mtime: Date | string | number) {
return this.makeCallSync(p, () => {
return this.baseFs.lutimesSync(p, atime, mtime);
}, (mountFs, {subPath}) => {
return mountFs.lutimesSync(subPath, atime, mtime);
});
}

async mkdirPromise(p: PortablePath, opts?: MkdirOptions) {
return await this.makeCallPromise(p, async () => {
return await this.baseFs.mkdirPromise(p, opts);
Expand Down
8 changes: 8 additions & 0 deletions packages/yarnpkg-fslib/sources/NoFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,14 @@ export class NoFS extends FakeFS<PortablePath> {
throw makeError();
}

async lutimesPromise(): Promise<never> {
throw makeError();
}

lutimesSync(): never {
throw makeError();
}

async readFilePromise(): Promise<never> {
throw makeError();
}
Expand Down
Loading