@nrwl/nx-cloud 13.3.0-beta.0 → 13.3.1
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/bin/nx-cloud.js +7 -0
- package/bin/nx-cloud.js.map +1 -1
- package/lib/core/api/run-group.api.js +1 -65
- package/lib/core/commands/record-output.d.ts +16 -0
- package/lib/core/commands/record-output.js +203 -0
- package/lib/core/commands/record-output.js.map +1 -0
- package/lib/core/runners/cloud-enabled/cloud-enabled-life-cycle.js +1 -138
- package/lib/core/runners/cloud-enabled/cloud-enabled.runner.js +1 -166
- package/lib/core/runners/cloud-enabled/cloud-remote-cache.js +1 -113
- package/lib/core/runners/cloud-enabled/cloud-run.api.js +1 -158
- package/lib/core/runners/distributed-agent/distributed-agent.api.js +1 -79
- package/lib/core/runners/distributed-agent/distributed-agent.impl.js +1 -239
- package/lib/core/runners/distributed-execution/distributed-execution.api.js +1 -130
- package/lib/core/runners/distributed-execution/distributed-execution.runner.js +1 -306
- package/package.json +3 -2
package/bin/nx-cloud.js
CHANGED
|
@@ -5,6 +5,7 @@ const distributed_agent_impl_1 = require("../lib/core/runners/distributed-agent/
|
|
|
5
5
|
const start_ci_run_1 = require("../lib/core/commands/start-ci-run");
|
|
6
6
|
const stop_all_agents_1 = require("../lib/core/commands/stop-all-agents");
|
|
7
7
|
const clean_up_agents_1 = require("../lib/core/commands/clean-up-agents");
|
|
8
|
+
const record_output_1 = require("../lib/core/commands/record-output");
|
|
8
9
|
const command = process.argv[2];
|
|
9
10
|
if (command === 'start-agent') {
|
|
10
11
|
(0, distributed_agent_impl_1.startAgent)().catch((e) => {
|
|
@@ -30,6 +31,12 @@ else if (command === 'clean-up-agents') {
|
|
|
30
31
|
process.exit(1);
|
|
31
32
|
});
|
|
32
33
|
}
|
|
34
|
+
else if (command === 'record') {
|
|
35
|
+
(0, record_output_1.runCommandAndStoreInCloud)().catch((e) => {
|
|
36
|
+
console.error(e);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
33
40
|
else {
|
|
34
41
|
console.log('Pass start-agent, stop-all-agents, or clean-up-agents');
|
|
35
42
|
}
|
package/bin/nx-cloud.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nx-cloud.js","sourceRoot":"","sources":["../../../../../libs/nx-packages/nx-cloud/bin/nx-cloud.ts"],"names":[],"mappings":";;;AAEA,yGAA0F;AAC1F,oEAA+D;AAC/D,0EAAqE;AACrE,0EAAqE;
|
|
1
|
+
{"version":3,"file":"nx-cloud.js","sourceRoot":"","sources":["../../../../../libs/nx-packages/nx-cloud/bin/nx-cloud.ts"],"names":[],"mappings":";;;AAEA,yGAA0F;AAC1F,oEAA+D;AAC/D,0EAAqE;AACrE,0EAAqE;AACrE,sEAA+E;AAE/E,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAEhC,IAAI,OAAO,KAAK,aAAa,EAAE;IAC7B,IAAA,mCAAU,GAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;CACJ;KAAM,IAAI,OAAO,KAAK,iBAAiB,EAAE;IACxC,IAAA,+BAAa,GAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;CACJ;KAAM,IAAI,OAAO,KAAK,cAAc,EAAE;IACrC,IAAA,yBAAU,GAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACvB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;CACJ;KAAM,IAAI,OAAO,KAAK,iBAAiB,EAAE;IACxC,IAAA,+BAAa,GAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;CACJ;KAAM,IAAI,OAAO,KAAK,QAAQ,EAAE;IAC/B,IAAA,yCAAyB,GAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QACtC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;CACJ;KAAM;IACL,OAAO,CAAC,GAAG,CAAC,uDAAuD,CAAC,CAAC;CACtE"}
|
|
@@ -1,65 +1 @@
|
|
|
1
|
-
|
|
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) {
|
|
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: branch,
|
|
27
|
-
runGroup: runGroup,
|
|
28
|
-
}));
|
|
29
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
33
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
34
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
35
|
-
output.error({
|
|
36
|
-
title: e.message,
|
|
37
|
-
});
|
|
38
|
-
process.exit(1);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
completeRunGroup(runGroup) {
|
|
43
|
-
var _a;
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const recorder = (0, metric_logger_1.createMetricRecorder)('createRunGroup');
|
|
46
|
-
try {
|
|
47
|
-
const resp = yield (0, axios_1.axiosMultipleTries)(() => this.apiAxiosInstance.post('/nx-cloud/executions/complete-run-group', {
|
|
48
|
-
runGroup: runGroup,
|
|
49
|
-
}));
|
|
50
|
-
recorder.recordMetric((0, metric_logger_1.mapRespToPerfEntry)(resp));
|
|
51
|
-
}
|
|
52
|
-
catch (e) {
|
|
53
|
-
recorder.recordMetric(((_a = e === null || e === void 0 ? void 0 : e.axiosException) === null || _a === void 0 ? void 0 : _a.response)
|
|
54
|
-
? (0, metric_logger_1.mapRespToPerfEntry)(e.axiosException.response)
|
|
55
|
-
: metric_logger_1.RUNNER_FAILURE_PERF_ENTRY);
|
|
56
|
-
output.error({
|
|
57
|
-
title: e.message,
|
|
58
|
-
});
|
|
59
|
-
process.exit(1);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.RunGroupApi = RunGroupApi;
|
|
65
|
-
//# sourceMappingURL=run-group.api.js.map
|
|
1
|
+
const a0_0x4db5=['../../utilities/nx-imports','mapRespToPerfEntry','/nx-cloud/executions/complete-run-group','RUNNER_FAILURE_PERF_ENTRY','createMetricRecorder','exit','error','../../utilities/axios','createRunGroup','message','post','done','defineProperty','__awaiter','next','recordMetric','apiAxiosInstance','apply','throw','createApiAxiosInstance','value','completeRunGroup','RunGroupApi','axiosMultipleTries','then','axiosException','../../utilities/metric-logger','response'];(function(_0x2caff5,_0x4db52a){const _0x1b4cf0=function(_0x249f4e){while(--_0x249f4e){_0x2caff5['push'](_0x2caff5['shift']());}};_0x1b4cf0(++_0x4db52a);}(a0_0x4db5,0x11f));const a0_0x1b4c=function(_0x2caff5,_0x4db52a){_0x2caff5=_0x2caff5-0x0;let _0x1b4cf0=a0_0x4db5[_0x2caff5];return _0x1b4cf0;};'use strict';var __awaiter=this&&this[a0_0x1b4c('0x6')]||function(_0x3b02d9,_0x46a2f4,_0x4a0179,_0x111ea2){function _0x82bc8a(_0x2780c8){return _0x2780c8 instanceof _0x4a0179?_0x2780c8:new _0x4a0179(function(_0x11cc0e){_0x11cc0e(_0x2780c8);});}return new(_0x4a0179||(_0x4a0179=Promise))(function(_0x5280d8,_0x231f30){function _0x377e03(_0x26fb1f){try{_0x1369af(_0x111ea2[a0_0x1b4c('0x7')](_0x26fb1f));}catch(_0x2beaec){_0x231f30(_0x2beaec);}}function _0x16350d(_0x36f2ea){try{_0x1369af(_0x111ea2[a0_0x1b4c('0xb')](_0x36f2ea));}catch(_0xf8d209){_0x231f30(_0xf8d209);}}function _0x1369af(_0x1c7435){_0x1c7435[a0_0x1b4c('0x4')]?_0x5280d8(_0x1c7435[a0_0x1b4c('0xd')]):_0x82bc8a(_0x1c7435[a0_0x1b4c('0xd')])[a0_0x1b4c('0x11')](_0x377e03,_0x16350d);}_0x1369af((_0x111ea2=_0x111ea2[a0_0x1b4c('0xa')](_0x3b02d9,_0x46a2f4||[]))[a0_0x1b4c('0x7')]());});};Object[a0_0x1b4c('0x5')](exports,'__esModule',{'value':!![]});exports[a0_0x1b4c('0xf')]=void 0x0;const axios_1=require(a0_0x1b4c('0x0'));const metric_logger_1=require(a0_0x1b4c('0x13'));const {output}=require(a0_0x1b4c('0x15'));class RunGroupApi{constructor(_0xc99419){this[a0_0x1b4c('0x9')]=(0x0,axios_1[a0_0x1b4c('0xc')])(_0xc99419);}[a0_0x1b4c('0x1')](_0x48afbf,_0x1b0fec){var _0x17c9c2;return __awaiter(this,void 0x0,void 0x0,function*(){const _0x448139=(0x0,metric_logger_1[a0_0x1b4c('0x19')])('createRunGroup');try{const _0x8fce58=yield(0x0,axios_1[a0_0x1b4c('0x10')])(()=>this[a0_0x1b4c('0x9')][a0_0x1b4c('0x3')]('/nx-cloud/executions/create-run-group',{'branch':_0x48afbf,'runGroup':_0x1b0fec}));_0x448139[a0_0x1b4c('0x8')]((0x0,metric_logger_1[a0_0x1b4c('0x16')])(_0x8fce58));}catch(_0x46896b){_0x448139['recordMetric'](((_0x17c9c2=_0x46896b===null||_0x46896b===void 0x0?void 0x0:_0x46896b['axiosException'])===null||_0x17c9c2===void 0x0?void 0x0:_0x17c9c2[a0_0x1b4c('0x14')])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x46896b['axiosException'][a0_0x1b4c('0x14')]):metric_logger_1[a0_0x1b4c('0x18')]);output[a0_0x1b4c('0x1b')]({'title':_0x46896b[a0_0x1b4c('0x2')]});process[a0_0x1b4c('0x1a')](0x1);}});}[a0_0x1b4c('0xe')](_0x254d54){var _0x1eea5f;return __awaiter(this,void 0x0,void 0x0,function*(){const _0xc45b66=(0x0,metric_logger_1['createMetricRecorder'])(a0_0x1b4c('0x1'));try{const _0xd29b4b=yield(0x0,axios_1[a0_0x1b4c('0x10')])(()=>this[a0_0x1b4c('0x9')]['post'](a0_0x1b4c('0x17'),{'runGroup':_0x254d54}));_0xc45b66['recordMetric']((0x0,metric_logger_1['mapRespToPerfEntry'])(_0xd29b4b));}catch(_0x1426ce){_0xc45b66[a0_0x1b4c('0x8')](((_0x1eea5f=_0x1426ce===null||_0x1426ce===void 0x0?void 0x0:_0x1426ce[a0_0x1b4c('0x12')])===null||_0x1eea5f===void 0x0?void 0x0:_0x1eea5f['response'])?(0x0,metric_logger_1['mapRespToPerfEntry'])(_0x1426ce[a0_0x1b4c('0x12')][a0_0x1b4c('0x14')]):metric_logger_1['RUNNER_FAILURE_PERF_ENTRY']);output[a0_0x1b4c('0x1b')]({'title':_0x1426ce[a0_0x1b4c('0x2')]});process[a0_0x1b4c('0x1a')](0x1);}});}}exports[a0_0x1b4c('0xf')]=RunGroupApi;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function runCommandAndStoreInCloud(): Promise<void>;
|
|
2
|
+
/**
|
|
3
|
+
* https://github.com/nrwl/nx/blob/master/packages/nx/src/utils/find-workspace-root.ts
|
|
4
|
+
* Recursive function that walks back up the directory
|
|
5
|
+
* tree to try and find a workspace file.
|
|
6
|
+
*
|
|
7
|
+
* @param dir Directory to start searching with
|
|
8
|
+
*/
|
|
9
|
+
export declare function findWorkspaceRoot(dir: string): WorkspaceTypeAndRoot | null;
|
|
10
|
+
/**
|
|
11
|
+
* https://github.com/nrwl/nx/blob/master/packages/nx/src/utils/find-workspace-root.ts
|
|
12
|
+
*/
|
|
13
|
+
export interface WorkspaceTypeAndRoot {
|
|
14
|
+
type: 'nx' | 'angular';
|
|
15
|
+
dir: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
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.findWorkspaceRoot = exports.runCommandAndStoreInCloud = void 0;
|
|
13
|
+
const cp = require("child_process");
|
|
14
|
+
const fs_1 = require("fs");
|
|
15
|
+
const path = require("path");
|
|
16
|
+
const environment_1 = require("../../utilities/environment");
|
|
17
|
+
const axios_1 = require("../../utilities/axios");
|
|
18
|
+
const util_1 = require("util");
|
|
19
|
+
const zlib_1 = require("zlib");
|
|
20
|
+
const output_obfuscator_1 = require("../terminal-output/output-obfuscator");
|
|
21
|
+
const print_message_1 = require("../../utilities/print-message");
|
|
22
|
+
const { output } = require('../../utilities/nx-imports');
|
|
23
|
+
const MAX_CHARACTERS_OUTPUT_CAPTURE = 200000;
|
|
24
|
+
function runCommandAndStoreInCloud() {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
const taskRunnerOptions = getTaskRunnerOptions();
|
|
27
|
+
const axios = (0, axios_1.createApiAxiosInstance)(taskRunnerOptions);
|
|
28
|
+
const outputObfuscator = new output_obfuscator_1.OutputObfuscator(taskRunnerOptions.maskedProperties);
|
|
29
|
+
const branch = (0, environment_1.getBranch)();
|
|
30
|
+
const runGroup = (0, environment_1.getRunGroup)();
|
|
31
|
+
let userCommandAndArgs;
|
|
32
|
+
const commandStartIndex = process.argv.findIndex((arg) => arg === 'record') + 1;
|
|
33
|
+
if (commandStartIndex < process.argv.length) {
|
|
34
|
+
// Different package managers may remove not the "--" from the command automatically, so account for that
|
|
35
|
+
const sliceOffset = process.argv[commandStartIndex] === '--' ? 1 : 0;
|
|
36
|
+
userCommandAndArgs = process.argv.slice(commandStartIndex + sliceOffset);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
console.log('Invalid command. Use `nx-cloud record [my command] [my arg1] [my arg...]`');
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
const [userCommand, ...userArgs] = userCommandAndArgs;
|
|
43
|
+
const startRecordRunRequest = {
|
|
44
|
+
branch,
|
|
45
|
+
runGroup,
|
|
46
|
+
hashes: [],
|
|
47
|
+
};
|
|
48
|
+
yield (0, axios_1.axiosMultipleTries)(() => axios.post('/nx-cloud/runs/start', startRecordRunRequest));
|
|
49
|
+
const startTime = new Date().toISOString();
|
|
50
|
+
const { statusCode, terminalOutput } = yield spawnUserCommandAndCaptureOutput(userCommand, userArgs);
|
|
51
|
+
const endTime = new Date().toISOString();
|
|
52
|
+
const endRecordOutputRunParams = {
|
|
53
|
+
statusCode,
|
|
54
|
+
terminalOutput,
|
|
55
|
+
userCommandAndArgsString: userCommandAndArgs.join(' '),
|
|
56
|
+
startTime,
|
|
57
|
+
endTime,
|
|
58
|
+
branch,
|
|
59
|
+
runGroup,
|
|
60
|
+
};
|
|
61
|
+
yield endRecordOutputRun(axios, outputObfuscator, taskRunnerOptions, endRecordOutputRunParams);
|
|
62
|
+
process.exit(statusCode);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
exports.runCommandAndStoreInCloud = runCommandAndStoreInCloud;
|
|
66
|
+
function getTaskRunnerOptions() {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
const workspaceRoot = findWorkspaceRoot(process.cwd());
|
|
69
|
+
if (workspaceRoot == null) {
|
|
70
|
+
throw new Error('Unable to locate task runner options.');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const taskRunnerOptions = (_c = (_b = (_a = require(`${workspaceRoot.dir}/nx.json`)) === null || _a === void 0 ? void 0 : _a.tasksRunnerOptions) === null || _b === void 0 ? void 0 : _b.default) === null || _c === void 0 ? void 0 : _c.options;
|
|
74
|
+
return taskRunnerOptions;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function splitUserCommandAndArgs(userCommandAndArgs) {
|
|
78
|
+
const userCommand = userCommandAndArgs[0];
|
|
79
|
+
let userArgs = [];
|
|
80
|
+
if (userCommandAndArgs.length > 1) {
|
|
81
|
+
userArgs = userCommandAndArgs.slice(1);
|
|
82
|
+
}
|
|
83
|
+
return { userCommand, userArgs };
|
|
84
|
+
}
|
|
85
|
+
function spawnUserCommandAndCaptureOutput(command, args) {
|
|
86
|
+
return new Promise((res, rej) => {
|
|
87
|
+
try {
|
|
88
|
+
const userCommandProcess = cp.spawn(command, args, {
|
|
89
|
+
stdio: ['inherit', 'pipe', 'pipe', 'ipc'],
|
|
90
|
+
});
|
|
91
|
+
const outLines = [];
|
|
92
|
+
userCommandProcess.stdout.on('data', (chunk) => {
|
|
93
|
+
process.stdout.write(chunk);
|
|
94
|
+
outLines.push(chunk.toString());
|
|
95
|
+
});
|
|
96
|
+
userCommandProcess.stderr.on('data', (chunk) => {
|
|
97
|
+
process.stderr.write(chunk);
|
|
98
|
+
outLines.push(chunk.toString());
|
|
99
|
+
});
|
|
100
|
+
userCommandProcess.on('exit', (exitCode, exitSignal) => {
|
|
101
|
+
const statusCode = exitCode !== null && exitCode !== void 0 ? exitCode : signalToCode(exitSignal || '');
|
|
102
|
+
const joinedOutput = outLines.join('');
|
|
103
|
+
res({
|
|
104
|
+
statusCode,
|
|
105
|
+
terminalOutput: joinedOutput,
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
catch (e) {
|
|
110
|
+
rej(e);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function createTaskDefinitionFromUserCommand(outputObfuscator, params) {
|
|
115
|
+
const sanitizedOutput = outputObfuscator.obfuscate(params.terminalOutput);
|
|
116
|
+
const truncatedOutput = sanitizedOutput.length > MAX_CHARACTERS_OUTPUT_CAPTURE
|
|
117
|
+
? `TRUNCATED\n\n${sanitizedOutput.slice(sanitizedOutput.length - MAX_CHARACTERS_OUTPUT_CAPTURE)}`
|
|
118
|
+
: sanitizedOutput;
|
|
119
|
+
return {
|
|
120
|
+
taskId: 'nx-cloud-tasks-runner:record-command',
|
|
121
|
+
target: 'record-command',
|
|
122
|
+
projectName: 'nx-cloud-tasks-runner',
|
|
123
|
+
hash: '',
|
|
124
|
+
startTime: params.startTime,
|
|
125
|
+
endTime: params.endTime,
|
|
126
|
+
hashDetails: {},
|
|
127
|
+
params: params.userCommandAndArgsString,
|
|
128
|
+
cacheStatus: 'n/a',
|
|
129
|
+
status: params.statusCode,
|
|
130
|
+
terminalOutput: truncatedOutput,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
function endRecordOutputRun(axios, obfuscator, taskRunnerOptions, params) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
const commandWithPrefix = `nx-cloud record -- ${params.userCommandAndArgsString}`;
|
|
136
|
+
const endRunReq = {
|
|
137
|
+
meta: {
|
|
138
|
+
nxCloudVersion: '0.0.0',
|
|
139
|
+
},
|
|
140
|
+
tasks: [createTaskDefinitionFromUserCommand(obfuscator, params)],
|
|
141
|
+
run: {
|
|
142
|
+
command: commandWithPrefix,
|
|
143
|
+
startTime: params.startTime,
|
|
144
|
+
endTime: params.endTime,
|
|
145
|
+
branch: params.branch,
|
|
146
|
+
scan: true,
|
|
147
|
+
runGroup: params.runGroup,
|
|
148
|
+
// only set sha if branch is set because we invoke a separate process,
|
|
149
|
+
// which adds a few millis
|
|
150
|
+
sha: params.branch ? (0, environment_1.extractGitSha)() : undefined,
|
|
151
|
+
},
|
|
152
|
+
machineInfo: (0, environment_1.getMachineInfo)(taskRunnerOptions),
|
|
153
|
+
};
|
|
154
|
+
const uncompressedBuffer = Buffer.from(JSON.stringify(endRunReq));
|
|
155
|
+
const compressedBuffer = yield (0, util_1.promisify)(zlib_1.gzip)(uncompressedBuffer);
|
|
156
|
+
const endRunResp = yield (0, axios_1.axiosMultipleTries)(() => axios.post('/nx-cloud/runs/end', compressedBuffer, {
|
|
157
|
+
headers: Object.assign(Object.assign({}, axios.defaults.headers), { 'Content-Encoding': 'gzip', 'Content-Type': 'application/octet-stream' }),
|
|
158
|
+
}));
|
|
159
|
+
printRecordOutputRunEndMessage(endRunResp.data.runUrl);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function printRecordOutputRunEndMessage(runUrl) {
|
|
163
|
+
output.addVerticalSeparator();
|
|
164
|
+
output.note({ title: 'Nx Cloud: Successfully recorded command output' });
|
|
165
|
+
(0, print_message_1.printMessage)(`You can view or share your output by visiting ${runUrl}`);
|
|
166
|
+
}
|
|
167
|
+
// Everything from here down is ripped from the nx package
|
|
168
|
+
// You probably don't want to adjust this manually
|
|
169
|
+
/**
|
|
170
|
+
* https://github.com/nrwl/nx/blob/master/packages/nx/src/utils/find-workspace-root.ts
|
|
171
|
+
* Recursive function that walks back up the directory
|
|
172
|
+
* tree to try and find a workspace file.
|
|
173
|
+
*
|
|
174
|
+
* @param dir Directory to start searching with
|
|
175
|
+
*/
|
|
176
|
+
function findWorkspaceRoot(dir) {
|
|
177
|
+
if ((0, fs_1.existsSync)(path.join(dir, 'angular.json'))) {
|
|
178
|
+
return { type: 'angular', dir };
|
|
179
|
+
}
|
|
180
|
+
if ((0, fs_1.existsSync)(path.join(dir, 'nx.json'))) {
|
|
181
|
+
return { type: 'nx', dir };
|
|
182
|
+
}
|
|
183
|
+
if (path.dirname(dir) === dir) {
|
|
184
|
+
return null;
|
|
185
|
+
}
|
|
186
|
+
return findWorkspaceRoot(path.dirname(dir));
|
|
187
|
+
}
|
|
188
|
+
exports.findWorkspaceRoot = findWorkspaceRoot;
|
|
189
|
+
/**
|
|
190
|
+
* https://github.com/nrwl/nx/blob/master/packages/nx/src/tasks-runner/forked-process-task-runner.ts
|
|
191
|
+
*
|
|
192
|
+
* @param signal
|
|
193
|
+
*/
|
|
194
|
+
function signalToCode(signal) {
|
|
195
|
+
if (signal === 'SIGHUP')
|
|
196
|
+
return 128 + 1;
|
|
197
|
+
if (signal === 'SIGINT')
|
|
198
|
+
return 128 + 2;
|
|
199
|
+
if (signal === 'SIGTERM')
|
|
200
|
+
return 128 + 15;
|
|
201
|
+
return 128;
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=record-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record-output.js","sourceRoot":"","sources":["../../../../../../../libs/nx-packages/nx-cloud/lib/core/commands/record-output.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,oCAAoC;AACpC,2BAAgC;AAChC,6BAA6B;AAC7B,6DAKqC;AAErC,iDAG+B;AAC/B,+BAAiC;AACjC,+BAA4B;AAE5B,4EAAwE;AACxE,iEAA6D;AAC7D,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAiBzD,MAAM,6BAA6B,GAAG,MAAO,CAAC;AAE9C,SAAsB,yBAAyB;;QAC7C,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,IAAA,8BAAsB,EAAC,iBAAiB,CAAC,CAAC;QACxD,MAAM,gBAAgB,GAAG,IAAI,oCAAgB,CAC3C,iBAAiB,CAAC,gBAAgB,CACnC,CAAC;QACF,MAAM,MAAM,GAAG,IAAA,uBAAS,GAAE,CAAC;QAC3B,MAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAC;QAE/B,IAAI,kBAAkB,CAAC;QAEvB,MAAM,iBAAiB,GACrB,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC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AC,CAAC;IACxC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,GAAG,GAAG,EAAE,CAAC;IAC1C,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,138 +1 @@
|
|
|
1
|
-
|
|
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 { appRootPath, unparse } = require('../../../utilities/nx-imports');
|
|
8
|
-
class CloudEnabledLifeCycle {
|
|
9
|
-
constructor(runContext, cacheDirectory, skipNxCache, collectTerminalOutput, cacheableOperations, outputObfuscator, tasks) {
|
|
10
|
-
this.runContext = runContext;
|
|
11
|
-
this.cacheDirectory = cacheDirectory;
|
|
12
|
-
this.skipNxCache = skipNxCache;
|
|
13
|
-
this.collectTerminalOutput = collectTerminalOutput;
|
|
14
|
-
this.cacheableOperations = cacheableOperations;
|
|
15
|
-
this.outputObfuscator = outputObfuscator;
|
|
16
|
-
this.tasks = tasks;
|
|
17
|
-
}
|
|
18
|
-
scheduleTask(task) {
|
|
19
|
-
this.runContext.scheduledTasks.push(task);
|
|
20
|
-
}
|
|
21
|
-
startTask(task) {
|
|
22
|
-
const overrides = Object.assign({}, (task.overrides || {}));
|
|
23
|
-
if (task.target.configuration) {
|
|
24
|
-
overrides['configuration'] = task.target.configuration;
|
|
25
|
-
}
|
|
26
|
-
this.tasks.push({
|
|
27
|
-
taskId: task.id,
|
|
28
|
-
startTime: new Date().toISOString(),
|
|
29
|
-
target: task.target.target,
|
|
30
|
-
projectName: task.target.project,
|
|
31
|
-
hash: task.hash,
|
|
32
|
-
hashDetails: this.cleanUpHashDetails(task.hashDetails),
|
|
33
|
-
params: unparse(overrides).join(' '),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
// Used for older version for Nx. Remove in Dec 2022
|
|
37
|
-
endTask(task, code) {
|
|
38
|
-
let cacheStatus;
|
|
39
|
-
if (this.runContext.statuses[task.hash]) {
|
|
40
|
-
cacheStatus = this.runContext.statuses[task.hash];
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
if (this.cacheableOperations.indexOf(task.target.target) > -1 &&
|
|
44
|
-
!this.skipNxCache) {
|
|
45
|
-
cacheStatus = 'local-cache-hit';
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
cacheStatus = 'cache-miss';
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
this.updateStartedTask(task, code, cacheStatus);
|
|
52
|
-
}
|
|
53
|
-
endTasks(tasks) {
|
|
54
|
-
for (let t of tasks) {
|
|
55
|
-
const status = t.status === 'remote-cache'
|
|
56
|
-
? 'remote-cache-hit'
|
|
57
|
-
: t.status === 'local-cache' ||
|
|
58
|
-
t.status === 'local-cache-kept-existing'
|
|
59
|
-
? 'local-cache-hit'
|
|
60
|
-
: 'cache-miss';
|
|
61
|
-
this.updateStartedTask(t.task, t.code, status);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
endCommand() { }
|
|
65
|
-
updateStartedTask(task, code, cacheStatus) {
|
|
66
|
-
const startedTask = this.tasks.find((t) => t.taskId === task.id);
|
|
67
|
-
if (!startedTask) {
|
|
68
|
-
throw new Error(`Cannot find task ${task.id}`);
|
|
69
|
-
}
|
|
70
|
-
startedTask.endTime = new Date().toISOString();
|
|
71
|
-
startedTask.status = code;
|
|
72
|
-
startedTask.params = this.outputObfuscator.obfuscate(startedTask.params);
|
|
73
|
-
startedTask.cacheStatus = cacheStatus;
|
|
74
|
-
if (this.collectTerminalOutput) {
|
|
75
|
-
startedTask.terminalOutput = this.getTerminalOutput(task.hash, startedTask.cacheStatus, code);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
getTerminalOutput(hash, cacheStatus, code) {
|
|
79
|
-
let dir;
|
|
80
|
-
if (this.cacheDirectory) {
|
|
81
|
-
if (this.cacheDirectory.startsWith('./')) {
|
|
82
|
-
dir = (0, path_1.join)(appRootPath, this.cacheDirectory);
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
dir = this.cacheDirectory;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
dir = (0, path_1.join)(appRootPath, 'node_modules', '.cache', 'nx');
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
const taskOutput = this.readTerminalOutputFile(dir, hash);
|
|
93
|
-
const taskOutputSanitized = this.outputObfuscator.obfuscate(taskOutput);
|
|
94
|
-
const maxCharacters = cacheStatus === 'cache-miss'
|
|
95
|
-
? code === 0
|
|
96
|
-
? CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK
|
|
97
|
-
: CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK
|
|
98
|
-
: CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK;
|
|
99
|
-
return taskOutputSanitized.length > maxCharacters
|
|
100
|
-
? `TRUNCATED\n\n${taskOutputSanitized.slice(taskOutputSanitized.length - maxCharacters)}`
|
|
101
|
-
: taskOutputSanitized;
|
|
102
|
-
}
|
|
103
|
-
catch (e) {
|
|
104
|
-
return '';
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
cleanUpHashDetails(hashDetails) {
|
|
108
|
-
const nodes = {};
|
|
109
|
-
Object.keys(hashDetails.nodes)
|
|
110
|
-
.filter((k) => !k.startsWith('npm:'))
|
|
111
|
-
.forEach((k) => {
|
|
112
|
-
nodes[k] = hashDetails.nodes[k];
|
|
113
|
-
});
|
|
114
|
-
return {
|
|
115
|
-
nodes,
|
|
116
|
-
runtime: hashDetails.runtime,
|
|
117
|
-
implicitDeps: hashDetails.implicitDeps,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
readTerminalOutputFile(dir, hash) {
|
|
121
|
-
try {
|
|
122
|
-
return (0, fs_1.readFileSync)(path.join(dir, 'terminalOutputs', hash)).toString();
|
|
123
|
-
}
|
|
124
|
-
catch (_a) {
|
|
125
|
-
try {
|
|
126
|
-
return (0, fs_1.readFileSync)(path.join(dir, hash, 'terminalOutput')).toString();
|
|
127
|
-
}
|
|
128
|
-
catch (_b) {
|
|
129
|
-
return '';
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.CloudEnabledLifeCycle = CloudEnabledLifeCycle;
|
|
135
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_FAILED_TASK = 200000;
|
|
136
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_SUCCESSFUL_TASK = 20000;
|
|
137
|
-
CloudEnabledLifeCycle.MAX_CHARACTERS_CACHED_TASK = 5000;
|
|
138
|
-
//# sourceMappingURL=cloud-enabled-life-cycle.js.map
|
|
1
|
+
const a0_0x5205=['status','readFileSync','CloudEnabledLifeCycle','cache-miss','cacheDirectory','MAX_CHARACTERS_SUCCESSFUL_TASK','TRUNCATED\x0a\x0a','hash','slice','getTerminalOutput','endTasks','implicitDeps','toString','endTask','forEach','configuration','local-cache-kept-existing','skipNxCache','push','outputObfuscator','find','../../../utilities/nx-imports','readTerminalOutputFile','project','local-cache','remote-cache-hit','keys','MAX_CHARACTERS_CACHED_TASK','length','endTime','toISOString','overrides','runtime','params','local-cache-hit','cacheStatus','path','terminalOutput','__esModule','task','taskId','join','statuses','terminalOutputs','collectTerminalOutput','MAX_CHARACTERS_FAILED_TASK','remote-cache','runContext','npm:','tasks','startsWith','Cannot\x20find\x20task\x20','target','obfuscate','code','cleanUpHashDetails','scheduleTask','endCommand','assign','updateStartedTask','indexOf','scheduledTasks','cacheableOperations','defineProperty'];(function(_0x26bdf2,_0x5205c2){const _0x5900b5=function(_0x1cfdf9){while(--_0x1cfdf9){_0x26bdf2['push'](_0x26bdf2['shift']());}};_0x5900b5(++_0x5205c2);}(a0_0x5205,0x6e));const a0_0x5900=function(_0x26bdf2,_0x5205c2){_0x26bdf2=_0x26bdf2-0x0;let _0x5900b5=a0_0x5205[_0x26bdf2];return _0x5900b5;};'use strict';Object[a0_0x5900('0x11')](exports,a0_0x5900('0x38'),{'value':!![]});exports[a0_0x5900('0x14')]=void 0x0;const path=require(a0_0x5900('0x36'));const path_1=require(a0_0x5900('0x36'));const fs_1=require('fs');const {appRootPath,unparse}=require(a0_0x5900('0x27'));class CloudEnabledLifeCycle{constructor(_0x3f49f0,_0x1c3435,_0x33c94a,_0x3ce46e,_0x19c9c6,_0x2b91fe,_0x3adeb1){this[a0_0x5900('0x1')]=_0x3f49f0;this['cacheDirectory']=_0x1c3435;this[a0_0x5900('0x23')]=_0x33c94a;this[a0_0x5900('0x3e')]=_0x3ce46e;this[a0_0x5900('0x10')]=_0x19c9c6;this[a0_0x5900('0x25')]=_0x2b91fe;this['tasks']=_0x3adeb1;}[a0_0x5900('0xa')](_0x51d19a){this[a0_0x5900('0x1')][a0_0x5900('0xf')]['push'](_0x51d19a);}['startTask'](_0x18604d){const _0x1e299f=Object[a0_0x5900('0xc')]({},_0x18604d[a0_0x5900('0x31')]||{});if(_0x18604d[a0_0x5900('0x6')][a0_0x5900('0x21')]){_0x1e299f['configuration']=_0x18604d[a0_0x5900('0x6')][a0_0x5900('0x21')];}this[a0_0x5900('0x3')][a0_0x5900('0x24')]({'taskId':_0x18604d['id'],'startTime':new Date()[a0_0x5900('0x30')](),'target':_0x18604d[a0_0x5900('0x6')]['target'],'projectName':_0x18604d[a0_0x5900('0x6')][a0_0x5900('0x29')],'hash':_0x18604d['hash'],'hashDetails':this[a0_0x5900('0x9')](_0x18604d['hashDetails']),'params':unparse(_0x1e299f)['join']('\x20')});}[a0_0x5900('0x1f')](_0x53668b,_0x2d2490){let _0x57cdd8;if(this[a0_0x5900('0x1')][a0_0x5900('0x3c')][_0x53668b[a0_0x5900('0x19')]]){_0x57cdd8=this['runContext'][a0_0x5900('0x3c')][_0x53668b[a0_0x5900('0x19')]];}else{if(this[a0_0x5900('0x10')][a0_0x5900('0xe')](_0x53668b[a0_0x5900('0x6')][a0_0x5900('0x6')])>-0x1&&!this['skipNxCache']){_0x57cdd8='local-cache-hit';}else{_0x57cdd8='cache-miss';}}this[a0_0x5900('0xd')](_0x53668b,_0x2d2490,_0x57cdd8);}[a0_0x5900('0x1c')](_0xd4b27){for(let _0x5c8f25 of _0xd4b27){const _0x6e8e36=_0x5c8f25[a0_0x5900('0x12')]===a0_0x5900('0x0')?a0_0x5900('0x2b'):_0x5c8f25[a0_0x5900('0x12')]===a0_0x5900('0x2a')||_0x5c8f25['status']===a0_0x5900('0x22')?a0_0x5900('0x34'):a0_0x5900('0x15');this[a0_0x5900('0xd')](_0x5c8f25[a0_0x5900('0x39')],_0x5c8f25[a0_0x5900('0x8')],_0x6e8e36);}}[a0_0x5900('0xb')](){}['updateStartedTask'](_0x59e232,_0x5f44cd,_0x575365){const _0x154782=this[a0_0x5900('0x3')][a0_0x5900('0x26')](_0x3b965d=>_0x3b965d[a0_0x5900('0x3a')]===_0x59e232['id']);if(!_0x154782){throw new Error(a0_0x5900('0x5')+_0x59e232['id']);}_0x154782[a0_0x5900('0x2f')]=new Date()[a0_0x5900('0x30')]();_0x154782['status']=_0x5f44cd;_0x154782[a0_0x5900('0x33')]=this[a0_0x5900('0x25')]['obfuscate'](_0x154782[a0_0x5900('0x33')]);_0x154782[a0_0x5900('0x35')]=_0x575365;if(this[a0_0x5900('0x3e')]){_0x154782[a0_0x5900('0x37')]=this[a0_0x5900('0x1b')](_0x59e232['hash'],_0x154782[a0_0x5900('0x35')],_0x5f44cd);}}['getTerminalOutput'](_0x32c1fe,_0x549e7a,_0x19cbfe){let _0x2be8f9;if(this['cacheDirectory']){if(this[a0_0x5900('0x16')][a0_0x5900('0x4')]('./')){_0x2be8f9=(0x0,path_1[a0_0x5900('0x3b')])(appRootPath,this[a0_0x5900('0x16')]);}else{_0x2be8f9=this[a0_0x5900('0x16')];}}else{_0x2be8f9=(0x0,path_1[a0_0x5900('0x3b')])(appRootPath,'node_modules','.cache','nx');}try{const _0x13d8ab=this[a0_0x5900('0x28')](_0x2be8f9,_0x32c1fe);const _0x32fb5a=this[a0_0x5900('0x25')][a0_0x5900('0x7')](_0x13d8ab);const _0x47b613=_0x549e7a===a0_0x5900('0x15')?_0x19cbfe===0x0?CloudEnabledLifeCycle[a0_0x5900('0x17')]:CloudEnabledLifeCycle[a0_0x5900('0x3f')]:CloudEnabledLifeCycle[a0_0x5900('0x2d')];return _0x32fb5a[a0_0x5900('0x2e')]>_0x47b613?a0_0x5900('0x18')+_0x32fb5a[a0_0x5900('0x1a')](_0x32fb5a[a0_0x5900('0x2e')]-_0x47b613):_0x32fb5a;}catch(_0x2e9f50){return'';}}[a0_0x5900('0x9')](_0x1e5962){const _0x501be5={};Object[a0_0x5900('0x2c')](_0x1e5962['nodes'])['filter'](_0x100e6c=>!_0x100e6c[a0_0x5900('0x4')](a0_0x5900('0x2')))[a0_0x5900('0x20')](_0x2243e2=>{_0x501be5[_0x2243e2]=_0x1e5962['nodes'][_0x2243e2];});return{'nodes':_0x501be5,'runtime':_0x1e5962[a0_0x5900('0x32')],'implicitDeps':_0x1e5962[a0_0x5900('0x1d')]};}['readTerminalOutputFile'](_0x4e9fbf,_0x32f234){try{return(0x0,fs_1[a0_0x5900('0x13')])(path[a0_0x5900('0x3b')](_0x4e9fbf,a0_0x5900('0x3d'),_0x32f234))['toString']();}catch(_0x285905){try{return(0x0,fs_1[a0_0x5900('0x13')])(path['join'](_0x4e9fbf,_0x32f234,a0_0x5900('0x37')))[a0_0x5900('0x1e')]();}catch(_0x1f02bf){return'';}}}}exports[a0_0x5900('0x14')]=CloudEnabledLifeCycle;CloudEnabledLifeCycle['MAX_CHARACTERS_FAILED_TASK']=0x30d40;CloudEnabledLifeCycle[a0_0x5900('0x17')]=0x4e20;CloudEnabledLifeCycle['MAX_CHARACTERS_CACHED_TASK']=0x1388;
|