|
9 | 9 | import { tags, terminal } from '@angular-devkit/core'; |
10 | 10 | import { resolve } from '@angular-devkit/core/node'; |
11 | 11 | import * as path from 'path'; |
12 | | -import { SemVer, satisfies } from 'semver'; |
13 | | -import { isWarningEnabled } from '../utilities/config'; |
| 12 | +import { SemVer } from 'semver'; |
14 | 13 |
|
15 | 14 |
|
16 | 15 | export class Version { |
@@ -110,67 +109,4 @@ export class Version { |
110 | 109 | } |
111 | 110 | } |
112 | 111 |
|
113 | | - static assertTypescriptVersion(projectRoot: string) { |
114 | | - if (!isWarningEnabled('typescriptMismatch')) { |
115 | | - return; |
116 | | - } |
117 | | - |
118 | | - let compilerVersion: string; |
119 | | - let tsVersion: string; |
120 | | - let compilerTypeScriptPeerVersion: string; |
121 | | - try { |
122 | | - const resolveOptions = { |
123 | | - basedir: projectRoot, |
124 | | - checkGlobal: false, |
125 | | - checkLocal: true, |
126 | | - }; |
127 | | - const compilerPackagePath = resolve('@angular/compiler-cli/package.json', resolveOptions); |
128 | | - const typescriptProjectPath = resolve('typescript', resolveOptions); |
129 | | - const compilerPackageInfo = require(compilerPackagePath); |
130 | | - |
131 | | - compilerVersion = compilerPackageInfo['version']; |
132 | | - compilerTypeScriptPeerVersion = compilerPackageInfo['peerDependencies']['typescript']; |
133 | | - tsVersion = require(typescriptProjectPath).version; |
134 | | - } catch { |
135 | | - console.error(terminal.bold(terminal.red(tags.stripIndents` |
136 | | - Versions of @angular/compiler-cli and typescript could not be determined. |
137 | | - The most common reason for this is a broken npm install. |
138 | | -
|
139 | | - Please make sure your package.json contains both @angular/compiler-cli and typescript in |
140 | | - devDependencies, then delete node_modules and package-lock.json (if you have one) and |
141 | | - run npm install again. |
142 | | - `))); |
143 | | - process.exit(2); |
144 | | - |
145 | | - return; |
146 | | - } |
147 | | - |
148 | | - // These versions do not have accurate typescript peer dependencies |
149 | | - const versionCombos = [ |
150 | | - { compiler: '>=2.3.1 <3.0.0', typescript: '>=2.0.2 <2.3.0' }, |
151 | | - { compiler: '>=4.0.0-beta.0 <5.0.0', typescript: '>=2.1.0 <2.4.0' }, |
152 | | - { compiler: '5.0.0-beta.0 - 5.0.0-rc.2', typescript: '>=2.4.2 <2.5.0' }, |
153 | | - ]; |
154 | | - |
155 | | - let currentCombo = versionCombos.find((combo) => satisfies(compilerVersion, combo.compiler)); |
156 | | - if (!currentCombo && compilerTypeScriptPeerVersion) { |
157 | | - currentCombo = { compiler: compilerVersion, typescript: compilerTypeScriptPeerVersion }; |
158 | | - } |
159 | | - |
160 | | - if (currentCombo && !satisfies(tsVersion, currentCombo.typescript)) { |
161 | | - // First line of warning looks weird being split in two, disable tslint for it. |
162 | | - console.error((terminal.yellow('\n' + tags.stripIndent` |
163 | | - @angular/compiler-cli@${compilerVersion} requires typescript@'${ |
164 | | - currentCombo.typescript}' but ${tsVersion} was found instead. |
165 | | - Using this version can result in undefined behaviour and difficult to debug problems. |
166 | | -
|
167 | | - Please run the following command to install a compatible version of TypeScript. |
168 | | -
|
169 | | - npm install typescript@"${currentCombo.typescript}" |
170 | | -
|
171 | | - To disable this warning run "ng config cli.warnings.typescriptMismatch false". |
172 | | - ` + '\n'))); |
173 | | - } |
174 | | - } |
175 | | - |
176 | 112 | } |
0 commit comments