@nrwl/nx-cloud
Advanced tools
Comparing version 9.1.0-beta.1 to 9.1.0-beta.2
@@ -66,2 +66,27 @@ "use strict"; | ||
} | ||
findSimilarTasks(task) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
// API is not working, don't make the end request | ||
if (this.errors.apiError) | ||
return null; | ||
const resp = yield this.apiAxiosInstance.post('/nx-cloud/find-similar-tasks', { | ||
task: { | ||
target: task.target, | ||
projectName: task.projectName, | ||
hash: task.hash, | ||
hashDetails: task.hashDetails | ||
} | ||
}); | ||
if (!resp.data) { | ||
this.errors.apiError = `Invalid end run response: ${JSON.stringify(resp.data)}`; | ||
} | ||
return resp.data.message; | ||
} | ||
catch (e) { | ||
this.errors.apiError = extractErrorMessage(e); | ||
return null; | ||
} | ||
}); | ||
} | ||
} | ||
@@ -82,3 +107,3 @@ class CloudRemoteCache { | ||
if (CloudRemoteCache.VERBOSE_LOGGING) { | ||
console.log(`NxCloud: Downloading ${hash}`); | ||
output_1.output.note({ title: `Nx Cloud: Downloading ${hash}` }); | ||
} | ||
@@ -89,3 +114,3 @@ const tgz = this.createFileName(hash, cacheDirectory); | ||
if (CloudRemoteCache.VERBOSE_LOGGING) { | ||
console.log(`NxCloud: Cache hit ${hash}`); | ||
output_1.output.note({ title: `Nx Cloud: Cache hit ${hash}` }); | ||
} | ||
@@ -98,3 +123,3 @@ this.statuses[hash] = 'remote-cache-hit'; | ||
if (CloudRemoteCache.VERBOSE_LOGGING) { | ||
console.log(`NxCloud: Cache miss ${hash}`); | ||
output_1.output.note({ title: `Nx Cloud: Cache miss ${hash}` }); | ||
} | ||
@@ -119,3 +144,5 @@ // cache miss. print nothing | ||
if (CloudRemoteCache.VERBOSE_LOGGING) { | ||
console.log(`NxCloud: Skipping storing ${hash}. Read only token is used.`); | ||
output_1.output.note({ | ||
title: `Nx Cloud: Skipping storing ${hash}. Read only token is used.` | ||
}); | ||
} | ||
@@ -126,3 +153,3 @@ return true; | ||
if (CloudRemoteCache.VERBOSE_LOGGING) { | ||
console.log(`NxCloud: Storing ${hash}`); | ||
output_1.output.note({ title: `Nx Cloud: Storing ${hash}` }); | ||
} | ||
@@ -132,3 +159,3 @@ const tgz = yield this.createFile(hash, cacheDirectory); | ||
if (CloudRemoteCache.VERBOSE_LOGGING) { | ||
console.log(`NxCloud: Stored ${hash}`); | ||
output_1.output.note({ title: `Nx Cloud: Stored ${hash}` }); | ||
} | ||
@@ -203,2 +230,7 @@ return true; | ||
startTask(task) { | ||
const overrides = Object.assign({}, (task.overrides || {})); | ||
if (task.target.configuration) { | ||
overrides['configuration'] = task.target.configuration; | ||
} | ||
const params = Object.keys(overrides).reduce((m, k) => `${m} --${k}=${overrides[k]}`, ``); | ||
this.tasks.push({ | ||
@@ -211,3 +243,3 @@ taskId: `${task.id}-${this.uniqRunId}`, | ||
hashDetails: task.hashDetails, | ||
parmas: '' | ||
params: params | ||
}); | ||
@@ -226,4 +258,3 @@ } | ||
class ErrorReporter { | ||
constructor(statuses) { | ||
this.statuses = statuses; | ||
constructor() { | ||
this.cacheError = null; | ||
@@ -246,18 +277,36 @@ this.apiError = null; | ||
} | ||
const anyHits = Object.values(this.statuses).some(s => s === 'remote-cache-hit'); | ||
if (!anyHits && ErrorReporter.VERBOSE_LOGGING) { | ||
console.log(`NxCloud: Nx wasn't able to get anything from the distributed cache.`); | ||
console.log(`NxCloud: If you expected the results to be fetched from the cache, check the following:`); | ||
console.log(`NxCloud: - All runtimeCacheInputs in nx.json return the same values.`); | ||
console.log(`NxCloud: - Global configuration files (e.g., nx.json, package.json, workspace.json) are the same.`); | ||
console.log(`NxCloud: - Flags passed to the builder are the same (e.g., --max-workers, --source-maps)`); | ||
} | ||
} | ||
} | ||
ErrorReporter.VERBOSE_LOGGING = process.env.NX_VERBOSE_LOGGING; | ||
class CacheMissAssistant { | ||
constructor(errors, statuses, api) { | ||
this.errors = errors; | ||
this.statuses = statuses; | ||
this.api = api; | ||
} | ||
findSimilarTasksForFirstTaskWithCacheMiss(tasks) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (CacheMissAssistant.VERBOSE_LOGGING && | ||
!this.errors.apiError && | ||
!this.errors.cacheError) { | ||
const missedTask = tasks.find(t => this.statuses[t.hash] === 'remote-cache-miss'); | ||
if (missedTask) { | ||
const r = yield this.api.findSimilarTasks(missedTask); | ||
if (r) { | ||
output_1.output.note({ | ||
title: `Nx Cloud cache miss analysis:`, | ||
bodyLines: r.split('\n') | ||
}); | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
CacheMissAssistant.VERBOSE_LOGGING = process.env.NX_VERBOSE_LOGGING; | ||
const nxCloudTasksRunner = (tasks, options, context) => { | ||
if (process.env.NX_CLOUD_AUTH_TOKEN || options.accessToken) { | ||
const statuses = {}; | ||
const errors = new ErrorReporter(statuses); | ||
const errors = new ErrorReporter(); | ||
const api = createApi(errors, options); | ||
const cacheMissAssistant = new CacheMissAssistant(errors, statuses, api); | ||
const urls = api.startRun(tasks.map(t => t.hash)); | ||
@@ -277,2 +326,3 @@ const lifeCycle = new TaskRunnerLifeCycle(statuses); | ||
errors.printErrors(); | ||
yield cacheMissAssistant.findSimilarTasksForFirstTaskWithCacheMiss(lifeCycle.tasks); | ||
wrappedRes.complete(); | ||
@@ -279,0 +329,0 @@ }) |
{ | ||
"name": "@nrwl/nx-cloud", | ||
"version": "9.1.0-beta.1", | ||
"version": "9.1.0-beta.2", | ||
"description": "Nx Cloud plugin for Nx", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
27516
410
0