Skip to content

Commit f768929

Browse files
clydinalan-agius4
authored andcommitted
test(@angular/cli): locally publish LTS tooling packages for E2E update tests
The tooling packages needed to perform a canonical update process are now published to the local test package registry. This removes the need to switch back and forth between the npm registry and the test registry during E2E tests. It also ensures that CLI versions are used that are compatible with the Node.js version used for the tests.
1 parent d002bb7 commit f768929

File tree

2 files changed

+74
-20
lines changed

2 files changed

+74
-20
lines changed

tests/legacy-cli/e2e/setup/010-local-publish.ts

+63-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import { getGlobalVariable } from '../utils/env';
2-
import { npm } from '../utils/process';
2+
import { npm, silentNpm } from '../utils/process';
33
import { isPrereleaseCli } from '../utils/project';
44

5+
async function publishLocal(specifier: string, tags: string[], registry: string): Promise<void> {
6+
const { stdout: stdoutPack1 } = await silentNpm(
7+
'pack',
8+
specifier,
9+
'--registry=https://registry.npmjs.org',
10+
);
11+
for (const tag of tags) {
12+
await silentNpm('publish', stdoutPack1.trim(), `--registry=${registry}`, `--tag=${tag}`);
13+
}
14+
}
15+
516
export default async function () {
617
const testRegistry = getGlobalVariable('package-registry');
718
await npm(
@@ -15,4 +26,55 @@ export default async function () {
1526
'--tag',
1627
isPrereleaseCli() ? 'next' : 'latest',
1728
);
29+
30+
const basePackages = [
31+
'@angular/cli',
32+
'@angular-devkit/architect',
33+
'@angular-devkit/build-angular',
34+
'@angular-devkit/build-optimizer',
35+
'@angular-devkit/build-webpack',
36+
'@angular-devkit/core',
37+
'@angular-devkit/schematics',
38+
'@ngtools/webpack',
39+
'@schematics/angular',
40+
'@schematics/update',
41+
];
42+
43+
const ltsVersions = {
44+
'8': [...basePackages],
45+
'9': [...basePackages],
46+
'10': [...basePackages],
47+
};
48+
for (const [ltsVersion, ltsPackages] of Object.entries(ltsVersions)) {
49+
const tag = `v${ltsVersion}-lts`;
50+
51+
for (const packageName of ltsPackages) {
52+
await publishLocal(
53+
`${packageName}@${tag}`,
54+
[tag],
55+
testRegistry,
56+
);
57+
}
58+
}
59+
60+
const v8OriginalPackages = [
61+
'@angular/[email protected]',
62+
'@angular-devkit/[email protected]',
63+
'@angular-devkit/[email protected]',
64+
'@angular-devkit/[email protected]',
65+
'@angular-devkit/[email protected]',
66+
'@angular-devkit/[email protected]',
67+
'@angular-devkit/[email protected]',
68+
'@ngtools/[email protected]',
69+
'@schematics/[email protected]',
70+
'@schematics/[email protected]',
71+
];
72+
73+
for (const fullPackageSpecifier of v8OriginalPackages) {
74+
await publishLocal(
75+
fullPackageSpecifier,
76+
['v8-original'],
77+
testRegistry,
78+
);
79+
}
1880
}

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

+11-19
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,19 @@ import { ng, noSilentNg } from '../../utils/process';
55
import { isPrereleaseCli, useCIChrome, useCIDefaults } from '../../utils/project';
66

77
export default async function () {
8-
// We need to use the public registry because in the local NPM server we don't have
9-
// older versions @angular/cli packages which would cause `npm install` during `ng update` to fail.
10-
try {
11-
await createProjectFromAsset('8.0-project', true, true);
12-
13-
await setRegistry(false);
14-
await installWorkspacePackages();
15-
16-
// Update Angular to 9
17-
await installPackage('@angular/cli@8');
18-
const { stdout } = await ng('update', '@angular/[email protected]', '@angular/[email protected]');
19-
if (!stdout.includes("Executing migrations of package '@angular/cli'")) {
20-
throw new Error('Update did not execute migrations. OUTPUT: \n' + stdout);
21-
}
22-
23-
// Update Angular to 10
24-
await ng('update', '@angular/cli@10', '@angular/core@10');
25-
} finally {
26-
await setRegistry(true);
8+
await createProjectFromAsset('8.0-project', true, true);
9+
await installWorkspacePackages();
10+
11+
// Update Angular to 9
12+
await installPackage('@angular/cli@8');
13+
const { stdout } = await ng('update', '@angular/[email protected]', '@angular/[email protected]');
14+
if (!stdout.includes("Executing migrations of package '@angular/cli'")) {
15+
throw new Error('Update did not execute migrations. OUTPUT: \n' + stdout);
2716
}
2817

18+
// Update Angular to 10
19+
await ng('update', '@angular/cli@10', '@angular/core@10');
20+
2921
// Update Angular current build
3022
const extraUpdateArgs = isPrereleaseCli() ? ['--next', '--force'] : ['--force'];
3123
// For the latest/next release we purposely don't add `@angular/core`.

0 commit comments

Comments
 (0)