Skip to content

Commit 10517bc

Browse files
filipesilvahansl
authored andcommitted
fix(@angular/cli): error out in un-updated projects
1 parent ecdc52c commit 10517bc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/@angular/cli/models/workspace-loader.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { Observable, of } from 'rxjs';
1111
import { concatMap, tap } from 'rxjs/operators';
1212
import * as fs from 'fs';
1313
import { homedir } from 'os';
14+
import { stripIndent } from 'common-tags';
1415
import { findUp } from '../utilities/find-up';
1516

1617

@@ -38,6 +39,7 @@ export class WorkspaceLoader {
3839

3940
// TODO: do this with the host instead of fs.
4041
private _getProjectWorkspaceFilePath(projectPath?: string): Observable<Path | null> {
42+
this._assertUpdatedWorkspace(projectPath);
4143
// Find the workspace file, either where specified, in the Angular CLI project
4244
// (if it's in node_modules) or from the current process.
4345
const workspaceFilePath = (projectPath && findUp(this._configFileNames, projectPath))
@@ -81,4 +83,26 @@ export class WorkspaceLoader {
8183
tap(workspace => this._workspaceCacheMap.set(workspacePath, workspace))
8284
);
8385
}
86+
87+
private _assertUpdatedWorkspace(projectPath?: string) {
88+
const oldConfigFileNames = [
89+
normalize('.angular-cli.json'),
90+
normalize('angular-cli.json'),
91+
];
92+
93+
const oldConfigFilePath = (projectPath && findUp(oldConfigFileNames, projectPath))
94+
|| findUp(oldConfigFileNames, process.cwd())
95+
|| findUp(oldConfigFileNames, __dirname);
96+
97+
if (oldConfigFilePath) {
98+
throw new Error(stripIndent`
99+
An old project has been detected, which needs to be updated to Angular CLI 6.
100+
101+
Please run the following commands to update this project.
102+
103+
ng update @angular/cli --migrate-only --from=1.7.1
104+
npm i
105+
`);
106+
}
107+
}
84108
}

0 commit comments

Comments
 (0)