@nrwl/nx-cloud
Advanced tools
Comparing version 8.12.4 to 8.12.5
@@ -72,3 +72,4 @@ "use strict"; | ||
class CloudRemoteCache { | ||
constructor(api) { | ||
constructor(errors, api) { | ||
this.errors = errors; | ||
this.api = api; | ||
@@ -90,3 +91,3 @@ } | ||
else { | ||
this.printErrorMessage(e); | ||
this.addErrorMessage(e); | ||
} | ||
@@ -107,3 +108,3 @@ return false; | ||
catch (e) { | ||
this.printErrorMessage(e); | ||
this.addErrorMessage(e); | ||
return false; | ||
@@ -117,13 +118,13 @@ } | ||
} | ||
printErrorMessage(e) { | ||
addErrorMessage(e) { | ||
if (e.code === 'ECONNREFUSED' || | ||
e.code === 'EAI_AGAIN' || | ||
e.code === 'ENOTFOUND') { | ||
console.error(`Error: Cannot connect to remote cache.`); | ||
this.errors.cacheError = `Cannot connect to remote cache.`; | ||
} | ||
else if (e.response.status === 401) { | ||
console.error(`Error: Invalid Nx Cloud access token.`); | ||
this.errors.cacheError = `Invalid Nx Cloud access token.`; | ||
} | ||
else { | ||
console.error(e.message); | ||
this.errors.cacheError = e.message; | ||
} | ||
@@ -179,6 +180,7 @@ } | ||
const api = createApi(options); | ||
const lifeCycle = new TaskRunnerLifeCycle(api); | ||
const remoteCache = new CloudRemoteCache(api); | ||
const errors = new ErrorReporter(); | ||
const lifeCycle = new TaskRunnerLifeCycle(errors, api); | ||
const remoteCache = new CloudRemoteCache(errors, api); | ||
const res = tasks_runner_v2_1.tasksRunnerV2(tasks, Object.assign({}, options, { remoteCache, lifeCycle }), context); | ||
return lifeCycle.complete().pipe(operators_1.concatMap(() => res)); | ||
return lifeCycle.complete().pipe(operators_1.tap(() => errors.printErrors()), operators_1.concatMap(() => res)); | ||
} | ||
@@ -190,6 +192,6 @@ else { | ||
class TaskRunnerLifeCycle { | ||
constructor(api) { | ||
constructor(errors, api) { | ||
this.errors = errors; | ||
this.api = api; | ||
this.promises = {}; | ||
this.errors = []; | ||
} | ||
@@ -199,3 +201,3 @@ startTask(task) { | ||
this.promises[`${task.id}-start`] = this.api.startTask(task).catch(e => { | ||
this.errors.push(e.message); | ||
this.errors.lifeCycleError = e.message; | ||
}); | ||
@@ -211,3 +213,3 @@ } | ||
.catch((e) => { | ||
this.errors.push(e.message); | ||
this.errors.lifeCycleError = e.message; | ||
}); | ||
@@ -218,16 +220,20 @@ this.promises[`${task.id}-end`] = endPromise; | ||
complete() { | ||
return rxjs_1.from(Promise.all(Object.values(this.promises)).then(() => { | ||
if (this.errors.length > 0) { | ||
this.printNxCloudStatus(); | ||
} | ||
})); | ||
return rxjs_1.from(Promise.all(Object.values(this.promises))); | ||
} | ||
printNxCloudStatus() { | ||
console.warn(`We were unable to send the data to Nx Cloud:`); | ||
console.error(`Errors:`); | ||
console.error(this.errors[0]); | ||
} | ||
class ErrorReporter { | ||
constructor() { | ||
this.cacheError = null; | ||
this.lifeCycleError = null; | ||
} | ||
printErrors() { | ||
if (this.cacheError || this.lifeCycleError) { | ||
console.warn(`Nx Cloud Errors:`); | ||
console.error(`- ${this.cacheError}`); | ||
console.error(`- ${this.lifeCycleError}`); | ||
} | ||
} | ||
} | ||
function createApi(options) { | ||
const baseUrl = options.url || 'https://nrwl.api.io'; | ||
const baseUrl = options.url || 'https://api.nrwl.io'; | ||
if (process.env.NX_CLOUD_AUTH_TOKEN) { | ||
@@ -234,0 +240,0 @@ return new CloudApi(baseUrl, process.env.NX_CLOUD_AUTH_TOKEN); |
{ | ||
"name": "@nrwl/nx-cloud", | ||
"version": "8.12.4", | ||
"version": "8.12.5", | ||
"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
18340
282