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
73 lines (65 loc) · 1.94 KB
/
state.js
File metadata and controls
73 lines (65 loc) · 1.94 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
'use strict';
var extend = require('../utils/extend');
var shelljs = require('shelljs');
var IonicAppLib = require('ionic-app-lib');
var IonicProject = IonicAppLib.project;
var State = IonicAppLib.state;
var log = IonicAppLib.logging.logger;
var appLibUtils = IonicAppLib.utils;
shelljs.config.silent = true;
var settings = {
title: 'state',
name: 'state',
summary: 'Saves or restores state of your Ionic Application using the package.json file',
args: {
'<COMMAND>': '[ save | restore | clear | reset ]'
},
options: {
save: 'Save the platforms and plugins into package.json',
restore: 'Restore the platforms and plugins from package.json',
clear: 'Clear the package.json of cordovaPlugins and cordovaPlatforms, ' +
'as well as clear out the platforms and plugins folders',
reset: 'Clear out the platforms and plugins directories, and reinstall plugins and platforms',
'--plugins': {
title: 'Only do operations with plugins',
boolean: true
},
'--platforms': {
title: 'Only do operations with platforms',
boolean: true
}
},
isProjectTask: true
};
function run(ionic, argv) {
var options = { platforms: true, plugins: true };
try {
IonicProject.load();
} catch (ex) {
appLibUtils.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:
log.error('Please specify a command [ save | restore | reset | clear ] for the state command.');
}
}
module.exports = extend(settings, {
run: run
});