Update cordova plugins in one command

前端 未结 14 722
故里飘歌
故里飘歌 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 07:03

    npm update -f its working form me

    npm update -f

    it will update all plugins and cli

    • cordova-sqlite-storage@2.3.0
    • cordova-plugin-x-socialsharing@5.3.2
    • onesignal-cordova-plugin@2.3.3
    • @ionic-native/device@4.6.0
    • @ionic-native/screen-orientation@4.6.0
    • @ionic-native/onesignal@4.6.0
    • @ionic-native/status-bar@4.6.0
    • @ionic-native/splash-screen@4.6.0
    • @ionic-native/core@4.6.0
    • @ionic-native/social-sharing@4.6.0
    • @angular/cli@1.7.3
    • cordova-plugin-splashscreen@5.0.3-dev added 322 packages, removed 256 packages, updated 91 packages and moved 8 packages in 350.86s
    0 讨论(0)
  • 2020-12-04 07:05

    You don't need remove, just add again.

    cordova plugin add https://github.com/apache/cordova-plugin-camera
    
    0 讨论(0)
  • 2020-12-04 07:06

    you cannot update ,but i wrote a batch file that removes my plugins and install again so in this case my all plugins are updated automatically, hope this solves your problem

    @echo off
    for %%a in (
    "com.ionic.keyboard"
    "com.phonegap.plugins.PushPlugin"
    "cordova-instagram-plugin"
    "cordova-plugin-camera"
    "cordova-plugin-crosswalk-webview"
    "cordova-plugin-file"
    "cordova-plugin-file-transfer"
    
    ) do call cordova plugin rm %%a
    
    
    for %%b in (
    "com.ionic.keyboard"
    "com.phonegap.plugins.PushPlugin"
    "cordova-instagram-plugin"
    "cordova-plugin-camera"
    "cordova-plugin-crosswalk-webview"
    "cordova-plugin-file"
    "cordova-plugin-file-transfer"
    
    
    ) do call cordova plugin add %%b
    
    0 讨论(0)
  • 2020-12-04 07:12

    If you install the third party package:

    npm i cordova-check-plugins
    

    You can then run a simple command of

    cordova-check-plugins --update=auto --force
    

    Keep in mind forcing anything always comes with potential risks of breaking changes.

    As other answers have stated, the connecting NPM packages that manage these plugins also require a consequent update when updating the plugins, so now you can check them with:

    npm outdated
    

    And then sweeping update them with

    npm update
    

    Now tentatively serve your app again and check all of the things that have potentially gone awry from breaking changes. The joy of software development! :)

    0 讨论(0)
  • 2020-12-04 07:15

    This is my Windows Batch version for update all plugins in one command

    How to use:

    From command line, in the same folder of project, run

    c:\> batchNameFile
    

    or

    c:\> batchNameFile autoupdate
    

    Where "batchNameFile" is the name of .BAT file, with the script below.

    For only test ( first exmple ) or to force every update avaiable ( 2nd example )

    @echo off
    
    cls
    
    set pluginListFile=update.plugin.list
    
    if exist %pluginListFile% del %pluginListFile%
    
    Echo "Reading installed Plugins"
    Call cordova plugins > %pluginListFile%
    echo.
    
    for /F "tokens=1,2 delims= " %%a in ( %pluginListFile% ) do (
       Echo "Checking online version for %%a"
    
       for /F "delims=" %%I in ( 'npm info %%a version' ) do (
         Echo "Local : %%b"
         Echo "Online: %%I"
         if %%b LSS %%I Call :toUpdate %%a %~1
         :cont
         echo.
       )
    )
    
    if exist %pluginListFile% del %pluginListFile%
    
    Exit /B
    
    :toUpdate
    Echo "Need Update !"
    if '%~2' == 'autoupdate' Call :DoUpdate %~1
    goto cont
    
    :DoUpdate
    Echo "Removing Plugin"
    Call cordova plugin rm %~1
    Echo "Adding Plugin"
    Call cordova plugin add %~1
    goto cont
    

    This batch was only tested in Windows 10

    0 讨论(0)
  • 2020-12-04 07:16

    Go to your cordova project directory then write

    npm outdated
    

    npm will be display your outdated plugins, if any plugin outdated then write this command

    npm update
    

    0 讨论(0)
提交回复
热议问题