forked from ionic-team/ionic-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.js
More file actions
101 lines (87 loc) · 2.54 KB
/
state.js
File metadata and controls
101 lines (87 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// "cordovaPlatforms": [
// "ios",
// {
// "android": {
// "id": "android",
// "locator": "https://github.com/apache/cordova-android.git"
// }
// }
// ],
// "cordovaPlugins": [
// "org.apache.cordova.device",
// "org.apache.cordova.console",
// "com.ionic.keyboard",
// "org.apache.cordova.splashscreen",
// {
// "locator": "https://github.com/MobileChromeApps/cordova-crosswalk-engine.git",
// "id": "org.cordova.croswalk"
// },
// {
// "locator": "/path/to/cloned/phonegap-facebook-plugin",
// "id": "",
// "variables": {
// "APP_ID": "some_id",
// "APP_NAME": "some_name"
// }
// }
// ]
var fs = require('fs'),
path = require('path'),
// argv = require('optimist').boolean(['plugins', 'platforms']).argv,
Q = require('q'),
shelljs = require('shelljs'),
Task = require('./task').Task,
IonicStats = require('./stats').IonicStats,
_ = require('underscore'),
IonicProject = require('./project'),
IonicAppLib = require('ionic-app-lib'),
State = IonicAppLib.state,
Utils = IonicAppLib.utils,
IonicInfo = IonicAppLib.info;
// var State = module.exports;
shelljs.config.silent = true;
var IonicTask = function() {};
IonicTask.prototype = new Task();
IonicTask.prototype.run = function run(ionic, argv) {
var self = this,
project,
stats,
projectPath,
options = { platforms: true, plugins: true };
this.ionic = ionic;
try {
projectPath = path.resolve('ionic.project');
stats = fs.statSync(projectPath);
} catch (ex) {
this.ionic.fail('You cannot run any state commands on a project that is not an Ionic project.\nTry adding an ionic.project file or running ionic start to get an application to save or restore');
return;
}
try {
project = IonicProject.load();
} catch (ex) {
this.ionic.fail(ex.message);
return;
}
//If either plugin or platforms is specified, set it to that value.
if (argv.platforms || argv.plugins) {
options = { platforms: argv.platforms, plugins: argv.plugins };
}
switch (argv._[1]) {
case 'save':
State.saveState(process.cwd(), options);
break;
case 'restore':
State.restoreState(process.cwd(), options);
break;
case 'reset':
State.resetState(process.cwd(), options);
break;
case 'clear':
State.clearState(process.cwd(), options);
break;
default:
console.log('Please specify a command [ save | restore | reset | clear ] for the state command.'.red.bold);
}
IonicStats.t();
};
exports.IonicTask = IonicTask;