[Cloud Deploy] How can I get active snapshot UUID?


#1

Hello everyone,
I’m testing the Ionic Cloud Deploy Services.

After deploy, download and extract some snapshots in my app, i want to delete all of them except the current one.

From de documentation:

Make sure you do not delete the active snapshot or your app will become unusable.

this.deploy.getSnapshots() method returns me an array of snapshot UUIDs. For example:

[“f776ce18-b0ca-11e6-82c1-ce731e1eefca”, “456903fa-b0c4-11e6-b81b-62abd1a4e315”, “5748f42e-b0d7-11e6-ae1b-06f49b13e20e”, “7428a438-b0c3-11e6-865e-06f49b13c20e”]

How can I know what is the active snapshot?

Thanks in advance.


#2

Hello,

In Typescript definitions:

(method) Deploy.info(): Promise<any>
Get information about the current snapshot.

The promise is resolved with an object that has key/value pairs pertaining to the currently deployed snapshot.

So you can use:

this.deploy.info().then((x) => {
    console.log('Current snapshot infos', x);
})

I tried and i got:

binary_version: "2.0.0",
deploy_uuid: "********-****-****-****-************"

#3

So the solution, i tested is:

this.deploy.getSnapshots().then((snapshots) => {
        console.log('Snapshots', snapshots);
        // snapshots will be an array of snapshot uuids
        this.deploy.info().then((x) => {
          console.log('Current snapshot infos', x);
          for (let suuid of snapshots) {
            if (suuid !== x.deploy_uuid) {
              this.deploy.deleteSnapshot(suuid);
            }
          }
        })
      });

#4

Thanks for your help @Zaphod!