Package detail

cordova-clean

DavidBriglio236MIT1.4.2

Helps maintain a synchronized cordova repository.

cordova, cleanup, plugin, plugins

readme

cordova-clean npm version

This tries to fix the issue of inconsistent cordova plugins/platforms of a project when working in different branches. It can remove all installed plugins/platforms and install all plugins/platforms listed in the package.json file. This avoids the case of having left over plugins/platforms from other branches installed, and if a plugin has been updated without updating the version number.

How To Install

Install through npm:

npm install cordova-clean

This package depends on any version of cordova being installed.

How To Use

Run the shell command: cordova-clean <COMMAND> <OPTIONS>

Commands

Command Explanation
clean Atomic approach that will remove all installed plugins and platforms, and add all plugins and platforms specified in package.json.
plugins Removes all installed plugins and installs plugins specified in package.json.
platforms Removes all platforms and installs platforms specified in package.json.
sync This will do the same functionality as clean, but instead of removing/adding everything it will do a smart compare to see which plugins should be added/removed. Note that -noforce is not used here, since we do not want to remove any plugins that are dependencies. By default this will compare platform/plugin versions, but if you only want to check names add the -soft option to this command.
version, v, -v, -version Output package version.

Options

Option Short Form Command Valid In Explanation
-noremove -nr clean, plugins, platforms, sync Prevents the removal of plugins/platforms. Use this if you only want to install the package.json plugins/platforms on top of the installed ones.
-noforce -nf clean, plugins Prevents force uninstall plugins. By default all plugins are removed using the -force flag, this way all plugins will be removed even if they are dependencies to other plugins.
-gitfetch -gf clean, plugins, sync Prevents -nofetch from being used when installing git repository plugins. This is mostly an issue with cordova versions below 8, it will fail installing plugins from git repositories because it attempts to add them as an npm package instead of using git. By default nofetch is used to prevent this issue from happening.
-noadd -na clean, plugins, platforms, sync Prevents adding plugins/platforms. Use this if you only want to remove installed plugins/platforms, without adding from the package.json.
-noios -ni clean, platforms, sync Prevents iOS from being installed / removed on platform steps.
-noandroid -nand clean, platforms, sync Prevents Android from being installed / removed on platform steps.
-soft -s sync Makes plugin / platform checks only based off of name (no version check).
-addlinks -al sync This forces plugins / platforms added from git or local to be re-added during sync.

You can set these options to true or false by following the option with = and the value: -noios=true -noandroid=false. This can be used to override options that are defined in the cordova-clean.json configuration file.

All options can be added with single or double dashes '-'.

Quirks

Version checking with the sync command works by checking the version listed in cordova [platform|plugin] ls against the version in the package.json file. Plugins and platforms added through local or github repositories will always be skipped by default if the plugin / platform is present (they will be assumed to be up to date). This is because we cannot reliably compare the installed version number to the repository link. If you would like to change the behaviour to re-add these plugins instead of skipping in this situation, add the -addlinks option when performing the sync command.

Clean Config File

You can put cordova-clean.json at the root of your project to set options automatically. All values can be set to either true or false. If any other value is used, it will default to false. These options will apply to every command that is executed. If you do not wish for one of these options to apply, use the command line argument to set the variable (ie -noandroid=true), since command line options override those in the cordova-clean.json file.

Option
noForce
noRemove
fetch
noAdd
soft
noiOS
noAndroid
addLinks

Example:

{
    "noForce": true,
    "noiOS": true,
    "noAndroid": false
}

Questions?

Feel free to open an issue if you are having issues or would like to contribute!

MIT License

Please see the LICENSE.md file for more information on licensing.

changelog

Changelog

v1.4.2 - 29/09/2020

  • Added support for plugin names with prefixes (ie: @mycompany/plugin-name)

v1.4.1 - 24/09/2020

  • Added support for plugins located in devDependencies

v1.4.0 - 24/09/2020

  • Added support for platforms located in devDependencies

v1.3.5 - 04/01/2019

  • Added gitignore

v1.3.4 - 04/01/2019

  • Moved message output order to show only version number on version command, and to show config related messages after welcome banner

v1.3.3 - 03/27/2019

  • Removed references to config.xml, now only using package.json (compliant with cordova 9+)
  • Removed cordova dependency that was causing cordova to be installed within the package directory

v1.3.2 - 08/14/2018

  • Fixed variable plugin install

v1.3.1 - 07/26/2018

  • Added clean config file support, to always apply options for all operations
  • Added support for option values (ie -noios=false, -noandroid=true) to override clean config file

v1.3.0 - 07/25/2018

  • Changed intro text and moved option output after intro output
  • Added version checking to plugins / platforms in sync command
    • New -soft and -addlinks options for sync command
  • Adding plugins now adds their variables specified in package.json
  • Configuration reference is now package.json, instead of config.xml

v1.2.3 - 06/28/2018

  • Re-ordered operations in 'clean' and 'sync' to increase speed

v1.2.2 - 05/11/2018

  • Added -noios and -noandroid options, this prevents those platforms from being added / removed

v1.2.1 - 03/07/2018

  • Fixed issue with installing plugins from file paths (replaced '\' with '/')
  • Added package version command
  • Options can now be entered with single or double '-', ie: '--option1' and '-option1'

v1.2.0 - 03/05/2018

  • Added sync command

v1.1.1 - 03/01/2018

  • Fixed issue with installing plugins from file paths

v1.1.0 - 02/08/2018

  • Added commands for clean/platform/plugin
  • renamed to 'cordova-clean' since it will not be plugin specific

v1.0.1 - 02/08/2018

  • Added --noadd option to skip adding plugins

v1.0.0 - 02/08/2018

  • Initial release