-
Notifications
You must be signed in to change notification settings - Fork 0
/
jscrates.js
63 lines (52 loc) · 1.82 KB
/
jscrates.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
#!/usr/bin/env node
import Configstore from 'configstore'
import checkOnlineStatus from 'is-online'
import BaseCommand from './lib/base-command.js'
import { CONFIG_FILE } from './lib/constants.js'
import unloadPackages from './actions/packages/unload.js'
import publishPackage from './actions/packages/publish.js'
import login from './actions/auth/login.js'
import register from './actions/auth/register.js'
import logout from './actions/auth/logout.js'
async function jscratesApp() {
const isOnline = await checkOnlineStatus()
const configStore = new Configstore(CONFIG_FILE)
const program = new BaseCommand({
isOnline,
isAuthed: configStore.has('auth.token'),
})
program
.name('jscrates')
.description(`Welcome to JSCrates 📦, yet another package manager for Node`)
.version('v2.6.3', '-v, --version', 'Display installed version of JSCrates')
program
.command('login')
.description('Login to JSCrates ecosystem')
.action(login(configStore))
program
.command('register')
.description('Register on the JSCrates ecosystem')
.action(register(configStore))
program
.command('logout')
.description('Logout from your JSCrates account')
.action(logout(configStore))
program
.command('unload')
.description('🔽 Download package(s) from the JSCrates registry')
.argument('<packages...>', 'List of packages delimited by a space')
.action(unloadPackages)
.addHelpText(
'after',
'\nExamples:\n jscrates unload bodmas' +
'\n jscrates unload [email protected]' +
'\n jscrates unload binary-search merge-sort [email protected]'
)
.aliases(['u'])
program
.command('publish')
.description(`Publish your package to JSCrates repository.`)
.action(publishPackage)
await program.parseAsync(process.argv)
}
jscratesApp()