Skip to content

Commit a9338a7

Browse files
committed
refactor(@angular/cli): Make modernize use the file system
- Refactors the `modernize` tool to run all schematics on a temporary directory on the file system instead of using the `SchematicTestRunner` and a virtual file system. - This fixes issues with migrations that require access to the real file system, such as the `control-flow-migration`. - Extracts the core logic into a separate `runModernization` function to improve testability. - Adds a new test suite (`modernize_spec.ts`) to cover the refactored logic, including tests for default transformations, file system setup, and updated file content.
1 parent ffb754b commit a9338a7

5 files changed

Lines changed: 510 additions & 299 deletions

File tree

package.json

Lines changed: 175 additions & 172 deletions
Original file line numberDiff line numberDiff line change
@@ -1,178 +1,181 @@
11
{
2-
"name": "@angular/devkit-repo",
3-
"version": "20.2.0-next.2",
4-
"private": true,
5-
"description": "Software Development Kit for Angular",
6-
"keywords": [
7-
"angular",
8-
"Angular CLI",
9-
"devkit",
10-
"sdk",
11-
"Angular DevKit"
12-
],
13-
"scripts": {
14-
"admin": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only ./scripts/devkit-admin.mjs",
15-
"bazel": "bazelisk",
16-
"test": "bazel test //packages/...",
17-
"build": "pnpm -s admin build",
18-
"lint": "eslint --cache --max-warnings=0 \"**/*.@(ts|mts|cts)\"",
19-
"templates": "pnpm -s admin templates",
20-
"validate": "pnpm -s admin validate",
21-
"postinstall": "pnpm -s webdriver-update && husky",
22-
"//webdriver-update-README": "ChromeDriver version must match Puppeteer Chromium version, see https://github.com/GoogleChrome/puppeteer/releases http://chromedriver.chromium.org/downloads",
23-
"webdriver-update": "webdriver-manager update --standalone false --gecko false --versions.chrome 106.0.5249.21",
24-
"public-api:check": "node goldens/public-api/manage.js test",
25-
"ng-dev": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only node_modules/@angular/ng-dev/bundles/cli.mjs",
26-
"public-api:update": "node goldens/public-api/manage.js accept",
27-
"ts-circular-deps": "pnpm -s ng-dev ts-circular-deps --config ./scripts/circular-deps-test.conf.mjs",
28-
"check-tooling-setup": "tsc --project .ng-dev/tsconfig.json",
29-
"diff-release-package": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/diff-release-package.mts"
30-
},
31-
"repository": {
32-
"type": "git",
33-
"url": "https://github.com/angular/angular-cli.git"
34-
},
35-
"packageManager": "pnpm@9.15.9",
36-
"engines": {
37-
"node": "^20.19.0 || ^22.12.0 || >=24.0.0",
38-
"npm": "Please use pnpm instead of NPM to install dependencies",
39-
"yarn": "Please use pnpm instead of Yarn to install dependencies",
40-
"pnpm": "^9.15.6"
41-
},
42-
"author": "Angular Authors",
43-
"license": "MIT",
44-
"bugs": {
45-
"url": "https://github.com/angular/angular-cli/issues"
46-
},
47-
"homepage": "https://github.com/angular/angular-cli",
48-
"devDependencies": {
49-
"@angular/animations": "20.2.0-next.3",
50-
"@angular/cdk": "20.2.0-next.2",
51-
"@angular/common": "20.2.0-next.3",
52-
"@angular/compiler": "20.2.0-next.3",
53-
"@angular/compiler-cli": "20.2.0-next.3",
54-
"@angular/core": "20.2.0-next.3",
55-
"@angular/forms": "20.2.0-next.3",
56-
"@angular/localize": "20.2.0-next.3",
57-
"@angular/material": "20.2.0-next.2",
58-
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#9aea3ff6c63a7a692d33e91956641887e8c6b838",
59-
"@angular/platform-browser": "20.2.0-next.3",
60-
"@angular/platform-server": "20.2.0-next.3",
61-
"@angular/router": "20.2.0-next.3",
62-
"@angular/service-worker": "20.2.0-next.3",
63-
"@bazel/bazelisk": "1.26.0",
64-
"@bazel/buildifier": "8.2.1",
65-
"@eslint/compat": "1.3.1",
66-
"@eslint/eslintrc": "3.3.1",
67-
"@eslint/js": "9.32.0",
68-
"@rollup/plugin-alias": "^5.1.1",
69-
"@rollup/plugin-commonjs": "^28.0.0",
70-
"@rollup/plugin-json": "^6.1.0",
71-
"@rollup/plugin-node-resolve": "16.0.1",
72-
"@stylistic/eslint-plugin": "^5.0.0",
73-
"@types/babel__core": "7.20.5",
74-
"@types/babel__generator": "^7.6.8",
75-
"@types/browser-sync": "^2.27.0",
76-
"@types/express": "~5.0.1",
77-
"@types/http-proxy": "^1.17.4",
78-
"@types/ini": "^4.0.0",
79-
"@types/jasmine": "~5.1.0",
80-
"@types/jasmine-reporters": "^2",
81-
"@types/karma": "^6.3.0",
82-
"@types/less": "^3.0.3",
83-
"@types/loader-utils": "^2.0.0",
84-
"@types/lodash": "^4.17.0",
85-
"@types/node": "^22.12.0",
86-
"@types/npm-package-arg": "^6.1.0",
87-
"@types/pacote": "^11.1.3",
88-
"@types/picomatch": "^4.0.0",
89-
"@types/progress": "^2.0.3",
90-
"@types/resolve": "^1.17.1",
91-
"@types/semver": "^7.3.12",
92-
"@types/shelljs": "^0.8.11",
93-
"@types/watchpack": "^2.4.4",
94-
"@types/yargs": "^17.0.20",
95-
"@types/yargs-parser": "^21.0.0",
96-
"@types/yarnpkg__lockfile": "^1.1.5",
97-
"@typescript-eslint/eslint-plugin": "8.38.0",
98-
"@typescript-eslint/parser": "8.38.0",
99-
"ajv": "8.17.1",
100-
"ansi-colors": "4.1.3",
101-
"beasties": "0.3.5",
102-
"buffer": "6.0.3",
103-
"esbuild": "0.25.8",
104-
"esbuild-wasm": "0.25.8",
105-
"eslint": "9.32.0",
106-
"eslint-config-prettier": "10.1.8",
107-
"eslint-plugin-header": "3.1.1",
108-
"eslint-plugin-import": "2.32.0",
109-
"express": "5.1.0",
110-
"fast-glob": "3.3.3",
111-
"globals": "16.3.0",
112-
"http-proxy": "^1.18.1",
113-
"http-proxy-middleware": "3.0.5",
114-
"husky": "9.1.7",
115-
"jasmine": "~5.9.0",
116-
"jasmine-core": "~5.9.0",
117-
"jasmine-reporters": "^2.5.2",
118-
"jasmine-spec-reporter": "~7.0.0",
119-
"karma": "~6.4.0",
120-
"karma-chrome-launcher": "~3.2.0",
121-
"karma-coverage": "~2.2.0",
122-
"karma-jasmine": "~5.1.0",
123-
"karma-jasmine-html-reporter": "~2.1.0",
124-
"karma-source-map-support": "1.4.0",
125-
"listr2": "9.0.1",
126-
"lodash": "^4.17.21",
127-
"npm": "^11.0.0",
128-
"magic-string": "0.30.17",
129-
"rollup-plugin-dts": "6.2.1",
130-
"rollup-plugin-sourcemaps2": "0.5.3",
131-
"prettier": "^3.0.0",
132-
"protractor": "~7.0.0",
133-
"puppeteer": "18.2.1",
134-
"quicktype-core": "23.2.6",
135-
"rollup": "4.46.2",
136-
"rollup-license-plugin": "~3.0.1",
137-
"semver": "7.7.2",
138-
"shelljs": "^0.10.0",
139-
"source-map-support": "0.5.21",
140-
"tar": "^7.0.0",
141-
"ts-node": "^10.9.1",
142-
"tslib": "2.8.1",
143-
"typescript": "5.9.2",
144-
"undici": "7.13.0",
145-
"unenv": "^1.10.0",
146-
"verdaccio": "6.1.6",
147-
"verdaccio-auth-memory": "^10.0.0",
148-
"yargs-parser": "22.0.0",
149-
"zone.js": "^0.15.0"
150-
},
151-
"dependenciesMeta": {
152-
"esbuild": {
153-
"built": true
154-
},
155-
"puppeteer": {
156-
"built": true
157-
}
158-
},
159-
"pnpm": {
160-
"onlyBuiltDependencies": [
161-
"puppeteer",
162-
"webdriver-manager"
2+
"name": "@angular/devkit-repo",
3+
"version": "20.2.0-next.2",
4+
"private": true,
5+
"description": "Software Development Kit for Angular",
6+
"keywords": [
7+
"angular",
8+
"Angular CLI",
9+
"devkit",
10+
"sdk",
11+
"Angular DevKit"
16312
],
164-
"overrides": {
165-
"@angular/build": "workspace:*"
13+
"scripts": {
14+
"admin": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only ./scripts/devkit-admin.mjs",
15+
"bazel": "bazelisk",
16+
"test": "bazel test //packages/",
17+
"build": "pnpm -s admin build",
18+
"lint": "eslint --cache --max-warnings=0 \"**/*.@(ts|mts|cts)\"",
19+
"templates": "pnpm -s admin templates",
20+
"validate": "pnpm -s admin validate",
21+
"postinstall": "pnpm -s webdriver-update && husky",
22+
"//webdriver-update-README": "ChromeDriver version must match Puppeteer Chromium version, see https://github.com/GoogleChrome/puppeteer/releases http://chromedriver.chromium.org/downloads",
23+
"webdriver-update": "webdriver-manager update --standalone false --gecko false --versions.chrome 106.0.5249.21",
24+
"public-api:check": "node goldens/public-api/manage.js test",
25+
"ng-dev": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only node_modules/@angular/ng-dev/bundles/cli.mjs",
26+
"public-api:update": "node goldens/public-api/manage.js accept",
27+
"ts-circular-deps": "pnpm -s ng-dev ts-circular-deps --config ./scripts/circular-deps-test.conf.mjs",
28+
"check-tooling-setup": "tsc --project .ng-dev/tsconfig.json",
29+
"diff-release-package": "node --no-warnings=ExperimentalWarning --loader ts-node/esm/transpile-only scripts/diff-release-package.mts"
30+
},
31+
"repository": {
32+
"type": "git",
33+
"url": "https://github.com/angular/angular-cli.git"
34+
},
35+
"packageManager": "pnpm@9.15.9",
36+
"engines": {
37+
"node": "^20.19.0 || ^22.12.0 || >=24.0.0",
38+
"npm": "Please use pnpm instead of NPM to install dependencies",
39+
"yarn": "Please use pnpm instead of Yarn to install dependencies",
40+
"pnpm": "^9.15.6"
41+
},
42+
"author": "Angular Authors",
43+
"license": "MIT",
44+
"bugs": {
45+
"url": "https://github.com/angular/angular-cli/issues"
16646
},
167-
"packageExtensions": {
168-
"grpc-gcp": {
169-
"peerDependencies": {
170-
"protobufjs": "*"
47+
"homepage": "https://github.com/angular/angular-cli",
48+
"devDependencies": {
49+
"@angular/animations": "20.2.0-next.3",
50+
"@angular/cdk": "20.2.0-next.2",
51+
"@angular/common": "20.2.0-next.3",
52+
"@angular/compiler": "20.2.0-next.3",
53+
"@angular/compiler-cli": "20.2.0-next.3",
54+
"@angular/core": "20.2.0-next.3",
55+
"@angular/forms": "20.2.0-next.3",
56+
"@angular/localize": "20.2.0-next.3",
57+
"@angular/material": "20.2.0-next.2",
58+
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#9aea3ff6c63a7a692d33e91956641887e8c6b838",
59+
"@angular/platform-browser": "20.2.0-next.3",
60+
"@angular/platform-server": "20.2.0-next.3",
61+
"@angular/router": "20.2.0-next.3",
62+
"@angular/service-worker": "20.2.0-next.3",
63+
"@bazel/bazelisk": "1.26.0",
64+
"@bazel/buildifier": "8.2.1",
65+
"@eslint/compat": "1.3.1",
66+
"@eslint/eslintrc": "3.3.1",
67+
"@eslint/js": "9.32.0",
68+
"@rollup/plugin-alias": "^5.1.1",
69+
"@rollup/plugin-commonjs": "^28.0.0",
70+
"@rollup/plugin-json": "^6.1.0",
71+
"@rollup/plugin-node-resolve": "16.0.1",
72+
"@stylistic/eslint-plugin": "^5.0.0",
73+
"@types/babel__core": "7.20.5",
74+
"@types/babel__generator": "^7.6.8",
75+
"@types/browser-sync": "^2.27.0",
76+
"@types/express": "~5.0.1",
77+
"@types/http-proxy": "^1.17.4",
78+
"@types/ini": "^4.0.0",
79+
"@types/jasmine": "~5.1.0",
80+
"@types/jasmine-reporters": "^2",
81+
"@types/karma": "^6.3.0",
82+
"@types/less": "^3.0.3",
83+
"@types/loader-utils": "^2.0.0",
84+
"@types/lodash": "^4.17.0",
85+
"@types/node": "^22.12.0",
86+
"@types/npm-package-arg": "^6.1.0",
87+
"@types/pacote": "^11.1.3",
88+
"@types/picomatch": "^4.0.0",
89+
"@types/progress": "^2.0.3",
90+
"@types/resolve": "^1.17.1",
91+
"@types/semver": "^7.3.12",
92+
"@types/shelljs": "^0.8.11",
93+
"@types/watchpack": "^2.4.4",
94+
"@types/yargs": "^17.0.20",
95+
"@types/yargs-parser": "^21.0.0",
96+
"@types/yarnpkg__lockfile": "^1.1.5",
97+
"@typescript-eslint/eslint-plugin": "8.38.0",
98+
"@typescript-eslint/parser": "8.38.0",
99+
"ajv": "8.17.1",
100+
"ansi-colors": "4.1.3",
101+
"beasties": "0.3.5",
102+
"buffer": "6.0.3",
103+
"esbuild": "0.25.8",
104+
"esbuild-wasm": "0.25.8",
105+
"eslint": "9.32.0",
106+
"eslint-config-prettier": "10.1.8",
107+
"eslint-plugin-header": "3.1.1",
108+
"eslint-plugin-import": "2.32.0",
109+
"express": "5.1.0",
110+
"fast-glob": "3.3.3",
111+
"globals": "16.3.0",
112+
"http-proxy": "^1.18.1",
113+
"http-proxy-middleware": "3.0.5",
114+
"husky": "9.1.7",
115+
"jasmine": "~5.9.0",
116+
"jasmine-core": "~5.9.0",
117+
"jasmine-reporters": "^2.5.2",
118+
"jasmine-spec-reporter": "~7.0.0",
119+
"karma": "~6.4.0",
120+
"karma-chrome-launcher": "~3.2.0",
121+
"karma-coverage": "~2.2.0",
122+
"karma-jasmine": "~5.1.0",
123+
"karma-jasmine-html-reporter": "~2.1.0",
124+
"karma-source-map-support": "1.4.0",
125+
"listr2": "9.0.1",
126+
"lodash": "^4.17.21",
127+
"magic-string": "0.30.17",
128+
"npm": "^11.0.0",
129+
"prettier": "^3.0.0",
130+
"protractor": "~7.0.0",
131+
"puppeteer": "18.2.1",
132+
"quicktype-core": "23.2.6",
133+
"rollup": "4.46.2",
134+
"rollup-license-plugin": "~3.0.1",
135+
"rollup-plugin-dts": "6.2.1",
136+
"rollup-plugin-sourcemaps2": "0.5.3",
137+
"semver": "7.7.2",
138+
"shelljs": "^0.10.0",
139+
"source-map-support": "0.5.21",
140+
"tar": "^7.0.0",
141+
"ts-node": "^10.9.1",
142+
"tslib": "2.8.1",
143+
"typescript": "5.9.2",
144+
"undici": "7.13.0",
145+
"unenv": "^1.10.0",
146+
"verdaccio": "6.1.6",
147+
"verdaccio-auth-memory": "^10.0.0",
148+
"yargs-parser": "22.0.0",
149+
"zone.js": "^0.15.0"
150+
},
151+
"dependenciesMeta": {
152+
"esbuild": {
153+
"built": true
154+
},
155+
"puppeteer": {
156+
"built": true
157+
}
158+
},
159+
"pnpm": {
160+
"onlyBuiltDependencies": [
161+
"puppeteer",
162+
"webdriver-manager"
163+
],
164+
"overrides": {
165+
"@angular/build": "workspace:*"
166+
},
167+
"packageExtensions": {
168+
"grpc-gcp": {
169+
"peerDependencies": {
170+
"protobufjs": "*"
171+
}
171172
}
172173
}
174+
},
175+
"resolutions": {
176+
"typescript": "5.9.2"
177+
},
178+
"dependencies": {
179+
"rxjs": "7.8.2"
173180
}
174-
},
175-
"resolutions": {
176-
"typescript": "5.9.2"
177-
}
178-
}
181+
}

packages/angular/cli/BUILD.bazel

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,12 @@ ts_project(
125125
":node_modules/@angular-devkit/core",
126126
":node_modules/@angular-devkit/schematics",
127127
":node_modules/yargs",
128+
"//:node_modules/@types/jasmine",
128129
"//:node_modules/@types/semver",
129130
"//:node_modules/@types/yargs",
131+
"//:node_modules/rxjs",
130132
"//:node_modules/semver",
133+
"//packages/angular_devkit/schematics/testing",
131134
],
132135
)
133136

0 commit comments

Comments
 (0)