@nrwl/nx-cloud 14.4.1 → 14.5.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/core/api/error-reporter.api.js +36 -1
- package/lib/core/api/run-group.api.js +68 -1
- package/lib/core/file-storage/file-storage.d.ts +6 -1
- package/lib/core/file-storage/file-storage.js +6 -1
- package/lib/core/file-storage/file-storage.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +156 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +284 -1
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js.map +1 -1
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +113 -1
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +166 -1
- package/lib/core/runners/cloud-enabled/id-generator.d.ts +1 -0
- package/lib/core/runners/cloud-enabled/id-generator.js +16 -0
- package/lib/core/runners/cloud-enabled/id-generator.js.map +1 -0
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +79 -1
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +263 -1
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +143 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +220 -1
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js.map +1 -1
- package/lib/core/runners/distributed-execution/split-task-graph-into-stages.js +37 -1
- package/lib/core/runners/distributed-execution/task-graph-creator.js +77 -1
- package/lib/core/terminal-output/end-of-run-message.js +0 -1
- package/lib/core/terminal-output/end-of-run-message.js.map +1 -1
- package/lib/daemon/process-run-end.d.ts +3 -0
- package/lib/daemon/process-run-end.js +60 -0
- package/lib/daemon/process-run-end.js.map +1 -0
- package/lib/utilities/axios.js +4 -4
- package/lib/utilities/axios.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ErrorReporterApi = void 0;
|
|
13
|
+
const axios_1 = require("../../utilities/axios");
|
|
14
|
+
const { output } = require('../../utilities/nx-imports');
|
|
15
|
+
class ErrorReporterApi {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
18
|
+
}
|
|
19
|
+
reportError(message) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
try {
|
|
22
|
+
yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/report-client-error', {
|
|
23
|
+
message,
|
|
24
|
+
}));
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
output.warn({
|
|
28
|
+
title: `Unable to record the following error: '${message}'`,
|
|
29
|
+
bodyLines: [e.message],
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.ErrorReporterApi = ErrorReporterApi;
|
|
36
|
+
//# sourceMappingURL=error-reporter.api.js.map
|
|
@@ -1 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RunGroupApi = void 0;
|
|
13
|
+
const axios_1 = require("../../utilities/axios");
|
|
14
|
+
const metric_logger_1 = require("../../utilities/metric-logger");
|
|
15
|
+
const { output } = require('../../utilities/nx-imports');
|
|
16
|
+
class RunGroupApi {
|
|
17
|
+
constructor(options) {
|
|
18
|
+
this.apiAxiosInstance = (0, axios_1.createApiAxiosInstance)(options);
|
|
19
|
+
}
|
|
20
|
+
createRunGroup(branch, runGroup, stopAgentsOnFailure, agentCount, commandCount) {
|
|
21
|
+
var _a;
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
24
|
+
try {
|
|
25
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/create-run-group', {
|
|
26
|
+
branch,
|
|
27
|
+
runGroup,
|
|
28
|
+
stopAgentsOnFailure,
|
|
29
|
+
agentCount,
|
|
30
|
+
commandCount,
|
|
31
|
+
}));
|
|
32
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
36
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
37
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
38
|
+
output.error({
|
|
39
|
+
title: e.message,
|
|
40
|
+
});
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
completeRunGroup(runGroup) {
|
|
46
|
+
var _a;
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
49
|
+
try {
|
|
50
|
+
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
51
|
+
runGroup: runGroup,
|
|
52
|
+
}));
|
|
53
|
+
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
57
|
+
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
58
|
+
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
59
|
+
output.error({
|
|
60
|
+
title: e.message,
|
|
61
|
+
});
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.RunGroupApi = RunGroupApi;
|
|
68
|
+
//# sourceMappingURL=run-group.api.js.map
|
|
@@ -4,7 +4,12 @@ export declare class FileStorage {
|
|
|
4
4
|
private readonly encryption;
|
|
5
5
|
private readonly errorReporter;
|
|
6
6
|
private readonly failWhenCannotDownloadArtifact;
|
|
7
|
-
|
|
7
|
+
private readonly recordUploads;
|
|
8
|
+
uploads: {
|
|
9
|
+
hash: string;
|
|
10
|
+
url: string;
|
|
11
|
+
}[];
|
|
12
|
+
constructor(encryption: E2EEncryption, errorReporter: ErrorReporterApi, failWhenCannotDownloadArtifact: boolean, recordUploads: boolean);
|
|
8
13
|
retrieve(hash: string, url: string, cacheDirectory: string): Promise<void>;
|
|
9
14
|
store(hash: string, url: string, cacheDirectory: string): Promise<any>;
|
|
10
15
|
private createFileName;
|
|
@@ -21,10 +21,12 @@ const axios = require('axios');
|
|
|
21
21
|
const tar = require('tar');
|
|
22
22
|
const { output } = require('../../utilities/nx-imports');
|
|
23
23
|
class FileStorage {
|
|
24
|
-
constructor(encryption, errorReporter, failWhenCannotDownloadArtifact) {
|
|
24
|
+
constructor(encryption, errorReporter, failWhenCannotDownloadArtifact, recordUploads) {
|
|
25
25
|
this.encryption = encryption;
|
|
26
26
|
this.errorReporter = errorReporter;
|
|
27
27
|
this.failWhenCannotDownloadArtifact = failWhenCannotDownloadArtifact;
|
|
28
|
+
this.recordUploads = recordUploads;
|
|
29
|
+
this.uploads = [];
|
|
28
30
|
}
|
|
29
31
|
retrieve(hash, url, cacheDirectory) {
|
|
30
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -61,6 +63,9 @@ class FileStorage {
|
|
|
61
63
|
}
|
|
62
64
|
store(hash, url, cacheDirectory) {
|
|
63
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
if (this.recordUploads) {
|
|
67
|
+
this.uploads.push({ hash, url });
|
|
68
|
+
}
|
|
64
69
|
if (environment_1.VERBOSE_LOGGING) {
|
|
65
70
|
output.note({
|
|
66
71
|
title: `Nx Cloud: Storing ${hash}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-storage.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/file-storage/file-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAA6B;AAC7B,6DAMqC;AACrC,iDAA2D;AAE3D,2BAOY;AACZ,mDAA8C;AAC9C,iEAIuC;AAEvC,mCAAoC;AAEpC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAEzD,MAAa,WAAW;
|
|
1
|
+
{"version":3,"file":"file-storage.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/file-storage/file-storage.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6BAA6B;AAC7B,6DAMqC;AACrC,iDAA2D;AAE3D,2BAOY;AACZ,mDAA8C;AAC9C,iEAIuC;AAEvC,mCAAoC;AAEpC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAC/B,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AAC3B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAEzD,MAAa,WAAW;IAGtB,YACmB,UAAyB,EACzB,aAA+B,EAC/B,8BAAuC,EACvC,aAAsB;QAHtB,eAAU,GAAV,UAAU,CAAe;QACzB,kBAAa,GAAb,aAAa,CAAkB;QAC/B,mCAA8B,GAA9B,8BAA8B,CAAS;QACvC,kBAAa,GAAb,aAAa,CAAS;QANzC,YAAO,GAAoC,EAAE,CAAC;IAO3C,CAAC;IAEE,QAAQ,CACZ,IAAY,EACZ,GAAW,EACX,cAAsB;;YAEtB,IAAI,6BAAe,EAAE;gBACnB,MAAM,CAAC,IAAI,CAAC;oBACV,KAAK,EAAE,yBAAyB,IAAI,EAAE;oBACtC,SAAS,EAAE,CAAC,kBAAkB,GAAG,EAAE,CAAC;iBACrC,CAAC,CAAC;aACJ;YACD,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;YACtD,MAAM,cAAc,GAAG,IAAI,CAAC,oBAAoB,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;YACvE,IAAI;gBACF,MAAM,IAAI,CAAC,YAAY,CAAC,GAA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M,EAAE;gBACf,QAAQ,CAAC,YAAY,CACnB,CAAA,MAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,cAAc,0CAAE,QAAQ;oBACzB,CAAC,CAAC,IAAA,kCAAkB,EAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC;oBAC/C,CAAC,CAAC,yCAAyB,CAC9B,CAAC;gBACF,MAAM,CAAC,CAAC;aACT;;KACF;IAEO,WAAW,CAAC,IAAY;QAC9B,MAAM,MAAM,GAAG,IAAA,mBAAU,EAAC,KAAK,CAAC,CAAC;QACjC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpB,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC;IAEO,oBAAoB,CAAC,GAAW,EAAE,OAAe;QACvD,MAAM,sBAAsB,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;QACtD,MAAM,OAAO,GAAG;YACd,cAAc,EAAE,0BAA0B;YAC1C,gBAAgB,EAAE,WAAW;SAC9B,CAAC;QAEF,IAAI,sBAAsB,EAAE;YAC1B,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC;SAClC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AAvRD,kCAuRC"}
|
|
@@ -1 +1,156 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CloudEnabledLifeCycle = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const fs_1 = require("fs");
|
|
7
|
+
const environment_1 = require("../../../utilities/environment");
|
|
8
|
+
const serializer_overrides_1 = require("../../../utilities/serializer-overrides");
|
|
9
|
+
const { workspaceRoot } = require('../../../utilities/nx-imports');
|
|
10
|
+
class CloudEnabledLifeCycle {
|
|
11
|
+
constructor(runContext, cacheDirectory, skipNxCache, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
|
|
12
|
+
this.runContext = runContext;
|
|
13
|
+
this.cacheDirectory = cacheDirectory;
|
|
14
|
+
this.skipNxCache = skipNxCache;
|
|
15
|
+
this.collectTerminalOutput = collectTerminalOutput;
|
|
16
|
+
this.cacheableOperations = cacheableOperations;
|
|
17
|
+
this.outputObfuscator = outputObfuscator;
|
|
18
|
+
this.tasks = tasks;
|
|
19
|
+
}
|
|
20
|
+
scheduleTask(task) {
|
|
21
|
+
this.runContext.scheduledTasks.push(task);
|
|
22
|
+
}
|
|
23
|
+
startTask(task) {
|
|
24
|
+
this.tasks.push({
|
|
25
|
+
taskId: task.id,
|
|
26
|
+
startTime: new Date().toISOString(),
|
|
27
|
+
target: task.target.target,
|
|
28
|
+
projectName: task.target.project,
|
|
29
|
+
hash: task.hash,
|
|
30
|
+
hashDetails: this.cleanUpHashDetails(task.hashDetails),
|
|
31
|
+
params: (0, serializer_overrides_1.serializeOverrides)(task),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// Used for older version for Nx. Remove in Dec 2022
|
|
35
|
+
endTask(task, code) {
|
|
36
|
+
let cacheStatus;
|
|
37
|
+
if (this.runContext.statuses[task.hash]) {
|
|
38
|
+
cacheStatus = this.runContext.statuses[task.hash];
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
if (this.cacheableOperations.indexOf(task.target.target) > -1 &&
|
|
42
|
+
!this.skipNxCache) {
|
|
43
|
+
cacheStatus = 'local-cache-hit';
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
cacheStatus = 'cache-miss';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
this.updateStartedTask(task, code, cacheStatus);
|
|
50
|
+
}
|
|
51
|
+
endTasks(tasks) {
|
|
52
|
+
for (let t of tasks) {
|
|
53
|
+
let cacheStatus;
|
|
54
|
+
const taskIsRemoteCacheHit = t.status === 'remote-cache';
|
|
55
|
+
const taskIsLocalCacheHitPreNx135 = t.status === 'cache';
|
|
56
|
+
const taskIsLocalCacheHit = t.status === 'local-cache' ||
|
|
57
|
+
t.status === 'local-cache-kept-existing' ||
|
|
58
|
+
taskIsLocalCacheHitPreNx135;
|
|
59
|
+
if (this.runContext.statuses[t.task.hash]) {
|
|
60
|
+
cacheStatus = this.runContext.statuses[t.task.hash];
|
|
61
|
+
}
|
|
62
|
+
else if (taskIsRemoteCacheHit) {
|
|
63
|
+
cacheStatus = 'remote-cache-hit';
|
|
64
|
+
}
|
|
65
|
+
else if (taskIsLocalCacheHit) {
|
|
66
|
+
cacheStatus = 'local-cache-hit';
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
if (this.cacheableOperations.indexOf(t.task.target.target) > -1 &&
|
|
70
|
+
!this.skipNxCache) {
|
|
71
|
+
cacheStatus = 'local-cache-hit';
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
cacheStatus = 'cache-miss';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this.updateStartedTask(t.task, t.code, cacheStatus);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
endCommand() { }
|
|
81
|
+
updateStartedTask(task, code, cacheStatus) {
|
|
82
|
+
const startedTask = this.tasks.find((t) => t.taskId === task.id);
|
|
83
|
+
if (!startedTask) {
|
|
84
|
+
throw new Error(`Cannot find task ${task.id}`);
|
|
85
|
+
}
|
|
86
|
+
startedTask.endTime = new Date().toISOString();
|
|
87
|
+
startedTask.status = code;
|
|
88
|
+
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
|
|
89
|
+
startedTask.cacheStatus = cacheStatus;
|
|
90
|
+
if (this.collectTerminalOutput) {
|
|
91
|
+
startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
getTerminalOutput(hash, cacheStatus, code) {
|
|
95
|
+
let dir;
|
|
96
|
+
if (this.cacheDirectory) {
|
|
97
|
+
if (this.cacheDirectory.startsWith('./')) {
|
|
98
|
+
dir = (0, path_1.join)(workspaceRoot, this.cacheDirectory);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
dir = this.cacheDirectory;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
dir = (0, path_1.join)(workspaceRoot, 'node_modules', '.cache', 'nx');
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const taskOutput = this.readTerminalOutputFile(dir, hash);
|
|
109
|
+
const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
|
|
110
|
+
if (environment_1.NX_CLOUD_UNLIMITED_OUTPUT)
|
|
111
|
+
return taskOutputSanitized;
|
|
112
|
+
const maxCharacters = cacheStatus === 'cache-miss'
|
|
113
|
+
? code === 0
|
|
114
|
+
? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
|
|
115
|
+
: CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
|
|
116
|
+
: CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
|
|
117
|
+
return taskOutputSanitized.length > maxCharacters
|
|
118
|
+
? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
|
|
119
|
+
: taskOutputSanitized;
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
return '';
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
cleanUpHashDetails(hashDetails) {
|
|
126
|
+
const nodes = {};
|
|
127
|
+
Object.keys(hashDetails.nodes)
|
|
128
|
+
.filter((k) => !k.startsWith('npm:'))
|
|
129
|
+
.forEach((k) => {
|
|
130
|
+
nodes[k] = hashDetails.nodes[k];
|
|
131
|
+
});
|
|
132
|
+
return {
|
|
133
|
+
nodes,
|
|
134
|
+
runtime: hashDetails.runtime,
|
|
135
|
+
implicitDeps: hashDetails.implicitDeps,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
readTerminalOutputFile(dir, hash) {
|
|
139
|
+
try {
|
|
140
|
+
return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
|
|
141
|
+
}
|
|
142
|
+
catch (_a) {
|
|
143
|
+
try {
|
|
144
|
+
return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
|
|
145
|
+
}
|
|
146
|
+
catch (_b) {
|
|
147
|
+
return '';
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
|
|
153
|
+
CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
|
|
154
|
+
CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
|
|
155
|
+
CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 20000;
|
|
156
|
+
//# sourceMappingURL=cloud-enabled-life-cycle.js.map
|