Skip to content

Commit 0b458e4

Browse files
mhartingtonjthoms1
authored andcommitted
docs(): update readme (#1481)
Update readme with more accurate information for recent Ionic V1 and V2 projects
1 parent d22c78e commit 0b458e4

File tree

1 file changed

+47
-148
lines changed

1 file changed

+47
-148
lines changed

README.md

Lines changed: 47 additions & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
[![Build status][appveyor-badge]][appveyor-badge-url]
33
[![npm][npm-badge]][npm-badge-url]
44

5-
Ionic-Cli
6-
=========
5+
# Ionic-Cli
76

8-
The Ionic Framework command line utility makes it easy to start, build, run, and emulate [Ionic](http://ionicframework.com/) apps. In addition, it comes with (optional!) integration with the [Ionic Cloud](http://ionic.io/), a set of mobile backend services perfect for Ionic apps.
7+
The Ionic Framework command line utility makes it easy to start, build, run, and emulate [Ionic](http://ionicframework.com/) apps. In addition, it comes with (optional!) integration with the [Ionic Cloud](http://ionic.io/), a set of mobile backend services perfect for Ionic apps.
98

109
Use the `ionic --help` command for more detailed task information.
1110

@@ -15,28 +14,47 @@ Use the `ionic --help` command for more detailed task information.
1514
$ npm install -g ionic
1615
```
1716

18-
*Note: For a global install of `-g ionic`, OSX/Linux users may need to prefix the command with `sudo` or can setup [proper file permissions on OSX for npm](http://www.johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/) to install without `sudo`. *
17+
*Note: For a global install of `-g ionic`, OSX/Linux users may need to prefix the command with `sudo` or can setup [proper file permissions on OSX for npm](http://www.johnpapa.net/how-to-use-npm-global-without-sudo-on-osx/) to install without `sudo`.*
18+
19+
20+
Minimal node requirements:
21+
22+
- NodeLTS or greater
23+
- NPM 3x
1924

20-
*Please ensure that you have npm 2.7+ installed. We are now depending on scoped npm packages which were not introduced until this version. This occurred around the time of NodeJS 0.12.2*
2125

2226

2327
## Starting an Ionic App
2428

29+
To start a Ionic 1x app, run:
30+
2531
```bash
2632
$ ionic start myapp [template]
2733
```
2834

29-
Starter templates can either come from a named template, a Github repo, a Codepen, or a local directory. A starter template is what becomes the `www` directory within the Cordova project.
35+
To start a Ionic 2 app, run:
36+
37+
```bash
38+
$ ionic start myapp [template] --v2
39+
```
40+
41+
Starter templates can either come from a named template, a Github repo, a Codepen, or a local directory. A starter template is what becomes the `www` directory for a V1 project, and a `src` directory for a V2 project
3042

31-
__Named template starters:__
43+
__Named V1 template starters:__
3244

3345
* [tabs](https://github.com/driftyco/ionic-starter-tabs) (Default)
3446
* [sidemenu](https://github.com/driftyco/ionic-starter-sidemenu)
3547
* [maps](https://github.com/driftyco/ionic-starter-maps)
3648
* [salesforce](https://github.com/driftyco/ionic-starter-salesforce)
37-
* [complex-list](https://github.com/driftyco/ionic-starter-complex-list)
3849
* [blank](https://github.com/driftyco/ionic-starter-blank)
3950

51+
__Named V2 template starters:__
52+
53+
* [tabs](https://github.com/driftyco/ionic2-starter-tabs) (Default)
54+
* [sidemenu](https://github.com/driftyco/ionic2-starter-sidemenu)
55+
* [blank](https://github.com/driftyco/ionic2-starter-blank)
56+
57+
4058
__Github Repo starters:__
4159

4260
* Any Github repo url, ex: [https://github.com/driftyco/ionic-starter-tabs](https://github.com/driftyco/ionic-starter-tabs)
@@ -62,7 +80,7 @@ __Command-line flags/options:__
6280
[--id|-i] ............ Package name set in the <widget id> config
6381
ex: com.mycompany.myapp
6482
[--no-cordova|-w] .... Do not create an app targeted for Cordova
65-
[--sass|-s] ........... Setup the project to use Sass CSS precompiling
83+
[--sass|-s] ........... Setup the project to use Sass CSS precompiling (V1 only)
6684
[--list|-l] .......... List starter templates available
6785

6886
[--io-app-id] ......... The Ionic.io app ID to use
@@ -75,7 +93,7 @@ $ ionic platform ios android
7593

7694
## Testing in a Browser
7795

78-
Use `ionic serve` to start a local development server for app dev and testing. This is useful for both desktop browser testing, and to test within a device browser which is connected to the same network. Additionally, this command starts LiveReload which is used to monitor changes in the file system. As soon as you save a file the browser is refreshed automatically. View [Using Sass](https://github.com/driftyco/ionic-cli/blob/master/README.md#using-sass) if you would also like to have `ionic serve` watch the project's Sass files.
96+
Use `ionic serve` to start a local development server for app dev and testing. Additionally, this command starts LiveReload which is used to monitor changes in the file system. As soon as you save a file the browser is refreshed automatically. View [Using Sass](https://github.com/driftyco/ionic-cli/blob/master/README.md#using-sass) if you would also like to have `ionic serve` watch the project's Sass files.
7997

8098
```bash
8199
$ ionic serve [options]
@@ -87,33 +105,6 @@ $ ionic serve [options]
87105
$ ionic build ios
88106
```
89107

90-
## Live Reload App During Development (beta)
91-
92-
The `run` or `emulate` command will deploy the app to the specified platform devices/emulators. You can also run __live reload__ on the specified platform device by adding the `--livereload` option. The live reload functionality is similar to `ionic serve`, but instead of developing and debugging an app using a standard browser, the compiled hybrid app itself is watching for any changes to its files and reloading the app when needed. This reduces the requirement to constantly rebuild the app for small changes. However, any changes to plugins will still require a full rebuild. For live reload to work, the dev machine and device must be on the same local network, and the device must support [web sockets](http://caniuse.com/websockets).
93-
94-
With live reload enabled, an app's console logs can also be printed to the terminal/command prompt by including the `--consolelogs` or `-c` option. Additionally, the development server's request logs can be printed out using `--serverlogs` or `-s` options.
95-
96-
__Command-line flags/options for `run` and `emulate`:__
97-
98-
[--livereload|-l] ....... Live Reload app dev files from the device (beta)
99-
[--consolelogs|-c] ...... Print app console logs to Ionic CLI (live reload req.)
100-
[--serverlogs|-s] ....... Print dev server logs to Ionic CLI (live reload req.)
101-
[--port|-p] ............. Dev server HTTP port (8100 default, live reload req.)
102-
[--livereload-port|-i] .. Live Reload port (35729 default, live reload req.)
103-
[--all|-a] .............. Specify to run on all addresses, 0.0.0.0, so you can view externally
104-
[--browser|-w] .......... Specifies the browser to use (safari, firefox, chrome)
105-
[--browseroption|-o] .... Specifies a path to open to (/#/tab/dash)
106-
[--debug|--release]
107-
108-
While the server is running for live reload, you can use the following commands within the CLI:
109-
110-
restart or r to restart the client app from the root
111-
goto or g and a url to have the app navigate to the given url
112-
consolelogs or c to enable/disable console log output
113-
serverlogs or s to enable/disable server log output
114-
quit or q to shutdown the server and exit
115-
116-
117108
## Emulating your app
118109

119110
Deploys the Ionic app on specified platform emulator. This is simply an alias for `run --emulator`.
@@ -196,26 +187,19 @@ When starting a new app and adding a platform `ionic platform add ios` - the def
196187

197188
## Crosswalk for Android
198189

199-
In v1.3.0 and later, you can now specify which browser to use in your Cordova Android projects. Currently we only support [Crosswalk](https://crosswalk-project.org/) and have plans to support more browsers later.
200-
201-
Execute `ionic browser add crosswalk` to add the Crosswalk browser to your Android project. By default, this will install the `12.41.296.5` version of Crosswalk.
190+
To install [Crosswalk](https://crosswalk-project.org/) for Android run:
202191

203-
If you'd like to specify a different version of Crosswalk, run `ionic browser list` to see which browsers are available and what versions. Then run `ionic browser add [email protected]`.
192+
```bash
193+
ionic plugin add cordova-plugin-crosswalk-webview --save
194+
```
204195

205196
All that is left is to run the project as normal - `ionic run android`.
206197

207-
If you'd like to build without Crosswalk for Android SDK 21 or later, do the following:
208-
209-
```
210-
ionic browser revert android
211-
ionic build android --release -- --minSdkVersion 21
212-
```
213-
214198
## Advanced serve options
215199

216200
__LiveReload__
217201

218-
By default, LiveReload will watch for changes in your `www/` directory,
202+
By default, for Ionic 1 projects, LiveReload will watch for changes in your `www/` directory,
219203
excluding `www/lib/`. To change this, you can specify a `watchPatterns`
220204
property in the `ionic.config.json` file located in your project root to watch
221205
(or not watch) for specific changes.
@@ -249,7 +233,7 @@ If you would like to disable gulp from running during serve, pass the `--nogulp`
249233

250234
Your gulpfile must be named gulpfile.js or Gulpfile.js, there is currently no support for typescript, babel or coffeescript gulp files in the 2.0 CLI
251235

252-
NOTE:
236+
NOTE For V1:
253237

254238
```bash
255239
$ ionic setup sass
@@ -325,16 +309,18 @@ __Command-line flags/options:__
325309

326310
## Using Ionic Labs
327311

328-
We've extended the serve command to open the new Lab UI that features iOS and Android side-by-side.
312+
We've extended the serve command to open the new Lab UI that features iOS, Android, and Windows side-by-side.
329313

330314
```bash
331315
$ ionic serve --lab
332316
```
333317

334-
If you've used the serve command before, you'll feel right at home with this one. Just like serve, it opens your app in a browser, but now it shows you what your app will look like on a phone, with both iOS and Android side by side.
318+
If you've used the serve command before, you'll feel right at home with this one. Just like serve, it opens your app in a browser, but now it shows you what your app will look like on a phone, with both iOS, Android, Windows side by side.
335319

336320
And of course, it supports Live Reload and all the other goodies we've added over the last couple of months.
337321

322+
NOTE: This does **not** emulate cordova or cordova plugins. So while the UI may feel like a native app, you'll still want to deploy to a device to test plugins.
323+
338324
## Serving an alternate document root
339325

340326
If you'd like to test your app in the browser and you use a folder other than the default of `www`, you can specify this folder in your `ionic.config.json` file.
@@ -356,17 +342,6 @@ It is also advised you specify the watch patterns for this document root as well
356342

357343
```
358344

359-
## Update Ionic lib
360-
361-
Update Ionic library files, which are found in the `www/lib/ionic` directory. If bower is being used
362-
by the project, this command will automatically run `bower update ionic`, otherwise this command updates
363-
the local static files from Ionic's CDN.
364-
365-
```bash
366-
$ ionic lib update
367-
```
368-
*Note: Using bower? This command does not update Ionic's dependencies. Run `bower update` to update Ionic and all of it's dependencies defined in `bower.json`.*
369-
370345
## Packaging an app (beta)
371346

372347
Using Ionic's service, you can compile and package your project into an app-store ready app without
@@ -403,16 +378,18 @@ PROXY=internal.proxy.com ionic start my_app
403378
```
404379

405380

406-
## Using Sass
381+
## Using Sass (V1 Only)
407382

408-
By default, starter projects are hooked up to Ionic's precompiled CSS file, which is found in the project's `www/lib/ionic/css` directory, and is linked to the app in the head of the root `index.html` file. However, Ionic projects can also be customized using [Sass](http://sass-lang.com/), which gives developers and designers "superpowers" in terms of creating and maintaining CSS. Below are two ways to setup Sass for your Ionic project (the `ionic setup sass` command simply does the manual steps for you). Once Sass has been setup for your Ionic project, then the `ionic serve` command will also watch for Sass changes.
383+
By default, V1 starter projects are hooked up to Ionic's precompiled CSS file, which is found in the project's `www/lib/ionic/css` directory, and is linked to the app in the head of the root `index.html` file. However, projects can also be customized using [Sass](http://sass-lang.com/), which gives developers and designers "superpowers" in terms of creating and maintaining CSS. Below are two ways to setup Sass for your Ionic project (the `ionic setup sass` command simply does the manual steps for you). Once Sass has been setup for your Ionic project, then the `ionic serve` command will also watch for Sass changes.
409384

410-
#### Setup Sass Automatically
385+
For V2 projects, there's nothing you need to do! Ionic 2 projects by default are setup with sass and come with all the build process enabled.
386+
387+
#### Setup Sass Automatically (V1)
411388

412389
ionic setup sass
413390

414391

415-
#### Setup Sass Manually
392+
#### Setup Sass Manually (V1)
416393

417394
1. Run `npm install` from the working directory of an Ionic project. This will install [gulp.js](http://gulpjs.com/) and a few handy tasks, such as [gulp-sass](https://www.npmjs.org/package/gulp-sass) and [gulp-minify-css](https://www.npmjs.org/package/gulp-minify-css).
418395
2. Remove `<link href="lib/ionic/css/ionic.css" rel="stylesheet">` from the `<head>` of the root `index.html` file.
@@ -476,16 +453,7 @@ Use the `ionic link <appId>` command to set your Ionic App ID to continue workin
476453

477454
Use the `ionic share <email>` command to have an email sent to another person to have them view the Ionic application you are using. Note: You must have an [Ionic Cloud](http://ionic.io/) account as well as the user you are sharing with.
478455

479-
# Ionic Docs
480-
481-
To get Ionic documentation from the Ionic CLI, try using the `ionic docs` command. The command will look up your currently used Ionic version and open the docs specific for that version. Ex: RC0, RC1, etc.
482-
483-
To view all docs, `ionic docs ls`.
484-
485-
To get help with a doc you may not remember, just type the name close enough: `ionic docs list` and you will be prompted for suggestions that may match.
486-
487-
488-
# Ionic Hooks
456+
# Ionic Hooks (V1)
489457

490458
Ionic provides some default hooks for you to use in your Cordova application. In versions prior to 1.3.18, these hooks were automatically installed via the `ionic platform` command.
491459

@@ -496,82 +464,13 @@ If you were a user who would still like to use those hooks, you can re-install t
496464
If you would like to remove these hooks yourself, use `ionic hooks remove` to get rid of them.
497465

498466

499-
# Ionic State
500-
501-
Ionic now provides a command to help you manage the state of your Ionic application. Previously Cordova hooks were used to save platforms and plugins to your `package.json` file.
502-
503-
Now when using `ionic platform add`, `ionic platform rm`, `ionic plugin add`, or `ionic plugin rm`, the state command will automatically be used to save the platform or plugin state to the `package.json` file.
504-
505-
If you would like to avoid saving plugins or platforms to the `package.json` file - pass in the `--nosave` option. (`ionic plugin add org.apache.cordova.file --nosave`).
506-
507-
Your package.json file might look something like the following:
508-
509-
```json
510-
"cordovaPlatforms": [
511-
"ios",
512-
{
513-
"android": {
514-
"id": "android",
515-
"locator": "https://github.com/apache/cordova-android.git"
516-
}
517-
}
518-
],
519-
"cordovaPlugins": [
520-
"org.apache.cordova.device",
521-
"org.apache.cordova.console",
522-
"com.ionic.keyboard",
523-
"org.apache.cordova.splashscreen",
524-
{
525-
"locator": "https://github.com/MobileChromeApps/cordova-crosswalk-engine.git",
526-
"id": "org.cordova.croswalk"
527-
},
528-
{
529-
"locator": "/path/to/cloned/phonegap-facebook-plugin",
530-
"id": "",
531-
"variables": {
532-
"APP_ID": "some_id",
533-
"APP_NAME": "some_name"
534-
}
535-
}
536-
]
537-
```
538-
539-
## ionic state save
540-
541-
The `ionic state save` command does some lookup in your platforms and plugins to save the current state of your cordova application.
542-
543-
First it looks in your platforms folder to see which platforms are installed, and saves the name and version in your `package.json` file under the `cordovaPlatforms` attribute.
544-
545-
Second it looks at your plugins `fetch.json` file to save the plugins installed both from the Cordova registry, locally installed plugins, as well as remote plugins from github or a remote HTTP url.
546-
547-
## ionic state restore
548-
549-
The `ionic state restore` command looks at the `cordovaPlugins` and `cordovaPlatforms` attributes in your `package.json` file to restore your application with those platforms and plugins.
550-
551-
In the package.json file, `cordovaPlugins` will be stored as just their `ID` if they are installed from the Cordova registry. However, if they are local or remote, they will be stored as an object with those properties. Also to note, variables are stored for plugins with variables like the Facebook connect plugin.
552-
553-
The `cordovaPlatforms` follow the same convention of either an `ID` for the platform name, if they are local or remote, they will be stored as an object with those properties.
554-
555-
If you'd like, you can populate the `cordovaPlugins` and `cordovaPlatforms` by hand, then use the `ionic state restore` command to get your app ready to go.
556-
557-
## ionic state clear
558-
559-
The `ionic state clear` method will clear out your platforms and plugins directories, as well as removing the `cordovaPlugins` and `cordovaPlaforms` attributes in your `package.json` file.
560-
561-
## ionic state reset
562-
563-
The `ionic state reset` method will first remove your platforms and plugins folders. Then it will look at your `package.json` file to re-install the platforms and plugins as specified there.
564-
565-
This command can be helpful for you to reinstall your plugins and platforms to get a fresh start.
566-
567-
568467
# Ionic CLI 2.0
569468

570469
## Ionic Generators
571470

572-
First class support has come to the Ionic CLI to scaffold and generate Ionic and Angular 2 components. To use this feature, first install the V2 Ionic CLI: `npm install ionic@alpha` and start an app.
471+
First class support has come to the Ionic CLI to scaffold and generate Ionic and Angular 2 components.
573472

574-
Once in the app folder, use the `generate` command (alias: `g`).
473+
From your app directory, use the `generate` command (alias: `g`).
575474

576475
Usage:
577476
* `ionic generate page About` - Generate a page named About with HTML, JavaScript, and Sass named `about`.

0 commit comments

Comments
 (0)