ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

The ionic-cli is not saving the variables to package.json on plugin add

Open maksymilian-majer opened this issue 11 years ago • 15 comments

Plugin variables aren't being saved to the package.json after running ionic plugin add submodules/phonegap-facebook-plugin --variable APP_ID=SOMEID --variable APP_NAME=someName.

I checked the source of State in ionic-app-lib and it takes a variables arguments (source), but the ionic-cli does not pass it along (source).

maksymilian-majer avatar May 20 '15 10:05 maksymilian-majer

Nice catch. I'll patch it today. Thanks for reporting!

jbavari avatar May 20 '15 14:05 jbavari

@maksymilian-majer Mind double checking for me - npm install -g ionic@beta

The beta version should be passing along variables now.

jbavari avatar May 20 '15 14:05 jbavari

@jbavari I checked it and it works as expected :+1:

maksymilian-majer avatar May 20 '15 16:05 maksymilian-majer

Awesome. I'll merge this into master and be pushing it out later. Thanks again for reporting!

jbavari avatar May 20 '15 16:05 jbavari

No problem. You're doing amazing work with ionic, glad to be helpful!

maksymilian-majer avatar May 20 '15 16:05 maksymilian-majer

I ran into the same issue. I'm using CLI 1.5.5

ionic plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="SOME_BILLING_KEY"

yankustefan avatar Jun 18 '15 09:06 yankustefan

Ran into this issue today using CLI 1.5.5 as well when I tried:

ionic plugin add https://github.com/Telerik-Verified-Plugins/Stripe --variable API_KEY=STRIPE_SECRET_API_KEY

eroh92 avatar Jun 25 '15 21:06 eroh92

Note, I'm assuming that this thread is reporting that when you use the --variable flag, the variable doesn't get saved to the root package.json so you can use ionic state restore on other team's machines, build boxes, etc.

I tried npm install -g ionic@beta and it didn't work there either.

eroh92 avatar Jun 25 '15 22:06 eroh92

in my experience trying to use this with the facebook plugin i discovered that ionic add does edit the package.json correctly, however a restore or even a reset does not install the plugin correctly. the facebook plugin directly actually becomes completely empty. i did use the http url. for now I am installing the plugin via bash script immediately after ionic restore

kfatehi avatar Jul 09 '15 07:07 kfatehi

The facebook plugin is an exception as you need to have a copy of it locally in order for it to install: https://github.com/Wizcorp/phonegap-facebook-plugin#-----cordova-registry-warning-ios

On Thu, Jul 9, 2015 at 12:14 AM, Keyvan Fatehi [email protected] wrote:

in my experience trying to use this with the facebook plugin https://github.com/Wizcorp/phonegap-facebook-plugin i discovered that ionic add does edit the package.json correctly, however a restore or even a reset does not install the plugin correctly. the facebook plugin directly actually becomes completely empty. i did use the http url. for now I am installing the plugin via bash script immediately after ionic restore

— Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic-cli/issues/429#issuecomment-119852396.

eroh92 avatar Jul 09 '15 17:07 eroh92

i would argue that because the locator attribute is set to a git repository, it is expected that under the hood ionic would locally clone the repo down and try to add it, thereby complying with that warning.

kfatehi avatar Jul 09 '15 17:07 kfatehi

Ionic: v1.6.4 Cordova: v5.1.1

It isn't working, when I tried to add the google plugin.

Command: ionic plugin add ionic plugin add https://github.com/EddyVerbruggen/cordova-plugin-googleplus --variable REVERSED_CLIENT_ID=CLIENT_ID

And below was the result in package.json, variables object is pretty much empty

"locator": "https://github.com/EddyVerbruggen/cordova-plugin-googleplus", "id": "cordova-plugin-googleplus", "variables": { "": "" }

gothammm avatar Aug 20 '15 06:08 gothammm

@peek4y I believe you are running into the same issue I was having with using --variable. See https://github.com/driftyco/ionic-app-lib/pull/26 for the details and a possible solution.

BennettSmith avatar Sep 18 '15 05:09 BennettSmith

Hi @maksymilian-majer @jbavari

Just a quick question. This has been closed but I'm not sure if this resolved. If I add a plugin with variables, it saves to config.xml but not to package.json

Is it supposed to work that way and do we need to add the plugins and config to package.json manually? For example:

  "cordovaPlugins": [
    "cordova-plugin-device",
    "cordova-plugin-console",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "ionic-plugin-keyboard",
    {
      "id": "cc.fovea.cordova.purchase",
      "locator": "https://github.com/j3k0/cordova-plugin-purchase.git",
      "variables": {
        "BILLING_KEY": "SOME_KEY_VALUE"
      }
    },
    {
      "id": "cc.fovea.plugins.newsstand",
      "locator": "https://github.com/j3k0/PhoneGap-Newsstand-iOS.git"
    }
  ]

Thank you for your input.

yankustefan avatar Oct 13 '16 02:10 yankustefan

With the command ionic state save the plugins are saved to config.xml But the variables are ignored. Is that okay?

yankustefan avatar Oct 13 '16 08:10 yankustefan