@mablhq/mabl-cli 2.37.10 → 2.44.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/mablApiClient.js +9 -1
- package/browserEngines/chromiumBrowserEngine.js +4 -0
- package/browserLauncher/playwrightBrowserLauncher/chromium/chromiumElementHandleDelegate.js +0 -2
- package/cli.js +1 -2
- package/commands/config/config_cmds/install.js +2 -2
- package/commands/constants.js +3 -3
- package/commands/environments/environments_cmds/build-files.js +5 -0
- package/commands/environments/environments_cmds/build-files_cmds/add.js +73 -0
- package/commands/environments/environments_cmds/build-files_cmds/list.js +54 -0
- package/commands/environments/environments_cmds/build-files_cmds/update.js +71 -0
- package/commands/mobile-build-files/mobile-build-files.js +5 -0
- package/commands/{app-files/app-files_cmds → mobile-build-files/mobile-build-files_cmds}/delete.js +4 -4
- package/commands/{app-files/app-files_cmds → mobile-build-files/mobile-build-files_cmds}/download.js +5 -5
- package/commands/{app-files/app-files_cmds → mobile-build-files/mobile-build-files_cmds}/list.js +2 -2
- package/commands/{app-files/app-files_cmds/create.js → mobile-build-files/mobile-build-files_cmds/upload.js} +12 -10
- package/commands/tests/tests_cmds/run-mobile.js +12 -11
- package/core/execution/ApiTestUtils.js +157 -48
- package/core/execution/newman-types.js +7 -0
- package/core/messaging/messaging.js +15 -2
- package/execution/index.js +3 -3
- package/index.d.ts +35 -2
- package/mablApi/index.js +1 -1
- package/mobile/types.js +6 -0
- package/package.json +5 -6
- package/upload/index.js +1 -1
- package/util/analytics-events.js +1 -0
- package/commands/app-files/app-files.js +0 -5
package/api/mablApiClient.js
CHANGED
|
@@ -118,6 +118,14 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
118
118
|
throw toApiError(`Failed to create deployment`, error);
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
+
async updateDeployment(id, deployment) {
|
|
122
|
+
try {
|
|
123
|
+
return await this.makePatchRequest(`${this.baseApiUrl}/deployments/${id}`, deployment);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
throw toApiError(`Failed to update environment`, error);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
121
129
|
async selectLinkServer(workspaceId, label) {
|
|
122
130
|
try {
|
|
123
131
|
const queryParams = query_string_1.default.stringify({
|
|
@@ -420,7 +428,7 @@ class MablApiClient extends basicApiClient_1.BasicApiClient {
|
|
|
420
428
|
catch (error) {
|
|
421
429
|
throw toApiError(`Failed to get Snippet [${snippetId}]. ${workspaceId
|
|
422
430
|
? `The Snippet was likely deleted. To recover this snippet, visit the activity feed [workspaces/${workspaceId}/settings/activity-log?activityLogEntity=snippet&activityLogEvent=delete]`
|
|
423
|
-
: ''}`, error);
|
|
431
|
+
: 'The Snippet was likely deleted. To recover this snippet, visit the activity feed.'}`, error);
|
|
424
432
|
}
|
|
425
433
|
}
|
|
426
434
|
async getBranchById(branchId) {
|
|
@@ -71,8 +71,6 @@ class ChromiumElementHandleDelegate {
|
|
|
71
71
|
await this.enableOverlay();
|
|
72
72
|
const nodeInfo = await ((_a = this.getInternalCDPSession()) === null || _a === void 0 ? void 0 : _a.send('DOM.describeNode', {
|
|
73
73
|
objectId: this.getRemoteObjectId(),
|
|
74
|
-
depth: -1,
|
|
75
|
-
pierce: true,
|
|
76
74
|
}));
|
|
77
75
|
if (!nodeInfo) {
|
|
78
76
|
return;
|
package/cli.js
CHANGED
|
@@ -33,13 +33,11 @@ const constants_1 = require("./commands/constants");
|
|
|
33
33
|
const middleware_1 = require("./middleware");
|
|
34
34
|
const path_1 = __importDefault(require("path"));
|
|
35
35
|
const fs_1 = __importDefault(require("fs"));
|
|
36
|
-
require('v8-compile-cache');
|
|
37
36
|
require('yargonaut').style('cyan').helpStyle('magenta').errorsStyle('red');
|
|
38
37
|
const hasInternalDirectory = fs_1.default.existsSync(path_1.default.resolve(__dirname, 'commands', 'internal', 'internal_cmds'));
|
|
39
38
|
const excludeInternal = !hasInternalDirectory ? { exclude: /.*/gm } : undefined;
|
|
40
39
|
yargs
|
|
41
40
|
.scriptName(env_1.SCRIPT_NAME)
|
|
42
|
-
.commandDir('./commands/app-files')
|
|
43
41
|
.commandDir('./commands/applications')
|
|
44
42
|
.commandDir('./commands/auth')
|
|
45
43
|
.commandDir('./commands/branches')
|
|
@@ -51,6 +49,7 @@ yargs
|
|
|
51
49
|
.commandDir('./commands/flows')
|
|
52
50
|
.commandDir('./commands/internal', excludeInternal)
|
|
53
51
|
.commandDir('./commands/link-agents')
|
|
52
|
+
.commandDir('./commands/mobile-build-files')
|
|
54
53
|
.commandDir('./commands/plans')
|
|
55
54
|
.commandDir('./commands/tests')
|
|
56
55
|
.commandDir('./commands/test-runs')
|
|
@@ -30,8 +30,8 @@ const fs = __importStar(require("fs"));
|
|
|
30
30
|
const path = __importStar(require("path"));
|
|
31
31
|
const resourceUtil_1 = require("../../../util/resourceUtil");
|
|
32
32
|
const OperatingSystemDescriptor_1 = require("../../../mablscript/types/OperatingSystemDescriptor");
|
|
33
|
-
const UI_AUTOMATOR_VERSION = '
|
|
34
|
-
const XCUITEST_VERSION = '
|
|
33
|
+
const UI_AUTOMATOR_VERSION = '3.7.6';
|
|
34
|
+
const XCUITEST_VERSION = '7.24.15';
|
|
35
35
|
const addOnConfigKey = 'add-on';
|
|
36
36
|
var AddOnOptions;
|
|
37
37
|
(function (AddOnOptions) {
|
package/commands/constants.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandArgMablBranchChangesOnly = exports.CommandArgMablBranch = exports.CommandArgMablAutoLogin = exports.CommandArgMablAutoBranch = exports.CommandArgLinkBypass = exports.CommandArgLinkLabel = exports.CommandArgLimitOutput = exports.CommandArgLabels = exports.CommandArgLabelsInclude = exports.CommandArgLabelsExclude = exports.CommandArgTestInteractionSpeed = exports.CommandArgTestRunId = exports.CommandArgTestFile = exports.CommandArgKeepBrowserOpen = exports.CommandArgInput = exports.CommandArgIncludedTests = exports.CommandArgIncludeDefaults = exports.CommandArgId = exports.CommandArgUserAgent = exports.CommandArgHttpHeaders = exports.CommandArgHelp = exports.CommandArgHeadless = exports.CommandArgFromPlanId = exports.CommandArgFrom = exports.CommandArgFormat = exports.CommandArgFindPath = exports.CommandArgFastFailure = exports.CommandArgOverrideEnvironmentId = exports.CommandArgGrep = exports.CommandArgExtraArguments = exports.CommandArgExistingReport = exports.CommandArgExcludedTests = exports.CommandArgEnvironmentId = exports.CommandArgDetailLevel = exports.CommandArgDestination = exports.CommandArgDescription = exports.CommandArgDeploymentId = exports.CommandArgDecrypt = exports.CommandArgDebug = exports.CommandArgDataTables = exports.CommandArgDataTableId = exports.CommandArgCredentials = exports.CommandArgBasicAuthCredentials = exports.CommandArgBrowsers = exports.CommandArgBrowser = exports.CommandArgBranch = exports.CommandArgAuto = exports.CommandArgApplicationId = exports.CommandArgApiKey = exports.CommandArgABConfigFile = void 0;
|
|
4
|
-
exports.DefaultBrowserType = exports.DefaultBranchName = exports.DefaultOutputFormatChoices = exports.DetailLevelFormats = exports.ReporterOptions = exports.OutputFormats = exports.CommandArgAliases = exports.CommandArgBrowserEnableExtensions = exports.CommandArgBrowserIgnoreCertificateErrors = exports.CommandArgBrowserDisableIsolation = exports.ListTimeFormat = exports.CommandArgTimezoneID = exports.CommandArgLocale = exports.CommandArgUseTestExecutionProxy = exports.CommandArgScenarioId = exports.CommandArgReporterOptions = exports.CommandArgReporter = exports.CommandArgWorkspaceId = exports.CommandArgVersion = exports.CommandArgVariables = exports.CommandArgUrlApi = exports.CommandArgUrlApp = exports.CommandArgUrl = exports.CommandArgTo = exports.CommandArgTrainerVersion = exports.CommandArgTraceFile = exports.CommandArgTracesPath = exports.CommandArgTestPath = exports.CommandArgSilent = exports.CommandArgRevision = exports.CommandArgRecordVideoPath = exports.CommandArgMaxHeartbeatAge = exports.CommandArgPlanId = exports.CommandArgContentTypes = exports.CommandArgPreview = exports.CommandArgPath = exports.CommandArgOutputFilePath = exports.CommandArgOutput = exports.CommandArgNoPrompt = exports.CommandArgPrompt = exports.CommandArgProject = exports.CommandArgPortNumber = exports.CommandArgName = exports.CommandArgMobileDeviceName = exports.CommandArgMobilePlatform = exports.
|
|
4
|
+
exports.DefaultBrowserType = exports.DefaultBranchName = exports.DefaultOutputFormatChoices = exports.DetailLevelFormats = exports.ReporterOptions = exports.OutputFormats = exports.CommandArgAliases = exports.CommandArgBrowserEnableExtensions = exports.CommandArgBrowserIgnoreCertificateErrors = exports.CommandArgBrowserDisableIsolation = exports.ListTimeFormat = exports.CommandArgTimezoneID = exports.CommandArgLocale = exports.CommandArgUseTestExecutionProxy = exports.CommandArgScenarioId = exports.CommandArgReporterOptions = exports.CommandArgReporter = exports.CommandArgWorkspaceId = exports.CommandArgVersion = exports.CommandArgVariables = exports.CommandArgUrlApi = exports.CommandArgUrlApp = exports.CommandArgUrl = exports.CommandArgTo = exports.CommandArgTrainerVersion = exports.CommandArgTraceFile = exports.CommandArgTracesPath = exports.CommandArgTestPath = exports.CommandArgSilent = exports.CommandArgRevision = exports.CommandArgRecordVideoPath = exports.CommandArgMaxHeartbeatAge = exports.CommandArgPlanId = exports.CommandArgContentTypes = exports.CommandArgPreview = exports.CommandArgPath = exports.CommandArgOutputFilePath = exports.CommandArgOutput = exports.CommandArgNoPrompt = exports.CommandArgPrompt = exports.CommandArgProject = exports.CommandArgPortNumber = exports.CommandArgName = exports.CommandArgMobileDeviceName = exports.CommandArgMobilePlatform = exports.CommandArgMobileBuildFileId = exports.CommandArgMobileBuildFilePath = exports.CommandArgiOSdMobileAppFileId = exports.CommandArgAndroidMobileAppFileId = exports.CommandArgMulti = void 0;
|
|
5
5
|
exports.SCENARIO_ID_HEADER = exports.SCENARIO_NAME_HEADER = exports.ValidBrowserTypesForLocalRuns = exports.BrowserTypeSelections = void 0;
|
|
6
6
|
const browserTypes_1 = require("./browserTypes");
|
|
7
7
|
exports.CommandArgABConfigFile = 'ab-config-file';
|
|
@@ -57,8 +57,8 @@ exports.CommandArgMablBranchChangesOnly = 'branch-changes-only';
|
|
|
57
57
|
exports.CommandArgMulti = 'multi';
|
|
58
58
|
exports.CommandArgAndroidMobileAppFileId = 'android-app-file-id';
|
|
59
59
|
exports.CommandArgiOSdMobileAppFileId = 'ios-app-file-id';
|
|
60
|
-
exports.
|
|
61
|
-
exports.
|
|
60
|
+
exports.CommandArgMobileBuildFilePath = 'build-file-path';
|
|
61
|
+
exports.CommandArgMobileBuildFileId = 'build-file-id';
|
|
62
62
|
exports.CommandArgMobilePlatform = 'platform';
|
|
63
63
|
exports.CommandArgMobileDeviceName = 'device';
|
|
64
64
|
exports.CommandArgName = 'name';
|
|
@@ -0,0 +1,73 @@
|
|
|
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.createDeploymentForBuildFile = exports.addEnvironmentBuildFilesOptions = void 0;
|
|
7
|
+
const constants_1 = require("../../../constants");
|
|
8
|
+
const util_1 = require("../../../commandUtil/util");
|
|
9
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
10
|
+
const loggingProvider_1 = require("../../../../providers/logging/loggingProvider");
|
|
11
|
+
const mablApi_1 = require("../../../../mablApi");
|
|
12
|
+
const mablApiClientFactory_1 = require("../../../../api/mablApiClientFactory");
|
|
13
|
+
exports.command = `add <${constants_1.CommandArgId}>`;
|
|
14
|
+
exports.describe = 'Associate mobile build file with an environment';
|
|
15
|
+
exports.builder = (yargs) => {
|
|
16
|
+
addEnvironmentBuildFilesOptions(yargs)
|
|
17
|
+
.positional(constants_1.CommandArgId, {
|
|
18
|
+
describe: 'ID of environment to add mobile build file associations to',
|
|
19
|
+
type: 'string',
|
|
20
|
+
})
|
|
21
|
+
.demandOption(constants_1.CommandArgApplicationId)
|
|
22
|
+
.demandOption(constants_1.CommandArgMobileBuildFileId);
|
|
23
|
+
};
|
|
24
|
+
exports.handler = (0, util_1.failWrapper)(createDeployment);
|
|
25
|
+
function addEnvironmentBuildFilesOptions(yargs) {
|
|
26
|
+
return yargs
|
|
27
|
+
.option(constants_1.CommandArgApplicationId, {
|
|
28
|
+
describe: 'ID of application to associate with this environment',
|
|
29
|
+
nargs: 1,
|
|
30
|
+
type: 'string',
|
|
31
|
+
})
|
|
32
|
+
.option(constants_1.CommandArgMobileBuildFileId, {
|
|
33
|
+
describe: 'mobile build file ID to associate with the application-environment pair',
|
|
34
|
+
nargs: 1,
|
|
35
|
+
type: 'string',
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.addEnvironmentBuildFilesOptions = addEnvironmentBuildFilesOptions;
|
|
39
|
+
async function createDeployment(parsed) {
|
|
40
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
41
|
+
const applicationId = parsed[constants_1.CommandArgApplicationId];
|
|
42
|
+
const environmentId = parsed[constants_1.CommandArgId];
|
|
43
|
+
const buildFileId = parsed[constants_1.CommandArgMobileBuildFileId];
|
|
44
|
+
try {
|
|
45
|
+
await apiClient.getApplication(applicationId);
|
|
46
|
+
await apiClient.getMobileAppFile(buildFileId);
|
|
47
|
+
const environment = await apiClient.getEnvironment(environmentId);
|
|
48
|
+
await createDeploymentForBuildFile(apiClient, environment, applicationId, buildFileId);
|
|
49
|
+
return 'done';
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
throw new Error(`Error adding build file for environment ${parsed.id}: ${error}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function createDeploymentForBuildFile(apiClient, environment, applicationId, buildFileId) {
|
|
56
|
+
try {
|
|
57
|
+
const deployment = {
|
|
58
|
+
organization_id: environment.organization_id,
|
|
59
|
+
environment_id: environment.id,
|
|
60
|
+
application_id: applicationId,
|
|
61
|
+
mobile_app_file_id: buildFileId,
|
|
62
|
+
deployment_type: mablApi_1.Deployment.DeploymentTypeEnum.MobileApplication,
|
|
63
|
+
};
|
|
64
|
+
await apiClient.createDeployment(deployment);
|
|
65
|
+
loggingProvider_1.logger.info(chalk_1.default.white(`Associated ${buildFileId} with environment ${environment.id} and application ${applicationId}`));
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
loggingProvider_1.logger.error(error);
|
|
69
|
+
const reRunCommandString = `mabl environments build-files add ${environment.id} --applicationId ${applicationId} --build-file-id ${buildFileId}`;
|
|
70
|
+
loggingProvider_1.logger.info(chalk_1.default.white(`Associating build file with environment failed. You can reattempt this association by running ${chalk_1.default.bold(reRunCommandString)}`));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.createDeploymentForBuildFile = createDeploymentForBuildFile;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const interfaces_1 = require("../../../commandUtil/interfaces");
|
|
4
|
+
const constants_1 = require("../../../constants");
|
|
5
|
+
const util_1 = require("../../../commandUtil/util");
|
|
6
|
+
const mablApiClientFactory_1 = require("../../../../api/mablApiClientFactory");
|
|
7
|
+
const describe_1 = require("../../../commandUtil/describe");
|
|
8
|
+
exports.command = `list <${constants_1.CommandArgId}>`;
|
|
9
|
+
exports.describe = 'Show build files associated with an environment';
|
|
10
|
+
exports.builder = (yargs) => {
|
|
11
|
+
yargs
|
|
12
|
+
.positional(constants_1.CommandArgId, {
|
|
13
|
+
describe: 'Environment ID to list build file associations for',
|
|
14
|
+
type: 'string',
|
|
15
|
+
})
|
|
16
|
+
.option(constants_1.CommandArgApplicationId, {
|
|
17
|
+
describe: 'Application ID to filter build files by',
|
|
18
|
+
alias: constants_1.CommandArgAliases.ApplicationId,
|
|
19
|
+
nargs: 1,
|
|
20
|
+
type: 'string',
|
|
21
|
+
})
|
|
22
|
+
.option(constants_1.CommandArgLimitOutput, {
|
|
23
|
+
alias: constants_1.CommandArgAliases.LimitOutput,
|
|
24
|
+
describe: `The number of build files to return'`,
|
|
25
|
+
default: interfaces_1.DEFAULT_LISTING_RESULT_LIMIT,
|
|
26
|
+
nargs: 1,
|
|
27
|
+
type: 'string',
|
|
28
|
+
})
|
|
29
|
+
.option(constants_1.CommandArgOutput, {
|
|
30
|
+
alias: constants_1.CommandArgAliases.OutputType,
|
|
31
|
+
choices: constants_1.DefaultOutputFormatChoices,
|
|
32
|
+
describe: 'Specify result output format',
|
|
33
|
+
nargs: 1,
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.handler = (0, util_1.failWrapper)(queryDeployments);
|
|
37
|
+
async function queryDeployments(parsed) {
|
|
38
|
+
var _a, _b, _c;
|
|
39
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
40
|
+
try {
|
|
41
|
+
const environment = await apiClient.getEnvironment(parsed.id);
|
|
42
|
+
const deploymentEntities = await apiClient.queryDeploymentEntities((_a = environment.organization_id) !== null && _a !== void 0 ? _a : '', environment.id, parsed[constants_1.CommandArgApplicationId], parsed.limit);
|
|
43
|
+
const mobileDeployments = (_c = (_b = deploymentEntities.deployments) === null || _b === void 0 ? void 0 : _b.filter((deployment) => !!deployment.mobile_app_file_id)) !== null && _c !== void 0 ? _c : [];
|
|
44
|
+
const mobileBuildFiles = await Promise.all(mobileDeployments.map((deployment) => apiClient.getMobileAppFile(deployment.mobile_app_file_id)));
|
|
45
|
+
(0, describe_1.outputEntity)(mobileDeployments.map((deployment, index) => ({
|
|
46
|
+
...deployment,
|
|
47
|
+
mobile_app_file: mobileBuildFiles[index],
|
|
48
|
+
})), parsed.output);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new Error(`Error listing build files for environment ${parsed.id}: ${error}`);
|
|
52
|
+
}
|
|
53
|
+
return 'done';
|
|
54
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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.updateDeploymentForBuildFile = void 0;
|
|
7
|
+
const constants_1 = require("../../../constants");
|
|
8
|
+
const util_1 = require("../../../commandUtil/util");
|
|
9
|
+
const add_1 = require("./add");
|
|
10
|
+
const mablApiClientFactory_1 = require("../../../../api/mablApiClientFactory");
|
|
11
|
+
const mablApi_1 = require("../../../../mablApi");
|
|
12
|
+
const loggingProvider_1 = require("../../../../providers/logging/loggingProvider");
|
|
13
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
14
|
+
exports.command = `update <${constants_1.CommandArgId}>`;
|
|
15
|
+
exports.describe =
|
|
16
|
+
'Update mobile build file associated with an environment or add new association';
|
|
17
|
+
exports.builder = (yargs) => {
|
|
18
|
+
(0, add_1.addEnvironmentBuildFilesOptions)(yargs)
|
|
19
|
+
.positional(constants_1.CommandArgId, {
|
|
20
|
+
describe: 'ID of environment to update mobile build file association',
|
|
21
|
+
type: 'string',
|
|
22
|
+
})
|
|
23
|
+
.demandOption(constants_1.CommandArgApplicationId)
|
|
24
|
+
.demandOption(constants_1.CommandArgMobileBuildFileId);
|
|
25
|
+
};
|
|
26
|
+
exports.handler = (0, util_1.failWrapper)(updateOrCreateDeployment);
|
|
27
|
+
async function updateOrCreateDeployment(parsed) {
|
|
28
|
+
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
29
|
+
const applicationId = parsed[constants_1.CommandArgApplicationId];
|
|
30
|
+
const environmentId = parsed[constants_1.CommandArgId];
|
|
31
|
+
const buildFileId = parsed[constants_1.CommandArgMobileBuildFileId];
|
|
32
|
+
try {
|
|
33
|
+
await apiClient.getApplication(applicationId);
|
|
34
|
+
const buildFile = await apiClient.getMobileAppFile(buildFileId);
|
|
35
|
+
const environment = await apiClient.getEnvironment(environmentId);
|
|
36
|
+
await updateDeploymentForBuildFile(apiClient, environment, applicationId, buildFile);
|
|
37
|
+
return 'done';
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
throw new Error(`Error updating build file for environment ${parsed.id}: ${error}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async function updateDeploymentForBuildFile(apiClient, environment, applicationId, newBuildFile) {
|
|
44
|
+
var _a, _b, _c, _d;
|
|
45
|
+
const deploymentEntities = await apiClient.queryDeploymentEntities((_a = environment.organization_id) !== null && _a !== void 0 ? _a : '', environment.id, applicationId, 1000);
|
|
46
|
+
const candidatesForUpdate = (_d = (_c = (_b = deploymentEntities === null || deploymentEntities === void 0 ? void 0 : deploymentEntities.deployments) === null || _b === void 0 ? void 0 : _b.filter((deployment) => !!deployment.mobile_app_file_id)) === null || _c === void 0 ? void 0 : _c.filter(async (deployment) => {
|
|
47
|
+
const buildFile = await apiClient.getMobileAppFile(deployment.mobile_app_file_id);
|
|
48
|
+
return (deployment.deployment_type ===
|
|
49
|
+
mablApi_1.Deployment.DeploymentTypeEnum.MobileApplication &&
|
|
50
|
+
buildFile.platform === newBuildFile.platform);
|
|
51
|
+
})) !== null && _d !== void 0 ? _d : [];
|
|
52
|
+
if ((candidatesForUpdate === null || candidatesForUpdate === void 0 ? void 0 : candidatesForUpdate.length) === 0) {
|
|
53
|
+
await (0, add_1.createDeploymentForBuildFile)(apiClient, environment, applicationId, newBuildFile.id);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
else if ((candidatesForUpdate === null || candidatesForUpdate === void 0 ? void 0 : candidatesForUpdate.length) > 1) {
|
|
57
|
+
throw new Error('Multiple deployments with the same mobile platform found. Please remove duplicates or use mabl UI to change the build file association.');
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
const existingDeployment = candidatesForUpdate[0];
|
|
61
|
+
existingDeployment.mobile_app_file_id = newBuildFile.id;
|
|
62
|
+
await apiClient.updateDeployment(existingDeployment.id, existingDeployment);
|
|
63
|
+
loggingProvider_1.logger.info(chalk_1.default.white(`Updated ${newBuildFile.platform} build file associated with environment ${environment.id} and application ${applicationId} to ${newBuildFile.id} `));
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
loggingProvider_1.logger.error(error);
|
|
67
|
+
const reRunCommandString = `mabl environments build-files update ${environment.id} --applicationId ${applicationId} --build-file-id ${newBuildFile.id}`;
|
|
68
|
+
loggingProvider_1.logger.info(chalk_1.default.white(`Associating build file with environment failed. You can reattempt this association by running ${chalk_1.default.bold(reRunCommandString)}`));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.updateDeploymentForBuildFile = updateDeploymentForBuildFile;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = ['mobile-build-files <command>', 'app-files <command>'];
|
|
4
|
+
exports.describe = 'Manage your mobile build files';
|
|
5
|
+
exports.builder = (yargs) => yargs.commandDir('mobile-build-files_cmds').demandCommand();
|
package/commands/{app-files/app-files_cmds → mobile-build-files/mobile-build-files_cmds}/delete.js
RENAMED
|
@@ -9,10 +9,10 @@ const util_1 = require("../../commandUtil/util");
|
|
|
9
9
|
const chalk_1 = __importDefault(require("chalk"));
|
|
10
10
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
11
11
|
exports.command = `delete <${constants_1.CommandArgId}>`;
|
|
12
|
-
exports.describe = 'Delete a mobile
|
|
12
|
+
exports.describe = 'Delete a mobile build file.';
|
|
13
13
|
exports.builder = (yargs) => {
|
|
14
14
|
yargs.positional(constants_1.CommandArgId, {
|
|
15
|
-
describe: '
|
|
15
|
+
describe: 'ID of the mobile build file',
|
|
16
16
|
type: 'string',
|
|
17
17
|
});
|
|
18
18
|
};
|
|
@@ -22,10 +22,10 @@ async function deleteMobileAppFile(parsed) {
|
|
|
22
22
|
const apiClient = await mablApiClientFactory_1.MablApiClientFactory.createApiClient();
|
|
23
23
|
const id = parsed[constants_1.CommandArgId];
|
|
24
24
|
await apiClient.deleteMobileAppFile(id);
|
|
25
|
-
loggingProvider_1.logger.info(chalk_1.default.green(`Mobile
|
|
25
|
+
loggingProvider_1.logger.info(chalk_1.default.green(`Mobile build file ${chalk_1.default.bold(id)} DELETED`));
|
|
26
26
|
return id;
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
|
-
throw new Error(`Error deleting mobile
|
|
29
|
+
throw new Error(`Error deleting mobile build file: ${error}`);
|
|
30
30
|
}
|
|
31
31
|
}
|
package/commands/{app-files/app-files_cmds → mobile-build-files/mobile-build-files_cmds}/download.js
RENAMED
|
@@ -11,15 +11,15 @@ const util_1 = require("../../commandUtil/util");
|
|
|
11
11
|
const MobileAppFileCache_1 = require("../../../util/MobileAppFileCache");
|
|
12
12
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
13
13
|
exports.command = `download <${constants_1.CommandArgId}> <${constants_1.CommandArgDestination}>`;
|
|
14
|
-
exports.describe = 'Download a mobile
|
|
14
|
+
exports.describe = 'Download a mobile build file.';
|
|
15
15
|
exports.builder = (yargs) => {
|
|
16
16
|
yargs
|
|
17
17
|
.positional(constants_1.CommandArgId, {
|
|
18
|
-
describe: '
|
|
18
|
+
describe: 'ID of the mobile build file',
|
|
19
19
|
type: 'string',
|
|
20
20
|
})
|
|
21
21
|
.positional(constants_1.CommandArgDestination, {
|
|
22
|
-
describe: 'Relative path to
|
|
22
|
+
describe: 'Relative path to destination directory or file',
|
|
23
23
|
type: 'string',
|
|
24
24
|
});
|
|
25
25
|
};
|
|
@@ -31,10 +31,10 @@ async function downloadMobileAppFile(parsed) {
|
|
|
31
31
|
const mobileAppFile = await new MobileAppFileCache_1.MobileAppFileCache().getMobileAppFile(id);
|
|
32
32
|
const downloadPath = await resolveDestination(destination, mobileAppFile);
|
|
33
33
|
await (0, promises_1.copyFile)(mobileAppFile.path, downloadPath);
|
|
34
|
-
loggingProvider_1.logger.info(chalk_1.default.green(`Mobile
|
|
34
|
+
loggingProvider_1.logger.info(chalk_1.default.green(`Mobile build file downloaded to ${downloadPath}`));
|
|
35
35
|
}
|
|
36
36
|
catch (error) {
|
|
37
|
-
throw new Error(`Error downloading mobile
|
|
37
|
+
throw new Error(`Error downloading mobile build file: ${error}`);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
async function resolveDestination(destination, mobileAppFile) {
|
package/commands/{app-files/app-files_cmds → mobile-build-files/mobile-build-files_cmds}/list.js
RENAMED
|
@@ -12,8 +12,8 @@ const list_1 = require("../../commandUtil/list");
|
|
|
12
12
|
const loggingProvider_1 = require("../../../providers/logging/loggingProvider");
|
|
13
13
|
const constants_1 = require("../../constants");
|
|
14
14
|
exports.command = 'list';
|
|
15
|
-
exports.describe = 'List your mobile
|
|
16
|
-
exports.builder = (0, list_1.getListBuilderOptions)('mobile
|
|
15
|
+
exports.describe = 'List your mobile build files';
|
|
16
|
+
exports.builder = (0, list_1.getListBuilderOptions)('mobile build files');
|
|
17
17
|
exports.handler = (0, util_1.failWrapper)(listMobileAppFiles);
|
|
18
18
|
async function listMobileAppFiles(parsed) {
|
|
19
19
|
const output = parsed.output;
|
|
@@ -15,20 +15,22 @@ const upload_1 = require("../../../upload");
|
|
|
15
15
|
const env_1 = require("../../../env/env");
|
|
16
16
|
const authenticationProvider_1 = require("../../../providers/authenticationProvider");
|
|
17
17
|
const types_1 = require("../../../api/types");
|
|
18
|
-
exports.command =
|
|
19
|
-
|
|
18
|
+
exports.command = [
|
|
19
|
+
`upload <${constants_1.CommandArgMobileBuildFilePath}>`,
|
|
20
|
+
`create <${constants_1.CommandArgMobileBuildFilePath}>`,
|
|
21
|
+
];
|
|
22
|
+
exports.describe = 'Upload a new mobile build file';
|
|
20
23
|
exports.builder = (yargs) => {
|
|
21
24
|
yargs
|
|
22
|
-
.positional(constants_1.
|
|
23
|
-
|
|
24
|
-
describe: 'Relative path to mobile app file',
|
|
25
|
+
.positional(constants_1.CommandArgMobileBuildFilePath, {
|
|
26
|
+
describe: 'Relative path to mobile build file file',
|
|
25
27
|
})
|
|
26
28
|
.option(constants_1.CommandArgBranch, {
|
|
27
|
-
describe: 'Branch from which this mobile
|
|
29
|
+
describe: 'Branch from which this mobile build file was built',
|
|
28
30
|
type: 'string',
|
|
29
31
|
})
|
|
30
32
|
.option(constants_1.CommandArgLabels, {
|
|
31
|
-
describe: 'Space delimited labels to save
|
|
33
|
+
describe: 'Space delimited labels to save the file with',
|
|
32
34
|
type: 'array',
|
|
33
35
|
})
|
|
34
36
|
.option(constants_1.CommandArgMobilePlatform, {
|
|
@@ -42,19 +44,19 @@ exports.builder = (yargs) => {
|
|
|
42
44
|
})
|
|
43
45
|
.version(false)
|
|
44
46
|
.option(constants_1.CommandArgVersion, {
|
|
45
|
-
describe: 'Version of this mobile
|
|
47
|
+
describe: 'Version of this mobile build file',
|
|
46
48
|
type: 'string',
|
|
47
49
|
})
|
|
48
50
|
.option(constants_1.CommandArgWorkspaceId, {
|
|
49
51
|
alias: constants_1.CommandArgAliases.WorkspaceId,
|
|
50
|
-
describe: `Workspace to create mobile
|
|
52
|
+
describe: `Workspace to create mobile build file in`,
|
|
51
53
|
type: 'string',
|
|
52
54
|
});
|
|
53
55
|
};
|
|
54
56
|
exports.handler = (0, util_1.failWrapper)(createMobileAppFile);
|
|
55
57
|
async function createMobileAppFile(parsed) {
|
|
56
58
|
const { branch, labels, platform, version } = parsed;
|
|
57
|
-
const file = parsed[constants_1.
|
|
59
|
+
const file = parsed[constants_1.CommandArgMobileBuildFilePath];
|
|
58
60
|
const workspaceId = await (0, util_1.getWorkspaceId)(parsed);
|
|
59
61
|
const mobileAppFilePrototype = {
|
|
60
62
|
branch,
|
|
@@ -47,11 +47,12 @@ exports.builder = (yargs) => {
|
|
|
47
47
|
describe: 'The id of the test to run',
|
|
48
48
|
type: 'string',
|
|
49
49
|
})
|
|
50
|
-
.option(constants_1.
|
|
50
|
+
.option(constants_1.CommandArgMobileBuildFilePath, {
|
|
51
|
+
alias: 'app-file',
|
|
51
52
|
describe: 'The path to the mobile application binary',
|
|
52
53
|
type: 'string',
|
|
53
54
|
})
|
|
54
|
-
.option(constants_1.
|
|
55
|
+
.option(constants_1.CommandArgMobileBuildFileId, {
|
|
55
56
|
describe: 'The ID of a previously uploaded mobile app file',
|
|
56
57
|
type: 'string',
|
|
57
58
|
})
|
|
@@ -117,7 +118,7 @@ exports.builder = (yargs) => {
|
|
|
117
118
|
.middleware(inferMobilePlatform)
|
|
118
119
|
.check((argv) => {
|
|
119
120
|
(0, testsUtil_1.validateRunCommandWithLabels)(argv[constants_1.CommandArgId], argv[constants_1.CommandArgLabelsInclude], argv[constants_1.CommandArgLabelsExclude], argv[constants_1.CommandArgTestRunId], argv[constants_1.CommandArgFromPlanId], true, undefined);
|
|
120
|
-
validateMobileCommand(argv[constants_1.
|
|
121
|
+
validateMobileCommand(argv[constants_1.CommandArgMobileBuildFilePath], argv[constants_1.CommandArgMobileBuildFileId]);
|
|
121
122
|
return true;
|
|
122
123
|
});
|
|
123
124
|
};
|
|
@@ -125,7 +126,7 @@ const exitCodeOnError = 1;
|
|
|
125
126
|
exports.handler = (0, util_1.failWrapper)(run, exitCodeOnError);
|
|
126
127
|
function validateMobileCommand(appFile, appFileId) {
|
|
127
128
|
if (appFile && appFileId) {
|
|
128
|
-
throw new Error(`Only one of { --${constants_1.
|
|
129
|
+
throw new Error(`Only one of { --${constants_1.CommandArgMobileBuildFilePath}, --${constants_1.CommandArgMobileBuildFileId} } may be specified`);
|
|
129
130
|
}
|
|
130
131
|
}
|
|
131
132
|
async function run(parsed) {
|
|
@@ -163,8 +164,8 @@ async function run(parsed) {
|
|
|
163
164
|
testId: parsed.id,
|
|
164
165
|
workspaceId,
|
|
165
166
|
mobileConfig: {
|
|
166
|
-
mobileAppFileId: parsed[constants_1.
|
|
167
|
-
path: parsed[constants_1.
|
|
167
|
+
mobileAppFileId: parsed[constants_1.CommandArgMobileBuildFileId],
|
|
168
|
+
path: parsed[constants_1.CommandArgMobileBuildFilePath],
|
|
168
169
|
platformName,
|
|
169
170
|
avdName: parsed[constants_1.CommandArgMobileDeviceName],
|
|
170
171
|
recordVideoPath: parsed[constants_1.CommandArgRecordVideoPath],
|
|
@@ -230,20 +231,20 @@ async function validateSystemRequirements(platform, deviceName) {
|
|
|
230
231
|
}
|
|
231
232
|
}
|
|
232
233
|
async function inferMobilePlatform(argv) {
|
|
233
|
-
if (!argv[constants_1.CommandArgMobilePlatform] && argv[constants_1.
|
|
234
|
-
if (argv[constants_1.
|
|
234
|
+
if (!argv[constants_1.CommandArgMobilePlatform] && argv[constants_1.CommandArgMobileBuildFileId]) {
|
|
235
|
+
if (argv[constants_1.CommandArgMobileBuildFileId]) {
|
|
235
236
|
try {
|
|
236
|
-
const { platform } = await new MobileAppFileCache_1.MobileAppFileCache().getMobileAppFileImmutableFields(argv[constants_1.
|
|
237
|
+
const { platform } = await new MobileAppFileCache_1.MobileAppFileCache().getMobileAppFileImmutableFields(argv[constants_1.CommandArgMobileBuildFileId]);
|
|
237
238
|
if (platform) {
|
|
238
239
|
argv[constants_1.CommandArgMobilePlatform] = platform.toString().toLowerCase();
|
|
239
240
|
return;
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
catch (error) {
|
|
243
|
-
loggingProvider_1.logger.warn(chalk.yellow(`Warning: Unable to fetch mobile app file ${argv[constants_1.
|
|
244
|
+
loggingProvider_1.logger.warn(chalk.yellow(`Warning: Unable to fetch mobile app file ${argv[constants_1.CommandArgMobileBuildFilePath]}: ${error}`));
|
|
244
245
|
}
|
|
245
246
|
}
|
|
246
|
-
const extension = (0, path_1.extname)(argv[constants_1.
|
|
247
|
+
const extension = (0, path_1.extname)(argv[constants_1.CommandArgMobileBuildFilePath]).toLowerCase();
|
|
247
248
|
switch (extension) {
|
|
248
249
|
case '.apk':
|
|
249
250
|
argv[constants_1.CommandArgMobilePlatform] = mablApi_1.MobilePlatformEnum.Android;
|