Nativescript-cli: How to request user input during plugin installation?

Created on 9 Feb 2017  路  4Comments  路  Source: NativeScript/nativescript-cli

Hi,

Before {N} 2.5.0 was released nativescript-plugin-firebase was able to use a postinstall script that prompted the user about his configuration ("Do you want to use Firebase Messaging? (y/n)"). The prompt code can be found here.

When 2.5.0 was released and you installed version 3.9.2 of the plugin the CLI just hanged. So I released 3.9.3 that removed the postinstall script, now users must not forget to run it themselves after plugin installation.

Was this intended / is it a bug.. I don't know, but what would you currently recommend for me to use to prompt the user during plugin installation?

Thanks!

bug

All 4 comments

Amplifying this, and I'd like to re-enable the use of postinstall prompts as it's a great feature to have with these more feature-full plugins

Hey @EddyVerbruggen , @jlooper , thanks for pointing this regression.
In versions before 2.5.0, CLI was using npm as a dependency in it's own package.json. In 2.5.0, we rely on user's npm installation. So this required a lot of changes in the code and it looks like we've missed this case.
We'll try to provide a fix as soon as possible. Thanks for reporting it.

Btw @EddyVerbruggen , such postinstall scripts can cause issues in CI builds, where the terminal is not interactive. I would advise you to add isInteractive method and call any prompt only in case the method returns true:

function isInteractive() {
    return process.stdout.isTTY && process.stdin.isTTY;
}

Hey @rosen-vladimirov, thanks a lot for picking this up so quickly, much appreciated!

Btw, the firebase plugin saves a json config file for CI builds to pick up, but your suggestion is a great addition to that, will add it!

@rosen-vladimirov This issue is back with the current CLI (3.1.0). This line uses "pipe" instead of your fix ("inherit").

I've found a way to fix it and will do a PR so postinstall scripts are executed again.

Was this page helpful?
0 / 5 - 0 ratings