Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ionic state reset changes package.json #564

Closed
Freundschaft opened this issue Aug 14, 2015 · 6 comments
Closed

ionic state reset changes package.json #564

Freundschaft opened this issue Aug 14, 2015 · 6 comments
Labels

Comments

@Freundschaft
Copy link

I have this:

"cordovaPlugins": [
"ionic-plugin-keyboard",
"cordova-plugin-statusbar",
"cordova-plugin-camera",
"./engine/cordova-crosswalk-engine-c0.6.2",
"uk.co.workingedge.phonegap.plugin.launchnavigator",
"https://github.com/danwilson/google-analytics-plugin.git",
"cordova-plugin-file-transfer",
"cordova-plugin-whitelist",
"cordova-plugin-inappbrowser",
{
"locator": "https://github.com/carlosjavier84/phonegap-facebook-plugin.git",
"id": "com.phonegap.plugins.facebookconnect",
"variables": {
"APP_ID": "234234234234",
"APP_NAME": "testapp"
}
}
],

and when I run ionic state reset, there is always an additional https://github.com/carlosjavier84/phonegap-facebook-plugin.git entry that gets appended to cordovaplugins

I think this is a bug because then the plugin gets installed twice :(

@Freundschaft
Copy link
Author

okay it seems that cordova plugin save shows the same behavior

@Freundschaft
Copy link
Author

@Freundschaft
Copy link
Author

I think its required to compare locator as well, right?

@jbavari jbavari self-assigned this Aug 24, 2015
@jbavari jbavari added the bug label Aug 24, 2015
@jbavari
Copy link

jbavari commented Aug 24, 2015

I'll look into this today. Thank you for reporting.

@jakub-g
Copy link

jakub-g commented Mar 2, 2016

Edit: it seems I confused things, the extra entry is indeed added to package.json via the default ionic-provided hook, not by cordova command; deleting the hooks/after_plugin_add/010_register_plugin.js solves the issue


The same happens to us with ionic state restore

Basically AFAIU there's a fundamental mismatch between the ionic way and cordova way of handling the variables

When you have in package.json in cordovaPlugins:

{
  "variables": {
    "APP_ID": "123123",
    "APP_NAME": "test"
  },
  "locator": "[email protected]",
  "id": "[email protected]"
},

then when you do ionic state restore, ionic prints and executes the following command

cordova plugin add [email protected] --variable APP_ID="123123" --variable APP_NAME="test" 

which adds the following entry to package.json (plain plugin name without variables)

so now you have two entries for such plugin, one plain plugin@version and the other as JSON object.

You can have cordova save the variables but then you have to pass --save to the cordova plugin add ... command, and the variables will be saved not in package.json but in config.xml like this

<plugin name="cordova-plugin-facebook4" spec="~1.6.3">
    <variable name="APP_ID" value="123132" />
    <variable name="APP_NAME" value="test" />
</plugin>

(which is a pain BTW because cordova and ionic use a different XML formatter) and in package.json you will still end up with just a "plain" entry "[email protected]"

The same happens regardless if I put @1.6.3 anywhere or not

@jgw96
Copy link
Contributor

jgw96 commented May 2, 2016

Hello all! Thanks for opening an issue with us. We are currently in the process of deprecating the ionic state commands in favor of doing it the cordova way. https://cordova.apache.org/docs/en/latest/platform_plugin_versioning_ref/index.html You can keep up with the status of this on #904 . Thanks for using Ionic!

@jgw96 jgw96 closed this as completed May 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants