Skip to content

Commit a478eb0

Browse files
committed
this is now a single executable, removes angular-cli addon functionality
see angular/angular-cli#3695 closes #1
1 parent 5beb8a6 commit a478eb0

File tree

5 files changed

+115
-169
lines changed

5 files changed

+115
-169
lines changed

README.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77

88
<hr>
99

10-
Angular CLI addon. Publish to any gh-pages branch on GitHub (or any other branch on any other remote).
10+
This __was__ an angular CLI addon (until they [removed addon support](https://github.com/angular/angular-cli/pull/3695)).
11+
Now it's just a wrapper around [tschaub/gh-pages](https://github.com/tschaub/gh-pages).
12+
13+
Publish to any gh-pages branch on GitHub (or any other branch on any other remote).
1114
Made for Travis-CI. Brought to you by the [angular-buch.com](https://angular-buch.com/) team!
1215

1316
## About
1417

15-
This is similar to the normal `github-pages:deploy` command.
18+
This script is similar to the normal `github-pages:deploy` command.
1619
But by design, the command is limited to the `gh-pages` branch of the same repository.
1720

18-
In contrast to this, the [angular-buch/angular-cli-ghpages](https://github.com/angular-buch/angular-cli-ghpages) addon is able to push to any branch on any repository. It's made on top of [tschaub/gh-pages](https://github.com/tschaub/gh-pages).
19-
__This addon works great on [Travis-CI](https://travis-ci.org/).__ No git credentials must be set up in before. Specific environment variables of Travis-CI are evaluated, too. You will like it!
20-
21-
angular-cli-ghpages was sucessfully tested against __`angular-cli@1.0.0-beta.22-1`__.
21+
In contrast to this, the [angular-buch/angular-cli-ghpages](https://github.com/angular-buch/angular-cli-ghpages) script is able to push to any branch on any repository. It's made on top of [tschaub/gh-pages](https://github.com/tschaub/gh-pages).
22+
__This script works great on [Travis-CI](https://travis-ci.org/).__ No git credentials must be set up in before. Specific environment variables of Travis-CI are evaluated, too. You will like it!
2223

2324

2425
## Installation & Setup
@@ -27,24 +28,29 @@ This addon has the following prerequisites:
2728

2829
- Node.js 4.x
2930
- Git 1.7.6 or higher
30-
- Angular project created via [angular-cli](https://github.com/angular/angular-cli)
31+
- Optional: Angular project created via [angular-cli](https://github.com/angular/angular-cli)
3132

3233
To install this addon run the following command:
3334

3435
```sh
35-
cd <your-angular-cli-project>
36-
npm install angular-cli-ghpages --save-dev
36+
npm i -g angular-cli-ghpages
3737
```
3838

3939
## Usage
4040

41-
Execute `ng ghpages` in order to deploy the project with a build from `dist` folder.
41+
Execute `angular-cli-ghpages` in order to deploy the project with a build from `dist` folder.
4242
Note: you have to create the folder in before (e.g. `ng build --prod`)
4343

4444
Usage:
4545

4646
```sh
47-
ng ghpages [OPTIONS]
47+
angular-cli-ghpages [OPTIONS]
48+
```
49+
50+
there is also a shorter `ngh` command available
51+
52+
```sh
53+
ngh [OPTIONS]
4854
```
4955

5056
## Options
@@ -64,7 +70,7 @@ Some handy additional text is always added, if the environment variable `process
6470

6571
Example:
6672
```sh
67-
ng ghpages --message="What could possibly go wrong?"
73+
angular-cli-ghpages --message="What could possibly go wrong?"
6874
```
6975

7076

@@ -116,7 +122,7 @@ For your convenience, the addon will recognize the [environment variable](https:
116122
In example, the following command runs [on our Travis-CI](https://travis-ci.org/angular-buch/book-monkey2):
117123

118124
```sh
119-
ng ghpages --repo=https://GH_TOKEN@github.com/organisation/your-repo.git --name="Displayed Username" --email=mail@example.orf
125+
angular-cli-ghpages --repo=https://GH_TOKEN@github.com/organisation/your-repo.git --name="Displayed Username" --email=mail@example.orf
120126
```
121127
> You have to treat the GH_TOKEN as secure as a password!
122128

bin/angular-cli-ghpages

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var index = require('../index'),
2+
pjson = require('../package.json'),
3+
program = require('commander');
4+
5+
program
6+
.version(pjson.version)
7+
.description(pjson.description)
8+
.option('-d, --dir <dir>', 'Directory for all published sources, relative to the project-root. Most probably no change is required here.', 'dist')
9+
.option('-r, --repo <repo>', 'The commit message to include with the build, must be wrapped in quotes.')
10+
.option('-m, --message <message>', 'The commit message, must be wrapped in quotes.', 'Auto-generated commit')
11+
.option('-b, --branch <branch>', 'The git branch to push your pages to.', 'gh-pages')
12+
.option('-n, --name <name>', 'The git user-name which is associated with this commit.')
13+
.option('-e, --email <email>', 'The git user-email which is associated with this commit')
14+
.option('-x, --silent', 'Suppress console logging. This option should be used if the repository URL or other information passed to git commands is sensitive! Default: true')
15+
.option('-t, --dotfiles', 'Includes dotfiles by default. When set to `false` files starting with `.` are ignored. Default: true')
16+
.parse(process.argv);
17+
18+
index.run(program);

deploy.js

Lines changed: 0 additions & 127 deletions
This file was deleted.

index.js

Lines changed: 67 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,70 @@
1-
module.exports = {
2-
name: 'angular-cli-ghpages',
1+
var path = require('path'),
2+
fs = require('fs'),
3+
ghpages = require('gh-pages'),
4+
denodeify = require('denodeify');
35

4-
includedCommands: function() {
5-
return {
6-
'ghpages': require('./deploy'),
7-
};
6+
exports.run = function (options) {
7+
8+
options = options || {};
9+
10+
if (options.silent === undefined) {
11+
options.silent = true;
12+
}
13+
14+
if (options.dotfiles === undefined) {
15+
options.dotfiles = true;
16+
}
17+
18+
if (options['name'] && options['email']) {
19+
options.user = {
20+
name: options['name'],
21+
email: options['email']
22+
}
23+
};
24+
25+
// gh-pages: forwards messages to console
26+
options.logger = function (message) { console.log(message + "\n"); }
27+
28+
var dir = path.join(process.cwd(), options.dir);
29+
30+
if (process.env.TRAVIS) {
31+
options.message += '\n\n' +
32+
'Triggered by commit: https://github.com/' + process.env.TRAVIS_REPO_SLUG + '/commit/' + process.env.TRAVIS_COMMIT + '\n' +
33+
'Travis build: https://travis-ci.org/' + process.env.TRAVIS_REPO_SLUG + '/builds/' + process.env.TRAVIS_BUILD_ID;
34+
}
35+
36+
// for your convenience - here you can hack credentials into the repository URL
37+
if (process.env.GH_TOKEN && options.repo) {
38+
options.repo = options.repo.replace('GH_TOKEN', process.env.GH_TOKEN);
39+
}
40+
41+
// always clean the cache directory.
42+
// avoids "Error: Remote url mismatch."
43+
ghpages.clean();
44+
45+
var access = publish = denodeify(fs.access);
46+
var publish = denodeify(ghpages.publish);
47+
48+
function go() {
49+
return Promise.resolve();
850
}
51+
52+
return go()
53+
.then(function () {
54+
return access(dir, fs.F_OK)
55+
})
56+
.catch(function (error) {
57+
console.error('Dist folder does not exist. Check the dir --dir parameter or build the project first!\n');
58+
return Promise.reject(error);
59+
})
60+
.then(function () {
61+
return publish(dir, options)
62+
})
63+
.then(function () {
64+
console.log('Successfully published!\n');
65+
})
66+
.catch(function (error) {
67+
console.error('An error occurred!\n');
68+
return Promise.reject(error);
69+
});
970
};

package.json

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"name": "angular-cli-ghpages",
3-
"version": "0.3.3",
4-
"description": "Angular CLI addon. Publish to any gh-pages branch on GitHub (or any other branch on any other remote).",
3+
"version": "0.4.0",
4+
"description": "Wrapper around gh-pages, made for angular-cli users. Publish to any gh-pages branch on GitHub (or any other branch on any other remote).",
5+
"main": "index.js",
6+
"bin": {
7+
"angular-cli-ghpages": "bin/angular-cli-ghpages",
8+
"ngh": "bin/angular-cli-ghpages"
9+
},
510
"repository": {
611
"type": "git",
712
"url": "git+https://github.com/angular-buch/angular-cli-ghpages.git"
@@ -13,28 +18,11 @@
1318
"name": "Angular-Buch Team",
1419
"email": "team@angular2buch.de"
1520
},
16-
"maintainers": [
17-
{
18-
"name": "johanneshoppe",
19-
"email": "johannes.hoppe@haushoppe-its.de"
20-
},
21-
{
22-
"name": "fmalcher",
23-
"email": "mail@ferdinand-malcher.de"
24-
},
25-
{
26-
"name": "d-koppenhagen",
27-
"email": "mail@d-koppenhagen.de"
28-
},
29-
{
30-
"name": "gregonnet",
31-
"email": "gregor.woiwode@gmail.com"
32-
}
33-
],
3421
"license": "MIT",
3522
"dependencies": {
36-
"gh-pages": "^0.11.0",
37-
"denodeify": "^1.2.1"
23+
"gh-pages": "~0.12.0",
24+
"denodeify": "~1.2.1",
25+
"commander": "~2.9.0"
3826
},
39-
"keywords": ["ember-addon", "angular2", "angular-cli", "git", "github pages", "gh-pages", "ghpages", "angular-cli-ghpages", "angular-cli-github-pages"]
27+
"keywords": ["angular2", "angular-cli", "git", "github pages", "gh-pages", "ghpages", "angular-cli-ghpages", "angular-cli-github-pages"]
4028
}

0 commit comments

Comments
 (0)