Cordova CLI, using Git, and saving plugins/platforms

后端 未结 2 902
南笙
南笙 2021-02-08 13:41

I\'m trying to figure out how to reconcile some Cordova + git \"best practices\" with what I think is reality, and I\'m hoping someone can shed some light on this for me.

<
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-08 14:04

    I typically write a hook to capture the plugins I want to use in my project. You can see this in an article I wrote here: http://devgirl.org/2013/11/12/three-hooks-your-cordovaphonegap-project-needs/

    With the new modular architecture of Cordova 3.x, every app needs plugins, even to use basic functionality such as logging or geolocation. Rather than document which plugins/features your project needs and ask each new developer to install them, download and install them automatically with a hook in the after_platform_add step. Using this plugin, every time a developer checks out the project and adds a platform, they automatically have the required plugins.

    You also may be interested in following along with this bug, which suggests npm style --save functionality: https://issues.apache.org/jira/browse/CB-5775

    Platforms are a little more difficult because they don't fit into the hook architecture, but you could write a shell script which you could execute to add your platforms.

    #!/bin/sh
    for plat in ios android; do
       cordova platform add $plat
    done
    

    You could do something similar with the version of cordova you have installed in node_modules (at least that is what I think you are installing in node_modules)--have shell script to get the correct version of cordova:

    #!/bin/sh
    VERSION=3.3.1-0.4.2
    npm install cordova@$VERSION
    

    PS Glad you liked the book!

提交回复
热议问题