Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Commit

Permalink
added more debugging options
Browse files Browse the repository at this point in the history
  • Loading branch information
jerrymannel committed Sep 10, 2022
1 parent 65e4c45 commit 156b19d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
4 changes: 4 additions & 0 deletions dist/lib.cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const mainMenu = [
function validateCLIParams() {
return __awaiter(this, void 0, void 0, function* () {
let credentials = new types_1.Credentials();
credentials.logger = logger;
if (logger.level.toString() == "TRACE")
credentials.trace = true;
credentials.host = process.env.DS_BR_HOST;
if ((0, lib_misc_1.isNotAnAcceptableValue)(process.env.DS_BR_HOST)) {
logger.info("Env var DS_BR_HOST not set or is invalid.");
Expand All @@ -43,6 +46,7 @@ function validateCLIParams() {
global.host = credentials.host || "";
(0, lib_misc_1.printInfo)(`Host : ${credentials.host}`);
(0, lib_misc_1.printInfo)(`Username : ${credentials.username}`);
logger.trace(`Credentials : ${JSON.stringify(credentials)}`);
return credentials;
});
}
Expand Down
8 changes: 6 additions & 2 deletions dist/manager.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.del = exports.put = exports.post = exports.get = exports.getApps = exports.login = void 0;
const got_1 = __importDefault(require("got"));
const ds_sdk_1 = require("@appveen/ds-sdk");
const types_1 = require("@appveen/ds-sdk/dist/types");
const lib_misc_1 = require("./lib.misc");
var logger = global.logger;
var dataStack;
function login(config) {
return __awaiter(this, void 0, void 0, function* () {
logger.trace(config);
logger.trace(JSON.stringify(config));
try {
dataStack = yield (0, ds_sdk_1.authenticateByCredentials)(config);
(0, lib_misc_1.printInfo)("Logged into data.stack.");
Expand All @@ -29,14 +30,17 @@ function login(config) {
catch (e) {
(0, lib_misc_1.printError)("Unable to login to data.stack server");
logger.error(e);
logger.trace(e);
(0, lib_misc_1.killThySelf)(400);
}
});
}
exports.login = login;
function getApps() {
return __awaiter(this, void 0, void 0, function* () {
let apps = yield dataStack.ListApps();
let listOptions = new types_1.ListOptions();
listOptions.count = -1;
let apps = yield dataStack.ListApps(listOptions);
return apps.map(a => a.app._id).sort();
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"bin": "dist/app.js",
"homepage": "https://github.com/appveen/datastack-backup-restore#readme",
"dependencies": {
"@appveen/ds-sdk": "^2.3.0",
"@appveen/ds-sdk": "^2.3.2",
"commander": "^9.3.0",
"got": "^11.8.3",
"inquirer": "^8.2.1",
Expand Down
4 changes: 4 additions & 0 deletions src/lib.cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const mainMenu = [

export async function validateCLIParams(): Promise<Credentials> {
let credentials = new Credentials();
credentials.logger = logger;
if (logger.level.toString() == "TRACE") credentials.trace = true;
credentials.host = process.env.DS_BR_HOST;
if (isNotAnAcceptableValue(process.env.DS_BR_HOST)) {
logger.info("Env var DS_BR_HOST not set or is invalid.");
Expand All @@ -37,6 +39,8 @@ export async function validateCLIParams(): Promise<Credentials> {
printInfo(`Host : ${credentials.host}`);
printInfo(`Username : ${credentials.username}`);

logger.trace(`Credentials : ${JSON.stringify(credentials)}`);

return credentials;
}

Expand Down
9 changes: 6 additions & 3 deletions src/manager.api.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import got, { HTTPError } from "got";
import { authenticateByCredentials, DataStack } from "@appveen/ds-sdk";
import { Credentials } from "@appveen/ds-sdk/dist/types";
import { Credentials, ListOptions } from "@appveen/ds-sdk/dist/types";
import { killThySelf, printError, printInfo } from "./lib.misc";

var logger = global.logger;
var dataStack: DataStack;


export async function login(config: Credentials) {
logger.trace(config);
logger.trace(JSON.stringify(config));
try {
dataStack = await authenticateByCredentials(config);
printInfo("Logged into data.stack.");
global.dataStack = dataStack;
} catch (e) {
printError("Unable to login to data.stack server");
logger.error(e);
logger.trace(e);
killThySelf(400);
}
}

export async function getApps() {
let apps = await dataStack.ListApps();
let listOptions = new ListOptions();
listOptions.count = -1;
let apps = await dataStack.ListApps(listOptions);
return apps.map(a => a.app._id).sort();
}

Expand Down

0 comments on commit 156b19d

Please sign in to comment.