Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-pages script #30

Merged
merged 1 commit into from
Sep 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,14 @@ If you'd like to hack on this project and don't have access to the npm repos, co
npm login

And fire up __[http://localhost:9000](http://localhost:9000)__!


## Publishing to GitHub Pages

To publish to __https://mozvr.github.io/vr-components/__:

npm run ghpages

To publish to __https://cvan.github.io/vr-components/__:

npm run ghpages cvan
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
"browserify": "browserify ./index.js -s 'vr-components' -t browserify-css",
"build": "mkdir -p build/ && npm run browserify -- --debug -o build/vr-components.js",
"dist": "mkdir -p dist/ && npm run browserify -- --debug -o dist/vr-components.js && uglifyjs dist/vr-components.js -c warnings=false -m -o dist/vr-components.min.js",
"replacepaths": "replace 'build/vr-components.js' 'dist/vr-components.min.js' gh-pages/ -r",
"preghpages": "npm run dist && rm -rf gh-pages && mkdir -p gh-pages && cp -r {.nojekyll,dist,lib,examples,index.html,style} gh-pages/. && git checkout dist/ && replace 'build/vr-components.js' 'dist/vr-components.min.js' gh-pages/ -r --silent",
"ghpages": "node ./scripts/gh-pages",
"gh-pages": "npm run ghpages",
"preghpages": "mkdir -p gh-pages && cp -r {.nojekyll,dist,lib,examples,index.html,style} gh-pages/. && npm run replacepaths",
"ghpages": "gh-pages -d gh-pages && rm -rf gh-pages",
"release": "npm version patch --minor && npm login && npm publish",
"lint": "semistandard -v $(git ls-files '*.js') | snazzy",
"precommit": "npm run lint"
Expand Down
63 changes: 63 additions & 0 deletions scripts/gh-pages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env node

/**
* Fancy script to deploy to GitHub Pages
* ======================================
*
* Sample usage
* ------------
*
* % node ./scripts/gh-pages
* gh-pages -d dist -r git@github.com:MozVR/vr-components.git
*
* % node ./scripts/gh-pages cvan
* gh-pages -d dist -r git@github.com:cvan/vr-components.git
*
* % node ./scripts/gh-pages git@github.com:dmarcos/vr-components.git
* gh-pages -d dist -r git@github.com:dmarcos/vr-components.git
*
*/

var spawn = require('child_process').spawn;

var ghpages = require('gh-pages');
var path = require('path');

var repo = {
username: 'MozVR',
name: 'vr-components'
};

var arg = process.argv[2];
if (arg) {
if (arg.indexOf(':') === -1) {
repo.username = arg;
} else {
repo.url = arg;
var usernameMatches = arg.match(':(.+)/');
if (usernameMatches) {
repo.username = usernameMatches[1];
}
}
}

if (!repo.url) {
repo.url = 'git@github.com:' + repo.username + '/' + repo.name + '.git';
}

repo.ghPagesUrl = 'https://' + repo.username + '.github.io/' + repo.name + '/';

console.log('Publishing to', repo.url);

ghpages.clean();
ghpages.publish(path.join(process.cwd(), 'gh-pages'), {
repo: repo.url,
dotfiles: true,
logger: function (message) {
console.log(message);
}
}, function () {
console.log('Published');
console.log(repo.ghPagesUrl);
spawn('open', [repo.ghPagesUrl]);
});