Skip to content

Commit 0fc6101

Browse files
committed
updating to nest angular-cli
1 parent f1d447c commit 0fc6101

File tree

3 files changed

+71
-27
lines changed

3 files changed

+71
-27
lines changed

README.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@
1010
Angular CLI addon. Publish to any gh-pages branch on GitHub (or any other branch on any other remote).
1111
Made for Travis-CI. Brought to you by the [angular2buch.de](https://angular2buch.de/) team!
1212

13-
## WHY?
13+
## About
1414

15-
This is __NOT__ [IgorMinar/angular-cli-github-pages](https://github.com/IgorMinar/angular-cli-github-pages). That addon is limited to the `gh-pages` branch of the same repository.
15+
This is similar to the normal `github-pages:deploy` command.
16+
But by design, the command is limited to the `gh-pages` branch of the same repository.
1617

1718
In contrast to this, the [Angular2Buch/angular-cli-ghpages](https://github.com/Angular2Buch/angular-cli-ghpages) addon is able to push to any branch on any repository. It's build on top of [tschaub/gh-pages](https://github.com/tschaub/gh-pages).
18-
__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.
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!
1920

2021
## Installation & Setup
2122

@@ -33,13 +34,11 @@ npm install --save-dev angular-cli-ghpages
3334

3435
## Usage
3536

36-
Run `ng build` to fill the `dist` folder.
37-
Then execute `ng ghpages` in order to deploy it.
37+
Execute `ng ghpages` in order to deploy the project with a `production` build.
3838

3939
Usage:
4040

4141
```sh
42-
ng build
4342
ng ghpages [OPTIONS]
4443
```
4544

@@ -49,14 +48,14 @@ ng ghpages [OPTIONS]
4948
* optional
5049
* default: url of the origin remote of the current dir (assumes a git repository)
5150

52-
By default, [tschaub/gh-pages](https://github.com/tschaub/gh-pages) assumes that the current working directory is a git repository, and that you want to push changes to the `origin` remote. If instead your script is not in a git repository, or if you want to push to another repository, you can provide the repository URL in the `repo` option.
51+
By default, __gh-pages__ assumes that the current working directory is a git repository, and that you want to push changes to the `origin` remote. If instead your script is not in a git repository, or if you want to push to another repository, you can provide the repository URL in the `repo` option.
5352

5453
#### <a id="message">--message</a>
5554
* optional
5655
* default: `Auto-generated commit`
5756

5857
The commit message, __must be wrapped in quotes__.
59-
Hardcoded additional text is always added, if the environment variable `process.env.TRAVIS` exists (for Travis CI).
58+
Some handy additional text is always added, if the environment variable `process.env.TRAVIS` exists (for Travis CI).
6059

6160
Example:
6261
```sh
@@ -84,15 +83,31 @@ If you are running the command in a repository without a `user.name` or `user.em
8483

8584
Suppress logging. With silent `true` log messages are suppressed and error messages are sanitized.
8685

87-
> This option should be used if the repository URL or other information passed to git commands is sensitive and should not be logged. By default the silent mode is enabled to avoid sensitive data exposure.
86+
> This option should be used if the repository URL or other information passed to git commands is sensitive and should not be logged (== you have a public build server). By default the silent mode is enabled to avoid sensitive data exposure.
8887
8988

9089
#### <a id="dir">--dir</a>
9190
* optional
9291
* default: `dist`
9392

9493
Directory for all sources, relative to the project-root.
95-
Monst probably no change is required here.
94+
Most probably no change is required here, usefull together with --skip-build.
95+
This option can be used to deploy completely different folders, which are note related at all to angular.
96+
97+
98+
#### <a id="environment">--environment</a>
99+
* optional
100+
* default: `production`
101+
102+
The Angular environment to create a build for.
103+
104+
105+
#### <a id="skip-build">--skip-build</a>
106+
* optional
107+
* default: `false` (boolean)
108+
109+
Skip building the project before deploying, usefull together with --dir.
110+
96111

97112

98113

deploy.js

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
'use strict';
22

3+
var Command = require('ember-cli/lib/models/command');
4+
var Promise = require('ember-cli/lib/ext/promise');
5+
var BuildTask = require('ember-cli/lib/tasks/build');
6+
37
var path = require('path');
48
var fs = require('fs');
59
var ghpages = require('gh-pages');
6-
var RSVP = require('rsvp');
710

8-
module.exports = {
11+
module.exports = Command.extend({
912
name: 'ghpages',
1013
aliases: ['gh-pages'],
1114
description: 'Publish to any gh-pages branch on GitHub (or any other branch on any other remote). Build the project before publishing!',
@@ -45,14 +48,24 @@ module.exports = {
4548
name: 'dir',
4649
type: String,
4750
default: 'dist',
48-
description: 'Directory for all sources, relative to the project-root. Monst probably no change is required here.'
51+
description: 'Directory for all sources, relative to the project-root. Most probably no change is required here.'
52+
}, {
53+
name: 'environment',
54+
type: String,
55+
default: 'production',
56+
description: 'The Angular environment to create a build for'
57+
}, {
58+
name: 'skip-build',
59+
type: Boolean,
60+
default: false,
61+
description: 'Skip building the project before deploying, usefull together with --dir'
4962
}],
5063
run: function(options, rawArgs) {
5164

5265
var ui = this.ui;
5366
var root = this.project.root;
5467
var dir = path.join(root, options.dir);
55-
68+
5669
options = options || {};
5770
if (options['name'] && options['email']) {
5871
options.user = {
@@ -72,21 +85,35 @@ module.exports = {
7285
// for your convenience - here you can hack credentials into the repository URL
7386
if (process.env.GH_TOKEN && options.repo) {
7487
options.repo = options.repo.replace('GH_TOKEN', process.env.GH_TOKEN);
75-
}
76-
88+
}
89+
7790
// always clean the cache directory.
7891
// avoids "Error: Remote url mismatch."
7992
ghpages.clean();
8093

81-
var access = publish = RSVP.denodeify(fs.access);
82-
var publish = RSVP.denodeify(ghpages.publish);
94+
var access = publish = Promise.denodeify(fs.access);
95+
var publish = Promise.denodeify(ghpages.publish);
8396

97+
function build() {
98+
if (options.skipBuild) return Promise.resolve();
99+
100+
var buildTask = new BuildTask({
101+
ui: this.ui,
102+
analytics: this.analytics,
103+
project: this.project
104+
});
105+
106+
return buildTask.run(buildOptions);
107+
}
84108

85-
return access(dir, fs.F_OK)
86-
.catch(function(error) {
87-
ui.writeError('Dist folder does not exist. Can \'t publish anything. Run `ng build` first!\n');
88-
return RSVP.reject(error) ;
89-
})
109+
return build()
110+
.then(function() {
111+
return access(dir, fs.F_OK)
112+
})
113+
.catch(function(error) {
114+
ui.writeError('Dist folder does not exist. Check the dir --dir parameter or build the project first!\n');
115+
return Promise.reject(error) ;
116+
})
90117
.then(function() {
91118
return publish(dir, options)
92119
})
@@ -95,7 +122,7 @@ module.exports = {
95122
})
96123
.catch(function(error) {
97124
ui.writeError('An error occurred!\n');
98-
return RSVP.reject(error) ;
125+
return Promise.reject(error) ;
99126
});
100127
}
101-
};
128+
});

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@
3333
],
3434
"license": "MIT",
3535
"dependencies": {
36-
"gh-pages": "^0.11.0",
37-
"rsvp": "^3.0.14"
36+
"gh-pages": "^0.11.0"
37+
}
38+
"peerDependencies": {
39+
"ember-cli": "^2.5.0"
3840
},
3941
"keywords": ["ember-addon", "angular2", "angular-cli", "git", "github pages", "gh-pages", "ghpages", "angular-cli-ghpages", "angular-cli-github-pages"]
4042
}

0 commit comments

Comments
 (0)