-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·25 lines (23 loc) · 809 Bytes
/
cli.js
File metadata and controls
executable file
·25 lines (23 loc) · 809 Bytes
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
#! /usr/bin/env node
const inquirer = require("inquirer");
const { initLogin } = require("./services/login");
const { getAllShops } = require("./services/shops");
const { prompedSelectShop } = require("./services/prompt");
const { initDashboard } = require("./services/dashboard");
let configs = {};
const run = async () => {
try {
configs = await initLogin();
if (!configs) throw new Error("Sorry, cant verify. Try again later.");
console.log("Congrats! you are successfully login to RedX");
const shops = await getAllShops(configs);
const selectedShopName = await prompedSelectShop(shops);
configs.selectedShopId = shops.find(
(shop) => shop.SHOP_NAME === selectedShopName
).ID;
await initDashboard(configs);
} catch (err) {
console.error(err);
}
};
run();