@shipengine/connect
Version:
The official developer tooling for building ShipEngine connect apps
57 lines • 2.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const base_command_1 = tslib_1.__importDefault(require("../base-command"));
const login_1 = tslib_1.__importDefault(require("./login"));
const publish_app_1 = require("../core/publish-app");
const command_1 = require("@oclif/command");
const create_or_find_test_account_1 = require("../core/utils/create-or-find-test-account");
const app_loader_1 = require("../core/app-loader");
const unauthenticated_error_1 = require("../core/unauthenticated-error");
class Accounts extends base_command_1.default {
static description = 'Lists or creates testing accounts';
static examples = ['$ connect accounts'];
static flags = {
help: command_1.flags.help({
char: 'h',
description: 'Show help for the account command',
}),
debug: command_1.flags.boolean({
char: 'd',
description: 'Show network debugging information',
default: false,
hidden: true,
}),
};
async run() {
// When the -h flag is present the following line haults execution
const { flags } = this.parse(Accounts);
// Verify user is logged in
try {
await this.getCurrentUser(flags.debug);
}
catch (error) {
if (error instanceof unauthenticated_error_1.UnauthenticatedError) {
await login_1.default.run([]);
}
else {
return this.error(error, {
exit: 1,
});
}
}
const apiClient = await this.apiClient(flags.debug);
const pathToApp = process.cwd();
const app = await (0, app_loader_1.loadApp)(pathToApp);
const supportedCountries = (0, publish_app_1.getSupportedCountries)(app);
const platformApp = await apiClient.apps.findOrCreateApp({
appId: app.manifest.appId || app.providerId,
name: app.manifest.name,
type: app.deploymentType,
});
const accountInfo = await (0, create_or_find_test_account_1.createOrFindTestAccounts)(apiClient, platformApp, supportedCountries);
(0, publish_app_1.displayAccountInfo)(accountInfo);
}
}
exports.default = Accounts;
//# sourceMappingURL=accounts.js.map