-
-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathcli.ts
More file actions
executable file
·80 lines (74 loc) · 2.33 KB
/
Copy pathcli.ts
File metadata and controls
executable file
·80 lines (74 loc) · 2.33 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
#!/usr/bin/env node
import prompts from 'prompts'
const chalk = require('chalk')
import { updateConfig, readConfig, getConfigSource } from '../common/config'
import plaid from '../integrations/plaid/setup'
import google from '../integrations/google/setup'
import csvImport from '../integrations/csv-import/setup'
import csvExport from '../integrations/csv-export/setup'
import accountSetup from '../integrations/plaid/accountSetup'
import fetch from './fetch'
import migrate from './migrate'
import { logError } from '../common/logging'
;(async function() {
const logo = [
'\n',
' %',
' %%',
' %%%%%',
' %%%%%%%%',
' %%%%%%%%%%',
' %%%%%%%%%%%%',
' %%%% %%%%%%%%',
' %%% %%%%%%',
' %% %%%%%%',
' % %%%',
' %%%',
' %%',
' %',
'\n'
]
logo.forEach(line => {
console.log(chalk.green(line))
})
console.log(' M I N T A B L E\n')
const commands = {
migrate: migrate,
fetch: fetch,
'plaid-setup': plaid,
'account-setup': accountSetup,
'google-setup': google,
'csv-import-setup': csvImport,
'csv-export-setup': csvExport
}
const arg = process.argv[2]
if (arg == 'setup') {
const configSource = getConfigSource()
if (readConfig(configSource, true)) {
const overwrite = await prompts([
{
type: 'confirm',
name: 'confirm',
message: 'Config already exists. Do you to overwrite it?',
initial: false
}
])
if (overwrite.confirm === false) {
logError('Config update cancelled by user.')
}
}
await updateConfig(config => config, true)
await plaid()
await google()
await accountSetup()
} else if (commands.hasOwnProperty(arg)) {
commands[arg]()
} else {
console.log(`\nmintable v${require('../../package.json').version}\n`)
console.log('\nusage: mintable <command>\n')
console.log('available commands:')
Object.keys(commands)
.concat(['setup'])
.forEach(command => console.log(`\t${command}`))
}
})()