development

하나의 명령으로 Cordova 플러그인 업데이트

big-blog 2020. 7. 18. 09:32
반응형

하나의 명령으로 Cordova 플러그인 업데이트


Cordova 플러그인을 업데이트하는 더 쉬운 방법이 있는지 궁금합니다.

나는 구글 (2013 년 @)을 찾았지만 이것은 내가 원하는 100 %가 아닙니다.

나는 두 단계 로이 작업을 수행 할 수 있다는 것을 알고 있습니다 : rm, 추가하지만 새로운 버전의 플러그인이있는 더 나은 (공식) 방법을 찾고 있습니까? 하나의 명령으로 모든 것을 업데이트 할 수 있습니다. (npm 업데이트와 동일)

예를 들면 다음과 같습니다.

$ cordova plugin list
/* list all installed plugins, their dependencies, and newer versions */

$ cordova plugin update
/* update all of them for me */

공식적인 방법이 없다면 다른 도우미가 있습니까? 에야디야?


플러그인 업데이트를 수동으로 확인하는 데 지쳤으므로 https://github.com/dpa99c/cordova-check-plugins

전역으로 설치하십시오.

$ npm install -g cordova-check-plugins

그런 다음 Cordova 프로젝트의 루트에서 실행하십시오. 선택적으로 오래된 플러그인을 대화식 또는 자동으로 업데이트 할 수 있습니다 (예 :

$ cordova-check-plugins --update=auto

CLI 스크린 샷


업데이트 할 수 없습니다. 코드 바 플러그인을 제거하고 다시 추가하면됩니다.

cordova plugin rm https://github.com/apache/cordova-plugin-camera --save
cordova plugin add https://github.com/apache/cordova-plugin-camera --save

이온 상태는 ionic@3.7.0에서와 같이 더 이상 사용되지 않습니다.

이온 및 이온 클리닉을 사용하는 경우 다음을 실행할 수 있습니다.

ionic state reset

모든 플러그인 정보가 package.json에 이전에 저장되어있는 한, 모든 플러그인에 대해 rm / add를 기본적으로 수행합니다. 이것도 플랫폼을 rm / add 할 것이지만, 중요하지 않습니다.

리포지토리에서 플러그인 폴더를 무시하고 다른 컴퓨터에서 프로젝트를 설정하려는 경우에도 유용합니다.

분명히 이것은 질문에 직접 대답하지는 않지만 많은 사람들이 현재 두 가지를 모두 사용하고 있으며 결국 여기에 올 것입니다.


여기 내가 사용하는 bash 스크립트가 있으며 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

shan의 설명에 따라 충돌이있는 경우 도움이 될 수 있습니다 . 차이점은 --force제거 할 때 플래그 가 추가 된다는 것입니다.

#!/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

npmjs.org에서 다른 답변을 찾았습니다.

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

기본적으로 프로젝트에 도구를 설치합니다.

npm install -g cordova-plugin-update

완료되면 명령을 실행해야합니다

cordova-plugin-update

최신 버전의 플러그인이 사용 가능한 경우 업데이트하라는 메시지가 표시됩니다.


이것은 하나의 명령으로 모든 플러그인을 업데이트하기위한 Windows Batch 버전입니다.

사용하는 방법:

프로젝트의 동일한 폴더에있는 명령 줄에서

c:\> batchNameFile

또는

c:\> batchNameFile autoupdate

여기서 "batchNameFile"은 아래 스크립트와 함께 .BAT 파일의 이름입니다.

테스트 만 (첫 번째 예) 또는 모든 업데이트를 사용 가능하도록 (두 번째 예)

@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

이 배치는 Windows 10에서만 테스트되었습니다.


PhoneGap / Cordova CLI를 사용한 플러그인 관리는 매우 성가신 일입니다. 이 블로그 게시물은 다음과 같은 시작일 수 있습니다.하지만 A) 아직 활용 방법 또는 B) 작동 방식이 확실하지 않습니다.

http://nocurve.com/cordova-update-all-plugins-in-project

My initial attempt at running the entire script right in the terminal command line did create an output of text with add/remove plugin commands ... but they didn't actually execute they just echoed into the terminal. I've reached out to the author hoping they will explain a bit more.


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

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

The easiest way would be to delete the plugins folder. Run this command: cordova prepare But, before you run it, you can check each plugin's version that you think would work for your build on Cordova's plugin repository website, and then you should modify the config.xml file, manually. Use upper carrots, "^" in the version field of the universal modeling language file, "config," to indicate that you want the specified plugin to update to the latest version in the future (the next time you run the command.)


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

콘솔 미리보기


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

use the command line


You don't need remove, just add again.

cordova plugin add https://github.com/apache/cordova-plugin-camera

참고 URL : https://stackoverflow.com/questions/28783968/update-cordova-plugins-in-one-command

반응형