Skip to content

Commit

Permalink
Add browserify and build commands for compiling browser friendly libr…
Browse files Browse the repository at this point in the history
…ary.

Note this depends on request's built in support for being browser friendly: request/request#455.
  • Loading branch information
phillbaker committed Mar 17, 2016
1 parent 4787739 commit 83e87a4
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 1 deletion.
1 change: 1 addition & 0 deletions .jshintignore
@@ -1,2 +1,3 @@
dist
node_modules
test
22 changes: 22 additions & 0 deletions README.md
Expand Up @@ -109,6 +109,28 @@ client.droplets.list(function (err, account, headers, response) {
npm test
```

## Usage in the Browser

This library is also available as a single file built for usage in the browser at `dist/digitalocean.js`. It uses [browserify](http://browserify.org/) to package all dependencies and output the built file. This file is updated and released to [Bower](https://bower.io) for each release with the same version.


For example, using the built file at `dist/digitalocean.js`:
```html
<html>
<head></head>
<body>
<script src="dist/digitalocean.js"></script>
<script>
var client = digitalocean.client('TOKEN');
client.account.get(function(_, account) {
console.log(account.uuid);
});
</script>
</body>
</html>
```

## License

MIT
Expand Down
28 changes: 28 additions & 0 deletions bower.json
@@ -0,0 +1,28 @@
{
"name": "digitalocean",
"description": "js wrapper for digitalocean v2 api",
"main": "dist/digitalocean.js",
"authors": [
"Phillip Baker <phillbaker@retrodict.com>"
],
"license": "MIT",
"keywords": [
"wrapper",
"api",
"v2",
"droplet",
"digitalocean",
"digital ocean"
],
"homepage": "https://github.com/phillbaker/digitalocean-node",
"moduleType": [
"node"
],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
]
}
13 changes: 12 additions & 1 deletion package.json
Expand Up @@ -12,13 +12,24 @@
"digitalocean"
],
"scripts": {
"test": "mocha --bail --recursive --reporter dot"
"test": "mocha --bail --recursive --reporter dot",
"clean": "rm -r dist/*",
"build:js": "browserify lib/digitalocean.js -o dist/digitalocean.js --standalone 'digitalocean'",
"build": "mkdir -p dist && npm run build:js",
"preversion": "npm test",
"version": "npm run build && git add -A dist",
"release": "git push --follow-tags && npm publish",
"release:patch": "npm version patch -m 'Bump version to %s'",
"release:minor": "npm version minor -m 'Bump version to %s'",
"release:major": "npm version major -m 'Bump version to %s'"
},
"dependencies": {
"deep-extend": "0.x.x",
"request": "2.51.x"
},
"devDependencies": {
"bower": ">= 0.0.0",
"browserify": "^13.0.0",
"chai": "~1.10.0",
"mocha": "~2.1.0",
"mocha-jshint": "^2.3.1",
Expand Down

0 comments on commit 83e87a4

Please sign in to comment.