UNPKG

azure-cli

Version:

Microsoft Azure Cross Platform Command Line tool

929 lines (454 loc) 44.4 kB
/*** Generated by streamline 0.10.17 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename, false),__func=__rt.__func,__cb=__rt.__cb,__catch=__rt.__catch,__tryCatch=__rt.__tryCatch; var async = require("async"); var util = require("util"); var profile = require("../../util/profile"); var utils = require("../../util/utils"); var cacheUtils = require("../../util/cacheUtils"); var kuduscript = require("kuduscript"); var WebsitesClient = require("./websites/websitesclient"); var linkedRevisionControl = require("../../util/git/linkedrevisioncontrol"); var validation = require("../../util/validation"); var $ = utils.getLocaleString; exports.init = function(cli) { var log = cli.output; var site = cli.category("site").description($("Commands to manage your Web Sites")); var getSiteLocation = function(locations, site) { var webspace = locations.filter(function(l) { return utils.ignoreCaseEquals(l.name, site.webSpace); })[0]; if (webspace) { return webspace.geoRegion; } ; return site.webSpace; }; site.command("list [name]").description($("List your web sites")).option("-s, --subscription <id>", $("the subscription id")).execute(function __1(name, options, _) { var context, sites; var __frame = { name: "__1", line: 55 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() { context = { subscription: profile.current.getSubscription(options.subscription).id }; context.skipCache = true; return ensureSpaces(context, __cb(_, __frame, 6, 10, function __$__1() { return site.doSitesGet(context, __cb(_, __frame, 7, 27, function ___(__0, __1) { sites = __1; if (name) { sites = sites.filter(function(s) { var currentSiteName = WebsitesClient.parseSiteName(s.name); return utils.ignoreCaseEquals(currentSiteName.name, name); }); } ; cli.interaction.formatOutput(sites, function(data) { if ((data.length > 0)) { log.table(data, function(row, item) { var parsedName = WebsitesClient.parseSiteName(item.name); row.cell($("Name"), parsedName.name); row.cell($("Slot"), (parsedName.slot ? parsedName.slot : "")); row.cell($("Status"), item.state); row.cell($("Location"), getSiteLocation(context.spaces, item)); row.cell($("SKU"), item.sku); row.cell($("URL"), item.hostNames); }); } else { log.info($("No sites created yet. You can create new sites using \"azure site create\" or through the portal")); } ; }); _(); }, true)); }, true)); }); }); site.command("set [name]").description($("Set configuration options for your web site [name]")).option("--slot <slot>", $("the name of the slot")).option("--net-version <net-version>", $("the .NET version. Valid options are v3.5 and v4.5")).option("--php-version <php-version>", $("the PHP version. Valid options are off, v5.4, v5.5 and v5.6")).option("--platform <platform>", $("the platform. Valid options are x86 and x64")).option("-w, --web-socket", $("use this flag to enable web sockets")).option("-W, --disable-web-socket", $("use this flag to disable web sockets")).option("-r, --remote-debugging", $("use this flag to enable remote debugging")).option("-R, --disable-remote-debugging", $("use this flag to disable remote debugging")).option("-d, --remote-debugging-version <remote-debugging-version>", $("the version of remote debugging. It's either VS2012 or VS2013. This parameter is only valid when remote debugging is on.")).option("-m, --managed-pipeline-mode <managed-pipeline-mode>", $("the mode for managed pipeline. valid values are Classic and Integrated.")).option("-s, --subscription <id>", $("the subscription id")).execute(function __2(name, options, _) { var parsedSiteName, context, siteConfigurations; var __frame = { name: "__2", line: 101 }; return __func(_, this, arguments, __2, 2, __frame, function __$__2() { parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name, slot: (options.slot ? options.slot : parsedSiteName.slot) } }; if (options.netVersion) { validation.isValidEnumValue(options.netVersion, ["3.5","4.5",]); } ; if (options.phpVersion) { validation.isValidEnumValue(options.phpVersion, ["off","5.4","5.5","5.6",]); } ; if (options.platform) { validation.isValidEnumValue(options.platform, ["x86","x64",]); } ; if ((options.remoteDebuggingVersion && !options.remoteDebugging)) { return _(new Error($("remote-debugging-version can only be set if remote-debugging is also used"))); } ; return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 26, 11, function __$__2() { siteConfigurations = { }; if (options.netVersion) { siteConfigurations.netFrameworkVersion = ((options.netVersion === "3.5") ? "v2.0" : "v4.0"); } ; if (options.phpVersion) { if ((options.phpVersion.toLowerCase() === "off")) { options.phpVersion = " "; } ; siteConfigurations.phpVersion = options.phpVersion; } ; if (options.platform) { siteConfigurations.use32BitWorkerProcess = (((options.platform === "x86")) ? "true" : "false"); } ; if ((options.webSocket || options.disableWebSocket)) { siteConfigurations.webSocketsEnabled = ((options.webSocket === true)).toString(); } ; if ((options.remoteDebugging || options.disableRemoteDebugging)) { siteConfigurations.remoteDebuggingEnabled = ((options.remoteDebugging === true)).toString(); } ; if (options.remoteDebuggingVersion) { validation.isValidEnumValue(options.remoteDebuggingVersion, ["VS2012","VS2013",]); siteConfigurations.remoteDebuggingVersion = ((options.remoteDebuggingVersion.toLowerCase() === "vs2012") ? "VS2012" : "VS2013"); } ; if (options.managedPipelineMode) { validation.isValidEnumValue(options.managedPipelineMode, ["Integrated","Classic",]); siteConfigurations.managedPipelineMode = ((options.managedPipelineMode.toLowerCase() === "integrated") ? "Integrated" : "Classic"); } ; if ((Object.getOwnPropertyNames(siteConfigurations) === 0)) { return _(new Error($("Command needs to perform at least one configuration change"))); } ; return site.doSiteConfigPUT(siteConfigurations, context, __cb(_, __frame, 67, 11, function __$__2() { _(); }, true)); }, true)); }); }); var deploymentScriptCommand = site.command("deploymentscript"); kuduscript.addDeploymentScriptOptions(deploymentScriptCommand); deploymentScriptCommand.execute(function __3(name, options, _) { var option; var __frame = { name: "__3", line: 174 }; return __func(_, this, arguments, __3, 2, __frame, function __$__3() { for (option in deploymentScriptCommand.optionValues) { deploymentScriptCommand[option] = deploymentScriptCommand.optionValues[option]; }; return kuduscript.deploymentScriptExecute(name, deploymentScriptCommand, log, function() { cli.interaction.confirm.apply(cli.interaction, arguments); }, __cb(_, __frame, 5, 15, function __$__3() { _(); }, true)); }); }); site.command("create [name]").description($("Create a web site")).option("--location <location>", $("the geographic region to create the website")).option("--hostname <hostname>", $("the custom host name to use")).option("--slot <slot>", $("the name of the slot")).option("--git", $("Configure git on web site and local folder")).option("--gitusername <gitusername>", $("the publishing username for git")).option("--github", $("Configure github on web site and local folder")).option("--githubusername <username>", $("the github username")).option("--githubpassword <password>", $("the github password")).option("--githubrepository <repository>", $("the github repository full name (i.e. user/repository)")).option("-s, --subscription <id>", $("the subscription id")).execute(function __4(nameArg, options, _) { var context, websiteClient; function promptForSiteName(_) { var __frame = { name: "promptForSiteName", line: 272 }; return __func(_, this, arguments, promptForSiteName, 0, __frame, function __$promptForSiteName() { log.silly("promptForSiteName"); return (function __$promptForSiteName(__then) { if ((context.site.name === undefined)) { log.help($("Need a site name")); return cli.interaction.prompt($("Name: "), __cb(_, __frame, 4, 50, function ___(__0, __1) { context.site.name = __1; __then(); }, true)); } else { __then(); } ; })(_); }); }; function determineIfSiteAndSlotExists(_) { var sites, siteHits, displayNameMatches, slotHits, displaySlotNameMatches; var __frame = { name: "determineIfSiteAndSlotExists", line: 280 }; return __func(_, this, arguments, determineIfSiteAndSlotExists, 0, __frame, function __$determineIfSiteAndSlotExists() { log.silly("determineIfSiteAndSlotExists"); return site.doSitesGet(context, __cb(_, __frame, 2, 29, function ___(__0, __1) { sites = __1; siteHits = sites.filter(function(item) { return utils.ignoreCaseEquals(item.name, context.site.name); }); return (function __$determineIfSiteAndSlotExists(__then) { if ((siteHits.length === 1)) { log.info($("Updating existing site")); context.flags.siteExists = true; return (function __$determineIfSiteAndSlotExists(__then) { if ((context.site.webspace === undefined)) { context.site.webspace = siteHits[0].webSpace; log.verbose(util.format($("Existing site location is %s"), context.site.webspace)); __then(); } else { return ensureSpaces(context, __cb(_, __frame, 15, 16, function __$determineIfSiteAndSlotExists() { displayNameMatches = context.spaces.filter(function(space) { return (space.GeoRegion === context.site.webspace); })[0]; if ((displayNameMatches && (displayNameMatches.Name !== siteHits[0].WebSpace))) { return _(new Error(util.format($("Expected location %s but was %s"), context.site.webspace, displayNameMatches.GeoRegion))); } ; __then(); }, true)); } ; })(__then); } else { __then(); } ; })(function __$determineIfSiteAndSlotExists() { return (function __$determineIfSiteAndSlotExists(__then) { if (context.site.slot) { slotHits = sites.filter(function(item) { return utils.ignoreCaseEquals(item.name, WebsitesClient.getSiteName(context.site.name, context.site.slot)); }); return (function __$determineIfSiteAndSlotExists(__then) { if ((slotHits.length === 0)) { return (function __$determineIfSiteAndSlotExists(__then) { if ((siteHits.length === 1)) { log.info($("Adding slot to existing site")); return (function __$determineIfSiteAndSlotExists(__then) { if ((context.site.webspace === undefined)) { context.site.webspace = siteHits[0].webSpace; log.verbose(util.format($("Existing site location is %s"), context.site.webspace)); __then(); } else { return ensureSpaces(context, __cb(_, __frame, 39, 20, function __$determineIfSiteAndSlotExists() { displaySlotNameMatches = context.spaces.filter(function(space) { return (space.GeoRegion === context.site.webspace); })[0]; if ((displaySlotNameMatches && (displaySlotNameMatches.Name !== siteHits[0].WebSpace))) { return _(new Error(util.format($("Expected location %s but was %s"), context.site.webspace, displaySlotNameMatches.GeoRegion))); } ; __then(); }, true)); } ; })(__then); } else { __then(); } ; })(__then); } else { context.flags.siteSlotExists = true; __then(); } ; })(__then); } else { __then(); } ; })(_); }); }, true)); }); }; function promptForLocation(_) { var locations, location; var __frame = { name: "promptForLocation", line: 335 }; return __func(_, this, arguments, promptForLocation, 0, __frame, function __$promptForLocation() { log.silly("promptForLocation"); return ensureSpaces(context, __cb(_, __frame, 2, 12, function __$promptForLocation() { return site.doAvailableLocationsGet(context, __cb(_, __frame, 4, 33, function ___(__0, __1) { locations = __1; location = null; return (function __$promptForLocation(__then) { if ((!context.site.location && !context.site.webspace)) { log.help($("Choose a location")); return cli.interaction.choose(locations.map(function(location) { return location.name; }), __cb(_, __frame, 9, 51, function ___(__0, __2) { location = locations[__2]; __then(); }, true)); } else { if (context.site.location) { location = locations.filter(function(loc) { return utils.ignoreCaseEquals(loc.name, context.site.location); })[0]; } else { location = locations.filter(function(loc) { return utils.ignoreCaseEquals(loc.webSpace, context.site.webspace); })[0]; } ; __then(); } ; })(function __$promptForLocation() { if (!location) { return _(new Error($("Invalid location"))); } ; context.site.location = location.name; context.site.webspace = location.webSpace; _(); }); }, true)); }, true)); }); }; function updateLocalConfigWithSiteName(_) { var cfg; var __frame = { name: "updateLocalConfigWithSiteName", line: 366 }; return __func(_, this, arguments, updateLocalConfigWithSiteName, 0, __frame, function __$updateLocalConfigWithSiteName() { log.silly("updateLocalConfigWithSiteName"); return (function __$updateLocalConfigWithSiteName(__then) { if (context.flags.isGitWorkingTree) { return websiteClient.readConfig(__cb(_, __frame, 3, 38, function ___(__0, __1) { cfg = __1; cfg.name = context.site.name; cfg.slot = (context.site.slot || WebsitesClient.getProductionSlotName()); cfg.webspace = context.site.webspace; return websiteClient.writeConfig(cfg, __cb(_, __frame, 7, 28, __then, true)); }, true)); } else { __then(); } ; })(_); }); }; function createSite(_) { var site, websiteAddress; var __frame = { name: "createSite", line: 377 }; return __func(_, this, arguments, createSite, 0, __frame, function __$createSite() { log.silly("createSite"); return (function __$createSite(__then) { if (!context.flags.siteExists) { site = { name: context.site.name, webSpaceName: context.site.webspace, webSpace: { name: context.site.webspace, geoRegion: context.site.location, plan: "VirtualDedicatedPlan" }, serverFarm: "" }; return websiteClient.getHostNameSuffix(context.subscription, __cb(_, __frame, 14, 75, function ___(__0, __1) { websiteAddress = ((context.site.name + ".") + __1); if (context.site.hostNames) { site.hostNames.push(websiteAddress); } else { if (websiteAddress) { site.hostNames = [websiteAddress,]; } ; } ; return websiteClient.createSite(context.subscription, context.site.webspace, site, __cb(_, __frame, 21, 35, _, true)); }, true)); } else { __then(); } ; })(_); }); }; function createSiteSlot(_) { var site; var __frame = { name: "createSiteSlot", line: 402 }; return __func(_, this, arguments, createSiteSlot, 0, __frame, function __$createSiteSlot() { log.silly("createSiteSlot"); return (function __$createSiteSlot(__then) { if ((context.site.slot && !context.flags.siteSlotExists)) { site = { name: WebsitesClient.getSiteName(context.site.name, context.site.slot), webSpaceName: context.site.webspace, serverFarm: "" }; return websiteClient.createSite(context.subscription, context.site.webspace, site, __cb(_, __frame, 9, 35, _, true)); } else { __then(); } ; })(_); }); }; var __frame = { name: "__4", line: 194 }; return __func(_, this, arguments, __4, 2, __frame, function __$__4() { context = { subscription: profile.current.getSubscription(options.subscription).id, git: options.git, site: { name: nameArg, location: options.location, hostname: options.hostname }, flags: { } }; if (!WebsitesClient.isProductionSlot(options.slot)) { context.site.slot = options.slot; } ; if ((options.git && options.github)) { return _(new Error($("Please run the command with either --git or --github options. Not both"))); } ; if (options.git) { context.publishingUser = options.gitusername; } else { if (options.github) { context.github = { username: options.githubusername, password: options.githubpassword, repositoryFullName: options.githubrepository }; } ; } ; websiteClient = new WebsitesClient(cli, context.subscription); return promptForSiteName(__cb(_, __frame, 33, 10, function __$__4() { return determineIfSiteAndSlotExists(__cb(_, __frame, 35, 10, function __$__4() { if ((!context.flags.siteExists && context.site.slot)) { return _(new Error($("Can't create a slot for a site that does not exist"))); } ; return promptForLocation(__cb(_, __frame, 41, 10, function __$__4() { if (utils.stringIsNullOrEmpty(context.site.location)) { return _(new Error($("Invalid location"))); } ; return (function __$__4(__then) { if (context.site.slot) { return createSiteSlot(__cb(_, __frame, 48, 12, __then, true)); } else { return createSite(__cb(_, __frame, 50, 12, __then, true)); } ; })(function __$__4() { return (function __$__4(__then) { if ((options.git || options.github)) { if (options.github) { context.lvcClient = linkedRevisionControl.createClient(cli, "github", websiteClient); } else { if (options.git) { context.lvcClient = linkedRevisionControl.createClient(cli, "git", websiteClient); } ; } ; return context.lvcClient.init(context, __cb(_, __frame, 61, 30, function __$__4() { return utils.copyIisNodeWhenServerJsPresent(log, ".", __cb(_, __frame, 64, 18, function __$__4() { return updateLocalConfigWithSiteName(__cb(_, __frame, 65, 12, function __$__4() { return context.lvcClient.deploy(context, __cb(_, __frame, 66, 30, __then, true)); }, true)); }, true)); }, true)); } else { context.lvcClient = linkedRevisionControl.createClient(cli, "git", websiteClient); return context.lvcClient.determineIfCurrentDirectoryIsGitWorkingTree(context, __cb(_, __frame, 71, 30, function __$__4() { return (function __$__4(__then) { if (context.flags.isGitWorkingTree) { return context.lvcClient.scaffoldGitIgnore(__cb(_, __frame, 74, 32, __then, true)); } else { __then(); } ; })(__then); }, true)); } ; })(_); }); }, true)); }, true)); }, true)); }); }); var location = site.category("location").description($("Commands to manage your Web Site locations")); location.command("list").description($("List locations available for your account")).execute(function __5(options, _) { var context, locations; var __frame = { name: "__5", line: 421 }; return __func(_, this, arguments, __5, 1, __frame, function __$__5() { context = { subscription: profile.current.getSubscription(options.subscription).id }; return site.doAvailableLocationsGet(context, __cb(_, __frame, 5, 31, function ___(__0, __1) { locations = __1; log.table(locations, function(row, item) { row.cell($("Name"), item.name); }); _(); }, true)); }); }); site.command("browse [name]").description($("Open your web site in a browser")).option("--slot <slot>", $("the name of the slot")).option("-s, --subscription <id>", $("the subscription id")).execute(function __6(name, options, _) { var parsedSiteName, context, cache, siteData, href; var __frame = { name: "__6", line: 436 }; return __func(_, this, arguments, __6, 2, __frame, function __$__6() { parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name, slot: (options.slot ? options.slot : parsedSiteName.slot) } }; return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 10, 27, function ___(__0, __2) { cache = __2; return (function __$__6(_) { var __1 = cache; if (__1) { return _(null, __1); } ; return site.doSiteGet(context, __cb(_, __frame, 11, 39, _, true)); })(__cb(_, __frame, -435, 18, function ___(__0, __3) { siteData = __3; return (function __$__6(__then) { if (((siteData && siteData.hostNames) && (siteData.hostNames.length > 0))) { href = ("http://" + siteData.hostNames[0]); return cli.interaction.launchBrowser(href, __cb(_, __frame, 15, 28, __then, true)); } else { return _(new Error(util.format("Site %s does not exist or has no hostnames", name))); } ; })(_); }, true)); }, true)); }); }); site.command("show [name]").description($("Show details for a web site")).option("-d, --details", $("show additional site details")).option("--slot <slot>", $("the name of the slot")).option("-s, --subscription <id>", $("the subscription id")).execute(function __7(name, options, _) { var parsedSiteName, context, websiteClient, result, repositoryUri, gitUri, settings, diagnosticsSettings, siteInstances, data, showProperty, index, dSetting; var __frame = { name: "__7", line: 462 }; return __func(_, this, arguments, __7, 2, __frame, function __$__7() { parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name, slot: (options.slot ? options.slot : parsedSiteName.slot) } }; websiteClient = new WebsitesClient(cli, context.subscription); return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 11, 15, function __$__7() { log.info($("Showing details for site")); log.verbose($("Parameters"), context); return async.parallel([function __1(_) { var __frame = { name: "__1", line: 479 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() { return site.doSiteGet(context, __cb(_, __frame, 0, 39, _, true)); }); },function __2(_) { var __frame = { name: "__2", line: 480 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return site.doSiteConfigGet(context, __cb(_, __frame, 0, 39, _, true)); }); },], __cb(_, __frame, 16, 29, function ___(__0, __3) { result = __3; repositoryUri = websiteClient.getRepositoryUri(result[0]); gitUri = (repositoryUri ? websiteClient.getGitUri(repositoryUri, context.site.name) : "none"); settings = []; diagnosticsSettings = { }; return (function __$__7(__then) { if (repositoryUri) { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__7() { return site.ensureRepositoryUri(context, __cb(_, __frame, 29, 19, function __$__7() { return site.category("repository").doSettingsGet(context, __cb(_, __frame, 30, 53, function ___(__0, __4) { settings = __4; return websiteClient.getDiagnosticsSettings(context, __cb(_, __frame, 31, 50, function ___(__0, __5) { diagnosticsSettings = __5; __then(); }, true)); }, true)); }, true)); }); })(function ___(e, __result) { __catch(function __$__7() { if (e) { log.verbose("SCM Error", e.message.toString()); __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, __then); }); } else { __then(); } ; })(function __$__7() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__7() { return site.doSiteInstancesGet(context, __cb(_, __frame, 40, 33, function ___(__0, __6) { siteInstances = __6; __then(); }, true)); }); })(function ___(e, __result) { __catch(function __$__7() { if (e) { siteInstances = []; __then(); } else { _(null, __result); } ; }, _); }); })(function ___() { __tryCatch(_, function __$__7() { return (function __$__7(__then) { if (log.format().json) { data = { site: result[0], config: result[1], gitRepositoryUri: gitUri, settings: settings, diagnosticsSettings: diagnosticsSettings, instances: siteInstances }; log.json(data); __then(); } else { showProperty = function(source, name, property, defaultValue) { if (source[property]) { log.data(name, source[property].toString()); delete source[property]; } else if (defaultValue) { log.data(name, defaultValue); } else { log.data(name, ""); } ; }; context.skipCache = true; return ensureSpaces(context, __cb(_, __frame, 71, 12, function __$__7() { log.data(""); showProperty(result[0], $("Web Site Name: "), "name"); log.data($("SKU: "), result[0].sku); showProperty(result[0], $("Enabled: "), "enabled"); showProperty(result[0], $("Availability: "), "availabilityState"); showProperty(result[0], $("Last Modified: "), "lastModifiedTimeUtc", $("Never")); log.data($("Location: "), getSiteLocation(context.spaces, result[0])); if ((result[0].hostNames && (result[0].hostNames.length > 0))) { log.data(""); log.table(result[0].hostNames, function(row, s) { row.cell($("Host Name"), s); }); } ; delete result[0].hostNames; if ((result[0].sslCertificates && (result[0].sslCertificates.length > 0))) { log.data(""); log.table(Object.keys(result[0].sslCertificates), function(row, certificate) { for (var hostname in certificate.hostNames) { row.cell($("SSL Host Names"), hostname); }; }); } ; delete result[0].sslCertificates; if ((siteInstances && (siteInstances.length > 0))) { log.data(""); log.table(siteInstances, function(row, instanceId) { row.cell($("Instance Id"), instanceId); }); } ; if ((result[1].appSettings && (Object.keys(result[1].appSettings).length > 0))) { log.data(""); log.table(Object.keys(result[1].appSettings), function(row, s) { row.cell($("App Setting"), s); row.cell($("Value"), result[1].appSettings[s]); }); } ; delete result[1].appSettings; if ((result[1].defaultDocuments && (result[1].defaultDocuments.length > 0))) { log.data(""); log.table(result[1].defaultDocuments, function(row, s) { row.cell($("Default Documents"), s); }); } ; delete result[1].defaultDocuments; log.data(""); log.data($("Platform & Frameworks")); log.data($("---------------------")); showProperty(result[1], $(".NET Framework Version: "), "netFrameworkVersion"); showProperty(result[1], $("PHP Version: "), "phpVersion"); log.data($("Work Process: "), (result[1].use32BitWorkerProcess ? "32-bit" : "64-bit")); showProperty(result[1], $("Worker Count: "), "numberOfWorkers"); log.data($("WebSockets enabled: "), (result[1].webSocketsEnabled ? "true" : "false")); delete result[1].use32BitWorkerProcess; log.data(""); log.data($("Logging and Diagnostics")); log.data($("-----------------------")); showProperty(result[1], $("HTTP Logging: "), "httpLoggingEnabled"); if ((result[1].defaultDocuments && (result[1].defaultDocuments.length > 0))) { log.data(""); log.table(result[1].defaultDocuments, function(row, s) { row.cell($("Source Control"), s); }); } ; delete result[1].defaultDocuments; if ((settings && settings.ScmType)) { log.data(""); log.data($("Source Control")); log.data($("--------------")); log.data($("Type: "), settings.ScmType); log.data($("Git Repository: "), gitUri); log.data($("Branch: "), settings.deployment_branch); ["ScmType","SCM_GIT_USERNAME","deployment_branch",].forEach(function(key) { delete settings[key]; }); } ; if (options.details) { log.data(""); log.data($("Additional properties and settings")); log.data($("----------------------------------")); cli.interaction.logEachData($("Site"), result[0]); cli.interaction.logEachData($("Config"), result[1]); for (index in settings) { log.data((($("Settings") + " ") + index), settings[index]); }; for (dSetting in diagnosticsSettings) { log.data(($("Diagnostics Settings ") + dSetting), diagnosticsSettings[dSetting].toString()); }; } ; __then(); }, true)); } ; })(_); }); }); }); }, true)); }, true)); }); }); site.command("delete [name]").description($("Delete a web site")).option("-q, --quiet", $("quiet mode, do not ask for delete confirmation")).option("--slot <slot>", $("the name of the slot")).option("-s, --subscription <id>", $("the subscription id")).execute(function __8(name, options, _) { var parsedSiteName, context, progress, service, siteName; var __frame = { name: "__8", line: 659 }; return __func(_, this, arguments, __8, 2, __frame, function __$__8() { parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name, slot: (options.slot ? options.slot : parsedSiteName.slot) } }; if (WebsitesClient.isProductionSlot(options.slot)) { delete options.slot; } ; return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 14, 15, function __$__8() { return (function __$__8(__then) { if (!options.quiet) { return (function __$__8(__then) { if (!context.site.slot) { return cli.interaction.confirm(util.format("Delete site %s? [y/n] ", context.site.name), __cb(_, __frame, 18, 35, function ___(__0, __2) { var __1 = !__2; return (function __$__8(__then) { if (__1) { return _(null); } else { __then(); } ; })(__then); }, true)); } else { return cli.interaction.confirm(util.format("Delete site %s in slot %s? [y/n] ", context.site.name, context.site.slot), __cb(_, __frame, 21, 40, function ___(__0, __4) { var __3 = !__4; return (function __$__8(__then) { if (__3) { return _(null); } else { __then(); } ; })(__then); }, true)); } ; })(__then); } else { __then(); } ; })(function __$__8() { progress = cli.interaction.progress($("Deleting site")); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__8() { return createWebsiteManagementService(context.subscription, __cb(_, __frame, 28, 26, function ___(__0, __5) { service = __5; siteName = WebsitesClient.getSiteName(context.site.name, context.site.slot); return service.webSites.deleteMethod(context.site.webspace, siteName, { deleteMetrics: true, deleteEmptyServerFarm: true, deleteAllSlots: !options.slot }, __cb(_, __frame, 31, 29, function __$__8() { return cacheUtils.deleteSite(context.subscription, siteName, __cb(_, __frame, 37, 23, function __$__8() { _(null, null, true); }, true)); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__8() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__8() { log.info(util.format($("Site %s has been deleted"), context.site.name)); _(); }); }); }); }, true)); }); }); site.command("swap <name> [slot1] [slot2]").description($("Swap two web site slots")).option("-q, --quiet", $("quiet mode, do not ask for swap confirmation")).option("-s, --subscription <id>", $("the subscription id")).execute(function __9(name, slot1, slot2, options, _) { var parsedSiteName, context, sites, slots, verifySlotExists, progress, service; var __frame = { name: "__9", line: 708 }; return __func(_, this, arguments, __9, 4, __frame, function __$__9() { parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name } }; if (parsedSiteName.slot) { return _(new Error($("Slot should not be passed in the site name"))); } ; return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 13, 15, function __$__9() { return site.doSitesGet(context, __cb(_, __frame, 15, 27, function ___(__0, __2) { sites = __2; slots = []; sites.forEach(function(s) { var currentSiteName = WebsitesClient.parseSiteName(s.name); if (utils.ignoreCaseEquals(currentSiteName.name, parsedSiteName.name)) { slots.push((currentSiteName.slot || WebsitesClient.getProductionSlotName())); } ; }); verifySlotExists = function(slot) { if (!slots.some(function(s) { return utils.ignoreCaseEquals(slot, s); })) { throw new Error(util.format($("The website does not contain a slot named: %s"), slot)); } ; }; if ((slots.length < 2)) { return _(new Error($("The website must have at least two slots to apply swap"))); } else { if (((slots.length > 2) && ((!slot1 || !slot2)))) { return _(new Error($("The website has more than 2 slots you must specify which ones to swap"))); } ; } ; if (slot1) { verifySlotExists(slot1); } ; if (slot2) { verifySlotExists(slot2); } ; if ((slots.length === 2)) { slot1 = slots[0]; slot2 = slots[1]; } else { if (utils.ignoreCaseEquals(slot1, slot2)) { return _(new Error($("Specified slots must be different"))); } ; } ; return (function __$__9(_) { var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return cli.interaction.confirm(util.format($("Swap slot \"%s\" from site \"%s\" with slot \"%s\" ? [y/n] "), slot1, context.site.name, slot2), __cb(_, __frame, 57, 49, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -707, 18, function ___(__0, __3) { return (function __$__9(__then) { if (__3) { return _(null); } else { __then(); } ; })(function __$__9() { progress = cli.interaction.progress(util.format($("Swapping slot \"%s\" from site \"%s\" with slot \"%s\""), slot1, context.site.name, slot2)); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$__9() { return createWebsiteManagementService(context.subscription, __cb(_, __frame, 63, 26, function ___(__0, __4) { service = __4; return service.webSites.swapSlots(context.site.webspace, context.site.name, slot1, slot2, __cb(_, __frame, 65, 29, function __$__9() { _(null, null, true); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$__9() { progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$__9() { log.info(util.format($("Site \"%s\" slots has been swapped"), context.site.name)); _(); }); }); }); }, true)); }, true)); }, true)); }); }); site.command("start [name]").description($("Start a web site")).option("--slot <slot>", $("the name of the slot")).option("-s, --subscription <id>", $("the subscription id")).execute(function __10(name, options, _) { var parsedSiteName, context; var __frame = { name: "__10", line: 785 }; return __func(_, this, arguments, __10, 2, __frame, function __$__10() { parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name, slot: (options.slot ? options.slot : parsedSiteName.slot) } }; return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 10, 15, function __$__10() { log.info(util.format($("Starting site %s"), context.site.name)); return site.doSitePUT(context, { state: "Running" }, __cb(_, __frame, 14, 15, function __$__10() { log.info(util.format($("Site %s has been started"), context.site.name)); _(); }, true)); }, true)); }); }); site.command("stop [name]").description($("Stop a web site")).option("--slot <slot>", $("the name of the slot")).option("-s, --subscription <id>", $("the subscription id")).execute(function __11(name, options, _) { var parsedSiteName, context; var __frame = { name: "__11", line: 808 }; return __func(_, this, arguments, __11, 2, __frame, function __$__11() { parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name, slot: (options.slot ? options.slot : parsedSiteName.slot) } }; return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 10, 15, function __$__11() { log.info("Stopping site", context.site.name); return site.doSitePUT(context, { state: "Stopped" }, __cb(_, __frame, 14, 15, function __$__11() { log.info((("Site " + context.site.name) + " has been stopped")); _(); }, true)); }, true)); }); }); site.command("restart [name]").description($("Stop and then start a web site")).option("--slot <slot>", $("the name of the slot")).option("-s, --subscription <id>", $("the subscription id")).execute(function __12(name, options, _) { var parsedSiteName, context; var __frame = { name: "__12", line: 831 }; return __func(_, this, arguments, __12, 2, __frame, function __$__12() { parsedSiteName = WebsitesClient.parseSiteName(name); context = { subscription: profile.current.getSubscription(options.subscription).id, site: { name: parsedSiteName.name, slot: (options.slot ? options.slot : parsedSiteName.slot) } }; return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 10, 15, function __$__12() { log.info(util.format($("Stopping site %s"), context.site.name)); return site.doSitePUT(context, { state: "Stopped" }, __cb(_, __frame, 13, 15, function __$__12() { log.info(util.format($("Site %s has been stopped, restarting"), context.site.name)); return site.doSitePUT(context, { state: "Running" }, __cb(_, __frame, 16, 15, function __$__12() { log.info(util.format($("Site %s has been restarted"), context.site.name)); _(); }, true)); }, true)); }, true)); }); }); site.lookupSiteNameAndWebSpace = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.lookupSiteNameAndWebSpace(options, callback); }; var ensureSpaces = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.ensureSpaces(options, callback); }; site.doRepositoryPost = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.createRepository(options, callback); }; site.doRepositoryGet = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.getRepository(options, callback); }; site.doRepositoryDelete = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.deleteRepository(options, callback); }; site.doRepositorySync = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.syncRepository(options, callback); }; site.ensureRepositoryUri = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.ensureRepositoryUri(options, callback); }; site.doAvailableLocationsGet = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.getAvailableLocations(options, callback); }; site.doSpacesGet = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.getSpaces(options, callback); }; site.doSitesGet = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.getSites(options, callback); }; site.doSiteGet = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.getSite(options, callback); }; site.doSiteInstancesGet = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.getSiteInstances(options, callback); }; site.doSiteConfigGet = function(options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.getSiteConfiguration(options, callback); }; site.doSitePUT = function(options, site, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.updateSite(site, options, callback); }; site.doSiteConfigPUT = function(config, options, callback) { var websiteClient = new WebsitesClient(cli, options.subscription); return websiteClient.updateSiteConfiguration(config, options, callback); }; function createWebsiteManagementService(subscription, callback) { return utils.createWebsiteClient(profile.current.getSubscription(subscription), callback); };};