This repository has been archived by the owner on Jun 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
executable file
·130 lines (112 loc) · 3.28 KB
/
index.js
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env node
const cli = require('commander')
const pkg = require('./package.json')
const cfg = require('./lib/config')
const core = require('./core')
cli.version(pkg.version).usage('<command> [option] <addon ...>')
cli
.command('add <addons...>')
.description('install one or more addons locally')
.alias('install')
.alias('get')
.option('--anyway', 'install latest addon release for _classic_ mode anyway')
.action((aa, cmd) => {
cfg.anyway(cmd.anyway)
core.add(aa)
})
cli
.command('rm <addon...>')
.description('remove addons from local installation')
.alias('delete')
.alias('uninstall')
.alias('remove')
.alias('del')
.action(key => core.rm(key))
cli
.command('search <text>')
.description('search addons whose name contain <text>')
.option(
'--anyway',
'search for latest addon release for _classic_ mode anyway'
)
.action((text, cmd) => {
cfg.anyway(cmd.anyway)
core.search(text)
})
cli
.command('ls')
.description('list all installed addons')
.option('-l, --long', 'show detailed addon information')
.option('-t, --time', 'sort by updated time')
.alias('list')
.action(core.ls)
cli
.command('info <addon>')
.description(
'show info of an addon, the addon does not have to be an installed locally'
)
.option(
'--anyway',
'show info of latest addon release for _classic_ mode anyway'
)
.action((ad, cmd) => {
cfg.anyway(cmd.anyway)
core.info(ad)
})
cli
.command('update')
.description('update all installed addons')
.option('--anyway', 'update latest addon release for _classic_ mode anyway')
.option(
'--db',
'for update addon database, no addon will be updated if this option is specified'
)
.action(cmd => {
cfg.anyway(cmd.anyway)
core.update(cli.args.length > 1 ? cli.args.slice(0, -1) : null, cmd)
})
cli
.command('import')
.description('import local addons')
.action(() => core.pickup())
cli
.command('pin <addon...>')
.description("pin an addon to it's current version, prevent it from updating")
.action(key => core.pin(key, 1))
cli
.command('unpin <addon...>')
.description("unpin an addon, allow it to be updated")
.action(key => core.pin(key, 0))
cli
.command('switch')
.alias('sw')
.description('switch mode between retail and classic')
.option('--ptr', 'switch mode to: retail PTR')
.option('--beta', 'switch mode to: retail BETA')
.option('--retail', 'switch mode to: retail formal')
.option('--retail-ptr', 'switch mode to: retail PTR')
.option('--retail-beta', 'switch mode to: retail BETA')
.option('--classic', 'switch mode to: classic formal')
.option('--classic-tbc', 'switch mode to: classic TBC')
.option('--classic-ptr', 'switch mode to: classic PTR')
.option('--classic-beta', 'switch mode to: classic BETA')
.action(core.switch)
cli
.command('restore [repo]')
.description(
'restore addons from github repo, only <org/repo> is required, not the full URL. (e.g. antiwinter/wowui)'
)
.option(
'-f, --full',
'not only restore addons, but also restore addons settings'
)
.action(repo => core.restore(repo))
cli.on('command:*', () => {
cli.help()
})
if (process.argv.length < 3) return cli.help()
// do the job
if (!cfg.checkPath()) return
core.checkUpdate(() => {
cli.parse(process.argv)
})