@@ -4,8 +4,7 @@ import { execAndWaitForOutputToMatch, npm, silentNpm, ng, git } from './process'
44import { getGlobalVariable } from './env' ;
55import { gitCommit } from './git' ;
66import { prerelease } from 'semver' ;
7-
8- const packages = require ( '../../../../lib/packages' ) . packages ;
7+ import { packages } from '../../../../lib/packages' ;
98
109
1110const tsConfigPath = 'tsconfig.json' ;
@@ -35,7 +34,7 @@ export function ngServe(...args: string[]) {
3534
3635
3736export async function createProject ( name : string , ...args : string [ ] ) {
38- const argv : any = getGlobalVariable ( 'argv' ) ;
37+ const argv : string [ ] = getGlobalVariable ( 'argv' ) ;
3938 const extraArgs = [ ] ;
4039
4140 if ( argv [ 'ivy' ] ) {
@@ -49,9 +48,7 @@ export async function createProject(name: string, ...args: string[]) {
4948}
5049
5150export async function prepareProjectForE2e ( name ) {
52- const argv : string [ ] = getGlobalVariable (
53- 'argv' ,
54- ) ;
51+ const argv : string [ ] = getGlobalVariable ( 'argv' ) ;
5552
5653 await git (
5754 'config' ,
@@ -68,7 +65,7 @@ export async function prepareProjectForE2e(name) {
6865 'commit.gpgSign' ,
6966 'false' ,
7067 ) ;
71- await useBuiltPackages ( ) ;
68+
7269 await useCIChrome (
7370 'e2e' ,
7471 ) ;
@@ -81,26 +78,13 @@ export async function prepareProjectForE2e(name) {
8178 'src' ,
8279 ) ;
8380
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 (
10488 `Project ${ name } created... Installing npm.` ,
10589 ) ;
10690 await silentNpm (
@@ -126,44 +110,6 @@ export async function prepareProjectForE2e(name) {
126110 ) ;
127111}
128112
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-
167113export function useBuiltPackages ( ) {
168114 return Promise . resolve ( )
169115 . then ( ( ) => updateJsonFile ( 'package.json' , json => {
@@ -344,160 +290,6 @@ export function useCIChrome(projectDir: string) {
344290 } ) ;
345291}
346292
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-
501293export async function isPrereleaseCli ( ) {
502294 const angularCliPkgJson = JSON . parse ( await readFile ( 'node_modules/@angular/cli/package.json' ) ) ;
503295 const pre = prerelease ( angularCliPkgJson . version ) ;
0 commit comments