@shipengine/connect
Version:
The official developer tooling for building ShipEngine connect apps
28 lines • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const ApiKeyStore = tslib_1.__importStar(require("./core/utils/api-key-store"));
const api_client_1 = tslib_1.__importDefault(require("./core/api-client"));
const fs_1 = tslib_1.__importDefault(require("fs"));
const path_1 = tslib_1.__importDefault(require("path"));
const command_1 = require("@oclif/command");
const pjson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(__dirname, '..', 'package.json'), 'utf8'));
class BaseCommand extends command_1.Command {
base = `${pjson.name}@${pjson.version}`;
async apiClient(debug = false) {
const apiKey = await ApiKeyStore.get();
return new api_client_1.default(apiKey, debug);
}
/**
* Get the current user logged into the CLI
* @returns {Promise<AppUser>} A promise w/ the user object
*/
async getCurrentUser(debug = false) {
const apiKey = await ApiKeyStore.get();
const apiClient = new api_client_1.default(apiKey, debug);
const user = await apiClient.users.getCurrent();
return user;
}
}
exports.default = BaseCommand;
//# sourceMappingURL=base-command.js.map