1
1
import { readFile , writeFile } from './fs' ;
2
- import { silentExecAndWaitForOutputToMatch } from './process' ;
2
+ import { silentExecAndWaitForOutputToMatch , silentNpm , ng } from './process' ;
3
+ import { getGlobalVariable } from './env' ;
4
+
5
+ const packages = require ( '../../../lib/packages' ) ;
6
+
3
7
4
8
const tsConfigPath = 'src/tsconfig.json' ;
5
9
@@ -24,3 +28,39 @@ export function ngServe(...args: string[]) {
24
28
return silentExecAndWaitForOutputToMatch ( 'ng' ,
25
29
[ 'serve' , ...args ] , / w e b p a c k : b u n d l e i s n o w V A L I D / ) ;
26
30
}
31
+
32
+
33
+ export function createProject ( name : string , ...args : string [ ] ) {
34
+ return Promise . resolve ( )
35
+ . then ( ( ) => process . chdir ( getGlobalVariable ( 'tmp-root' ) ) )
36
+ . then ( ( ) => ng ( 'new' , name , '--skip-npm' , ...args ) )
37
+ . then ( ( ) => process . chdir ( name ) )
38
+ . then ( ( ) => updateJsonFile ( 'package.json' , json => {
39
+ Object . keys ( packages ) . forEach ( pkgName => {
40
+ json [ 'dependencies' ] [ pkgName ] = packages [ pkgName ] . dist ;
41
+ } ) ;
42
+ } ) )
43
+ . then ( ( ) => {
44
+ const argv : any = getGlobalVariable ( 'argv' ) ;
45
+ if ( argv . nightly ) {
46
+ return updateJsonFile ( 'package.json' , json => {
47
+ // Install over the project with nightly builds.
48
+ const angularPackages = [
49
+ 'core' ,
50
+ 'common' ,
51
+ 'compiler' ,
52
+ 'forms' ,
53
+ 'http' ,
54
+ 'router' ,
55
+ 'platform-browser' ,
56
+ 'platform-browser-dynamic'
57
+ ] ;
58
+ angularPackages . forEach ( pkgName => {
59
+ json [ 'dependencies' ] [ `@angular/${ pkgName } ` ] = `github:angular/${ pkgName } -builds` ;
60
+ } ) ;
61
+ } ) ;
62
+ }
63
+ } )
64
+ . then ( ( ) => console . log ( `Project ${ name } created... Installing npm.` ) )
65
+ . then ( ( ) => silentNpm ( 'install' ) ) ;
66
+ }
0 commit comments