Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

#398: Update github feature to handle remotes #399

Merged
merged 15 commits into from
Commits on Oct 23, 2012
  1. @andrerod

    Initial app settings commit

    andrerod authored
  2. @andrerod

    Fixing issue with js2xml

    andrerod authored
  3. @andrerod

    updates

    andrerod authored
Commits on Oct 24, 2012
  1. @andrerod

    Implemeting app settings

    andrerod authored
  2. @andrerod

    Adding UT

    andrerod authored
  3. @andrerod

    Reenabling all UT

    andrerod authored
  4. @andrerod

    Add UT

    andrerod authored
  5. @andrerod

    removing unused requires

    andrerod authored
  6. @andrerod

    Removing dead code.

    andrerod authored
  7. @andrerod

    Improving UT.

    andrerod authored
  8. @andrerod

    #398: remotes update.

    andrerod authored
  9. @andrerod
  10. @andrerod

    Applying code review comments

    andrerod authored
  11. @andrerod

    Merge branch 'dev' into appconfig

    andrerod authored
    Conflicts:
    	lib/cli/commands/site.js
  12. @andrerod

    Merge pull request #14 from andrerod/appconfig

    andrerod authored
    #322: Setting up config vars for a Website [app settings]
This page is out of date. Refresh to see the latest.
View
109 lib/cli/commands/site.js
@@ -26,6 +26,7 @@ var child_process = require("child_process");
var utils = require("../utils");
var constants = require("../constants");
var cacheUtils = require("../cacheUtils");
+var js2xml = require("../../util/js2xml");
var linkedRevisionControl = require("../linkedrevisioncontrol");
@@ -70,7 +71,7 @@ exports.init = function(cli) {
var site = cli.category("site").description("Commands to manage your web sites");
- site.command("list").whiteListPowershell().description("List your web sites").option("-s, --subscription <id>", "use the subscription id").execute(function __1(options, _) { var parameters, sites, s; var __frame = { name: "__1", line: 77 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
+ site.command("list").whiteListPowershell().description("List your web sites").option("-s, --subscription <id>", "use the subscription id").execute(function __1(options, _) { var parameters, sites, s; var __frame = { name: "__1", line: 78 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
@@ -112,7 +113,7 @@ exports.init = function(cli) {
site.confirm = confirm;
- site.command("create [name]").whiteListPowershell().description("Create a new web site").option("-s, --subscription <id>", "use the subscription id").option("--location <location>", "the geographic region to create the website").option("--hostname <hostname>", "custom host name to use").option("--git", "configure git on web site and local folder").option("-pu, --publishingUsername <publishingUsername>", "The publishing username for git").option("--github", "configure github on web site and local folder").option("-u, --username <user>", "The github username").option("-up, --pass <pass>", "The github password").option("-r, --repository <repository>", "The github repository full name (i.e. user/repository)").execute(function __2(nameArg, options, _) { var context;
+ site.command("create [name]").whiteListPowershell().description("Create a new web site").option("-s, --subscription <id>", "use the subscription id").option("--location <location>", "the geographic region to create the website").option("--hostname <hostname>", "custom host name to use").option("--git", "configure git on web site and local folder").option("-pu, --publishingUsername <publishingUsername>", "The publishing username for git").option("--github", "configure github on web site and local folder").option("-u, --username <user>", "The github username").option("-up, --pass <pass>", "The github password").option("-r, --repository <repository>", "The github repository").execute(function __2(nameArg, options, _) { var context;
@@ -175,9 +176,7 @@ exports.init = function(cli) {
-
-
- function promptForSiteName(_) { var __frame = { name: "promptForSiteName", line: 180 }; return __func(_, this, arguments, promptForSiteName, 0, __frame, function __$promptForSiteName() {
+ function promptForSiteName(_) { var __frame = { name: "promptForSiteName", line: 179 }; 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");
@@ -185,7 +184,7 @@ exports.init = function(cli) {
- function determineIfSiteExists(_) { var sites, hits, displayNameMatches; var __frame = { name: "determineIfSiteExists", line: 188 }; return __func(_, this, arguments, determineIfSiteExists, 0, __frame, function __$determineIfSiteExists() {
+ function determineIfSiteExists(_) { var sites, hits, displayNameMatches; var __frame = { name: "determineIfSiteExists", line: 187 }; return __func(_, this, arguments, determineIfSiteExists, 0, __frame, function __$determineIfSiteExists() {
log.silly("determineIfSiteExists");
return site.doSitesGet(context, __cb(_, __frame, 2, 24, function ___(__0, __1) { sites = __1;
hits = sites.filter(function(item) {
@@ -211,7 +210,7 @@ exports.init = function(cli) {
- function promptForLocation(_) { var displayNameMatches; var __frame = { name: "promptForLocation", line: 214 }; return __func(_, this, arguments, promptForLocation, 0, __frame, function __$promptForLocation() {
+ function promptForLocation(_) { var displayNameMatches; var __frame = { name: "promptForLocation", line: 213 }; return __func(_, this, arguments, promptForLocation, 0, __frame, function __$promptForLocation() {
log.silly("promptForLocation");
return ensureSpaces(context, __cb(_, __frame, 2, 12, function __$promptForLocation() {
@@ -245,7 +244,7 @@ exports.init = function(cli) {
- function copyIisNodeWhenServerJsPresent(_) { var sourcePath; var __frame = { name: "copyIisNodeWhenServerJsPresent", line: 248 }; return __func(_, this, arguments, copyIisNodeWhenServerJsPresent, 0, __frame, function __$copyIisNodeWhenServerJsPresent() {
+ function copyIisNodeWhenServerJsPresent(_) { var sourcePath; var __frame = { name: "copyIisNodeWhenServerJsPresent", line: 247 }; return __func(_, this, arguments, copyIisNodeWhenServerJsPresent, 0, __frame, function __$copyIisNodeWhenServerJsPresent() {
log.silly("copyWebConfigWhenServerJsPresent"); return (function __$copyIisNodeWhenServerJsPresent(__then) {
if ((!utils.pathExistsSync("iisnode.yml") && ((utils.pathExistsSync("server.js") || utils.pathExistsSync("app.js"))))) {
log.info("Creating default iisnode.yml file");
@@ -254,7 +253,7 @@ exports.init = function(cli) {
- function updateLocalConfigWithSiteName(_) { var cfg; var __frame = { name: "updateLocalConfigWithSiteName", line: 257 }; return __func(_, this, arguments, updateLocalConfigWithSiteName, 0, __frame, function __$updateLocalConfigWithSiteName() {
+ function updateLocalConfigWithSiteName(_) { var cfg; var __frame = { name: "updateLocalConfigWithSiteName", line: 256 }; return __func(_, this, arguments, updateLocalConfigWithSiteName, 0, __frame, function __$updateLocalConfigWithSiteName() {
log.silly("updateLocalConfigWithSiteName"); return (function __$updateLocalConfigWithSiteName(__then) {
if (context.flags.isGitWorkingTree) {
return site.readConfig(__cb(_, __frame, 3, 24, function ___(__0, __1) { cfg = __1;
@@ -264,14 +263,14 @@ exports.init = function(cli) {
- function createSite(_) { var __frame = { name: "createSite", line: 267 }; return __func(_, this, arguments, createSite, 0, __frame, function __$createSite() {
+ function createSite(_) { var __frame = { name: "createSite", line: 266 }; return __func(_, this, arguments, createSite, 0, __frame, function __$createSite() {
log.silly("createSite"); return (function __$createSite(__then) {
if (!context.flags.siteExists) {
return site.doSitesPost(context, __cb(_, __frame, 3, 14, __then, true)); } else { __then(); } ; })(_); }); };
- function initializeRemoteRepo(_) { var __frame = { name: "initializeRemoteRepo", line: 274 }; return __func(_, this, arguments, initializeRemoteRepo, 0, __frame, function __$initializeRemoteRepo() {
+ function initializeRemoteRepo(_) { var __frame = { name: "initializeRemoteRepo", line: 273 }; return __func(_, this, arguments, initializeRemoteRepo, 0, __frame, function __$initializeRemoteRepo() {
log.silly("InitializeRemoteRepo"); return (function __$initializeRemoteRepo(__then) {
if (!context.flags.siteExists) {
return site.doRepositoryPost(context, __cb(_, __frame, 3, 14, function __$initializeRemoteRepo() {
@@ -287,7 +286,7 @@ exports.init = function(cli) {
log.silly("context.repo", context.repo); _(); }); }); };
- function addRemoteToLocalGitRepo(_) { var remotes, azureExists, gitUri; var __frame = { name: "addRemoteToLocalGitRepo", line: 290 }; return __func(_, this, arguments, addRemoteToLocalGitRepo, 0, __frame, function __$addRemoteToLocalGitRepo() {
+ function addRemoteToLocalGitRepo(_) { var remotes, azureExists, gitUri; var __frame = { name: "addRemoteToLocalGitRepo", line: 289 }; return __func(_, this, arguments, addRemoteToLocalGitRepo, 0, __frame, function __$addRemoteToLocalGitRepo() {
log.silly("addRemoteToLocalGitRepo");
if (!context.flags.isGitWorkingTree) {
log.info((("To create a local git repository to publish to the remote site, please rerun this command with the --git flag: \"azure site create " + ((((context.site && context.site.name)) || "{site name}"))) + " --git\".")); return _(null); } ; return (function __$addRemoteToLocalGitRepo(__then) {
@@ -315,17 +314,17 @@ exports.init = function(cli) {
return exec(("git remote add azure " + gitUri), __cb(_, __frame, 25, 12, _, true)); }); }, true)); }); }); };
- function ensureSpaces(context, _) { var __frame = { name: "ensureSpaces", line: 318 }; return __func(_, this, arguments, ensureSpaces, 1, __frame, function __$ensureSpaces() { return (function __$ensureSpaces(__then) {
+ function ensureSpaces(context, _) { var __frame = { name: "ensureSpaces", line: 317 }; return __func(_, this, arguments, ensureSpaces, 1, __frame, function __$ensureSpaces() { return (function __$ensureSpaces(__then) {
if (!context.spaces) {
return cacheUtils.readSpaces(context, __cb(_, __frame, 2, 31, function ___(__0, __1) { context.spaces = __1; return (function __$ensureSpaces(__then) {
if ((!context.spaces || !context.spaces.length)) {
- return context.site.doSpacesGet(context, __cb(_, __frame, 4, 33, function ___(__0, __2) { context.spaces = __2; __then(); }, true)); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(_); }); }; var __frame = { name: "__2", line: 127 }; return __func(_, this, arguments, __2, 2, __frame, function __$__2() { context = { subscription: cli.category("account").lookupSubscriptionId(options.subscription), git: options.git, site: { name: nameArg, webspace: options.location, hostname: options.hostname }, publishingUser: options.publishingUsername, github: { username: options.username, password: options.pass, repositoryFullName: options.repository }, flags: { } }; if ((options.git && options.github)) { return _(new Error("Please run the command with either --git or --github options. Not both.")); } ; return promptForSiteName(__cb(_, __frame, 23, 10, function __$__2() { return determineIfSiteExists(__cb(_, __frame, 24, 10, function __$__2() { return promptForLocation(__cb(_, __frame, 25, 10, function __$__2() { return createSite(__cb(_, __frame, 26, 10, function __$__2() { return (function __$__2(__then) { if ((options.git || options.github)) { if (options.github) { context.lvcClient = linkedRevisionControl.createClient(cli, "github"); } else { if (options.git) { context.lvcClient = linkedRevisionControl.createClient(cli, "git"); } ; } ; return context.lvcClient.init(context, __cb(_, __frame, 36, 12, function __$__2() { return copyIisNodeWhenServerJsPresent(__cb(_, __frame, 39, 12, function __$__2() { return updateLocalConfigWithSiteName(__cb(_, __frame, 40, 12, function __$__2() { return initializeRemoteRepo(__cb(_, __frame, 42, 12, function __$__2() { return (function __$__2(__then) { if (options.git) { return addRemoteToLocalGitRepo(__cb(_, __frame, 45, 14, __then, true)); } else { return (function __$__2(__then) { if (options.github) { return site.ensureRepositoryUri(context, __cb(_, __frame, 47, 14, __then, true)); } else { __then(); } ; })(__then); } ; })(function __$__2() { return context.lvcClient.deploy(context, __cb(_, __frame, 50, 12, __then, true)); }); }, true)); }, true)); }, true)); }, true)); } else { __then(); } ; })(_); }, true)); }, true)); }, true)); }, true)); }); });
+ return context.site.doSpacesGet(context, __cb(_, __frame, 4, 33, function ___(__0, __2) { context.spaces = __2; __then(); }, true)); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(_); }); }; var __frame = { name: "__2", line: 128 }; return __func(_, this, arguments, __2, 2, __frame, function __$__2() { context = { subscription: cli.category("account").lookupSubscriptionId(options.subscription), git: options.git, site: { name: nameArg, webspace: options.location, hostname: options.hostname }, publishingUser: options.publishingUsername, username: options.username, password: options.pass, remoteUri: options.repository, flags: { } }; if ((options.git && options.github)) { return _(new Error("Please run the command with either --git or --github options. Not both.")); } ; return promptForSiteName(__cb(_, __frame, 21, 10, function __$__2() { return determineIfSiteExists(__cb(_, __frame, 22, 10, function __$__2() { return promptForLocation(__cb(_, __frame, 23, 10, function __$__2() { return createSite(__cb(_, __frame, 24, 10, function __$__2() { return (function __$__2(__then) { if ((options.git || options.github)) { if (options.github) { context.lvcClient = linkedRevisionControl.createClient(cli, "github"); } else { if (options.git) { context.lvcClient = linkedRevisionControl.createClient(cli, "git"); } ; } ; return context.lvcClient.init(context, __cb(_, __frame, 34, 12, function __$__2() { return copyIisNodeWhenServerJsPresent(__cb(_, __frame, 37, 12, function __$__2() { return updateLocalConfigWithSiteName(__cb(_, __frame, 38, 12, function __$__2() { return initializeRemoteRepo(__cb(_, __frame, 40, 12, function __$__2() { return (function __$__2(__then) { if (options.git) { return addRemoteToLocalGitRepo(__cb(_, __frame, 43, 14, __then, true)); } else { return (function __$__2(__then) { if (options.github) { return site.ensureRepositoryUri(context, __cb(_, __frame, 45, 14, __then, true)); } else { __then(); } ; })(__then); } ; })(function __$__2() { return context.lvcClient.deploy(context, __cb(_, __frame, 48, 12, __then, true)); }); }, true)); }, true)); }, true)); }, true)); } else { __then(); } ; })(_); }, true)); }, true)); }, true)); }, true)); }); });
- function portalCreateSiteInstruction(context, _) { var href; var __frame = { name: "portalCreateSiteInstruction", line: 328 }; return __func(_, this, arguments, portalCreateSiteInstruction, 1, __frame, function __$portalCreateSiteInstruction() {
+ function portalCreateSiteInstruction(context, _) { var href; var __frame = { name: "portalCreateSiteInstruction", line: 327 }; return __func(_, this, arguments, portalCreateSiteInstruction, 1, __frame, function __$portalCreateSiteInstruction() {
log.help("You must create your first web site using the Windows Azure portal.");
log.help("Please follow these steps in the portal:");
log.help("1. At the bottom of the page, click on New > Web Site > Quick Create");
@@ -344,7 +343,7 @@ exports.init = function(cli) {
- function getPublishingUser(context, _) { var publishingUsers, filters; var __frame = { name: "getPublishingUser", line: 347 }; return __func(_, this, arguments, getPublishingUser, 1, __frame, function __$getPublishingUser() {
+ function getPublishingUser(context, _) { var publishingUsers, filters; var __frame = { name: "getPublishingUser", line: 346 }; return __func(_, this, arguments, getPublishingUser, 1, __frame, function __$getPublishingUser() {
publishingUsers = toArray(context.publishingUsers);
filters = publishingUsers.filter(function(item) {
return ((typeof item === "string") && (item.length <= 64)); }); return (function __$getPublishingUser(__then) {
@@ -362,7 +361,7 @@ exports.init = function(cli) {
return prompt("Publishing username: ", __cb(_, __frame, 15, 11, _, true)); }); }); };
- function portalGitInitInstruction(context, _) { var href; var __frame = { name: "portalGitInitInstruction", line: 365 }; return __func(_, this, arguments, portalGitInitInstruction, 1, __frame, function __$portalGitInitInstruction() {
+ function portalGitInitInstruction(context, _) { var href; var __frame = { name: "portalGitInitInstruction", line: 364 }; return __func(_, this, arguments, portalGitInitInstruction, 1, __frame, function __$portalGitInitInstruction() {
log.help("You must create your git publishing credentials using the Windows Azure portal.");
log.help("Please follow these steps in the portal:");
log.help("1. In the menu on the left select \"Web Sites\"");
@@ -382,7 +381,7 @@ exports.init = function(cli) {
var location = site.category("location").description("Commands to manage your Azure locations");
- location.command("list").whiteListPowershell().description("List locations available for your account").execute(function __3(options, _) { var context, spaces, s; var __frame = { name: "__3", line: 388 }; return __func(_, this, arguments, __3, 1, __frame, function __$__3() {
+ location.command("list").whiteListPowershell().description("List locations available for your account").execute(function __3(options, _) { var context, spaces, s; var __frame = { name: "__3", line: 387 }; return __func(_, this, arguments, __3, 1, __frame, function __$__3() {
@@ -404,7 +403,7 @@ exports.init = function(cli) {
- site.command("portal [name]").whiteListPowershell().description("Opens the portal in a browser to manage your web sites").option("-r, --realm <realm>", "specifies organization used for login").execute(function __4(name, options, _) { var href; var __frame = { name: "__4", line: 411 }; return __func(_, this, arguments, __4, 2, __frame, function __$__4() {
+ site.command("portal [name]").whiteListPowershell().description("Opens the portal in a browser to manage your web sites").option("-r, --realm <realm>", "specifies organization used for login").execute(function __4(name, options, _) { var href; var __frame = { name: "__4", line: 410 }; return __func(_, this, arguments, __4, 2, __frame, function __$__4() {
@@ -424,7 +423,7 @@ exports.init = function(cli) {
common.launchBrowser(targetUrl); _(); }); });
- site.command("browse [name]").whiteListPowershell().description("Open your web site in a browser.").option("-s, --subscription <id>", "use the subscription id").execute(function __5(name, options, _) { var context, cache, siteData, href; var __frame = { name: "__5", line: 431 }; return __func(_, this, arguments, __5, 2, __frame, function __$__5() {
+ site.command("browse [name]").whiteListPowershell().description("Open your web site in a browser.").option("-s, --subscription <id>", "use the subscription id").execute(function __5(name, options, _) { var context, cache, siteData, href; var __frame = { name: "__5", line: 430 }; return __func(_, this, arguments, __5, 2, __frame, function __$__5() {
@@ -438,14 +437,14 @@ exports.init = function(cli) {
return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 9, 22, function ___(__0, __2) { cache = __2; return (function __$__5(_) {
- var __1 = cache; if (__1) { return _(null, __1); } ; return site.doSiteGet(context, __cb(_, __frame, 10, 40, _, true)); })(__cb(_, __frame, -430, 17, function ___(__0, __3) { siteData = clean(__3);
+ var __1 = cache; if (__1) { return _(null, __1); } ; return site.doSiteGet(context, __cb(_, __frame, 10, 40, _, true)); })(__cb(_, __frame, -429, 17, function ___(__0, __3) { siteData = clean(__3);
href = ("http://" + toArray(siteData.HostNames)[0]);
common.launchBrowser(href); _(); }, true)); }, true)); }); });
- site.command("show [name]").whiteListPowershell().description("Show details for a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __6(name, options, _) { var context, result, repositoryUri, gitUri, settings, data, index; var __frame = { name: "__6", line: 452 }; return __func(_, this, arguments, __6, 2, __frame, function __$__6() {
+ site.command("show [name]").whiteListPowershell().description("Show details for a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __6(name, options, _) { var context, result, repositoryUri, gitUri, settings, data, index; var __frame = { name: "__6", line: 451 }; return __func(_, this, arguments, __6, 2, __frame, function __$__6() {
@@ -462,9 +461,9 @@ exports.init = function(cli) {
log.info("Showing details for site");
log.verbose("Parameters", context);
- return async.parallel([function __1(_) { var __frame = { name: "__1", line: 466 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() {
+ return async.parallel([function __1(_) { var __frame = { name: "__1", line: 465 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() {
return site.doSiteGet(context, __cb(_, __frame, 0, 34, _, true)); });
- },function __2(_) { var __frame = { name: "__2", line: 467 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return site.doSiteConfigGet(context, __cb(_, __frame, 0, 34, _, true)); }); },], __cb(_, __frame, 13, 23, function ___(__0, __3) { result = __3;
+ },function __2(_) { var __frame = { name: "__2", line: 466 }; return __func(_, this, arguments, __2, 0, __frame, function __$__2() { return site.doSiteConfigGet(context, __cb(_, __frame, 0, 34, _, true)); }); },], __cb(_, __frame, 13, 23, function ___(__0, __3) { result = __3;
@@ -496,7 +495,7 @@ exports.init = function(cli) {
- function lookupSiteName(context, _) { var cfg; var __frame = { name: "lookupSiteName", line: 499 }; return __func(_, this, arguments, lookupSiteName, 1, __frame, function __$lookupSiteName() {
+ function lookupSiteName(context, _) { var cfg; var __frame = { name: "lookupSiteName", line: 498 }; return __func(_, this, arguments, lookupSiteName, 1, __frame, function __$lookupSiteName() {
if ((context.site.name !== undefined)) { return _(null); } ;
@@ -517,7 +516,7 @@ exports.init = function(cli) {
- function lookupSiteWebSpace(context, _) { var sites, index; var __frame = { name: "lookupSiteWebSpace", line: 520 }; return __func(_, this, arguments, lookupSiteWebSpace, 1, __frame, function __$lookupSiteWebSpace() {
+ function lookupSiteWebSpace(context, _) { var sites, index; var __frame = { name: "lookupSiteWebSpace", line: 519 }; return __func(_, this, arguments, lookupSiteWebSpace, 1, __frame, function __$lookupSiteWebSpace() {
log.verbose("Attempting to locate site ", context.site.name);
return site.doSitesGet(context, __cb(_, __frame, 2, 16, function ___(__0, __1) { sites = __1;
for (index in sites) {
@@ -531,7 +530,7 @@ exports.init = function(cli) {
- function lookupSiteNameAndWebSpace(context, _) { var cache; var __frame = { name: "lookupSiteNameAndWebSpace", line: 534 }; return __func(_, this, arguments, lookupSiteNameAndWebSpace, 1, __frame, function __$lookupSiteNameAndWebSpace() {
+ function lookupSiteNameAndWebSpace(context, _) { var cache; var __frame = { name: "lookupSiteNameAndWebSpace", line: 533 }; return __func(_, this, arguments, lookupSiteNameAndWebSpace, 1, __frame, function __$lookupSiteNameAndWebSpace() {
return lookupSiteName(context, __cb(_, __frame, 1, 4, function __$lookupSiteNameAndWebSpace() {
return cacheUtils.readSite(context, __cb(_, __frame, 2, 16, function ___(__0, __1) { cache = __1;
if ((cache || context.site.webspace)) {
@@ -605,7 +604,7 @@ exports.init = function(cli) {
site.getRepositoryAuth = getRepositoryAuth;
- function ensureRepositoryUri(context, _) { var siteData, repositoryUri; var __frame = { name: "ensureRepositoryUri", line: 608 }; return __func(_, this, arguments, ensureRepositoryUri, 1, __frame, function __$ensureRepositoryUri() {
+ function ensureRepositoryUri(context, _) { var siteData, repositoryUri; var __frame = { name: "ensureRepositoryUri", line: 607 }; return __func(_, this, arguments, ensureRepositoryUri, 1, __frame, function __$ensureRepositoryUri() {
return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 1, 19, function ___(__0, __1) { siteData = __1;
repositoryUri = (siteData && site.getRepositoryUri(siteData)); return (function __$ensureRepositoryUri(__then) {
if (!repositoryUri) {
@@ -619,7 +618,7 @@ exports.init = function(cli) {
site.ensureRepositoryUri = ensureRepositoryUri;
- site.command("delete [name]").whiteListPowershell().description("Delete a web site").option("-s, --subscription <id>", "use the subscription id").option("-q, --quiet", "quiet mode, do not ask for delete confirmation").execute(function __7(name, options, _) { var context, progress, result; var __frame = { name: "__7", line: 627 }; return __func(_, this, arguments, __7, 2, __frame, function __$__7() {
+ site.command("delete [name]").whiteListPowershell().description("Delete a web site").option("-s, --subscription <id>", "use the subscription id").option("-q, --quiet", "quiet mode, do not ask for delete confirmation").execute(function __7(name, options, _) { var context, progress, result; var __frame = { name: "__7", line: 626 }; return __func(_, this, arguments, __7, 2, __frame, function __$__7() {
@@ -635,7 +634,7 @@ exports.init = function(cli) {
return lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 10, function __$__7() {
log.info("Deleting site", context.site.name); return (function __$__7(_) {
- var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return confirm((("Delete " + context.site.name) + " site? (y/n) "), __cb(_, __frame, 11, 33, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -626, 17, function ___(__0, __2) { return (function __$__7(__then) { if (__2) { return _(null); } else { __then(); } ; })(function __$__7() {
+ var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return confirm((("Delete " + context.site.name) + " site? (y/n) "), __cb(_, __frame, 11, 33, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -625, 17, function ___(__0, __2) { return (function __$__7(__then) { if (__2) { return _(null); } else { __then(); } ; })(function __$__7() {
@@ -658,7 +657,7 @@ exports.init = function(cli) {
- site.command("start [name]").whiteListPowershell().description("Start a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __8(name, options, _) { var context, progress, result; var __frame = { name: "__8", line: 665 }; return __func(_, this, arguments, __8, 2, __frame, function __$__8() {
+ site.command("start [name]").whiteListPowershell().description("Start a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __8(name, options, _) { var context, progress, result; var __frame = { name: "__8", line: 664 }; return __func(_, this, arguments, __8, 2, __frame, function __$__8() {
@@ -709,7 +708,7 @@ exports.init = function(cli) {
log.info((("Site " + context.site.name) + " has been started")); _(); }); }); }, true)); }); });
- site.command("stop [name]").whiteListPowershell().description("Stop a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __9(name, options, _) { var context, progress, result; var __frame = { name: "__9", line: 716 }; return __func(_, this, arguments, __9, 2, __frame, function __$__9() {
+ site.command("stop [name]").whiteListPowershell().description("Stop a web site").option("-s, --subscription <id>", "use the subscription id").execute(function __9(name, options, _) { var context, progress, result; var __frame = { name: "__9", line: 715 }; return __func(_, this, arguments, __9, 2, __frame, function __$__9() {
@@ -764,19 +763,19 @@ exports.init = function(cli) {
- site.readConfig = function site_readConfig__10(_) { var __frame = { name: "site_readConfig__10", line: 767 }; return __func(_, this, arguments, site_readConfig__10, 0, __frame, function __$site_readConfig__10() {
+ site.readConfig = function site_readConfig__10(_) { var __frame = { name: "site_readConfig__10", line: 766 }; return __func(_, this, arguments, site_readConfig__10, 0, __frame, function __$site_readConfig__10() {
return site.readConfigValue("azure.site.name", __cb(_, __frame, 2, 12, function ___(__0, __2) {
return site.readConfigValue("azure.site.webspace", __cb(_, __frame, 3, 16, function ___(__0, __3) { var __1 = { name: __2, webspace: __3 }; return _(null, __1); }, true)); }, true)); }); };
- site.writeConfig = function site_writeConfig__11(cfg, _) { var __frame = { name: "site_writeConfig__11", line: 774 }; return __func(_, this, arguments, site_writeConfig__11, 1, __frame, function __$site_writeConfig__11() {
+ site.writeConfig = function site_writeConfig__11(cfg, _) { var __frame = { name: "site_writeConfig__11", line: 773 }; return __func(_, this, arguments, site_writeConfig__11, 1, __frame, function __$site_writeConfig__11() {
return site.writeConfigValue("azure.site.name", cfg.name, __cb(_, __frame, 1, 4, function __$site_writeConfig__11() {
return site.writeConfigValue("azure.site.webspace", cfg.webspace, __cb(_, __frame, 2, 4, _, true)); }, true)); }); };
- site.readConfigValue = function site_readConfigValue__12(name, _) { var result; var __frame = { name: "site_readConfigValue__12", line: 779 }; return __func(_, this, arguments, site_readConfigValue__12, 1, __frame, function __$site_readConfigValue__12() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_readConfigValue__12() {
+ site.readConfigValue = function site_readConfigValue__12(name, _) { var result; var __frame = { name: "site_readConfigValue__12", line: 778 }; return __func(_, this, arguments, site_readConfigValue__12, 1, __frame, function __$site_readConfigValue__12() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_readConfigValue__12() {
return exec(("git config --get " + name), __cb(_, __frame, 2, 19, function ___(__0, __1) { result = __1;
return _(null, ((result.stdout + result.stderr)).trim()); }, true)); }); })(function ___(err, __result) { __tryCatch(_, function __$site_readConfigValue__12() { if (err) {
@@ -787,7 +786,7 @@ exports.init = function(cli) {
- site.writeConfigValue = function site_writeConfigValue__13(name, value, _) { var __frame = { name: "site_writeConfigValue__13", line: 790 }; return __func(_, this, arguments, site_writeConfigValue__13, 2, __frame, function __$site_writeConfigValue__13() {
+ site.writeConfigValue = function site_writeConfigValue__13(name, value, _) { var __frame = { name: "site_writeConfigValue__13", line: 789 }; return __func(_, this, arguments, site_writeConfigValue__13, 2, __frame, function __$site_writeConfigValue__13() {
return exec(((("git config " + name) + " ") + value), __cb(_, __frame, 1, 4, _, true)); }); };
@@ -885,7 +884,7 @@ exports.init = function(cli) {
- site.doSpacesGet = function site_doSpacesGet__14(options, _) { var progress, result, spaces; var __frame = { name: "site_doSpacesGet__14", line: 888 }; return __func(_, this, arguments, site_doSpacesGet__14, 1, __frame, function __$site_doSpacesGet__14() {
+ site.doSpacesGet = function site_doSpacesGet__14(options, _) { var progress, result, spaces; var __frame = { name: "site_doSpacesGet__14", line: 887 }; return __func(_, this, arguments, site_doSpacesGet__14, 1, __frame, function __$site_doSpacesGet__14() {
log.verbose("Subscription", options.subscription);
progress = cli.progress("Enumerating locations"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doSpacesGet__14() {
@@ -907,7 +906,7 @@ exports.init = function(cli) {
- site.doSitesGet = function site_doSitesGet__15(options, _) { var spaces, channel, progress, result, sites; var __frame = { name: "site_doSitesGet__15", line: 910 }; return __func(_, this, arguments, site_doSitesGet__15, 1, __frame, function __$site_doSitesGet__15() {
+ site.doSitesGet = function site_doSitesGet__15(options, _) { var spaces, channel, progress, result, sites; var __frame = { name: "site_doSitesGet__15", line: 909 }; return __func(_, this, arguments, site_doSitesGet__15, 1, __frame, function __$site_doSitesGet__15() {
log.verbose("Subscription", options.subscription);
return site.doSpacesGet(options, __cb(_, __frame, 3, 17, function ___(__0, __2) { spaces = __2;
@@ -919,7 +918,7 @@ exports.init = function(cli) {
progress = cli.progress("Enumerating sites"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doSitesGet__15() {
- return async.map(spaces, function __1(webspace, _) { var __frame = { name: "__1", line: 924 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
+ return async.map(spaces, function __1(webspace, _) { var __frame = { name: "__1", line: 923 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
@@ -998,13 +997,35 @@ exports.init = function(cli) {
- site.doRepositoryGet = function site_doRepositoryGet__16(options, _) { var siteData; var __frame = { name: "site_doRepositoryGet__16", line: 1001 }; return __func(_, this, arguments, site_doRepositoryGet__16, 1, __frame, function __$site_doRepositoryGet__16() {
+ site.doSiteConfigPUT = function site_doSiteConfigPUT__16(config, options, _) { var progress, xmlConfig; var __frame = { name: "site_doSiteConfigPUT__16", line: 1000 }; return __func(_, this, arguments, site_doSiteConfigPUT__16, 2, __frame, function __$site_doSiteConfigPUT__16() {
+ progress = cli.progress("Updating site config information");
+
+ if (!config.SiteConfig) {
+ config = { SiteConfig: config }; } ;
+
+
+ xmlConfig = js2xml.serialize(config);
+
+
+
+
+
+
+
+
+ return getChannel().path(options.subscription).path("services").path("webspaces").path(options.site.webspace).path("sites").path(options.site.name).path("config").PUT(function(req) {
+ req.write(xmlConfig);
+ req.end(); }, __cb(_, __frame, 16, 4, _, true)); }); };
+
+
+
+ site.doRepositoryGet = function site_doRepositoryGet__17(options, _) { var siteData; var __frame = { name: "site_doRepositoryGet__17", line: 1022 }; return __func(_, this, arguments, site_doRepositoryGet__17, 1, __frame, function __$site_doRepositoryGet__17() {
return site.doSiteGet(options, __cb(_, __frame, 1, 19, function ___(__0, __1) { siteData = __1;
return _(null, getRepositoryUri(siteData)); }, true)); }); };
- site.doPublishingUsersGet = function site_doPublishingUsersGet__17(options, _) { var progress, publishingUsers; var __frame = { name: "site_doPublishingUsersGet__17", line: 1006 }; return __func(_, this, arguments, site_doPublishingUsersGet__17, 1, __frame, function __$site_doPublishingUsersGet__17() {
- progress = cli.progress("Retrieving user information"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doPublishingUsersGet__17() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doPublishingUsersGet__17() {
+ site.doPublishingUsersGet = function site_doPublishingUsersGet__18(options, _) { var progress, publishingUsers; var __frame = { name: "site_doPublishingUsersGet__18", line: 1027 }; return __func(_, this, arguments, site_doPublishingUsersGet__18, 1, __frame, function __$site_doPublishingUsersGet__18() {
+ progress = cli.progress("Retrieving user information"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doPublishingUsersGet__18() { return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$site_doPublishingUsersGet__18() {
@@ -1016,10 +1037,10 @@ exports.init = function(cli) {
return getChannel().path(options.subscription).path("services").path("webspaces").path("").query("properties", "publishingUsers").GET(__cb(_, __frame, 10, 36, function ___(__0, __1) { publishingUsers = clean(__1);
log.verbose("PublishingUsers", publishingUsers);
- return _(null, publishingUsers); }, true)); }); })(function ___(e, __result) { __tryCatch(_, function __$site_doPublishingUsersGet__17() { if (e) {
+ return _(null, publishingUsers); }, true)); }); })(function ___(e, __result) { __tryCatch(_, function __$site_doPublishingUsersGet__18() { if (e) {
- return _(null, ["","",]); } else { _(null, __result); } ; }); }); })(function ___() { __tryCatch(_, function __$site_doPublishingUsersGet__17() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doPublishingUsersGet__17() {
+ return _(null, ["","",]); } else { _(null, __result); } ; }); }); })(function ___() { __tryCatch(_, function __$site_doPublishingUsersGet__18() { _(null, null, true); }); }); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$site_doPublishingUsersGet__18() {
View
23 lib/cli/commands/site_.js
@@ -26,6 +26,7 @@ var child_process = require('child_process');
var utils = require('../utils');
var constants = require('../constants');
var cacheUtils = require('../cacheUtils');
+var js2xml = require('../../util/js2xml');
var linkedRevisionControl = require('../linkedrevisioncontrol');
@@ -998,6 +999,28 @@ exports.init = function (cli) {
});
};
+ site.doSiteConfigPUT = function (config, options, _) {
+ var progress = cli.progress('Updating site config information');
+
+ if (!config.SiteConfig) {
+ config = { SiteConfig: config };
+ }
+
+ var xmlConfig = js2xml.serialize(config);
+ getChannel()
+ .path(options.subscription)
+ .path('services')
+ .path('webspaces')
+ .path(options.site.webspace)
+ .path('sites')
+ .path(options.site.name)
+ .path('config')
+ .PUT(function (req) {
+ req.write(xmlConfig);
+ req.end();
+ }, _);
+ };
+
site.doRepositoryGet = function (options, _) {
var siteData = site.doSiteGet(options, _);
return getRepositoryUri(siteData);
View
176 lib/cli/commands/siteconfig.js
@@ -0,0 +1,176 @@
+/*** Generated by streamline 0.4.5 (callbacks) - DO NOT EDIT ***/ var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=__rt.__func,__cb=__rt.__cb; var connectionStringParser = require("../../services/core/connectionstringparser");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+var linkedRevisionControl = require("../linkedrevisioncontrol");
+
+exports.init = function(cli) {
+
+ var log = cli.output;
+ var site = cli.category("site");
+ var siteConfig = site.category("config").description("Commands to manage your site configurations");
+
+
+ siteConfig.command("list [name]").usage("[options] [name]").description("Show your site application settings").option("-s, --subscription <id>", "use the subscription id").execute(function __1(name, options, _) { var context, siteConfigurations; var __frame = { name: "__1", line: 30 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
+
+
+
+
+ context = {
+ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
+ site: {
+ name: name } };
+
+
+
+ return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 8, 6, function __$__1() {
+
+ return site.doSiteConfigGet(context, __cb(_, __frame, 10, 31, function ___(__0, __1) { siteConfigurations = __1;
+ if (siteConfigurations.AppSettings.NameValuePair) {
+ siteConfigurations.AppSettings = getSettings(siteConfigurations.AppSettings);
+
+ log.table(siteConfigurations.AppSettings.NameValuePair, function(row, item) {
+ row.cell("Name", item.Name);
+ row.cell("Value", item.Value); }); }
+
+ else {
+ log.info("No app settings defined yet. You can define app settings using \"azure site config set <name>=<value>."); } ; _(); }, true)); }, true)); }); });
+
+
+
+ siteConfig.command("add <keyvaluepair> [name]").usage("[options] <keyvaluepair> [name]").description("Adds an application setting for your site").option("-s, --subscription <id>", "use the subscription id").execute(function __2(keyvaluepair, name, options, _) { var context, settings, siteConfigurations, setting; var __frame = { name: "__2", line: 57 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
+
+
+
+
+ context = {
+ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
+ site: {
+ name: name },
+
+ keyvaluepair: keyvaluepair };
+
+
+ settings = connectionStringParser.parse(context.keyvaluepair);
+
+ return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 11, 6, function __$__2() {
+ return site.doSiteConfigGet(context, __cb(_, __frame, 12, 31, function ___(__0, __1) { siteConfigurations = __1;
+
+ if ((Object.keys(settings).length > 0)) {
+ siteConfigurations.AppSettings = getSettings(siteConfigurations.AppSettings);
+
+ for (setting in settings) {
+ if (settings.hasOwnProperty(setting)) {
+ if (siteConfigurations.AppSettings.NameValuePair.some(function(kvp) {
+ return (kvp.Name === setting);
+ })) {
+
+ return _(new Error((("Application setting with key \"" + setting) + "\" already exists."))); } ;
+
+
+ siteConfigurations.AppSettings.NameValuePair.push({
+ Name: setting,
+ Value: settings[setting] }); } ; }; } ;
+
+
+
+
+
+ return site.doSiteConfigPUT(siteConfigurations, context, __cb(_, __frame, 34, 6, _, true)); }, true)); }, true)); }); });
+
+
+ siteConfig.command("clear <key> [name]").usage("[options] <key> [name]").description("Clears an application setting for your site").option("-s, --subscription <id>", "use the subscription id").execute(function __3(key, name, options, _) { var context, siteConfigurations, found, i; var __frame = { name: "__3", line: 98 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() {
+
+
+
+
+ context = {
+ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
+ site: {
+ name: name },
+
+ key: key };
+
+
+ return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 9, 6, function __$__3() {
+ return site.doSiteConfigGet(context, __cb(_, __frame, 10, 31, function ___(__0, __1) { siteConfigurations = __1;
+
+ found = false; return (function __$__3(__then) {
+ if (siteConfigurations.AppSettings.NameValuePair) {
+ siteConfigurations.AppSettings = getSettings(siteConfigurations.AppSettings);
+
+ for (i = 0; (i < siteConfigurations.AppSettings.NameValuePair.length); i++) {
+ if ((siteConfigurations.AppSettings.NameValuePair[i].Name === key)) {
+ siteConfigurations.AppSettings.NameValuePair.splice(i, 1);
+ found = true;
+ i--; } ; }; return (function __$__3(__then) {
+
+
+
+ if (found) {
+ if ((siteConfigurations.AppSettings.NameValuePair.length === 0)) {
+ siteConfigurations.AppSettings = { }; } ;
+
+
+ return site.doSiteConfigPUT(siteConfigurations, context, __cb(_, __frame, 29, 10, __then, true)); } else { __then(); } ; })(__then); } else { __then(); } ; })(function __$__3() {
+
+
+
+ if (!found) {
+ return _(Error((("Application setting with key \"" + key) + "\" does not exist."))); } ; _(); }); }, true)); }, true)); }); });
+
+
+
+ siteConfig.command("get <key> [name]").usage("[options] <key> [name]").description("Gets an application setting for your site").option("-s, --subscription <id>", "use the subscription id").execute(function __4(key, name, options, _) { var context, siteConfigurations, found, i; var __frame = { name: "__4", line: 140 }; return __func(_, this, arguments, __4, 3, __frame, function __$__4() {
+
+
+
+
+ context = {
+ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
+ site: {
+ name: name },
+
+ key: key };
+
+
+ return site.lookupSiteNameAndWebSpace(context, __cb(_, __frame, 9, 6, function __$__4() {
+ return site.doSiteConfigGet(context, __cb(_, __frame, 10, 31, function ___(__0, __1) { siteConfigurations = __1;
+
+ found = false;
+ if (siteConfigurations.AppSettings.NameValuePair) {
+ siteConfigurations.AppSettings = getSettings(siteConfigurations.AppSettings);
+
+ for (i = 0; (i < siteConfigurations.AppSettings.NameValuePair.length); i++) {
+ if ((siteConfigurations.AppSettings.NameValuePair[i].Name === key)) {
+ log.data("Value: ", siteConfigurations.AppSettings.NameValuePair[i].Value); return _(null); } ; }; } ;
+
+
+
+
+
+ if (!found) {
+ return _(Error((("Application setting with key \"" + key) + "\" does not exist."))); } ; _(); }, true)); }, true)); }); });
+
+
+
+ function getSettings(appSettings) {
+ if (!appSettings.NameValuePair) {
+ appSettings.NameValuePair = []; }
+ else if (appSettings.NameValuePair.Name) {
+ appSettings.NameValuePair = [appSettings.NameValuePair,]; } ;
+
+
+ return appSettings; };};
View
178 lib/cli/commands/siteconfig_.js
@@ -0,0 +1,178 @@
+/**
+* Copyright (c) Microsoft. All rights reserved.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+var connectionStringParser = require('../../services/core/connectionstringparser');
+var linkedRevisionControl = require('../linkedrevisioncontrol');
+
+exports.init = function (cli) {
+
+ var log = cli.output;
+ var site = cli.category('site');
+ var siteConfig = site.category('config')
+ .description('Commands to manage your site configurations');
+
+ siteConfig.command('list [name]')
+ .usage('[options] [name]')
+ .description('Show your site application settings')
+ .option('-s, --subscription <id>', 'use the subscription id')
+ .execute(function (name, options, _) {
+ var context = {
+ subscription: cli.category('account').lookupSubscriptionId(options.subscription),
+ site: {
+ name: name
+ }
+ };
+
+ site.lookupSiteNameAndWebSpace(context, _);
+
+ var siteConfigurations = site.doSiteConfigGet(context, _);
+ if (siteConfigurations.AppSettings.NameValuePair) {
+ siteConfigurations.AppSettings = getSettings(siteConfigurations.AppSettings);
+
+ log.table(siteConfigurations.AppSettings.NameValuePair, function (row, item) {
+ row.cell('Name', item.Name);
+ row.cell('Value', item.Value);
+ });
+ } else {
+ log.info('No app settings defined yet. You can define app settings using "azure site config set <name>=<value>.');
+ }
+ });
+
+ siteConfig.command('add <keyvaluepair> [name]')
+ .usage('[options] <keyvaluepair> [name]')
+ .description('Adds an application setting for your site')
+ .option('-s, --subscription <id>', 'use the subscription id')
+ .execute(function (keyvaluepair, name, options, _) {
+ var context = {
+ subscription: cli.category('account').lookupSubscriptionId(options.subscription),
+ site: {
+ name: name
+ },
+ keyvaluepair: keyvaluepair
+ };
+
+ var settings = connectionStringParser.parse(context.keyvaluepair);
+
+ site.lookupSiteNameAndWebSpace(context, _);
+ var siteConfigurations = site.doSiteConfigGet(context, _);
+
+ if (Object.keys(settings).length > 0) {
+ siteConfigurations.AppSettings = getSettings(siteConfigurations.AppSettings);
+
+ for (var setting in settings) {
+ if (settings.hasOwnProperty(setting)) {
+ if (siteConfigurations.AppSettings.NameValuePair.some(function (kvp) {
+ return kvp.Name === setting;
+ })) {
+ // add should throw if any of the added kvp already exists
+ throw new Error('Application setting with key "' + setting + '" already exists.');
+ }
+
+ siteConfigurations.AppSettings.NameValuePair.push({
+ Name: setting,
+ Value: settings[setting]
+ });
+ }
+ }
+ }
+
+ site.doSiteConfigPUT(siteConfigurations, context, _);
+ });
+
+ siteConfig.command('clear <key> [name]')
+ .usage('[options] <key> [name]')
+ .description('Clears an application setting for your site')
+ .option('-s, --subscription <id>', 'use the subscription id')
+ .execute(function (key, name, options, _) {
+ var context = {
+ subscription: cli.category('account').lookupSubscriptionId(options.subscription),
+ site: {
+ name: name
+ },
+ key: key
+ };
+
+ site.lookupSiteNameAndWebSpace(context, _);
+ var siteConfigurations = site.doSiteConfigGet(context, _);
+
+ var found = false;
+ if (siteConfigurations.AppSettings.NameValuePair) {
+ siteConfigurations.AppSettings = getSettings(siteConfigurations.AppSettings);
+
+ for (var i = 0; i < siteConfigurations.AppSettings.NameValuePair.length; i++) {
+ if (siteConfigurations.AppSettings.NameValuePair[i].Name === key) {
+ siteConfigurations.AppSettings.NameValuePair.splice(i, 1);
+ found = true;
+ i--;
+ }
+ }
+
+ if (found) {
+ if (siteConfigurations.AppSettings.NameValuePair.length === 0) {
+ siteConfigurations.AppSettings = { };
+ }
+
+ site.doSiteConfigPUT(siteConfigurations, context, _);
+ }
+ }
+
+ if (!found) {
+ throw Error('Application setting with key "' + key + '" does not exist.')
+ }
+ });
+
+ siteConfig.command('get <key> [name]')
+ .usage('[options] <key> [name]')
+ .description('Gets an application setting for your site')
+ .option('-s, --subscription <id>', 'use the subscription id')
+ .execute(function (key, name, options, _) {
+ var context = {
+ subscription: cli.category('account').lookupSubscriptionId(options.subscription),
+ site: {
+ name: name
+ },
+ key: key
+ };
+
+ site.lookupSiteNameAndWebSpace(context, _);
+ var siteConfigurations = site.doSiteConfigGet(context, _);
+
+ var found = false;
+ if (siteConfigurations.AppSettings.NameValuePair) {
+ siteConfigurations.AppSettings = getSettings(siteConfigurations.AppSettings);
+
+ for (var i = 0; i < siteConfigurations.AppSettings.NameValuePair.length; i++) {
+ if (siteConfigurations.AppSettings.NameValuePair[i].Name === key) {
+ log.data('Value: ', siteConfigurations.AppSettings.NameValuePair[i].Value);
+ return;
+ }
+ }
+ }
+
+ if (!found) {
+ throw Error('Application setting with key "' + key + '" does not exist.')
+ }
+ });
+
+ function getSettings(appSettings) {
+ if (!appSettings.NameValuePair) {
+ appSettings.NameValuePair = [ ];
+ } else if (appSettings.NameValuePair.Name) {
+ appSettings.NameValuePair = [ appSettings.NameValuePair ];
+ }
+
+ return appSettings;
+ };
+};
View
102 lib/cli/linkedrevisioncontrol.js
@@ -59,7 +59,20 @@ LinkedRevisionControlClient._getRepository = function(repositories, remoteFullNa
-LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTree = function LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1(context, _) { var isInsideWorkTree, lines, __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1", line: 62 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1, 1, __frame, function __$LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1() {
+
+
+
+
+LinkedRevisionControlClient._getRepositoryCloneUrl = function(repositories, remoteUri) {
+ return repositories.filter(function(repository) {
+ return (repository.clone_url.toLowerCase() === remoteUri.toLowerCase());
+ })[0];};
+
+
+
+
+
+LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTree = function LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1(context, _) { var isInsideWorkTree, lines, __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1", line: 75 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1, 1, __frame, function __$LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1() {
__this.log.silly("determineIfCurrentDirectoryIsGitWorkingTree"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1() {
@@ -80,7 +93,7 @@ LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTre
-LinkedRevisionControlClient.prototype.initGitOnCurrentDirectory = function LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2(context, scaffold, _) { var __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2", line: 83 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2, 2, __frame, function __$LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2() {
+LinkedRevisionControlClient.prototype.initGitOnCurrentDirectory = function LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2(context, scaffold, _) { var __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2", line: 96 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2, 2, __frame, function __$LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2() {
__this.log.silly("initGitOnCurrentDirectoryIfNeeded");
if (context.flags.isGitWorkingTree) { return _(null); } ;
@@ -112,12 +125,12 @@ function GitClient(cli) {
util.inherits(GitClient, LinkedRevisionControlClient);
-GitClient.prototype.init = function GitClient_prototype_init__3(context, _) { var __this = this; var __frame = { name: "GitClient_prototype_init__3", line: 115 }; return __func(_, this, arguments, GitClient_prototype_init__3, 1, __frame, function __$GitClient_prototype_init__3() {
+GitClient.prototype.init = function GitClient_prototype_init__3(context, _) { var __this = this; var __frame = { name: "GitClient_prototype_init__3", line: 128 }; return __func(_, this, arguments, GitClient_prototype_init__3, 1, __frame, function __$GitClient_prototype_init__3() {
return __this.determineIfCurrentDirectoryIsGitWorkingTree(context, __cb(_, __frame, 1, 2, function __$GitClient_prototype_init__3() {
return __this.initGitOnCurrentDirectory(context, true, __cb(_, __frame, 2, 2, _, true)); }, true)); });};
-GitClient.prototype.deploy = function GitClient_prototype_deploy__4(context, _) { var __frame = { name: "GitClient_prototype_deploy__4", line: 120 }; return __func(_, this, arguments, GitClient_prototype_deploy__4, 1, __frame, _);};
+GitClient.prototype.deploy = function GitClient_prototype_deploy__4(context, _) { var __frame = { name: "GitClient_prototype_deploy__4", line: 133 }; return __func(_, this, arguments, GitClient_prototype_deploy__4, 1, __frame, _);};
@@ -129,7 +142,7 @@ function GithubClient(cli) {
util.inherits(GithubClient, LinkedRevisionControlClient);
-GithubClient.prototype.authenticate = function GithubClient_prototype_authenticate__5(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_authenticate__5", line: 132 }; return __func(_, this, arguments, GithubClient_prototype_authenticate__5, 1, __frame, function __$GithubClient_prototype_authenticate__5() {
+GithubClient.prototype.authenticate = function GithubClient_prototype_authenticate__5(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_authenticate__5", line: 145 }; return __func(_, this, arguments, GithubClient_prototype_authenticate__5, 1, __frame, function __$GithubClient_prototype_authenticate__5() {
return __this.ensureCredentials(context, __cb(_, __frame, 1, 2, function __$GithubClient_prototype_authenticate__5() {
__this.client.authenticate({
@@ -139,7 +152,7 @@ GithubClient.prototype.authenticate = function GithubClient_prototype_authentica
-GithubClient.prototype.authenticateAuth = function GithubClient_prototype_authenticateAuth__6(context, _) { var oauthToken, __this = this; var __frame = { name: "GithubClient_prototype_authenticateAuth__6", line: 142 }; return __func(_, this, arguments, GithubClient_prototype_authenticateAuth__6, 1, __frame, function __$GithubClient_prototype_authenticateAuth__6() {
+GithubClient.prototype.authenticateAuth = function GithubClient_prototype_authenticateAuth__6(context, _) { var oauthToken, __this = this; var __frame = { name: "GithubClient_prototype_authenticateAuth__6", line: 155 }; return __func(_, this, arguments, GithubClient_prototype_authenticateAuth__6, 1, __frame, function __$GithubClient_prototype_authenticateAuth__6() {
return __this.ensureCredentials(context, __cb(_, __frame, 1, 2, function __$GithubClient_prototype_authenticateAuth__6() {
__this.client.authenticate({
@@ -156,7 +169,7 @@ GithubClient.prototype.authenticateAuth = function GithubClient_prototype_authen
-GithubClient.prototype.ensureCredentials = function GithubClient_prototype_ensureCredentials__7(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_ensureCredentials__7", line: 159 }; return __func(_, this, arguments, GithubClient_prototype_ensureCredentials__7, 1, __frame, function __$GithubClient_prototype_ensureCredentials__7() {
+GithubClient.prototype.ensureCredentials = function GithubClient_prototype_ensureCredentials__7(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_ensureCredentials__7", line: 172 }; return __func(_, this, arguments, GithubClient_prototype_ensureCredentials__7, 1, __frame, function __$GithubClient_prototype_ensureCredentials__7() {
if (!context.github) {
context.github = { }; } ;
@@ -174,7 +187,7 @@ GithubClient.prototype.ensureCredentials = function GithubClient_prototype_ensur
-GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _) { var repositories, __this = this; var __frame = { name: "GithubClient_prototype_init__8", line: 177 }; return __func(_, this, arguments, GithubClient_prototype_init__8, 1, __frame, function __$GithubClient_prototype_init__8() {
+GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _) { var repositories, remoteUris, __this = this; var __frame = { name: "GithubClient_prototype_init__8", line: 190 }; return __func(_, this, arguments, GithubClient_prototype_init__8, 1, __frame, function __$GithubClient_prototype_init__8() {
return __this.authenticate(context, __cb(_, __frame, 1, 2, function __$GithubClient_prototype_init__8() {
@@ -183,59 +196,46 @@ GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _
return __this.getRepositories(context.github.username, __cb(_, __frame, 8, 21, function ___(__0, __1) { repositories = __1; return (function __$GithubClient_prototype_init__8(__then) {
- if ((!((context.flags && context.flags.forceRepositorySelection)) && !context.github.repositoryFullName)) {
-
-
- return __this._getRemoteUri(__cb(_, __frame, 12, 40, function ___(__0, __2) { context.github.repositoryFullName = __2; __then(); }, true)); } else { __then(); } ; })(function __$GithubClient_prototype_init__8() {
-
-
if (context.github.repositoryFullName) {
context.github.repository = LinkedRevisionControlClient._getRepository(repositories, context.github.repositoryFullName);
if (!context.github.repository) {
- __this.log.info(("Invalid repository " + context.github.repositoryFullName)); } ; } ; return (function __$GithubClient_prototype_init__8(__then) {
+ __this.log.info(("Invalid repository " + context.github.repositoryFullName)); } ; __then(); } else { return (function __$GithubClient_prototype_init__8(__then) {
+ if (!((context.flags && context.flags.forceRepositorySelection))) {
- if (!context.github.repository) {
-
- __this.log.help("Choose a repository");
- return choose(__this.cli, repositories.map(function(repository) {
- return repository.full_name; }), __cb(_, __frame, 27, 45, function ___(__0, __3) { context.github.repository = repositories[__3]; __then(); }, true)); } else { __then(); } ; })(_); }); }, true)); }, true)); }, true)); }, true)); });};
-
+ return __this._getRemoteUris(__cb(_, __frame, 20, 21, function ___(__0, __2) { remoteUris = __2;
+ if ((remoteUris.length === 1)) {
+ context.github.repository = LinkedRevisionControlClient._getRepositoryCloneUrl(repositories, remoteUris[0]); }
+ else {
-GithubClient.prototype.deploy = function GithubClient_prototype_deploy__9(context, _) { var parsedCloneUrl, gitUri, azureRemote, __this = this; var __frame = { name: "GithubClient_prototype_deploy__9", line: 210 }; return __func(_, this, arguments, GithubClient_prototype_deploy__9, 1, __frame, function __$GithubClient_prototype_deploy__9() {
- return context.lvcClient.createOrUpdateHook(context.github.repository.owner.login, context.github.repository.name, context.repositoryUri, context.repositoryAuth, __cb(_, __frame, 1, 2, function __$GithubClient_prototype_deploy__9() {
+ repositories = repositories.filter(function(repository) {
+ return remoteUris.some(function(remoteUri) {
+ return (remoteUri === repository.clone_url); }); }); } ; __then(); }, true)); } else { __then(); } ; })(__then); } ; })(function __$GithubClient_prototype_init__8() { return (function __$GithubClient_prototype_init__8(__then) {
+ if (!context.github.repository) {
- parsedCloneUrl = url.parse(context.github.repository.clone_url);
- parsedCloneUrl.auth = context.username;
- gitUri = url.format(parsedCloneUrl); return (function __$GithubClient_prototype_deploy__9(__then) {
-
+ __this.log.help("Choose a repository");
+ return choose(__this.cli, repositories.map(function(repository) {
+ return repository.full_name; }), __cb(_, __frame, 37, 45, function ___(__0, __3) { context.github.repository = repositories[__3]; __then(); }, true)); } else { __then(); } ; })(_); }); }, true)); }, true)); }, true)); }, true)); });};
- if ((context.github.repositoryFullName && (context.github.repositoryFullName.toLowerCase() !== gitUri.toLowerCase()))) {
- context.github.repositoryFullName = null;
- return __this._getRemote("azure", __cb(_, __frame, 18, 22, function ___(__0, __1) { azureRemote = __1; return (function __$GithubClient_prototype_deploy__9(__then) {
- if (azureRemote) {
- __this.log.verbose("Removing existing azure remote alias");
- return __this._exec("git remote rm azure", __cb(_, __frame, 21, 6, __then, true)); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$GithubClient_prototype_deploy__9() { return (function __$GithubClient_prototype_deploy__9(__then) {
+GithubClient.prototype.deploy = function GithubClient_prototype_deploy__9(context, _) { var __frame = { name: "GithubClient_prototype_deploy__9", line: 233 }; return __func(_, this, arguments, GithubClient_prototype_deploy__9, 1, __frame, function __$GithubClient_prototype_deploy__9() {
+ return context.lvcClient.createOrUpdateHook(context.github.repository.owner.login, context.github.repository.name, context.repositoryUri, context.repositoryAuth, __cb(_, __frame, 2, 2, _, true)); });};
- if (!context.github.repositoryFullName) {
- __this.log.info((("Executing `git remote add azure " + gitUri) + "`"));
- return __this._exec(("git remote add azure " + gitUri), __cb(_, __frame, 28, 4, __then, true)); } else { __then(); } ; })(_); }); }, true)); });};
@@ -379,35 +379,31 @@ GithubClient.prototype.getHooks = function GithubClient_prototype_getHooks__15(u
-GithubClient.prototype._getRemoteUri = function GithubClient_prototype__getRemoteUri__16(_) { var progress, originUri, __this = this; var __frame = { name: "GithubClient_prototype__getRemoteUri__16", line: 382 }; return __func(_, this, arguments, GithubClient_prototype__getRemoteUri__16, 0, __frame, function __$GithubClient_prototype__getRemoteUri__16() {
+GithubClient.prototype._getRemoteUris = function GithubClient_prototype__getRemoteUris__16(_) { var progress, remoteUris, remotes, __this = this; var __frame = { name: "GithubClient_prototype__getRemoteUris__16", line: 382 }; return __func(_, this, arguments, GithubClient_prototype__getRemoteUris__16, 0, __frame, function __$GithubClient_prototype__getRemoteUris__16() {
progress = __this.cli.progress("Retrieving local git repositories");
- originUri = null; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype__getRemoteUri__16() {
-
-
- return __this._getRemote("azure", __cb(_, __frame, 5, 16, function ___(__0, __1) { originUri = __1; return (function __$GithubClient_prototype__getRemoteUri__16(__then) {
- if (!originUri) {
- return __this._getRemote("origin", __cb(_, __frame, 7, 18, function ___(__0, __2) { originUri = __2; __then(); }, true)); } else { __then(); } ; })(function __$GithubClient_prototype__getRemoteUri__16() { _(null, null, true); }); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$GithubClient_prototype__getRemoteUri__16() {
+ remoteUris = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype__getRemoteUris__16() {
+ return __this._exec("git remote -v", __cb(_, __frame, 4, 18, function ___(__0, __1) { remotes = __1;
+ remoteUris = ((remotes.stdout + remotes.stderr)).split("\n").filter(function(line) {
- progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$GithubClient_prototype__getRemoteUri__16() {
+ return (line.length > 0);
+ }).map(function(item) {
+ return item.split(" ")[1].split(" ")[0]; });
- return _(null, originUri); }); }); });};
+ remoteUris = removeDuplicates(remoteUris); _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$GithubClient_prototype__getRemoteUris__16() {
-GithubClient.prototype._getRemote = function GithubClient_prototype__getRemote__17(name, _) { var remotes, origin, __this = this; var __frame = { name: "GithubClient_prototype__getRemote__17", line: 398 }; return __func(_, this, arguments, GithubClient_prototype__getRemote__17, 1, __frame, function __$GithubClient_prototype__getRemote__17() {
- return __this._exec("git remote -v", __cb(_, __frame, 1, 16, function ___(__0, __1) { remotes = __1;
- origin = ((remotes.stdout + remotes.stderr)).split("\n").filter(function(item) {
- return item.split(" ").some(function(it) {
- return (it === name); }); });
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$GithubClient_prototype__getRemoteUris__16() {
+ return _(null, remoteUris); }); }); });};
- if ((origin && (origin.length > 0))) {
- return _(null, origin[0].split(" ")[1].split(" ")[0]); } ;
+function removeDuplicates(array) {
+ return array.filter(function(elem, pos) {
+ return (array.indexOf(elem) === pos); });};
- return _(null, null); }, true)); });};
function choose(cli, data, callback) {
View
102 lib/cli/linkedrevisioncontrol_.js
@@ -44,7 +44,7 @@ function LinkedRevisionControlClient(cli) {
}
/**
-* Returns a specific repository based on its github uri.
+* Returns a specific repository based on its github full name.
*
* @param {array} repositories The list of github repositories.
* @param {string} remoteFullName The repository full name.
@@ -57,6 +57,19 @@ LinkedRevisionControlClient._getRepository = function (repositories, remoteFullN
};
/**
+* Returns a specific repository based on its github clone uri.
+*
+* @param {array} repositories The list of github repositories.
+* @param {string} remoteUri The repository clone url.
+*
+*/
+LinkedRevisionControlClient._getRepositoryCloneUrl = function (repositories, remoteUri) {
+ return repositories.filter(function (repository) {
+ return repository.clone_url.toLowerCase() === remoteUri.toLowerCase();
+ })[0];
+};
+
+/**
* Determines if the current directory is within a git repository tree.
*/
LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTree = function (context, _) {
@@ -183,19 +196,29 @@ GithubClient.prototype.init = function (context, _) {
// Find github repository
var repositories = this.getRepositories(context.github.username, _);
- if (!(context.flags && context.flags.forceRepositorySelection) && !context.github.repositoryFullName) {
- // Unless the user forced the command to prompt for repository or passed a repository
- // as a parameter, try to find a github repository as a remote on the local folder
- context.github.repositoryFullName = this._getRemoteUri(_);
- }
-
if (context.github.repositoryFullName) {
- // Match either the repository passed as parameter or the local folder remote git repository
+ // Match the repository passed as parameter
// against the list of github repositories for the current github user
context.github.repository = LinkedRevisionControlClient._getRepository(repositories, context.github.repositoryFullName);
if (!context.github.repository) {
this.log.info('Invalid repository ' + context.github.repositoryFullName);
}
+ } else if (!(context.flags && context.flags.forceRepositorySelection)) {
+ // Unless the user forced the command to prompt for repository or passed a repository
+ // as a parameter, try to find a github repository as a remote on the local folder
+ // before actually prompting
+ var remoteUris = this._getRemoteUris(_);
+
+ if (remoteUris.length === 1) {
+ context.github.repository = LinkedRevisionControlClient._getRepositoryCloneUrl(repositories, remoteUris[0]);
+ } else {
+ // filter repositories to reduce prompt options
+ repositories = repositories.filter(function (repository) {
+ return remoteUris.some(function (remoteUri) {
+ return remoteUri === repository.clone_url;
+ });
+ });
+ }
}
if (!context.github.repository) {
@@ -208,35 +231,12 @@ GithubClient.prototype.init = function (context, _) {
};
GithubClient.prototype.deploy = function (context, _) {
+ // Add / update hook and trigger it
context.lvcClient.createOrUpdateHook(context.github.repository.owner.login,
context.github.repository.name,
context.repositoryUri,
context.repositoryAuth,
_);
-
- // Append the username to the git url
- var parsedCloneUrl = url.parse(context.github.repository.clone_url);
- parsedCloneUrl.auth = context.username;
- var gitUri = url.format(parsedCloneUrl);
-
- // If there was a previously defined repository and the url doesn't match
- if (context.github.repositoryFullName && context.github.repositoryFullName.toLowerCase() !== gitUri.toLowerCase()) {
- // Reset it so that it is forced that a new one is to be created
- context.github.repositoryFullName = null;
-
- // Remove the previous one in case it existed as azure
- var azureRemote = this._getRemote('azure', _);
- if (azureRemote) {
- this.log.verbose('Removing existing azure remote alias');
- this._exec('git remote rm azure', _);
- }
- }
-
- if (!context.github.repositoryFullName) {
- // create the remote repo locally
- this.log.info('Executing `git remote add azure ' + gitUri + '`');
- this._exec('git remote add azure ' + gitUri, _);
- }
};
GithubClient.prototype.getRepositories = function (username, _) {
@@ -379,36 +379,32 @@ GithubClient.prototype.getHooks = function (username, repository, _) {
}
};
-GithubClient.prototype._getRemoteUri = function (_) {
+GithubClient.prototype._getRemoteUris = function (_) {
var progress = this.cli.progress('Retrieving local git repositories');
- var originUri = null;
-
+ var remoteUris = [ ];
try {
- originUri = this._getRemote('azure', _);
- if (!originUri) {
- originUri = this._getRemote('origin', _);
- }
+ var remotes = this._exec('git remote -v', _);
+ remoteUris = (remotes.stdout + remotes.stderr).split('\n')
+ .filter(function (line) {
+ return line.length > 0;
+ })
+ .map(function (item) {
+ return item.split('\t')[1].split(' ')[0];
+ });
+
+ remoteUris = removeDuplicates(remoteUris);
} finally {
progress.end();
}
- return originUri;
+ return remoteUris;
};
-GithubClient.prototype._getRemote = function (name, _) {
- var remotes = this._exec('git remote -v', _);
- var origin = (remotes.stdout + remotes.stderr).split('\n').filter(function (item) {
- return item.split('\t').some(function (it) {
- return it === name;
- });
+function removeDuplicates (array) {
+ return array.filter(function(elem, pos) {
+ return array.indexOf(elem) === pos;
});
-
- if (origin && origin.length > 0) {
- return origin[0].split('\t')[1].split(' ')[0];
- }
-
- return null;
-};
+}
function choose(cli, data, callback) {
cli.choose(data, function (x) { callback(undefined, x); });
View
2  lib/services/core/connectionstringparser.js
@@ -209,7 +209,7 @@ ConnectionStringParser.prototype._extractValue = function () {
* Parses a connection string.
*
* @param {number} connectionString The connection string to be parsed.
-* @return {object} The query string object.
+* @return {object} The connection string object.
*/
exports.parse = function (connectionString) {
var connectionStringParser = new ConnectionStringParser(connectionString);
View
22 lib/util/js2xml.js
@@ -34,12 +34,16 @@ exports.serialize = function (entity) {
if (entity[rootElementName][Constants.XML_METADATA_MARKER]) {
for (var metadata in entity[rootElementName][Constants.XML_METADATA_MARKER]) {
- doc.att(metadata, entity[rootElementName][Constants.XML_METADATA_MARKER][metadata]);
+ if (entity[rootElementName][Constants.XML_METADATA_MARKER].hasOwnProperty(metadata)) {
+ doc.att(metadata, entity[rootElementName][Constants.XML_METADATA_MARKER][metadata]);
+ }
}
}
for (var attribute in entity[rootElementName]) {
- doc = _writeAtomEntryValue(doc, attribute, entity[rootElementName][attribute]);
+ if (attribute !== Constants.XML_METADATA_MARKER && entity[rootElementName].hasOwnProperty(attribute)) {
+ doc = _writeElementValue(doc, attribute, entity[rootElementName][attribute]);
+ }
}
doc = doc.doc();
@@ -55,7 +59,7 @@ exports.serialize = function (entity) {
* @param {object} value Property value.
* @return {object} The current DOM element.
*/
-function _writeAtomEntryValue (parentElement, name, value) {
+function _writeElementValue (parentElement, name, value) {
var ignored = false;
var propertyTagName = name;
@@ -65,7 +69,9 @@ function _writeAtomEntryValue (parentElement, name, value) {
if (Array.isArray(value) && value.length > 0) {
for (var i in value) {
- parentElement = _writeAtomEntryValue(parentElement, name, value[i]);
+ if (value.hasOwnProperty(i)) {
+ parentElement = _writeElementValue(parentElement, name, value[i]);
+ }
}
// For an array no element was actually added at this level, so skip uping level.
@@ -73,8 +79,8 @@ function _writeAtomEntryValue (parentElement, name, value) {
} else if (typeof value === 'object') {
parentElement = parentElement.ele(propertyTagName);
for (var propertyName in value) {
- if (propertyName !== Constants.XML_METADATA_MARKER) {
- parentElement = _writeAtomEntryValue(parentElement, propertyName, value[propertyName]);
+ if (propertyName !== Constants.XML_METADATA_MARKER && value.hasOwnProperty(propertyName)) {
+ parentElement = _writeElementValue(parentElement, propertyName, value[propertyName]);
}
}
} else {
@@ -92,7 +98,9 @@ function _writeAtomEntryValue (parentElement, name, value) {
// include the metadata
var attributeList = value[Constants.XML_METADATA_MARKER];
for (var attribute in attributeList) {
- parentElement = parentElement.att(attribute, attributeList[attribute]);
+ if (attributeList.hasOwnProperty(attribute)) {
+ parentElement = parentElement.att(attribute, attributeList[attribute]);
+ }
}
}
View
185 test/cli/commands/cli.siteconfig-tests.js
@@ -0,0 +1,185 @@
+/**
+* Copyright 2012 Microsoft Corporation
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+var should = require('should');
+var cli = require('../cli');
+var capture = require('../util').capture;
+
+var currentSiteName = 0;
+var siteNames = [ siteName1, siteName2 ];
+
+suite('cli', function(){
+ suite('siteconfig', function() {
+ setup(function (done) {
+
+ var removeSites = function (sites, cb) {
+ if (sites.length === 0) {
+ currentSiteName++;
+ cb();
+ } else {
+ var siteName = sites.pop();
+ // Delete created site
+ var cmd = ('node cli.js site delete ' + siteName + ' --json --quiet').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ removeSites(sites, cb);
+ });
+ }
+ };
+
+ // List sites
+ var cmd = ('node cli.js site list --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ var siteList = JSON.parse(result.text);
+ var filteredSites = siteNames.filter(function (site) {
+ return siteList.some(function (s) {
+ return site === s.Name;
+ });
+ });
+
+ removeSites(filteredSites, done);
+ });
+ });
+
+ test('siteconfig list', function(done) {
+ var siteName = siteNames[currentSiteName];
+
+ // Create site
+ var cmd = ('node cli.js site create ' + siteName + ' --json --location').split(' ');
+ cmd.push('East US');
+
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ // List sites
+ cmd = ('node cli.js site config list ' + siteName + ' --json ').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ // there should be not settings yet as the site was just created
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ // add a setting
+ var cmd = ('node cli.js site config add mysetting=myvalue ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ cmd = ('node cli.js site config list ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ var settingsList = JSON.parse(result.text);
+
+ // Listing should return 1 setting now
+ settingsList.length.should.equal(1);
+
+ // add another setting
+ var cmd = ('node cli.js site config add mysetting2=myvalue ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ cmd = ('node cli.js site config list ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ var settingsList = JSON.parse(result.text);
+
+ // Listing should return 2 setting now
+ settingsList.length.should.equal(2);
+
+ done();
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+
+ test('siteconfig add get clear', function(done) {
+ var siteName = siteNames[currentSiteName];
+
+ // Create site
+ var cmd = ('node cli.js site create ' + siteName + ' --json --location').split(' ');
+ cmd.push('East US');
+
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ // List sites
+ cmd = ('node cli.js site config list ' + siteName + ' --json ').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ // there should be not settings yet as the site was just created
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ // add a setting
+ var cmd = ('node cli.js site config add mysetting=myvalue ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ cmd = ('node cli.js site config get mysetting ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ result.text.should.equal('"myvalue"\n');
+ result.exitStatus.should.equal(0);
+
+ // add another setting
+ var cmd = ('node cli.js site config clear mysetting ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ cmd = ('node cli.js site config list ' + siteName + ' --json').split(' ');
+ capture(function() {
+ cli.parse(cmd);
+ }, function (result) {
+ result.text.should.equal('');
+ result.exitStatus.should.equal(0);
+
+ done();
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+ });
+});
View
48 test/cli/linkrevisioncontrol-tests.js
@@ -35,7 +35,7 @@ suite('cli', function(){
done();
});
- test('should get remote azure uri', function(done) {
+ test('should get remote uris single', function(done) {
// Setup
var azureUrl = {
stdout: 'azure\tgit://github.com/andrerod/mynewsite999.git (fetch)\n' +
@@ -50,42 +50,22 @@ suite('cli', function(){
execStub.yields(undefined, azureUrl);
// Test
- githubClient._getRemoteUri(function (err, url) {
+ githubClient._getRemoteUris(function (err, urls) {
// Assert
- url.should.equal('git://github.com/andrerod/mynewsite999.git');
+ urls.length.should.equal(1);
+ urls[0].should.equal('git://github.com/andrerod/mynewsite999.git');
done();
});
});
- test('should get remote origin uri', function(done) {
+ test('should get remote uris multiple', function(done) {
// Setup
- var originUrl = {
- stdout: 'origin\tgit://github.com/andrerod/mynewsite999.git (fetch)\n' +
- 'origin\tgit://github.com/andrerod/mynewsite999.git (push)\n',
- stderr: ''
- };
-
- var cli = { output: { }, progress: function() { return { end: function() {}}} };
- var githubClient = LinkedRevisionControl.createClient(cli, 'github');
-
- var execStub = sandbox.stub(githubClient, '_exec');
- execStub.yields(undefined, originUrl);
-
- // Test
- githubClient._getRemoteUri(function (err, url) {
- // Assert
- url.should.equal('git://github.com/andrerod/mynewsite999.git');
-
- done();
- });
- });
-
- test('should not get other remote uris', function(done) {
- // Setup
- var originUrl = {
- stdout: 'myremote\tgit://github.com/andrerod/mynewsite999.git (fetch)\n' +
- 'myremote\tgit://github.com/andrerod/mynewsite999.git (push)\n',
+ var azureUrl = {
+ stdout: 'azure\tgit://github.com/andrerod/mynewsite999.git (fetch)\n' +
+ 'azure\tgit://github.com/andrerod/mynewsite999.git (push)\n' +
+ 'origin\tgit://github.com/andrerod/mynewsite2.git (fetch)\n' +
+ 'origin\tgit://github.com/andrerod/mynewsite2.git (push)\n',
stderr: ''
};
@@ -93,12 +73,14 @@ suite('cli', function(){
var githubClient = LinkedRevisionControl.createClient(cli, 'github');
var execStub = sandbox.stub(githubClient, '_exec');
- execStub.yields(undefined, originUrl);
+ execStub.yields(undefined, azureUrl);
// Test
- githubClient._getRemoteUri(function (err, url) {
+ githubClient._getRemoteUris(function (err, urls) {
// Assert
- should.strictEqual(undefined, url);
+ urls.length.should.equal(2);
+ urls[0].should.equal('git://github.com/andrerod/mynewsite999.git');
+ urls[1].should.equal('git://github.com/andrerod/mynewsite2.git');
done();
});
View
1  test/clitestlist.txt
@@ -1,4 +1,5 @@
cli/commands/generate-psm1-utils-test.js
cli/commands/cli.deployment-tests.js
cli/commands/cli.site-tests.js
+cli/commands/cli.siteconfig-tests.js
cli/linkrevisioncontrol-tests.js
Something went wrong with that request. Please try again.