Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@yarnpkg/core

Package Overview
Dependencies
Maintainers
6
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@yarnpkg/core - npm Package Compare versions

Comparing version 4.0.0-rc.50 to 4.0.0-rc.51

3

lib/Cache.d.ts

@@ -55,3 +55,4 @@ import { FakeFS, PortablePath, Filename } from '@yarnpkg/fslib';

getChecksumFilename(locator: Locator, checksum: string): Filename;
getLocatorPath(locator: Locator, expectedChecksum: string | null, opts?: CacheOptions): PortablePath | null;
isChecksumCompatible(checksum: string): boolean;
getLocatorPath(locator: Locator, expectedChecksum: string | null): PortablePath;
getLocatorMirrorPath(locator: Locator): PortablePath | null;

@@ -58,0 +59,0 @@ setup(): Promise<void>;

@@ -5,2 +5,3 @@ "use strict";

const tslib_1 = require("tslib");
const core_1 = require("@yarnpkg/core");
const fslib_1 = require("@yarnpkg/fslib");

@@ -91,19 +92,13 @@ const fslib_2 = require("@yarnpkg/fslib");

}
getLocatorPath(locator, expectedChecksum, opts = {}) {
// If there is no mirror, then the local cache *is* the mirror, in which
// case we use the versioned filename pattern. Same if the package is
// unstable, meaning it may be there or not depending on the environment,
// so we can't rely on its checksum to get a stable location.
if (this.mirrorCwd === null || opts.unstablePackages?.has(locator.locatorHash))
return fslib_2.ppath.resolve(this.cwd, this.getVersionFilename(locator));
isChecksumCompatible(checksum) {
// If we don't yet know the checksum, discard the path resolution for now
// until the checksum can be obtained from somewhere (mirror or network).
if (expectedChecksum === null)
return null;
const { cacheVersion, cacheSpec, } = splitChecksumComponents(expectedChecksum);
if (checksum === null)
return false;
const { cacheVersion, cacheSpec, } = splitChecksumComponents(checksum);
if (cacheVersion === null)
return null;
return false;
// The cache keys must always be at least as old as the last checkpoint.
if (cacheVersion < exports.CACHE_CHECKPOINT)
return null;
return false;
const migrationMode = this.configuration.get(`cacheMigrationMode`);

@@ -113,6 +108,20 @@ // If the global cache is used, then the lockfile must always be up-to-date,

if (cacheVersion < exports.CACHE_VERSION && migrationMode === `always`)
return null;
return false;
// If the cache spec changed, we may need to regenerate the archive
if (cacheSpec !== this.cacheSpec && migrationMode !== `required-only`)
return null;
return false;
return true;
}
getLocatorPath(locator, expectedChecksum) {
// When using the global cache we want the archives to be named as per
// the cache key rather than the hash, as otherwise we wouldn't be able
// to find them if we didn't have the hash (which is the case when adding
// new dependencies to a project).
if (this.mirrorCwd === null)
return fslib_2.ppath.resolve(this.cwd, this.getVersionFilename(locator));
// Same thing if we don't know the checksum; it means that the package
// doesn't support being checksum'd (unstablePackage), so we fallback
// on the versioned filename.
if (expectedChecksum === null)
return fslib_2.ppath.resolve(this.cwd, this.getVersionFilename(locator));
return fslib_2.ppath.resolve(this.cwd, this.getChecksumFilename(locator, expectedChecksum));

@@ -242,8 +251,6 @@ }

// Do this before moving the file so that we don't pollute the cache with corrupted archives
const checksum = (await validateFile(packagePath, {
const { hash: checksum } = await validateFile(packagePath, {
isColdHit: true,
})).hash;
const cachePath = this.getLocatorPath(locator, checksum, opts);
if (!cachePath)
throw new Error(`Assertion failed: Expected the cache path to be available`);
});
const cachePath = this.getLocatorPath(locator, checksum);
const copyProcess = [];

@@ -278,6 +285,6 @@ // Copy the package into the mirror

const mutexedLoad = async () => {
// We don't yet know whether the cache path can be computed yet, since that
// depends on whether the cache is actually the mirror or not, and whether
// the checksum is known or not.
const tentativeCachePath = this.getLocatorPath(locator, expectedChecksum, opts);
const isUnstablePackage = opts.unstablePackages?.has(locator.locatorHash);
const tentativeCachePath = isUnstablePackage || !expectedChecksum || this.isChecksumCompatible(expectedChecksum)
? this.getLocatorPath(locator, expectedChecksum)
: null;
const cacheFileExists = tentativeCachePath !== null

@@ -294,2 +301,4 @@ ? this.markedFiles.has(tentativeCachePath) || await baseFs.existsPromise(tentativeCachePath)

if (!isCacheHit) {
if (this.immutable && isUnstablePackage)
throw new Report_1.ReportError(MessageName_1.MessageName.IMMUTABLE_CACHE, `Cache entry required but missing for ${structUtils.prettyLocator(this.configuration, locator)}; consider defining ${core_1.formatUtils.pretty(this.configuration, `supportedArchitectures`, core_1.formatUtils.Type.CODE)} to cache packages for multiple systems`);
return loadPackage();

@@ -296,0 +305,0 @@ }

@@ -137,2 +137,3 @@ /// <reference types="node" />

enableNetwork: boolean;
enableOfflineMode: boolean;
httpProxy: string | null;

@@ -139,0 +140,0 @@ httpsProxy: string | null;

@@ -393,3 +393,3 @@ "use strict";

const mark = `X`.repeat(locatorsCopy.length.toString().length);
const suffix = `and ${mark} more`;
const suffix = `and ${mark} more.`;
let otherCount = locatorsCopy.length;

@@ -396,0 +396,0 @@ while (named.length > 1 && remainingLength < suffix.length) {

@@ -100,5 +100,6 @@ export declare enum MessageName {

VERSION_NOTICE = 88,
TIPS_NOTICE = 89
TIPS_NOTICE = 89,
OFFLINE_MODE_ENABLED = 90
}
export declare function stringifyMessageName(name: MessageName | number): string;
export declare function parseMessageName(messageName: string): MessageName;

@@ -108,2 +108,3 @@ "use strict";

MessageName[MessageName["TIPS_NOTICE"] = 89] = "TIPS_NOTICE";
MessageName[MessageName["OFFLINE_MODE_ENABLED"] = 90] = "OFFLINE_MODE_ENABLED";
})(MessageName || (exports.MessageName = MessageName = {}));

@@ -110,0 +111,0 @@ function stringifyMessageName(name) {

{
"name": "@yarnpkg/core",
"version": "4.0.0-rc.50",
"version": "4.0.0-rc.51",
"stableVersion": "3.5.3",

@@ -16,6 +16,6 @@ "license": "BSD-2-Clause",

"@types/treeify": "^1.0.0",
"@yarnpkg/fslib": "^3.0.0-rc.50",
"@yarnpkg/libzip": "^3.0.0-rc.50",
"@yarnpkg/parsers": "^3.0.0-rc.50",
"@yarnpkg/shell": "^4.0.0-rc.50",
"@yarnpkg/fslib": "^3.0.0-rc.51",
"@yarnpkg/libzip": "^3.0.0-rc.51",
"@yarnpkg/parsers": "^3.0.0-rc.51",
"@yarnpkg/shell": "^4.0.0-rc.51",
"camelcase": "^5.3.1",

@@ -50,9 +50,9 @@ "chalk": "^3.0.0",

"@types/micromatch": "^4.0.1",
"@types/node": "^18.15.11",
"@types/node": "^18.17.15",
"@types/tar": "^4.0.4",
"@types/tunnel": "^0.0.0",
"@yarnpkg/cli": "^4.0.0-rc.50",
"@yarnpkg/plugin-link": "^3.0.0-rc.50",
"@yarnpkg/plugin-npm": "^3.0.0-rc.50",
"@yarnpkg/plugin-pnp": "^4.0.0-rc.50",
"@yarnpkg/cli": "^4.0.0-rc.51",
"@yarnpkg/plugin-link": "^3.0.0-rc.51",
"@yarnpkg/plugin-npm": "^3.0.0-rc.51",
"@yarnpkg/plugin-pnp": "^4.0.0-rc.51",
"comment-json": "^2.2.0",

@@ -59,0 +59,0 @@ "esbuild": "npm:esbuild-wasm@^0.15.15",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc