@@ -6,8 +6,9 @@ import * as chalk from 'chalk';
6
6
import * as fs from 'fs' ;
7
7
import * as fse from 'fs-extra' ;
8
8
import * as path from 'path' ;
9
- import * as BuildTask from 'ember-cli/lib/ tasks/build' ;
9
+ import * as WebpackBuild from '../ tasks/build-webpack ' ;
10
10
import * as CreateGithubRepo from '../tasks/create-github-repo' ;
11
+ import { CliConfig } from '../models/config' ;
11
12
12
13
const fsReadFile = Promise . denodeify ( fs . readFile ) ;
13
14
const fsWriteFile = Promise . denodeify ( fs . writeFile ) ;
@@ -26,11 +27,16 @@ module.exports = Command.extend({
26
27
type : String ,
27
28
default : 'new gh-pages version' ,
28
29
description : 'The commit message to include with the build, must be wrapped in quotes.'
29
- } , {
30
+ } , {
31
+ name : 'target' ,
32
+ type : String ,
33
+ default : 'production' ,
34
+ aliases : [ 't' , { 'dev' : 'development' } , { 'prod' : 'production' } ]
35
+ } , {
30
36
name : 'environment' ,
31
37
type : String ,
32
- default : 'production ' ,
33
- description : 'The Angular environment to create a build for'
38
+ default : '' ,
39
+ aliases : [ 'e' ]
34
40
} , {
35
41
name : 'user-page' ,
36
42
type : Boolean ,
@@ -59,24 +65,40 @@ module.exports = Command.extend({
59
65
var execOptions = {
60
66
cwd : root
61
67
} ;
68
+
69
+ if ( options . environment === '' ) {
70
+ if ( options . target === 'development' ) {
71
+ options . environment = 'dev' ;
72
+ }
73
+ if ( options . target === 'production' ) {
74
+ options . environment = 'prod' ;
75
+ }
76
+ }
77
+
62
78
var projectName = this . project . pkg . name ;
63
79
80
+ const outDir = CliConfig . fromProject ( ) . apps [ 0 ] . outDir ;
81
+
64
82
let ghPagesBranch = 'gh-pages' ;
65
83
let destinationBranch = options . userPage ? 'master' : ghPagesBranch ;
66
84
let initialBranch ;
67
85
68
86
// declared here so that tests can stub exec
69
87
const execPromise = Promise . denodeify ( exec ) ;
70
88
71
- var buildTask = new BuildTask ( {
89
+ var buildTask = new WebpackBuild ( {
72
90
ui : this . ui ,
73
91
analytics : this . analytics ,
74
- project : this . project
92
+ cliProject : this . project ,
93
+ target : options . target ,
94
+ environment : options . environment ,
95
+ outputPath : outDir
75
96
} ) ;
76
97
77
98
var buildOptions = {
99
+ target : options . target ,
78
100
environment : options . environment ,
79
- outputPath : 'dist/'
101
+ outputPath : outDir
80
102
} ;
81
103
82
104
var createGithubRepoTask = new CreateGithubRepo ( {
@@ -155,13 +177,13 @@ module.exports = Command.extend({
155
177
}
156
178
157
179
function copyFiles ( ) {
158
- return fsReadDir ( 'dist' )
180
+ return fsReadDir ( outDir )
159
181
. then ( ( files ) => Promise . all ( files . map ( ( file ) => {
160
182
if ( file === '.gitignore' ) {
161
183
// don't overwrite the .gitignore file
162
184
return Promise . resolve ( ) ;
163
185
}
164
- return fsCopy ( path . join ( 'dist' , file ) , path . join ( '.' , file ) )
186
+ return fsCopy ( path . join ( outDir , file ) , path . join ( '.' , file ) )
165
187
} ) ) ) ;
166
188
}
167
189
0 commit comments