Skip to content

marcochavezf/ionic-cli

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1,070 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Build Status npm

Ionic CLI

The Ionic command line interface (CLI) is your go-to tool for developing Ionic apps.

Use ionic --help for more detailed command information.

πŸ“£ Support/Questions? Please see our Support Page for general support questions. The issues on GitHub should be reserved for bug reports and feature requests.

πŸ’– Want to contribute? Please see CONTRIBUTING.md.

Table of Contents

Requirements

  • Node 6 LTS (latest)
  • npm 3+

Install

$ npm install -g ionic

πŸ“ Note: For a global install -g ionic, macOS/Linux users may need to prefix with sudo or can setup proper file permissions for npm.

πŸ“ Note: Running ionic will first look to see if you're in an Ionic project. If you are, it runs the locally installed CLI.

Getting Started

New projects are started with the ionic start command. For full details and examples, see:

ionic start --help

Here is a table of project types and links to their respective starter templates:

Project Type Start Command Starter Templates
Ionic Angular ionic start myApp blank, tabs, sidemenu, conference, tutorial, super
Ionic 1 ionic start myApp --type=ionic1 blank, tabs, sidemenu, maps

After you start your project, you can cd into the directory and serve it in your browser:

cd ./myApp
ionic serve

Using Cordova

Integrate Ionic with Cordova to bring native capabilities to your app.

Requirements

$ npm install -g cordova
$ npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest
$ ionic --help
$ ionic cordova run ios

Environment Variables

The CLI will look for the following environment variables:

  • IONIC_CONFIG_DIRECTORY: Where the CLI config files live. Defaults to ~/.ionic. You may prefer ~/.config/ionic.
  • IONIC_HTTP_PROXY: Set a URL for proxying all CLI requests through. See Using a Proxy. The CLI will also look for HTTP_PROXY and HTTPS_PROXY, both of which npm use.
  • IONIC_EMAIL / IONIC_PASSWORD: For automatic login via environment variables.

CLI Flags

CLI flags are global options that alter the behavior of a CLI command.

  • --help: Instead of running the command, view its help page.
  • --verbose: Show all log messages for debugging purposes.
  • --quiet: Only show WARN and ERROR log messages.
  • --no-interactive: Turn off interactive prompts and fancy outputs. If a CI server is detected (we use ci-info), the CLI is automatically non-interactive.
  • --confirm: Turn on auto-confirmation of confirmation prompts. Careful: the CLI prompts before doing something potentially harmful. Auto-confirming may have unintended results.

CLI Config

The CLI provides commands for setting and printing config values from project config files and the global CLI config file. See ionic config set --help and ionic config get --help for usage.

CLI Hooks

CLI hooks are how you can run scripts during CLI events, such as "watch" and "build". To hook into the CLI, use the following npm scripts in your package.json file:

npm script description commands
ionic:watch:before Runs before the file watcher activates during a "watch" event ionic serve, ionic cordova run, ionic cordova emulate
ionic:build:before Runs before the Ionic "build" event starts. ionic upload, ionic package build, ionic cordova build
ionic:build:after Runs after the Ionic "build" event finishes. ionic upload, ionic package build, ionic cordova build

Example

  "scripts": {
    "ionic:build:before": "cp somefile www/somefile",
  }

πŸ“ Note: Use gulp? Check out @ionic/cli-plugin-gulp.

Service Proxies

The CLI can add proxies to the HTTP server for "livereload" commands like ionic serve, ionic cordova run android -lcs, or similar. These proxies are useful if you are developing in the browser and you need to make calls to an external API. With this feature you can proxy request to the external api through the ionic http server preventing the No 'Access-Control-Allow-Origin' header is present on the requested resource error.

In the ionic.config.json file you can add a property with an array of proxies you want to add. The proxies are an object with the following properties:

  • path: string that will be matched against the beginning of the incoming request URL.
  • proxyUrl: a string with the url of where the proxied request should go.
  • proxyNoAgent: (optional) true/false, if true opts out of connection pooling, see HttpAgent
{
  "name": "appname",
  "app_id": "",
  "type": "ionic-angular",
  "proxies": [
    {
      "path": "/v1",
      "proxyUrl": "https://api.instagram.com/v1"
    }
  ]
}

Using the above configuration, you can now make requests to your local server at http://localhost:8100/v1 to have it proxy out requests to https://api.instagram.com/v1.

πŸ“ Note: Don't forget to change the URLs being requested in your app to the local URL. Also, the "livereload" command must be restarted for the proxy configuration to take effect.

Using a Proxy

To proxy HTTP requests performed by the CLI, you will need to install the CLI proxy plugin globally and locally (for when the CLI runs inside your project directories):

$ npm install -g @ionic/cli-plugin-proxy
$ cd myNewProject # cd into your project
$ npm install @ionic/cli-plugin-proxy

Then, set the following environment variables:

$ export HTTP_PROXY=http://proxy.example.org:8888 # used by npm
$ export HTTPS_PROXY=https://proxy.example.org:8888 # used by npm
$ export IONIC_HTTP_PROXY=http://proxy.example.org:8888

For example:

$ HTTPS_PROXY=https://internal.proxy.com ionic start

Legacy Version

The old version of the CLI can be installed with the legacy tag:

npm install -g ionic@legacy

About

The Ionic Command Line Utility

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • TypeScript 93.5%
  • JavaScript 2.9%
  • CSS 2.7%
  • HTML 0.9%