Skip to content

Commit 245fc50

Browse files
alan-agius4filipesilva
authored andcommitted
test: format updates files
(cherry picked from commit 82cf6dc)
1 parent de674f2 commit 245fc50

File tree

2 files changed

+40
-75
lines changed

2 files changed

+40
-75
lines changed

tests/legacy-cli/e2e/tests/update/update-8.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default async function () {
1616
// Update Angular to 9
1717
await installPackage('@angular/cli@8');
1818
const { stdout } = await ng('update', '@angular/[email protected]', '@angular/[email protected]');
19-
if (!stdout.includes('Executing migrations of package \'@angular/cli\'')) {
19+
if (!stdout.includes("Executing migrations of package '@angular/cli'")) {
2020
throw new Error('Update did not execute migrations. OUTPUT: \n' + stdout);
2121
}
2222

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

Lines changed: 39 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -9,92 +9,55 @@ import { installWorkspacePackages } from './packages';
99
import { execAndWaitForOutputToMatch, git, ng } from './process';
1010

1111
export function updateJsonFile(filePath: string, fn: (json: any) => any | void) {
12-
return readFile(filePath)
13-
.then(tsConfigJson => {
14-
// Remove single and multiline comments
15-
const tsConfig = JSON.parse(tsConfigJson.replace(/\/\*\s(.|\n|\r)*\s\*\/|\/\/.*/g, ''));
16-
const result = fn(tsConfig) || tsConfig;
12+
return readFile(filePath).then((tsConfigJson) => {
13+
// Remove single and multiline comments
14+
const tsConfig = JSON.parse(tsConfigJson.replace(/\/\*\s(.|\n|\r)*\s\*\/|\/\/.*/g, ''));
15+
const result = fn(tsConfig) || tsConfig;
1716

18-
return writeFile(filePath, JSON.stringify(result, null, 2));
19-
});
17+
return writeFile(filePath, JSON.stringify(result, null, 2));
18+
});
2019
}
2120

22-
2321
export function updateTsConfig(fn: (json: any) => any | void) {
2422
return updateJsonFile('tsconfig.json', fn);
2523
}
2624

27-
2825
export function ngServe(...args: string[]) {
29-
return execAndWaitForOutputToMatch('ng',
30-
['serve', ...args],
31-
/ Compiled successfully./);
26+
return execAndWaitForOutputToMatch('ng', ['serve', ...args], / Compiled successfully./);
3227
}
3328

3429
export async function prepareProjectForE2e(name) {
3530
const argv: string[] = getGlobalVariable('argv');
3631

37-
await git(
38-
'config',
39-
'user.email',
40-
41-
);
42-
await git(
43-
'config',
44-
'user.name',
45-
'Angular CLI E2e',
46-
);
47-
await git(
48-
'config',
49-
'commit.gpgSign',
50-
'false',
51-
);
32+
await git('config', 'user.email', '[email protected]');
33+
await git('config', 'user.name', 'Angular CLI E2e');
34+
await git('config', 'commit.gpgSign', 'false');
5235

5336
await ng('generate', '@schematics/angular:e2e', '--related-app-name', name);
5437

55-
await useCIChrome(
56-
'e2e',
57-
);
58-
await useCIChrome(
59-
'',
60-
);
38+
await useCIChrome('e2e');
39+
await useCIChrome('');
6140

6241
// legacy projects
63-
await useCIChrome(
64-
'src',
65-
);
42+
await useCIChrome('src');
6643

6744
if (argv['ng-snapshots'] || argv['ng-tag']) {
6845
await useSha();
6946
}
7047

71-
console.log(
72-
`Project ${name} created... Installing npm.`,
73-
);
48+
console.log(`Project ${name} created... Installing npm.`);
7449
await installWorkspacePackages();
75-
await useCIDefaults(
76-
name,
77-
);
50+
await useCIDefaults(name);
7851
// Force sourcemaps to be from the root of the filesystem.
79-
await updateJsonFile(
80-
'tsconfig.json',
81-
json => {
82-
json[
83-
'compilerOptions'
84-
][
85-
'sourceRoot'
86-
] =
87-
'/';
88-
},
89-
);
90-
await gitCommit(
91-
'prepare-project-for-e2e',
92-
);
52+
await updateJsonFile('tsconfig.json', (json) => {
53+
json['compilerOptions']['sourceRoot'] = '/';
54+
});
55+
await gitCommit('prepare-project-for-e2e');
9356
}
9457

9558
export function useBuiltPackages() {
96-
return Promise.resolve()
97-
.then(() => updateJsonFile('package.json', json => {
59+
return Promise.resolve().then(() =>
60+
updateJsonFile('package.json', (json) => {
9861
if (!json['dependencies']) {
9962
json['dependencies'] = {};
10063
}
@@ -103,14 +66,14 @@ export function useBuiltPackages() {
10366
}
10467

10568
for (const packageName of Object.keys(packages)) {
106-
if (json['dependencies'].hasOwnProperty(packageName)
107-
) {
69+
if (json['dependencies'].hasOwnProperty(packageName)) {
10870
json['dependencies'][packageName] = packages[packageName].tar;
10971
} else if (json['devDependencies'].hasOwnProperty(packageName)) {
11072
json['devDependencies'][packageName] = packages[packageName].tar;
11173
}
11274
}
113-
}));
75+
}),
76+
);
11477
}
11578

11679
export function useSha() {
@@ -121,20 +84,19 @@ export function useSha() {
12184
// 6.1.6+4a8d56a
12285
const label = argv['ng-tag'] ? argv['ng-tag'] : '';
12386
const ngSnapshotVersions = require('../ng-snapshot/package.json');
124-
return updateJsonFile('package.json', json => {
87+
return updateJsonFile('package.json', (json) => {
12588
// Install over the project with snapshot builds.
12689
function replaceDependencies(key: string) {
12790
const missingSnapshots = [];
12891
Object.keys(json[key] || {})
129-
.filter(name => name.match(/^@angular\//))
130-
.forEach(name => {
92+
.filter((name) => name.match(/^@angular\//))
93+
.forEach((name) => {
13194
const pkgName = name.split(/\//)[1];
13295
if (pkgName == 'cli') {
13396
return;
13497
}
13598
if (label) {
136-
json[key][`@angular/${pkgName}`]
137-
= `github:angular/${pkgName}-builds${label}`;
99+
json[key][`@angular/${pkgName}`] = `github:angular/${pkgName}-builds${label}`;
138100
} else {
139101
const replacement = ngSnapshotVersions.dependencies[`@angular/${pkgName}`];
140102
if (!replacement) {
@@ -144,8 +106,11 @@ export function useSha() {
144106
}
145107
});
146108
if (missingSnapshots.length > 0) {
147-
throw new Error('e2e test with --ng-snapshots requires all angular packages be ' +
148-
'listed in tests/legacy-cli/e2e/ng-snapshot/package.json.\nErrors:\n' + missingSnapshots.join('\n '));
109+
throw new Error(
110+
'e2e test with --ng-snapshots requires all angular packages be ' +
111+
'listed in tests/legacy-cli/e2e/ng-snapshot/package.json.\nErrors:\n' +
112+
missingSnapshots.join('\n '),
113+
);
149114
}
150115
}
151116
try {
@@ -161,11 +126,11 @@ export function useSha() {
161126
}
162127

163128
export function useNgVersion(version: string) {
164-
return updateJsonFile('package.json', json => {
129+
return updateJsonFile('package.json', (json) => {
165130
// Install over the project with specific versions.
166131
Object.keys(json['dependencies'] || {})
167-
.filter(name => name.match(/^@angular\//))
168-
.forEach(name => {
132+
.filter((name) => name.match(/^@angular\//))
133+
.forEach((name) => {
169134
const pkgName = name.split(/\//)[1];
170135
if (pkgName == 'cli') {
171136
return;
@@ -174,8 +139,8 @@ export function useNgVersion(version: string) {
174139
});
175140

176141
Object.keys(json['devDependencies'] || {})
177-
.filter(name => name.match(/^@angular\//))
178-
.forEach(name => {
142+
.filter((name) => name.match(/^@angular\//))
143+
.forEach((name) => {
179144
const pkgName = name.split(/\//)[1];
180145
if (pkgName == 'cli') {
181146
return;
@@ -201,7 +166,7 @@ export function useNgVersion(version: string) {
201166
}
202167

203168
export function useCIDefaults(projectName = 'test-project') {
204-
return updateJsonFile('angular.json', workspaceJson => {
169+
return updateJsonFile('angular.json', (workspaceJson) => {
205170
// Disable progress reporting on CI to reduce spam.
206171
const project = workspaceJson.projects[projectName];
207172
const appTargets = project.targets || project.architect;

0 commit comments

Comments
 (0)