Skip to content

Commit

Permalink
Merge branch 'develop' of bitbucket.org:modulus/fulcrum into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
InconceivableDuck committed Aug 22, 2013
2 parents 1f85705 + 5baea60 commit 35a919d
Show file tree
Hide file tree
Showing 4 changed files with 194 additions and 54 deletions.
124 changes: 111 additions & 13 deletions README.md
Expand Up @@ -32,7 +32,7 @@ You can also send feedback directly to Modulus using the *contact* command. Make

##Creating an Account

To start, you may need an account. Using the *signup* command, you can quickly create an account to get things rolling. It will prompt you for a few required pieces of information then set up and account.
To start, you may need an account. Using the *signup* command, you can quickly create an account to get things rolling. It will prompt you for a few required pieces of information then set up an account.

$ modulus signup
Welcome to Modulus
Expand All @@ -44,25 +44,17 @@ To start, you may need an account. Using the *signup* command, you can quickly c

You should receive an email at parker@example.com with more information.

Once you have an account, you need to log in. Running the *login* command will prompt you for your Modulus credentials or link your GitHub account in the web portal (under account settings) and add the *--github* flag to login using your GitHub credentials. This keeps a session open so you can run commands under your account and the session will not be closed unless you run the logout command.
Once you have an account, you need to log in. Running the *login* command will prompt you for your Modulus credentials or if you have linked your GitHub account in the web portal (under account settings) you can use the *--github* flag to login using your GitHub credentials. This keeps a session open so you can run commands under your account and the session will not be closed unless you run the *logout* command or log in with a different account.

$ modulus login
Welcome to Modulus
[?] Enter your username or email: spiderman
[?] Enter your password:
[√] Signed in as user spiderman

When you first create an account it is in a “beta locked” state. This means you cannot create or manage any projects until you unlock your account. Running the *unlock* command will prompt you for a beta code and unlock your account when a valid one is given.

$ modulus unlock
Welcome to Modulus
You are logged in as spiderman
[?] Enter a beta code: 2hMN2HFZ
[√] Your account has been unlocked. You may now create and deploy projects

##Project Management

Once unlocked, you are ready to create a project. This is done with the *project create* command, and all that is required is a name.
Once logged in, you are ready to create a project. This is done with the *project create* command, and all that is required is a name.

$ modulus project create
Welcome to Modulus
Expand All @@ -82,7 +74,68 @@ To deploy an application to your new project, you can use either the *project de
Uploading project...
Upload progress [===================] 100%
Deploying Project...
Deploying [ = ]
INFO: Attaching persistent storage.
INFO: Found package.json file: /package.json
INFO: Node version not specifed in package.json, using latest stable version.
INFO: Initializing Node v0.10.13
INFO: Running npm install.
INFO: Registry: http://registry.npmjs.org
npm http GET http://registry.npmjs.org/express
npm http 304 http://registry.npmjs.org/express
npm http GET http://registry.npmjs.org/qs
npm http GET http://registry.npmjs.org/connect
npm http GET http://registry.npmjs.org/mime/1.2.4
npm http GET http://registry.npmjs.org/mkdirp/0.3.0
npm http 304 http://registry.npmjs.org/qs
npm http 304 http://registry.npmjs.org/connect
npm http 304 http://registry.npmjs.org/mime/1.2.4
npm http 304 http://registry.npmjs.org/mkdirp/0.3.0
npm http GET http://registry.npmjs.org/mime/-/mime-1.2.4.tgz
npm http GET http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz
npm http GET http://registry.npmjs.org/qs/-/qs-0.4.2.tgz
npm http 200 http://registry.npmjs.org/mime/-/mime-1.2.4.tgz
npm http 200 http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz
npm http 200 http://registry.npmjs.org/qs/-/qs-0.4.2.tgz
npm http GET http://registry.npmjs.org/formidable
npm http 304 http://registry.npmjs.org/formidable
express@2.5.11 node_modules/express
├── qs@0.4.2
├── mime@1.2.4
├── mkdirp@0.3.0
└── connect@1.9.2 (formidable@1.0.14)
INFO: Main file found: /app.js
INFO: Starting application.
Express server started on port 8080
[2013-08-22T17:53:42.245Z] Application initialized with pid 11010
[√] Lizard Locator running at lizard-locator-895.onmodulus.net

The project's logs will be streamed in real-time during a deploy. You should see some information about Modulus' activity, as well as the NPM install process. In future deploy examples, these logs will be replaced for "...".

You can also pass in a directory as a command argument, if you do not want to deploy the current directory.

$ modulus deploy my/project/directory
Welcome to Modulus
You are logged in as spiderman
[?] Are you sure you want to use project Lizard Locator? (yes) yes
Compressing project...
2.9 KB written
Uploading project...
Upload progress [===================] 100%
Deploying Project...
...
[√] Lizard Locator running at lizard-locator-895.onmodulus.net

If you know which project you want to deploy to, you can use the *-p* option and provide the name of the project you would like to deploy to.

$ modulus deploy -p "Lizard Locator" my/project/directory
Welcome to Modulus
You are logged in as spiderman
Compressing project...
2.9 KB written
Uploading project...
Upload progress [===================] 100%
Deploying Project...
...
[√] Lizard Locator running at lizard-locator-895.onmodulus.net

##Environment Variables
Expand Down Expand Up @@ -114,4 +167,49 @@ If you have no need for a variable anymore, you can provide the *env delete* com
Deleting DB_AUTH for project Lizard Locator
[√] Successfully deleted variable DB_AUTH from project Lizard Locator

At any time, if you want to view the value of a single variable, use the *env get* command. It takes a name parameter and will display the value of the variable of the name you specify.
At any time, if you want to view the value of a single variable, use the *env get* command. It takes a name parameter and will display the value of the variable of the name you specify.

##Logs

In times when you need to check up on your projects, you can view the project's logs. This is done with the *project logs* command, which supports the *-p* option.

$ ./bin/modulus project logs -p "Lizard Locator"
Welcome to Modulus
You are logged in as spiderman
INFO: Attaching persistent storage.
INFO: Found package.json file: /package.json
INFO: Node version not specifed in package.json, using latest stable version.
INFO: Initializing Node v0.10.13
INFO: Running npm install.
INFO: Registry: http://registry.npmjs.org
npm http GET http://registry.npmjs.org/express
npm http 304 http://registry.npmjs.org/express
npm http GET http://registry.npmjs.org/qs
npm http GET http://registry.npmjs.org/connect
npm http GET http://registry.npmjs.org/mime/1.2.4
npm http GET http://registry.npmjs.org/mkdirp/0.3.0
npm http 304 http://registry.npmjs.org/qs
npm http 304 http://registry.npmjs.org/connect
npm http 304 http://registry.npmjs.org/mime/1.2.4
npm http 304 http://registry.npmjs.org/mkdirp/0.3.0
npm http GET http://registry.npmjs.org/mime/-/mime-1.2.4.tgz
npm http GET http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz
npm http GET http://registry.npmjs.org/qs/-/qs-0.4.2.tgz
npm http 200 http://registry.npmjs.org/mime/-/mime-1.2.4.tgz
npm http 200 http://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz
npm http 200 http://registry.npmjs.org/qs/-/qs-0.4.2.tgz
npm http GET http://registry.npmjs.org/formidable
npm http 304 http://registry.npmjs.org/formidable
express@2.5.11 node_modules/express
├── qs@0.4.2
├── mime@1.2.4
├── mkdirp@0.3.0
└── connect@1.9.2 (formidable@1.0.14)
INFO: Main file found: /app.js
INFO: Starting application.
Express server started on port 8080
[2013-08-22T17:53:42.245Z] Application initialized with pid 11010

[✓] Logs successfully retrieved.

While these logs are not streamed directly to the CLI, the logs themselves are updated in real-time, so anytime you retrieve them they are current.
87 changes: 57 additions & 30 deletions lib/commands/user.js
Expand Up @@ -5,7 +5,7 @@ var modulus = require('../modulus'),

var user = {};

user.authenticate = function(username, password, cb) {
user.authenticate = function(username, password, loginProvided, passwordProvided, cb) {
userController.authenticate(
username,
password,
Expand All @@ -14,7 +14,16 @@ user.authenticate = function(username, password, cb) {
err = error.handleApiError(err, 'LOGIN', cb);
if (err.length > 0) {
modulus.io.error(err);
return user.login(false, cb);

if(loginProvided && passwordProvided) {
return;
} else if(loginProvided) {
return user.login(username, null, false, cb);
} else if(passwordProvided) {
return user.login(null, password, false, cb);
} else {
return user.login(null, null, false, cb);
}
}
}
var udata = {
Expand All @@ -28,7 +37,7 @@ user.authenticate = function(username, password, cb) {
});
};

user.authenticateGithub = function(username, password, cb) {
user.authenticateGithub = function(username, password, loginProvided, passwordProvided, cb) {
userController.authenticateGithub(
username,
password,
Expand All @@ -37,7 +46,16 @@ user.authenticateGithub = function(username, password, cb) {
err = error.handleApiError(err, 'LOGIN', cb);
if(err.length > 0) {
modulus.io.error(err);
return user.login(true, cb);

if(loginProvided && passwordProvided) {
return;
} else if(loginProvided) {
return user.login(username, null, true, cb);
} else if(passwordProvided) {
return user.login(null, password, true, cb);
} else {
return user.login(null, null, true, cb);
}
}
}
var udata = {
Expand Down Expand Up @@ -124,43 +142,52 @@ var _signupPrompt = function(cb) {
});
};

user.login = function(github, cb) {
if (github) {
modulus.io.prompt.get([{
name: 'login',
description: 'Enter your GitHub username or email:',
required: true
}, {
name: 'password',
description: 'Enter your password:',
hidden: true,
required: true
}], function (err, result) {
if(err) {
return error.handlePromptError(err, cb);
}
user.login = function(username, password, github, cb) {
var login = username,
loginProvided = true,
pass = password,
passProvided = true,
prompt = [],
authFunction = github ? user.authenticateGithub : user.authenticate;

user.authenticateGithub(result.login, result.password, cb);
});
} else {
modulus.io.prompt.get([{
if(typeof login !== 'string' || login.length < 1) {
prompt.push({
name: 'login',
description: 'Enter your username or email:',
required: true
}, {
});

if(github) {
prompt[0].description = 'Enter your GitHub username or email:';
}

login = undefined;
loginProvided = false;
}

if(typeof pass !== 'string' || pass.length < 1) {
prompt.push({
name: 'password',
description: 'Enter your password:',
hidden: true,
required: true
}], function (err, result) {
if(err) {
return error.handlePromptError(err, cb);
}
});

user.authenticate(result.login, result.password, cb);
pass = undefined;
passProvided = false;
}

if(prompt.length > 0) {
modulus.io.prompt.get(prompt, function (err, result) {
if(err) {
return error.handlePromptError(err, cb);
}
authFunction.call(user, login || result.login, pass || result.password, loginProvided, passProvided, cb);
});
}

else {
authFunction.call(user, login, password, loginProvided, passProvided, cb);
}
};

user.logout = function(cb) {
Expand Down
31 changes: 20 additions & 11 deletions lib/controllers/project.js
Expand Up @@ -172,6 +172,20 @@ Project.prototype.deploy = function(projectId, file, callback) {

client.on('end', function() {

var logLength = 0;
var getDeployLogs = function(cb) {
librarian.project.getDeployLogs(projectId, userConfig.data.apiKey, function(err, result) {
for(var key in result) {
var log = result[key];
modulus.io.write(log.substring(logLength));
logLength = log.length;
break;
}

cb();
});
};

// check every second for project status change
var projectStatus = function () {
librarian.project.find({projectId : projectId}, userConfig.data.apiKey, function(err, proj) {
Expand All @@ -183,8 +197,11 @@ Project.prototype.deploy = function(projectId, file, callback) {
status = newStatus;
modulus.io.print('\nDeploying Project...');
} else if(newStatus === Project.status.running && status !== Project.status.uploading) {
modulus.io.print(' ');
return callback(null, proj.domain);
getDeployLogs(function() {
modulus.io.print(' ');
callback(null, proj.domain);
});
return;
}
}
}
Expand All @@ -197,17 +214,9 @@ Project.prototype.deploy = function(projectId, file, callback) {
};
projectStatus();

var logLength = 0;
var deployLogs = function() {
if(status === Project.status.deploying) {
librarian.project.getDeployLogs(projectId, userConfig.data.apiKey, function(err, result) {
for(var key in result) {
var log = result[key];
modulus.io.write(log.substring(logLength));
logLength = log.length;
break;
}
});
getDeployLogs(function(){});
}

if(status !== Project.status.running) {
Expand Down
6 changes: 6 additions & 0 deletions lib/routes/user.js
Expand Up @@ -20,10 +20,14 @@ module.exports = function(modulus) {
this.line('login'.verbose);
this.line('Log in to your Modulus account.'.input);
this.line(' options:'.input);
this.line(' --username The username to log in with.'.input);
this.line(' --password The password to use when logging in.'.input);
this.line(' -g, --github Log in using your GitHub credentials.'.input);
});

modulus.program
.option('-u, --username [value]', 'The username to log in with.')
.option('-P, --password [value]', 'The password to use when logging in.')
.option('-g, --github', 'Log in using your GitHub credentials.');

modulus.program
Expand All @@ -32,6 +36,8 @@ module.exports = function(modulus) {
.on('--help', help.commands.login)
.action(function() {
modulus.runCommand(modulus.commands.user.login, [
modulus.program.username,
modulus.program.password,
typeof modulus.program.github === 'undefined' ? false : modulus.program.github
]);
});
Expand Down

0 comments on commit 35a919d

Please sign in to comment.