Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improved --json output from devices #5565

Merged
merged 3 commits into from
Feb 15, 2022
Merged

Conversation

rigor789
Copy link
Member

@rigor789 rigor789 commented Sep 7, 2021

PR Checklist

What is the current behavior?

ns device --json

Connected devices & emulators
Searching for devices...
{"imageIdentifier":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","identifier":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","displayName":"iPhone 12 Pro Max","model":"iPhone 12 Pro Max","version":"15.0","vendor":"Apple","platform":"iOS","status":"Connected","errorHelp":null,"isTablet":false,"type":"Emulator","connectionTypes":[10]}
ns device --available-devices --json

Available emulators
┌───────────────────────────────────────┬──────────┬───────────┬──────────────────────────────────────┬──────────────────────────────────────┬────────────┐
│ Device Name                           │ Platform │ Version   │ Device Identifier                    │ Image Identifier                     │ Error Help │
│ iPhone 5s                             │ iOS      │ 12.4      │ XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX │ XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX │            │
│ Pixel_3_XL_API_31                     │ Android  │           │                                      │ Pixel_3_XL_API_31                    │            │
│ ...                                   │          │           │                                      │                                      │            │
└───────────────────────────────────────┴──────────┴───────────┴──────────────────────────────────────┴──────────────────────────────────────┴────────────┘

Connected devices & emulators
Searching for devices...
{"imageIdentifier":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","identifier":"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX","displayName":"iPhone 12 Pro Max","model":"iPhone 12 Pro Max","version":"15.0","vendor":"Apple","platform":"iOS","status":"Connected","errorHelp":null,"isTablet":false,"type":"Emulator","connectionTypes":[10]}

What is the new behavior?

ns device --json
Searching for devices...
{
  "devices": [
    {
      "imageIdentifier": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "identifier": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "displayName": "iPhone 12 Pro Max",
      "model": "iPhone 12 Pro Max",
      "version": "15.0",
      "vendor": "Apple",
      "platform": "iOS",
      "status": "Connected",
      "errorHelp": null,
      "isTablet": false,
      "type": "Emulator",
      "connectionTypes": [
        10
      ]
    }
  ]
}
ns device --json --available-devices
Searching for devices...
{
  "devices": [
    {
      "imageIdentifier": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "identifier": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "displayName": "iPhone 12 Pro Max",
      "model": "iPhone 12 Pro Max",
      "version": "15.0",
      "vendor": "Apple",
      "platform": "iOS",
      "status": "Connected",
      "errorHelp": null,
      "isTablet": false,
      "type": "Emulator",
      "connectionTypes": [
        10
      ]
    }
  ],
  "available": [
    {
      "imageIdentifier": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "identifier": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
      "displayName": "iPhone 5s",
      "model": "iPhone 5s",
      "version": "12.4",
      "vendor": "Apple",
      "status": "Not running",
      "errorHelp": null,
      "isTablet": false,
      "type": "Emulator",
      "connectionTypes": [
        10
      ],
      "platform": "iOS"
    },
    {
      "identifier": null,
      "imageIdentifier": "Pixel_3_XL_API_31",
      "displayName": "Pixel_3_XL_API_31",
      "vendor": "Avd",
      "status": "Not running",
      "errorHelp": null,
      "isTablet": false,
      "type": "Emulator",
      "connectionTypes": [
        10
      ],
      "platform": "Android"
    },
    ...
  ]
}

BREAKING CHANGES:

ns devices --json now prints a JSON object containing a devices key with an array of all devices.
ns devices --available-devices --json now properly prints available devices as JSON.

Migration steps:
update how parsing of the output is handled to use the new schema

{
  available?: any[];
  devices: any[];
}

@project-bot project-bot bot added this to Pull Request in CLI Team Sep 7, 2021
@cla-bot cla-bot bot added the cla: yes label Sep 7, 2021
@pekevski
Copy link

pekevski commented Sep 8, 2021

Hi @rigor789, could we also add a --json option for ns device list-applications?

@rigor789
Copy link
Member Author

rigor789 commented Sep 8, 2021

Hi @rigor789, could we also add a --json option for ns device list-applications?

I've never used that command! Where would you use the output?

What json schema would work best?

Maybe this:

{
  [deviceId: string]: Array<string>
}

example:

{
  "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX": [
    "org.nativescript.myApp",
    "org.nativescript.myOtherApp"
  ]
}

@pekevski
Copy link

pekevski commented Sep 8, 2021

Not sure but there was another command that took an application ID as input. So using this command would help find the ID I suppose. I guess we could leverage this command in fig so that applications IDs are autocompleted to the user.

I like that json structure!

@rigor789 rigor789 merged commit 8446795 into master Feb 15, 2022
@rigor789 rigor789 deleted the feat/improved--json-output branch February 15, 2022 13:47
CLI Team automation moved this from Pull Request to Done Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
CLI Team
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants