@@ -4,8 +4,7 @@ import { execAndWaitForOutputToMatch, npm, silentNpm, ng, git } from './process'
4
4
import { getGlobalVariable } from './env' ;
5
5
import { gitCommit } from './git' ;
6
6
import { prerelease } from 'semver' ;
7
-
8
- const packages = require ( '../../../../lib/packages' ) . packages ;
7
+ import { packages } from '../../../../lib/packages' ;
9
8
10
9
11
10
const tsConfigPath = 'tsconfig.json' ;
@@ -35,7 +34,7 @@ export function ngServe(...args: string[]) {
35
34
36
35
37
36
export async function createProject ( name : string , ...args : string [ ] ) {
38
- const argv : any = getGlobalVariable ( 'argv' ) ;
37
+ const argv : string [ ] = getGlobalVariable ( 'argv' ) ;
39
38
const extraArgs = [ ] ;
40
39
41
40
if ( argv [ 'ivy' ] ) {
@@ -49,9 +48,7 @@ export async function createProject(name: string, ...args: string[]) {
49
48
}
50
49
51
50
export async function prepareProjectForE2e ( name ) {
52
- const argv : string [ ] = getGlobalVariable (
53
- 'argv' ,
54
- ) ;
51
+ const argv : string [ ] = getGlobalVariable ( 'argv' ) ;
55
52
56
53
await git (
57
54
'config' ,
@@ -68,7 +65,7 @@ export async function prepareProjectForE2e(name) {
68
65
'commit.gpgSign' ,
69
66
'false' ,
70
67
) ;
71
- await useBuiltPackages ( ) ;
68
+
72
69
await useCIChrome (
73
70
'e2e' ,
74
71
) ;
@@ -81,26 +78,13 @@ export async function prepareProjectForE2e(name) {
81
78
'src' ,
82
79
) ;
83
80
84
- await useDevKitSnapshots ( ) ;
85
- ( await argv [
86
- 'ng2'
87
- ] )
88
- ? useNg2 ( )
89
- : Promise . resolve ( ) ;
90
- ( await argv [
91
- 'ng4'
92
- ] )
93
- ? useNg4 ( )
94
- : Promise . resolve ( ) ;
95
- ( await argv [
96
- 'ng-snapshots'
97
- ] ) ||
98
- argv [
99
- 'ng-tag'
100
- ]
101
- ? useSha ( )
102
- : Promise . resolve ( ) ;
103
- await console . log (
81
+ if ( argv [ 'ng-snapshots' ] || argv [ 'ng-tag' ] ) {
82
+ await useSha ( ) ;
83
+ } else {
84
+ await writeFile ( '.npmrc' , 'registry=http://localhost:4873' ) ;
85
+ }
86
+
87
+ console . log (
104
88
`Project ${ name } created... Installing npm.` ,
105
89
) ;
106
90
await silentNpm (
@@ -126,44 +110,6 @@ export async function prepareProjectForE2e(name) {
126
110
) ;
127
111
}
128
112
129
-
130
- export function useDevKit ( devkitRoot : string ) {
131
- return Promise . resolve ( )
132
- . then ( ( ) => {
133
- // Load the packages info for devkit.
134
- const devkitPackages = require ( devkitRoot + '/lib/packages' ) . packages ;
135
-
136
- return updateJsonFile ( 'package.json' , json => {
137
- if ( ! json [ 'dependencies' ] ) {
138
- json [ 'dependencies' ] = { } ;
139
- }
140
- if ( ! json [ 'devDependencies' ] ) {
141
- json [ 'devDependencies' ] = { } ;
142
- }
143
-
144
- for ( const packageName of Object . keys ( devkitPackages ) ) {
145
- if ( json [ 'dependencies' ] . hasOwnProperty ( packageName ) ) {
146
- json [ 'dependencies' ] [ packageName ] = devkitPackages [ packageName ] . tar ;
147
- } else if ( json [ 'devDependencies' ] . hasOwnProperty ( packageName ) ) {
148
- json [ 'devDependencies' ] [ packageName ] = devkitPackages [ packageName ] . tar ;
149
- }
150
- }
151
- } ) ;
152
- } ) ;
153
- }
154
-
155
- export function useDevKitSnapshots ( ) {
156
- return updateJsonFile ( 'package.json' , json => {
157
- // TODO: actually add these.
158
- // These were not working on any test that ran `npm i`.
159
- // json['devDependencies']['@angular-devkit/build-angular'] =
160
- // 'github:angular/angular-devkit-build-angular-builds';
161
- // // By adding build-ng-packagr preemptively, adding a lib will not update it.
162
- // json['devDependencies']['@angular-devkit/build-ng-packagr'] =
163
- // 'github:angular/angular-devkit-build-ng-packagr-builds';
164
- } ) ;
165
- }
166
-
167
113
export function useBuiltPackages ( ) {
168
114
return Promise . resolve ( )
169
115
. then ( ( ) => updateJsonFile ( 'package.json' , json => {
@@ -344,160 +290,6 @@ export function useCIChrome(projectDir: string) {
344
290
} ) ;
345
291
}
346
292
347
- // Convert a Angular 5 project to Angular 2.
348
- export function useNg2 ( ) {
349
- const ng2Deps : any = {
350
- 'dependencies' : {
351
- '@angular/common' : '^2.4.0' ,
352
- '@angular/compiler' : '^2.4.0' ,
353
- '@angular/core' : '^2.4.0' ,
354
- '@angular/forms' : '^2.4.0' ,
355
- '@angular/http' : '^2.4.0' ,
356
- '@angular/platform-browser' : '^2.4.0' ,
357
- '@angular/platform-browser-dynamic' : '^2.4.0' ,
358
- '@angular/router' : '^3.4.0' ,
359
- 'zone.js' : '^0.7.4'
360
- } ,
361
- 'devDependencies' : {
362
- '@angular/compiler-cli' : '^2.4.0' ,
363
- '@types/jasmine' : '~2.2.0' ,
364
- '@types/jasminewd2' : undefined ,
365
- 'typescript' : '~2.0.0'
366
- }
367
- } ;
368
-
369
- const tsconfigAppJson : any = {
370
- 'compilerOptions' : {
371
- 'sourceMap' : true ,
372
- 'declaration' : false ,
373
- 'moduleResolution' : 'node' ,
374
- 'emitDecoratorMetadata' : true ,
375
- 'experimentalDecorators' : true ,
376
- 'target' : 'es5' ,
377
- 'lib' : [
378
- 'es2017' ,
379
- 'dom'
380
- ] ,
381
- 'outDir' : '../out-tsc/app' ,
382
- 'module' : 'es2015' ,
383
- 'baseUrl' : '' ,
384
- 'types' : [ ]
385
- } ,
386
- 'exclude' : [
387
- 'test.ts' ,
388
- '**/*.spec.ts'
389
- ]
390
- } ;
391
-
392
- const tsconfigSpecJson : any = {
393
- 'compilerOptions' : {
394
- 'sourceMap' : true ,
395
- 'declaration' : false ,
396
- 'moduleResolution' : 'node' ,
397
- 'emitDecoratorMetadata' : true ,
398
- 'experimentalDecorators' : true ,
399
- 'lib' : [
400
- 'es2017' ,
401
- 'dom'
402
- ] ,
403
- 'outDir' : '../out-tsc/spec' ,
404
- 'module' : 'commonjs' ,
405
- 'target' : 'es5' ,
406
- 'baseUrl' : '' ,
407
- 'types' : [
408
- 'jasmine' ,
409
- 'node'
410
- ]
411
- } ,
412
- 'files' : [
413
- 'test.ts'
414
- ] ,
415
- 'include' : [
416
- '**/*.spec.ts' ,
417
- '**/*.d.ts'
418
- ]
419
- } ;
420
-
421
- const tsconfigE2eJson : any = {
422
- 'compilerOptions' : {
423
- 'sourceMap' : true ,
424
- 'declaration' : false ,
425
- 'moduleResolution' : 'node' ,
426
- 'emitDecoratorMetadata' : true ,
427
- 'experimentalDecorators' : true ,
428
- 'lib' : [
429
- 'es2017'
430
- ] ,
431
- 'outDir' : '../out-tsc/e2e' ,
432
- 'module' : 'commonjs' ,
433
- 'target' : 'es5' ,
434
- 'types' : [
435
- 'jasmine' ,
436
- 'node'
437
- ]
438
- }
439
- } ;
440
-
441
-
442
- return Promise . resolve ( )
443
- . then ( ( ) => updateJsonFile ( 'package.json' , json => {
444
- Object . keys ( ng2Deps [ 'dependencies' ] ) . forEach ( pkgName => {
445
- json [ 'dependencies' ] [ pkgName ] = ng2Deps [ 'dependencies' ] [ pkgName ] ;
446
- } ) ;
447
- Object . keys ( ng2Deps [ 'devDependencies' ] ) . forEach ( pkgName => {
448
- json [ 'devDependencies' ] [ pkgName ] = ng2Deps [ 'devDependencies' ] [ pkgName ] ;
449
- } ) ;
450
- console . log ( JSON . stringify ( json ) ) ;
451
- } ) )
452
- . then ( ( ) => updateJsonFile ( 'src/tsconfig.app.json' , json =>
453
- Object . assign ( json , tsconfigAppJson ) ) )
454
- . then ( ( ) => updateJsonFile ( 'src/tsconfig.spec.json' , json =>
455
- Object . assign ( json , tsconfigSpecJson ) ) )
456
- . then ( ( ) => updateJsonFile ( 'e2e/tsconfig.e2e.json' , json =>
457
- Object . assign ( json , tsconfigE2eJson ) ) )
458
- . then ( ( ) => replaceInFile ( 'src/test.ts' , 'import \'zone.js/dist/zone-testing\';' , `
459
- import 'zone.js/dist/long-stack-trace-zone';
460
- import 'zone.js/dist/proxy.js';
461
- import 'zone.js/dist/sync-test';
462
- import 'zone.js/dist/jasmine-patch';
463
- import 'zone.js/dist/async-test';
464
- import 'zone.js/dist/fake-async-test';
465
- ` ) ) ;
466
- }
467
-
468
- // Convert a Angular 5 project to Angular 4.
469
- export function useNg4 ( ) {
470
- const ng4Deps : any = {
471
- 'dependencies' : {
472
- '@angular/common' : '^4.4.6' ,
473
- '@angular/compiler' : '^4.4.6' ,
474
- '@angular/core' : '^4.4.6' ,
475
- '@angular/forms' : '^4.4.6' ,
476
- '@angular/http' : '^4.4.6' ,
477
- '@angular/platform-browser' : '^4.4.6' ,
478
- '@angular/platform-browser-dynamic' : '^4.4.6' ,
479
- '@angular/router' : '^4.4.6' ,
480
- 'zone.js' : '^0.8.14'
481
- } ,
482
- 'devDependencies' : {
483
- '@angular/compiler-cli' : '^4.4.6' ,
484
- 'typescript' : '~2.3.3'
485
- }
486
- } ;
487
-
488
-
489
- return Promise . resolve ( )
490
- . then ( ( ) => updateJsonFile ( 'package.json' , json => {
491
- Object . keys ( ng4Deps [ 'dependencies' ] ) . forEach ( pkgName => {
492
- json [ 'dependencies' ] [ pkgName ] = ng4Deps [ 'dependencies' ] [ pkgName ] ;
493
- } ) ;
494
- Object . keys ( ng4Deps [ 'devDependencies' ] ) . forEach ( pkgName => {
495
- json [ 'devDependencies' ] [ pkgName ] = ng4Deps [ 'devDependencies' ] [ pkgName ] ;
496
- } ) ;
497
- console . log ( JSON . stringify ( json ) ) ;
498
- } ) ) ;
499
- }
500
-
501
293
export async function isPrereleaseCli ( ) {
502
294
const angularCliPkgJson = JSON . parse ( await readFile ( 'node_modules/@angular/cli/package.json' ) ) ;
503
295
const pre = prerelease ( angularCliPkgJson . version ) ;
0 commit comments