-
Notifications
You must be signed in to change notification settings - Fork 0
/
up_actual.js
79 lines (59 loc) · 2.64 KB
/
up_actual.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
const sync = require('./sync')
const nconf = require('nconf')
const fsExtra = require('fs-extra');
const configure = require('./configure');
const configFile = process.env.configFile || './config.json';
const USE_NODE_CRON = process.env.USE_NODE_CRON;
console.log("Config File Location: ", configFile)
nconf.argv().env().file({ file: configFile })
let actualInstance
async function main() {
let token = nconf.get('UP:token')
let budgetId = nconf.get('actual:budgetId')
let budgetEncryption = nconf.get('actual:budgetEncryption') || ''
let serverUrl = nconf.get('actual:serverUrl') || ''
let serverPassword = nconf.get('actual:serverPassword') || ''
let sendNotes = nconf.get('actual:sendNotes') || ''
let serverValidated = nconf.get('actual:serverValidated') || ''
let linkedAccounts = nconf.get('linkedAccounts') || []
let webUI = nconf.get('webUI')
const setupRequired = !!nconf.get('setup') || !token || !budgetId || !serverUrl || !serverPassword || !serverValidated
const linkRequired = setupRequired || !!nconf.get('link') || !linkedAccounts
if (webUI) {
const webUIService = require('./index')
}
if (setupRequired) {
console.log('Setup required. Either provide a config.json file or set webUI=true and complete configuration')
// const initialSetup = await configure.initialSetup(token, budgetId, budgetEncryption, serverUrl, serverPassword)
// token = initialSetup.token
// budgetId = initialSetup.budgetId
// budgetEncryption = initialSetup.budgetEncryption
// serverUrl = initialSetup.serverUrl
// serverPassword = initialSetup.serverPassword
// sendNotes = initialSetup.sendNotes
// nconf.set('UP:token', token)
// nconf.set('actual:budgetId', budgetId)
// nconf.set('actual:budgetEncryption', budgetEncryption)
// nconf.set('actual:serverUrl', serverUrl)
// nconf.set('actual:serverPassword', serverPassword)
// nconf.set('actual:sendNotes', sendNotes)
// await nconf.save()
// nconf.set('actual:serverValidated', 'yes');
// await nconf.save()
}
if (linkRequired) {
console.log('Account linking required. Either add these to the config.json file or set webUI=true and complete linking')
// actualConfig = {
// budgetId: budgetId,
// budgetEncryption: budgetEncryption,
// serverUrl: serverUrl,
// serverPassword: serverPassword
// }
// if (!actualInstance) {
// actualInstance = await configure.initialize(actualConfig);
// }
// linkedAccounts = await configure.accountSetup(token, actualInstance, linkedAccounts, linkRequired)
// nconf.set('linkedAccounts', linkedAccounts)
// nconf.save()
}
}