@mablhq/mabl-cli 1.19.3 → 1.20.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/api/basicApiClient.js +4 -8
- package/api/mablApiClient.js +3 -3
- package/api/mablApiClientFactory.js +9 -9
- package/api/types.js +8 -0
- package/auth/AuthClient.js +1 -0
- package/auth/OktaClient.js +66 -21
- package/browserLauncher/playwrightBrowserLauncher/playwrightDom.js +11 -4
- package/browserLauncher/playwrightBrowserLauncher/playwrightFrame.js +1 -1
- package/browserLauncher/types.js +2 -2
- package/cli.js +1 -3
- package/commands/applications/applications_cmds/list.js +1 -1
- package/commands/auth/auth_cmds/activate-key.js +2 -2
- package/commands/auth/auth_cmds/clear.js +1 -1
- package/commands/auth/auth_cmds/info.js +1 -1
- package/commands/branches/branches_cmds/create.js +1 -1
- package/commands/branches/branches_cmds/describe.js +1 -1
- package/commands/branches/branches_cmds/list.js +1 -1
- package/commands/branches/branches_cmds/merge.js +1 -1
- package/commands/commandUtil/util.js +3 -3
- package/commands/config/config_cmds/configKeys.js +11 -0
- package/commands/config/config_cmds/delete.js +6 -5
- package/commands/config/config_cmds/get.js +6 -5
- package/commands/config/config_cmds/list.js +7 -7
- package/commands/config/config_cmds/set.js +14 -21
- package/commands/credentials/credentials_cmds/list.js +1 -1
- package/commands/deploy/deploy_cmds/create.js +2 -2
- package/commands/deploy/deploy_cmds/list.js +1 -1
- package/commands/environments/environments_cmds/create.js +8 -4
- package/commands/environments/environments_cmds/list.js +1 -1
- package/commands/flows/flows_cmds/list.js +1 -1
- package/commands/link-agents/link-agents_cmds/delete.js +1 -6
- package/commands/plans/plans_cmds/list.js +1 -1
- package/commands/tests/testsUtil.js +8 -8
- package/commands/tests/tests_cmds/create.js +1 -1
- package/commands/tests/tests_cmds/import.js +2 -2
- package/commands/tests/tests_cmds/list.js +1 -1
- package/commands/tests/tests_cmds/run-cloud.js +3 -7
- package/commands/tests/tests_cmds/run.js +8 -4
- package/commands/tests/tests_cmds/trainer_cmds/trainerUtil.js +2 -2
- package/execution/index.js +1 -1
- package/package.json +2 -1
- package/providers/authenticationProvider.js +106 -60
- package/providers/cliConfigProvider.js +159 -61
- package/providers/types.js +9 -0
- package/util/analytics.js +8 -8
- package/util/httpUtil.js +2 -2
- package/utilities.js +7 -0
|
@@ -18,7 +18,7 @@ exports.handler = (0, util_1.failWrapper)(listCredentials);
|
|
|
18
18
|
async function listCredentials(parsed) {
|
|
19
19
|
const output = parsed.output;
|
|
20
20
|
const limit = parsed.limit;
|
|
21
|
-
const workspaceId = (0, util_1.getWorkspaceId)(parsed);
|
|
21
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
22
22
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
23
23
|
const credentials = await apiClient.getCredentials(workspaceId, limit);
|
|
24
24
|
printCredentials(credentials, output);
|
|
@@ -10,7 +10,7 @@ const awaitDeploymentCompletion_1 = require("./awaitDeploymentCompletion");
|
|
|
10
10
|
const moment = require("moment");
|
|
11
11
|
const scmContextProvider_1 = require("../../../providers/scmContextProvider");
|
|
12
12
|
const cliConfigProvider_1 = require("../../../providers/cliConfigProvider");
|
|
13
|
-
const
|
|
13
|
+
const configKeys_1 = require("../../config/config_cmds/configKeys");
|
|
14
14
|
const codeInsights_1 = require("../../commandUtil/codeInsights");
|
|
15
15
|
const constants_1 = require("../../constants");
|
|
16
16
|
const describe_1 = require("../../commandUtil/describe");
|
|
@@ -277,7 +277,7 @@ exports.printDeploymentEventResultOutput = printDeploymentEventResultOutput;
|
|
|
277
277
|
async function collectSourceControlMetadataIfEnabled(parsed) {
|
|
278
278
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
279
279
|
const userSuppliedRepositoryUrl = parsed['repository-url'];
|
|
280
|
-
if (cliConfigProvider_1.CliConfigProvider.getConfigProperty(
|
|
280
|
+
if (await cliConfigProvider_1.CliConfigProvider.getConfigProperty(configKeys_1.configKeys.enableSourceControlMetadataCollection)) {
|
|
281
281
|
const buildInfo = await new scmContextProvider_1.ScmContextProvider(process.env).extractScmAndBuildInfo();
|
|
282
282
|
const sourceControlBranch = ((_a = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.scmInfo) === null || _a === void 0 ? void 0 : _a.branchName) || ((_b = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.buildInfo) === null || _b === void 0 ? void 0 : _b.branchName);
|
|
283
283
|
const sourceControlTag = ((_c = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.scmInfo) === null || _c === void 0 ? void 0 : _c.tagName) || ((_d = buildInfo === null || buildInfo === void 0 ? void 0 : buildInfo.buildInfo) === null || _d === void 0 ? void 0 : _d.tagName);
|
|
@@ -18,7 +18,7 @@ exports.handler = (0, util_1.failWrapper)(listDeployments);
|
|
|
18
18
|
async function listDeployments(parsed) {
|
|
19
19
|
const output = parsed.output;
|
|
20
20
|
const limit = parsed.limit;
|
|
21
|
-
const workspaceId = (0, util_1.getWorkspaceId)(parsed);
|
|
21
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
22
22
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
23
23
|
const deployments = await apiClient.getDeploymentEvents(workspaceId, limit);
|
|
24
24
|
printDeployments(deployments, output);
|
|
@@ -12,7 +12,6 @@ const branches_1 = require("../../commandUtil/branches");
|
|
|
12
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
13
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
14
14
|
const add_1 = require("./urls_cmds/add");
|
|
15
|
-
const cliConfigProvider_1 = require("../../../providers/cliConfigProvider");
|
|
16
15
|
exports.command = 'create';
|
|
17
16
|
exports.describe = 'Create a new mabl environment';
|
|
18
17
|
exports.builder = (yargs) => {
|
|
@@ -96,11 +95,16 @@ function addUpdateEnvCommands(argv) {
|
|
|
96
95
|
}
|
|
97
96
|
exports.addUpdateEnvCommands = addUpdateEnvCommands;
|
|
98
97
|
async function createEnvironment(parsed) {
|
|
99
|
-
var _a
|
|
98
|
+
var _a;
|
|
100
99
|
let environment;
|
|
101
100
|
try {
|
|
102
101
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
103
|
-
|
|
102
|
+
let workspaceId;
|
|
103
|
+
try {
|
|
104
|
+
workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
}
|
|
104
108
|
environment = {
|
|
105
109
|
organization_id: workspaceId,
|
|
106
110
|
name: parsed[constants_1.CommandArgName],
|
|
@@ -114,7 +118,7 @@ async function createEnvironment(parsed) {
|
|
|
114
118
|
variables: parsed[constants_1.CommandArgVariables],
|
|
115
119
|
};
|
|
116
120
|
environment = await apiClient.createEnvironment(environment);
|
|
117
|
-
loggingProvider_1.logger.info(chalk_1.default.green(`Environment ${chalk_1.default.bold((
|
|
121
|
+
loggingProvider_1.logger.info(chalk_1.default.green(`Environment ${chalk_1.default.bold((_a = environment.id) !== null && _a !== void 0 ? _a : '')} CREATED`));
|
|
118
122
|
const applicationId = parsed[constants_1.CommandArgApplicationId];
|
|
119
123
|
if (applicationId) {
|
|
120
124
|
loggingProvider_1.logger.info('Associating URLs with environment');
|
|
@@ -17,7 +17,7 @@ exports.builder = (0, list_1.getListBuilderOptions)('environments');
|
|
|
17
17
|
exports.handler = (0, util_1.failWrapper)(listEnvironments);
|
|
18
18
|
async function listEnvironments(parsed) {
|
|
19
19
|
const output = parsed.output;
|
|
20
|
-
const workspaceId = (0, util_1.getWorkspaceId)(parsed);
|
|
20
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
21
21
|
const limit = parsed.limit;
|
|
22
22
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
23
23
|
const environments = await apiClient.getEnvironments(workspaceId, limit);
|
|
@@ -30,7 +30,7 @@ exports.builder = (yargs) => {
|
|
|
30
30
|
exports.handler = (0, util_1.failWrapper)(listFlows);
|
|
31
31
|
async function listFlows(parsed) {
|
|
32
32
|
const limit = parsed.limit;
|
|
33
|
-
const workspaceId = (0, util_1.getWorkspaceId)(parsed);
|
|
33
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
34
34
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
35
35
|
const flows = await apiClient.getFlows({
|
|
36
36
|
organization_id: workspaceId,
|
|
@@ -8,7 +8,6 @@ const constants_1 = require("../../constants");
|
|
|
8
8
|
const util_1 = require("../../commandUtil/util");
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
11
|
-
const cliConfigProvider_1 = require("../../../providers/cliConfigProvider");
|
|
12
11
|
exports.command = `delete <${constants_1.CommandArgLinkLabel}>`;
|
|
13
12
|
exports.describe =
|
|
14
13
|
'Delete link agents and infrastructure associate with the link agent label and block new agents with the given label for 15 minutes. Customers dynamically creating link agents must call this when the agent is no longer needed.';
|
|
@@ -25,14 +24,10 @@ exports.builder = (yargs) => {
|
|
|
25
24
|
};
|
|
26
25
|
exports.handler = (0, util_1.failWrapper)(deleteLinkAgent);
|
|
27
26
|
async function deleteLinkAgent(parsed) {
|
|
28
|
-
var _a, _b;
|
|
29
27
|
try {
|
|
30
28
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
31
29
|
const linkLabel = parsed[constants_1.CommandArgLinkLabel];
|
|
32
|
-
const workspaceId = (
|
|
33
|
-
if (!workspaceId) {
|
|
34
|
-
throw new Error('Workspace id is required');
|
|
35
|
-
}
|
|
30
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
36
31
|
await apiClient.deleteLinkLabel(workspaceId, linkLabel);
|
|
37
32
|
loggingProvider_1.logger.info(chalk_1.default.green(`Link agent ${chalk_1.default.bold(linkLabel)} DELETED`));
|
|
38
33
|
return linkLabel;
|
|
@@ -30,7 +30,7 @@ exports.builder = (yargs) => {
|
|
|
30
30
|
exports.handler = (0, util_1.failWrapper)(listPlans);
|
|
31
31
|
async function listPlans(parsed) {
|
|
32
32
|
const limit = parsed.limit;
|
|
33
|
-
const workspaceId = (0, util_1.getWorkspaceId)(parsed);
|
|
33
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
34
34
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
35
35
|
const plans = await apiClient.getPlans({
|
|
36
36
|
organization_id: workspaceId,
|
|
@@ -34,7 +34,7 @@ const path = __importStar(require("path"));
|
|
|
34
34
|
const constants_1 = require("../constants");
|
|
35
35
|
const messaging_1 = require("../../core/messaging/messaging");
|
|
36
36
|
const cliConfigProvider_1 = require("../../providers/cliConfigProvider");
|
|
37
|
-
const
|
|
37
|
+
const configKeys_1 = require("../config/config_cmds/configKeys");
|
|
38
38
|
const trainingSessionActions_1 = require("../../core/messaging/actions/trainingSessionActions");
|
|
39
39
|
const async_retry_1 = __importDefault(require("async-retry"));
|
|
40
40
|
const env_1 = require("../../env/env");
|
|
@@ -93,22 +93,22 @@ function searchForChrome() {
|
|
|
93
93
|
})[0];
|
|
94
94
|
}
|
|
95
95
|
exports.searchForChrome = searchForChrome;
|
|
96
|
-
function findChrome() {
|
|
97
|
-
const existingLocation = cliConfigProvider_1.CliConfigProvider.getConfigProperty(
|
|
96
|
+
async function findChrome() {
|
|
97
|
+
const existingLocation = await cliConfigProvider_1.CliConfigProvider.getConfigProperty(configKeys_1.configKeys.browserPath);
|
|
98
98
|
if (typeof existingLocation === 'string' &&
|
|
99
99
|
existingLocation &&
|
|
100
100
|
fs.existsSync(existingLocation)) {
|
|
101
101
|
return existingLocation;
|
|
102
102
|
}
|
|
103
103
|
const chromePath = searchForChrome();
|
|
104
|
-
cliConfigProvider_1.CliConfigProvider.setConfigProperty(
|
|
104
|
+
await cliConfigProvider_1.CliConfigProvider.setConfigProperty(configKeys_1.configKeys.browserPath, chromePath);
|
|
105
105
|
return chromePath;
|
|
106
106
|
}
|
|
107
107
|
exports.findChrome = findChrome;
|
|
108
108
|
async function createBrowserWithAuthedExtension(accessToken, browserWidth, browserHeight, tempBrowserPreferencesDirectory, options) {
|
|
109
109
|
const { credentials, disableIsolation, ignoreCertificateErrors, runnerType, loggerFunc, } = options;
|
|
110
110
|
const pathToExtension = await (0, trainerUtil_1.getMablTrainerExtensionPath)();
|
|
111
|
-
const chromePath = findChrome();
|
|
111
|
+
const chromePath = await findChrome();
|
|
112
112
|
if (!chromePath.length) {
|
|
113
113
|
messaging_1.mablEventEmitter.log(chalk.yellow('Could not find a local install of Chrome to use, please ensure you have it installed and try again'));
|
|
114
114
|
throw new Error('Chrome not found error');
|
|
@@ -209,7 +209,7 @@ function removeTempBrowserPreferencesDirectory(tempDirPath) {
|
|
|
209
209
|
}
|
|
210
210
|
async function createBrowser(browserWidth, browserHeight, headless, containerTesting, tempBrowserPreferencesDirectory, options) {
|
|
211
211
|
const { bypassContentSecurityPolicy, credentials, browserPath, disableIsolation, extraHttpHeaders, ignoreCertificateErrors, emulationConfig, enableExtensions, runnerType, loggerFunc, resourcesDirectoryOverride, userAgent, } = options || {};
|
|
212
|
-
const chromePath = browserPath !== null && browserPath !== void 0 ? browserPath : findChrome();
|
|
212
|
+
const chromePath = browserPath !== null && browserPath !== void 0 ? browserPath : (await findChrome());
|
|
213
213
|
if (!chromePath.length) {
|
|
214
214
|
messaging_1.mablEventEmitter.log(chalk.yellow('Could not find a local install of Chrome to use, please ensure you have it installed and try again'));
|
|
215
215
|
throw new Error('Chrome not found error');
|
|
@@ -279,7 +279,7 @@ function addExecutionEngineLaunchArgs(browserWidth, browserHeight, proxyInfo, em
|
|
|
279
279
|
exports.addExecutionEngineLaunchArgs = addExecutionEngineLaunchArgs;
|
|
280
280
|
async function createBrowserForExecutionEngine(browserWidth, browserHeight, headless, tempBrowserPreferencesDirectory, proxyInfo, options) {
|
|
281
281
|
const { credentials, browserPath, emulationConfig, runnerType, loggerFunc } = options || {};
|
|
282
|
-
const chromePath = browserPath !== null && browserPath !== void 0 ? browserPath : findChrome();
|
|
282
|
+
const chromePath = browserPath !== null && browserPath !== void 0 ? browserPath : (await findChrome());
|
|
283
283
|
const { launchArgs, defaultDeviceDescriptor } = addExecutionEngineLaunchArgs(browserWidth, browserHeight, proxyInfo, emulationConfig);
|
|
284
284
|
const maybeBrowser = await maybeLaunchBrowser(chromePath, launchArgs, tempBrowserPreferencesDirectory, headless, credentials, {
|
|
285
285
|
defaultDeviceDescriptor,
|
|
@@ -535,7 +535,7 @@ async function downloadUploadFile(fileUploadUrl, fileUpload, downloadDirectory,
|
|
|
535
535
|
client = mablApiClient.httpClient;
|
|
536
536
|
}
|
|
537
537
|
else {
|
|
538
|
-
client = axios_1.default.create((0, httpUtil_1.currentProxyConfig)());
|
|
538
|
+
client = axios_1.default.create(await (0, httpUtil_1.currentProxyConfig)());
|
|
539
539
|
}
|
|
540
540
|
try {
|
|
541
541
|
const finalDirectory = path.normalize(`${downloadDirectory}/${fileUpload.id}`);
|
|
@@ -96,7 +96,7 @@ async function launchTrainingSession(parsed) {
|
|
|
96
96
|
const width = parsed.width;
|
|
97
97
|
const height = parsed.height;
|
|
98
98
|
const testName = parsed['test-name'];
|
|
99
|
-
const workspaceId = (0, util_1.getWorkspaceId)(parsed);
|
|
99
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
100
100
|
const testDescription = parsed['test-description'];
|
|
101
101
|
const branchName = parsed['mabl-branch'];
|
|
102
102
|
const autoBranch = parsed['auto-branch'];
|
|
@@ -107,7 +107,7 @@ exports.builder = (yargs) => {
|
|
|
107
107
|
};
|
|
108
108
|
exports.handler = (0, util_1.failWrapper)(importTest);
|
|
109
109
|
async function importTest(parsed) {
|
|
110
|
-
const workspaceId = (0, util_1.getWorkspaceId)(parsed);
|
|
110
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
111
111
|
const importMultipleTests = parsed.multi;
|
|
112
112
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
113
113
|
const name = await getTestName(parsed.name);
|
|
@@ -245,7 +245,7 @@ async function runTests(workspaceId, name, apiClient, importedTests) {
|
|
|
245
245
|
var _a, _b;
|
|
246
246
|
const flows = importedTests.map((steps) => stepsToFlow(workspaceId, steps));
|
|
247
247
|
const firstUrl = (_a = flows.find((flow) => flow.url)) === null || _a === void 0 ? void 0 : _a.url;
|
|
248
|
-
const browserPath = (0, testsUtil_1.findChrome)();
|
|
248
|
+
const browserPath = await (0, testsUtil_1.findChrome)();
|
|
249
249
|
for (let flowIndex = 0; flowIndex < flows.length; flowIndex++) {
|
|
250
250
|
loggingProvider_1.logger.info(`Running test ${flowIndex + 1} of ${flows.length}.`);
|
|
251
251
|
const flow = flows[flowIndex];
|
|
@@ -42,7 +42,7 @@ exports.builder = (yargs) => {
|
|
|
42
42
|
exports.handler = (0, util_1.failWrapper)(listTests);
|
|
43
43
|
async function listTests(parsed) {
|
|
44
44
|
const limit = parsed.limit;
|
|
45
|
-
const workspaceId = (0, util_1.getWorkspaceId)(parsed);
|
|
45
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
46
46
|
const labels = parsed[constants_1.CommandArgLabels];
|
|
47
47
|
const output = parsed[constants_1.CommandArgOutput];
|
|
48
48
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const mablApiClientFactory_1 = require("../../../api/mablApiClientFactory");
|
|
7
7
|
const constants_1 = require("../../constants");
|
|
8
|
-
const cliConfigProvider_1 = require("../../../providers/cliConfigProvider");
|
|
9
8
|
const util_1 = require("../../commandUtil/util");
|
|
10
9
|
const branches_1 = require("../../commandUtil/branches");
|
|
11
10
|
const env_1 = require("../../../env/env");
|
|
@@ -134,12 +133,9 @@ exports.builder = (yargs) => {
|
|
|
134
133
|
};
|
|
135
134
|
exports.handler = (0, util_1.failWrapper)(runInCloud);
|
|
136
135
|
async function runInCloud(parsed) {
|
|
137
|
-
var _a
|
|
136
|
+
var _a;
|
|
138
137
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClientFromOptionalApiKey(parsed['api-key']);
|
|
139
|
-
const workspaceId = (
|
|
140
|
-
if (!workspaceId) {
|
|
141
|
-
throw new Error('Provide workspace ID with --workspace-id or configure a default workspace');
|
|
142
|
-
}
|
|
138
|
+
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
143
139
|
const prompt = parsed.prompt;
|
|
144
140
|
const branchName = parsed['mabl-branch'] || constants_1.DefaultBranchName;
|
|
145
141
|
const branchChangesOnly = parsed['branch-changes-only'];
|
|
@@ -147,7 +143,7 @@ async function runInCloud(parsed) {
|
|
|
147
143
|
const labelsInclude = parsed.labels || [];
|
|
148
144
|
const labelsExclude = parsed['exclude-labels'] || [];
|
|
149
145
|
const maybeDeploymentId = parsed['deployment-id'];
|
|
150
|
-
const maybeUrlApp = (
|
|
146
|
+
const maybeUrlApp = (_a = parsed['app-url']) !== null && _a !== void 0 ? _a : parsed.url;
|
|
151
147
|
const maybeUrlApi = parsed['api-url'];
|
|
152
148
|
const browsers = parsed.browsers;
|
|
153
149
|
const credentialsId = parsed['credentials-id'];
|
|
@@ -4,7 +4,6 @@ exports.run = void 0;
|
|
|
4
4
|
const util_1 = require("../../commandUtil/util");
|
|
5
5
|
const testsUtil_1 = require("../testsUtil");
|
|
6
6
|
const constants_1 = require("../../constants");
|
|
7
|
-
const cliConfigProvider_1 = require("../../../providers/cliConfigProvider");
|
|
8
7
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
9
8
|
const mablApi_1 = require("../../../mablApi");
|
|
10
9
|
const reporter_1 = require("../../../reporters/reporter");
|
|
@@ -170,11 +169,16 @@ exports.builder = (yargs) => {
|
|
|
170
169
|
const exitCodeOnError = 1;
|
|
171
170
|
exports.handler = (0, util_1.failWrapper)(run, exitCodeOnError);
|
|
172
171
|
async function run(parsed) {
|
|
173
|
-
var _a
|
|
172
|
+
var _a;
|
|
174
173
|
const commandStartTime = Date.now();
|
|
175
|
-
|
|
174
|
+
let workspaceId;
|
|
175
|
+
try {
|
|
176
|
+
workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
179
|
+
}
|
|
176
180
|
const extraHttpHeaders = {};
|
|
177
|
-
((
|
|
181
|
+
((_a = parsed['http-headers']) !== null && _a !== void 0 ? _a : []).forEach((header) => {
|
|
178
182
|
const headerParts = header.split(':');
|
|
179
183
|
if (headerParts.length === 2 && headerParts[0] && headerParts[1]) {
|
|
180
184
|
extraHttpHeaders[headerParts[0].toLowerCase()] = headerParts[1];
|
|
@@ -93,7 +93,7 @@ function getTrainerVersion() {
|
|
|
93
93
|
exports.getTrainerVersion = getTrainerVersion;
|
|
94
94
|
async function downloadTrainer(version) {
|
|
95
95
|
fs.ensureDirSync(getTrainerPath());
|
|
96
|
-
const client = axios_1.default.create((0, httpUtil_1.currentProxyConfig)());
|
|
96
|
+
const client = axios_1.default.create(await (0, httpUtil_1.currentProxyConfig)());
|
|
97
97
|
const url = `${env_1.BASE_API_URL}/trainer/distribution?${buildQueryStringsForDistro(version)}`;
|
|
98
98
|
const finalPath = getTrainerZipFile();
|
|
99
99
|
const writer = fs.createWriteStream(finalPath);
|
|
@@ -154,7 +154,7 @@ exports.checkForTrainerUpdate = checkForTrainerUpdate;
|
|
|
154
154
|
async function getCurrentVersionChecksum() {
|
|
155
155
|
const url = `${env_1.BASE_API_URL}/trainer/distribution?${buildQueryStringsForDistro()}`;
|
|
156
156
|
return axios_1.default
|
|
157
|
-
.head(url, (0, httpUtil_1.currentProxyConfig)())
|
|
157
|
+
.head(url, await (0, httpUtil_1.currentProxyConfig)())
|
|
158
158
|
.then((response) => response.headers['x-goog-hash'])
|
|
159
159
|
.catch((error) => {
|
|
160
160
|
loggingProvider_1.logger.error(chalk.red.bold(`There was an issue checking the current mabl trainer. ${error.message}`));
|