Skip to content

Commit 8d7ab42

Browse files
clydinmgechev
authored andcommitted
test: use locally published version in E2E project setup (#15052)
1 parent 20696fa commit 8d7ab42

File tree

4 files changed

+18
-234
lines changed

4 files changed

+18
-234
lines changed

tests/legacy-cli/e2e/setup/015-build.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

tests/legacy-cli/e2e/setup/100-global-cli.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import { getGlobalVariable } from '../utils/env';
22
import { exec, silentNpm } from '../utils/process';
33

4-
const packages = require('../../../../lib/packages').packages;
5-
64
export default async function() {
75
const argv = getGlobalVariable('argv');
86
if (argv.noglobal) {
97
return;
108
}
119

1210
// Install global Angular CLI.
13-
await silentNpm('install', '-g', packages['@angular/cli'].tar);
11+
await silentNpm(
12+
'install',
13+
'--global',
14+
'@angular/cli',
15+
'--registry=http://localhost:4873',
16+
);
1417

1518
try {
1619
await exec(process.platform.startsWith('win') ? 'where' : 'which', 'ng');

tests/legacy-cli/e2e/utils/project.ts

Lines changed: 11 additions & 219 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { execAndWaitForOutputToMatch, npm, silentNpm, ng, git } from './process'
44
import { getGlobalVariable } from './env';
55
import { gitCommit } from './git';
66
import { prerelease } from 'semver';
7-
8-
const packages = require('../../../../lib/packages').packages;
7+
import { packages } from '../../../../lib/packages';
98

109

1110
const tsConfigPath = 'tsconfig.json';
@@ -35,7 +34,7 @@ export function ngServe(...args: string[]) {
3534

3635

3736
export 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

5150
export 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-
167113
export 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-
501293
export async function isPrereleaseCli() {
502294
const angularCliPkgJson = JSON.parse(await readFile('node_modules/@angular/cli/package.json'));
503295
const pre = prerelease(angularCliPkgJson.version);

tests/legacy-cli/verdaccio.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ packages:
1818
access: $all
1919
publish: $all
2020

21-
'@ngtools/*':
21+
'@ngtools/webpack':
2222
access: $all
2323
publish: $all
2424

0 commit comments

Comments
 (0)