Update cordova plugins in one command

前端 未结 14 721
故里飘歌
故里飘歌 2020-12-04 06:34

I am wondering is there an easier way to update cordova plugin?

I googled, found a hook (@ year 2013), but this is not 100% what I want.

I know I can do this

相关标签:
14条回答
  • 2020-12-04 06:56
    cordova-check-plugins --update=auto --force
    

    use the command line

    0 讨论(0)
  • 2020-12-04 06:57

    ionic state is deprecated as on ionic@3.7.0

    If you happen to be using ionic and the ionic cli you can run:

    ionic state reset
    

    As long as all your plugin information was saved in your package.json earlier, this will essentially perform an rm/add for all your plugins. Just note that this will also rm/add your platforms as well, but that shouldn't matter.

    This is also nice for when you ignore your plugin folders from your repo, and want to setup the project on another machine.

    Obviously this doesn't directly answer the question, but many people are currently using both, and will end up here.

    0 讨论(0)
  • 2020-12-04 06:59

    I got tired of manually checking for plugin updates so created a tool to do it for me: https://github.com/dpa99c/cordova-check-plugins

    Install it globally:

    $ npm install -g cordova-check-plugins
    

    Then run from the root of your Cordova project. You can optionally update outdated plugins interactively or automatically, e.g.

    $ cordova-check-plugins --update=auto
    

    0 讨论(0)
  • 2020-12-04 06:59

    Found another answer from the npmjs.org

    https://www.npmjs.com/package/cordova-plugin-update

    Basically its installing the tool into your project:

    npm install -g cordova-plugin-update
    

    when done you then have to run the command

    cordova-plugin-update
    

    and it will prompt you to update if ever a newer version of a plugin is available

    0 讨论(0)
  • 2020-12-04 06:59

    Here's a bash script I use, works on OSX 10.11.3.

    #!/bin/bash
    
    PLUGINS=$(cordova plugin list | awk '{print $1}')
    
    for PLUGIN in $PLUGINS; do
        cordova plugin rm $PLUGIN --save && cordova plugin add $PLUGIN --save
    done
    

    This may help if there are conflicts, per shan's comment. The difference is the addition of the --force flag when removing.

    #!/bin/bash
    
    PLUGINS=$(cordova plugin list | awk '{print $1}')
    
    for PLUGIN in $PLUGINS; do
        cordova plugin rm $PLUGIN --force --save && cordova plugin add $PLUGIN --save
    done
    
    0 讨论(0)
  • 2020-12-04 07:00

    You can't update it. What you can do is uninstall the cordova plugin and add it again.

    cordova plugin rm https://github.com/apache/cordova-plugin-camera --save
    cordova plugin add https://github.com/apache/cordova-plugin-camera --save
    
    0 讨论(0)
提交回复
热议问题