Skip to content

Commit

Permalink
Merge branch '0.11.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
scottcorgan committed May 23, 2014
2 parents 0565765 + 16f4eb9 commit c65e9e2
Show file tree
Hide file tree
Showing 9 changed files with 383 additions and 6 deletions.
93 changes: 93 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,36 @@ CLI for Divshot
* [domains](#domains) - list your domains
* [domains:add](#domainsadd) - add a custom domain to your app
* [domains:remove](#domainsremove) - remove a custom domain from your app
* [emails](#emails) - list emails associated with your app
* [emails:add](#emailsadd) - add an email to your app
* [emails:remove](#emailsremove) - remove an email from your app
* [emails:resend](#emailsresend) - resend the confirmation email
* [env](#env) - list environment variables for your app
* [env:add](#envadd) - add an environment variable to your app
* [env:pull](#envpull) - copy environment data to your local environment
* [files](#files) - list the current files associated with the given environment
* [help](#help) - get help with common commands
* [init](#init) - step by step guide to initiate an app in the current directory
* [login](#login) - login to Divshot
* [logout](#logout) - logout from Divshot
* [open](#open) - open the current app in your default browser
* [promote](#promote) - promote one environment to another
* [protect](#protect) - add http basic auth to any environment
* [pull](#pull) - download the current files for a given environment into a directory
* [push](#push) - deploy your app to the specified environment
* [rename](#rename) - change the name of an app
* [rollback](#rollback) - rollback an environment to a previous release
* [server](#server) - start server for local dev
* [status](#status) - show release info for each environment
* [unprotect](#unprotect) - remove basic auth from an environment on your app

#### Command Options

* `-h, --help` - show the help menu
* `-v, --version` - show current version of Divshot CLI
* `-t, --token [token] ` - manually pass access token
* `-a, --app [app name] ` - manually supply an app name
* `-c, --config [config] ` - use a different config file

####Environments

Expand Down Expand Up @@ -151,6 +162,70 @@ divshot domains:remove [domain]

Remove a custom domain from your app. You may see a list of your domains with [` divshot domains `](#domains). For more in-depth usage, see [Divshot Custom Domains](http://docs.divshot.io/guides/domains).

### emails

```
divshot emails
```

Show any emails associated with this app. Also shows which emails have been approved and which emails are pending authorization by the email owner.

### emails:add

```
divshot emails:add [email]
```

Add an email to the current app. Once added, the email will receive an email that the email owner must use to authorize the email address.

### emails:remove

```
divshot emails:remove [email]
```

Remove an email from the current app.

### emails:resend

```
divshot emails:resend [email]
```

Resend the the authorization email for the given email address.

### env

```
divshot env [environment]
```

List the key/value pairs of environment variables associated with the given environment on the current app. See [Environment Variables](http://docs.divshot.com/guides/environment-variables) for more details.

### env:add

```
divshot env:add [environment] KEY=value KEY2=value ...
```

Add environment variables to the current app. See [Environment Variables](http://docs.divshot.com/guides/environment-variables) for more details.

### env:pull

```
divshot env:pull [environment]
```

Copy environment data to your local environment. Creates a `.env.json` file that is available to your app with `__env.js` or `__env.json`. See [Environment Variables](http://docs.divshot.com/guides/environment-variables) for more details.

### files

```
divshot files [environment]
```

List the files currently associated with the given environment. These are the files that were deployed to Divshot using [divshot push](#push)

### help

```
Expand Down Expand Up @@ -230,6 +305,14 @@ divshot protect [environment] [username:password]

Protect your development and staging environments with [http authentication](http://en.wikipedia.org/wiki/Basic_access_authentication).

### pull

```
divshot pull [environment] [optional directory]
```

Download all the files currently associated with the given environment. If no directory is provided, it defaults to the current directory. These files are the files deployed to Divshot using [divshot push](#push)

### push

```
Expand Down Expand Up @@ -275,3 +358,13 @@ divshot status [environment]

Show release info for each environment. If no environment is specified, the latest release info will be listed for each environment. If an environment is specified, it will list the last few releases for that environment. See [environments](#environments) for a list of available environments.

### unprotect

```
divshot unprotect [environment]
```

Unprotect your development and staging environments and remove the authentication.



202 changes: 202 additions & 0 deletions lib/commands/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
var _ = require('lodash');
var request = require('request');
var format = require('chalk');
var markdown = require('markdown');

module.exports = function (cli) {
// var changelog = cli.command('changelog')
// .description('view info for the latest changes the the Divshot cli')
// .handler(function (done) {
// var requestOptions = {
// uri: 'https://api.github.com/repos/divshot/divshot-cli/releases',
// method: 'GET',
// headers: {'user-agent': 'node.js'}
// };

// // request(requestOptions, function (err, response, body) {
// // if (response.statusCode !== 200) {}


// // var releases = JSON.parse(body);
// var releases = mockReleases();

// releases.reverse().forEach(function (release) {
// cli.log('\n');
// cli.log(format[cli.color]('=== ' + release.name));
// cli.log();

// var tree = markdown.markdown.toHTML(release.body);

// tree = tree
// .replace(/<li>/gi, ' * ')
// .replace(/<\/li>/gi, '\n')
// .replace(/<ul>/gi, '')
// .replace(/<\/ul>/gi, '')
// .replace(/<p>/gi, '')
// .replace(/<\/p>/gi, '\n')

// tree = tree.split('\n')
// .filter(function (line) {
// if (line !== '') return true;
// })
// .map(function (line) {
// if (matches = line.match(/<strong>([^<]+)<\/strong>/i)) {
// return format.bold(matches[1]);
// }
// // else if (matches = line.replace(/[^<]*(<a href="([^"]+)">([^<]+)<\/a>)/i, '$3')) {
// // return matches;
// // }
// else {
// return line;
// }
// });

// console.log(tree);

// // _(tree)
// // .tail()
// // .each(parseNode);

// // function parseNode (node) {
// // var attrs;
// // var textNodes = _.tail(node);
// // var wrapperTagName = node[0];

// // if (_.isObject(textNodes[0]) && !_.isArray(textNodes[0])) {
// // attrs = textNodes[0];
// // textNodes = _.tail(textNodes);
// // }

// // _(textNodes)
// // .each(function (node) {
// // if (typeof node === 'string') {
// // if (wrapperTagName === 'italic') node = format.italic(node);
// // if (wrapperTagName === 'strong') node = format.bold(node);
// // if (wrapperTagName === 'h1') node = format.bold(node);
// // if (wrapperTagName === 'h2') node = format.bold(node);
// // if (wrapperTagName === 'h3') node = format.bold(node);
// // if (wrapperTagName === 'h4') node = format.bold(node);
// // if (wrapperTagName === 'h5') node = format.bold(node);
// // if (wrapperTagName === 'h6') node = format.bold(node);

// // process.stdout.write(node);
// // }

// // if (_.isObject(node)) {
// // parseNode(node);
// // }
// // });

// // if (wrapperTagName === 'p') cli.log('\n');
// // }

// // cli.log();
// });
// // });

// });

// changelog.task('open')
// .description('open the changelog on Github')
// .handler(function () {
// console.log('open');
// });
// };

// function mockReleases () {
// return [ { url: 'https://api.github.com/repos/divshot/divshot-cli/releases/318945',
// assets_url: 'https://api.github.com/repos/divshot/divshot-cli/releases/318945/assets',
// upload_url: 'https://uploads.github.com/repos/divshot/divshot-cli/releases/318945/assets{?name}',
// html_url: 'https://github.com/divshot/divshot-cli/releases/tag/0.10.0',
// id: 318945,
// tag_name: '0.10.0',
// target_commitish: 'master',
// name: '0.10.0',
// draft: false,
// author:
// { login: 'scottcorgan',
// id: 974723,
// avatar_url: 'https://avatars.githubusercontent.com/u/974723?',
// gravatar_id: '061f75a1a59b4a089d82e79f773ce424',
// url: 'https://api.github.com/users/scottcorgan',
// html_url: 'https://github.com/scottcorgan',
// followers_url: 'https://api.github.com/users/scottcorgan/followers',
// following_url: 'https://api.github.com/users/scottcorgan/following{/other_user}',
// gists_url: 'https://api.github.com/users/scottcorgan/gists{/gist_id}',
// starred_url: 'https://api.github.com/users/scottcorgan/starred{/owner}{/repo}',
// subscriptions_url: 'https://api.github.com/users/scottcorgan/subscriptions',
// organizations_url: 'https://api.github.com/users/scottcorgan/orgs',
// repos_url: 'https://api.github.com/users/scottcorgan/repos',
// events_url: 'https://api.github.com/users/scottcorgan/events{/privacy}',
// received_events_url: 'https://api.github.com/users/scottcorgan/received_events',
// type: 'User',
// site_admin: false },
// prerelease: false,
// created_at: '2014-05-14T00:35:38Z',
// published_at: '2014-05-14T00:44:20Z',
// assets: [],
// tarball_url: 'https://api.github.com/repos/divshot/divshot-cli/tarball/0.10.0',
// zipball_url: 'https://api.github.com/repos/divshot/divshot-cli/zipball/0.10.0',
// body: 'View the [0.10.0 milestone](https://github.com/divshot/superstatic/issues?milestone=2&page=1&state=closed) for full details.\r\n\r\n**Major updates**\r\n\r\n* [Updated Superstatic to 0.10.0](https://github.com/divshot/divshot-cli/issues/83) - that means it\'s faster, more stable, and adds the [redirects](https://github.com/divshot/superstatic/issues/50) configuration!\r\n* [Package out of date notification](https://github.com/divshot/divshot-cli/issues/80) - get notified when there is a newer version of divshot-cli\r\n* [Get specific configuration values](https://github.com/divshot/divshot-cli/issues/41) - no need to list your entire app\'s configuration. just use `divshot config <config name>` to get a specific value!\r\n* [Version badge](https://github.com/divshot/divshot-cli/issues/84) - Added a version badge so you always know the latest version on NPM\r\n* Various bug fixes' },
// { url: 'https://api.github.com/repos/divshot/divshot-cli/releases/244657',
// assets_url: 'https://api.github.com/repos/divshot/divshot-cli/releases/244657/assets',
// upload_url: 'https://uploads.github.com/repos/divshot/divshot-cli/releases/244657/assets{?name}',
// html_url: 'https://github.com/divshot/divshot-cli/releases/tag/0.9.0',
// id: 244657,
// tag_name: '0.9.0',
// target_commitish: 'master',
// name: '0.9.0 - Improved Authentication Flow',
// draft: false,
// author:
// { login: 'mbleigh',
// id: 1022,
// avatar_url: 'https://avatars.githubusercontent.com/u/1022?',
// gravatar_id: '69dc78b59ef008c58e6e842f9f3e0624',
// url: 'https://api.github.com/users/mbleigh',
// html_url: 'https://github.com/mbleigh',
// followers_url: 'https://api.github.com/users/mbleigh/followers',
// following_url: 'https://api.github.com/users/mbleigh/following{/other_user}',
// gists_url: 'https://api.github.com/users/mbleigh/gists{/gist_id}',
// starred_url: 'https://api.github.com/users/mbleigh/starred{/owner}{/repo}',
// subscriptions_url: 'https://api.github.com/users/mbleigh/subscriptions',
// organizations_url: 'https://api.github.com/users/mbleigh/orgs',
// repos_url: 'https://api.github.com/users/mbleigh/repos',
// events_url: 'https://api.github.com/users/mbleigh/events{/privacy}',
// received_events_url: 'https://api.github.com/users/mbleigh/received_events',
// type: 'User',
// site_admin: false },
// prerelease: false,
// created_at: '2014-03-26T20:46:41Z',
// published_at: '2014-03-27T23:35:34Z',
// assets: [],
// tarball_url: 'https://api.github.com/repos/divshot/divshot-cli/tarball/0.9.0',
// zipball_url: 'https://api.github.com/repos/divshot/divshot-cli/zipball/0.9.0',
// body: 'In this release, `divshot login` has received a big upgrade to a new, PIN-less authentication system. When run, it should open your browser to Divshot\'s authentication server. Once authenticated, the client will gain authorization without you needing to enter a PIN code.' } ];
// }

// function mockTree () {
// return [ 'html',
// [ 'p',
// 'View the ',
// [ 'a', [Object], '0.10.0 milestone' ],
// ' for full details.' ],
// [ 'p', [ 'strong', 'Major updates' ] ],
// [ 'ul',
// [ 'li',
// [Object],
// ' - that means it\'s faster, more stable, and adds the ',
// [Object],
// ' configuration!' ],
// [ 'li',
// [Object],
// ' - get notified when there is a newer version of divshot-cli' ],
// [ 'li',
// [Object],
// ' - no need to list your entire app\'s configuration. just use ',
// [Object],
// ' to get a specific value!' ],
// [ 'li',
// [Object],
// ' - Added a version badge so you always know the latest version on NPM' ],
// [ 'li', 'Various bug fixes' ] ] ];
}
6 changes: 3 additions & 3 deletions lib/commands/emails.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ module.exports = function (cli) {
.before('authenticate')
.handler(showUserEmails);

emails.task('add')
emails.task('add <email>')
.description('add an email to your account')
.handler(addEmail);

emails.task('remove')
emails.task('remove <email>')
.description('remove an email from your account')
.handler(removeEmail);

emails.task('resend')
emails.task('resend <email>')
.description('resend the confirmation for an email')
.handler(resend);

Expand Down
32 changes: 32 additions & 0 deletions lib/commands/files.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var _ = require('lodash');
var format = require('chalk');

module.exports = function (cli) {
cli.command('files <environment>')
.description('show a list of the files for the given environment')
.before('authenticate')
.handler(function (environment, done) {
if (!environment) return done(cli.errors.MISSING_ENVIRONMENT);

var appName = cli.cwd.getConfig().name;

if (!appName) return done(cli.errors.DIRECTORY_NOT_APP);

var app = cli.api.apps.id(appName);

app.releases.env(environment).get().then(function (releases) {
var release = _(releases)
.sortBy(version)
.last();

cli.log();
cli.logObject(release.build.files);

done(null, release.build.files);
});

function version (release) {
return release.version;
}
});
};
Loading

0 comments on commit c65e9e2

Please sign in to comment.