-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ng-update): properly handle update from different working directory
In some situations, developers will run `ng update` from a sub directory of the project. This currently results in a noop migration as file system paths were computed incorrectly. This is because ng-update always assumed that the CWD is the workspace root in the real file system. This is not the case and therefore threw off path resolution. We fix this by fully relying on the virtual file system now. Previously we mixed virtual and real file system as TypeScript relied on the real file system for parsing configuration, matching and reading files. This commit adds a new compiler host for config parsing and program creation that works fully with a virtual file system. This is something we had planned a long time ago as schematics should never deal with the real file system. We can re-use this logic in other repositories too (such as Angular framework, potentially the CLI, and universal schematics). Ideally we will share this as part of better tooling for migrations. Fixes #19779.
- Loading branch information
1 parent
36d4c5d
commit de19045
Showing
25 changed files
with
267 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import {join} from '@angular-devkit/core'; | ||
import {Tree} from '@angular-devkit/schematics'; | ||
|
||
/** Regular expression that matches stylesheet paths */ | ||
const STYLESHEET_REGEX = /.*\.(css|scss)/; | ||
|
||
/** Finds stylesheets in the given directory from within the specified tree. */ | ||
export function findStylesheetFiles(tree: Tree, baseDir: string): string[] { | ||
const result: string[] = []; | ||
const visitDir = dirPath => { | ||
// Do not visit directories or files inside node modules or `dist/` folders. | ||
if (/^\/?(node_modules|dist)\//.test(dirPath)) { | ||
return; | ||
} | ||
const stat = tree.getDir(dirPath); | ||
stat.subdirs.forEach(fragment => visitDir(join(dirPath, fragment))); | ||
result.push(...stat.subfiles.filter(f => STYLESHEET_REGEX.test(f))); | ||
}; | ||
visitDir(baseDir); | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.