From 9f4685314a781719fa6d5bb4938e92a2f35146c7 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sat, 17 Oct 2015 13:40:42 +0100 Subject: [PATCH 01/15] refactor: invoke 'ng build' instead of 'ember build' --- lib/commands/commit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/commit.js b/lib/commands/commit.js index 20c8f89..0af14c8 100644 --- a/lib/commands/commit.js +++ b/lib/commands/commit.js @@ -33,7 +33,7 @@ module.exports = { function buildApp() { var env = options.environment; - return runCommand('ember build --environment=' + env, execOptions); + return runCommand('ng build --environment=' + env, execOptions); } function checkoutGhPages() { From 99b7da28b887aad9727eda61b9bc59eeea1f14e3 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sat, 17 Oct 2015 14:54:23 +0100 Subject: [PATCH 02/15] chore: fork package.json and rename to angular-cli-github-pages --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 943daa6..a77914e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "ember-cli-github-pages", - "description": "Easily manage gh-pages of your ember-cli addon", + "name": "angular-cli-github-pages", + "description": "Easily manage gh-pages of your angular-cli addon", "version": "0.0.6", "directories": { "doc": "doc", @@ -11,7 +11,7 @@ "build": "ember build", "test": "ember test" }, - "repository": "https://github.com/poetic/ember-cli-github-pages", + "repository": "https://github.com/IgorMinar/angular-cli-github-pages", "engines": { "node": ">= 0.10.0" }, From 842f34ac7fd44ea2c399002a864f9373805804bb Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sun, 18 Oct 2015 17:18:23 +0100 Subject: [PATCH 03/15] full workflow works, but needs a lot of cleanup + multiplatform compatibility --- index.js | 2 +- lib/commands/commit.js | 108 +++++++++++++++++++++++++++++++++++------ package.json | 3 +- 3 files changed, 97 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index a771b8f..2e35afc 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ module.exports = { includedCommands: function() { return { - 'github-pages:commit': require('./lib/commands/commit') + 'github-pages:deploy': require('./lib/commands/commit') }; } }; diff --git a/lib/commands/commit.js b/lib/commands/commit.js index 0af14c8..c85ba48 100644 --- a/lib/commands/commit.js +++ b/lib/commands/commit.js @@ -2,11 +2,15 @@ var exec = require('child_process').exec; var RSVP = require('rsvp'); +var https = require('https'); +var querystring = require('querystring'); +var inquire = require('inquirer'); + module.exports = { - name: 'github-pages:commit', - aliases: ['gh-pages:commit'], - description: 'Build the test app for production and commit it into a git branch', + name: 'github-pages:deploy', + aliases: ['gh-pages:deploy'], + description: 'Build the test app for production, commit it into a git branch, setup GitHub repo and push to it', works: 'insideProject', availableOptions: [{ @@ -18,7 +22,7 @@ module.exports = { name: 'environment', type: String, default: 'production', - description: 'The ember environment to create a build for' + description: 'The Angular environment to create a build for' }, { name: 'branch', type: String, @@ -30,6 +34,8 @@ module.exports = { var ui = this.ui; var root = this.project.root; var execOptions = { cwd: root }; + var projectName = this.project.pkg.name; + var projectUrl = ''; function buildApp() { var env = options.environment; @@ -45,24 +51,98 @@ module.exports = { } function addAndCommit() { - return runCommand('git add . && git commit -m "' + options.message + '"', execOptions) + return runCommand('git add favicon.ico index.html app* vendor', execOptions). + then(function() { + return runCommand('git commit -m "' + options.message + '"', execOptions). + then(function() { return true; }, function() { return false; }); + }); + } + + function createGitHubRepoIfNeeded() { + return runCommand('git remote -v'). + then(function(stdout) { + + if (!/origin\s+git@github\.com/m.test(stdout)) { + ui.write("In order to deploy this project via GitHub Pages, we must first create a repository for it...\n"); + + return new RSVP.Promise(function(resolve, reject) { + inquire.prompt([{ + name: 'ghUserName', + type: 'input', + message: 'Please enter your GitHub user name', + validate: function(userName) { return /\w+/.test(userName); } + }, { + name: 'ghPassword', + type: 'password', + message: 'and your GitHub password (used only once to create the repo)', + validate: function(password) { return /.+/.test(password); } + }], function(answers) { + + projectUrl = `https://${answers.ghUserName.toLowerCase()}.github.io/${projectName}/`; + + var postData = JSON.stringify({ + 'name' : projectName + }); + + var req = https.request({ + hostname: 'api.github.com', + port: 443, + path: '/user/repos', + method: 'POST', + auth: answers.ghUserName + ':' + answers.ghPassword, + headers: { + 'Content-Type': 'application/json', + 'Content-Length': postData.length, + 'User-Agent': 'angular-cli-github-pages' + } + }); + + req.on('response', function(response) { + if (response.statusCode === 201) { + resolve(runCommand(`git remote add origin git@github.com:${answers.ghUserName}/${projectName}.git`). + then(() => runCommand("git checkout --orphan gh-pages && git rm --cached -r . && git add .gitignore && git clean -f -d && git commit -m 'initial gh-pages commit' && git checkout master"))) + } else { + reject(`Failed to create GitHub repo. Error: ${response.statusCode} ${response.statusMessage}`); + } + }); + + req.write(postData); + req.end(); + }); + }); + } else { + var userName = stdout.match(/origin\s+git@github\.com\:([^\/]+)/m)[1].toLowerCase(); + projectUrl = `https://${userName}.github.io/${projectName}/`; + } + }); } - function returnToPreviousCheckout() { - // Each '\' needed to be escaped here - return runCommand("git checkout `git reflog HEAD | sed -n " + - "'/checkout/ !d; s/.* \\(\\S*\\)$/\\1/;p' | sed '2 !d'`", execOptions); + function pushToGitRepo(committed) { + if (committed) { + return runCommand("git push origin gh-pages", execOptions).then(function() { return committed; }); + } + return committed; + } + + function returnToPreviousCheckout(committed) { + return runCommand("git checkout -", execOptions).then(function() { return committed; }); } return buildApp() + .then(createGitHubRepoIfNeeded) .then(checkoutGhPages) .then(copy) .then(addAndCommit) .then(returnToPreviousCheckout) - .then(function() { - var branch = options.branch; - ui.write('Done. All that\'s left is to git push the ' + branch + - ' branch.\nEx: git push origin ' + branch + '\n'); + .then(pushToGitRepo) + .then(function(committed) { + //var branch = options.branch; + if (committed) { + ui.write(`Deployed! Visit ${projectUrl}\n`); + } else { + ui.write('No changes found. Deployment skipped.\n'); + } + }); } }; @@ -94,7 +174,7 @@ function runCommand(/* child_process.exec args */) { return reject(err); } - return resolve(); + return resolve(stdout); }; args.push(cb); diff --git a/package.json b/package.json index a77914e..df17c95 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,8 @@ "ember-data": "1.0.0-beta.12", "ember-export-application-global": "^1.0.0", "express": "^4.8.5", - "glob": "^4.0.5" + "glob": "^4.0.5", + "inquirer": "^0.10.1" }, "keywords": [ "ember-addon" From cf50e80761abb46a04290f34975ccc82d930fe11 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sun, 18 Oct 2015 22:32:32 +0100 Subject: [PATCH 04/15] chore(release): v0.1.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index df17c95..f7e42e5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-cli-github-pages", "description": "Easily manage gh-pages of your angular-cli addon", - "version": "0.0.6", + "version": "0.1.0", "directories": { "doc": "doc", "test": "tests" From 9d0c492832be1c9e4562e7384b843d18498ef026 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sun, 18 Oct 2015 22:33:14 +0100 Subject: [PATCH 05/15] fix(package.json): move inquire from devDependencies to dependencies --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f7e42e5..443a381 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,7 @@ "ember-data": "1.0.0-beta.12", "ember-export-application-global": "^1.0.0", "express": "^4.8.5", - "glob": "^4.0.5", - "inquirer": "^0.10.1" + "glob": "^4.0.5" }, "keywords": [ "ember-addon" @@ -40,6 +39,7 @@ "configPath": "tests/dummy/config" }, "dependencies": { - "rsvp": "^3.0.14" + "rsvp": "^3.0.14", + "inquirer": "^0.10.1" } } From 548f9b99d7f069362499d124164025b8fa050c38 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Sun, 18 Oct 2015 22:33:26 +0100 Subject: [PATCH 06/15] chore(release): v0.1.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 443a381..4a1d0f0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-cli-github-pages", "description": "Easily manage gh-pages of your angular-cli addon", - "version": "0.1.0", + "version": "0.1.1", "directories": { "doc": "doc", "test": "tests" From 98e59108dcda927ebfb6c000674319e9e85d4432 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 19 Oct 2015 02:02:12 +0100 Subject: [PATCH 07/15] chore: update docs, remove unused files --- .travis.yml | 2 - README.md | 94 +++++-------------- blueprints/ember-cli-github-pages/index.js | 67 ------------- bower.json | 17 ---- lib/commands/{commit.js => deploy.js} | 25 +++-- package.json | 28 +----- tests/.jshintrc | 74 --------------- tests/dummy/app/app.js | 16 ---- tests/dummy/app/components/.gitkeep | 0 tests/dummy/app/controllers/.gitkeep | 0 tests/dummy/app/helpers/.gitkeep | 0 tests/dummy/app/index.html | 25 ----- tests/dummy/app/models/.gitkeep | 0 tests/dummy/app/router.js | 11 --- tests/dummy/app/routes/.gitkeep | 0 tests/dummy/app/styles/app.css | 3 - tests/dummy/app/templates/application.hbs | 3 - tests/dummy/app/templates/components/.gitkeep | 0 tests/dummy/app/views/.gitkeep | 0 tests/dummy/config/environment.js | 47 ---------- tests/dummy/public/.gitkeep | 0 tests/dummy/public/crossdomain.xml | 15 --- tests/dummy/public/robots.txt | 2 - tests/helpers/resolver.js | 11 --- tests/helpers/start-app.js | 19 ---- tests/index.html | 49 ---------- tests/test-helper.js | 12 --- tests/unit/.gitkeep | 0 28 files changed, 45 insertions(+), 475 deletions(-) delete mode 100644 blueprints/ember-cli-github-pages/index.js delete mode 100644 bower.json rename lib/commands/{commit.js => deploy.js} (85%) delete mode 100644 tests/.jshintrc delete mode 100644 tests/dummy/app/app.js delete mode 100644 tests/dummy/app/components/.gitkeep delete mode 100644 tests/dummy/app/controllers/.gitkeep delete mode 100644 tests/dummy/app/helpers/.gitkeep delete mode 100644 tests/dummy/app/index.html delete mode 100644 tests/dummy/app/models/.gitkeep delete mode 100644 tests/dummy/app/router.js delete mode 100644 tests/dummy/app/routes/.gitkeep delete mode 100644 tests/dummy/app/styles/app.css delete mode 100644 tests/dummy/app/templates/application.hbs delete mode 100644 tests/dummy/app/templates/components/.gitkeep delete mode 100644 tests/dummy/app/views/.gitkeep delete mode 100644 tests/dummy/config/environment.js delete mode 100644 tests/dummy/public/.gitkeep delete mode 100644 tests/dummy/public/crossdomain.xml delete mode 100644 tests/dummy/public/robots.txt delete mode 100644 tests/helpers/resolver.js delete mode 100644 tests/helpers/start-app.js delete mode 100644 tests/index.html delete mode 100644 tests/test-helper.js delete mode 100644 tests/unit/.gitkeep diff --git a/.travis.yml b/.travis.yml index cf23938..c5a0125 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,7 @@ before_install: - "npm install -g npm@^2" install: - - npm install -g bower - npm install - - bower install script: - npm test diff --git a/README.md b/README.md index ddac175..c7f6803 100644 --- a/README.md +++ b/README.md @@ -1,52 +1,26 @@ -# ember-cli-github-pages +# angular-cli-github-pages -[![npm version](https://badge.fury.io/js/ember-cli-github-pages.svg)](http://badge.fury.io/js/ember-cli-github-pages) -[![Ember Observer Score](http://emberobserver.com/badges/ember-cli-github-pages.svg)](http://emberobserver.com/addons/ember-cli-github-pages) -[![Code Climate](https://codeclimate.com/github/poetic/ember-cli-github-pages/badges/gpa.svg)](https://codeclimate.com/github/poetic/ember-cli-github-pages) -[![Dependency Status](https://david-dm.org/poetic/ember-cli-github-pages.svg)](https://david-dm.org/poetic/ember-cli-github-pages) -[![devDependency Status](https://david-dm.org/poetic/ember-cli-github-pages/dev-status.svg)](https://david-dm.org/poetic/ember-cli-github-pages#info=devDependencies) +Angular CLI addon for deploying apps to GitHub pages. +If you need to quickly deploy and redeploy a small Angular 2 app via GitHub pages this angular-cli +addon is for you! -If you need to throw up a quick example of your addon in action, this is the -addon for you! +This addon does the following: -This addon provides new command(s) to help manage a gh-pages branch for your -addon. It's an addon for addons. +- creates GitHub repo for the current project if one doesn't exist +- rebuilds the app at the current `HEAD` +- creates a local `gh-pages` branch if one doesn't exist +- moves your app to the `gh-pages` branch and creates a commit +- pushes the `gh-pages` branch to github +- returns back to the original `HEAD` -## Installation & Setup - -First you need to install ember-cli-github-pages: - -ember-cli - 0.2.3 or newer - -```sh -ember install ember-cli-github-pages -``` - -ember-cli - 0.1.5 to 0.2.3 -```sh -ember install:addon ember-cli-github-pages -``` - -ember-cli - 0.1.4 and below -```sh -npm install --save-dev ember-cli-github-pages -ember generate ember-cli-github-pages -``` -In order to have any assets you have in your repo load correctly you need to add the following to your `tests/dummy/config/environment.js` file: -```javascript -if (environment === 'production') { - ENV.baseURL = '/name-of-your-repo' -} -``` - -Commit these changes `git add -A && git commit -m "Added ember-cli-github-pages addon"` +## Installation & Setup -Then you need to create the gh-pages branch and remove the unnecessary files: +Assuming that you have an angular-cli project running, all you need to do is install angular-cli-github-pages: ```sh -git checkout --orphan gh-pages && rm -rf `ls -a | grep -vE '\.gitignore|\.git|node_modules|bower_components|(^[.]{1,2}/?$)'` && git add -A && git commit -m "initial gh-pages commit" +npm install --save-dev angular-cli-github-pages ``` ## Usage @@ -54,48 +28,28 @@ git checkout --orphan gh-pages && rm -rf `ls -a | grep -vE '\.gitignore|\.git|no Once that's done, you can checkout the branch you want to create the gh-page from(likely master) and run the command to build and commit it. -Then run ember github-pages:commit --message "some commit message" in order to rebuild gh-pages branch. +Then run `ng github-pages:deploy` in order to rebuild gh-pages branch and deploy it. ```sh git checkout master -ember github-pages:commit --message "Initial gh-pages release" +ng github-pages:deploy --message "Initial gh-pages release" ``` -### A note about Org and User Pages - -While in general, github repo pages will serve the content in the `gh-pages` branch, [org and user pages](https://help.github.com/articles/user-organization-and-project-pages/#user--organization-pages) serve content in the `master` branch. When using this addon to develop a Org or User page, edit your Ember Application on an alternate branch such as `ember`. Once you are ready to build the application and send to GitHub you can either: - -* add the `--branch master` option to the `ember github-pages:commit` command -* make the `gh-pages` branch on your local machine track the master branch on `origin` via the command: - -```sh -git branch --set-upstream gh-pages origin/master -``` +## Authentication -### Advanced Usage +This addon relies on ssh authentication for all git operations that communicate with github.com. +To simplify the authentication, be sure to (setup your ssh keys](https://help.github.com/articles/generating-ssh-keys/). -You may optionally specify an ember build environment and a branch name as parameters +For repository creation, the addon needs to make a single https call to the GitHub api, for this +user name and password are requested when the repo is being created. -```sh -git checkout master -ember github-pages:commit --message "Initial demo app release" \ - --branch="my-demo-app" \ - --environment=development -``` -| Optional Argument | Default Value | Description | -|-------------------|---------------|-------------| -| environment | `production` | Ember build environment (i.e., `development`, `production`) | -| branch | `gh-pages` | Branch to commit your app to | +Two factor authentication is currently not supported by this addon. -You will still need to push the gh-pages branch up to github using git. Once you -do that you can access the repo at `http://username.github.io/repo-name`. It may -take a few minutes after pushing the code to show up. ## Authors -- [Jake Craige](http://twitter.com/jakecraige) - -[We are very thankful for our many contributors](https://github.com/poetic/ember-cli-github-pages/graphs/contributors) +- [Igor Minar](http://twitter.com/IgorMinar) +- Based on ember-cli-github-pages by [Jake Craige](http://twitter.com/jakecraige) ## Legal diff --git a/blueprints/ember-cli-github-pages/index.js b/blueprints/ember-cli-github-pages/index.js deleted file mode 100644 index a5389b4..0000000 --- a/blueprints/ember-cli-github-pages/index.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -var RSVP = require('rsvp'); -var path = require('path'); -var fs = require('fs'); -var writeFile = RSVP.denodeify(fs.writeFile); - -module.exports = { - description: 'Updates baseURL in config to work on gh-pages', - normalizeEntityName: function() { }, - - afterInstall: function() { - return this.updateBaseURL().then(function() { - return this.updateLocationType(); - }.bind(this)).then(function() { - this.ui.writeLine('Updated config/environment.js baseURL and locationType.'); - }.bind(this)); - }, - - updateLocationType: function() { - var search = "locationType: 'auto'"; - var replace = "locationType: 'hash'"; - - return this.replaceEnvironment(search, replace); - }, - - updateBaseURL: function() { - var name = this.project.config('production').modulePrefix; - var search = "baseURL: '/'"; - var replace = "baseURL: '/" + name + "'"; - - return this.replaceEnvironment(search, replace); - }, - - replaceEnvironment: function(search, replace) { - return this.replaceInFile('config/environment.js', search, replace); - }, - - replaceInFile: function(pathRelativeToProjectRoot, searchTerm, contentsToInsert) { - var fullPath = path.join(this.project.root, pathRelativeToProjectRoot); - var originalContents = ''; - - if (fs.existsSync(fullPath)) { - originalContents = fs.readFileSync(fullPath, { encoding: 'utf8' }); - } - - var contentsToWrite = originalContents.replace(searchTerm, contentsToInsert); - - var returnValue = { - path: fullPath, - originalContents: originalContents, - contents: contentsToWrite, - inserted: false - }; - - if (contentsToWrite !== originalContents) { - returnValue.inserted = true; - - return writeFile(fullPath, contentsToWrite) - .then(function() { - return returnValue; - }); - } else { - return RSVP.resolve(returnValue); - } - } -} diff --git a/bower.json b/bower.json deleted file mode 100644 index 2159f6b..0000000 --- a/bower.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "ember-cli-github-pages", - "dependencies": { - "handlebars": "~1.3.0", - "jquery": "^1.11.1", - "ember": "1.8.1", - "ember-data": "1.0.0-beta.12", - "ember-resolver": "~0.1.10", - "loader.js": "stefanpenner/loader.js#1.0.1", - "ember-cli-shims": "stefanpenner/ember-cli-shims#0.0.3", - "ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4", - "ember-load-initializers": "stefanpenner/ember-load-initializers#0.0.2", - "ember-qunit": "0.1.8", - "ember-qunit-notifications": "0.0.4", - "qunit": "~1.15.0" - } -} \ No newline at end of file diff --git a/lib/commands/commit.js b/lib/commands/deploy.js similarity index 85% rename from lib/commands/commit.js rename to lib/commands/deploy.js index c85ba48..8fe8976 100644 --- a/lib/commands/commit.js +++ b/lib/commands/deploy.js @@ -3,7 +3,6 @@ var exec = require('child_process').exec; var RSVP = require('rsvp'); var https = require('https'); -var querystring = require('querystring'); var inquire = require('inquirer'); @@ -52,10 +51,8 @@ module.exports = { function addAndCommit() { return runCommand('git add favicon.ico index.html app* vendor', execOptions). - then(function() { - return runCommand('git commit -m "' + options.message + '"', execOptions). - then(function() { return true; }, function() { return false; }); - }); + then(runCommandLater('git commit -m "' + options.message + '"', execOptions)). + then(function() { return true; }, function() { return false; })); } function createGitHubRepoIfNeeded() { @@ -99,8 +96,15 @@ module.exports = { req.on('response', function(response) { if (response.statusCode === 201) { - resolve(runCommand(`git remote add origin git@github.com:${answers.ghUserName}/${projectName}.git`). - then(() => runCommand("git checkout --orphan gh-pages && git rm --cached -r . && git add .gitignore && git clean -f -d && git commit -m 'initial gh-pages commit' && git checkout master"))) + resolve( + runCommand(`git remote add origin git@github.com:${answers.ghUserName}/${projectName}.git`). + then(runCommandLater("git checkout --orphan gh-pages")). + then(runCommandLater("git rm --cached -r . ")). + then(runCommandLater("git add .gitignore")). + then(runCommandLater("git clean -f -d")). + then(runCommandLater("git commit -m 'initial gh-pages commit'")). + then(runCommandLater("git checkout master")) + ) } else { reject(`Failed to create GitHub repo. Error: ${response.statusCode} ${response.statusMessage}`); } @@ -147,6 +151,13 @@ module.exports = { } }; +function runCommandLater() { + var args = arguments; + return function() { + return runCommand.apply(null, args); + } +} + function runCommand(/* child_process.exec args */) { var args = Array.prototype.slice.call(arguments); diff --git a/package.json b/package.json index 4a1d0f0..b106a17 100644 --- a/package.json +++ b/package.json @@ -1,36 +1,14 @@ { "name": "angular-cli-github-pages", - "description": "Easily manage gh-pages of your angular-cli addon", + "description": "Easily publish your projects as gh-pages via angular-cli", "version": "0.1.1", - "directories": { - "doc": "doc", - "test": "tests" - }, - "scripts": { - "start": "ember server", - "build": "ember build", - "test": "ember test" - }, "repository": "https://github.com/IgorMinar/angular-cli-github-pages", "engines": { - "node": ">= 0.10.0" + "node": ">= 4.1.0" }, - "author": "Jake Craige ", + "author": "Igor Minar ", "license": "MIT", "devDependencies": { - "broccoli-asset-rev": "^1.0.0", - "broccoli-ember-hbs-template-compiler": "^1.6.1", - "ember-cli": "0.1.3", - "ember-cli-content-security-policy": "0.3.0", - "ember-cli-dependency-checker": "0.0.6", - "ember-cli-esnext": "0.1.1", - "ember-cli-ic-ajax": "0.1.1", - "ember-cli-inject-live-reload": "^1.3.0", - "ember-cli-qunit": "0.1.2", - "ember-data": "1.0.0-beta.12", - "ember-export-application-global": "^1.0.0", - "express": "^4.8.5", - "glob": "^4.0.5" }, "keywords": [ "ember-addon" diff --git a/tests/.jshintrc b/tests/.jshintrc deleted file mode 100644 index 6ebf71a..0000000 --- a/tests/.jshintrc +++ /dev/null @@ -1,74 +0,0 @@ -{ - "predef": [ - "document", - "window", - "location", - "setTimeout", - "$", - "-Promise", - "QUnit", - "define", - "console", - "equal", - "notEqual", - "notStrictEqual", - "test", - "asyncTest", - "testBoth", - "testWithDefault", - "raises", - "throws", - "deepEqual", - "start", - "stop", - "ok", - "strictEqual", - "module", - "moduleFor", - "moduleForComponent", - "moduleForModel", - "process", - "expect", - "visit", - "exists", - "fillIn", - "click", - "keyEvent", - "triggerEvent", - "find", - "findWithAssert", - "wait", - "DS", - "isolatedContainer", - "startApp", - "andThen", - "currentURL", - "currentPath", - "currentRouteName" - ], - "node": false, - "browser": false, - "boss": true, - "curly": false, - "debug": false, - "devel": false, - "eqeqeq": true, - "evil": true, - "forin": false, - "immed": false, - "laxbreak": false, - "newcap": true, - "noarg": true, - "noempty": false, - "nonew": false, - "nomen": false, - "onevar": false, - "plusplus": false, - "regexp": false, - "undef": true, - "sub": true, - "strict": false, - "white": false, - "eqnull": true, - "esnext": true -} diff --git a/tests/dummy/app/app.js b/tests/dummy/app/app.js deleted file mode 100644 index 757df38..0000000 --- a/tests/dummy/app/app.js +++ /dev/null @@ -1,16 +0,0 @@ -import Ember from 'ember'; -import Resolver from 'ember/resolver'; -import loadInitializers from 'ember/load-initializers'; -import config from './config/environment'; - -Ember.MODEL_FACTORY_INJECTIONS = true; - -var App = Ember.Application.extend({ - modulePrefix: config.modulePrefix, - podModulePrefix: config.podModulePrefix, - Resolver: Resolver -}); - -loadInitializers(App, config.modulePrefix); - -export default App; diff --git a/tests/dummy/app/components/.gitkeep b/tests/dummy/app/components/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/app/controllers/.gitkeep b/tests/dummy/app/controllers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/app/helpers/.gitkeep b/tests/dummy/app/helpers/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/app/index.html b/tests/dummy/app/index.html deleted file mode 100644 index 6a7d324..0000000 --- a/tests/dummy/app/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - Dummy - - - - {{content-for 'head'}} - - - - - {{content-for 'head-footer'}} - - - {{content-for 'body'}} - - - - - {{content-for 'body-footer'}} - - diff --git a/tests/dummy/app/models/.gitkeep b/tests/dummy/app/models/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js deleted file mode 100644 index cef554b..0000000 --- a/tests/dummy/app/router.js +++ /dev/null @@ -1,11 +0,0 @@ -import Ember from 'ember'; -import config from './config/environment'; - -var Router = Ember.Router.extend({ - location: config.locationType -}); - -Router.map(function() { -}); - -export default Router; diff --git a/tests/dummy/app/routes/.gitkeep b/tests/dummy/app/routes/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/app/styles/app.css b/tests/dummy/app/styles/app.css deleted file mode 100644 index 9adb5ad..0000000 --- a/tests/dummy/app/styles/app.css +++ /dev/null @@ -1,3 +0,0 @@ -html, body { - margin: 20px; -} diff --git a/tests/dummy/app/templates/application.hbs b/tests/dummy/app/templates/application.hbs deleted file mode 100644 index d08c11f..0000000 --- a/tests/dummy/app/templates/application.hbs +++ /dev/null @@ -1,3 +0,0 @@ -

Welcome to Ember.js

- -{{outlet}} diff --git a/tests/dummy/app/templates/components/.gitkeep b/tests/dummy/app/templates/components/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/app/views/.gitkeep b/tests/dummy/app/views/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js deleted file mode 100644 index d3f169f..0000000 --- a/tests/dummy/config/environment.js +++ /dev/null @@ -1,47 +0,0 @@ -/* jshint node: true */ - -module.exports = function(environment) { - var ENV = { - modulePrefix: 'dummy', - environment: environment, - baseURL: '/', - locationType: 'auto', - EmberENV: { - FEATURES: { - // Here you can enable experimental features on an ember canary build - // e.g. 'with-controller': true - } - }, - - APP: { - // Here you can pass flags/options to your application instance - // when it is created - } - }; - - if (environment === 'development') { - // ENV.APP.LOG_RESOLVER = true; - ENV.APP.LOG_ACTIVE_GENERATION = true; - // ENV.APP.LOG_TRANSITIONS = true; - // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; - ENV.APP.LOG_VIEW_LOOKUPS = true; - } - - if (environment === 'test') { - // Testem prefers this... - ENV.baseURL = '/'; - ENV.locationType = 'none'; - - // keep test console output quieter - ENV.APP.LOG_ACTIVE_GENERATION = false; - ENV.APP.LOG_VIEW_LOOKUPS = false; - - ENV.APP.rootElement = '#ember-testing'; - } - - if (environment === 'production') { - - } - - return ENV; -}; diff --git a/tests/dummy/public/.gitkeep b/tests/dummy/public/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/tests/dummy/public/crossdomain.xml b/tests/dummy/public/crossdomain.xml deleted file mode 100644 index 29a035d..0000000 --- a/tests/dummy/public/crossdomain.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - diff --git a/tests/dummy/public/robots.txt b/tests/dummy/public/robots.txt deleted file mode 100644 index 5debfa4..0000000 --- a/tests/dummy/public/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -# http://www.robotstxt.org -User-agent: * diff --git a/tests/helpers/resolver.js b/tests/helpers/resolver.js deleted file mode 100644 index 28f4ece..0000000 --- a/tests/helpers/resolver.js +++ /dev/null @@ -1,11 +0,0 @@ -import Resolver from 'ember/resolver'; -import config from '../../config/environment'; - -var resolver = Resolver.create(); - -resolver.namespace = { - modulePrefix: config.modulePrefix, - podModulePrefix: config.podModulePrefix -}; - -export default resolver; diff --git a/tests/helpers/start-app.js b/tests/helpers/start-app.js deleted file mode 100644 index e087e48..0000000 --- a/tests/helpers/start-app.js +++ /dev/null @@ -1,19 +0,0 @@ -import Ember from 'ember'; -import Application from '../../app'; -import Router from '../../router'; -import config from '../../config/environment'; - -export default function startApp(attrs) { - var App; - - var attributes = Ember.merge({}, config.APP); - attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; - - Ember.run(function() { - App = Application.create(attributes); - App.setupForTesting(); - App.injectTestHelpers(); - }); - - return App; -} diff --git a/tests/index.html b/tests/index.html deleted file mode 100644 index 4112b61..0000000 --- a/tests/index.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - Dummy Tests - - - - {{content-for 'head'}} - {{content-for 'test-head'}} - - - - - - - {{content-for 'head-footer'}} - {{content-for 'test-head-footer'}} - - - - {{content-for 'body'}} - {{content-for 'test-body'}} - - - - - - - {{content-for 'body-footer'}} - {{content-for 'test-body-footer'}} - - diff --git a/tests/test-helper.js b/tests/test-helper.js deleted file mode 100644 index b5f6449..0000000 --- a/tests/test-helper.js +++ /dev/null @@ -1,12 +0,0 @@ -import resolver from './helpers/resolver'; -import { - setResolver -} from 'ember-qunit'; - -setResolver(resolver); - -document.write('
'); - -QUnit.config.urlConfig.push({ id: 'nocontainer', label: 'Hide container'}); -var containerVisibility = QUnit.urlParams.nocontainer ? 'hidden' : 'visible'; -document.getElementById('ember-testing-container').style.visibility = containerVisibility; diff --git a/tests/unit/.gitkeep b/tests/unit/.gitkeep deleted file mode 100644 index e69de29..0000000 From 6a0cc84033e98b8b7d64e2dbf6ca9156e79e3ad5 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 19 Oct 2015 02:03:35 +0100 Subject: [PATCH 08/15] chore: use fse.copy instead of unix cp command to copy files --- index.js | 2 +- lib/commands/deploy.js | 41 +++++++++++++++++++++++------------------ package.json | 5 +++-- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/index.js b/index.js index 2e35afc..05f72b4 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ module.exports = { includedCommands: function() { return { - 'github-pages:deploy': require('./lib/commands/commit') + 'github-pages:deploy': require('./lib/commands/deploy') }; } }; diff --git a/lib/commands/deploy.js b/lib/commands/deploy.js index 8fe8976..d4c5e5c 100644 --- a/lib/commands/deploy.js +++ b/lib/commands/deploy.js @@ -4,6 +4,9 @@ var exec = require('child_process').exec; var RSVP = require('rsvp'); var https = require('https'); var inquire = require('inquirer'); +var fs = require('fs'); +var fse = require('fs-extra'); +var path = require('path'); module.exports = { @@ -35,6 +38,8 @@ module.exports = { var execOptions = { cwd: root }; var projectName = this.project.pkg.name; var projectUrl = ''; + var fsReadDir = RSVP.denodeify(fs.readdir); + var fsCopy = RSVP.denodeify(fse.copy); function buildApp() { var env = options.environment; @@ -46,13 +51,14 @@ module.exports = { } function copy() { - return runCommand('cp -R dist/* .', execOptions); + return fsReadDir('dist').then( + (files) => RSVP.all(files.map((file) => fsCopy(path.join('dist', file), path.join('.', file))))); } function addAndCommit() { return runCommand('git add favicon.ico index.html app* vendor', execOptions). then(runCommandLater('git commit -m "' + options.message + '"', execOptions)). - then(function() { return true; }, function() { return false; })); + then(function() { return true; }, function() { return false; }); } function createGitHubRepoIfNeeded() { @@ -132,21 +138,22 @@ module.exports = { return runCommand("git checkout -", execOptions).then(function() { return committed; }); } - return buildApp() - .then(createGitHubRepoIfNeeded) - .then(checkoutGhPages) - .then(copy) - .then(addAndCommit) - .then(returnToPreviousCheckout) - .then(pushToGitRepo) - .then(function(committed) { + + + return buildApp(). + then(createGitHubRepoIfNeeded). + then(checkoutGhPages). + then(copy). + then(addAndCommit). + then(returnToPreviousCheckout). + then(pushToGitRepo). + then(function(committed) { //var branch = options.branch; if (committed) { ui.write(`Deployed! Visit ${projectUrl}\n`); } else { ui.write('No changes found. Deployment skipped.\n'); } - }); } }; @@ -171,14 +178,12 @@ function runCommand(/* child_process.exec args */) { return new RSVP.Promise(function(resolve, reject) { var cb = function(err, stdout, stderr) { - if (logOutput) { - if (stderr) { - console.log(stderr); - } + if (stderr) { + console.log(stderr); + } - if (stdout) { - console.log(stdout); - } + if (logOutput && stdout) { + console.log(stdout); } if (err) { diff --git a/package.json b/package.json index b106a17..82e4820 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "configPath": "tests/dummy/config" }, "dependencies": { - "rsvp": "^3.0.14", - "inquirer": "^0.10.1" + "fs-extra": "^0.24.0", + "inquirer": "^0.10.1", + "rsvp": "^3.0.14" } } From 8653e695d120a0122a3dce7bfd63f6fb81ae6fc5 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 19 Oct 2015 02:07:11 +0100 Subject: [PATCH 09/15] chore(release): v0.1.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 82e4820..1a2e0f8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-cli-github-pages", "description": "Easily publish your projects as gh-pages via angular-cli", - "version": "0.1.1", + "version": "0.1.2", "repository": "https://github.com/IgorMinar/angular-cli-github-pages", "engines": { "node": ">= 4.1.0" From b5ec54dbeaa52aa2496525b5f89ba8e4d5323f8e Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 19 Oct 2015 21:50:40 +0100 Subject: [PATCH 10/15] fix: use single quotes around git commit message to make the comman compatible with windows --- lib/commands/deploy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/deploy.js b/lib/commands/deploy.js index d4c5e5c..8fae898 100644 --- a/lib/commands/deploy.js +++ b/lib/commands/deploy.js @@ -108,7 +108,7 @@ module.exports = { then(runCommandLater("git rm --cached -r . ")). then(runCommandLater("git add .gitignore")). then(runCommandLater("git clean -f -d")). - then(runCommandLater("git commit -m 'initial gh-pages commit'")). + then(runCommandLater("git commit -m \"initial gh-pages commit\"")). then(runCommandLater("git checkout master")) ) } else { From 3bdb99a0520dfb13a4277c276de529ed4c6aa318 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 19 Oct 2015 21:56:35 +0100 Subject: [PATCH 11/15] docs: update readme.md --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c7f6803..8a02999 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,13 @@ This addon does the following: ## Installation & Setup -Assuming that you have an angular-cli project running, all you need to do is install angular-cli-github-pages: +This addon has the following prerequisites: + +- Node.js 4.x +- SSH keys setup for authentication with GitHub (see "Authentication" section below) +- Angular project created via [angular-cli](https://github.com/angular/angular-cli) + +To install this addon all you need to do is install angular-cli-github-pages via npm: ```sh npm install --save-dev angular-cli-github-pages @@ -26,31 +32,31 @@ npm install --save-dev angular-cli-github-pages ## Usage Once that's done, you can checkout the branch you want to create the gh-page -from(likely master) and run the command to build and commit it. +from (likely master) and run the command to build and commit it. Then run `ng github-pages:deploy` in order to rebuild gh-pages branch and deploy it. ```sh git checkout master -ng github-pages:deploy --message "Initial gh-pages release" +ng github-pages:deploy --message "Optional commit message" ``` ## Authentication This addon relies on ssh authentication for all git operations that communicate with github.com. -To simplify the authentication, be sure to (setup your ssh keys](https://help.github.com/articles/generating-ssh-keys/). +To simplify the authentication, be sure to [setup your ssh keys](https://help.github.com/articles/generating-ssh-keys/). For repository creation, the addon needs to make a single https call to the GitHub api, for this user name and password are requested when the repo is being created. -Two factor authentication is currently not supported by this addon. +*Note: Two factor authentication is currently not supported by this addon.* ## Authors - [Igor Minar](http://twitter.com/IgorMinar) -- Based on ember-cli-github-pages by [Jake Craige](http://twitter.com/jakecraige) +- Based on [ember-cli-github-pages](https://github.com/poetic/ember-cli-github-pages) by [Jake Craige](http://twitter.com/jakecraige) -## Legal +## License [Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php) From b134e67ad495cf8186e1110f9a955f6e38b3b5e8 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 19 Oct 2015 22:00:07 +0100 Subject: [PATCH 12/15] chore(release): v0.1.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a2e0f8..f4f77d8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-cli-github-pages", "description": "Easily publish your projects as gh-pages via angular-cli", - "version": "0.1.2", + "version": "0.1.3", "repository": "https://github.com/IgorMinar/angular-cli-github-pages", "engines": { "node": ">= 4.1.0" From 51e49a78a49a246c7f5bf1a1a410046c2b26f822 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 2 Nov 2015 20:55:20 -0800 Subject: [PATCH 13/15] feat: fail deployment if there are pending changes in project repo --- lib/commands/deploy.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/commands/deploy.js b/lib/commands/deploy.js index 8fae898..934d489 100644 --- a/lib/commands/deploy.js +++ b/lib/commands/deploy.js @@ -46,6 +46,14 @@ module.exports = { return runCommand('ng build --environment=' + env, execOptions); } + function checkForPendingChanges() { + return runCommand('git status --porcelain', execOptions).then(stdout => { + if (/\w+/m.test(stdout)) { + return RSVP.reject('Uncommitted file changes found! Please commit all changes before deploying.'); + } + }); + } + function checkoutGhPages() { return runCommand('git checkout ' + options.branch, execOptions); } @@ -141,6 +149,7 @@ module.exports = { return buildApp(). + then(checkForPendingChanges). then(createGitHubRepoIfNeeded). then(checkoutGhPages). then(copy). From 8fac05d408dbf75caa40675c761bf47262aa22df Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 2 Nov 2015 20:55:42 -0800 Subject: [PATCH 14/15] feat: improve github username/password prompts --- lib/commands/deploy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/commands/deploy.js b/lib/commands/deploy.js index 934d489..eb79be9 100644 --- a/lib/commands/deploy.js +++ b/lib/commands/deploy.js @@ -80,12 +80,12 @@ module.exports = { inquire.prompt([{ name: 'ghUserName', type: 'input', - message: 'Please enter your GitHub user name', + message: 'Please enter your GitHub user name:', validate: function(userName) { return /\w+/.test(userName); } }, { name: 'ghPassword', type: 'password', - message: 'and your GitHub password (used only once to create the repo)', + message: 'and your GitHub password (used only once to create the repo):', validate: function(password) { return /.+/.test(password); } }], function(answers) { From f2c772c289cad1aef0a35c9e6fa5e17eede1eb2f Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Mon, 2 Nov 2015 20:56:15 -0800 Subject: [PATCH 15/15] chore(release): v0.2.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f4f77d8..130a5f9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "angular-cli-github-pages", "description": "Easily publish your projects as gh-pages via angular-cli", - "version": "0.1.3", + "version": "0.2.0", "repository": "https://github.com/IgorMinar/angular-cli-github-pages", "engines": { "node": ">= 4.1.0"