Skip to content

Commit 4d1f404

Browse files
author
Peter Collins
committed
Merge branch 'master' into 5-build
Conflicts: lib/ionic.js lib/ionic/build.js lib/ionic/platform.js lib/ionic/run.js lib/ionic/start.js lib/ionic/task.js package.json
2 parents 0cd395a + a44fd0f commit 4d1f404

14 files changed

Lines changed: 814 additions & 85 deletions

File tree

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# FUCK CRLF
2+
* text eol=lf

README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,44 @@
1-
ionic-cli
1+
Ionic-Cli
22
=========
33

4-
The Ionic Framework command line utility
4+
The Ionic Framework command line utility makes it easy to start, build, run, and emulate [Ionic](http://ionicframework.com/) apps. In the future, it will also have support for our mobile development services and tools that make Ionic even more powerful.
5+
6+
## Installing
7+
8+
```bash
9+
$ sudo npm install -g ionic
10+
```
11+
12+
## Starting an Ionic App
13+
14+
```bash
15+
$ ionic start myApp
16+
```
17+
18+
## Adding a platform target
19+
20+
```bash
21+
$ ionic platform ios android
22+
```
23+
24+
## Building your app
25+
26+
```bash
27+
$ ionic build ios
28+
```
29+
30+
## Emulating your app
31+
32+
```bash
33+
$ ionic emulate ios
34+
```
35+
36+
## Running your app
37+
38+
```bash
39+
$ ionic run ios
40+
```
41+
42+
Ionic uses Cordova underneath, so you can also substitute Cordova commands to prepare/build/emulate/run, or to add additional plugins.
43+
44+
Note: we occasionally anonymous usage statistics to the Ionic team to make the tool better.

bin/ionic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22

3+
34
'use strict';
45

56
process.title = 'ionic';

lib/ionic.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Copyright 2013 Drifty (http://drifty.com/)
1717
var IonicStartTask = require('./ionic/start').IonicStartTask,
1818
IonicPlatformTask = require('./ionic/platform').IonicPlatformTask,
1919
IonicRunTask = require('./ionic/run').IonicRunTask,
20+
IonicEmulateTask = require('./ionic/emulate.js').IonicEmulateTask;
2021
IonicBuildTask = require('./ionic/build').IonicBuildTask,
2122
IonicLoginTask = require('./ionic/login').IonicLoginTask,
2223
IonicUploadTask = require('./ionic/upload').IonicUploadTask,
@@ -32,6 +33,12 @@ var TASKS = [
3233
usage: 'appname',
3334
task: IonicStartTask
3435
},
36+
{
37+
title: 'emulate',
38+
name: 'emulate',
39+
usage: 'emulate',
40+
task: IonicEmulateTask
41+
},
3542
{
3643
title: 'run',
3744
name: 'run',
@@ -78,6 +85,7 @@ Ionic.prototype = {
7885
IONIC_DASH: 'http://virt/',
7986
IONIC_COOKIES: 'ionic.cookies',
8087
IONIC_CONFIG: 'ionic.config',
88+
IONIC_CONF: '.ionic',
8189
IONIC_API: 'api/v1/',
8290
CONFIG_DEFAULT: {
8391
name: '',
@@ -91,8 +99,7 @@ Ionic.prototype = {
9199
android_keystore_alias: '',
92100
android_keystore_password: '',
93101
android_key_password: ''
94-
},
95-
102+
},
96103
_tryBuildingTask: function() {
97104
if(argv._.length == 0) {
98105
return false;

lib/ionic/build.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
<<<<<<< HEAD
12
var argv = require('optimist').argv,
23
IonicTask = require('./task').IonicTask;
4+
=======
5+
var fs = require('fs'),
6+
os = require('os'),
7+
request = require('request'),
8+
ncp = require('ncp').ncp,
9+
path = require('path'),
10+
shelljs = require('shelljs/global'),
11+
unzip = require('unzip'),
12+
IonicTask = require('./task').IonicTask,
13+
IonicStats = require('./stats').IonicStats;
14+
>>>>>>> master
315

416
var IonicBuildTask = function() {
517
}
@@ -24,6 +36,8 @@ IonicBuildTask.prototype.run = function(ionic) {
2436
ionic.fail('No platforms specified, exiting.');
2537
}
2638

39+
IonicStats.t('build', { 'platform': platforms.join(',') });
40+
2741
for(var i = 0; i < platforms.length; i++) {
2842
var platform = platforms[i];
2943
console.log('Building platform', platform);

lib/ionic/config.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
var fs = require('fs'),
2+
path = require('path'),
3+
ionic = require('../ionic');
4+
5+
var home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
6+
7+
module.exports = {
8+
CONF_DIR: '.ionic',
9+
CONF_FILE: '.ionic/info.json',
10+
getConfig: function() {
11+
if(fs.existsSync(path.join(home, this.CONF_FILE))) {
12+
var data = JSON.parse(fs.readFileSync(path.join(home, this.CONF_FILE)));
13+
this.data = data;
14+
} else {
15+
this.create();
16+
}
17+
return this;
18+
},
19+
get: function(k) {
20+
return this.data[k];
21+
},
22+
set: function(k, v) {
23+
if(!this.data) {
24+
this.create();
25+
}
26+
this.data[k] = v;
27+
this.save();
28+
},
29+
save: function() {
30+
if(!this.data) { return; }
31+
32+
try {
33+
var dirPath = path.join(home, this.CONF_DIR);
34+
var p = path.join(home, this.CONF_FILE);
35+
36+
if(!fs.existsSync(dirPath)) {
37+
fs.mkdirSync(dirPath);
38+
}
39+
if(!fs.exists(p)) {
40+
fs.writeFileSync(p, JSON.stringify(this.data));
41+
}
42+
} catch(e) {
43+
console.error('Unable to save settings file:', e);
44+
}
45+
},
46+
create: function() {
47+
this.data = {};
48+
this.save();
49+
}
50+
};

lib/ionic/emulate.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
var fs = require('fs'),
2+
os = require('os'),
3+
request = require('request'),
4+
ncp = require('ncp').ncp,
5+
path = require('path'),
6+
shelljs = require('shelljs/global'),
7+
unzip = require('unzip'),
8+
IonicTask = require('./task').IonicTask,
9+
IonicStats = require('./stats').IonicStats;
10+
11+
var argv = require('optimist').argv;
12+
13+
var IonicEmulateTask = function() {
14+
}
15+
16+
IonicEmulateTask.HELP_LINE = 'Emulate an ionic project on a simulator or emulator.';
17+
18+
IonicEmulateTask.prototype = new IonicTask();
19+
20+
IonicEmulateTask.prototype._printUsage = function() {
21+
process.stderr.write('\nUsage: ionic emulate [platform]\n');
22+
}
23+
24+
IonicEmulateTask.prototype.run = function(ionic) {
25+
var patform;
26+
27+
if(argv._.length < 2) {
28+
IonicEmulateTask.prototype._printUsage();
29+
ionic.fail('No platforms specified, exiting.');
30+
}
31+
32+
var platforms = argv._.slice(1);
33+
34+
if(platforms.length < 1) {
35+
ionic.fail('No platforms specified, exiting.');
36+
}
37+
38+
IonicStats.t('emulate', { 'platform': platforms.join(',') });
39+
40+
for(var i = 0; i < platforms.length; i++) {
41+
platform = platforms[i];
42+
console.log('Emulating app on platform', platform);
43+
if(exec("cordova emulate " + platform).code !== 0) {
44+
ionic.fail('Unable to emulate app on platform ' + platform + '. Please see console for more info.');
45+
}
46+
}
47+
};
48+
49+
exports.IonicEmulateTask = IonicEmulateTask;

lib/ionic/platform.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
var argv = require('optimist').argv,
2-
IonicTask = require('./task').IonicTask;
1+
var fs = require('fs'),
2+
os = require('os'),
3+
argv = require('optimist').argv,
4+
request = require('request'),
5+
ncp = require('ncp').ncp,
6+
path = require('path'),
7+
shelljs = require('shelljs/global'),
8+
unzip = require('unzip'),
9+
IonicTask = require('./task').IonicTask,
10+
IonicStats = require('./stats').IonicStats;
311

412
var IonicPlatformTask = function() {
513
}
@@ -25,6 +33,8 @@ IonicPlatformTask.prototype.run = function(ionic) {
2533
ionic.fail('No platforms specified, exiting.');
2634
}
2735

36+
IonicStats.t('platform', { 'platform': platforms.join(',') });
37+
2838
for(var i = 0; i < platforms.length; i++) {
2939
var platform = platforms[i];
3040
console.log('Adding platform', platform);

lib/ionic/run.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
var argv = require('optimist').argv,
2-
IonicTask = require('./task').IonicTask;
1+
var fs = require('fs'),
2+
os = require('os'),
3+
argv = require('optimist').argv,
4+
request = require('request'),
5+
ncp = require('ncp').ncp,
6+
path = require('path'),
7+
shelljs = require('shelljs/global'),
8+
unzip = require('unzip'),
9+
IonicTask = require('./task').IonicTask,
10+
IonicStats = require('./stats').IonicStats;
311

412
var IonicRunTask = function() {
513
}
@@ -24,6 +32,8 @@ IonicRunTask.prototype.run = function(ionic) {
2432
ionic.fail('No platforms specified, exiting.');
2533
}
2634

35+
IonicStats.t('run', { 'platform': platforms.join(',') });
36+
2737
for(var i = 0; i < platforms.length; i++) {
2838
var platform = platforms[i];
2939
console.log('Running app on platform', platform);

lib/ionic/start.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ var fs = require('fs'),
77
unzip = require('unzip'),
88
argv = require('optimist').argv,
99
IonicTask = require('./task').IonicTask;
10+
IonicStats = require('./stats').IonicStats;
1011

1112
fs.mkdirParent = function(dirPath, mode, callback) {
1213
//Call the standard fs.mkdir
@@ -84,6 +85,8 @@ IonicStartTask.prototype._fetchAndWriteSeed = function() {
8485
!exec('cordova plugin add org.apache.cordova.statusbar')) {
8586
process.stderr.write('Unable to install one or more cordova plugins.\n');
8687
}
88+
89+
IonicStats.t('start', {});
8790
});
8891
readStream.pipe(writeStream);
8992
};

0 commit comments

Comments
 (0)