Skip to content

Commit d9c1004

Browse files
devversionAndrewKushnir
authored andcommitted
refactor(migrations): ensure control flow analysis of signal input migration works with all TS versions (#57566)
Ensures that the control flow analysis version of the signal input works with all TS versions currently supported. PR Close #57566
1 parent bb29c8b commit d9c1004

File tree

8 files changed

+115
-0
lines changed

8 files changed

+115
-0
lines changed

WORKSPACE

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,3 +181,15 @@ http_archive(
181181
strip_prefix = "sc-4.8.2-osx",
182182
url = "https://saucelabs.com/downloads/sc-4.8.2-osx.zip",
183183
)
184+
185+
yarn_install(
186+
name = "npm_ts_versions",
187+
data = [
188+
YARN_LABEL,
189+
"//:.yarnrc",
190+
],
191+
exports_directories_only = False,
192+
package_json = "//packages/core/schematics/migrations/signal-migration/test/ts-versions:package.json",
193+
yarn = YARN_LABEL,
194+
yarn_lock = "//packages/core/schematics/migrations/signal-migration/test/ts-versions:yarn.lock",
195+
)

packages/core/schematics/migrations/signal-migration/test/BUILD.bazel

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
load("@npm//@angular/build-tooling/bazel/integration:index.bzl", "integration_test")
2+
load("//packages/core/schematics/migrations/signal-migration/test/ts-versions:index.bzl", "TS_VERSIONS")
23
load("//tools:defaults.bzl", "nodejs_binary", "ts_library")
34

45
ts_library(
@@ -49,6 +50,32 @@ integration_test(
4950
},
5051
)
5152

53+
[
54+
integration_test(
55+
name = "test_ts_%s" % version,
56+
srcs = [
57+
"golden.txt",
58+
"//packages/core/schematics/migrations/signal-migration/test/golden-test:test_files",
59+
"//packages/core/schematics/migrations/signal-migration/test/ts-versions:hooks.mjs",
60+
"//packages/core/schematics/migrations/signal-migration/test/ts-versions:loader.mjs",
61+
],
62+
commands = [
63+
"$(rootpath //packages/core/schematics/migrations/signal-migration/src:bin) --node_options=--import=./ts-versions/loader.js ./golden-test/tsconfig.json",
64+
"$(rootpath :golden_test_runner) ./golden-test ./golden.txt",
65+
],
66+
data = [
67+
":golden_test_runner",
68+
"//packages/core/schematics/migrations/signal-migration/src:bin",
69+
"@npm_ts_versions//%s" % version,
70+
],
71+
environment = {
72+
"FORCE_COLOR": "3",
73+
"TS_VERSION_PACKAGE": version,
74+
},
75+
)
76+
for version in TS_VERSIONS
77+
]
78+
5279
integration_test(
5380
name = "test_best_effort",
5481
srcs = [
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
exports_files([
2+
"package.json",
3+
"yarn.lock",
4+
"loader.mjs",
5+
"hooks.mjs",
6+
])
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {runfiles} from '@bazel/runfiles';
10+
11+
const PACKAGE_PATH =
12+
runfiles.resolve(`npm_ts_versions/node_modules/${process.env.TS_VERSION_PACKAGE}`);
13+
14+
/**
15+
* NodeJS hook that ensures TypeScript is imported from the configured
16+
* TS version package. This allows us to conveniently test against multiple
17+
* TS versions.
18+
*/
19+
export async function resolve(specifier, context, nextResolve) {
20+
if (specifier === 'typescript') {
21+
return nextResolve(`${PACKAGE_PATH}/lib/typescript.js`, context);
22+
}
23+
return nextResolve(specifier, context);
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""Exposes information about the tested TS versions."""
2+
3+
TS_VERSIONS = [
4+
"typescript-5.5.4",
5+
"typescript-5.5.3",
6+
"typescript-5.5.2",
7+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import {register} from 'node:module';
10+
11+
// Registers the TypeScript version loader.
12+
register('./hooks.mjs', import.meta.url);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "ts-versions",
3+
"license": "MIT",
4+
"dependencies": {
5+
"typescript-5.5.4": "npm:typescript@5.5.4",
6+
"typescript-5.5.3": "npm:typescript@5.5.3",
7+
"typescript-5.5.2": "npm:typescript@5.5.2"
8+
}
9+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
"typescript-5.5.2@npm:typescript@5.5.2":
6+
version "5.5.2"
7+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.2.tgz#c26f023cb0054e657ce04f72583ea2d85f8d0507"
8+
integrity sha512-NcRtPEOsPFFWjobJEtfihkLCZCXZt/os3zf8nTxjVH3RvTSxjrCamJpbExGvYOF+tFHc3pA65qpdwPbzjohhew==
9+
10+
"typescript-5.5.3@npm:typescript@5.5.3":
11+
version "5.5.3"
12+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.3.tgz#e1b0a3c394190838a0b168e771b0ad56a0af0faa"
13+
integrity sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==
14+
15+
"typescript-5.5.4@npm:typescript@5.5.4":
16+
version "5.5.4"
17+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
18+
integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==

0 commit comments

Comments
 (0)