@yarnpkg/core
Advanced tools
Comparing version 2.0.0-rc.22 to 2.0.0-rc.23
@@ -25,3 +25,3 @@ "use strict"; | ||
// cause all files to be fetched again. Use with caution. | ||
const CACHE_VERSION = 1; | ||
const CACHE_VERSION = 2; | ||
class Cache { | ||
@@ -76,5 +76,5 @@ constructor(cacheCwd, { configuration, immutable = configuration.get(`enableImmutableCache`), check = false }) { | ||
const validateFile = async (path, refetchPath = null) => { | ||
const actualChecksum = await hashUtils.checksumFile(path); | ||
const actualChecksum = `${CACHE_VERSION}/${await hashUtils.checksumFile(path)}`; | ||
if (refetchPath !== null) { | ||
const previousChecksum = await hashUtils.checksumFile(refetchPath); | ||
const previousChecksum = `${CACHE_VERSION}/${await hashUtils.checksumFile(refetchPath)}`; | ||
if (actualChecksum !== previousChecksum) { | ||
@@ -87,3 +87,5 @@ throw new Report_1.ReportError(MessageName_1.MessageName.CACHE_CHECKSUM_MISMATCH, `The remote archive doesn't match the local checksum - has the local cache been corrupted?`); | ||
const checksumBehavior = !this.check | ||
? this.configuration.get(`checksumBehavior`) | ||
? expectedChecksum.match(/^[0-9]+\//) === null | ||
? `update` | ||
: this.configuration.get(`checksumBehavior`) | ||
: `throw`; | ||
@@ -90,0 +92,0 @@ switch (checksumBehavior) { |
@@ -75,3 +75,3 @@ /// <reference types="node" /> | ||
invalid: Map<string, string>; | ||
private packageExtensions; | ||
private packageExtensions?; | ||
/** | ||
@@ -146,3 +146,3 @@ * Instantiate a new configuration object exposing the configuration obtained | ||
getLinkers(): import("./Linker").Linker[]; | ||
refreshPackageExtensions(): void; | ||
refreshPackageExtensions(): Promise<void>; | ||
normalizePackage(original: Package): Package; | ||
@@ -149,0 +149,0 @@ triggerHook<U extends any[], V, HooksDefinition = Hooks>(get: (hooks: HooksDefinition) => ((...args: U) => V) | undefined, ...args: U): Promise<void>; |
@@ -617,2 +617,3 @@ "use strict"; | ||
} | ||
await configuration.refreshPackageExtensions(); | ||
return configuration; | ||
@@ -742,5 +743,2 @@ } | ||
this.sources.set(key, source); | ||
if (key === `packageExtensions`) { | ||
this.refreshPackageExtensions(); | ||
} | ||
} | ||
@@ -807,4 +805,5 @@ } | ||
} | ||
refreshPackageExtensions() { | ||
async refreshPackageExtensions() { | ||
this.packageExtensions = new Map(); | ||
const packageExtensions = this.packageExtensions; | ||
const registerPackageExtension = (descriptor, extensionData) => { | ||
@@ -815,3 +814,3 @@ if (!semver_1.default.validRange(descriptor.range)) | ||
extension.load(extensionData); | ||
miscUtils.getArrayWithDefault(this.packageExtensions, descriptor.identHash).push({ | ||
miscUtils.getArrayWithDefault(packageExtensions, descriptor.identHash).push({ | ||
range: descriptor.range, | ||
@@ -828,3 +827,3 @@ patch: pkg => { | ||
registerPackageExtension(structUtils.parseDescriptor(descriptorString, true), extensionData); | ||
this.triggerHook(hooks => { | ||
await this.triggerHook(hooks => { | ||
return hooks.registerPackageExtensions; | ||
@@ -837,2 +836,4 @@ }, this, registerPackageExtension); | ||
// properly listed in the original package definition | ||
if (this.packageExtensions == null) | ||
throw new Error(`refreshPackageExtensions has to be called before normalizing packages`); | ||
const extensionList = this.packageExtensions.get(original.identHash); | ||
@@ -839,0 +840,0 @@ if (typeof extensionList !== `undefined`) { |
@@ -72,3 +72,3 @@ "use strict"; | ||
(options) => { | ||
hostname = options.hostname; | ||
hostname = options.url.hostname; | ||
}, | ||
@@ -78,3 +78,3 @@ ], | ||
(options) => { | ||
if (options.headers && options.headers.authorization && options.hostname !== hostname) { | ||
if (options.headers && options.headers.authorization && options.url.hostname !== hostname) { | ||
delete options.headers.authorization; | ||
@@ -81,0 +81,0 @@ } |
@@ -34,2 +34,3 @@ /// <reference types="node" /> | ||
private progressTimeout; | ||
private forgettableLines; | ||
constructor({ configuration, stdout, json, includeFooter, includeLogs, includeInfos, includeWarnings }: StreamReportOptions); | ||
@@ -59,2 +60,4 @@ hasErrors(): boolean; | ||
private writeLine; | ||
private writeLineWithForgettableReset; | ||
private writeLines; | ||
private clearProgress; | ||
@@ -61,0 +64,0 @@ private writeProgress; |
@@ -14,2 +14,4 @@ "use strict"; | ||
const PROGRESS_INTERVAL = 80; | ||
const FORGETTABLE_NAMES = new Set([MessageName_1.MessageName.FETCH_NOT_CACHED]); | ||
const FORGETTABLE_BUFFER_SIZE = 5; | ||
const now = new Date(); | ||
@@ -66,2 +68,3 @@ // We only want to support environments that will out-of-the-box accept the | ||
this.progressTimeout = null; | ||
this.forgettableLines = []; | ||
this.configuration = configuration; | ||
@@ -145,3 +148,3 @@ this.includeFooter = includeFooter; | ||
if (this.indent === 0) { | ||
this.writeLine(``); | ||
this.writeLineWithForgettableReset(``); | ||
} | ||
@@ -156,3 +159,16 @@ else { | ||
if (!this.json) { | ||
this.writeLine(`${this.configuration.format(`➤`, `blueBright`)} ${this.formatName(name)}: ${this.formatIndent()}${text}`); | ||
if (FORGETTABLE_NAMES.has(name)) { | ||
this.forgettableLines.push(text); | ||
if (this.forgettableLines.length > FORGETTABLE_BUFFER_SIZE) { | ||
while (this.forgettableLines.length > FORGETTABLE_BUFFER_SIZE) | ||
this.forgettableLines.shift(); | ||
this.writeLines(name, this.forgettableLines); | ||
} | ||
else { | ||
this.writeLine(`${this.configuration.format(`➤`, `blueBright`)} ${this.formatName(name)}: ${this.formatIndent()}${text}`); | ||
} | ||
} | ||
else { | ||
this.writeLineWithForgettableReset(`${this.configuration.format(`➤`, `blueBright`)} ${this.formatName(name)}: ${this.formatIndent()}${text}`); | ||
} | ||
} | ||
@@ -168,3 +184,3 @@ else { | ||
if (!this.json) { | ||
this.writeLine(`${this.configuration.format(`➤`, `yellowBright`)} ${this.formatName(name)}: ${this.formatIndent()}${text}`); | ||
this.writeLineWithForgettableReset(`${this.configuration.format(`➤`, `yellowBright`)} ${this.formatName(name)}: ${this.formatIndent()}${text}`); | ||
} | ||
@@ -178,3 +194,3 @@ else { | ||
if (!this.json) { | ||
this.writeLine(`${this.configuration.format(`➤`, `redBright`)} ${this.formatName(name)}: ${this.formatIndent()}${text}`); | ||
this.writeLineWithForgettableReset(`${this.configuration.format(`➤`, `redBright`)} ${this.formatName(name)}: ${this.formatIndent()}${text}`); | ||
} | ||
@@ -227,3 +243,3 @@ else { | ||
if (this.json) { | ||
this.writeLine(`${JSON.stringify(data)}`); | ||
this.writeLineWithForgettableReset(`${JSON.stringify(data)}`); | ||
} | ||
@@ -281,2 +297,12 @@ } | ||
} | ||
writeLineWithForgettableReset(str) { | ||
this.forgettableLines = []; | ||
this.writeLine(str); | ||
} | ||
writeLines(name, lines) { | ||
this.clearProgress({ delta: lines.length }); | ||
for (const line of lines) | ||
this.stdout.write(`${this.configuration.format(`➤`, `blueBright`)} ${this.formatName(name)}: ${this.formatIndent()}${line}\n`); | ||
this.writeProgress(); | ||
} | ||
clearProgress({ delta = 0, clear = false }) { | ||
@@ -283,0 +309,0 @@ if (!this.configuration.get(`enableProgressBars`) || this.json) |
{ | ||
"name": "@yarnpkg/core", | ||
"version": "2.0.0-rc.22", | ||
"version": "2.0.0-rc.23", | ||
"main": "./lib/index.js", | ||
"sideEffects": false, | ||
"dependencies": { | ||
"@yarnpkg/fslib": "^2.0.0-rc.15", | ||
"@yarnpkg/fslib": "^2.0.0-rc.16", | ||
"@yarnpkg/json-proxy": "^2.0.0-rc.7", | ||
"@yarnpkg/libzip": "^2.0.0-rc.9", | ||
"@yarnpkg/parsers": "^2.0.0-rc.9", | ||
"@yarnpkg/pnp": "^2.0.0-rc.16", | ||
"@yarnpkg/shell": "^2.0.0-rc.8", | ||
"@yarnpkg/libzip": "^2.0.0-rc.10", | ||
"@yarnpkg/parsers": "^2.0.0-rc.10", | ||
"@yarnpkg/pnp": "^2.0.0-rc.17", | ||
"@yarnpkg/shell": "^2.0.0-rc.9", | ||
"camelcase": "^5.3.1", | ||
@@ -28,3 +28,3 @@ "chalk": "^3.0.0", | ||
"pretty-bytes": "^5.1.0", | ||
"semver": "^5.6.0", | ||
"semver": "^7.1.2", | ||
"stream-to-promise": "^2.2.0", | ||
@@ -41,9 +41,9 @@ "tar": "^4.4.6", | ||
"@types/micromatch": "^3.1.0", | ||
"@types/semver": "^6.0.2", | ||
"@types/semver": "^7.1.0", | ||
"@types/tar": "^4.0.0", | ||
"@types/tmp": "^0.0.33", | ||
"@types/tunnel": "^0.0.0", | ||
"@yarnpkg/cli": "^2.0.0-rc.28", | ||
"@yarnpkg/cli": "^2.0.0-rc.29", | ||
"@yarnpkg/plugin-link": "^2.0.0-rc.11", | ||
"@yarnpkg/plugin-pnp": "^2.0.0-rc.16" | ||
"@yarnpkg/plugin-pnp": "^2.0.0-rc.17" | ||
}, | ||
@@ -50,0 +50,0 @@ "scripts": { |
347241
7513
+ Addedsemver@7.6.3(transitive)
Updated@yarnpkg/fslib@^2.0.0-rc.16
Updated@yarnpkg/libzip@^2.0.0-rc.10
Updated@yarnpkg/pnp@^2.0.0-rc.17
Updated@yarnpkg/shell@^2.0.0-rc.9
Updatedsemver@^7.1.2