Is there a way to pin Cordova plugins to a specific version?

This is more a Cordova question, but specific to Ionic as it also helps us to manage our plugins:

Is there a way to pin Cordova plugins to a specific version?

Cordova released quite a lot of updated plugins a few days ago which is quite nice, but a desaster for me as I am just in the middle of a release process, building apps for the stores. And a /plugins and /platform are not in git (and have to be rebuilt because of package name changes) I have to download the plugin source again… UAHHH!

1 Like

Ok, got answers on Slack.

Yes, you can do that. Just use the current version when you install the plugin (ionic plugin add plugin-id-or-name@1.2.3) and you should be fine.

I tried all the different versions of parameters that you can use, here they are and their results:

  1. ionic plugin add phonegap-plugin-push installs the current version of the plugin and adds the plugin name to cordovaPlugins in package.json:
  • "phonegap-plugin-push",
  1. ionic plugin add com.adjust.sdk --save installs the current version of the plugin, adds the plugin name to cordovaPlugins in package.json and the plugin name and current version to config.xml:
  • "com.adjust.sdk",
  • <plugin name="com.adjust.sdk" spec="~4.1.3" />
  1. ionic plugin add cordova-plugin-inappbrowser@1.0.0 installs the 1.0.0 version of the plugin and adds the plugin name and version to cordovaPlugins in package.json:
  • “cordova-plugin-inappbrowser@1.0.0”,`
  1. ionic plugin add cordova-plugin-file@3.0.0 --save installs the 1.0.0 version of the plugin, adds the plugin name and version to cordovaPlugins in package.json and the plugin name and specified version to config.xml:
  • "cordova-plugin-file@3.0.0"
  • <plugin name="cordova-plugin-file" spec="~3.0.0" />

What seems missing is a command that does for package.json what --save does for Cordova: Pin the current version on install time. Or did I miss it?

Luckily I can fix my current issues by getting the currently installed and last working (and saved to git) version of the plugins, add them to package.json and ionic state restore will work again as intended.

3 Likes