azure-cli
Version:
Microsoft Azure Cross Platform Command Line tool
185 lines (85 loc) • 8.1 kB
JavaScript
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ "use strict"; var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb; var __ = require("underscore");
var util = require("util");
var wrap = require("wordwrap").hard(0, 75);
var profile = require("../util/profile");
var tokenCache = require("../util/authentication/adalAuth").tokenCache;
var utils = require("../util/utils");
var $ = utils.getLocaleString;
exports.init = function(cli) {
var log = cli.output;
var account = cli.category("account").description($("Commands to manage your account information and publish settings"));
account.command("list").description($("List the imported subscriptions")).execute(function __1(options, _) { var subscriptions; var __frame = { name: "__1", line: 38 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
subscriptions = __.values(profile.current.subscriptions);
log.table(subscriptions, function(row, s) {
row.cell($("Name"), s.name);
row.cell($("Id"), s.id);
row.cell($("Current"), s.isDefault);
row.cell($("State"), (s.state || "n/a")); }); _(); }); });
account.command("show [subscriptionNameOrId]").description($("Show details about a subscription")).option("-s --subscriptionNameOrId <subscriptionNameOrId>", $("The subscription to show")).option("-d --details", $("Show extra information about the subscription")).execute(function __2(subscriptionNameOrId, options, _) { var subscriptions; var __frame = { name: "__2", line: 52 }; return __func(_, this, arguments, __2, 2, __frame, function __$__2() {
subscriptions = profile.current.getSubscription(subscriptionNameOrId, true);
cli.interaction.formatOutput(subscriptions, function(data) {
for (var i = 0; (i < data.length); i++) {
log.data($("Name :"), data[i].name);
log.data($("ID :"), data[i].id);
log.data($("State :"), (data[i].state || "n/a"));
log.data($("Tenant ID :"), data[i].tenantId);
log.data($("Is Default :"), data[i].isDefault);
log.data($("Environment :"), data[i].environment.name);
if (data[i].managementCertificate) {
log.data($("Has Certificate :"), "Yes"); }
else {
log.data($("Has Certificate :"), "No"); } ;
if (data[i].user) {
log.data($("Has Access Token :"), "Yes");
log.data($("User name :"), data[i].user.name); }
else {
log.data($("Has Access Token :"), "No"); } ;
if (options.details) {
log.data($("Registered ASM Providers :"), data[i].registeredProviders); } ;
log.data(""); }; }); _(); }); });
account.command("set <subscriptionNameOrId>").description($("Set the current subscription")).execute(function __3(subscriptionNameOrId, options, _) { var subscriptions, newSubscription; var __frame = { name: "__3", line: 88 }; return __func(_, this, arguments, __3, 2, __frame, function __$__3() {
subscriptions = profile.current.getSubscription(subscriptionNameOrId, true);
if ((subscriptions.length === 0)) {
return _(new Error(util.format($("Invalid subscription \"%s\""), subscriptionNameOrId))); } ;
newSubscription = subscriptions[0];
if ((subscriptions.length > 1)) {
log.warn(util.format($((("We found multiple subscriptions matching the name \"%s\". " + "We are setting the first subscription match, with id - \"%s\" as the current subscription. ") + "Provide the \"subscription-id\" to set a specific subscription.")), newSubscription.name, newSubscription.id)); } ;
profile.current.currentSubscription = newSubscription;
profile.current.save();
log.info(util.format($("Setting subscription to \"%s\" with id \"%s\"."), newSubscription.name, newSubscription.id));
log.info($("Changes saved"));
if ((cli.isArmMode() && newSubscription.wasCreatedFromPublishSettingsFile())) {
log.warn($((("Your current subscription was likely created from a publishsettings file " + "and will not work under arm mode. You can fix it by running either 'azure login' ") + "or 'azure accout set'"))); } ; _(); }); });
account.command("clear").description($("Remove a subscription or environment, or clear all of the stored account and environment info")).option("-s --subscription <subscriptionNameOrId>", $("Subscription name or id to remove")).option("-e --environment <environmentName>", $("Environment name to remove")).option("-q --quiet", $("quiet mode, do not ask for delete confirmation")).execute(function __4(options, _) { var matchSubscription, matchEnvironment, clearAll, shouldClear; var __frame = { name: "__4", line: 122 }; return __func(_, this, arguments, __4, 1, __frame, function __$__4() {
matchSubscription = function() { return false; };
matchEnvironment = function() { return false; };
clearAll = false; return (function __$__4(__then) {
if ((!options.subscription && !options.environment)) {
clearAll = true; return (function __$__4(_) {
var __1 = options.quiet; if (__1) { return _(null, __1); } ; return cli.interaction.confirm($("This will clear all account information. Are you sure? [y/n] "), __cb(_, __frame, 7, 59, _, true)); })(__cb(_, __frame, -121, 18, function ___(__0, __2) { shouldClear = __2;
if (!shouldClear) { return _(null); } ;
matchSubscription = function() { return true; };
matchEnvironment = function() { return true; }; __then(); }, true)); } else {
if (options.subscription) {
matchSubscription = function(s) {
return ((s.id === options.subscription) || utils.ignoreCaseEquals(s.name, options.subscription)); }; } ;
if (options.environment) {
matchEnvironment = function(e) {
return utils.ignoreCaseEquals(e.name, options.environment); }; } ; __then(); } ; })(function __$__4() {
__.values(profile.current.subscriptions).filter(matchSubscription).forEach(function(subscription) {
profile.current.deleteSubscription(subscription.id); });
__.values(profile.current.environments).filter(matchEnvironment).forEach(function(env) {
profile.current.deleteEnvironment(env.name); });
profile.current.save(); return (function __$__4(__then) {
if (clearAll) {
profile.clearAzureDir();
return tokenCache.clear(__cb(_, __frame, 41, 19, __then, true)); } else { __then(); } ; })(_); }); }); });
if (cli.isAsmMode()) {
account.command("import <file>").description($("Import a publishsettings file or certificate for your account")).option("--skipregister", $("skip registering resources")).execute(function __5(file, options, _) { var __frame = { name: "__5", line: 171 }; return __func(_, this, arguments, __5, 2, __frame, function __$__5() {
profile.current.importPublishSettings(file);
profile.current.save(); _(); }); });
account.command("download").description($("Launch a browser to download your publishsettings file")).option("-e, --environment <environment>", $("the publish settings download environment")).option("-r, --realm <realm>", $("the organization's realm, aka 'tenant'")).execute(function __6(options, _) { var url; var __frame = { name: "__6", line: 180 }; return __func(_, this, arguments, __6, 1, __frame, function __$__6() {
url = profile.current.getEnvironment(options.environment).getPublishingProfileUrl(options.realm);
return cli.interaction.launchBrowser(url, __cb(_, __frame, 2, 22, function __$__6() {
log.help($("Save the downloaded file, then execute the command"));
log.help($(" account import <file>")); _(); }, true)); }); }); } ;};