@testim/testim-cli 3.289.0 → 3.290.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/cli.js +22390 -122
- package/cli.js.map +1 -0
- package/npm-shrinkwrap.json +1951 -203
- package/package.json +9 -5
- package/OverrideTestDataBuilder.js +0 -117
- package/agent/routers/cliJsCode/index.js +0 -13
- package/agent/routers/cliJsCode/router.js +0 -63
- package/agent/routers/cliJsCode/service.js +0 -705
- package/agent/routers/codim/router.js +0 -69
- package/agent/routers/codim/router.test.js +0 -60
- package/agent/routers/codim/service.js +0 -193
- package/agent/routers/general/index.js +0 -36
- package/agent/routers/hybrid/registerRoutes.js +0 -81
- package/agent/routers/index.js +0 -56
- package/agent/routers/playground/router.js +0 -77
- package/agent/routers/playground/service.js +0 -96
- package/agent/routers/standalone-browser/registerRoutes.js +0 -47
- package/agent/server.js +0 -150
- package/cdpTestRunner.js +0 -86
- package/chromiumInstaller.js +0 -91
- package/cli/isCiRun.js +0 -10
- package/cli/onExit.js +0 -65
- package/cli/writeStackTrace.js +0 -27
- package/cliAgentMode.js +0 -384
- package/codim/codim-cli.js +0 -91
- package/codim/codim-npm-package/index.ts +0 -427
- package/codim/codim-npm-package/package-lock.json +0 -14
- package/codim/codim-npm-package/package.json +0 -14
- package/codim/hybrid-utils.js +0 -28
- package/codim/measure-perf.js +0 -41
- package/codim/template.js/.idea/workspace.xml +0 -57
- package/codim/template.js/.vscode/launch.json +0 -53
- package/codim/template.ts/.idea/workspace.xml +0 -57
- package/codim/template.ts/.vscode/launch.json +0 -55
- package/commons/AbortError.js +0 -12
- package/commons/SeleniumPerfStats.js +0 -58
- package/commons/chrome-launcher.js +0 -15
- package/commons/chromedriverWrapper.js +0 -70
- package/commons/config.js +0 -39
- package/commons/constants.js +0 -67
- package/commons/detectDebugger.js +0 -19
- package/commons/featureAvailabilityService.js +0 -26
- package/commons/featureFlags.js +0 -132
- package/commons/getSessionPlayerRequire.js +0 -28
- package/commons/httpRequest.js +0 -261
- package/commons/httpRequestCounters.js +0 -98
- package/commons/httpRequestCounters.test.js +0 -38
- package/commons/initializeUserWithAuth.js +0 -55
- package/commons/lazyRequire.js +0 -105
- package/commons/logUtils.js +0 -15
- package/commons/logUtils.test.js +0 -21
- package/commons/logger.js +0 -178
- package/commons/mockNetworkRuleFileSchema.json +0 -140
- package/commons/npmWrapper.js +0 -174
- package/commons/npmWrapper.test.js +0 -374
- package/commons/performance-logger.js +0 -71
- package/commons/preloadTests.js +0 -29
- package/commons/prepareRunner.js +0 -85
- package/commons/prepareRunner.test.js +0 -144
- package/commons/prepareRunnerAndTestimStartUtils.js +0 -198
- package/commons/prepareRunnerAndTestimStartUtils.test.js +0 -73
- package/commons/requireWithFallback.js +0 -25
- package/commons/runnerFileCache.js +0 -204
- package/commons/socket/baseSocketServiceSocketIO.js +0 -197
- package/commons/socket/realDataService.js +0 -59
- package/commons/socket/realDataServiceSocketIO.js +0 -33
- package/commons/socket/remoteStepService.js +0 -55
- package/commons/socket/remoteStepServiceSocketIO.js +0 -61
- package/commons/socket/socketService.js +0 -175
- package/commons/socket/testResultService.js +0 -62
- package/commons/socket/testResultServiceSocketIO.js +0 -64
- package/commons/testimAnalytics.js +0 -40
- package/commons/testimCloudflare.js +0 -83
- package/commons/testimCloudflare.test.js +0 -185
- package/commons/testimCustomToken.js +0 -124
- package/commons/testimDesiredCapabilitiesBuilder.js +0 -647
- package/commons/testimNgrok.js +0 -90
- package/commons/testimNgrok.test.js +0 -140
- package/commons/testimServicesApi.js +0 -631
- package/commons/testimTunnel.js +0 -73
- package/commons/testimTunnel.test.js +0 -172
- package/commons/xhr2.js +0 -897
- package/coverage/SummaryToObjectReport.js +0 -19
- package/coverage/jsCoverage.js +0 -252
- package/credentialsManager.js +0 -142
- package/errors.js +0 -161
- package/executionQueue.js +0 -37
- package/fixLocalBuild.js +0 -24
- package/inputFileUtils.js +0 -103
- package/lib/coralogix-winston.transport.js +0 -99
- package/player/SeleniumProtocolError.js +0 -100
- package/player/WebDriverHttpRequest.js +0 -177
- package/player/WebdriverioWebDriverApi.js +0 -671
- package/player/appiumTestPlayer.js +0 -90
- package/player/chromeLauncherTestPlayer.js +0 -67
- package/player/constants.js +0 -332
- package/player/extensionTestPlayer.js +0 -32
- package/player/findElementStrategy.js +0 -154
- package/player/scripts/isElementDisplayed.js +0 -252
- package/player/seleniumTestPlayer.js +0 -140
- package/player/services/frameLocator.js +0 -170
- package/player/services/mobileFrameLocatorMock.js +0 -32
- package/player/services/playbackTimeoutCalculator.js +0 -175
- package/player/services/portSelector.js +0 -19
- package/player/services/tabService.js +0 -551
- package/player/services/tabServiceMock.js +0 -167
- package/player/services/windowCreationListener.js +0 -8
- package/player/stepActions/RefreshStepAction.js +0 -16
- package/player/stepActions/apiStepAction.js +0 -89
- package/player/stepActions/baseCliJsStepAction.js +0 -51
- package/player/stepActions/baseJsStepAction.js +0 -277
- package/player/stepActions/cliConditionStepAction.js +0 -11
- package/player/stepActions/cliJsStepAction.js +0 -11
- package/player/stepActions/dropFileStepAction.js +0 -34
- package/player/stepActions/evaluateExpressionStepAction.js +0 -52
- package/player/stepActions/extensionOnlyStepAction.js +0 -12
- package/player/stepActions/extractTextStepAction.js +0 -19
- package/player/stepActions/hoverStepAction.js +0 -55
- package/player/stepActions/inputFileStepAction.js +0 -199
- package/player/stepActions/jsCodeStepAction.js +0 -11
- package/player/stepActions/jsConditionStepAction.js +0 -11
- package/player/stepActions/locateStepAction.js +0 -159
- package/player/stepActions/mouseStepAction.js +0 -370
- package/player/stepActions/navigationStepAction.js +0 -29
- package/player/stepActions/nodePackageStepAction.js +0 -47
- package/player/stepActions/pixelValidationStepAction.js +0 -39
- package/player/stepActions/scripts/dispatchEvents.js +0 -282
- package/player/stepActions/scripts/doClick.js +0 -221
- package/player/stepActions/scripts/doDragPath.js +0 -225
- package/player/stepActions/scripts/doubleClick.js +0 -119
- package/player/stepActions/scripts/dropEvent.js +0 -63
- package/player/stepActions/scripts/focusElement.js +0 -46
- package/player/stepActions/scripts/html5dragAction.js +0 -56
- package/player/stepActions/scripts/html5dragActionV2.js +0 -312
- package/player/stepActions/scripts/runCode.js +0 -147
- package/player/stepActions/scripts/scroll.js +0 -90
- package/player/stepActions/scripts/selectOption.js +0 -51
- package/player/stepActions/scripts/setText.js +0 -415
- package/player/stepActions/scripts/wheel.js +0 -61
- package/player/stepActions/scrollStepAction.js +0 -96
- package/player/stepActions/selectOptionStepAction.js +0 -49
- package/player/stepActions/sfdcRecordedStepAction.js +0 -24
- package/player/stepActions/sfdcStepAction.js +0 -28
- package/player/stepActions/sleepStepAction.js +0 -12
- package/player/stepActions/specialKeyStepAction.js +0 -52
- package/player/stepActions/stepAction.js +0 -73
- package/player/stepActions/stepActionRegistrar.js +0 -111
- package/player/stepActions/submitStepAction.js +0 -12
- package/player/stepActions/tdkHybridStepAction.js +0 -18
- package/player/stepActions/textStepAction.js +0 -110
- package/player/stepActions/textValidationStepAction.js +0 -64
- package/player/stepActions/wheelStepAction.js +0 -41
- package/player/utils/cookieUtils.js +0 -39
- package/player/utils/eyeSdkService.js +0 -250
- package/player/utils/imageCaptureUtils.js +0 -267
- package/player/utils/screenshotUtils.js +0 -68
- package/player/utils/stepActionUtils.js +0 -90
- package/player/utils/windowUtils.js +0 -195
- package/player/webDriverUtils.js +0 -40
- package/player/webDriverUtils.test.js +0 -116
- package/player/webdriver.js +0 -976
- package/polyfills/Array.prototype.at.js +0 -13
- package/polyfills/index.js +0 -13
- package/processHandler.js +0 -79
- package/processHandler.test.js +0 -55
- package/reports/chromeReporter.js +0 -17
- package/reports/consoleReporter.js +0 -190
- package/reports/debugReporter.js +0 -82
- package/reports/jsonReporter.js +0 -55
- package/reports/junitReporter.js +0 -183
- package/reports/reporter.js +0 -166
- package/reports/reporterUtils.js +0 -54
- package/reports/teamCityReporter.js +0 -73
- package/runOptions.d.ts +0 -305
- package/runOptions.js +0 -1288
- package/runOptionsAgentFlow.js +0 -87
- package/runOptionsUtils.js +0 -60
- package/runner.js +0 -355
- package/runners/ParallelWorkerManager.js +0 -284
- package/runners/TestPlanRunner.js +0 -419
- package/runners/buildCodeTests.js +0 -159
- package/runners/runnerUtils.js +0 -81
- package/services/analyticsService.js +0 -96
- package/services/branchService.js +0 -29
- package/services/gridService.js +0 -357
- package/services/gridService.test.js +0 -357
- package/services/labFeaturesService.js +0 -64
- package/services/lambdatestService.js +0 -227
- package/services/lambdatestService.test.js +0 -353
- package/services/localRCASaver.js +0 -124
- package/stepPlayers/cliJsStepPlayback.js +0 -40
- package/stepPlayers/hybridStepPlayback.js +0 -140
- package/stepPlayers/nodePackageStepPlayback.js +0 -28
- package/stepPlayers/playwrightHybridStepPlayback.js +0 -61
- package/stepPlayers/puppeteerHybridStepPlayback.js +0 -76
- package/stepPlayers/remoteStepPlayback.js +0 -80
- package/stepPlayers/seleniumHybridStepPlayback.js +0 -84
- package/stepPlayers/tdkHybridStepPlayback.js +0 -112
- package/testRunHandler.js +0 -603
- package/testRunStatus.js +0 -567
- package/testimNpmDriver.js +0 -52
- package/utils/argsUtils.js +0 -91
- package/utils/argsUtils.test.js +0 -32
- package/utils/fsUtils.js +0 -174
- package/utils/index.js +0 -197
- package/utils/promiseUtils.js +0 -85
- package/utils/stringUtils.js +0 -98
- package/utils/stringUtils.test.js +0 -22
- package/utils/timeUtils.js +0 -25
- package/utils/utils.test.js +0 -27
- package/workers/BaseWorker.js +0 -498
- package/workers/BaseWorker.test.js +0 -186
- package/workers/WorkerAppium.js +0 -180
- package/workers/WorkerExtension.js +0 -192
- package/workers/WorkerExtensionSingleBrowser.js +0 -77
- package/workers/WorkerSelenium.js +0 -253
- package/workers/workerUtils.js +0 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testim/testim-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.290.0",
|
|
4
4
|
"description": "Command line interface for running Testing on your CI",
|
|
5
5
|
"author": "Oren Rubin",
|
|
6
6
|
"contributors": [{
|
|
@@ -11,21 +11,24 @@
|
|
|
11
11
|
"email": "info@testim.io"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
+
"@types/decompress": "4.2.4",
|
|
14
15
|
"@types/fs-extra": "9.0.13",
|
|
15
16
|
"@types/ms": "0.7.31",
|
|
16
17
|
"@types/node": "10.17.24",
|
|
18
|
+
"@types/prompts": "2.4.2",
|
|
17
19
|
"@types/selenium-webdriver": "4.0.9",
|
|
20
|
+
"@types/validate-npm-package-name": "3.0.3",
|
|
18
21
|
"bundle-deps": "1.0.0",
|
|
19
22
|
"gulp": "4.0.2",
|
|
20
23
|
"gulp-cli": "2.3.0",
|
|
21
24
|
"gulp-json-editor": "2.5.6",
|
|
22
|
-
"gulp-preprocess": "3.0.3",
|
|
23
25
|
"merge-stream": "2.0.0",
|
|
24
26
|
"proxyquire": "2.1.3",
|
|
25
27
|
"sinon": "9.0.2",
|
|
26
28
|
"sinon-chai": "3.7.0",
|
|
27
29
|
"ts-node": "9.1.1",
|
|
28
30
|
"tsconfig-paths": "3.12.0",
|
|
31
|
+
"tsup": "6.6.0",
|
|
29
32
|
"typescript": "4.6.2"
|
|
30
33
|
},
|
|
31
34
|
"lazyDependencies": {
|
|
@@ -90,6 +93,7 @@
|
|
|
90
93
|
"semver": "7.3.2",
|
|
91
94
|
"serialize-error": "7.0.1",
|
|
92
95
|
"socket.io-client": "4.5.4",
|
|
96
|
+
"source-map-support": "0.5.19",
|
|
93
97
|
"superagent": "3.8.3",
|
|
94
98
|
"superagent-proxy": "3.0.0",
|
|
95
99
|
"test-exclude": "6.0.0",
|
|
@@ -108,15 +112,15 @@
|
|
|
108
112
|
"testim": "cli.js"
|
|
109
113
|
},
|
|
110
114
|
"scripts": {
|
|
111
|
-
"test": "yarn test:pattern './src/**/*.test.
|
|
112
|
-
"test:pattern": "IS_UNIT_TEST=1 ../../node_modules/mocha/bin/_mocha --timeout 2000 --exit --recursive --exclude ./src/codim/template.
|
|
115
|
+
"test": "yarn test:pattern './src/**/*.test.[jt]s'",
|
|
116
|
+
"test:pattern": "IS_UNIT_TEST=1 ../../node_modules/mocha/bin/_mocha --timeout 2000 --exit --recursive --exclude ./src/codim/template.[jt]s/tests/examples/**/*.test.[jt]s --watch-files 'src' -r ts-node/register/transpile-only -r tsconfig-paths/register",
|
|
113
117
|
"test:cov": "nyc --reporter=lcov --reporter=text yarn test",
|
|
114
118
|
"upload-bundle-s3": "ts-node-transpile-only scripts/upload.js",
|
|
115
119
|
"prepare-version": "rm -rf ./deploy && mkdir -p deploy && gulp prepare-version-on-prem",
|
|
116
120
|
"make-onprem-deps": "cp ../../yarn.lock deploy && cd deploy && yarn install --production && bundle-deps",
|
|
117
121
|
"pack-onprem": "yarn prepare-version && yarn make-onprem-deps && cd deploy && npm pack && zip -r testim-cli.zip testim-cli-*.tgz",
|
|
118
122
|
"pack-serve": "yarn pack-onprem && http-server deploy/",
|
|
119
|
-
"self-test": "cd /tmp &&
|
|
123
|
+
"self-test": "cd /tmp && DEBUG=self-test BUILD_MAX_MEMORY=4096 tsx /home/circleci/testimio/apps/runner/scripts/selfTest.ts"
|
|
120
124
|
},
|
|
121
125
|
"engines": {
|
|
122
126
|
"node": ">= 14.0.0"
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const utils = require('./utils');
|
|
6
|
-
const _ = require('lodash');
|
|
7
|
-
const logger = require('./commons/logger').getLogger('override-test-data-builder');
|
|
8
|
-
|
|
9
|
-
class OverrideTestDataBuilder {
|
|
10
|
-
constructor(params, testInfoList, projectId) {
|
|
11
|
-
this.params = params;
|
|
12
|
-
this.testInfoList = testInfoList;
|
|
13
|
-
this.projectId = projectId;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
isObjectNotArray(param) {
|
|
17
|
-
return _.isObject(param) && !Array.isArray(param);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
isArrayOfObjects(params) {
|
|
21
|
-
return Array.isArray(params) && params.filter(param => !this.isObjectNotArray(param)).length === 0;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
overrideTestData() {
|
|
25
|
-
const { params, projectId } = this;
|
|
26
|
-
if (this.isObjectNotArray(params) && typeof params.overrideTestData !== 'undefined') {
|
|
27
|
-
if (this.isObjectNotArray(params.overrideTestData) && !_.isEmpty(params.overrideTestData)) {
|
|
28
|
-
Object.keys(params.overrideTestData).forEach(testName => this.overrideSingeTest(testName, params.overrideTestData[testName]));
|
|
29
|
-
delete params.overrideTestData;
|
|
30
|
-
} else {
|
|
31
|
-
logger.error('invalid overrideTestData', { overrideTestData: params.overrideTestData, projectId });
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (this.isObjectNotArray(params) && typeof params.overrideAllTestsData !== 'undefined') {
|
|
35
|
-
if (_.isObject(params.overrideAllTestsData) && !_.isEmpty(params.overrideAllTestsData)) {
|
|
36
|
-
const testNames = this.testInfoList.map(test => test.name);
|
|
37
|
-
testNames.forEach(testName => this.overrideSingeTest(testName, params.overrideAllTestsData));
|
|
38
|
-
delete params.overrideAllTestsData;
|
|
39
|
-
} else {
|
|
40
|
-
logger.error('invalid overrideAllTestsData', { overrideAllTestsData: params.overrideAllTestsData, projectId });
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return this.testInfoList;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
overrideSingeTest(testName, testOverrideTestData) {
|
|
48
|
-
const { projectId } = this;
|
|
49
|
-
if (this.isObjectNotArray(testOverrideTestData) || this.isArrayOfObjects(testOverrideTestData)) {
|
|
50
|
-
this.replaceAndCreateOverrideTestData(testName, testOverrideTestData);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
logger.error('skip override test data to test name', { testName, projectId });
|
|
54
|
-
console.error(`Invalid override test data provided to test '${testName}'`);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
replaceAndCreateOverrideTestData(testName, testOverrideTestData) {
|
|
58
|
-
const uniqueMatchIds = this.mapTestListToUniqueId(testName);
|
|
59
|
-
if (uniqueMatchIds.length === 0) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
return this.createNewTestPerOverrideTestData(uniqueMatchIds, testOverrideTestData);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
mapTestListToUniqueId(testName) {
|
|
66
|
-
const { testInfoList } = this;
|
|
67
|
-
return _(testInfoList).map(test => {
|
|
68
|
-
if (test.name.toLowerCase() === testName.toLowerCase()) {
|
|
69
|
-
return this.generateTestUniqId(test);
|
|
70
|
-
}
|
|
71
|
-
return undefined;
|
|
72
|
-
}).filter(Boolean).uniq()
|
|
73
|
-
.value();
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
createNewTestPerOverrideTestData(uniqueMatchIds, testOverrideTestData) {
|
|
77
|
-
const { testInfoList } = this;
|
|
78
|
-
return _.uniq(uniqueMatchIds).map(uniqTestId => {
|
|
79
|
-
const testUniqIds = testInfoList.map(test => this.generateTestUniqId(test));
|
|
80
|
-
const firstIndex = _.findIndex(testUniqIds, id => id === uniqTestId);
|
|
81
|
-
const lastIndex = _.findLastIndex(testUniqIds, id => id === uniqTestId);
|
|
82
|
-
const currentTest = testInfoList[firstIndex];
|
|
83
|
-
const newTestDataItems = this.createNewTestItems(currentTest, testOverrideTestData);
|
|
84
|
-
return testInfoList.splice(firstIndex, (lastIndex - firstIndex) + 1, ...newTestDataItems);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
createNewTestItems(currentTest, testOverrideTestData) {
|
|
89
|
-
return ([].concat(testOverrideTestData)).map((newTestData, index) => {
|
|
90
|
-
const testResultId = utils.guid();
|
|
91
|
-
return Object.assign({}, currentTest, {
|
|
92
|
-
resultId: testResultId,
|
|
93
|
-
testData: {
|
|
94
|
-
value: newTestData,
|
|
95
|
-
index: index + 1,
|
|
96
|
-
total: testOverrideTestData.length || 1,
|
|
97
|
-
},
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
getTestType(test) {
|
|
103
|
-
if (test.isBeforeTestPlan) {
|
|
104
|
-
return 'before';
|
|
105
|
-
}
|
|
106
|
-
if (test.isAfterTestPlan) {
|
|
107
|
-
return 'after';
|
|
108
|
-
}
|
|
109
|
-
return 'test';
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
generateTestUniqId(test) {
|
|
113
|
-
return `${test.testId}:${test.testConfig.id}:${this.getTestType(test)}`;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
module.exports = OverrideTestDataBuilder;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const router = require('./router');
|
|
4
|
-
const service = require('./service');
|
|
5
|
-
const logger = require('../../../commons/logger').getLogger('cli-service');
|
|
6
|
-
|
|
7
|
-
// clean local
|
|
8
|
-
service.cleanLocalPackageInstallFolder()
|
|
9
|
-
.catch(err => logger.warn('failed to clean local package folder', { err }));
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
router,
|
|
13
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
const express = require('express');
|
|
6
|
-
const service = require('./service');
|
|
7
|
-
const { NpmPackageError, TimeoutError } = require('../../../errors');
|
|
8
|
-
const logger = require('../../../commons/logger').getLogger('cli-router');
|
|
9
|
-
const chalk = require('chalk');
|
|
10
|
-
|
|
11
|
-
const router = express.Router();
|
|
12
|
-
|
|
13
|
-
router.post('/run', async (req, res) => {
|
|
14
|
-
const { code, stepId, incomingParams, context, testResultId, retryIndex, stepResultId, timeout, fileDataUrl } = req.body;
|
|
15
|
-
|
|
16
|
-
if (typeof code !== 'string' || !stepId || !incomingParams || !context || !testResultId || typeof retryIndex !== 'number' || !stepResultId || typeof timeout !== 'number') {
|
|
17
|
-
res.status(400).json({ success: false, code: 'invalid-params' });
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
const data = await service.runCodeWithPackages(code, stepId, incomingParams, context, testResultId, retryIndex, stepResultId, timeout, fileDataUrl);
|
|
23
|
-
if (!data.success) {
|
|
24
|
-
console.log(chalk.red(data.result.resultValue));
|
|
25
|
-
logger.error('CLI Action Failure', { message: data.result.resultValue });
|
|
26
|
-
}
|
|
27
|
-
res.status(200).json({ success: true, data });
|
|
28
|
-
} catch (err) {
|
|
29
|
-
logger.error('failed to run cli code', { err });
|
|
30
|
-
console.log(chalk.red('failed to run cli code', err));
|
|
31
|
-
res.status(500).json({ success: false, code: 'internal-error' });
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
router.post('/install', async (req, res) => {
|
|
36
|
-
const { stepId, testResultId, retryIndex, packageData, stepResultId, timeout } = req.body;
|
|
37
|
-
|
|
38
|
-
if (!stepId || typeof packageData !== 'object' || !testResultId || typeof retryIndex !== 'number' || !stepResultId || typeof timeout !== 'number') {
|
|
39
|
-
res.status(400).json({ success: false, code: 'invalid-params' });
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
try {
|
|
44
|
-
const data = await service.installPackage(stepId, testResultId, retryIndex, packageData, stepResultId, timeout);
|
|
45
|
-
logger.info('installed packages successfully');
|
|
46
|
-
res.status(200).json({ success: true, data });
|
|
47
|
-
} catch (err) {
|
|
48
|
-
if (err instanceof NpmPackageError) {
|
|
49
|
-
logger.error('failed to install node packages', { err });
|
|
50
|
-
res.status(200).json({ success: false, code: 'invalid-node-package', message: err.message });
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
if (err instanceof TimeoutError) {
|
|
54
|
-
logger.error('timeout installing node package');
|
|
55
|
-
res.status(200).json({ success: false, code: 'timeout' });
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
logger.error('failed to install node packages', { err });
|
|
59
|
-
res.status(500).json({ success: false, code: 'internal-error' });
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
module.exports = router;
|