@@ -9,7 +9,7 @@ import { experimental } from '@angular-devkit/core';
9
9
import { SchematicsException } from '@angular-devkit/schematics' ;
10
10
import { satisfies } from 'semver' ;
11
11
12
- const escapeRegExp = ( str : String ) => str . replace ( / [ \- \[ \] \/ \{ \} \( \) \* \+ \? \ .\\ \^ \$ \ |] / g, '\\$&' ) ;
12
+ const escapeRegExp = ( str : string ) => str . replace ( / [ \- \[ \] \/ { } ( ) * + ? . \\ ^ $ | ] / g, '\\$&' ) ;
13
13
14
14
const moveSync = ( src : string , dest : string ) => {
15
15
copySync ( src , dest ) ;
@@ -30,7 +30,7 @@ const deployToHosting = (
30
30
execSync ( `open http://localhost:${ port } || true` ) ;
31
31
} , 1500 ) ;
32
32
33
- return firebaseTools . serve ( { port, targets : [ 'hosting' ] } ) . then ( ( ) =>
33
+ return firebaseTools . serve ( { port, targets : [ 'hosting' ] } ) . then ( ( ) =>
34
34
require ( 'inquirer' ) . prompt ( {
35
35
type : 'confirm' ,
36
36
name : 'deployProject' ,
@@ -78,19 +78,24 @@ const getPackageJson = (context: BuilderContext, workspaceRoot: string) => {
78
78
const npmList = execSync ( 'npm ls || true' ) . toString ( ) ;
79
79
Object . keys ( dependencies ) . forEach ( ( dependency : string ) => {
80
80
const npmLsMatch = npmList . match ( ` ${ escapeRegExp ( dependency ) } @.+\\w` ) ;
81
- if ( npmLsMatch ) { dependencies [ dependency ] = npmLsMatch [ 0 ] . split ( `${ dependency } @` ) [ 1 ] ; }
81
+ if ( npmLsMatch ) {
82
+ dependencies [ dependency ] = npmLsMatch [ 0 ] . split ( `${ dependency } @` ) [ 1 ] ;
83
+ }
82
84
} ) ;
83
85
Object . keys ( devDependencies ) . forEach ( ( devDependency : string ) => {
84
86
const npmLsMatch = npmList . match ( ` ${ escapeRegExp ( devDependency ) } @.+\\w` ) ;
85
- if ( npmLsMatch ) { devDependencies [ devDependency ] = npmLsMatch [ 0 ] . split ( `${ devDependency } @` ) [ 1 ] ; }
87
+ if ( npmLsMatch ) {
88
+ devDependencies [ devDependency ] = npmLsMatch [ 0 ] . split ( `${ devDependency } @` ) [ 1 ] ;
89
+ }
86
90
} ) ;
87
91
if ( existsSync ( join ( workspaceRoot , 'angular.json' ) ) ) {
88
92
const angularJson = JSON . parse ( readFileSync ( join ( workspaceRoot , 'angular.json' ) ) . toString ( ) ) ;
93
+ // tslint:disable-next-line:no-non-null-assertion
89
94
const server = angularJson . projects [ context . target ! . project ] . architect . server ;
90
95
const serverOptions = server && server . options ;
91
96
const externalDependencies = serverOptions && serverOptions . externalDependencies || [ ] ;
92
97
const bundleDependencies = serverOptions && serverOptions . bundleDependencies ;
93
- if ( bundleDependencies == false ) {
98
+ if ( bundleDependencies ! == true ) {
94
99
if ( existsSync ( join ( workspaceRoot , 'package.json' ) ) ) {
95
100
const packageJson = JSON . parse ( readFileSync ( join ( workspaceRoot , 'package.json' ) ) . toString ( ) ) ;
96
101
Object . keys ( packageJson . dependencies ) . forEach ( ( dependency : string ) => {
@@ -100,7 +105,9 @@ const getPackageJson = (context: BuilderContext, workspaceRoot: string) => {
100
105
} else {
101
106
externalDependencies . forEach ( externalDependency => {
102
107
const npmLsMatch = npmList . match ( ` ${ escapeRegExp ( externalDependency ) } @.+\\w` ) ;
103
- if ( npmLsMatch ) { dependencies [ externalDependency ] = npmLsMatch [ 0 ] . split ( `${ externalDependency } @` ) [ 1 ] ; }
108
+ if ( npmLsMatch ) {
109
+ dependencies [ externalDependency ] = npmLsMatch [ 0 ] . split ( `${ externalDependency } @` ) [ 1 ] ;
110
+ }
104
111
} ) ;
105
112
}
106
113
} // TODO should we throw?
@@ -177,7 +184,7 @@ export const deployToFunction = async (
177
184
execSync ( `open http://localhost:${ port } || true` ) ;
178
185
} , 1500 ) ;
179
186
180
- return firebaseTools . serve ( { port, targets : [ 'hosting' , 'functions' ] } ) . then ( ( ) =>
187
+ return firebaseTools . serve ( { port, targets : [ 'hosting' , 'functions' ] } ) . then ( ( ) =>
181
188
require ( 'inquirer' ) . prompt ( {
182
189
type : 'confirm' ,
183
190
name : 'deployProject' ,
@@ -186,6 +193,7 @@ export const deployToFunction = async (
186
193
) . then ( ( { deployProject } : { deployProject : boolean } ) => {
187
194
if ( deployProject ) {
188
195
return firebaseTools . deploy ( {
196
+ // tslint:disable-next-line:no-non-null-assertion
189
197
only : `hosting:${ context . target ! . project } ,functions:ssr` ,
190
198
cwd : workspaceRoot
191
199
} ) ;
@@ -195,6 +203,7 @@ export const deployToFunction = async (
195
203
} ) ;
196
204
} else {
197
205
return firebaseTools . deploy ( {
206
+ // tslint:disable-next-line:no-non-null-assertion
198
207
only : `hosting:${ context . target ! . project } ,functions:ssr` ,
199
208
cwd : workspaceRoot
200
209
} ) ;
@@ -233,8 +242,6 @@ export default async function deploy(
233
242
}
234
243
235
244
try {
236
- let success : { hosting : string } ;
237
-
238
245
const winston = require ( 'winston' ) ;
239
246
const tripleBeam = require ( 'triple-beam' ) ;
240
247
@@ -243,22 +250,22 @@ export default async function deploy(
243
250
level : 'info' ,
244
251
format : winston . format . printf ( ( info ) =>
245
252
[ info . message , ...( info [ tripleBeam . SPLAT ] || [ ] ) ]
246
- . filter ( ( chunk ) => typeof chunk == 'string' )
253
+ . filter ( ( chunk ) => typeof chunk === 'string' )
247
254
. join ( ' ' )
248
- ) ,
255
+ )
249
256
} )
250
257
) ;
251
258
252
259
if ( ssr ) {
253
- success = await deployToFunction (
260
+ await deployToFunction (
254
261
firebaseTools ,
255
262
context ,
256
263
context . workspaceRoot ,
257
264
projectTargets ,
258
265
preview
259
266
) ;
260
267
} else {
261
- success = await deployToHosting (
268
+ await deployToHosting (
262
269
firebaseTools ,
263
270
context ,
264
271
context . workspaceRoot ,
0 commit comments