ryuu
Version:
Domo App Dev Studio CLI, The main tool used to create, edit, and publish app designs to Domo
60 lines • 2.83 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var validator_1 = require("validator");
var manifest_1 = require("../util/manifest");
var login_1 = require("../util/login");
var log_1 = require("../util/log");
module.exports = function (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(function (action, users, options) {
var 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 {
var 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(function (client) {
switch (action) {
case 'add':
if (users) {
client
.addOwners(designId, users)
.then(function (res) { return log_1.log.ok('Owners added ' + users); })
.catch(function (e) { return log_1.log.fail('Error adding owners'); });
}
break;
case 'rm':
if (users) {
client
.removeOwners(designId, users)
.then(function () { return log_1.log.ok('Owners removed ' + users); })
.catch(function (e) { return log_1.log.fail('Error removing owners'); });
}
break;
case 'ls':
client
.getDesign(designId, { parts: 'owners' })
.then(function (designs) {
log_1.log.ok("Owners for design ".concat(designId, ":"));
designs.owners.forEach(function (owner) {
console.log('\t' + owner.displayName);
});
})
.catch(function () { return log_1.log.fail('Error retrieving owners'); });
break;
}
});
});
};
//# sourceMappingURL=owner.js.map