ryuu
Version:
Domo App Dev Studio CLI, The main tool used to create, edit, and publish app designs to Domo
63 lines • 2.85 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const validator_1 = __importDefault(require("validator"));
const manifest_1 = require("../util/manifest");
const login_1 = require("../util/login");
const log_1 = require("../util/log");
module.exports = (program) => {
program
.command('owner <add|rm|ls> [user-emails...]')
.description('manage design owners')
.option('-i, --designId <id>', 'Specify design ID, otherwise it is retrieved from a manifest file')
.action((action, users, options) => {
let designId;
if (options.design_id) {
designId = options.design_id;
if (!validator_1.default.isUUID(designId))
return log_1.log.fail('The value specified for option -i is not a valid design ID', designId);
}
else {
const manifest = manifest_1.ManifestUtils.getManifest(program.opts().manifest);
if (!manifest)
return log_1.log.fail('No manifest found. Please supply design id using -i or change to a directory with a valid manifest file');
if (!manifest.id)
return log_1.log.fail('No manifest id. Please publish your design before attempting to add owners to it.');
designId = manifest.id;
}
new login_1.Login().getClient().then(client => {
switch (action) {
case 'add':
if (users) {
client
.addOwners(designId, users)
.then(() => log_1.log.ok('Owners added ' + users))
.catch(() => log_1.log.fail('Error adding owners'));
}
break;
case 'rm':
if (users) {
client
.removeOwners(designId, users)
.then(() => log_1.log.ok('Owners removed ' + users))
.catch(() => log_1.log.fail('Error removing owners'));
}
break;
case 'ls':
client
.getDesign(designId, { parts: 'owners' })
.then(designs => {
log_1.log.ok(`Owners for design ${designId}:`);
designs.owners.forEach(owner => {
console.log('\t' + owner.displayName);
});
})
.catch(() => log_1.log.fail('Error retrieving owners'));
break;
}
});
});
};
//# sourceMappingURL=owner.js.map