@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/commons/logger.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const winston = require('winston');
|
|
4
|
-
const os = require('os');
|
|
5
|
-
|
|
6
|
-
const hostname = os.hostname();
|
|
7
|
-
const runnerVersion = getRunnerVersion();
|
|
8
|
-
const config = require('./config');
|
|
9
|
-
|
|
10
|
-
const isLocal = 'false';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const loggerConfig = {
|
|
14
|
-
privateKey: 'd0eb01da-f966-1663-63c6-8871225d7c39',
|
|
15
|
-
applicationName: 'testim',
|
|
16
|
-
subsystemName: 'runner',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
function getRunnerVersion() {
|
|
20
|
-
try {
|
|
21
|
-
const pack = require(`${__dirname}/../package.json`);
|
|
22
|
-
return pack.version;
|
|
23
|
-
} catch (err) {
|
|
24
|
-
return '';
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getStreamsAndWaitForFlushPromise() {
|
|
29
|
-
const transports = [];
|
|
30
|
-
|
|
31
|
-
let waitForFlush = () => Promise.resolve();
|
|
32
|
-
|
|
33
|
-
if (!config.IS_ON_PREM) {
|
|
34
|
-
const { CoralogixTransport } = require('../lib/coralogix-winston.transport');
|
|
35
|
-
|
|
36
|
-
CoralogixTransport.configure(loggerConfig);
|
|
37
|
-
const loggerInstance = new CoralogixTransport({
|
|
38
|
-
category: 'ROOT',
|
|
39
|
-
});
|
|
40
|
-
transports.push(loggerInstance);
|
|
41
|
-
|
|
42
|
-
waitForFlush = () => loggerInstance.waitForFlush();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (config.LOGGER_CONSOLE) {
|
|
46
|
-
transports.push(new winston.transports.Console({
|
|
47
|
-
format: winston.format.combine(winston.format.colorize(), winston.format.simple()),
|
|
48
|
-
}));
|
|
49
|
-
}
|
|
50
|
-
return [transports, waitForFlush];
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const [transports, waitForFlush] = getStreamsAndWaitForFlushPromise();
|
|
54
|
-
const level = config.LOGGER_DEBUG ? 'debug' : 'info';
|
|
55
|
-
const defaultMeta = {};
|
|
56
|
-
if (!isLocal.includes('@echo')) {
|
|
57
|
-
Object.assign(defaultMeta, devFlags());
|
|
58
|
-
|
|
59
|
-
} else {
|
|
60
|
-
Object.assign(defaultMeta, localFlags());
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const winstonMainLogger = winston.createLogger({
|
|
64
|
-
levels: winston.config.syslog.levels,
|
|
65
|
-
level,
|
|
66
|
-
transports,
|
|
67
|
-
defaultMeta: { name: 'runner', hostname, nodeVersion: process.version, runnerVersion, ...defaultMeta },
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
let executionId = null;
|
|
71
|
-
let projectId = null;
|
|
72
|
-
|
|
73
|
-
function setExecutionId(execId) {
|
|
74
|
-
executionId = execId;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function setProjectId(projId) {
|
|
78
|
-
projectId = projId;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
function setProxyUri(proxyUri) {
|
|
82
|
-
if (config.IS_ON_PREM || !proxyUri) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const { CoralogixTransport } = require('../lib/coralogix-winston.transport');
|
|
86
|
-
CoralogixTransport.configure({ ...loggerConfig, proxyUri });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function releaseFlags() {
|
|
90
|
-
return {
|
|
91
|
-
release: true,
|
|
92
|
-
branch: 'production',
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function devFlags() {
|
|
97
|
-
return {
|
|
98
|
-
release: false,
|
|
99
|
-
branch: 'test',
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
function localFlags() {
|
|
104
|
-
return {
|
|
105
|
-
release: false,
|
|
106
|
-
branch: 'local',
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function addExecutionMetadata(dataExecutionId) {
|
|
111
|
-
const logData = {};
|
|
112
|
-
if (executionId && !dataExecutionId) {
|
|
113
|
-
logData.executionId = executionId;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
logData.projectId = projectId;
|
|
117
|
-
logData.time = (new Date()).toISOString();
|
|
118
|
-
|
|
119
|
-
return logData;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
class Logger {
|
|
123
|
-
constructor(logger) {
|
|
124
|
-
this._logger = logger;
|
|
125
|
-
this.debug = this.debug.bind(this);
|
|
126
|
-
this.info = this.info.bind(this);
|
|
127
|
-
this.warn = this.warn.bind(this);
|
|
128
|
-
this.error = this.error.bind(this);
|
|
129
|
-
this.fatal = this.fatal.bind(this);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
debug(msg, data = {}) {
|
|
133
|
-
this.innerLog('debug', msg, data);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
info(msg, data = {}) {
|
|
137
|
-
this.innerLog('info', msg, data);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
warn(msg, data = {}) {
|
|
141
|
-
this.innerLog('warning', msg, data);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
error(msg, data = {}) {
|
|
145
|
-
this.innerLog('error', msg, data);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
fatal(msg, data = {}) {
|
|
149
|
-
this.innerLog('crit', msg, data);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
innerLog(logLevel, msg, data = {}) {
|
|
153
|
-
try {
|
|
154
|
-
this._logger.log(logLevel, Object.assign({ meta: data }, { message: msg }, addExecutionMetadata(data.executionId)));
|
|
155
|
-
} catch (err) {
|
|
156
|
-
try {
|
|
157
|
-
this._logger.log('crit', Object.assign({ message: `failed to log message ${err.message}, ${err.stack}` }, addExecutionMetadata(data.executionId)));
|
|
158
|
-
} catch (_err) {
|
|
159
|
-
// well what can we do
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
waitForFlush() {
|
|
165
|
-
return waitForFlush();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function getLogger(loggerName) {
|
|
170
|
-
return new Logger(winstonMainLogger.child({ category: loggerName }));
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
module.exports = {
|
|
174
|
-
getLogger,
|
|
175
|
-
setExecutionId,
|
|
176
|
-
setProjectId,
|
|
177
|
-
setProxyUri,
|
|
178
|
-
};
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"definitions": {
|
|
4
|
-
"request": {
|
|
5
|
-
"type": "object",
|
|
6
|
-
"required": ["url"],
|
|
7
|
-
"additionalProperties": false,
|
|
8
|
-
"properties": {
|
|
9
|
-
"url": { "type": "string" },
|
|
10
|
-
"method": {
|
|
11
|
-
"type": "string",
|
|
12
|
-
"pattern": "^GET$|^HEAD$|^POST$|^PUT$|^DELETE$|^CONNECT$|^OPTIONS$|^TRACE$|^PATCH$"
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"header": {
|
|
17
|
-
"type": "object",
|
|
18
|
-
"required": [
|
|
19
|
-
"name",
|
|
20
|
-
"value"
|
|
21
|
-
],
|
|
22
|
-
"additionalProperties": false,
|
|
23
|
-
"properties": {
|
|
24
|
-
"name": {
|
|
25
|
-
"type": "string"
|
|
26
|
-
},
|
|
27
|
-
"value": {
|
|
28
|
-
"type": "string"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"cookie": {
|
|
33
|
-
"type": "object",
|
|
34
|
-
"required": [
|
|
35
|
-
"name",
|
|
36
|
-
"value"
|
|
37
|
-
],
|
|
38
|
-
"additionalProperties": false,
|
|
39
|
-
"properties": {
|
|
40
|
-
"name": {
|
|
41
|
-
"type": "string"
|
|
42
|
-
},
|
|
43
|
-
"value": {
|
|
44
|
-
"type": "string"
|
|
45
|
-
},
|
|
46
|
-
"path": {
|
|
47
|
-
"type": "string"
|
|
48
|
-
},
|
|
49
|
-
"domain": {
|
|
50
|
-
"type": "string"
|
|
51
|
-
},
|
|
52
|
-
"expires": {
|
|
53
|
-
"type": "string",
|
|
54
|
-
"format": "date-time"
|
|
55
|
-
},
|
|
56
|
-
"httpOnly": {
|
|
57
|
-
"type": "boolean"
|
|
58
|
-
},
|
|
59
|
-
"secure": {
|
|
60
|
-
"type": "boolean"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
"response": {
|
|
65
|
-
"type": "object",
|
|
66
|
-
"required": ["status"],
|
|
67
|
-
"additionalProperties": false,
|
|
68
|
-
"properties": {
|
|
69
|
-
"status": {
|
|
70
|
-
"type": "integer",
|
|
71
|
-
"minimum": 100,
|
|
72
|
-
"exclusiveMaximum": 600
|
|
73
|
-
},
|
|
74
|
-
"headers": {
|
|
75
|
-
"type": "array",
|
|
76
|
-
"items": { "$ref": "#/definitions/header" }
|
|
77
|
-
},
|
|
78
|
-
"cookies": {
|
|
79
|
-
"type": "array",
|
|
80
|
-
"items": { "$ref": "#/definitions/cookie" }
|
|
81
|
-
},
|
|
82
|
-
"content": {
|
|
83
|
-
"type": "object",
|
|
84
|
-
"required": ["text"],
|
|
85
|
-
"additionalProperties": false,
|
|
86
|
-
"properties": {
|
|
87
|
-
"text": {
|
|
88
|
-
"type": "string"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
"redirectResponse": {
|
|
95
|
-
"type": "object",
|
|
96
|
-
"required": ["redirectUrl"],
|
|
97
|
-
"additionalProperties": false,
|
|
98
|
-
"properties": {
|
|
99
|
-
"redirectUrl": { "type": "string" }
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
"passthroughResponse": {
|
|
103
|
-
"type": "object",
|
|
104
|
-
"required": ["passthrough"],
|
|
105
|
-
"additionalProperties": false,
|
|
106
|
-
"properties": {
|
|
107
|
-
"passthrough": { "type": "boolean", "enum": [ true ] }
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
"entry": {
|
|
111
|
-
"type": "object",
|
|
112
|
-
"required": ["request", "response"],
|
|
113
|
-
"additionalProperties": false,
|
|
114
|
-
"properties": {
|
|
115
|
-
"request": { "$ref": "#/definitions/request" },
|
|
116
|
-
"response": {
|
|
117
|
-
"oneOf": [
|
|
118
|
-
{ "$ref": "#/definitions/response" },
|
|
119
|
-
{ "$ref": "#/definitions/redirectResponse" },
|
|
120
|
-
{ "$ref": "#/definitions/passthroughResponse" }
|
|
121
|
-
]
|
|
122
|
-
},
|
|
123
|
-
"maxHits": {
|
|
124
|
-
"type": "integer",
|
|
125
|
-
"minimum": 1
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
"type": "object",
|
|
131
|
-
"required": ["entries"],
|
|
132
|
-
"properties": {
|
|
133
|
-
"version": { "type": "string", "enum": ["1.2", "1.2.0"] },
|
|
134
|
-
"creator": { "type": "string" },
|
|
135
|
-
"entries": {
|
|
136
|
-
"type": "array",
|
|
137
|
-
"items": { "$ref": "#/definitions/entry" }
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
package/commons/npmWrapper.js
DELETED
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const util = require('util');
|
|
3
|
-
const { additionalLogDetails } = require('./logUtils');
|
|
4
|
-
const exec = util.promisify(require('child_process').exec);
|
|
5
|
-
const spawn = require('child_process').spawn;
|
|
6
|
-
const path = require('path');
|
|
7
|
-
const { NpmPackageError, NpmPermissionsError } = require('../errors');
|
|
8
|
-
const fse = require('fs-extra');
|
|
9
|
-
const logger = require('./logger').getLogger('cli-service');
|
|
10
|
-
const { requireWithFallback } = require('./requireWithFallback');
|
|
11
|
-
const fs = require('fs');
|
|
12
|
-
const utils = require('../utils');
|
|
13
|
-
|
|
14
|
-
async function getLatestPackageVersion(packageName) {
|
|
15
|
-
const result = await exec(`npm view ${packageName} version`);
|
|
16
|
-
return result.stdout.trim();
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getPackageIfInstalledLocally(packageName) {
|
|
20
|
-
try {
|
|
21
|
-
// note: this code fails if require itself throws here
|
|
22
|
-
// rather than an ENOENT - but since lazy dependencies are all controlled
|
|
23
|
-
// by us that's probably fine.
|
|
24
|
-
return requireWithFallback(packageName);
|
|
25
|
-
} catch (err) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async function isPackageInstalledInPath(rootPath, packageName) {
|
|
31
|
-
try {
|
|
32
|
-
return await fse.pathExists(path.join(rootPath, `./node_modules/${packageName}/package.json`));
|
|
33
|
-
} catch (error) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getLocallyInstalledPackageVersion(rootPath, packageName) {
|
|
39
|
-
// eslint-disable-next-line import/no-dynamic-require
|
|
40
|
-
return require(path.join(rootPath, `./node_modules/${packageName}/package.json`)).version;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// this is not exactly correct, but it's good enough.
|
|
44
|
-
async function fileExists(path) {
|
|
45
|
-
try {
|
|
46
|
-
await fs.promises.access(path);
|
|
47
|
-
return true;
|
|
48
|
-
} catch (err) {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async function installPackageLocally(rootPath, packageName, execOptions) {
|
|
54
|
-
function getPathWithMissingPermissions(error) {
|
|
55
|
-
const pathRegex = /EACCES[^']+'(.+)'/;
|
|
56
|
-
const regexResult = pathRegex.exec(error.stderr);
|
|
57
|
-
if (regexResult === null) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
return regexResult[1];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// https://github.com/npm/arborist/pull/362
|
|
64
|
-
function npmSevenAndEightMissingPermissions(error) {
|
|
65
|
-
return /The "to" argument must be of type string./.exec(error.stderr);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// this is here because our shrinkwrap blocks our lazy deps for some reason
|
|
69
|
-
const oldShrinkwrap = path.join(rootPath, 'npm-shrinkwrap.json');
|
|
70
|
-
const newShrinkwrap = path.join(rootPath, 'npm-shrinkwrap-dummy.json');
|
|
71
|
-
let renamed = false;
|
|
72
|
-
try {
|
|
73
|
-
try {
|
|
74
|
-
if (await fileExists(oldShrinkwrap)) {
|
|
75
|
-
await fs.promises.rename(oldShrinkwrap, newShrinkwrap);
|
|
76
|
-
renamed = true;
|
|
77
|
-
}
|
|
78
|
-
} catch (err) {
|
|
79
|
-
// ignore error
|
|
80
|
-
}
|
|
81
|
-
return await exec(`npm i ${packageName} --no-save --no-prune --prefer-offline --no-audit --progress=false`, { ...execOptions, cwd: rootPath }).catch(err => {
|
|
82
|
-
const pathWithMissingPermissions = getPathWithMissingPermissions(err);
|
|
83
|
-
const npmEightMissingPermissions = npmSevenAndEightMissingPermissions(err);
|
|
84
|
-
if (pathWithMissingPermissions || npmEightMissingPermissions) {
|
|
85
|
-
logger.info('Failed to install package due to insufficient write access', {
|
|
86
|
-
...additionalLogDetails(),
|
|
87
|
-
package: packageName,
|
|
88
|
-
path: pathWithMissingPermissions || rootPath,
|
|
89
|
-
});
|
|
90
|
-
// eslint-disable-next-line no-console
|
|
91
|
-
console.error(`
|
|
92
|
-
|
|
93
|
-
Testim failed installing the package ${packageName} due to insufficient permissions.
|
|
94
|
-
This is probably due to an installation of @testim/testim-cli with sudo, and running it without sudo.
|
|
95
|
-
Testim had missing write access to ${pathWithMissingPermissions || rootPath}
|
|
96
|
-
|
|
97
|
-
`);
|
|
98
|
-
throw new NpmPermissionsError(pathWithMissingPermissions || rootPath);
|
|
99
|
-
}
|
|
100
|
-
throw err;
|
|
101
|
-
});
|
|
102
|
-
} finally {
|
|
103
|
-
if (renamed) {
|
|
104
|
-
try {
|
|
105
|
-
await fs.promises.rename(newShrinkwrap, oldShrinkwrap);
|
|
106
|
-
} catch (err) {
|
|
107
|
-
// ignore error
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const localNpmLocation = path.resolve(require.resolve('npm').replace('index.js', ''), 'bin', 'npm-cli.js');
|
|
114
|
-
|
|
115
|
-
function installPackages(prefix, packageNames, proxyUri, timeoutMs) {
|
|
116
|
-
return new Promise((resolve, reject) => {
|
|
117
|
-
const proxyFlag = proxyUri ? ['--proxy', proxyUri] : [];
|
|
118
|
-
|
|
119
|
-
const envVars = proxyUri ? { env: Object.assign(process.env, { HTTP_PROXY: proxyUri, HTTPS_PROXY: proxyUri }) } : {};
|
|
120
|
-
|
|
121
|
-
let stdout = '';
|
|
122
|
-
let stderr = '';
|
|
123
|
-
|
|
124
|
-
const ops = '--no-save --no-package-lock --no-prune --prefer-offline --no-audit --progress=false'.split(' ');
|
|
125
|
-
const npmInstall = spawn('node', [localNpmLocation, 'i', '--prefix', prefix, ...ops, ...packageNames, ...proxyFlag], envVars);
|
|
126
|
-
npmInstall.stderr.pipe(process.stderr);
|
|
127
|
-
npmInstall.stdout.pipe(process.stdout);
|
|
128
|
-
|
|
129
|
-
npmInstall.stdout.on('data', (data) => {
|
|
130
|
-
stdout += data;
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
npmInstall.stderr.on('data', (data) => {
|
|
134
|
-
stderr += data;
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
npmInstall.on('close', (code) => {
|
|
138
|
-
if (code) {
|
|
139
|
-
let errorString;
|
|
140
|
-
try {
|
|
141
|
-
const packageVersion = /npm ERR! 404 {2}'(.+)' is not in the npm registry/gm.exec(stderr)[1];
|
|
142
|
-
const packageName = packageVersion.split('@')[0];
|
|
143
|
-
errorString = `404 Not Found - GET https://registry.npmjs.org/${packageName} - Not found`;
|
|
144
|
-
} catch (err) {
|
|
145
|
-
errorString = `Npm Install closed with exit code ${code}\n stdout: ${stdout} stderr: ${stderr}`;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
logger.debug(`Npm Install closed with exit code ${code}`, { message: errorString });
|
|
149
|
-
|
|
150
|
-
reject(new NpmPackageError(errorString));
|
|
151
|
-
} else {
|
|
152
|
-
resolve(stdout);
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
setTimeout(() => {
|
|
157
|
-
try {
|
|
158
|
-
npmInstall.kill();
|
|
159
|
-
} finally {
|
|
160
|
-
reject(new utils.TimeoutError());
|
|
161
|
-
}
|
|
162
|
-
}, timeoutMs);
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
module.exports = {
|
|
167
|
-
isPackageInstalledInPath,
|
|
168
|
-
getLatestPackageVersion,
|
|
169
|
-
getPackageIfInstalledLocally,
|
|
170
|
-
getLocallyInstalledPackageVersion,
|
|
171
|
-
installPackageLocally,
|
|
172
|
-
installPackages,
|
|
173
|
-
NpmPermissionsError,
|
|
174
|
-
};
|