Skip to content

command not found: appcenter when using react-native codepush #1932

@JMeyer-FSHealth

Description

@JMeyer-FSHealth

Hello,

We're in the process of migrating from our old observability platform to datadog for our React-Native application. While following the documentation outlined here, I encountered an error during execution of this command:

npm run datadog-ci react-native codepush --platform ios --service com.company.app --bundle ./build/CodePush/main.jsbundle --sourcemap ./build/CodePush/main.jsbundle.map --app MyOrganization/MyApplication --deployment MyDeployment

... which makes sense because AppCenter was retired/EOL in March of this year. See https://learn.microsoft.com/en-us/appcenter/retirement. We had already made the switch to code-push-server, which replaces the documented command to make the jsbundle (and related maps), but I needed to use patch-package to patch @datadog/datadog-ci@4.0.2 to get the upload command to work with our appcenter replacement.

See the following edits:

diff --git a/node_modules/@datadog/datadog-ci/dist/commands/react-native/codepush.js b/node_modules/@datadog/datadog-ci/dist/commands/react-native/codepush.js
index 3907ee9..d5a210d 100644
--- a/node_modules/@datadog/datadog-ci/dist/commands/react-native/codepush.js
+++ b/node_modules/@datadog/datadog-ci/dist/commands/react-native/codepush.js
@@ -49,7 +49,8 @@ class ReactNativeCodepushCommand extends datadog_ci_base_1.BaseCommand {
             fipsIgnoreError: (_b = (0, env_1.toBoolean)(process.env[constants_1.FIPS_IGNORE_ERROR_ENV_VAR])) !== null && _b !== void 0 ? _b : false,
         };
         this.getReleaseVersionFromCodepushHistory = (appCenterAppName, appCenterDeployment) => __awaiter(this, void 0, void 0, function* () {
-            const command = `appcenter codepush deployment history ${appCenterDeployment} --app ${appCenterAppName} --output json`;
+            const command = `code-push-standalone deployment history ${appCenterAppName} ${appCenterDeployment} --format json`;
             return new Promise((resolve, reject) => {
                 (0, child_process_1.exec)(command, (error, stdout, stderr) => {
                     if (error) {
@@ -62,12 +63,11 @@ class ReactNativeCodepushCommand extends datadog_ci_base_1.BaseCommand {
                             reject(new errors_1.NoCodepushReleaseError(appCenterAppName, appCenterDeployment));
                         }
                         const lastDeployment = history[history.length - 1];
-                        const [lastCodePushLabel, _, lastVersion] = lastDeployment;
-                        const version = (0, utils_1.sanitizeReleaseVersion)(lastVersion);
-                        if (/^[^\d]/.test(version)) {
-                            reject(new errors_1.CodepushHistoryParseError(`Error parsing codepush history: invalid version string '${lastVersion}'`));
+                        const sanitizedVersion = (0, utils_1.sanitizeReleaseVersion)(lastDeployment.appVersion);
+                        if (/^[^\d]/.test(sanitizedVersion)) {
+                            reject(new errors_1.CodepushHistoryParseError(`Error parsing codepush history: invalid version string '${lastDeployment.appVersion}'`));
                         }
-                        resolve(`${version}-codepush.${lastCodePushLabel}`);
+                        resolve(`${sanitizedVersion}-codepush.${lastDeployment.label}`);
                     }
                     catch (parseError) {
                         reject(new errors_1.CodepushHistoryParseError(`Error parsing codepush history: \n${String(parseError)}\n${stdout}`));

Is there a built-in way to use code-push-server (or similar alternatives) over the retired appcenter commands?

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    rumRelated to [dsyms, flutter-symbols, react-native, sourcemaps, unity-symbols]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions