Skip to content

Commit 8a2b48c

Browse files
delastevehansl
authored andcommitted
fix(@angular/cli): update warning message when @angular/cli not found in devDependencies
fixes #5112
1 parent 0454f1e commit 8a2b48c

File tree

1 file changed

+17
-6
lines changed
  • packages/@angular/cli/bin

1 file changed

+17
-6
lines changed

packages/@angular/cli/bin/ng

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,33 @@ if (packageJsonProjectPath && fs.existsSync(packageJsonProjectPath)) {
9494
const deps = packageJsonProject['dependencies'] || {};
9595
const devDeps = packageJsonProject['devDependencies'] || {};
9696
const hasOldDep = !!deps['angular-cli'];
97+
const hasDep = !!deps['@angular/cli'];
9798
const hasOldDevDep = !!devDeps['angular-cli'];
9899
const hasDevDep = !!devDeps['@angular/cli'];
99100

100-
if (hasOldDep || hasOldDevDep || !hasDevDep) {
101+
if (hasOldDep || hasOldDevDep || !hasDevDep || !hasDep) {
101102
const warnings = [
102-
'The package "angular-cli" has been renamed to "@angular/cli". The old package will be '
103-
+ 'deprecated soon.',
104-
'',
105-
'Please take the following steps to avoid issues:'
103+
'Unable to find "@angular/cli" in devDependencies.',
104+
''
106105
];
106+
107+
if (hasOldDep || hasOldDevDep) {
108+
warnings.push(
109+
'The package "angular-cli" has been deprecated and renamed to "@angular/cli".',
110+
'');
111+
}
112+
113+
warnings.push('Please take the following steps to avoid issues:');
114+
107115
if (hasOldDep) {
108116
warnings.push('"npm uninstall --save angular-cli"');
109117
}
110118
if (hasOldDevDep) {
111119
warnings.push('"npm uninstall --save-dev angular-cli"');
112120
}
121+
if (hasDep) {
122+
warnings.push('"npm uninstall --save @angular/cli"')
123+
}
113124
if (!hasDevDep) {
114125
warnings.push('"npm install --save-dev @angular/cli@latest"');
115126
}
@@ -148,7 +159,7 @@ resolve('@angular/cli', { basedir: process.cwd() },
148159
console.log(yellow(stripIndents`
149160
Your global Angular CLI version (${globalVersion}) is greater than your local
150161
version (${localVersion}). The local Angular CLI version is used.
151-
162+
152163
To disable this warning use "ng set --global warnings.versionMismatch=false".
153164
`));
154165
}

0 commit comments

Comments
 (0)