diff --git a/tests/legacy-cli/e2e/setup/015-build.ts b/tests/legacy-cli/e2e/setup/015-build.ts deleted file mode 100644 index 4c434aac714b..000000000000 --- a/tests/legacy-cli/e2e/setup/015-build.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { getGlobalVariable } from '../utils/env'; -import { npm } from '../utils/process'; - -export default function() { - const argv = getGlobalVariable('argv'); - if (argv.nobuild) { - return; - } - - return npm('run', 'build', '--', '--local'); -} diff --git a/tests/legacy-cli/e2e/setup/100-global-cli.ts b/tests/legacy-cli/e2e/setup/100-global-cli.ts index dd24d7acc8a7..21ed8749789c 100644 --- a/tests/legacy-cli/e2e/setup/100-global-cli.ts +++ b/tests/legacy-cli/e2e/setup/100-global-cli.ts @@ -1,8 +1,6 @@ import { getGlobalVariable } from '../utils/env'; import { exec, silentNpm } from '../utils/process'; -const packages = require('../../../../lib/packages').packages; - export default async function() { const argv = getGlobalVariable('argv'); if (argv.noglobal) { @@ -10,7 +8,12 @@ export default async function() { } // Install global Angular CLI. - await silentNpm('install', '-g', packages['@angular/cli'].tar); + await silentNpm( + 'install', + '--global', + '@angular/cli', + '--registry=http://localhost:4873', + ); try { await exec(process.platform.startsWith('win') ? 'where' : 'which', 'ng'); diff --git a/tests/legacy-cli/e2e/utils/project.ts b/tests/legacy-cli/e2e/utils/project.ts index 7960614d06b5..789ce4eab3f3 100644 --- a/tests/legacy-cli/e2e/utils/project.ts +++ b/tests/legacy-cli/e2e/utils/project.ts @@ -4,8 +4,7 @@ import { execAndWaitForOutputToMatch, npm, silentNpm, ng, git } from './process' import { getGlobalVariable } from './env'; import { gitCommit } from './git'; import { prerelease } from 'semver'; - -const packages = require('../../../../lib/packages').packages; +import { packages } from '../../../../lib/packages'; const tsConfigPath = 'tsconfig.json'; @@ -35,7 +34,7 @@ export function ngServe(...args: string[]) { export async function createProject(name: string, ...args: string[]) { - const argv: any = getGlobalVariable('argv'); + const argv: string[] = getGlobalVariable('argv'); const extraArgs = []; if (argv['ivy']) { @@ -49,9 +48,7 @@ export async function createProject(name: string, ...args: string[]) { } export async function prepareProjectForE2e(name) { - const argv: string[] = getGlobalVariable( - 'argv', - ); + const argv: string[] = getGlobalVariable('argv'); await git( 'config', @@ -68,7 +65,7 @@ export async function prepareProjectForE2e(name) { 'commit.gpgSign', 'false', ); - await useBuiltPackages(); + await useCIChrome( 'e2e', ); @@ -81,26 +78,13 @@ export async function prepareProjectForE2e(name) { 'src', ); - await useDevKitSnapshots(); - (await argv[ - 'ng2' - ]) - ? useNg2() - : Promise.resolve(); - (await argv[ - 'ng4' - ]) - ? useNg4() - : Promise.resolve(); - (await argv[ - 'ng-snapshots' - ]) || - argv[ - 'ng-tag' - ] - ? useSha() - : Promise.resolve(); - await console.log( + if (argv['ng-snapshots'] || argv['ng-tag']) { + await useSha(); + } else { + await writeFile('.npmrc', 'registry=http://localhost:4873'); + } + + console.log( `Project ${name} created... Installing npm.`, ); await silentNpm( @@ -126,44 +110,6 @@ export async function prepareProjectForE2e(name) { ); } - -export function useDevKit(devkitRoot: string) { - return Promise.resolve() - .then(() => { - // Load the packages info for devkit. - const devkitPackages = require(devkitRoot + '/lib/packages').packages; - - return updateJsonFile('package.json', json => { - if (!json['dependencies']) { - json['dependencies'] = {}; - } - if (!json['devDependencies']) { - json['devDependencies'] = {}; - } - - for (const packageName of Object.keys(devkitPackages)) { - if (json['dependencies'].hasOwnProperty(packageName)) { - json['dependencies'][packageName] = devkitPackages[packageName].tar; - } else if (json['devDependencies'].hasOwnProperty(packageName)) { - json['devDependencies'][packageName] = devkitPackages[packageName].tar; - } - } - }); - }); -} - -export function useDevKitSnapshots() { - return updateJsonFile('package.json', json => { - // TODO: actually add these. - // These were not working on any test that ran `npm i`. - // json['devDependencies']['@angular-devkit/build-angular'] = - // 'github:angular/angular-devkit-build-angular-builds'; - // // By adding build-ng-packagr preemptively, adding a lib will not update it. - // json['devDependencies']['@angular-devkit/build-ng-packagr'] = - // 'github:angular/angular-devkit-build-ng-packagr-builds'; - }); -} - export function useBuiltPackages() { return Promise.resolve() .then(() => updateJsonFile('package.json', json => { @@ -344,160 +290,6 @@ export function useCIChrome(projectDir: string) { }); } -// Convert a Angular 5 project to Angular 2. -export function useNg2() { - const ng2Deps: any = { - 'dependencies': { - '@angular/common': '^2.4.0', - '@angular/compiler': '^2.4.0', - '@angular/core': '^2.4.0', - '@angular/forms': '^2.4.0', - '@angular/http': '^2.4.0', - '@angular/platform-browser': '^2.4.0', - '@angular/platform-browser-dynamic': '^2.4.0', - '@angular/router': '^3.4.0', - 'zone.js': '^0.7.4' - }, - 'devDependencies': { - '@angular/compiler-cli': '^2.4.0', - '@types/jasmine': '~2.2.0', - '@types/jasminewd2': undefined, - 'typescript': '~2.0.0' - } - }; - - const tsconfigAppJson: any = { - 'compilerOptions': { - 'sourceMap': true, - 'declaration': false, - 'moduleResolution': 'node', - 'emitDecoratorMetadata': true, - 'experimentalDecorators': true, - 'target': 'es5', - 'lib': [ - 'es2017', - 'dom' - ], - 'outDir': '../out-tsc/app', - 'module': 'es2015', - 'baseUrl': '', - 'types': [] - }, - 'exclude': [ - 'test.ts', - '**/*.spec.ts' - ] - }; - - const tsconfigSpecJson: any = { - 'compilerOptions': { - 'sourceMap': true, - 'declaration': false, - 'moduleResolution': 'node', - 'emitDecoratorMetadata': true, - 'experimentalDecorators': true, - 'lib': [ - 'es2017', - 'dom' - ], - 'outDir': '../out-tsc/spec', - 'module': 'commonjs', - 'target': 'es5', - 'baseUrl': '', - 'types': [ - 'jasmine', - 'node' - ] - }, - 'files': [ - 'test.ts' - ], - 'include': [ - '**/*.spec.ts', - '**/*.d.ts' - ] - }; - - const tsconfigE2eJson: any = { - 'compilerOptions': { - 'sourceMap': true, - 'declaration': false, - 'moduleResolution': 'node', - 'emitDecoratorMetadata': true, - 'experimentalDecorators': true, - 'lib': [ - 'es2017' - ], - 'outDir': '../out-tsc/e2e', - 'module': 'commonjs', - 'target': 'es5', - 'types': [ - 'jasmine', - 'node' - ] - } - }; - - - return Promise.resolve() - .then(() => updateJsonFile('package.json', json => { - Object.keys(ng2Deps['dependencies']).forEach(pkgName => { - json['dependencies'][pkgName] = ng2Deps['dependencies'][pkgName]; - }); - Object.keys(ng2Deps['devDependencies']).forEach(pkgName => { - json['devDependencies'][pkgName] = ng2Deps['devDependencies'][pkgName]; - }); - console.log(JSON.stringify(json)); - })) - .then(() => updateJsonFile('src/tsconfig.app.json', json => - Object.assign(json, tsconfigAppJson))) - .then(() => updateJsonFile('src/tsconfig.spec.json', json => - Object.assign(json, tsconfigSpecJson))) - .then(() => updateJsonFile('e2e/tsconfig.e2e.json', json => - Object.assign(json, tsconfigE2eJson))) - .then(() => replaceInFile('src/test.ts', 'import \'zone.js/dist/zone-testing\';', ` - import 'zone.js/dist/long-stack-trace-zone'; - import 'zone.js/dist/proxy.js'; - import 'zone.js/dist/sync-test'; - import 'zone.js/dist/jasmine-patch'; - import 'zone.js/dist/async-test'; - import 'zone.js/dist/fake-async-test'; - `)); -} - -// Convert a Angular 5 project to Angular 4. -export function useNg4() { - const ng4Deps: any = { - 'dependencies': { - '@angular/common': '^4.4.6', - '@angular/compiler': '^4.4.6', - '@angular/core': '^4.4.6', - '@angular/forms': '^4.4.6', - '@angular/http': '^4.4.6', - '@angular/platform-browser': '^4.4.6', - '@angular/platform-browser-dynamic': '^4.4.6', - '@angular/router': '^4.4.6', - 'zone.js': '^0.8.14' - }, - 'devDependencies': { - '@angular/compiler-cli': '^4.4.6', - 'typescript': '~2.3.3' - } - }; - - - return Promise.resolve() - .then(() => updateJsonFile('package.json', json => { - Object.keys(ng4Deps['dependencies']).forEach(pkgName => { - json['dependencies'][pkgName] = ng4Deps['dependencies'][pkgName]; - }); - Object.keys(ng4Deps['devDependencies']).forEach(pkgName => { - json['devDependencies'][pkgName] = ng4Deps['devDependencies'][pkgName]; - }); - console.log(JSON.stringify(json)); - })); -} - export async function isPrereleaseCli() { const angularCliPkgJson = JSON.parse(await readFile('node_modules/@angular/cli/package.json')); const pre = prerelease(angularCliPkgJson.version); diff --git a/tests/legacy-cli/verdaccio.yaml b/tests/legacy-cli/verdaccio.yaml index 1a3c825278c3..75ca0c10e257 100644 --- a/tests/legacy-cli/verdaccio.yaml +++ b/tests/legacy-cli/verdaccio.yaml @@ -18,7 +18,7 @@ packages: access: $all publish: $all - '@ngtools/*': + '@ngtools/webpack': access: $all publish: $all