Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Applying more code review comments

  • Loading branch information...
commit ad598c8da0d62002dd0f707e4721ec79f0750060 1 parent b62156d
@andrerod andrerod authored
View
12 lib/cli/commands/deployment_.js
@@ -176,20 +176,22 @@ exports.init = function (cli) {
.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')
+ .option('-r, --repository <repository>', 'The github repository full name (i.e. user/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,
+ github: {
+ username: options.username,
+ password: options.pass,
+ repositoryFullName: options.repository
+ },
flags: { }
};
- if (!context.remoteUri) {
+ if (!context.) {
// If no explicit github repository URI is passed
// this command always prompts the user for a repository
context.flags = { forceRepositorySelection: true };
View
10 lib/cli/commands/site_.js
@@ -123,7 +123,7 @@ exports.init = function (cli) {
.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')
+ .option('-r, --repository <repository>', 'The github repository full name (i.e. user/repository)')
.execute(function (nameArg, options, _) {
var context = {
subscription: cli.category('account').lookupSubscriptionId(options.subscription),
@@ -134,9 +134,11 @@ exports.init = function (cli) {
hostname: options.hostname
},
publishingUser: options.publishingUsername,
- username: options.username,
- password: options.pass,
- remoteUri: options.repository,
+ github: {
+ username: options.username,
+ password: options.pass,
+ repositoryFullName: options.repository
+ },
flags: { }
};
View
43 lib/cli/linkedrevisioncontrol.js
@@ -42,7 +42,16 @@ function LinkedRevisionControlClient(cli) {
this.cli = cli;};
+
+
+
+
+
+
LinkedRevisionControlClient.getRepository = function(repositories, remoteUri) {
+ console.log(repositories);
+ console.log(remoteUri);
+
var parsedRepositoryUri = url.parse(remoteUri);
var pathParts = parsedRepositoryUri.pathname.split("/");
if ((pathParts.length === 3)) {
@@ -60,7 +69,7 @@ LinkedRevisionControlClient.getRepository = function(repositories, remoteUri) {
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() {
+LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTree = function LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1(context, _) { var isInsideWorkTree, lines, __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_determineIfCurrentDirectoryIsGitWorkingTree__1", line: 72 }; 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() {
@@ -78,7 +87,7 @@ LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTre
-LinkedRevisionControlClient.prototype.initGitOnCurrentDirectory = function LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2(context, scaffold, _) { var __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2", line: 81 }; return __func(_, this, arguments, LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2, 2, __frame, function __$LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2() {
+LinkedRevisionControlClient.prototype.initGitOnCurrentDirectory = function LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2(context, scaffold, _) { var __this = this; var __frame = { name: "LinkedRevisionControlClient_prototype_initGitOnCurrentDirectory__2", line: 90 }; 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); } ;
@@ -110,12 +119,12 @@ function GitClient(cli) {
util.inherits(GitClient, LinkedRevisionControlClient);
-GitClient.prototype.init = function GitClient_prototype_init__3(context, _) { var __this = this; var __frame = { name: "GitClient_prototype_init__3", line: 113 }; return __func(_, this, arguments, GitClient_prototype_init__3, 1, __frame, function __$GitClient_prototype_init__3() {
+GitClient.prototype.init = function GitClient_prototype_init__3(context, _) { var __this = this; var __frame = { name: "GitClient_prototype_init__3", line: 122 }; 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, _);};
+GitClient.prototype.deploy = function GitClient_prototype_deploy__4(context, _) { var __frame = { name: "GitClient_prototype_deploy__4", line: 127 }; return __func(_, this, arguments, GitClient_prototype_deploy__4, 1, __frame, _);};
@@ -127,7 +136,7 @@ function GithubClient(cli) {
util.inherits(GithubClient, LinkedRevisionControlClient);
-GithubClient.prototype.authenticate = function GithubClient_prototype_authenticate__5(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_authenticate__5", line: 130 }; return __func(_, this, arguments, GithubClient_prototype_authenticate__5, 1, __frame, function __$GithubClient_prototype_authenticate__5() {
+GithubClient.prototype.authenticate = function GithubClient_prototype_authenticate__5(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_authenticate__5", line: 139 }; 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({
@@ -137,7 +146,7 @@ GithubClient.prototype.authenticate = function GithubClient_prototype_authentica
-GithubClient.prototype.authenticateAuth = function GithubClient_prototype_authenticateAuth__6(context, _) { var oauthToken, __this = this; var __frame = { name: "GithubClient_prototype_authenticateAuth__6", line: 140 }; return __func(_, this, arguments, GithubClient_prototype_authenticateAuth__6, 1, __frame, function __$GithubClient_prototype_authenticateAuth__6() {
+GithubClient.prototype.authenticateAuth = function GithubClient_prototype_authenticateAuth__6(context, _) { var oauthToken, __this = this; var __frame = { name: "GithubClient_prototype_authenticateAuth__6", line: 149 }; 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({
@@ -154,7 +163,7 @@ GithubClient.prototype.authenticateAuth = function GithubClient_prototype_authen
-GithubClient.prototype.ensureCredentials = function GithubClient_prototype_ensureCredentials__7(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_ensureCredentials__7", line: 157 }; return __func(_, this, arguments, GithubClient_prototype_ensureCredentials__7, 1, __frame, function __$GithubClient_prototype_ensureCredentials__7() {
+GithubClient.prototype.ensureCredentials = function GithubClient_prototype_ensureCredentials__7(context, _) { var __this = this; var __frame = { name: "GithubClient_prototype_ensureCredentials__7", line: 166 }; 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) {
@@ -168,7 +177,7 @@ GithubClient.prototype.ensureCredentials = function GithubClient_prototype_ensur
-GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _) { var repositories, __this = this; var __frame = { name: "GithubClient_prototype_init__8", line: 171 }; return __func(_, this, arguments, GithubClient_prototype_init__8, 1, __frame, function __$GithubClient_prototype_init__8() {
+GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _) { var repositories, __this = this; var __frame = { name: "GithubClient_prototype_init__8", line: 180 }; 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() {
@@ -194,7 +203,7 @@ GithubClient.prototype.init = function GithubClient_prototype_init__8(context, _
-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() {
+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: 206 }; 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";
@@ -235,7 +244,7 @@ GithubClient.prototype.getRepositories = function GithubClient_prototype_getRepo
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 (repository["private"] !== true); }; var __frame = { name: "GithubClient_prototype_getRepositories__10", line: 237 }; 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() {
@@ -267,7 +276,7 @@ GithubClient.prototype.getRepositories = function GithubClient_prototype_getRepo
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() {
+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: 279 }; return __func(_, this, arguments, GithubClient_prototype_createOrUpdateHook__11, 3, __frame, function __$GithubClient_prototype_createOrUpdateHook__11() {
hook = {
name: "web",
user: username,
@@ -311,7 +320,7 @@ GithubClient.prototype.createOrUpdateHook = function GithubClient_prototype_crea
-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() {
+GithubClient.prototype.createHook = function GithubClient_prototype_createHook__12(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_createHook__12", line: 323 }; 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() {
@@ -321,7 +330,7 @@ GithubClient.prototype.createHook = function GithubClient_prototype_createHook__
-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() {
+GithubClient.prototype.updateHook = function GithubClient_prototype_updateHook__13(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_updateHook__13", line: 333 }; 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() {
@@ -331,7 +340,7 @@ GithubClient.prototype.updateHook = function GithubClient_prototype_updateHook__
-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() {
+GithubClient.prototype.testHook = function GithubClient_prototype_testHook__14(hook, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_testHook__14", line: 343 }; 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() {
@@ -341,7 +350,7 @@ GithubClient.prototype.testHook = function GithubClient_prototype_testHook__14(h
-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() {
+GithubClient.prototype.getHooks = function GithubClient_prototype_getHooks__15(username, repository, _) { var progress, __this = this; var __frame = { name: "GithubClient_prototype_getHooks__15", line: 353 }; 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() {
@@ -354,7 +363,7 @@ GithubClient.prototype.getHooks = function GithubClient_prototype_getHooks__15(u
-GithubClient.prototype._getRemoteUri = function GithubClient_prototype__getRemoteUri__16(_) { var progress, originUri, __this = this; var __frame = { name: "GithubClient_prototype__getRemoteUri__16", line: 357 }; return __func(_, this, arguments, GithubClient_prototype__getRemoteUri__16, 0, __frame, function __$GithubClient_prototype__getRemoteUri__16() {
+GithubClient.prototype._getRemoteUri = function GithubClient_prototype__getRemoteUri__16(_) { var progress, originUri, __this = this; var __frame = { name: "GithubClient_prototype__getRemoteUri__16", line: 366 }; 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() {
@@ -370,7 +379,7 @@ GithubClient.prototype._getRemoteUri = function GithubClient_prototype__getRemot
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() {
+GithubClient.prototype._getRemote = function GithubClient_prototype__getRemote__17(name, _) { var remotes, origin, __this = this; var __frame = { name: "GithubClient_prototype__getRemote__17", line: 382 }; 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) {
View
100 lib/cli/linkedrevisioncontrol_.js
@@ -40,28 +40,27 @@ exports.GitClient = GitClient;
function LinkedRevisionControlClient(cli) {
this.cli = cli;
+ this.log = cli.output;
}
-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;
+/**
+* Returns a specific repository based on its github uri.
+*
+* @param {array} repositories The list of github repositories.
+* @param {string} remoteFullName The repository full name.
+*
+*/
+LinkedRevisionControlClient._getRepository = function (repositories, remoteFullName) {
+ return repositories.filter(function (repository) {
+ return repository.full_name === remoteFullName;
+ })[0];
};
+/**
+* Determines if the current directory is within a git repository tree.
+*/
LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTree = function (context, _) {
- this.cli.output.silly('determineIfCurrentDirectoryIsGitWorkingTree');
+ this.log.silly('determineIfCurrentDirectoryIsGitWorkingTree');
try {
var isInsideWorkTree = this._exec('git rev-parse --git-dir', _);
@@ -78,17 +77,20 @@ LinkedRevisionControlClient.prototype.determineIfCurrentDirectoryIsGitWorkingTre
}
};
+/**
+* Initializes a git repository in the current directory.
+*/
LinkedRevisionControlClient.prototype.initGitOnCurrentDirectory = function (context, scaffold, _) {
- this.cli.output.silly('initGitOnCurrentDirectoryIfNeeded');
+ this.log.silly('initGitOnCurrentDirectoryIfNeeded');
if (context.flags.isGitWorkingTree) {
return;
}
- this.cli.output.info('Executing `git init`');
+ this.log.info('Executing `git init`');
this._exec('git init', _);
if (scaffold && !utils.pathExistsSync('.gitignore')) {
- this.cli.output.info('Creating default .gitignore file');
+ this.log.info('Creating default .gitignore file');
fs.writeFile('.gitignore', 'node_modules\nazure_error', _);
}
@@ -132,8 +134,8 @@ GithubClient.prototype.authenticate = function (context, _) {
this.client.authenticate({
type: "basic",
- username: context.username,
- password: context.password
+ username: context.github.username,
+ password: context.github.password
});
};
@@ -142,12 +144,12 @@ GithubClient.prototype.authenticateAuth = function(context, _) {
this.client.authenticate({
type: "basic",
- username: context.username,
- password: context.password
+ username: context.github.username,
+ password: context.github.password
});
// Get auth token and switch authentication to oauth
- var oauthToken = this.client.oauth.createAuthorization({ user: context.username }, _);
+ var oauthToken = this.client.oauth.createAuthorization({ user: context.github.username }, _);
this.client.authenticate({
type: "oauth",
token: oauthToken.token
@@ -155,40 +157,48 @@ GithubClient.prototype.authenticateAuth = function(context, _) {
};
GithubClient.prototype.ensureCredentials = function (context, _) {
- if (!context.username || !context.password) {
- this.cli.output.help('Enter your github credentials');
+ if (!context.github) {
+ context.github = { };
}
- if (!context.username) {
- context.username = prompt(this.cli, 'Username: ', _);
+ if (!context.github.username || !context.github.password) {
+ this.log.help('Enter your github credentials');
}
- if (!context.password) {
- context.password = promptPassword(this.cli, 'Password: ', _);
+ if (!context.github.username) {
+ context.github.username = prompt(this.cli, 'Username: ', _);
+ }
+
+ if (!context.github.password) {
+ context.github.password = promptPassword(this.cli, 'Password: ', _);
}
};
GithubClient.prototype.init = function (context, _) {
this.authenticate(context, _);
+ // Initialize local git artifacts
this.determineIfCurrentDirectoryIsGitWorkingTree(context, _);
this.initGitOnCurrentDirectory(context, false, _);
- var repositories = this.getRepositories(context.username, _);
-
- if (!context.remoteUri) {
- // Look for git repository in local git remotes
- context.remoteUri = this._getRemoteUri(_);
+ // Find github repository
+ var repositories = this.getRepositories(context.github.username, _);
+ if (!(context.flags && context.flags.forceRepositorySelection) && !context.github.repositoryFullName) {
+ // Unless the user forced the command to prompt for repository or passed a repository
+ // as a parameter, try to find a github repository as a remote on the local folder
+ context.github.repositoryFullName = this._getRemoteUri(_);
}
- if (context.remoteUri) {
- context.repository = LinkedRevisionControlClient.getRepository(repositories, context.remoteUri);
+ if (context.github.repositoryFullName) {
+ // Match either the repository passed as parameter or the local folder remote git repository
+ // against the list of github repositories for the current github user
+ context.github.repository = LinkedRevisionControlClient._getRepository(repositories, context.github.repositoryFullName);
}
- if ((context.flags && context.flags.forceRepositorySelection) || !context.repository) {
- // Look for git repository in github
- this.cli.output.help('Choose a repository');
- context.repository = repositories[choose(this.cli, repositories.map(function (repository) {
+ if (!context.github.repository) {
+ // If there is no repository already determined, prompt the user to pick one
+ this.log.help('Choose a repository');
+ context.github.repository = repositories[choose(this.cli, repositories.map(function (repository) {
return repository.full_name;
}), _)];
}
@@ -213,14 +223,14 @@ GithubClient.prototype.deploy = function (context, _) {
var azureRemote = this._getRemote('azure', _);
if (azureRemote) {
- this.cli.output.verbose('Removing existing azure remote alias');
+ this.log.verbose('Removing existing azure remote alias');
this._exec('git remote rm azure', _);
}
}
if (!context.remoteUri) {
// create the remote repo locally
- this.cli.output.info('Executing `git remote add azure ' + gitUri + '`');
+ this.log.info('Executing `git remote add azure ' + gitUri + '`');
this._exec('git remote add azure ' + gitUri, _);
}
};
@@ -301,7 +311,7 @@ GithubClient.prototype.createOrUpdateHook = function (username, repository, depl
existingHook = this.updateHook(existingHook, _);
this.testHook(existingHook, _);
} else {
- this.cli.output.info('Link already established');
+ this.log.info('Link already established');
}
} else {
hook = this.createHook(hook, _);
View
4 test/cli/commands/cli.account-tests.js
@@ -18,8 +18,8 @@ var cli = require('../cli');
var capture = require('../util').capture;
suite('cli', function(){
- suite('account', function() {
- suite('import', function() {
+ suite('account', function() {
+ suite('import', function() {
test('should launch browser when there is no file name', function(done) {
capture(function() {
cli.parse('node cli.js account import data/account-credentials.publishsettings'.split(' '));
View
22 test/cli/commands/cli.site-tests.js
@@ -128,13 +128,6 @@ suite('cli', function(){
test('site create github', function(done) {
var siteName = 'cliuttestsite2';
- // Setup
- var originUrl = {
- stdout: 'myremote\tgit://github.com/andrerod/mynewsite999.git (fetch)\n' +
- 'myremote\tgit://github.com/andrerod/mynewsite999.git (push)\n',
- stderr: ''
- };
-
// Create site
var cmd = ('node cli.js site create ' + siteName + ' --github --json --location').split(' ');
cmd.push('East US');
@@ -229,6 +222,14 @@ suite('cli', function(){
result.text.should.equal('');
result.exitStatus.should.equal(0);
+ cmd.push('--github');
+ cmd.push('--username');
+ cmd.push(githubUsername);
+ cmd.push('--pass');
+ cmd.push(githubPassword);
+ cmd.push('--repository');
+ cmd.push(githubRepositoryUri);
+
// Rerun to make sure update hook works properly
capture(function() {
cli.parse(cmd);
@@ -238,13 +239,6 @@ suite('cli', function(){
// List sites
cmd = 'node cli.js site list --json'.split(' ');
- cmd.push('--github');
- cmd.push('--username');
- cmd.push(githubUsername);
- cmd.push('--pass');
- cmd.push(githubPassword);
- cmd.push('--repository');
- cmd.push(githubRepositoryUri);
capture(function() {
cli.parse(cmd);
Please sign in to comment.
Something went wrong with that request. Please try again.