2

What does actually happen in the project, when we do following ionic state commands?

  • restore
  • save
  • clear
  • reset

In what kind of situations do we need to use them?

I googled about this, but couldn't find any appropriate answer with details.

I appreciate any kind of your help.

coder
  • 8,346
  • 16
  • 39
  • 53

2 Answers2

11

You could always look into their source code for the Ionic CLI v1/v2

save: 'Save the platforms and plugins into package.json',

restore: 'Restore the platforms and plugins from package.json',

clear: 'Clear the package.json of cordovaPlugins and cordovaPlatforms, '
  'as well as clear out the platforms and plugins folders',

reset: 'Clear out the platforms and plugins directories, and reinstall plugins and platforms',

https://github.com/driftyco/ionic-cli/blob/fac1c4d7b49e7c102269f3d5e0acef660d762bf5/lib/ionic/state.js#L20-L33

state has been removed from CLI v3: The plugins and platforms can be managed entirely by Cordova. Please remove the cordovaPlatforms and cordovaPlugins keys from your package.json file. If you're using Cordova 7, please review the announcement about how Cordova uses config.xml and package.json to manage plugins and platforms.

0x1ad2
  • 8,014
  • 9
  • 35
  • 48
  • This command doesn't work with the new CLI, what is the new one? – Jay Ordway May 22 '17 at 19:53
  • Note the CLI v3 section on Github https://github.com/driftyco/ionic-cli/blob/86d8c9ab910a65b4daed080e6c9e3c4f1a72f88c/CHANGELOG.md#cli-v3 – 0x1ad2 May 24 '17 at 07:41
  • Looks like it's "cordova plugin save" and it stores it to the config.xml and not the package.json any longer – Jay Ordway May 25 '17 at 02:47
4

ionic state restore - Ionic will add in the appropriate plugins and platforms. This will be incredibly useful for folks checking out your Ionic project from a source control repository.

ionic state save - To store the current platforms and plugins to the package.json.

ionic state clear - Removes everything, including the default plugins Ionic always install.

ionic state reset - This will remove everything then bring back what you have specified in the package.json file.

Ref. - https://www.raymondcamden.com/2015/04/20/ionic-adds-a-new-state-feature

Regards.

Hardik Vaghani
  • 2,163
  • 24
  • 46