Hire Me! I'm currently looking for my next role in developer relations and advocacy. If you've got an open role and think I'd be a fit, please reach out. You can also find me on LinkedIn.

To be fair, this may not be very new, I've been working with an alpha version of the Ionic CLI while I test push (and other stuff ;) so my version has been a bit out of sync. Today I switched from the alpha to the release version and discovered a cool new feature - State.

The State feature lets you quickly save and restore plugins and platforms for an Ionic project. By default, when you add a platform or a plugin, Ionic will store this information in the package.json file. Here is an example of adding a platform:

ionic1

(And as an aside - did you notice it added icons and splashscreens? Freaking awesome.) And here is adding a new plugin:

ionic2

When done, here is how package.json is updated:

{
  "name": "apr20-2",
  "version": "1.0.0",
  "description": "apr20-2: An Ionic project",
  "dependencies": {
    "gulp": "^3.5.6",
    "gulp-sass": "^1.3.3",
    "gulp-concat": "^2.2.0",
    "gulp-minify-css": "^0.3.0",
    "gulp-rename": "^1.2.0"
  },
  "devDependencies": {
    "bower": "^1.3.3",
    "gulp-util": "^2.2.14",
    "shelljs": "^0.3.0"
  },
  "cordovaPlugins": [
    "org.apache.cordova.device",
    "org.apache.cordova.console",
    "com.ionic.keyboard",
    "org.apache.cordova.device-motion"
  ],
  "cordovaPlatforms": [
    "ios"
  ]
}

To skip this, you can use --nosave for both platform and plugin modifications. Now comes the cool part. To quickly load in plugins and platforms, you can simply do:

ionic state restore

And 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.

You can also do:

ionic state save

To store the current platforms and plugins to the package.json. I would imagine you would use this feature if you used the --nosave option to test a plugin you weren't sure you wanted to actually keep around.

You may want to remove everything. You can do this with:

ionic state clear

But be aware this really, really does remove everything, including the default plugins Ionic always install. Finally, you can do:

ionic state reset

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