Skip to content

Commit 8eeedd6

Browse files
committed
using WebpackBuild as seen in angular/angular-cli#1633
1 parent a53dbab commit 8eeedd6

File tree

3 files changed

+88
-62
lines changed

3 files changed

+88
-62
lines changed

README.md

Lines changed: 51 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ angular-cli-ghpages is right now not compatible with `angular-cli: 1.0.0-beta.11
2525

2626
This addon has the following prerequisites:
2727

28-
- Node.js 4.x
28+
- Node.js 4.x
2929
- Git 1.7.6 or higher
30-
- Angular project created via [angular-cli](https://github.com/angular/angular-cli)
30+
- Angular project created via [angular-cli](https://github.com/angular/angular-cli)
3131

3232
To install this addon run the following command:
3333

@@ -55,8 +55,8 @@ By default, __gh-pages__ assumes that the current working directory is a git rep
5555

5656
#### <a id="message">--message</a>
5757
* optional
58-
* default: `Auto-generated commit`
59-
58+
* default: `Auto-generated commit`
59+
6060
The commit message, __must be wrapped in quotes__.
6161
Some handy additional text is always added, if the environment variable `process.env.TRAVIS` exists (for Travis CI).
6262

@@ -68,7 +68,7 @@ ng ghpages --message="What could possibly go wrong?"
6868

6969
#### <a id="branch">--branch</a>
7070
* optional
71-
* default: `gh-pages`
71+
* default: `gh-pages`
7272

7373
The name of the branch you'll be pushing to. The default uses GitHub's `gh-pages` branch, but this can be configured to push to any branch on any remote.
7474

@@ -86,43 +86,52 @@ If you are running the command in a repository without a `user.name` or `user.em
8686

8787
Suppress logging. With silent `true` log messages are suppressed and error messages are sanitized.
8888

89-
> 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.
90-
91-
92-
#### <a id="dir">--dir</a>
93-
* optional
94-
* default: `dist`
95-
96-
Directory for all published sources, relative to the project-root.
97-
Most probably no change is required here, useful together with --skip-build.
98-
This option can be used to deploy completely different folders, which are note related at all to angular.
99-
100-
101-
#### <a id="environment">--environment</a>
102-
* optional
103-
* default: `production`
104-
105-
The Angular environment to create a build for.
106-
The build artifacts are always placed into the path `dist/`.
107-
The option `--dir` has no effect on the output path.
108-
109-
110-
#### <a id="skip-build">--skip-build</a>
111-
* optional
112-
* default: `false` (boolean)
113-
114-
Skip building the project before deploying, useful together with --dir.
115-
116-
117-
118-
#### <a id="dotfiles">--dotfiles</a>
119-
* optional
120-
* default: `true` (boolean)
121-
122-
Includes dotfiles by default. When set to `false` files starting with `.` are ignored.
123-
124-
125-
89+
> 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.
90+
91+
92+
#### <a id="dir">--dir</a>
93+
* optional
94+
* default: `dist`
95+
96+
Directory for all published sources, relative to the project-root.
97+
Most probably no change is required here, useful together with --skip-build.
98+
This option can be used to deploy completely different folders, which are note related at all to angular.
99+
(Hint: usual angular-cli config is ignored here!)
100+
101+
AND ALSO: Output path for the build, if a build is done.
102+
103+
#### <a id="target">--target</a>
104+
* optional
105+
* default: `production`
106+
* alias: `t`
107+
108+
Build target (`development` or `production`), see [Build Targets and Environment Files](https://github.com/angular/angular-cli/#build-targets-and-environment-files).
109+
110+
111+
#### <a id="environment">--environment</a>
112+
* optional
113+
* default: `prod`
114+
* alias: `e`
115+
116+
Environment file to be used with that build (`dev`, `prod` or own), see [Build Targets and Environment Files](https://github.com/angular/angular-cli/#build-targets-and-environment-files).
117+
118+
119+
#### <a id="skip-build">--skip-build</a>
120+
* optional
121+
* default: `false` (boolean)
122+
123+
Skip building the project before deploying, useful together with --dir.
124+
125+
126+
127+
#### <a id="dotfiles">--dotfiles</a>
128+
* optional
129+
* default: `true` (boolean)
130+
131+
Includes dotfiles by default. When set to `false` files starting with `.` are ignored.
132+
133+
134+
126135
## Extra
127136

128137
For your convenience, the addon will recognize the [environment variable](https://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings) `GH_TOKEN` and will replace this pattern in the `--repo` string. Please __do NOT disable the silent mode__ if you have any credentials in the repository URL! Read more about [Github tokens here](https://help.github.com/articles/creating-an-access-token-for-command-line-use/).

deploy.js

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +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');
3+
// `require.main.require` so that plugin even works when linked with `npm link`
4+
// see https://github.com/npm/npm/issues/5875 / http://stackoverflow.com/a/25800501
5+
//
6+
// hint:
7+
// this asumes a flat node_modules structure with ember-cli and angular-cli on top
8+
// and does not work in NPM 2 until ember-cli is directly in package.json
9+
var Command = require.main.require('ember-cli/lib/models/command');
10+
var Promise = require.main.require('ember-cli/lib/ext/promise');
11+
var WebpackBuild = require.main.require('angular-cli/addon/ng2/tasks/build-webpack.ts'); // see angular-cli/lib/cli/index.js which hooks up on require calls to transpile TypeScript.
612

713
var path = require('path');
814
var fs = require('fs');
@@ -49,21 +55,28 @@ module.exports = Command.extend({
4955
type: String,
5056
default: 'dist',
5157
description: 'Directory for all published sources, relative to the project-root. Most probably no change is required here.'
58+
}, {
59+
name: 'target',
60+
type: String,
61+
default: 'production',
62+
aliases: ['t', { 'dev': 'development' }, { 'prod': 'production' }],
63+
description: 'Build target (`development` or `production`)'
64+
}, {
65+
name: 'environment',
66+
type: String,
67+
default: 'prod',
68+
aliases: ['e'],
69+
description: 'Environment file to be used with that build (`dev`, `prod` or own)'
5270
}, {
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, useful together with --dir'
71+
name: 'skip-build',
72+
type: Boolean,
73+
default: false,
74+
description: 'Skip building the project before deploying, useful together with --dir'
6275
}, {
63-
name: 'dotfiles',
64-
type: Boolean,
65-
default: true,
66-
description: 'Includes dotfiles by default. When set to `false` files starting with `.` are ignored.'
76+
name: 'dotfiles',
77+
type: Boolean,
78+
default: true,
79+
description: 'Includes dotfiles by default. When set to `false` files starting with `.` are ignored.'
6780
}],
6881
run: function(options, rawArgs) {
6982

@@ -82,15 +95,19 @@ module.exports = Command.extend({
8295
// gh-pages: forwards messages to ui
8396
options.logger = function(message) { ui.write(message + "\n"); }
8497

85-
var buildTask = new BuildTask({
98+
var buildTask = new WebpackBuild({
8699
ui: this.ui,
87100
analytics: this.analytics,
88-
project: this.project
101+
cliProject: this.project,
102+
target: options.target,
103+
environment: options.environment,
104+
outputPath: dir
89105
});
90106

91107
var buildOptions = {
108+
target: options.target,
92109
environment: options.environment,
93-
outputPath: 'dist/'
110+
outputPath: dir
94111
};
95112

96113
if (process.env.TRAVIS) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"license": "MIT",
3535
"dependencies": {
3636
"gh-pages": "^0.11.0"
37-
}
37+
},
3838
"peerDependencies": {
3939
"ember-cli": "^2.5.0"
4040
},

0 commit comments

Comments
 (0)