checkly 0.0.0-pr.1006.2fb1ffc
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/README.md +102 -0
- package/bin/run +5 -0
- package/bin/run.cmd +3 -0
- package/constructs.d.ts +1 -0
- package/constructs.js +2 -0
- package/dist/auth/index.d.ts +15 -0
- package/dist/auth/index.js +262 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/commands/authCommand.d.ts +5 -0
- package/dist/commands/authCommand.js +37 -0
- package/dist/commands/authCommand.js.map +1 -0
- package/dist/commands/baseCommand.d.ts +13 -0
- package/dist/commands/baseCommand.js +48 -0
- package/dist/commands/baseCommand.js.map +1 -0
- package/dist/commands/deploy.d.ts +18 -0
- package/dist/commands/deploy.js +289 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/destroy.d.ts +10 -0
- package/dist/commands/destroy.js +84 -0
- package/dist/commands/destroy.js.map +1 -0
- package/dist/commands/env/add.d.ts +14 -0
- package/dist/commands/env/add.js +85 -0
- package/dist/commands/env/add.js.map +1 -0
- package/dist/commands/env/ls.d.ts +6 -0
- package/dist/commands/env/ls.js +44 -0
- package/dist/commands/env/ls.js.map +1 -0
- package/dist/commands/env/pull.d.ts +12 -0
- package/dist/commands/env/pull.js +99 -0
- package/dist/commands/env/pull.js.map +1 -0
- package/dist/commands/env/rm.d.ts +12 -0
- package/dist/commands/env/rm.js +82 -0
- package/dist/commands/env/rm.js.map +1 -0
- package/dist/commands/env/update.d.ts +14 -0
- package/dist/commands/env/update.js +88 -0
- package/dist/commands/env/update.js.map +1 -0
- package/dist/commands/help.d.ts +6 -0
- package/dist/commands/help.js +17 -0
- package/dist/commands/help.js.map +1 -0
- package/dist/commands/login.d.ts +13 -0
- package/dist/commands/login.js +134 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +9 -0
- package/dist/commands/logout.js +43 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/runtimes.d.ts +6 -0
- package/dist/commands/runtimes.js +49 -0
- package/dist/commands/runtimes.js.map +1 -0
- package/dist/commands/switch.d.ts +9 -0
- package/dist/commands/switch.js +81 -0
- package/dist/commands/switch.js.map +1 -0
- package/dist/commands/sync-playwright.d.ts +10 -0
- package/dist/commands/sync-playwright.js +98 -0
- package/dist/commands/sync-playwright.js.map +1 -0
- package/dist/commands/test.d.ts +45 -0
- package/dist/commands/test.js +366 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/trigger.d.ts +37 -0
- package/dist/commands/trigger.js +242 -0
- package/dist/commands/trigger.js.map +1 -0
- package/dist/commands/whoami.d.ts +6 -0
- package/dist/commands/whoami.js +42 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -0
- package/dist/constants.d.ts +7 -0
- package/dist/constants.js +10 -0
- package/dist/constants.js.map +1 -0
- package/dist/constructs/alert-channel-subscription.d.ts +44 -0
- package/dist/constructs/alert-channel-subscription.js +39 -0
- package/dist/constructs/alert-channel-subscription.js.map +1 -0
- package/dist/constructs/alert-channel.d.ts +53 -0
- package/dist/constructs/alert-channel.js +55 -0
- package/dist/constructs/alert-channel.js.map +1 -0
- package/dist/constructs/alert-escalation-policy.d.ts +34 -0
- package/dist/constructs/alert-escalation-policy.js +47 -0
- package/dist/constructs/alert-escalation-policy.js.map +1 -0
- package/dist/constructs/api-check.d.ts +187 -0
- package/dist/constructs/api-check.js +279 -0
- package/dist/constructs/api-check.js.map +1 -0
- package/dist/constructs/browser-check.d.ts +90 -0
- package/dist/constructs/browser-check.js +151 -0
- package/dist/constructs/browser-check.js.map +1 -0
- package/dist/constructs/check-group.d.ts +162 -0
- package/dist/constructs/check-group.js +208 -0
- package/dist/constructs/check-group.js.map +1 -0
- package/dist/constructs/check.d.ts +144 -0
- package/dist/constructs/check.js +133 -0
- package/dist/constructs/check.js.map +1 -0
- package/dist/constructs/construct.d.ts +17 -0
- package/dist/constructs/construct.js +22 -0
- package/dist/constructs/construct.js.map +1 -0
- package/dist/constructs/dashboard.d.ts +138 -0
- package/dist/constructs/dashboard.js +126 -0
- package/dist/constructs/dashboard.js.map +1 -0
- package/dist/constructs/email-alert-channel.d.ts +26 -0
- package/dist/constructs/email-alert-channel.js +37 -0
- package/dist/constructs/email-alert-channel.js.map +1 -0
- package/dist/constructs/environment-variable.d.ts +2 -0
- package/dist/constructs/environment-variable.js +3 -0
- package/dist/constructs/environment-variable.js.map +1 -0
- package/dist/constructs/frequency.d.ts +20 -0
- package/dist/constructs/frequency.js +26 -0
- package/dist/constructs/frequency.js.map +1 -0
- package/dist/constructs/heartbeat-check.d.ts +43 -0
- package/dist/constructs/heartbeat-check.js +61 -0
- package/dist/constructs/heartbeat-check.js.map +1 -0
- package/dist/constructs/http-header.d.ts +2 -0
- package/dist/constructs/http-header.js +3 -0
- package/dist/constructs/http-header.js.map +1 -0
- package/dist/constructs/index.d.ts +27 -0
- package/dist/constructs/index.js +44 -0
- package/dist/constructs/index.js.map +1 -0
- package/dist/constructs/key-value-pair.d.ts +6 -0
- package/dist/constructs/key-value-pair.js +3 -0
- package/dist/constructs/key-value-pair.js.map +1 -0
- package/dist/constructs/maintenance-window.d.ts +61 -0
- package/dist/constructs/maintenance-window.js +47 -0
- package/dist/constructs/maintenance-window.js.map +1 -0
- package/dist/constructs/multi-step-check.d.ts +65 -0
- package/dist/constructs/multi-step-check.js +153 -0
- package/dist/constructs/multi-step-check.js.map +1 -0
- package/dist/constructs/opsgenie-alert-channel.d.ts +45 -0
- package/dist/constructs/opsgenie-alert-channel.js +44 -0
- package/dist/constructs/opsgenie-alert-channel.js.map +1 -0
- package/dist/constructs/pagerduty-alert-channel.d.ts +39 -0
- package/dist/constructs/pagerduty-alert-channel.js +42 -0
- package/dist/constructs/pagerduty-alert-channel.js.map +1 -0
- package/dist/constructs/phone-call-alert-channel.d.ts +34 -0
- package/dist/constructs/phone-call-alert-channel.js +42 -0
- package/dist/constructs/phone-call-alert-channel.js.map +1 -0
- package/dist/constructs/playwright-config.d.ts +52 -0
- package/dist/constructs/playwright-config.js +3 -0
- package/dist/constructs/playwright-config.js.map +1 -0
- package/dist/constructs/private-location-check-assignment.d.ts +29 -0
- package/dist/constructs/private-location-check-assignment.js +35 -0
- package/dist/constructs/private-location-check-assignment.js.map +1 -0
- package/dist/constructs/private-location-group-assignment.d.ts +29 -0
- package/dist/constructs/private-location-group-assignment.js +35 -0
- package/dist/constructs/private-location-group-assignment.js.map +1 -0
- package/dist/constructs/private-location.d.ts +51 -0
- package/dist/constructs/private-location.js +61 -0
- package/dist/constructs/private-location.js.map +1 -0
- package/dist/constructs/project.d.ts +66 -0
- package/dist/constructs/project.js +155 -0
- package/dist/constructs/project.js.map +1 -0
- package/dist/constructs/query-param.d.ts +2 -0
- package/dist/constructs/query-param.js +3 -0
- package/dist/constructs/query-param.js.map +1 -0
- package/dist/constructs/ref.d.ts +5 -0
- package/dist/constructs/ref.js +13 -0
- package/dist/constructs/ref.js.map +1 -0
- package/dist/constructs/retry-strategy.d.ts +50 -0
- package/dist/constructs/retry-strategy.js +51 -0
- package/dist/constructs/retry-strategy.js.map +1 -0
- package/dist/constructs/slack-alert-channel.d.ts +26 -0
- package/dist/constructs/slack-alert-channel.js +40 -0
- package/dist/constructs/slack-alert-channel.js.map +1 -0
- package/dist/constructs/sms-alert-channel.d.ts +32 -0
- package/dist/constructs/sms-alert-channel.js +40 -0
- package/dist/constructs/sms-alert-channel.js.map +1 -0
- package/dist/constructs/validator-error.d.ts +2 -0
- package/dist/constructs/validator-error.js +7 -0
- package/dist/constructs/validator-error.js.map +1 -0
- package/dist/constructs/webhook-alert-channel.d.ts +67 -0
- package/dist/constructs/webhook-alert-channel.js +52 -0
- package/dist/constructs/webhook-alert-channel.js.map +1 -0
- package/dist/help/examples.d.ts +6 -0
- package/dist/help/examples.js +22 -0
- package/dist/help/examples.js.map +1 -0
- package/dist/help/help-extension.d.ts +7 -0
- package/dist/help/help-extension.js +59 -0
- package/dist/help/help-extension.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/common-messages.d.ts +5 -0
- package/dist/messages/common-messages.js +9 -0
- package/dist/messages/common-messages.js.map +1 -0
- package/dist/playwright/playwright-config-loader.d.ts +1 -0
- package/dist/playwright/playwright-config-loader.js +26 -0
- package/dist/playwright/playwright-config-loader.js.map +1 -0
- package/dist/playwright/playwright-config-template.d.ts +8 -0
- package/dist/playwright/playwright-config-template.js +78 -0
- package/dist/playwright/playwright-config-template.js.map +1 -0
- package/dist/reporters/abstract-list.d.ts +41 -0
- package/dist/reporters/abstract-list.js +171 -0
- package/dist/reporters/abstract-list.js.map +1 -0
- package/dist/reporters/ci.d.ts +12 -0
- package/dist/reporters/ci.js +34 -0
- package/dist/reporters/ci.js.map +1 -0
- package/dist/reporters/dot.d.ts +10 -0
- package/dist/reporters/dot.js +29 -0
- package/dist/reporters/dot.js.map +1 -0
- package/dist/reporters/github.d.ts +32 -0
- package/dist/reporters/github.js +119 -0
- package/dist/reporters/github.js.map +1 -0
- package/dist/reporters/json.d.ts +26 -0
- package/dist/reporters/json.js +101 -0
- package/dist/reporters/json.js.map +1 -0
- package/dist/reporters/list.d.ts +15 -0
- package/dist/reporters/list.js +85 -0
- package/dist/reporters/list.js.map +1 -0
- package/dist/reporters/reporter.d.ts +16 -0
- package/dist/reporters/reporter.js +29 -0
- package/dist/reporters/reporter.js.map +1 -0
- package/dist/reporters/util.d.ts +18 -0
- package/dist/reporters/util.js +325 -0
- package/dist/reporters/util.js.map +1 -0
- package/dist/rest/accounts.d.ts +12 -0
- package/dist/rest/accounts.js +15 -0
- package/dist/rest/accounts.js.map +1 -0
- package/dist/rest/api.d.ts +33 -0
- package/dist/rest/api.js +98 -0
- package/dist/rest/api.js.map +1 -0
- package/dist/rest/assets.d.ts +13 -0
- package/dist/rest/assets.js +30 -0
- package/dist/rest/assets.js.map +1 -0
- package/dist/rest/checkly-storage.d.ts +12 -0
- package/dist/rest/checkly-storage.js +15 -0
- package/dist/rest/checkly-storage.js.map +1 -0
- package/dist/rest/environment-variables.d.ts +17 -0
- package/dist/rest/environment-variables.js +25 -0
- package/dist/rest/environment-variables.js.map +1 -0
- package/dist/rest/heartbeat-checks.d.ts +11 -0
- package/dist/rest/heartbeat-checks.js +17 -0
- package/dist/rest/heartbeat-checks.js.map +1 -0
- package/dist/rest/locations.d.ts +11 -0
- package/dist/rest/locations.js +12 -0
- package/dist/rest/locations.js.map +1 -0
- package/dist/rest/private-locations.d.ts +10 -0
- package/dist/rest/private-locations.js +12 -0
- package/dist/rest/private-locations.js.map +1 -0
- package/dist/rest/projects.d.ts +46 -0
- package/dist/rest/projects.js +25 -0
- package/dist/rest/projects.js.map +1 -0
- package/dist/rest/runtimes.d.ts +16 -0
- package/dist/rest/runtimes.js +15 -0
- package/dist/rest/runtimes.js.map +1 -0
- package/dist/rest/test-sessions.d.ts +59 -0
- package/dist/rest/test-sessions.js +24 -0
- package/dist/rest/test-sessions.js.map +1 -0
- package/dist/rest/users.d.ts +12 -0
- package/dist/rest/users.js +12 -0
- package/dist/rest/users.js.map +1 -0
- package/dist/rest/util.d.ts +4 -0
- package/dist/rest/util.js +17 -0
- package/dist/rest/util.js.map +1 -0
- package/dist/services/abstract-check-runner.d.ts +60 -0
- package/dist/services/abstract-check-runner.js +225 -0
- package/dist/services/abstract-check-runner.js.map +1 -0
- package/dist/services/check-parser/collector.d.ts +33 -0
- package/dist/services/check-parser/collector.js +48 -0
- package/dist/services/check-parser/collector.js.map +1 -0
- package/dist/services/check-parser/errors.d.ts +8 -0
- package/dist/services/check-parser/errors.js +45 -0
- package/dist/services/check-parser/errors.js.map +1 -0
- package/dist/services/check-parser/package-files/index.d.ts +1 -0
- package/dist/services/check-parser/package-files/index.js +6 -0
- package/dist/services/check-parser/package-files/index.js.map +1 -0
- package/dist/services/check-parser/package-files/jsconfig-json-file.d.ts +17 -0
- package/dist/services/check-parser/package-files/jsconfig-json-file.js +46 -0
- package/dist/services/check-parser/package-files/jsconfig-json-file.js.map +1 -0
- package/dist/services/check-parser/package-files/json-source-file.d.ts +10 -0
- package/dist/services/check-parser/package-files/json-source-file.js +38 -0
- package/dist/services/check-parser/package-files/json-source-file.js.map +1 -0
- package/dist/services/check-parser/package-files/loader.d.ts +7 -0
- package/dist/services/check-parser/package-files/loader.js +19 -0
- package/dist/services/check-parser/package-files/loader.js.map +1 -0
- package/dist/services/check-parser/package-files/package-json-file.d.ts +20 -0
- package/dist/services/check-parser/package-files/package-json-file.js +48 -0
- package/dist/services/check-parser/package-files/package-json-file.js.map +1 -0
- package/dist/services/check-parser/package-files/paths.d.ts +80 -0
- package/dist/services/check-parser/package-files/paths.js +177 -0
- package/dist/services/check-parser/package-files/paths.js.map +1 -0
- package/dist/services/check-parser/package-files/resolver.d.ts +70 -0
- package/dist/services/check-parser/package-files/resolver.js +290 -0
- package/dist/services/check-parser/package-files/resolver.js.map +1 -0
- package/dist/services/check-parser/package-files/source-file.d.ts +15 -0
- package/dist/services/check-parser/package-files/source-file.js +54 -0
- package/dist/services/check-parser/package-files/source-file.js.map +1 -0
- package/dist/services/check-parser/package-files/tsconfig-json-file.d.ts +68 -0
- package/dist/services/check-parser/package-files/tsconfig-json-file.js +127 -0
- package/dist/services/check-parser/package-files/tsconfig-json-file.js.map +1 -0
- package/dist/services/check-parser/parser.d.ts +32 -0
- package/dist/services/check-parser/parser.js +313 -0
- package/dist/services/check-parser/parser.js.map +1 -0
- package/dist/services/checkly-config-loader.d.ts +72 -0
- package/dist/services/checkly-config-loader.js +103 -0
- package/dist/services/checkly-config-loader.js.map +1 -0
- package/dist/services/config.d.ts +28 -0
- package/dist/services/config.js +99 -0
- package/dist/services/config.js.map +1 -0
- package/dist/services/project-parser.d.ts +21 -0
- package/dist/services/project-parser.js +192 -0
- package/dist/services/project-parser.js.map +1 -0
- package/dist/services/snapshot-service.d.ts +13 -0
- package/dist/services/snapshot-service.js +85 -0
- package/dist/services/snapshot-service.js.map +1 -0
- package/dist/services/socket-client.d.ts +4 -0
- package/dist/services/socket-client.js +88 -0
- package/dist/services/socket-client.js.map +1 -0
- package/dist/services/test-filters.d.ts +3 -0
- package/dist/services/test-filters.js +27 -0
- package/dist/services/test-filters.js.map +1 -0
- package/dist/services/test-runner.d.ts +24 -0
- package/dist/services/test-runner.js +91 -0
- package/dist/services/test-runner.js.map +1 -0
- package/dist/services/trigger-runner.d.ts +29 -0
- package/dist/services/trigger-runner.js +59 -0
- package/dist/services/trigger-runner.js.map +1 -0
- package/dist/services/util.d.ts +32 -0
- package/dist/services/util.js +244 -0
- package/dist/services/util.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/oclif.manifest.json +635 -0
- package/package.json +151 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const api_1 = require("../rest/api");
|
|
30
|
+
const abstract_check_runner_1 = __importDefault(require("./abstract-check-runner"));
|
|
31
|
+
const snapshot_service_1 = require("../services/snapshot-service");
|
|
32
|
+
const uuid = __importStar(require("uuid"));
|
|
33
|
+
class TestRunner extends abstract_check_runner_1.default {
|
|
34
|
+
constructor(accountId, project, checks, location, timeout, verbose, shouldRecord, repoInfo, environment, updateSnapshots, baseDirectory, testRetryStrategy) {
|
|
35
|
+
super(accountId, timeout, verbose);
|
|
36
|
+
this.project = project;
|
|
37
|
+
this.checkConstructs = checks;
|
|
38
|
+
this.location = location;
|
|
39
|
+
this.shouldRecord = shouldRecord;
|
|
40
|
+
this.repoInfo = repoInfo;
|
|
41
|
+
this.environment = environment;
|
|
42
|
+
this.updateSnapshots = updateSnapshots;
|
|
43
|
+
this.baseDirectory = baseDirectory;
|
|
44
|
+
this.testRetryStrategy = testRetryStrategy;
|
|
45
|
+
}
|
|
46
|
+
async scheduleChecks(checkRunSuiteId) {
|
|
47
|
+
var _a, _b, _c, _d, _e, _f;
|
|
48
|
+
const checkRunJobs = this.checkConstructs.map(check => ({
|
|
49
|
+
...check.synthesize(),
|
|
50
|
+
testRetryStrategy: this.testRetryStrategy,
|
|
51
|
+
group: check.groupId ? this.project.data['check-group'][check.groupId.ref].synthesize() : undefined,
|
|
52
|
+
groupId: undefined,
|
|
53
|
+
sourceInfo: {
|
|
54
|
+
checkRunSuiteId,
|
|
55
|
+
checkRunId: uuid.v4(),
|
|
56
|
+
updateSnapshots: this.updateSnapshots,
|
|
57
|
+
},
|
|
58
|
+
logicalId: check.logicalId,
|
|
59
|
+
filePath: check.getSourceFile(),
|
|
60
|
+
}));
|
|
61
|
+
try {
|
|
62
|
+
if (!checkRunJobs.length) {
|
|
63
|
+
throw new Error('Unable to find checks to run.');
|
|
64
|
+
}
|
|
65
|
+
const { data } = await api_1.testSessions.run({
|
|
66
|
+
name: this.project.name,
|
|
67
|
+
checkRunJobs,
|
|
68
|
+
project: { logicalId: this.project.logicalId },
|
|
69
|
+
runLocation: this.location,
|
|
70
|
+
repoInfo: this.repoInfo,
|
|
71
|
+
environment: this.environment,
|
|
72
|
+
shouldRecord: this.shouldRecord,
|
|
73
|
+
});
|
|
74
|
+
const { testSessionId, sequenceIds } = data;
|
|
75
|
+
const checks = this.checkConstructs.map(check => ({ check, sequenceId: sequenceIds === null || sequenceIds === void 0 ? void 0 : sequenceIds[check.logicalId] }));
|
|
76
|
+
return { testSessionId, checks };
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
throw new Error((_f = (_c = (_b = (_a = err.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : (_e = (_d = err.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.error) !== null && _f !== void 0 ? _f : err.message);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
async processCheckResult(result) {
|
|
83
|
+
var _a;
|
|
84
|
+
await super.processCheckResult(result);
|
|
85
|
+
if (this.updateSnapshots) {
|
|
86
|
+
await (0, snapshot_service_1.pullSnapshots)(this.baseDirectory, (_a = result.assets) === null || _a === void 0 ? void 0 : _a.snapshots);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.default = TestRunner;
|
|
91
|
+
//# sourceMappingURL=test-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-runner.js","sourceRoot":"","sources":["../../src/services/test-runner.ts"],"names":[],"mappings":";;;;;;;;;;;;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AC;IAED,KAAK,CAAC,kBAAkB,CAAE,MAAW;;QACnC,MAAM,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;QACtC,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,MAAM,IAAA,gCAAa,EAAC,IAAI,CAAC,aAAa,EAAE,MAAA,MAAM,CAAC,MAAM,0CAAE,SAAS,CAAC,CAAA;QACnE,CAAC;IACH,CAAC;CACF;AAnFD,6BAmFC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RetryStrategy } from '../constructs';
|
|
2
|
+
import AbstractCheckRunner, { RunLocation, SequenceId } from './abstract-check-runner';
|
|
3
|
+
import { GitInformation } from './util';
|
|
4
|
+
export declare class NoMatchingChecksError extends Error {
|
|
5
|
+
}
|
|
6
|
+
export default class TriggerRunner extends AbstractCheckRunner {
|
|
7
|
+
shouldRecord: boolean;
|
|
8
|
+
location: RunLocation;
|
|
9
|
+
targetTags: string[][];
|
|
10
|
+
envVars: Array<{
|
|
11
|
+
key: string;
|
|
12
|
+
value: string;
|
|
13
|
+
}>;
|
|
14
|
+
repoInfo: GitInformation | null;
|
|
15
|
+
environment: string | null;
|
|
16
|
+
testSessionName: string | undefined;
|
|
17
|
+
testRetryStrategy: RetryStrategy | null;
|
|
18
|
+
constructor(accountId: string, timeout: number, verbose: boolean, shouldRecord: boolean, location: RunLocation, targetTags: string[][], envVars: Array<{
|
|
19
|
+
key: string;
|
|
20
|
+
value: string;
|
|
21
|
+
}>, repoInfo: GitInformation | null, environment: string | null, testSessionName: string | undefined, testRetryStrategy: RetryStrategy | null);
|
|
22
|
+
scheduleChecks(checkRunSuiteId: string): Promise<{
|
|
23
|
+
testSessionId?: string;
|
|
24
|
+
checks: Array<{
|
|
25
|
+
check: any;
|
|
26
|
+
sequenceId: SequenceId;
|
|
27
|
+
}>;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NoMatchingChecksError = void 0;
|
|
7
|
+
const api_1 = require("../rest/api");
|
|
8
|
+
const abstract_check_runner_1 = __importDefault(require("./abstract-check-runner"));
|
|
9
|
+
class NoMatchingChecksError extends Error {
|
|
10
|
+
}
|
|
11
|
+
exports.NoMatchingChecksError = NoMatchingChecksError;
|
|
12
|
+
class TriggerRunner extends abstract_check_runner_1.default {
|
|
13
|
+
constructor(accountId, timeout, verbose, shouldRecord, location, targetTags, envVars, repoInfo, environment, testSessionName, testRetryStrategy) {
|
|
14
|
+
super(accountId, timeout, verbose);
|
|
15
|
+
this.shouldRecord = shouldRecord;
|
|
16
|
+
this.location = location;
|
|
17
|
+
this.targetTags = targetTags;
|
|
18
|
+
this.envVars = envVars;
|
|
19
|
+
this.repoInfo = repoInfo;
|
|
20
|
+
this.environment = environment;
|
|
21
|
+
this.testSessionName = testSessionName;
|
|
22
|
+
this.testRetryStrategy = testRetryStrategy;
|
|
23
|
+
}
|
|
24
|
+
async scheduleChecks(checkRunSuiteId) {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f;
|
|
26
|
+
try {
|
|
27
|
+
const { data } = await api_1.testSessions.trigger({
|
|
28
|
+
name: (_a = this.testSessionName) !== null && _a !== void 0 ? _a : 'Triggered Session',
|
|
29
|
+
shouldRecord: this.shouldRecord,
|
|
30
|
+
runLocation: this.location,
|
|
31
|
+
checkRunSuiteId,
|
|
32
|
+
targetTags: this.targetTags,
|
|
33
|
+
environmentVariables: this.envVars,
|
|
34
|
+
repoInfo: this.repoInfo,
|
|
35
|
+
environment: this.environment,
|
|
36
|
+
testRetryStrategy: this.testRetryStrategy,
|
|
37
|
+
});
|
|
38
|
+
const { checks, testSessionId, sequenceIds, } = data;
|
|
39
|
+
if (!checks.length) {
|
|
40
|
+
// Currently the BE will never return an empty `checks` array, it returns a 403 instead.
|
|
41
|
+
// This is added to make the old CLI versions compatible if we ever change this, though.
|
|
42
|
+
throw new NoMatchingChecksError();
|
|
43
|
+
}
|
|
44
|
+
const augmentedChecks = checks.map(check => ({
|
|
45
|
+
check,
|
|
46
|
+
sequenceId: sequenceIds === null || sequenceIds === void 0 ? void 0 : sequenceIds[check.id],
|
|
47
|
+
}));
|
|
48
|
+
return { checks: augmentedChecks, testSessionId };
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if (((_c = (_b = err.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.errorCode) === 'ERR_NO_MATCHING_CHECKS') {
|
|
52
|
+
throw new NoMatchingChecksError();
|
|
53
|
+
}
|
|
54
|
+
throw new Error((_f = (_e = (_d = err.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.message) !== null && _f !== void 0 ? _f : err.message);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.default = TriggerRunner;
|
|
59
|
+
//# sourceMappingURL=trigger-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trigger-runner.js","sourceRoot":"","sources":["../../src/services/trigger-runner.ts"],"names":[],"mappings":";;;;;;AACA,qCAA0C;AAC1C,oFAAsF;AAGtF,MAAa,qBAAsB,SAAQ,KAAK;CAAG;AAAnD,sDAAmD;AAEnD,MAAqB,aAAc,SAAQ,+BAAmB;IAU5D,YACE,SAAiB,EACjB,OAAe,EACf,OAAgB,EAChB,YAAqB,EACrB,QAAqB,EACrB,UAAsB,EACtB,OAA8C,EAC9C,QAA+B,EAC/B,WAA0B,EAC1B,eAAmC,EACnC,iBAAuC;QAEvC,KAAK,CAAC,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;QAClC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;QAChC,IAAI,CAAC,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,EAAE,CAAA;QACnD,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAA,MAAA,MAAA,GAAG,CAAC,QAAQ,0CAAE,IAAI,0CAAE,SAAS,MAAK,wBAAwB,EAAE,CAAC;gBAC/D,MAAM,IAAI,qBAAqB,EAAE,CAAA;YACnC,CAAC;YACD,MAAM,IAAI,KAAK,CAAC,MAAA,MAAA,MAAA,GAAG,CAAC,QAAQ,0CAAE,IAAI,0CAAE,OAAO,mCAAI,GAAG,CAAC,OAAO,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;CACF;AA/ED,gCA+EC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CreateAxiosDefaults } from 'axios';
|
|
2
|
+
export interface GitInformation {
|
|
3
|
+
commitId: string;
|
|
4
|
+
repoUrl?: string | null;
|
|
5
|
+
branchName?: string | null;
|
|
6
|
+
commitOwner?: string | null;
|
|
7
|
+
commitMessage?: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface CiInformation {
|
|
10
|
+
environment: string | null;
|
|
11
|
+
}
|
|
12
|
+
export declare function findFilesRecursively(directory: string, ignoredPaths?: Array<string>): string[];
|
|
13
|
+
export declare function loadJsFile(filepath: string): Promise<any>;
|
|
14
|
+
export declare function loadTsFile(filepath: string): Promise<any>;
|
|
15
|
+
/**
|
|
16
|
+
* @param relPath the path to be converted
|
|
17
|
+
* @param separator this is for testing purposes only so we can reliably replace the separator on Linux / Darwin
|
|
18
|
+
*/
|
|
19
|
+
export declare function pathToPosix(relPath: string, separator?: string): string;
|
|
20
|
+
export declare function splitConfigFilePath(configFile?: string): {
|
|
21
|
+
configDirectory: string;
|
|
22
|
+
configFilenames?: string[];
|
|
23
|
+
};
|
|
24
|
+
export declare function isFileSync(path: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* @param repoUrl default repoURL the user can set in their project config.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getGitInformation(repoUrl?: string): GitInformation | null;
|
|
29
|
+
export declare function getCiInformation(): CiInformation;
|
|
30
|
+
export declare function escapeValue(value: string | undefined): string;
|
|
31
|
+
export declare function getEnvs(envFile: string | undefined, envArgs: Array<string>): Promise<import("dotenv").DotenvParseOutput>;
|
|
32
|
+
export declare function assignProxy(baseURL: string, axiosConfig: CreateAxiosDefaults): CreateAxiosDefaults<any>;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.assignProxy = exports.getEnvs = exports.escapeValue = exports.getCiInformation = exports.getGitInformation = exports.isFileSync = exports.splitConfigFilePath = exports.pathToPosix = exports.loadTsFile = exports.loadJsFile = exports.findFilesRecursively = void 0;
|
|
30
|
+
const path = __importStar(require("path"));
|
|
31
|
+
const fs = __importStar(require("fs/promises"));
|
|
32
|
+
const fsSync = __importStar(require("fs"));
|
|
33
|
+
const git_repo_info_1 = __importDefault(require("git-repo-info"));
|
|
34
|
+
const dotenv_1 = require("dotenv");
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
const proxy_from_env_1 = require("proxy-from-env");
|
|
37
|
+
const tunnel_1 = require("tunnel");
|
|
38
|
+
// Copied from oclif/core
|
|
39
|
+
// eslint-disable-next-line
|
|
40
|
+
const _importDynamic = new Function('modulePath', 'return import(modulePath)');
|
|
41
|
+
function findFilesRecursively(directory, ignoredPaths = []) {
|
|
42
|
+
var _a;
|
|
43
|
+
if (!((_a = fsSync.statSync(directory, { throwIfNoEntry: false })) === null || _a === void 0 ? void 0 : _a.isDirectory())) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
const files = [];
|
|
47
|
+
const directoriesToVisit = [directory];
|
|
48
|
+
const ignoredPathsSet = new Set(ignoredPaths);
|
|
49
|
+
while (directoriesToVisit.length > 0) {
|
|
50
|
+
const currentDirectory = directoriesToVisit.shift();
|
|
51
|
+
const contents = fsSync.readdirSync(currentDirectory, { withFileTypes: true });
|
|
52
|
+
for (const content of contents) {
|
|
53
|
+
if (content.isSymbolicLink()) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const fullPath = path.resolve(currentDirectory, content.name);
|
|
57
|
+
if (ignoredPathsSet.has(fullPath)) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (content.isDirectory()) {
|
|
61
|
+
directoriesToVisit.push(fullPath);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
files.push(fullPath);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return files;
|
|
69
|
+
}
|
|
70
|
+
exports.findFilesRecursively = findFilesRecursively;
|
|
71
|
+
async function loadJsFile(filepath) {
|
|
72
|
+
try {
|
|
73
|
+
// There is a Node opened issue related with a segmentation fault using ES6 modules
|
|
74
|
+
// with jest https://github.com/nodejs/node/issues/35889
|
|
75
|
+
// As a work around, we check if Jest is running to modify the way to import the module.
|
|
76
|
+
// TODO: investigate if the issue is fixed to clean up the conditional import
|
|
77
|
+
let { default: exported } = typeof jest !== 'undefined'
|
|
78
|
+
? { default: await require(filepath) }
|
|
79
|
+
: await _importDynamic(pathToPosix(filepath));
|
|
80
|
+
if (exported instanceof Function) {
|
|
81
|
+
exported = await exported();
|
|
82
|
+
}
|
|
83
|
+
return exported;
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
throw new Error(`Error loading file ${filepath}\n${err.stack}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.loadJsFile = loadJsFile;
|
|
90
|
+
async function loadTsFile(filepath) {
|
|
91
|
+
try {
|
|
92
|
+
const tsCompiler = await getTsCompiler();
|
|
93
|
+
tsCompiler.enabled(true);
|
|
94
|
+
let { default: exported } = await require(filepath);
|
|
95
|
+
if (exported instanceof Function) {
|
|
96
|
+
exported = await exported();
|
|
97
|
+
}
|
|
98
|
+
tsCompiler.enabled(false); // Re-disable the TS compiler
|
|
99
|
+
return exported;
|
|
100
|
+
}
|
|
101
|
+
catch (err) {
|
|
102
|
+
throw new Error(`Error loading file ${filepath}\n${err.stack}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.loadTsFile = loadTsFile;
|
|
106
|
+
// To avoid a dependency on typescript for users with no TS checks, we need to dynamically import ts-node
|
|
107
|
+
let tsCompiler;
|
|
108
|
+
async function getTsCompiler() {
|
|
109
|
+
if (tsCompiler)
|
|
110
|
+
return tsCompiler;
|
|
111
|
+
try {
|
|
112
|
+
const tsNode = await import('ts-node');
|
|
113
|
+
tsCompiler = tsNode.register({
|
|
114
|
+
moduleTypes: {
|
|
115
|
+
'**/*': 'cjs',
|
|
116
|
+
},
|
|
117
|
+
compilerOptions: {
|
|
118
|
+
module: 'CommonJS',
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
if (err.code === 'ERR_MODULE_NOT_FOUND' || err.code === 'MODULE_NOT_FOUND') {
|
|
124
|
+
throw new Error('Please install "ts-node" and "typescript" to use TypeScript configuration files');
|
|
125
|
+
}
|
|
126
|
+
throw err;
|
|
127
|
+
}
|
|
128
|
+
return tsCompiler;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @param relPath the path to be converted
|
|
132
|
+
* @param separator this is for testing purposes only so we can reliably replace the separator on Linux / Darwin
|
|
133
|
+
*/
|
|
134
|
+
function pathToPosix(relPath, separator) {
|
|
135
|
+
// Windows uses \ rather than / as a path separator.
|
|
136
|
+
// It's important that logical ID's are consistent across platforms, though.
|
|
137
|
+
// Otherwise, checks will be deleted and recreated when `npx checkly deploy` is run on different machines.
|
|
138
|
+
return path.normalize(relPath).split(separator !== null && separator !== void 0 ? separator : path.sep).join(path.posix.sep).replace(/^[C|D]:/i, '');
|
|
139
|
+
}
|
|
140
|
+
exports.pathToPosix = pathToPosix;
|
|
141
|
+
function splitConfigFilePath(configFile) {
|
|
142
|
+
if (configFile) {
|
|
143
|
+
const cwd = path.resolve(path.dirname(configFile));
|
|
144
|
+
return {
|
|
145
|
+
configDirectory: cwd,
|
|
146
|
+
configFilenames: [path.basename(configFile)],
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
configDirectory: process.cwd(),
|
|
151
|
+
configFilenames: undefined,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
exports.splitConfigFilePath = splitConfigFilePath;
|
|
155
|
+
function isFileSync(path) {
|
|
156
|
+
// This helper is useful to test paths inside constructors which cannot be async.
|
|
157
|
+
let result;
|
|
158
|
+
try {
|
|
159
|
+
result = fsSync.existsSync(path);
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
throw new Error(`Error parsing the file path: ${path}`);
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
exports.isFileSync = isFileSync;
|
|
167
|
+
/**
|
|
168
|
+
* @param repoUrl default repoURL the user can set in their project config.
|
|
169
|
+
*/
|
|
170
|
+
function getGitInformation(repoUrl) {
|
|
171
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
172
|
+
const repositoryInfo = (0, git_repo_info_1.default)();
|
|
173
|
+
if (!process.env.CHECKLY_REPO_SHA && !process.env.CHECKLY_TEST_REPO_SHA && !repositoryInfo.sha) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
// safe way to remove the email address
|
|
177
|
+
const committer = (_b = (((_a = repositoryInfo.committer) === null || _a === void 0 ? void 0 : _a.match(/([^<]+)/)) || [])[1]) === null || _b === void 0 ? void 0 : _b.trim();
|
|
178
|
+
return {
|
|
179
|
+
commitId: (_d = (_c = process.env.CHECKLY_REPO_SHA) !== null && _c !== void 0 ? _c : process.env.CHECKLY_TEST_REPO_SHA) !== null && _d !== void 0 ? _d : repositoryInfo.sha,
|
|
180
|
+
repoUrl: (_f = (_e = process.env.CHECKLY_REPO_URL) !== null && _e !== void 0 ? _e : process.env.CHECKLY_TEST_REPO_URL) !== null && _f !== void 0 ? _f : repoUrl,
|
|
181
|
+
branchName: (_h = (_g = process.env.CHECKLY_REPO_BRANCH) !== null && _g !== void 0 ? _g : process.env.CHECKLY_TEST_REPO_BRANCH) !== null && _h !== void 0 ? _h : repositoryInfo.branch,
|
|
182
|
+
commitOwner: (_k = (_j = process.env.CHECKLY_REPO_COMMIT_OWNER) !== null && _j !== void 0 ? _j : process.env.CHECKLY_TEST_REPO_COMMIT_OWNER) !== null && _k !== void 0 ? _k : committer,
|
|
183
|
+
commitMessage: (_m = (_l = process.env.CHECKLY_REPO_COMMIT_MESSAGE) !== null && _l !== void 0 ? _l : process.env.CHECKLY_TEST_REPO_COMMIT_MESSAGE) !== null && _m !== void 0 ? _m : repositoryInfo.commitMessage,
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
exports.getGitInformation = getGitInformation;
|
|
187
|
+
function getCiInformation() {
|
|
188
|
+
var _a;
|
|
189
|
+
return {
|
|
190
|
+
environment: (_a = process.env.CHECKLY_TEST_ENVIRONMENT) !== null && _a !== void 0 ? _a : null,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
exports.getCiInformation = getCiInformation;
|
|
194
|
+
function escapeValue(value) {
|
|
195
|
+
return value
|
|
196
|
+
? value
|
|
197
|
+
.replace(/\n/g, '\\n') // combine newlines (unix) into one line
|
|
198
|
+
.replace(/\r/g, '\\r') // combine newlines (windows) into one line
|
|
199
|
+
: '';
|
|
200
|
+
}
|
|
201
|
+
exports.escapeValue = escapeValue;
|
|
202
|
+
async function getEnvs(envFile, envArgs) {
|
|
203
|
+
if (envFile) {
|
|
204
|
+
const envsString = await fs.readFile(envFile, { encoding: 'utf8' });
|
|
205
|
+
return (0, dotenv_1.parse)(envsString);
|
|
206
|
+
}
|
|
207
|
+
const envsString = `${envArgs.join('\n')}`;
|
|
208
|
+
return (0, dotenv_1.parse)(envsString);
|
|
209
|
+
}
|
|
210
|
+
exports.getEnvs = getEnvs;
|
|
211
|
+
const isHttps = (protocol) => protocol.startsWith('https');
|
|
212
|
+
function assignProxy(baseURL, axiosConfig) {
|
|
213
|
+
const proxyUrlEnv = (0, proxy_from_env_1.getProxyForUrl)(baseURL);
|
|
214
|
+
if (!proxyUrlEnv) {
|
|
215
|
+
return axiosConfig;
|
|
216
|
+
}
|
|
217
|
+
const parsedProxyUrl = new URL(proxyUrlEnv);
|
|
218
|
+
const isProxyHttps = isHttps(parsedProxyUrl.protocol);
|
|
219
|
+
const isEndpointHttps = isHttps(baseURL);
|
|
220
|
+
const proxy = {
|
|
221
|
+
host: parsedProxyUrl.hostname,
|
|
222
|
+
port: parsedProxyUrl.port,
|
|
223
|
+
protocol: parsedProxyUrl.protocol,
|
|
224
|
+
};
|
|
225
|
+
if (parsedProxyUrl.username && parsedProxyUrl.password) {
|
|
226
|
+
proxy.proxyAuth = `${parsedProxyUrl.username}:${parsedProxyUrl.password}`;
|
|
227
|
+
}
|
|
228
|
+
if (isProxyHttps && isEndpointHttps) {
|
|
229
|
+
axiosConfig.httpsAgent = (0, tunnel_1.httpsOverHttps)({ proxy });
|
|
230
|
+
}
|
|
231
|
+
else if (isProxyHttps && !isEndpointHttps) {
|
|
232
|
+
axiosConfig.httpAgent = (0, tunnel_1.httpOverHttps)({ proxy });
|
|
233
|
+
}
|
|
234
|
+
else if (!isProxyHttps && isEndpointHttps) {
|
|
235
|
+
axiosConfig.httpsAgent = (0, tunnel_1.httpsOverHttp)({ proxy });
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
axiosConfig.httpAgent = (0, tunnel_1.httpOverHttp)({ proxy });
|
|
239
|
+
}
|
|
240
|
+
axiosConfig.proxy = false;
|
|
241
|
+
return axiosConfig;
|
|
242
|
+
}
|
|
243
|
+
exports.assignProxy = assignProxy;
|
|
244
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/services/util.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,2CAA4B;AAC5B,gDAAiC;AACjC,2CAA4B;AAE5B,kEAAuC;AACvC,mCAA8B;AAC9B,aAAa;AACb,mDAA+C;AAC/C,mCAAmF;AAEnF,yBAAyB;AACzB,2BAA2B;AAC3B,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAC,CAAA;AAc9E,SAAgB,oBAAoB,CAAE,SAAiB,EAAE,eAA8B,EAAE;;IACvF,IAAI,CA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