@@ -32574,9 +32574,13 @@ const escapeShellValue = (value) => {
3257432574 // Escape special characters that could cause shell interpretation issues
3257532575 return value.replace(/(["\\'$`!\s\[\]{}()&|;<>*?#^~])/g, '\\$1');
3257632576};
32577- const getTestStatus = (uploadId) => __awaiter(void 0, void 0, void 0, function* () {
32577+ const getTestStatus = (uploadId, apiKey, apiUrl ) => __awaiter(void 0, void 0, void 0, function* () {
3257832578 try {
32579- const statusOutput = (0, child_process_1.execSync)(`npx --yes @devicecloud.dev/dcd status --json ${uploadId}`, { encoding: 'utf-8' });
32579+ let command = `npx --yes @devicecloud.dev/dcd status --json --upload-id ${uploadId} --api-key ${escapeShellValue(apiKey)}`;
32580+ if (apiUrl) {
32581+ command += ` --api-url ${escapeShellValue(apiUrl)}`;
32582+ }
32583+ const statusOutput = (0, child_process_1.execSync)(command, { encoding: 'utf-8' });
3258032584 return JSON.parse(statusOutput);
3258132585 }
3258232586 catch (error) {
@@ -32585,6 +32589,7 @@ const getTestStatus = (uploadId) => __awaiter(void 0, void 0, void 0, function*
3258532589 }
3258632590});
3258732591const run = () => __awaiter(void 0, void 0, void 0, function* () {
32592+ var _a;
3258832593 try {
3258932594 const { additionalAppBinaryIds, additionalAppFiles, androidApiLevel, androidDevice, apiKey, apiUrl, appBinaryId, appFilePath, async, deviceLocale, downloadArtifacts, env, excludeFlows, excludeTags, googlePlay, ignoreShaCheck, includeTags, iOSVersion, iosDevice, maestroVersion, name, orientation, report, retry, workspaceFolder, x86Arch, } = yield (0, params_1.getParameters)();
3259032595 const params = {
@@ -32634,15 +32639,28 @@ const run = () => __awaiter(void 0, void 0, void 0, function* () {
3263432639 });
3263532640 }
3263632641 // Execute the test command and capture the upload ID
32637- const testOutput = (0, child_process_1.execSync)(`npx --yes @devicecloud.dev/dcd cloud ${paramsString} --quiet`, { encoding: 'utf-8' });
32638- // Extract upload ID from the console URL in the output
32639- const urlMatch = testOutput.match(/https:\/\/console\.devicecloud\.dev\/results\?upload=([a-zA-Z0-9-]+)/);
32640- const uploadId = urlMatch ? urlMatch[1] : '';
32642+ let uploadId = null;
32643+ let testOutput;
32644+ try {
32645+ testOutput = (0, child_process_1.execSync)(`npx --yes @devicecloud.dev/dcd cloud ${paramsString} --quiet`, { encoding: 'utf-8' });
32646+ }
32647+ catch (e) {
32648+ testOutput = e.output[1].toString();
32649+ const exitCode = e.status || 1;
32650+ if (exitCode === 1) {
32651+ throw new Error('DeviceCloud CLI failed to run - check your parameters or contact support');
32652+ }
32653+ }
32654+ finally {
32655+ console.log('test output', testOutput);
32656+ uploadId =
32657+ ((_a = testOutput === null || testOutput === void 0 ? void 0 : testOutput.match(/https:\/\/console\.devicecloud\.dev\/results\?upload=([a-zA-Z0-9-]+)/)) === null || _a === void 0 ? void 0 : _a[1]) || null;
32658+ }
3264132659 if (!uploadId) {
3264232660 throw new Error('Failed to get upload ID from console URL');
3264332661 }
3264432662 // Get the test status and results
32645- const result = yield getTestStatus(uploadId);
32663+ const result = yield getTestStatus(uploadId, apiKey, apiUrl );
3264632664 if (result) {
3264732665 // Set outputs based on the status results
3264832666 (0, core_1.setOutput)('DEVICE_CLOUD_CONSOLE_URL', result.consoleUrl || '');
0 commit comments