-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (24 loc) · 921 Bytes
/
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
const envPaths = require("env-paths")
const fs = require("fs")
const { setup } = require("./utils/setup")
const { manage } = require("./utils/manage")
const axios = require("axios").default;
// TODO: Wrap this all in a main function
console.clear()
axios.defaults.baseURL = 'https://vps.oxide.host';
// ok shutup this is scuffed and i could have made it 10x better. cry.
if (!fs.existsSync(envPaths("oxide-cli", { suffix: "" }).config) || !fs.existsSync(envPaths("oxide-cli", { suffix: "" }).config + "/config.json")) {
fs.mkdirSync(envPaths("oxide-cli", { suffix: "" }).config, {
recursive: true,
});
setup()
} else {
const configRaw = fs.readFileSync(envPaths("oxide-cli", { suffix: "" }).config + "/config.json", { encoding:'utf8', flag:'r' })
const config = JSON.parse(configRaw)
axios.defaults.params = {
api: "json",
apikey: config.key,
apipass: config.pass
}
manage()
}