phonegap / node-phonegap-build

PhoneGap Build node module to login, create, and build apps.
Apache License 2.0
25 stars 25 forks source link

Download app after build #66

Closed Scriptonita closed 7 years ago

Scriptonita commented 7 years ago

Hi!! I'm trying make a script to download the app after build succes.

phonegapbuild.build(datos, function(e, data) {
  if (e) {
    console.error("Fallo al compilar:", e);
  } else {
    //console.log("successfully built the app:", data);
    console.log("Se ha compilado con éxito!!");
    var file = fs.createWriteStream("myapp.apk");
    var request = https.get(
      //"https://build.phonegap.com/apps/xxxxxx/download/android", // This url fail too. 4,4Kb
      "https://build.phonegap.com/api/v1/apps/xxxxxx/android", // 61Bytes
      function(response) {
        response.pipe(file);
        console.log("Descargando versión android");
      }
    );   
  }
});

The first url download a 4,4Kb file, the second 61bytes.

I have also tried with: https://www.npmjs.com/package/download https://www.npmjs.com/package/request-progress

But the same thing happens. If I go to the build.phonegap.com and click on the Apps link, I download a file aprox 12mb

Thanks!!

Scriptonita commented 7 years ago

Already solved.

As happened to #63 phonegapBuild.on("login") never gets called.

If I change the extension apk to txt I can see that the content in files say that i need loggin.

This is the code that work for me:

phonegapbuild.login(datos, function(e, api) {
  console.log("Estás logeado en Phonegap Build");
  phonegapbuild.build(datos, function(e, data) {
    if (e) {
      console.error("Fallo al compilar:", e);
    } else {
      console.log("Se ha compilado con éxito!!");
      let android = fs.createWriteStream(datos.title + ".apk");
      api.get("/apps/XXXXXXX/android").pipe(android);
    }
  });
});