eventOneHQ / apkup

🚀 Publish APKs to Google Play directly from the terminal
https://oss.eventone.page/apkup
MIT License
36 stars 12 forks source link

Client cannot be set in Apkup class #11

Closed leonardosalles closed 5 years ago

leonardosalles commented 5 years ago

By some reason "this" is undefined in Apkup class and when this.client = new googleapis_1... is used it breaks and throw an error:

Cannot set property 'client' of undefined

Anyone is experiencing this issue too? I am using the latest version(1.2.0).

nprail commented 5 years ago

Are you trying to set client to your own instance of the Google APIs client?

Can you add an example of what you are running?

leonardosalles commented 5 years ago

I am trying to using publish method as showed in example, but it throws the error inside lib files.

Here is my code:

const { Apkup } = require('apkup'),
      playstorePrivate = require('./playstore-private.json'),
      co = require('co'),
      prompt = require('co-prompt'),
      confirm = prompt.confirm,
      fs = require('fs');

co(function*(){
    const releaseNotes = fs.readFileSync(__dirname + '/RELEASE-NOTES.md', 'utf-8');

    console.log('---------- RELEASE NOTES ----------\n\n')
    console.log(releaseNotes + '\n\n');
    console.log('---------- END RELEASE NOTES ----------\n\n')

    var ok = yield confirm('Está tudo correto? Confirma a publicação(y ou n)? ');

    if (ok) {
        const apkup = Apkup({
            client_email: playstorePrivate.client_email,
            private_key: playstorePrivate.private_key
        });

        console.log('Publicando...');

        apkup.upload('./QueroQueroEcm.apk', {
            releaseNotes: [
                {
                    language: 'pt-BR',
                    text: releaseNotes
                }
            ]
        }).then(data => {
            console.log(` > ${data.packageName} Versão ${data.versionCode} publicada!`);
        }).finally(function() {
            process.stdin.pause();
        }).catch(function(err) {
            console.log(err);
        });
    }

    if (!ok) {
        process.stdin.pause();
    }
})();
nprail commented 5 years ago

@leonardosalles Aha, that took a while to find. You forgot the new in front of Apkup.

For example:

// correct
const apkup = new Apkup({})

// incorrect
const apkup = Apkup({})

Let me know if that solves your problem! 😃

nprail commented 5 years ago

Oh, I just noticed that the README shows the incorrect example.

leonardosalles commented 5 years ago

Nice did bro! Thanks for the support, it is working fine now!

nprail commented 4 years ago

:tada: This issue has been resolved in version 1.3.0-beta.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

nprail commented 4 years ago

:tada: This issue has been resolved in version 1.3.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: