Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding repository selection

  • Loading branch information...
commit 1b83805cf25591e6dff184581ed7caeb9c5c344b 1 parent 0855816
@andrerod andrerod authored
Showing with 114 additions and 68 deletions.
  1. +65 −42 lib/cli/commands/deployment.js
  2. +49 −26 lib/cli/commands/deployment_.js
View
107 lib/cli/commands/deployment.js
@@ -172,60 +172,75 @@ exports.init = function(cli) {
- scm.command("github").whiteListPowershell().usage("[options]").description("Redeploy your git deployment").execute(function __4(options, _) { var context, userRepos; var __frame = { name: "__4", line: 179 }; return __func(_, this, arguments, __4, 1, __frame, function __$__4() {
+ scm.command("github").whiteListPowershell().usage("[options]").description("Redeploy your git deployment").execute(function __4(options, _) { var context;
+
+
+
+
+
+
+
+
+
+
- context = {
- subscription: cli.category("account").lookupSubscriptionId(options.subscription) };
- return prompt("username: ", __cb(_, __frame, 5, 25, function ___(__0, __1) { context.username = __1;
- return prompt("password: ", __cb(_, __frame, 6, 25, function ___(__0, __2) { context.password = __2;
- console.log(context);
- return scm.doGetRepositories(context, __cb(_, __frame, 10, 22, function ___(__0, __3) { userRepos = __3;
- userRepos.forEach(function(repo) {
- console.log(repo.git_url); }); _(); }, true)); }, true)); }, true)); }); });
- scm.doGetRepositories = function scm_doGetRepositories__5(context, _) { var github, userRepos, orgs, i, org; var __frame = { name: "scm_doGetRepositories__5", line: 195 }; return __func(_, this, arguments, scm_doGetRepositories__5, 1, __frame, function __$scm_doGetRepositories__5() {
- github = new GitHubApi({ version: "3.0.0" });
+ function promptForRepository(_) { var repositories; var __frame = { name: "promptForRepository", line: 197 }; return __func(_, this, arguments, promptForRepository, 0, __frame, function __$promptForRepository() {
+ return scm.doGetRepositories(context, __cb(_, __frame, 1, 27, function ___(__0, __1) { repositories = __1;
+ log.help("Choose a repository");
+ return choose(repositories.map(function(repository) {
+ var repoUrl = url.parse(repository.git_url);
+ return repoUrl.pathname; }), __cb(_, __frame, 3, 42, function ___(__0, __2) { context.repository = repositories[__2]; _(); }, true)); }, true)); }); }; var __frame = { name: "__4", line: 179 }; return __func(_, this, arguments, __4, 1, __frame, function __$__4() { context = { subscription: cli.category("account").lookupSubscriptionId(options.subscription) }; log.help("Enter your github credentials"); return prompt("username: ", __cb(_, __frame, 6, 25, function ___(__0, __1) { context.username = __1; return prompt("password: ", __cb(_, __frame, 7, 25, function ___(__0, __2) { context.password = __2; context.github = new GitHubApi({ version: "3.0.0" }); context.github.authenticate({ type: "basic", username: context.username, password: context.password }); return promptForRepository(__cb(_, __frame, 16, 6, _, true)); }, true)); }, true)); }); });
- console.log(context);
- github.authenticate({
- type: "basic",
- username: context.username,
- password: context.password });
+ scm.doCreateHook = function scm_doCreateHook__5(context, _) { var progress; var __frame = { name: "scm_doCreateHook__5", line: 209 }; return __func(_, this, arguments, scm_doCreateHook__5, 1, __frame, function __$scm_doCreateHook__5() {
+ progress = cli.progress("Retrieving repositories"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doCreateHook__5() {
+ context.github.repos.getHooks({ repo: context.repoPath }); _(null, null, true); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doCreateHook__5() {
- return github.repos.getFromUser({ user: "andrerod" }, __cb(_, __frame, 16, 20, function ___(__0, __3) { userRepos = __3;
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
+
+
+
+ scm.doGetRepositories = function scm_doGetRepositories__6(context, _) { var progress, userRepos, orgs, i, org; var __frame = { name: "scm_doGetRepositories__6", line: 219 }; return __func(_, this, arguments, scm_doGetRepositories__6, 1, __frame, function __$scm_doGetRepositories__6() {
+ progress = cli.progress("Retrieving repositories");
+ userRepos = []; return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doGetRepositories__6() {
+
+
+ return context.github.repos.getFromUser({ user: context.username }, __cb(_, __frame, 5, 18, function ___(__0, __3) { userRepos = __3;
+ return context.github.user.getOrgs({ user: context.username }, __cb(_, __frame, 6, 17, function ___(__0, __4) { orgs = __4;
+ var __1 = __forIn(orgs); var __2 = 0; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$scm_doGetRepositories__6() { __more = false; var __8 = (__2 < __1.length); if (__8) { i = __1[__2++]; return (function __$scm_doGetRepositories__6(__then) {
+ if (orgs.hasOwnProperty(i)) {
+ org = orgs[i]; return (function __$scm_doGetRepositories__6(__then) {
+ if (org.login) {
+ return context.github.repos.getFromOrg({ org: org.login }, __cb(_, __frame, 11, 20, function ___(__0, __5) { repos = __5;
- return github.user.getOrgs({ user: "andrerod" }, __cb(_, __frame, 18, 15, function ___(__0, __4) { orgs = __4;
- var __1 = __forIn(orgs); var __2 = 0; return (function ___(__break) { var __more; var __loop = __cb(_, __frame, 0, 0, function __$scm_doGetRepositories__5() { __more = false; var __8 = (__2 < __1.length); if (__8) { i = __1[__2++]; return (function __$scm_doGetRepositories__5(__then) {
- if (orgs.hasOwnProperty(i)) {
- org = orgs[i]; return (function __$scm_doGetRepositories__5(__then) {
- if (org.login) {
- return github.repos.getFromOrg({ org: org.login }, __cb(_, __frame, 23, 18, function ___(__0, __5) { repos = __5;
+ userRepos = userRepos.concat(repos); __then(); }, true)); } else { __then(); } ; })(__then); } else { __then(); } ; })(function __$scm_doGetRepositories__6() { while (__more) { __loop(); }; __more = true; }); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$scm_doGetRepositories__6() { _(null, null, true); }); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doGetRepositories__6() {
- userRepos = userRepos.concat(repos); __then(); }, true)); } else { __then(); } ; })(__then); } else { __then(); } ; })(function __$scm_doGetRepositories__5() { while (__more) { __loop(); }; __more = true; }); } else { __break(); } ; }); do { __loop(); } while (__more); __more = true; })(function __$scm_doGetRepositories__5() {
+ progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, function __$scm_doGetRepositories__6() {
- return _(null, userRepos); }); }, true)); }, true)); }); };
+ return _(null, userRepos); }); }); }); };
- scm.doDeploymentsGet = function scm_doDeploymentsGet__6(context, _) { var maxItems, channel, progress, deployments; var __frame = { name: "scm_doDeploymentsGet__6", line: 228 }; return __func(_, this, arguments, scm_doDeploymentsGet__6, 1, __frame, function __$scm_doDeploymentsGet__6() {
+
+ scm.doDeploymentsGet = function scm_doDeploymentsGet__7(context, _) { var maxItems, channel, progress, deployments; var __frame = { name: "scm_doDeploymentsGet__7", line: 243 }; return __func(_, this, arguments, scm_doDeploymentsGet__7, 1, __frame, function __$scm_doDeploymentsGet__7() {
maxItems = parseInt(context.maxItems, 10);
if ((!maxItems || (maxItems <= 0))) {
maxItems = 20; } ;
@@ -236,55 +251,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__6() {
+ progress = cli.progress("Enumerating deployments"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentsGet__7() {
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__6() {
- return _(null, deployments.map(formatDeployment)); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentsGet__6() {
+ return cacheUtils.saveCommitIds(context, deployments, __cb(_, __frame, 14, 6, function __$scm_doDeploymentsGet__7() {
+ return _(null, deployments.map(formatDeployment)); }, true)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentsGet__7() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
- scm.doDeploymentGet = function scm_doDeploymentGet__7(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentGet__7", line: 249 }; return __func(_, this, arguments, scm_doDeploymentGet__7, 1, __frame, function __$scm_doDeploymentGet__7() {
+ scm.doDeploymentGet = function scm_doDeploymentGet__8(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentGet__8", line: 264 }; return __func(_, this, arguments, scm_doDeploymentGet__8, 1, __frame, function __$scm_doDeploymentGet__8() {
channel = getScmChannel(context).path("deployments").path(context.id);
- progress = cli.progress("Retrieving deployment info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentGet__7() {
+ progress = cli.progress("Retrieving deployment info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentGet__8() {
- 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__7() {
+ 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__8() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
- scm.doDeploymentPut = function scm_doDeploymentPut__8(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentPut__8", line: 261 }; return __func(_, this, arguments, scm_doDeploymentPut__8, 1, __frame, function __$scm_doDeploymentPut__8() {
+ scm.doDeploymentPut = function scm_doDeploymentPut__9(context, _) { var channel, progress; var __frame = { name: "scm_doDeploymentPut__9", line: 276 }; return __func(_, this, arguments, scm_doDeploymentPut__9, 1, __frame, function __$scm_doDeploymentPut__9() {
channel = getScmChannel(context).path("deployments").path(context.id);
- progress = cli.progress("Redeploying deployment"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentPut__8() {
+ progress = cli.progress("Redeploying deployment"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doDeploymentPut__9() {
- return channel.PUT(null, __cb(_, __frame, 6, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentPut__8() {
+ return channel.PUT(null, __cb(_, __frame, 6, 13, _, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doDeploymentPut__9() {
progress.end(); __then(); }); })(function ___() { __tryCatch(_, function ___() { if (__cont) { __then(); } else { _(__e, __r); }; }); }); }); })(function ___() { __tryCatch(_, _); }); }); };
- scm.doLogGet = function scm_doLogGet__9(context, _) { var channel, progress, logs; var __frame = { name: "scm_doLogGet__9", line: 273 }; return __func(_, this, arguments, scm_doLogGet__9, 1, __frame, function __$scm_doLogGet__9() {
+ scm.doLogGet = function scm_doLogGet__10(context, _) { var channel, progress, logs; var __frame = { name: "scm_doLogGet__10", line: 288 }; return __func(_, this, arguments, scm_doLogGet__10, 1, __frame, function __$scm_doLogGet__10() {
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__9() {
+ progress = cli.progress("Retrieving deployment log info"); return (function ___(__then) { (function ___(_) { __tryCatch(_, function __$scm_doLogGet__10() {
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__9() {
+ return _(null, logs.map(formatLog)); }, true)); }); })(function ___(__e, __r, __cont) { (function ___(__then) { __tryCatch(_, function __$scm_doLogGet__10() {
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: 287 }; return __func(_, this, arguments, listDeployments, 1, __frame, function __$listDeployments() {
+ function listDeployments(context, _) { var deployments, authorLength, messageLength; var __frame = { name: "listDeployments", line: 302 }; 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)) {
@@ -302,13 +317,13 @@ exports.init = function(cli) {
- function getLogDetails(context, _) { var results, logs, progress, i; var __frame = { name: "getLogDetails", line: 305 }; return __func(_, this, arguments, getLogDetails, 1, __frame, function __$getLogDetails() {
+ function getLogDetails(context, _) { var results, logs, progress, i; var __frame = { name: "getLogDetails", line: 320 }; 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: 311 }; 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: 326 }; return __func(_, this, arguments, __1, 1, __frame, function __$__1() { return (function __$__1(__then) {
if (log.hasDetails) {
@@ -340,6 +355,14 @@ exports.init = function(cli) {
cli.prompt(label, function(x) { callback(undefined, x); }); };
+ function promptPassword(label, callback) {
+ cli.password(label, function(x) { callback(undefined, x); }); };
+
+
+ function choose(data, callback) {
+ cli.choose(data, function(x) { callback(undefined, x); }); };
+
+
function displayLog(item) {
if ((item.type === "Warning")) {
log.warn(((item.short_time + " ") + item.message)); }
@@ -393,7 +416,7 @@ exports.init = function(cli) {
- function ensureRepositoryUri(context, _) { var siteData, repositoryUri; var __frame = { name: "ensureRepositoryUri", line: 396 }; return __func(_, this, arguments, ensureRepositoryUri, 1, __frame, function __$ensureRepositoryUri() {
+ function ensureRepositoryUri(context, _) { var siteData, repositoryUri; var __frame = { name: "ensureRepositoryUri", line: 419 }; 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) {
View
75 lib/cli/commands/deployment_.js
@@ -181,45 +181,60 @@ exports.init = function (cli) {
subscription: cli.category('account').lookupSubscriptionId(options.subscription)
};
+ log.help('Enter your github credentials');
context.username = prompt('username: ', _);
context.password = prompt('password: ', _);
- console.log(context);
-
- var userRepos = scm.doGetRepositories(context, _);
- userRepos.forEach(function (repo) {
- console.log(repo.git_url);
+ context.github = new GitHubApi({ version: "3.0.0" });
+ context.github.authenticate({
+ type: "basic",
+ username: context.username,
+ password: context.password
});
- });
- scm.doGetRepositories = function (context, _) {
- var github = new GitHubApi({ version: "3.0.0" });
+ promptForRepository(_);
- console.log(context);
- github.authenticate({
- type: "basic",
- username: context.username,
- password: context.password
+ function promptForRepository(_) {
+ var repositories = scm.doGetRepositories(context, _);
+ log.help('Choose a repository');
+ context.repository = repositories[choose(repositories.map(function (repository) {
+ var repoUrl = url.parse(repository.git_url);
+ return repoUrl.pathname;
+ }), _)];
+ }
});
-/*
- var token = github.oauth.createAuthorization({
- scopes: ["user", "public_repo", "repo", "repo:status", "delete_repo", "gist"]
- }, _);
-*/
- var userRepos = github.repos.getFromUser({ user: 'andrerod' }, _);
- var orgs = github.user.getOrgs({ user: 'andrerod' }, _);
- for (var i in orgs) {
- if (orgs.hasOwnProperty(i)) {
- var org = orgs[i];
- if (org.login) {
- repos = github.repos.getFromOrg({ org: org.login }, _);
+ scm.doCreateHook = function (context, _) {
+ var progress = cli.progress('Retrieving repositories');
+
+ try {
+ context.github.repos.getHooks({ repo: context.repoPath })
+ } finally {
+ progress.end();
+ }
+ };
- userRepos = userRepos.concat(repos);
+ scm.doGetRepositories = function (context, _) {
+ var progress = cli.progress('Retrieving repositories');
+ var userRepos = [];
+
+ try {
+ userRepos = context.github.repos.getFromUser({ user: context.username }, _);
+ var orgs = context.github.user.getOrgs({ user: context.username }, _);
+ for (var i in orgs) {
+ if (orgs.hasOwnProperty(i)) {
+ var org = orgs[i];
+ if (org.login) {
+ repos = context.github.repos.getFromOrg({ org: org.login }, _);
+
+ userRepos = userRepos.concat(repos);
+ }
}
}
+ } finally {
+ progress.end();
}
return userRepos;
@@ -340,6 +355,14 @@ exports.init = function (cli) {
cli.prompt(label, function (x) { callback(undefined, x); });
}
+ function promptPassword(label, callback) {
+ cli.password(label, function (x) { callback(undefined, x); });
+ }
+
+ function choose(data, callback) {
+ cli.choose(data, function (x) { callback(undefined, x); });
+ }
+
function displayLog(item) {
if (item.type === 'Warning') {
log.warn(item.short_time + ' ' + item.message);
Please sign in to comment.
Something went wrong with that request. Please try again.