Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #13 from andrerod/github

Github
  • Loading branch information...
commit 0142328303d261c6d7d1ede8f08ec56d6be39904 2 parents 32e5ad7 + 1f9cd6f
@andrerod andrerod authored
View
96 lib/cli/cli.js
@@ -344,66 +344,71 @@ commander.Command.prototype.whiteListPowershell = function (whitelist) {
return this;
};
-// Allow cli.password to accept empty passwords
-commander.Command.prototype.password = function (str, mask, fn) {
+commander.Command.prototype.passwordOnce = function (currentStr, mask, callback) {
+ var self = this;
+ var buf = '';
+
// default mask
if ('function' === typeof mask) {
- fn = mask;
+ callback = mask;
mask = '';
}
- var getPassword = function (currentStr, callback) {
- var self = this;
- var buf = '';
+ if (!process.stdin.setRawMode) {
+ process.stdin.setRawMode = tty.setRawMode;
+ }
- if (!process.stdin.setRawMode) {
- process.stdin.setRawMode = tty.setRawMode;
+ process.stdin.resume();
+ process.stdin.setRawMode(true);
+ fs.writeSync(istty1 ? 1 : 2, currentStr);
+ process.stdin.on('data', function(char) {
+ // Exit on Ctrl+C keypress
+ char = char.toString();
+ if (char === '\003') {
+ console.log('%s', buf);
+ process.exit();
}
- process.stdin.resume();
- process.stdin.setRawMode(true);
- fs.writeSync(istty1 ? 1 : 2, currentStr);
- process.stdin.on('data', function(char) {
- // Exit on Ctrl+C keypress
- char = char.toString();
- if (char === '\003') {
- console.log('%s', buf);
- process.exit();
- }
+ // Return password in the buffer on enter key press
+ if (char === '\015') {
+ process.stdin.removeAllListeners('data');
+ process.stdout.write('\n');
+ process.stdin.setRawMode(false);
+ process.stdin.pause();
- // Return password in the buffer on enter key press
- if (char === '\015') {
- process.stdin.removeAllListeners('data');
- process.stdout.write('\n');
- process.stdin.setRawMode(false);
- callback(buf);
- return;
- }
-
- // Backspace handling
- // Windows usually sends '\b' (^H) while Linux sends '\x7f'
- if (char === '\b' || char === '\177') {
- if (buf) {
- buf = buf.slice(0, -1);
- for (var j = 0; j < mask.length; ++j) {
- process.stdout.write('\b \b'); // space the last char out
- }
+ return callback(buf);
+ }
+
+ // Backspace handling
+ // Windows usually sends '\b' (^H) while Linux sends '\x7f'
+ if (char === '\b' || char === '\177') {
+ if (buf) {
+ buf = buf.slice(0, -1);
+ for (var j = 0; j < mask.length; ++j) {
+ process.stdout.write('\b \b'); // space the last char out
}
- return;
- }
- char = char.split('\015')[0]; // only use the first line if many (for paste)
- for(var i = 0; i < char.length; ++i) {
- process.stdout.write(mask); // output several chars (for paste)
}
- buf += char;
- }).resume();
- };
+ return;
+ }
+
+ char = char.split('\015')[0]; // only use the first line if many (for paste)
+ for(var i = 0; i < char.length; ++i) {
+ process.stdout.write(mask); // output several chars (for paste)
+ }
+
+ buf += char;
+ });
+};
+
+// Allow cli.password to accept empty passwords
+commander.Command.prototype.password = function (str, mask, fn) {
+ var self = this;
// Prompt first time
- getPassword(str, function (pass) {
+ self.passwordOnce(str, mask, function (pass) {
// Prompt for confirmation
- getPassword('Confirm password: ', function (pass2) {
+ self.passwordOnce('Confirm password: ', mask, function (pass2) {
if (pass === pass2) {
fn (pass);
} else {
@@ -413,7 +418,6 @@ commander.Command.prototype.password = function (str, mask, fn) {
});
};
-
commander.Command.prototype.execute = function (fn) {
var self = this;
return self.action(function () {
View
110 lib/cli/commands/deployment.js
@@ -14,9 +14,6 @@
-
-
-
var fs = require("fs");
var path = require("path");
var url = require("url");
@@ -24,11 +21,12 @@ var crypto = require("crypto");
var pfx2pem = require("../../util/certificates/pkcs").pfx2pem;
var Channel = require("../channel");
var async = require("async");
-var child_process = require("child_process");
var utils = require("../utils");
var constants = require("../constants");
var cacheUtils = require("../cacheUtils");
+var linkedRevisionControl = require("../linkedrevisioncontrol");
+
exports.init = function(cli) {
var log = cli.output;
@@ -65,7 +63,7 @@ exports.init = function(cli) {
scm.getScmChannel = getScmChannel;
- scm.command("list [name]").whiteListPowershell().usage("[options] [name]").description("List your git deployments").option("-s, --subscription <id>", "use the subscription id").option("-m, --max <count>", "limit the maximum number of results").execute(function __1(name, options, _) { var context, repositoryUri; var __frame = { name: "__1", line: 74 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
+ scm.command("list [name]").whiteListPowershell().usage("[options] [name]").description("List your git deployments").option("-s, --subscription <id>", "use the subscription id").option("-m, --max <count>", "limit the maximum number of results").execute(function __1(name, options, _) { var context, repositoryUri; var __frame = { name: "__1", line: 72 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
@@ -80,7 +78,7 @@ exports.init = function(cli) {
- return ensureRepositoryUri(context, __cb(_, __frame, 9, 26, function ___(__0, __1) { repositoryUri = __1; return (function __$__1(__then) {
+ return site.ensureRepositoryUri(context, __cb(_, __frame, 9, 26, function ___(__0, __1) { repositoryUri = __1; return (function __$__1(__then) {
if (repositoryUri) {
return listDeployments(context, __cb(_, __frame, 11, 8, __then, true)); } else {
@@ -88,7 +86,7 @@ exports.init = function(cli) {
- scm.command("show <commitId> [name]").whiteListPowershell().usage("[options] <commitId> [name]").description("Show your git deployment").option("-s, --subscription <id>", "use the subscription id").option("-d, --details", "display log details").execute(function __2(commitId, name, options, _) { var context, repositoryUri, deployment, data, logs, i, details, j; var __frame = { name: "__2", line: 97 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
+ scm.command("show <commitId> [name]").whiteListPowershell().usage("[options] <commitId> [name]").description("Show your git deployment").option("-s, --subscription <id>", "use the subscription id").option("-d, --details", "display log details").execute(function __2(commitId, name, options, _) { var context, repositoryUri, deployment, data, logs, i, details, j; var __frame = { name: "__2", line: 95 }; return __func(_, this, arguments, __2, 3, __frame, function __$__2() {
@@ -107,7 +105,7 @@ exports.init = function(cli) {
return _(null, log.error((("deployment with " + commitId) + " does not exist"))); } else { __then(); } ; })(function __$__2() {
- return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __3) { repositoryUri = __3; return (function __$__2(__then) {
+ return site.ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __3) { repositoryUri = __3; return (function __$__2(__then) {
if (repositoryUri) {
return scm.doDeploymentGet(context, __cb(_, __frame, 15, 25, function ___(__0, __4) { deployment = __4; return (function __$__2(__then) {
@@ -140,7 +138,7 @@ exports.init = function(cli) {
- scm.command("redeploy <commitId> [name]").whiteListPowershell().usage("[options] <commitId> [name]").description("Redeploy your git deployment").option("-s, --subscription <id>", "use the subscription id").option("-q, --quiet", "quiet mode, do not ask for redeploy confirmation").execute(function __3(commitId, name, options, _) { var context, repositoryUri; var __frame = { name: "__3", line: 149 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() {
+ scm.command("redeploy <commitId> [name]").whiteListPowershell().usage("[options] <commitId> [name]").description("Redeploy your git deployment").option("-s, --subscription <id>", "use the subscription id").option("-q, --quiet", "quiet mode, do not ask for redeploy confirmation").execute(function __3(commitId, name, options, _) { var context, repositoryUri; var __frame = { name: "__3", line: 147 }; return __func(_, this, arguments, __3, 3, __frame, function __$__3() {
@@ -159,9 +157,9 @@ exports.init = function(cli) {
return _(null, log.error((("deployment with " + commitId) + " does not exist"))); } else { __then(); } ; })(function __$__3() {
- return ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __4) { repositoryUri = __4; return (function __$__3(__then) {
+ return site.ensureRepositoryUri(context, __cb(_, __frame, 13, 26, function ___(__0, __4) { repositoryUri = __4; return (function __$__3(__then) {
if (repositoryUri) { return (function __$__3(_) {
- var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return site.confirm((("Reploy deployment with " + context.shortId) + " id? (y/n) "), __cb(_, __frame, 15, 31, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -148, 17, function ___(__0, __5) { return (function __$__3(__then) { if (__5) { return _(null); } else { __then(); } ; })(function __$__3() {
+ var __1 = !options.quiet; if (!__1) { return _(null, __1); } ; return site.confirm((("Reploy deployment with " + context.shortId) + " id? (y/n) "), __cb(_, __frame, 15, 31, function ___(__0, __3) { var __2 = !__3; return _(null, __2); }, true)); })(__cb(_, __frame, -146, 17, function ___(__0, __5) { return (function __$__3(__then) { if (__5) { return _(null); } else { __then(); } ; })(function __$__3() {
return scm.doDeploymentPut(context, __cb(_, __frame, 18, 8, function __$__3() {
@@ -171,7 +169,51 @@ exports.init = function(cli) {
- scm.doDeploymentsGet = function scm_doDeploymentsGet__4(context, _) { var maxItems, channel, progress, deployments; var __frame = { name: "scm_doDeploymentsGet__4", line: 174 }; return __func(_, this, arguments, scm_doDeploymentsGet__4, 1, __frame, function __$scm_doDeploymentsGet__4() {
+ scm.command("github [name]").whiteListPowershell().usage("[options] [name]").description("Links a website to a github account for deployment").option("-s, --subscription <id>", "use the subscription id").option("-u, --username <user>", "The github username").option("-up, --pass <pass>", "The github password").option("-r, --repository <repository>", "The github repository").execute(function __4(name, options, _) { var context;
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ function initializeRemoteRepo(_) { var __frame = { name: "initializeRemoteRepo", line: 209 }; return __func(_, this, arguments, initializeRemoteRepo, 0, __frame, function __$initializeRemoteRepo() {
+ log.silly("InitializeRemoteRepo");
+ return site.doRepositoryPost(context, __cb(_, __frame, 2, 8, function __$initializeRemoteRepo() {
+ return site.ensureRepositoryUri(context, __cb(_, __frame, 3, 8, _, true)); }, true)); }); }; var __frame = { name: "__4", line: 180 }; return __func(_, this, arguments, __4, 2, __frame, function __$__4() { context = { subscription: cli.category("account").lookupSubscriptionId(options.subscription), site: { name: name }, username: options.username, password: options.pass, remoteUri: options.repository, flags: { } }; if (!context.remoteUri) { context.flags = { forceRepositorySelection: true }; } ; return site.ensureRepositoryUri(context, __cb(_, __frame, 19, 6, function __$__4() { return (function __$__4(__then) { if (!context.repositoryUri) { return initializeRemoteRepo(__cb(_, __frame, 22, 8, __then, true)); } else { __then(); } ; })(function __$__4() { context.lvcClient = linkedRevisionControl.createClient(cli, "github"); return context.lvcClient.init(context, __cb(_, __frame, 26, 6, function __$__4() { return context.lvcClient.deploy(context, __cb(_, __frame, 27, 6, _, true)); }, true)); }); }, true)); }); });
+
+
+
+ scm.doDeploymentsGet = function scm_doDeploymentsGet__5(context, _) { var maxItems, channel, progress, deployments; var __frame = { name: "scm_doDeploymentsGet__5", line: 216 }; return __func(_, this, arguments, scm_doDeploymentsGet__5, 1, __frame, function __$scm_doDeploymentsGet__5() {
maxItems = parseInt(context.maxItems, 10);
if ((!maxItems || (maxItems <= 0))) {
maxItems = 20; } ;
@@ -182,55 +224,55 @@ exports.init = function(cli) {
channel = getScmChannel(context).path("deployments").query("$orderby", "ReceivedTime desc").query("$top", maxItems);
- progress = cli.progress("Enumerating deployments"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentsGet__4() {
+ progress = cli.progress("Enumerating deployments"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentsGet__5() {
return channel.GET(__cb(_, __frame, 13, 44, function ___(__0, __1) { deployments = ensureShortCommitId(__1);
- return cacheUtils.saveCommitIds(context, deployments, __cb(_, __frame, 14, 6, function __$scm_doDeploymentsGet__4() {
- return _(null, deployments.map(formatDeployment)); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentsGet__4() {
+ return cacheUtils.saveCommitIds(context, deployments, __cb(_, __frame, 14, 6, function __$scm_doDeploymentsGet__5() {
+ return _(null, deployments.map(formatDeployment)); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentsGet__5() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
- scm.doDeploymentGet = function scm_doDeploymentGet__5(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentGet__5", line: 195 }; return __func(_, this, arguments, scm_doDeploymentGet__5, 1, __frame, function __$scm_doDeploymentGet__5() {
+ scm.doDeploymentGet = function scm_doDeploymentGet__6(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentGet__6", line: 237 }; return __func(_, this, arguments, scm_doDeploymentGet__6, 1, __frame, function __$scm_doDeploymentGet__6() {
channel = getScmChannel(context).path("deployments").path(context.id);
- progress = cli.progress("Retrieving deployment info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentGet__5() {
+ progress = cli.progress("Retrieving deployment info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentGet__6() {
- return channel.GET(__cb(_, __frame, 6, 30, function ___(__0, __2) { var __1 = formatDeployment(__2); return _(null, __1); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentGet__5() {
+ return channel.GET(__cb(_, __frame, 6, 30, function ___(__0, __2) { var __1 = formatDeployment(__2); return _(null, __1); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentGet__6() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
- scm.doDeploymentPut = function scm_doDeploymentPut__6(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentPut__6", line: 207 }; return __func(_, this, arguments, scm_doDeploymentPut__6, 1, __frame, function __$scm_doDeploymentPut__6() {
+ scm.doDeploymentPut = function scm_doDeploymentPut__7(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentPut__7", line: 249 }; return __func(_, this, arguments, scm_doDeploymentPut__7, 1, __frame, function __$scm_doDeploymentPut__7() {
channel = getScmChannel(context).path("deployments").path(context.id);
- progress = cli.progress("Redeploying deployment"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentPut__6() {
+ progress = cli.progress("Redeploying deployment"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentPut__7() {
- return channel.PUT(null, __cb(_, __frame, 6, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentPut__6() {
+ return channel.PUT(null, __cb(_, __frame, 6, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentPut__7() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
- scm.doLogGet = function scm_doLogGet__7(context, _) { var channel, progress, logs; var __frame = { name: "scm_doLogGet__7", line: 219 }; return __func(_, this, arguments, scm_doLogGet__7, 1, __frame, function __$scm_doLogGet__7() {
+ scm.doLogGet = function scm_doLogGet__8(context, _) { var channel, progress, logs; var __frame = { name: "scm_doLogGet__8", line: 261 }; return __func(_, this, arguments, scm_doLogGet__8, 1, __frame, function __$scm_doLogGet__8() {
channel = getScmChannel(context).path("deployments").path(context.id).path("log");
- progress = cli.progress("Retrieving deployment log info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doLogGet__7() {
+ progress = cli.progress("Retrieving deployment log info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doLogGet__8() {
return channel.GET(__cb(_, __frame, 7, 17, function ___(__0, __1) { logs = __1;
- return _(null, logs.map(formatLog)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doLogGet__7() {
+ return _(null, logs.map(formatLog)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doLogGet__8() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
- function listDeployments(context, _) { var deployments, authorLength, messageLength; var __frame = { name: "listDeployments", line: 233 }; return __func(_, this, arguments, listDeployments, 1, __frame, function __$listDeployments() {
+ function listDeployments(context, _) { var deployments, authorLength, messageLength; var __frame = { name: "listDeployments", line: 275 }; return __func(_, this, arguments, listDeployments, 1, __frame, function __$listDeployments() {
return scm.doDeploymentsGet(context, __cb(_, __frame, 1, 22, function ___(__0, __1) { deployments = __1;
authorLength = 0; messageLength = 0;
if ((deployments && deployments.length)) {
@@ -248,13 +290,13 @@ exports.init = function(cli) {
- function getLogDetails(context, _) { var results, logs, progress, i; var __frame = { name: "getLogDetails", line: 251 }; return __func(_, this, arguments, getLogDetails, 1, __frame, function __$getLogDetails() {
+ function getLogDetails(context, _) { var results, logs, progress, i; var __frame = { name: "getLogDetails", line: 293 }; return __func(_, this, arguments, getLogDetails, 1, __frame, function __$getLogDetails() {
return scm.doLogGet(context, __cb(_, __frame, 2, 15, function ___(__0, __2) { logs = __2; return (function __$getLogDetails(__then) {
if ((logs && logs.length)) {
progress = cli.progress("Retrieving log details"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$getLogDetails() {
- return async.map(logs, function __1(log, _) { var details; var __frame = { name: "__1", line: 257 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() { return (function __$__1(__then) {
+ return async.map(logs, function __1(log, _) { var details; var __frame = { name: "__1", line: 299 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() { return (function __$__1(__then) {
if (log.hasDetails) {
@@ -335,20 +377,6 @@ exports.init = function(cli) {
- function ensureRepositoryUri(context, _) { var siteData, repositoryUri; var __frame = { name: "ensureRepositoryUri", line: 338 }; 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) {
- return site.doSiteGet(context, __cb(_, __frame, 4, 17, function ___(__0, __2) { siteData = __2;
- repositoryUri = site.getRepositoryUri(siteData); __then(); }, true)); } else { __then(); } ; })(function __$ensureRepositoryUri() {
-
- if (repositoryUri) {
- context.repositoryAuth = site.getRepositoryAuth(siteData);
- return _(null, context.repositoryUri = repositoryUri); } ; _(); }); }, true)); }); };
-
-
- scm.ensureRepositoryUri = ensureRepositoryUri;
-
function formatDeployment(deployment) {
var timeProperties = ["end_time","last_success_end_time","received_time","start_time",];
for (var i = 0; (i < timeProperties.length); ++i) {
View
70 lib/cli/commands/deployment_.js
@@ -13,9 +13,6 @@
* limitations under the License.
*/
-
-//if (!require('streamline/module')(module)) return;
-
var common = require('../common');
var fs = require('fs');
var path = require('path');
@@ -24,11 +21,12 @@ var crypto = require('crypto');
var pfx2pem = require('../../util/certificates/pkcs').pfx2pem;
var Channel = require('../channel');
var async = require('async');
-var child_process = require('child_process');
var utils = require('../utils');
var constants = require('../constants');
var cacheUtils = require('../cacheUtils');
+var linkedRevisionControl = require('../linkedrevisioncontrol');
+
exports.init = function (cli) {
var log = cli.output;
@@ -80,7 +78,7 @@ exports.init = function (cli) {
}
};
- var repositoryUri = ensureRepositoryUri(context, _);
+ var repositoryUri = site.ensureRepositoryUri(context, _);
if (repositoryUri) {
listDeployments(context, _);
} else {
@@ -107,7 +105,7 @@ exports.init = function (cli) {
return log.error('deployment with ' + commitId + ' does not exist');
}
- var repositoryUri = ensureRepositoryUri(context, _);
+ var repositoryUri = site.ensureRepositoryUri(context, _);
if (repositoryUri) {
var deployment = scm.doDeploymentGet(context, _);
@@ -159,7 +157,7 @@ exports.init = function (cli) {
return log.error('deployment with ' + commitId + ' does not exist');
}
- var repositoryUri = ensureRepositoryUri(context, _);
+ var repositoryUri = site.ensureRepositoryUri(context, _);
if (repositoryUri) {
if (!options.quiet && !site.confirm('Reploy deployment with ' + context.shortId + ' id? (y/n) ', _)) {
return;
@@ -171,6 +169,50 @@ exports.init = function (cli) {
}
});
+ scm.command('github [name]')
+ .whiteListPowershell()
+ .usage('[options] [name]')
+ .description('Links a website to a github account for deployment')
+ .option('-s, --subscription <id>', 'use the subscription id')
+ .option('-u, --username <user>', 'The github username')
+ .option('-up, --pass <pass>', 'The github password')
+ .option('-r, --repository <repository>', 'The github repository')
+ .execute(function (name, options, _) {
+ var context = {
+ subscription: cli.category('account').lookupSubscriptionId(options.subscription),
+ site: {
+ name: name
+ },
+ username: options.username,
+ password: options.pass,
+ remoteUri: options.repository,
+ flags: { }
+ };
+
+ if (!context.remoteUri) {
+ // If no explicit github repository URI is passed
+ // this command always prompts the user for a repository
+ context.flags = { forceRepositorySelection: true };
+ }
+
+ // Fetch site and website repository data
+ site.ensureRepositoryUri(context, _);
+ if (!context.repositoryUri) {
+ // If there is no website remote repo, initialize it
+ initializeRemoteRepo(_);
+ }
+
+ context.lvcClient = linkedRevisionControl.createClient(cli, 'github');
+ context.lvcClient.init(context, _);
+ context.lvcClient.deploy(context, _);
+
+ function initializeRemoteRepo(_) {
+ log.silly('InitializeRemoteRepo');
+ site.doRepositoryPost(context, _);
+ site.ensureRepositoryUri(context, _);
+ }
+ });
+
scm.doDeploymentsGet = function (context, _) {
var maxItems = parseInt(context.maxItems, 10);
if (!maxItems || maxItems <= 0) {
@@ -335,20 +377,6 @@ exports.init = function (cli) {
});
}
- function ensureRepositoryUri(context, _) {
- var siteData = site.lookupSiteNameAndWebSpace(context, _);
- var repositoryUri = siteData && site.getRepositoryUri(siteData);
- if (!repositoryUri) {
- siteData = site.doSiteGet(context, _);
- repositoryUri = site.getRepositoryUri(siteData);
- }
- if (repositoryUri) {
- context.repositoryAuth = site.getRepositoryAuth(siteData);
- return context.repositoryUri = repositoryUri;
- }
- }
- scm.ensureRepositoryUri = ensureRepositoryUri;
-
function formatDeployment(deployment) {
var timeProperties = ['end_time', 'last_success_end_time', 'received_time', 'start_time'];
for (var i = 0; i < timeProperties.length; ++i) {
View
194 lib/cli/commands/log.js
@@ -1,113 +1,81 @@
-/*** Generated by streamline 0.3.6 (callbacks) - DO NOT EDIT ***/
-var __rt=require('streamline/lib/callbacks/runtime').runtime(__filename),__func=__rt.__func,__cb=__rt.__cb,__tryCatch=__rt.__tryCatch,__propagate=__rt.__propagate,__trap=__rt.__trap,__future=__rt.__future,__setEF=__rt.__setEF,__g=__rt.__g;
-/* 1 */ var common = require("../common");
-/* 20 */ var fs = require("fs");
-/* 21 */ var path = require("path");
-/* 22 */ var url = require("url");
-/* 23 */ var crypto = require("crypto");
-/* 24 */ var pfx2pem = require("../../util/certificates/pkcs").pfx2pem;
-/* 25 */ var Channel = require("../channel");
-/* 26 */ var async = require("async");
-/* 27 */ var child_process = require("child_process");
-/* 28 */ var utils = require("../utils");
-/* 29 */ var constants = require("../constants");
-/* 30 */ var cacheUtils = require("../cacheUtils");
-/* 32 */ exports.init = function(cli) {
-/* 34 */ var log = cli.output;
-/* 35 */ var site = cli.category("site");
-/* 36 */ var scm = site.category("deployment");
-/* 37 */ var diagnostic = site.category("log").description("Commands to download diagnostic log");
-/* 40 */ diagnostic.command("download [name]").whiteListPowershell().description("Download diagnostic log").option("-s, --subscription <id>", "use the subscription id").option("-o, --output <path>", "output path, default is local folder").execute(function __1(name, options, _) {
- var context, repositoryUri, buf;
- var __frame = {
- name: "__1",
- line: 45
- };
- return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
-/* 46 */ context = {
-/* 47 */ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
-/* 48 */ path: (options.output || ""),
-/* 49 */ site: {
-/* 50 */ name: name
- }
- };
-/* 54 */ if (!(/[.]zip$/i.test(context.path))) {
-/* 55 */ context.path = path.join(context.path, "diagnostics.zip");
- }
- ;
- return (function __$__1(__then) {
-/* 58 */ if (utils.pathExistsSync(context.path)) {
-/* 59 */ return site.confirm((("Replace existing " + context.path) + "? (y/n) "), __cb(_, __frame, 14, 13, function ___(__0, __2) {
-/* 59 */ var __1 = !__2;
- return (function __$__1(__then) {
- if (__1) {
- return _(null);
- }
- else {
- __then();
- }
- ;
- })(__then);
- }, true));
- }
- else {
- __then();
- }
- ;
- })(function __$__1() {
-/* 64 */ return scm.ensureRepositoryUri(context, __cb(_, __frame, 19, 26, function ___(__0, __3) {
- repositoryUri = __3;
- return (function __$__1(__then) {
-/* 65 */ if (repositoryUri) {
-/* 66 */ return doDownloadDiagnostic(context, __cb(_, __frame, 21, 18, function ___(__0, __4) {
- buf = __4;
-/* 67 */ log.info(("Writing to " + context.path));
-/* 68 */ return fs.writeFile(context.path, buf, __cb(_, __frame, 23, 8, __then, true));
- }, true));
- }
- else {
-/* 70 */ log.error("Repository is not setup");
- __then();
- }
- ;
- })(_);
- }, true));
- });
- });
- });
-/* 74 */ function doDownloadDiagnostic(context, _) {
- var channel, progress;
- var __frame = {
- name: "doDownloadDiagnostic",
- line: 74
- };
- return __func(_, this, arguments, doDownloadDiagnostic, 1, __frame, function __$doDownloadDiagnostic() {
-/* 76 */ channel = scm.getScmChannel(context).path("dump");
-/* 77 */ progress = cli.progress("Downloading diagnostic log");
- return (function ___(__then) {
- (function ___(_) {
- __tryCatch(_, function __$doDownloadDiagnostic() {
-/* 79 */ return channel.GET(__cb(_, __frame, 5, 13, _, true));
- });
- })(function ___(__e, __r, __cont) {
- (function ___(__then) {
- __tryCatch(_, function __$doDownloadDiagnostic() {
-/* 81 */ progress.end();
- __then();
- });
- })(function ___() {
- __tryCatch(_, function ___() {
- if (__cont) {
- __then();
- } else {
- _(__e, __r);
- };
- });
- });
- });
- })(function ___() {
- __tryCatch(_, _);
- });
- });
- };
- };
+/*** 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,__tryCatch=__rt.__tryCatch; var common = require("../common");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+var fs = require("fs");
+var path = require("path");
+var url = require("url");
+var crypto = require("crypto");
+var pfx2pem = require("../../util/certificates/pkcs").pfx2pem;
+var Channel = require("../channel");
+var async = require("async");
+var child_process = require("child_process");
+var utils = require("../utils");
+var constants = require("../constants");
+var cacheUtils = require("../cacheUtils");
+
+exports.init = function(cli) {
+
+ var log = cli.output;
+ var site = cli.category("site");
+ var scm = site.category("deployment");
+ var diagnostic = site.category("log").description("Commands to download diagnostic log");
+
+
+ diagnostic.command("download [name]").whiteListPowershell().description("Download diagnostic log").option("-s, --subscription <id>", "use the subscription id").option("-o, --output <path>", "output path, default is local folder").execute(function __1(name, options, _) { var context, repositoryUri, buf; var __frame = { name: "__1", line: 45 }; return __func(_, this, arguments, __1, 2, __frame, function __$__1() {
+
+
+
+
+
+ context = {
+ subscription: cli.category("account").lookupSubscriptionId(options.subscription),
+ path: (options.output || ""),
+ site: {
+ name: name } };
+
+
+
+ if (!(/[.]zip$/i.test(context.path))) {
+ context.path = path.join(context.path, "diagnostics.zip"); } ; return (function __$__1(__then) {
+
+
+ if (utils.pathExistsSync(context.path)) {
+ return site.confirm((("Replace existing " + context.path) + "? (y/n) "), __cb(_, __frame, 14, 13, function ___(__0, __2) { var __1 = !__2; return (function __$__1(__then) { if (__1) { return _(null); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$__1() {
+
+
+
+
+ return site.ensureRepositoryUri(context, __cb(_, __frame, 19, 26, function ___(__0, __3) { repositoryUri = __3; return (function __$__1(__then) {
+ if (repositoryUri) {
+ return doDownloadDiagnostic(context, __cb(_, __frame, 21, 18, function ___(__0, __4) { buf = __4;
+ log.info(("Writing to " + context.path));
+ return fs.writeFile(context.path, buf, __cb(_, __frame, 23, 8, __then, true)); }, true)); } else {
+
+ log.error("Repository is not setup"); __then(); } ; })(_); }, true)); }); }); });
+
+
+
+ function doDownloadDiagnostic(context, _) { var channel, progress; var __frame = { name: "doDownloadDiagnostic", line: 74 }; return __func(_, this, arguments, doDownloadDiagnostic, 1, __frame, function __$doDownloadDiagnostic() {
+
+ channel = scm.getScmChannel(context).path("dump");
+ progress = cli.progress("Downloading diagnostic log"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$doDownloadDiagnostic() {
+
+ return channel.GET(__cb(_, __frame, 5, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$doDownloadDiagnostic() {
+
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };};
View
2  lib/cli/commands/log_.js
@@ -61,7 +61,7 @@ exports.init = function (cli) {
}
}
- var repositoryUri = scm.ensureRepositoryUri(context, _);
+ var repositoryUri = site.ensureRepositoryUri(context, _);
if (repositoryUri) {
var buf = doDownloadDiagnostic(context, _);
log.info('Writing to ' + context.path);
View
228 lib/cli/commands/site.js
@@ -27,6 +27,8 @@ var utils = require("../utils");
var constants = require("../constants");
var cacheUtils = require("../cacheUtils");
+var linkedRevisionControl = require("../linkedrevisioncontrol");
+
exports.init = function(cli) {
var log = cli.output;
@@ -68,7 +70,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: 75 }; 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: 77 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
@@ -110,7 +112,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").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;
@@ -140,108 +142,108 @@ exports.init = function(cli) {
- function promptForSiteName(_) { var __frame = { name: "promptForSiteName", line: 143 }; 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 prompt("Name: ", __cb(_, __frame, 4, 34, function ___(__0, __1) { context.site.name = __1; __then(); }, true)); } else { __then(); } ; })(_); }); };
- function determineIfSiteExists(_) { var sites, hits; var __frame = { name: "determineIfSiteExists", line: 151 }; 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) {
- return utils.ignoreCaseEquals(item.Name, context.site.name); });
- if ((hits.length === 1)) {
- log.info("Updating existing site");
- context.flags.siteExists = true;
- if ((context.site.webspace === undefined)) {
- context.site.webspace = hits[0].WebSpace;
- log.verbose("Existing site location is ", context.site.webspace); } else {
- if ((context.site.webspace !== hits[0].WebSpace)) {
- return _(new Error(((("Expected location " + context.site.webspace) + " but was ") + hits[0].WebSpace))); } ; } ; } ; _(); }, true)); }); };
- function promptForLocation(_) { var spaces, displayNameMatches; var __frame = { name: "promptForLocation", line: 169 }; return __func(_, this, arguments, promptForLocation, 0, __frame, function __$promptForLocation() {
- log.silly("promptForLocation");
- return cacheUtils.readSpaces(context, __cb(_, __frame, 2, 25, function ___(__0, __1) { spaces = __1; return (function __$promptForLocation(__then) {
- if ((!spaces || !spaces.length)) {
- return site.doSpacesGet(context, __cb(_, __frame, 4, 23, function ___(__0, __2) { spaces = __2; __then(); }, true)); } else { __then(); } ; })(function __$promptForLocation() {
- if ((context.site.webspace !== undefined)) {
- displayNameMatches = spaces.filter(function(space) {
- return (space.GeoRegion === context.site.webspace); });
- if ((displayNameMatches.length === 1)) {
- context.site.webspace = displayNameMatches[0].Name; } ; } ;
- if ((context.site.webspace !== undefined)) { return _(null); } ; return (function __$promptForLocation(__then) {
- if ((spaces.length === 0)) {
- return portalCreateSiteInstruction(context, __cb(_, __frame, 24, 14, function __$promptForLocation() {
- return _(new Error("First site must be created on portal")); }, true)); } else { return (function __$promptForLocation(__then) {
- if ((spaces.length == 1)) {
- context.site.webspace = spaces[0].Name;
- log.info("Using location", spaces[0].GeoRegion); __then(); } else {
- log.help("Choose a region");
- return choose(spaces.map(function(space) {
- return space.GeoRegion; }), __cb(_, __frame, 31, 45, function ___(__0, __3) { context.site.webspace = spaces[__3].Name; __then(); }, true)); } ; })(__then); } ; })(_); }); }, true)); }); };
- function determineIfCurrentDirectoryIsGitWorkingTree(_) { var isInsideWorkTree, lines; var __frame = { name: "determineIfCurrentDirectoryIsGitWorkingTree", line: 206 }; return __func(_, this, arguments, determineIfCurrentDirectoryIsGitWorkingTree, 0, __frame, function __$determineIfCurrentDirectoryIsGitWorkingTree() {
- log.silly("determineIfCurrentDirectoryIsGitWorkingTree"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$determineIfCurrentDirectoryIsGitWorkingTree() {
- return exec("git rev-parse --git-dir", __cb(_, __frame, 4, 37, function ___(__0, __1) { isInsideWorkTree = __1;
- lines = (isInsideWorkTree.stdout + isInsideWorkTree.stderr);
- context.flags.isGitWorkingTree = lines.split("\n").some(function(line) {
- return (line === ".git"); }); __then(); }, true)); }); })(function ___(err, __result) { __tryCatch(_, function __$determineIfCurrentDirectoryIsGitWorkingTree() { if (err) {
- context.flags.isGitWorkingTree = false; __then(); } else { _(null, __result); } ; }); }); })(function ___() { __tryCatch(_, _); }); }); };
- function initGitOnCurrentDirectory(_) { var __frame = { name: "initGitOnCurrentDirectory", line: 220 }; return __func(_, this, arguments, initGitOnCurrentDirectory, 0, __frame, function __$initGitOnCurrentDirectory() {
- log.silly("initGitOnCurrentDirectoryIfNeeded");
- if (context.flags.isGitWorkingTree) { return _(null); } ;
+ function promptForSiteName(_) { var __frame = { name: "promptForSiteName", line: 178 }; 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 prompt("Name: ", __cb(_, __frame, 4, 34, function ___(__0, __1) { context.site.name = __1; __then(); }, true)); } else { __then(); } ; })(_); }); };
- if (!options.git) { return _(null); } ;
+ function determineIfSiteExists(_) { var sites, hits, displayNameMatches; var __frame = { name: "determineIfSiteExists", line: 186 }; 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) {
+ return utils.ignoreCaseEquals(item.Name, context.site.name); }); return (function __$determineIfSiteExists(__then) {
+
+
+ if ((hits.length === 1)) {
+ log.info("Updating existing site");
+ context.flags.siteExists = true; return (function __$determineIfSiteExists(__then) {
+ if ((context.site.webspace === undefined)) {
+ context.site.webspace = hits[0].WebSpace;
+ log.verbose("Existing site location is ", context.site.webspace); __then(); } else {
+
+ return ensureSpaces(context, __cb(_, __frame, 14, 16, function __$determineIfSiteExists() {
- return site.doPublishingUsersGet(context, __cb(_, __frame, 10, 38, function ___(__0, __1) { context.publishingUsers = __1;
- return getPublishingUser(context, __cb(_, __frame, 11, 37, function ___(__0, __2) { context.publishingUser = __2;
+ displayNameMatches = context.spaces.filter(function(space) { return (space.GeoRegion === context.site.webspace); })[0];
- log.info("Executing `git init`");
- return exec("git init", __cb(_, __frame, 14, 12, function __$initGitOnCurrentDirectory() { return (function __$initGitOnCurrentDirectory(__then) {
+ if ((displayNameMatches && (displayNameMatches.Name !== hits[0].WebSpace))) {
+ return _(new Error(((("Expected location " + context.site.webspace) + " but was ") + displayNameMatches.GeoRegion))); } ; __then(); }, true)); } ; })(__then); } else { __then(); } ; })(_); }, true)); }); };
+
+
+
+
+
+ function promptForLocation(_) { var displayNameMatches; var __frame = { name: "promptForLocation", line: 212 }; return __func(_, this, arguments, promptForLocation, 0, __frame, function __$promptForLocation() {
+ log.silly("promptForLocation");
+ return ensureSpaces(context, __cb(_, __frame, 2, 12, function __$promptForLocation() {
- if (!utils.pathExistsSync(".gitignore")) {
- log.info("Creating default .gitignore file");
- return fs.writeFile(".gitignore", "node_modules\nazure_error", __cb(_, __frame, 18, 14, __then, true)); } else { __then(); } ; })(function __$initGitOnCurrentDirectory() {
+ if ((context.site.webspace !== undefined)) {
+ displayNameMatches = context.spaces.filter(function(space) {
+ return (space.GeoRegion === context.site.webspace); });
- context.flags.isGitWorkingTree = true; _(); }); }, true)); }, true)); }, true)); }); };
+ if ((displayNameMatches.length === 1)) {
+ context.site.webspace = displayNameMatches[0].Name; } ; } ;
- function copyIisNodeWhenServerJsPresent(_) { var sourcePath; var __frame = { name: "copyIisNodeWhenServerJsPresent", line: 244 }; return __func(_, this, arguments, copyIisNodeWhenServerJsPresent, 0, __frame, function __$copyIisNodeWhenServerJsPresent() {
+
+
+ if ((context.site.webspace !== undefined)) { return _(null); } ; return (function __$promptForLocation(__then) {
+
+
+
+
+ if ((context.spaces.length === 0)) {
+ return portalCreateSiteInstruction(context, __cb(_, __frame, 21, 14, function __$promptForLocation() {
+ return _(new Error("First site must be created on portal")); }, true)); } else { return (function __$promptForLocation(__then) {
+ if ((context.spaces.length == 1)) {
+ context.site.webspace = context.spaces[0].Name;
+ log.info("Using location", context.spaces[0].GeoRegion); __then(); } else {
+
+ log.help("Choose a region");
+ return choose(context.spaces.map(function(space) {
+ return space.GeoRegion; }), __cb(_, __frame, 28, 53, function ___(__0, __1) { context.site.webspace = context.spaces[__1].Name; __then(); }, true)); } ; })(__then); } ; })(_); }, true)); }); };
+
+
+
+
+ function copyIisNodeWhenServerJsPresent(_) { var sourcePath; var __frame = { name: "copyIisNodeWhenServerJsPresent", line: 246 }; 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");
@@ -250,7 +252,7 @@ exports.init = function(cli) {
- function updateLocalConfigWithSiteName(_) { var cfg; var __frame = { name: "updateLocalConfigWithSiteName", line: 253 }; return __func(_, this, arguments, updateLocalConfigWithSiteName, 0, __frame, function __$updateLocalConfigWithSiteName() {
+ function updateLocalConfigWithSiteName(_) { var cfg; var __frame = { name: "updateLocalConfigWithSiteName", line: 255 }; 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;
@@ -260,23 +262,30 @@ exports.init = function(cli) {
- function createSiteAndInitializeRemoteRepo(_) { var __frame = { name: "createSiteAndInitializeRemoteRepo", line: 263 }; return __func(_, this, arguments, createSiteAndInitializeRemoteRepo, 0, __frame, function __$createSiteAndInitializeRemoteRepo() {
- log.silly("createSiteAndInitializeRemoteRepo"); return (function __$createSiteAndInitializeRemoteRepo(__then) {
+ function createSite(_) { var __frame = { name: "createSite", line: 265 }; 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: 272 }; return __func(_, this, arguments, initializeRemoteRepo, 0, __frame, function __$initializeRemoteRepo() {
+ log.silly("InitializeRemoteRepo"); return (function __$initializeRemoteRepo(__then) {
if (!context.flags.siteExists) {
- return site.doSitesPost(context, __cb(_, __frame, 3, 14, function __$createSiteAndInitializeRemoteRepo() {
- return site.doRepositoryPost(context, __cb(_, __frame, 4, 14, function __$createSiteAndInitializeRemoteRepo() {
- return site.doRepositoryGet(context, __cb(_, __frame, 5, 29, function ___(__0, __1) { context.repo = __1; __then(); }, true)); }, true)); }, true)); } else {
+ return site.doRepositoryPost(context, __cb(_, __frame, 3, 14, function __$initializeRemoteRepo() {
+ return site.doRepositoryGet(context, __cb(_, __frame, 4, 29, function ___(__0, __1) { context.repo = __1; __then(); }, true)); }, true)); } else {
- return site.doRepositoryGet(context, __cb(_, __frame, 7, 29, function ___(__0, __2) { context.repo = __2; return (function __$createSiteAndInitializeRemoteRepo(__then) {
+ return site.doRepositoryGet(context, __cb(_, __frame, 6, 29, function ___(__0, __2) { context.repo = __2; return (function __$initializeRemoteRepo(__then) {
if (!context.repo) {
- return site.doRepositoryPost(context, __cb(_, __frame, 9, 16, function __$createSiteAndInitializeRemoteRepo() {
- return site.doRepositoryGet(context, __cb(_, __frame, 10, 31, function ___(__0, __3) { context.repo = __3; __then(); }, true)); }, true)); } else { __then(); } ; })(__then); }, true)); } ; })(function __$createSiteAndInitializeRemoteRepo() {
+ return site.doRepositoryPost(context, __cb(_, __frame, 8, 16, function __$initializeRemoteRepo() {
+ return site.doRepositoryGet(context, __cb(_, __frame, 9, 31, function ___(__0, __3) { context.repo = __3; __then(); }, true)); }, true)); } else { __then(); } ; })(__then); }, true)); } ; })(function __$initializeRemoteRepo() {
+
log.silly("context.repo", context.repo); _(); }); }); };
- function addRemoteToLocalGitRepo(_) { var remotes, azureExists, gitUri; var __frame = { name: "addRemoteToLocalGitRepo", line: 279 }; return __func(_, this, arguments, addRemoteToLocalGitRepo, 0, __frame, function __$addRemoteToLocalGitRepo() {
+ function addRemoteToLocalGitRepo(_) { var remotes, azureExists, gitUri; var __frame = { name: "addRemoteToLocalGitRepo", line: 288 }; 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) {
@@ -301,11 +310,20 @@ exports.init = function(cli) {
gitUri = getGitUri(context.repo, context.site.name, context.publishingUser);
log.info((("Executing `git remote add azure " + gitUri) + "`"));
- return exec(("git remote add azure " + gitUri), __cb(_, __frame, 25, 12, _, true)); }); }, true)); }); }); }; var __frame = { name: "__2", line: 120 }; 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 }, flags: { } }; return promptForSiteName(__cb(_, __frame, 13, 10, function __$__2() { return determineIfSiteExists(__cb(_, __frame, 14, 10, function __$__2() { return promptForLocation(__cb(_, __frame, 15, 10, function __$__2() { return determineIfCurrentDirectoryIsGitWorkingTree(__cb(_, __frame, 16, 10, function __$__2() { return initGitOnCurrentDirectory(__cb(_, __frame, 17, 10, function __$__2() { return copyIisNodeWhenServerJsPresent(__cb(_, __frame, 18, 10, function __$__2() { return updateLocalConfigWithSiteName(__cb(_, __frame, 19, 10, function __$__2() { return createSiteAndInitializeRemoteRepo(__cb(_, __frame, 20, 10, function __$__2() { return addRemoteToLocalGitRepo(__cb(_, __frame, 21, 10, _, true)); }, true)); }, true)); }, true)); }, true)); }, true)); }, true)); }, true)); }, true)); }); });
+ return exec(("git remote add azure " + gitUri), __cb(_, __frame, 25, 12, _, true)); }); }, true)); }); }); };
+
+
+ function ensureSpaces(context, _) { var __frame = { name: "ensureSpaces", line: 316 }; 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, 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: 308 }; return __func(_, this, arguments, portalCreateSiteInstruction, 1, __frame, function __$portalCreateSiteInstruction() {
+
+
+ function portalCreateSiteInstruction(context, _) { var href; var __frame = { name: "portalCreateSiteInstruction", line: 326 }; 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");
@@ -324,7 +342,7 @@ exports.init = function(cli) {
- function getPublishingUser(context, _) { var publishingUsers, filters; var __frame = { name: "getPublishingUser", line: 327 }; return __func(_, this, arguments, getPublishingUser, 1, __frame, function __$getPublishingUser() {
+ function getPublishingUser(context, _) { var publishingUsers, filters; var __frame = { name: "getPublishingUser", line: 345 }; 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) {
@@ -342,7 +360,7 @@ exports.init = function(cli) {
return prompt("Publishing username: ", __cb(_, __frame, 15, 11, _, true)); }); }); };
- function portalGitInitInstruction(context, _) { var href; var __frame = { name: "portalGitInitInstruction", line: 345 }; return __func(_, this, arguments, portalGitInitInstruction, 1, __frame, function __$portalGitInitInstruction() {
+ function portalGitInitInstruction(context, _) { var href; var __frame = { name: "portalGitInitInstruction", line: 363 }; 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\"");
@@ -362,7 +380,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: 368 }; 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: 386 }; return __func(_, this, arguments, __3, 1, __frame, function __$__3() {
@@ -384,7 +402,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: 391 }; 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: 409 }; return __func(_, this, arguments, __4, 2, __frame, function __$__4() {
@@ -404,7 +422,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: 411 }; 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: 429 }; return __func(_, this, arguments, __5, 2, __frame, function __$__5() {
@@ -418,14 +436,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, -410, 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, -428, 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: 432 }; 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: 450 }; return __func(_, this, arguments, __6, 2, __frame, function __$__6() {
@@ -442,9 +460,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: 446 }; return __func(_, this, arguments, __1, 0, __frame, function __$__1() {
+ return async.parallel([function __1(_) { var __frame = { name: "__1", line: 464 }; 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: 447 }; 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: 465 }; 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;
@@ -476,7 +494,7 @@ exports.init = function(cli) {
- function lookupSiteName(context, _) { var cfg; var __frame = { name: "lookupSiteName", line: 479 }; return __func(_, this, arguments, lookupSiteName, 1, __frame, function __$lookupSiteName() {
+ function lookupSiteName(context, _) { var cfg; var __frame = { name: "lookupSiteName", line: 497 }; return __func(_, this, arguments, lookupSiteName, 1, __frame, function __$lookupSiteName() {
if ((context.site.name !== undefined)) { return _(null); } ;
@@ -497,7 +515,7 @@ exports.init = function(cli) {
- function lookupSiteWebSpace(context, _) { var sites, index; var __frame = { name: "lookupSiteWebSpace", line: 500 }; return __func(_, this, arguments, lookupSiteWebSpace, 1, __frame, function __$lookupSiteWebSpace() {
+ function lookupSiteWebSpace(context, _) { var sites, index; var __frame = { name: "lookupSiteWebSpace", line: 518 }; 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) {
@@ -511,7 +529,7 @@ exports.init = function(cli) {
- function lookupSiteNameAndWebSpace(context, _) { var cache; var __frame = { name: "lookupSiteNameAndWebSpace", line: 514 }; return __func(_, this, arguments, lookupSiteNameAndWebSpace, 1, __frame, function __$lookupSiteNameAndWebSpace() {
+ function lookupSiteNameAndWebSpace(context, _) { var cache; var __frame = { name: "lookupSiteNameAndWebSpace", line: 532 }; 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)) {
@@ -585,7 +603,21 @@ exports.init = function(cli) {
site.getRepositoryAuth = getRepositoryAuth;
- 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: 593 }; return __func(_, this, arguments, __7, 2, __frame, function __$__7() {
+ function ensureRepositoryUri(context, _) { var siteData, repositoryUri; var __frame = { name: "ensureRepositoryUri", line: 606 }; 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) {
+ return site.doSiteGet(context, __cb(_, __frame, 4, 17, function ___(__0, __2) { siteData = __2;
+ repositoryUri = site.getRepositoryUri(siteData); __then(); }, true)); } else { __then(); } ; })(function __$ensureRepositoryUri() {
+
+ if (repositoryUri) {
+ context.repositoryAuth = site.getRepositoryAuth(siteData);
+ return _(null, context.repositoryUri = repositoryUri); } ; _(); }); }, true)); }); };
+
+
+ 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: 625 }; return __func(_, this, arguments, __7, 2, __frame, function __$__7() {
@@ -601,7 +633,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, -592, 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, -624, 17, function ___(__0, __2) { return (function __$__7(__then) { if (__2) { return _(null); } else { __then(); } ; })(function __$__7() {
@@ -624,7 +656,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: 631 }; 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: 663 }; return __func(_, this, arguments, __8, 2, __frame, function __$__8() {
@@ -675,7 +707,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: 682 }; 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: 714 }; return __func(_, this, arguments, __9, 2, __frame, function __$__9() {
@@ -730,19 +762,19 @@ exports.init = function(cli) {
- site.readConfig = function site_readConfig__10(_) { var __frame = { name: "site_readConfig__10", line: 733 }; 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: 765 }; 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: 740 }; 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: 772 }; 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: 745 }; 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: 777 }; 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) {
@@ -753,7 +785,7 @@ exports.init = function(cli) {
- site.writeConfigValue = function site_writeConfigValue__13(name, value, _) { var __frame = { name: "site_writeConfigValue__13", line: 756 }; 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: 788 }; return __func(_, this, arguments, site_writeConfigValue__13, 2, __frame, function __$site_writeConfigValue__13() {
return exec(((("git config " + name) + " ") + value), __cb(_, __frame, 1, 4, _, true)); }); };
@@ -819,7 +851,7 @@ exports.init = function(cli) {
if (err) {
logError("Failed to initialize repository", err); }
else {
- log.info("Repository initialized"); } ;
+ log.info("Remote azure repository initialized"); } ;
return callback(err, result); }); };
@@ -851,7 +883,7 @@ exports.init = function(cli) {
- site.doSpacesGet = function site_doSpacesGet__14(options, _) { var progress, result, spaces; var __frame = { name: "site_doSpacesGet__14", line: 854 }; 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: 886 }; 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() {
@@ -873,7 +905,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: 876 }; 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: 908 }; 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;
@@ -885,7 +917,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: 890 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
+ return async.map(spaces, function __1(webspace, _) { var __frame = { name: "__1", line: 922 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() {
@@ -964,12 +996,12 @@ exports.init = function(cli) {
- site.doRepositoryGet = function site_doRepositoryGet__16(options, _) { var siteData; var __frame = { name: "site_doRepositoryGet__16", line: 967 }; return __func(_, this, arguments, site_doRepositoryGet__16, 1, __frame, function __$site_doRepositoryGet__16() {
+ site.doRepositoryGet = function site_doRepositoryGet__16(options, _) { var siteData; var __frame = { name: "site_doRepositoryGet__16", line: 999 }; return __func(_, this, arguments, site_doRepositoryGet__16, 1, __frame, function __$site_doRepositoryGet__16() {
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: 972 }; return __func(_, this, arguments, site_doPublishingUsersGet__17, 1, __frame, function __$site_doPublishingUsersGet__17() {
+ site.doPublishingUsersGet = function site_doPublishingUsersGet__17(options, _) { var progress, publishingUsers; var __frame = { name: "site_doPublishingUsersGet__17", line: 1004 }; 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() {
View
154 lib/cli/commands/site_.js
@@ -27,6 +27,8 @@ var utils = require('../utils');
var constants = require('../constants');
var cacheUtils = require('../cacheUtils');
+var linkedRevisionControl = require('../linkedrevisioncontrol');
+
exports.init = function (cli) {
var log = cli.output;
@@ -117,6 +119,11 @@ exports.init = function (cli) {
.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 (nameArg, options, _) {
var context = {
subscription: cli.category('account').lookupSubscriptionId(options.subscription),
@@ -126,19 +133,47 @@ exports.init = function (cli) {
webspace: options.location,
hostname: options.hostname
},
- flags: {
- }
+ publishingUser: options.publishingUsername,
+ username: options.username,
+ password: options.pass,
+ remoteUri: options.repository,
+ flags: { }
};
+ if (options.git && options.github) {
+ throw new Error('Please run the command with either --git or --github options. Not both.')
+ }
+
+ // Start by creating the site
promptForSiteName(_);
determineIfSiteExists(_);
promptForLocation(_);
- determineIfCurrentDirectoryIsGitWorkingTree(_);
- initGitOnCurrentDirectory(_);
- copyIisNodeWhenServerJsPresent(_);
- updateLocalConfigWithSiteName(_);
- createSiteAndInitializeRemoteRepo(_);
- addRemoteToLocalGitRepo(_);
+ createSite(_);
+
+ // Init git / github linking
+ if (options.git || options.github) {
+ if (options.github) {
+ context.lvcClient = linkedRevisionControl.createClient(cli, 'github');
+ } else if (options.git) {
+ context.lvcClient = linkedRevisionControl.createClient(cli, 'git');
+ }
+
+ context.lvcClient.init(context, _);
+
+ // Scaffold
+ copyIisNodeWhenServerJsPresent(_);
+ updateLocalConfigWithSiteName(_);
+
+ initializeRemoteRepo(_);
+
+ if (options.git) {
+ addRemoteToLocalGitRepo(_);
+ } else if (options.github) {
+ site.ensureRepositoryUri(context, _);
+ }
+
+ context.lvcClient.deploy(context, _);
+ }
function promptForSiteName(_) {
log.silly('promptForSiteName');
@@ -154,28 +189,33 @@ exports.init = function (cli) {
var hits = sites.filter(function (item) {
return utils.ignoreCaseEquals(item.Name, context.site.name);
});
+
if (hits.length === 1) {
log.info('Updating existing site');
context.flags.siteExists = true;
if (context.site.webspace === undefined) {
context.site.webspace = hits[0].WebSpace;
log.verbose('Existing site location is ', context.site.webspace)
- } else if (context.site.webspace !== hits[0].WebSpace) {
- throw new Error('Expected location ' + context.site.webspace + ' but was ' + hits[0].WebSpace);
+ } else {
+ ensureSpaces(context, _);
+ var displayNameMatches = context.spaces.filter(function (space) {
+ return space.GeoRegion === context.site.webspace;
+ })[0];
+
+ if (displayNameMatches && displayNameMatches.Name !== hits[0].WebSpace) {
+ throw new Error('Expected location ' + context.site.webspace + ' but was ' + displayNameMatches.GeoRegion);
+ }
}
}
}
function promptForLocation(_) {
log.silly('promptForLocation');
- var spaces = cacheUtils.readSpaces(context, _);
- if (!spaces || !spaces.length) {
- spaces = site.doSpacesGet(context, _);
- }
+ ensureSpaces(context, _);
if (context.site.webspace !== undefined) {
// Map user-provided value to GeoRegion display name, if unique match exists
- var displayNameMatches = spaces.filter(function (space) {
+ var displayNameMatches = context.spaces.filter(function (space) {
return space.GeoRegion === context.site.webspace;
});
@@ -189,58 +229,20 @@ exports.init = function (cli) {
return;
}
- if (spaces.length === 0) {
+ if (context.spaces.length === 0) {
portalCreateSiteInstruction(context, _);
throw new Error('First site must be created on portal');
- } else if (spaces.length == 1) {
- context.site.webspace = spaces[0].Name;
- log.info('Using location', spaces[0].GeoRegion);
+ } else if (context.spaces.length == 1) {
+ context.site.webspace = context.spaces[0].Name;
+ log.info('Using location', context.spaces[0].GeoRegion);
} else {
log.help('Choose a region');
- context.site.webspace = spaces[choose(spaces.map(function (space) {
+ context.site.webspace = context.spaces[choose(context.spaces.map(function (space) {
return space.GeoRegion;
}), _)].Name;
}
}
- function determineIfCurrentDirectoryIsGitWorkingTree(_) {
- log.silly('determineIfCurrentDirectoryIsGitWorkingTree');
-
- try {
- var isInsideWorkTree = exec('git rev-parse --git-dir', _);
- var lines = isInsideWorkTree.stdout + isInsideWorkTree.stderr;
- context.flags.isGitWorkingTree = lines.split('\n').some(function (line) {
- return line === '.git';
- });
- } catch (err) {
- context.flags.isGitWorkingTree = false;
- }
- }
-
- function initGitOnCurrentDirectory(_) {
- log.silly('initGitOnCurrentDirectoryIfNeeded');
- if (context.flags.isGitWorkingTree) {
- return;
- }
-
- if (!options.git) {
- return;
- }
-
- context.publishingUsers = site.doPublishingUsersGet(context, _);
- context.publishingUser = getPublishingUser(context, _);
-
- log.info('Executing `git init`');
- exec('git init', _);
-
- if (!utils.pathExistsSync('.gitignore')) {
- log.info('Creating default .gitignore file');
- fs.writeFile('.gitignore', 'node_modules\nazure_error', _);
- }
-
- context.flags.isGitWorkingTree = true;
- }
-
function copyIisNodeWhenServerJsPresent(_) {
log.silly('copyWebConfigWhenServerJsPresent');
if (!utils.pathExistsSync('iisnode.yml') && (utils.pathExistsSync('server.js') || utils.pathExistsSync('app.js'))) {
@@ -260,10 +262,16 @@ exports.init = function (cli) {
}
}
- function createSiteAndInitializeRemoteRepo(_) {
- log.silly('createSiteAndInitializeRemoteRepo');
+ function createSite(_) {
+ log.silly('createSite');
if (!context.flags.siteExists) {
site.doSitesPost(context, _);
+ }
+ }
+
+ function initializeRemoteRepo(_) {
+ log.silly('InitializeRemoteRepo');
+ if (!context.flags.siteExists) {
site.doRepositoryPost(context, _);
context.repo = site.doRepositoryGet(context, _);
} else {
@@ -273,6 +281,7 @@ exports.init = function (cli) {
context.repo = site.doRepositoryGet(context, _);
}
}
+
log.silly('context.repo', context.repo);
}
@@ -303,6 +312,15 @@ exports.init = function (cli) {
log.info('Executing `git remote add azure ' + gitUri + '`');
exec('git remote add azure ' + gitUri, _);
}
+
+ function ensureSpaces(context, _) {
+ if (!context.spaces) {
+ context.spaces = cacheUtils.readSpaces(context, _);
+ if (!context.spaces || !context.spaces.length) {
+ context.spaces = context.site.doSpacesGet(context, _);
+ }
+ }
+ }
});
function portalCreateSiteInstruction(context, _) {
@@ -585,6 +603,20 @@ exports.init = function (cli) {
}
site.getRepositoryAuth = getRepositoryAuth;
+ function ensureRepositoryUri(context, _) {
+ var siteData = site.lookupSiteNameAndWebSpace(context, _);
+ var repositoryUri = siteData && site.getRepositoryUri(siteData);
+ if (!repositoryUri) {
+ siteData = site.doSiteGet(context, _);
+ repositoryUri = site.getRepositoryUri(siteData);
+ }
+ if (repositoryUri) {
+ context.repositoryAuth = site.getRepositoryAuth(siteData);
+ return context.repositoryUri = repositoryUri;
+ }
+ }
+ site.ensureRepositoryUri = ensureRepositoryUri;
+
site.command('delete [name]')
.whiteListPowershell()
.description('Delete a web site')
@@ -819,7 +851,7 @@ exports.init = function (cli) {
if (err) {
logError('Failed to initialize repository', err);
} else {
- log.info('Repository initialized');
+ log.info('Remote azure repository initialized');
}
return callback(err, result);
});
View
397 lib/cli/linkedrevisioncontrol.js
@@ -0,0 +1,397 @@
+/*** 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,__tryCatch=__rt.__tryCatch,__forIn=__rt.__forIn; var url = require("url");
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+var fs = require("fs");
+var util = require("util");
+var child_process = require("child_process");
+var GitHubApi = require("github");
+
+var utils = require("./utils");
+
+exports.createClient = function(cli, name) {
+ switch (name) {
+ case "github": return new GithubClient(cli);
+ break;
+ case "git":
+ return new GitClient(cli);
+ break;
+ default:
+ throw new Error("Invalid client");
+ };};
+
+
+
+exports.LinkedRevisionControlClient = LinkedRevisionControlClient;
+exports.GithubClient = GithubClient;
+exports.GitClient = GitClient;
+
+function LinkedRevisionControlClient(cli) {
+ this.cli = cli;};
+
+
+LinkedRevisionControlClient.getRepository = function(repositories, remoteUri) {
+ var parsedRepositoryUri = url.parse(remoteUri);
+ var pathParts = parsedRepositoryUri.pathname.split("/");
+ if ((pathParts.length === 3)) {
+ var owner = pathParts[1];
+ var name = pathParts[2].split(".")[0];
+ var localRepositories = repositories.filter(function(repository) {
+ return ((repository.name === name) && (repository.owner.login === owner)); });
+
+
+ if ((localRepositories && (localRepositories.length > 0))) {
+ return localRepositories[0]; } ; };
+
+
+
+ return null;};
+
+
+LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTree = function LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1(context, _) { var isInsideWorkTree, lines, __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1", line: 63 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1, 1, __frame, function __$LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1() {
+ __this.cli.output.silly("determineIfCurrentDirectoryIsGitWorkingTree"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1() {
+
+
+ return __this._exec("git rev-parse --git-dir", __cb(_, __frame, 4, 27, function ___(__0, __1) { isInsideWorkTree = __1;
+ lines = (isInsideWorkTree.stdout + isInsideWorkTree.stderr);
+ if (!context.flags) {
+ context.flags = { }; } ;
+
+
+ context.flags.isGitWorkingTree = lines.split("\n").some(function(line) {
+ return (line === ".git"); }); __then(); }, true)); }); })(function ___(err, __result) { __tryCatch(_, function __$LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1() { if (err) {
+
+
+ context.flags.isGitWorkingTree = false; __then(); } else { _(null, __result); } ; }); }); })(function ___() { __tryCatch(_, _); }); });};
+
+
+
+LinkedRevisionControlClient.prototype.initGitOnCurrentDirectory = function LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2(context, scaffold, _) { var __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2", line: 81 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2, 2, __frame, function __$LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2() {
+ __this.cli.output.silly("initGitOnCurrentDirectoryIfNeeded");
+ if (context.flags.isGitWorkingTree) { return _(null); } ;
+
+
+
+ __this.cli.output.info("Executing `git init`");
+ return __this._exec("git init", __cb(_, __frame, 7, 2, function __$LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2() { return (function __$LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2(__then) {
+
+ if ((scaffold && !utils.pathExistsSync(".gitignore"))) {
+ __this.cli.output.info("Creating default .gitignore file");
+ return fs.writeFile(".gitignore", "node_modules\nazure_error", __cb(_, __frame, 11, 4, __then, true)); } else { __then(); } ; })(function __$LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2() {
+
+
+ context.flags.isGitWorkingTree = true; _(); }); }, true)); });};
+
+
+LinkedRevisionControlClient.prototype._exec = function(cmd, cb) {
+ child_process.exec(cmd, function(err, stdout, stderr) {
+ cb(err, {
+ stdout: stdout,
+ stderr: stderr }); });};
+
+
+
+
+function GitClient(cli) {
+ GitClient.super_.call(this, 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: 113 }; 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: 118 }; return __func(_, this, arguments, GitClient_prototype_deploy__4, 1, __frame, _);};
+
+
+
+function GithubClient(cli) {
+ GithubClient.super_.call(this, cli);
+
+ this.client = new GitHubApi({ version: "3.0.0" });};
+
+
+util.inherits(GithubClient, LinkedRevisionControlClient);
+
+GithubClient.prototype.authenticate = function GithubClient_prototype_authenticate__5(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_authenticate__5", line: 130 }; 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({
+ type: "basic",
+ username: context.username,
+ password: context.password }); _(); }, true)); });};
+
+
+
+GithubClient.prototype.authenticateAuth = function GithubClient_prototype_authenticateAuth__6(context, _) { var oauthToken, __this = this; var __frame = { name: "GithubClient_prototype_authenticateAuth__6", line: 140 }; 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({
+ type: "basic",
+ username: context.username,
+ password: context.password });
+
+
+
+ return __this.client.oauth.createAuthorization({ user: context.username }, __cb(_, __frame, 10, 19, function ___(__0, __1) { oauthToken = __1;
+ __this.client.authenticate({
+ type: "oauth",
+ token: oauthToken.token }); _(); }, true)); }, true)); });};
+
+
+
+GithubClient.prototype.ensureCredentials = function GithubClient_prototype_ensureCredentials__7(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_ensureCredentials__7", line: 157 }; return __func(_, this, arguments, GithubClient_prototype_ensureCredentials__7, 1, __frame, function __$GithubClient_prototype_ensureCredentials__7() {
+ if ((!context.username || !context.password)) {
+ __this.cli.output.help("Enter your github credentials"); } ; return (function __$GithubClient_prototype_ensureCredentials__7(__then) {
+
+
+ if (!context.username) {
+ return prompt(__this.cli, "Username: ", __cb(_, __frame, 6, 23, function ___(__0, __1) { context.username = __1; __then(); }, true)); } else { __then(); } ; })(function __$GithubClient_prototype_ensureCredentials__7() { return (function __$GithubClient_prototype_ensureCredentials__7(__then) {
+
+
+ if (!context.password) {
+ return promptPassword(__this.cli, "Password: ", __cb(_, __frame, 10, 23, function ___(__0, __2) { context.password = __2; __then(); }, true)); } else { __then(); } ; })(_); }); });};
+
+
+
+GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _) { var repositories, __this = this; var __frame = { name: "GithubClient_prototype_init__8", line: 171 }; 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() {
+
+ return __this.determineIfCurrentDirectoryIsGitWorkingTree(context, __cb(_, __frame, 3, 2, function __$GithubClient_prototype_init__8() {
+ return __this.initGitOnCurrentDirectory(context, false, __cb(_, __frame, 4, 2, function __$GithubClient_prototype_init__8() {
+
+ return __this.getRepositories(context.username, __cb(_, __frame, 6, 21, function ___(__0, __1) { repositories = __1; return (function __$GithubClient_prototype_init__8(__then) {
+
+ if (!context.remoteUri) {
+
+ return __this._getRemoteUri(__cb(_, __frame, 10, 24, function ___(__0, __2) { context.remoteUri = __2; __then(); }, true)); } else { __then(); } ; })(function __$GithubClient_prototype_init__8() {
+
+
+ if (context.remoteUri) {
+ context.repository = LinkedRevisionControlClient.getRepository(repositories, context.remoteUri); } ; return (function __$GithubClient_prototype_init__8(__then) {
+
+
+ if ((((context.flags && context.flags.forceRepositorySelection)) || !context.repository)) {
+
+ __this.cli.output.help("Choose a repository");
+ return choose(__this.cli, repositories.map(function(repository) {
+ return repository.full_name; }), __cb(_, __frame, 20, 38, function ___(__0, __3) { context.repository = repositories[__3]; __then(); }, true)); } else { __then(); } ; })(_); }); }, true)); }, true)); }, true)); }, true)); });};
+
+
+
+
+GithubClient.prototype.deploy = function GithubClient_prototype_deploy__9(context, _) { var parsedRepositoryUri, hookUrl, parsedCloneUrl, gitUri, azureRemote, __this = this; var __frame = { name: "GithubClient_prototype_deploy__9", line: 197 }; return __func(_, this, arguments, GithubClient_prototype_deploy__9, 1, __frame, function __$GithubClient_prototype_deploy__9() {
+ parsedRepositoryUri = url.parse(context.repositoryUri);
+ parsedRepositoryUri.auth = context.repositoryAuth;
+ parsedRepositoryUri.pathname = "/deploy";
+ hookUrl = url.format(parsedRepositoryUri).replace("https://%24", "https://$");
+ return context.lvcClient.createOrUpdateHook(context.repository.owner.login, context.repository.name, hookUrl, __cb(_, __frame, 5, 2, function __$GithubClient_prototype_deploy__9() {
+
+
+
+
+ parsedCloneUrl = url.parse(context.repository.clone_url);
+ parsedCloneUrl.auth = context.username;
+ gitUri = url.format(parsedCloneUrl); return (function __$GithubClient_prototype_deploy__9(__then) {
+
+ if ((context.remoteUri && (context.remoteUri.toLowerCase() !== gitUri.toLowerCase()))) {
+ context.remoteUri = null;
+
+ return __this._getRemote("azure", __cb(_, __frame, 17, 22, function ___(__0, __1) { azureRemote = __1; return (function __$GithubClient_prototype_deploy__9(__then) {
+ if (azureRemote) {
+ __this.cli.output.verbose("Removing existing azure remote alias");
+ return __this._exec("git remote rm azure", __cb(_, __frame, 20, 6, __then, true)); } else { __then(); } ; })(__then); }, true)); } else { __then(); } ; })(function __$GithubClient_prototype_deploy__9() { return (function __$GithubClient_prototype_deploy__9(__then) {
+
+
+
+ if (!context.remoteUri) {
+
+ __this.cli.output.info((("Executing `git remote add azure " + gitUri) + "`"));
+ return __this._exec(("git remote add azure " + gitUri), __cb(_, __frame, 27, 4, __then, true)); } else { __then(); } ; })(_); }); }, true)); });};
+
+
+
+GithubClient.prototype.getRepositories = function GithubClient_prototype_getRepositories__10(username, _) { var progress, userRepos, orgs, orgRepos, i, org, repos, __this = this;
+
+
+
+ function sortFunction(repositoryA, repositoryB) {
+ return repositoryA.full_name.toLowerCase().localeCompare(repositoryB.full_name.toLowerCase()); };
+
+
+
+ function filterPrivate(repository) {
+ return (repository["private"] !== true); }; var __frame = { name: "GithubClient_prototype_getRepositories__10", line: 228 }; return __func(_, this, arguments, GithubClient_prototype_getRepositories__10, 1, __frame, function __$GithubClient_prototype_getRepositories__10() { progress = __this.cli.progress("Retrieving repositories"); userRepos = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_getRepositories__10() {
+
+
+
+ return __this.client.repos.getFromUser({ user: username }, __cb(_, __frame, 14, 16, function ___(__0, __3) { userRepos = __3.filter(filterPrivate).sort(sortFunction);
+
+
+
+ return __this.client.orgs.getFromUser({ user: username }, __cb(_, __frame, 18, 15, function ___(__0, __4) { orgs = __4; return (function __$GithubClient_prototype_getRepositories__10(__then) {
+ if (orgs) {
+ orgRepos = [];
+ var __1 = __forIn(orgs); var __2 = 0; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$GithubClient_prototype_getRepositories__10() { __more = false; var __8 = (__2 < __1.length); if (__8) { i = __1[__2++]; return (function __$GithubClient_prototype_getRepositories__10(__then) {
+ if (orgs.hasOwnProperty(i)) {
+ org = orgs[i]; return (function __$GithubClient_prototype_getRepositories__10(__then) {
+ if (org.login) {
+ return __this.client.repos.getFromOrg({ org: org.login, sort: "updated", desc: "desc" }, __cb(_, __frame, 25, 24, function ___(__0, __5) { repos = __5;
+
+ orgRepos = orgRepos.concat(repos); __then(); }, true)); } else { __then(); } ; })(__then); } else { __then(); } ; })(function __$GithubClient_prototype_getRepositories__10() { while (__more) { __loop(); }; __more = true; }); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(__then); } else { __then(); } ; })(function __$GithubClient_prototype_getRepositories__10() {
+
+
+
+
+ orgRepos = orgRepos.filter(filterPrivate).sort(sortFunction);
+
+ userRepos = userRepos.concat(orgRepos); _(null, null, true); }); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$GithubClient_prototype_getRepositories__10() {
+
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$GithubClient_prototype_getRepositories__10() {
+
+
+ return _(null, userRepos); }); }); });};
+
+
+GithubClient.prototype.createOrUpdateHook = function GithubClient_prototype_createOrUpdateHook__11(username, repository, deployUri, _) { var hook, hooks, parsedDeployUri, existingHook, __this = this; var __frame = { name: "GithubClient_prototype_createOrUpdateHook__11", line: 270 }; return __func(_, this, arguments, GithubClient_prototype_createOrUpdateHook__11, 3, __frame, function __$GithubClient_prototype_createOrUpdateHook__11() {
+ hook = {
+ name: "web",
+ user: username,
+ repo: repository,
+ active: true,
+ events: ["push",],
+ config: {
+ url: deployUri,
+ insecure_ssl: "1",
+ content_type: "form" } };
+
+
+
+ return __this.getHooks(username, repository, __cb(_, __frame, 14, 14, function ___(__0, __1) { hooks = __1;
+ parsedDeployUri = url.parse(deployUri);
+
+
+
+
+
+
+
+ existingHook = hooks.filter(function(hook) { if (hook.config) { return ((hook.name === "web") && (url.parse(hook.config.url).hostname.toLowerCase() === parsedDeployUri.hostname.toLowerCase())); } ; return false; })[0]; return (function __$GithubClient_prototype_createOrUpdateHook__11(__then) {
+
+ if (existingHook) { return (function __$GithubClient_prototype_createOrUpdateHook__11(__then) {
+
+ if ((existingHook.config.url.toLowerCase() !== hook.config.url.toLowerCase())) {
+ existingHook.config.url = hook.config.url;
+ existingHook.user = username;
+ existingHook.repo = repository;
+ return __this.updateHook(existingHook, __cb(_, __frame, 31, 21, function ___(__0, __2) { existingHook = __2;
+ return __this.testHook(existingHook, __cb(_, __frame, 32, 6, __then, true)); }, true)); } else {
+
+ __this.cli.output.info("Link already established"); __then(); } ; })(__then); } else {
+
+
+ return __this.createHook(hook, __cb(_, __frame, 37, 11, function ___(__0, __3) { hook = __3;
+ hook.user = username;
+ hook.repo = repository;
+ return __this.testHook(hook, __cb(_, __frame, 40, 4, __then, true)); }, true)); } ; })(_); }, true)); });};
+
+
+
+GithubClient.prototype.createHook = function GithubClient_prototype_createHook__12(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_createHook__12", line: 314 }; return __func(_, this, arguments, GithubClient_prototype_createHook__12, 1, __frame, function __$GithubClient_prototype_createHook__12() {
+ progress = __this.cli.progress("Creating new hook"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_createHook__12() {
+
+
+ return __this.client.repos.createHook(hook, __cb(_, __frame, 4, 11, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$GithubClient_prototype_createHook__12() {
+
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); });};
+
+
+
+GithubClient.prototype.updateHook = function GithubClient_prototype_updateHook__13(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_updateHook__13", line: 324 }; return __func(_, this, arguments, GithubClient_prototype_updateHook__13, 1, __frame, function __$GithubClient_prototype_updateHook__13() {
+ progress = __this.cli.progress("Updating hook"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_updateHook__13() {
+
+
+ return __this.client.repos.updateHook(hook, __cb(_, __frame, 4, 11, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$GithubClient_prototype_updateHook__13() {
+
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); });};
+
+
+
+GithubClient.prototype.testHook = function GithubClient_prototype_testHook__14(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_testHook__14", line: 334 }; return __func(_, this, arguments, GithubClient_prototype_testHook__14, 1, __frame, function __$GithubClient_prototype_testHook__14() {
+ progress = __this.cli.progress("Testing hook"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_testHook__14() {
+
+
+ return __this.client.repos.testHook(hook, __cb(_, __frame, 4, 4, function __$GithubClient_prototype_testHook__14() { _(null, null, true); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$GithubClient_prototype_testHook__14() {
+
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); });};
+
+
+
+GithubClient.prototype.getHooks = function GithubClient_prototype_getHooks__15(username, repository, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_getHooks__15", line: 344 }; return __func(_, this, arguments, GithubClient_prototype_getHooks__15, 2, __frame, function __$GithubClient_prototype_getHooks__15() {
+ progress = __this.cli.progress("Retrieving website hooks"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$GithubClient_prototype_getHooks__15() {
+
+
+ return __this.client.repos.getHooks({
+ user: username,
+ repo: repository }, __cb(_, __frame, 4, 11, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$GithubClient_prototype_getHooks__15() {
+
+
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); });};
+
+
+
+GithubClient.prototype._getRemoteUri = function GithubClient_prototype__getRemoteUri__16(_) { var progress, originUri, __this = this; var __frame = { name: "GithubClient_prototype__getRemoteUri__16", line: 357 }; return __func(_, this, arguments, GithubClient_prototype__getRemoteUri__16, 0, __frame, function __$GithubClient_prototype__getRemoteUri__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() {
+
+
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$GithubClient_prototype__getRemoteUri__16() {
+
+
+ return _(null, originUri); }); }); });};
+
+
+GithubClient.prototype._getRemote = function GithubClient_prototype__getRemote__17(name, _) { var remotes, origin, __this = this; var __frame = { name: "GithubClient_prototype__getRemote__17", line: 373 }; 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); }); });
+
+
+
+ if ((origin && (origin.length > 0))) {
+ return _(null, origin[0].split(" ")[1].split(" ")[0]); } ;
+
+
+ return _(null, null); }, true)); });};
+
+
+function choose(cli, data, callback) {
+ cli.choose(data, function(x) { callback(undefined, x); });};
+
+
+function prompt(cli, label, callback) {
+ cli.prompt(label, function(x) { callback(undefined, x); });};
+
+
+function promptPassword(cli, label, callback) {
+ cli.passwordOnce(label, function(x) { callback(undefined, x); });};
View
398 lib/cli/linkedrevisioncontrol_.js
@@ -0,0 +1,398 @@
+/**
+* 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 url = require('url');
+var fs = require('fs');
+var util = require('util');
+var child_process = require('child_process');
+var GitHubApi = require('github');