Skip to content
This repository was archived by the owner on May 20, 2025. It is now read-only.
This repository was archived by the owner on May 20, 2025. It is now read-only.

Get code push version properly in JSON format #678

Closed

Description

As a user, I wish to get the apps code push version to pass it in other app/script/build tools.

Currently, I can get the info of my app via something like

appcenter codepush deployment list --app <myAppName>

That will output something like :

┌────────────┬─────────────────────────────────┬──────────────────────────┐
│ Name       │ Update Metadata                 │ Install Metrics          │
├────────────┼─────────────────────────────────┼──────────────────────────┤
│ Staging    │ Label: v44                      │ Active: 0.36% (1 of 275) │
│            │ App Version: 1.0.0              │ Installed: 1             │
│            │ Mandatory: No                   │                          │
│            │ Release Time: Nov 20, 06:00 AM  │                          │
│            │ Released By: me@mail.com        │                          │
└────────────┴─────────────────────────────────┴──────────────────────────┘

What's interesting here is the label : v44. Let's extract the data with JSON.

appcenter codepush deployment list --app <myAppName> --output json

And that's where the output is not clean and not parsable JSON. Here is the result :

[["Staging","\u001b[32mLabel: \u001b[39mv44\n\u001b[32mApp Version: \u001b[39m1.0.0\n\u001b[32mMandatory: \u001b[39mNo\n\u001b[32mRelease Time: \u001b[39mNov 20, 06:00 AM\n\u001b[32mReleased By: \u001b[39mme@mail.com","\u001b[32mActive: \u001b[39m0.36% (1 of 275)\n\u001b[32mInstalled: \u001b[39m1"]]

Is there a way to get clean JSON parsable ?
We wish to get this in something like :

[
  {
    "name": "Production",
    "updateMetadata": {
      "Label": "v44",
      "App Version": 1.0.0,
      "Mandatory": "No",
      "Release Time" : Nov 20, 06:00 AM",
      "Released by": "me@mail.com"
    },
    "installMetrics": {
      "Active": "0.36% (1 of 275)",
      "Installed": 1,
    }
  }
]

What do you think?

-- Edit
Similar question : #630

Activity

  1. changed the title [-]Get code push version properly[/-] [+]Get code push version properly in JSON format[/+] on Nov 20, 2019
  2. alexandergoncharov-zz commented on Mar 3, 2020

    @alexandergoncharov-zz
    Contributor

    Hi Romain de Wolff (@rdewolff) ,
    Thanks for reporting!

    Yeah, it is possible to get clean Json with --debug field.
    But it is a good point. Thanks! We will investigate it.
    I'll keep you in touch.

  3. rdewolff commented on Mar 3, 2020

    @rdewolff
    Author

    hey Alexander Goncharov (@alexandergoncharov) - you're welcome.
    Hope this feedback will help you craft an even better product.
    Would be great to be updated when you get this fixed. Thanks!

  4. alexhisen commented on Mar 20, 2020

    @alexhisen

    We use this script with the original code-push cli:

    exec(`code-push deployment history ${app} ${deployment} --format json`, {}, (error, stdout, stderr) => {
      if (error) {
        console.error(stderr); // eslint-disable-line
        throw error;
      }
    
      const releases = JSON.parse(stdout);
      const latestRelease = releases[releases.length - 1];
      if (!latestRelease) {
        console.log(`No releases for ${app} ${deployment}`); // eslint-disable-line
        return;
      }
    
      const tag = `${latestRelease.appVersion}${latestRelease.label}`;
      const gitCommand = `git tag ${tag} && git push origin ${tag}`;
      console.log(gitCommand); // eslint-disable-line
      exec(gitCommand, {}, (gitError, gitStdout, gitStderr) => {
        if (gitError) {
          console.error(gitStderr); // eslint-disable-line
          throw gitError;
        }
        console.log(gitStdout); // eslint-disable-line
      });
    });
    
  5. ghost closed this as completedon Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions