-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(schematics): compatibility with Angular CLI 6.2.0 (#2131)
- Loading branch information
Showing
4 changed files
with
84 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* @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 { SchematicsException } from '@angular-devkit/schematics'; | ||
import { Workspace } from './devkit-utils/config'; | ||
import { getProjectTargetOptions } from './project-targets'; | ||
|
||
/** Looks for the main TypeScript file in the given project and returns its path. */ | ||
export function getProjectMainFile(project: Workspace): string { | ||
const buildOptions = getProjectTargetOptions(project, 'build'); | ||
|
||
if (!buildOptions.main) { | ||
throw new SchematicsException(`Could not find the project main file inside of the ` + | ||
`workspace config (${(project as any).sourceRoot})`); | ||
} | ||
|
||
return buildOptions.main; | ||
} |
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,31 @@ | ||
/** | ||
* @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 { Project } from './devkit-utils/config'; | ||
|
||
/** Resolves the architect options for the build target of the given project. */ | ||
export function getProjectTargetOptions(project: Project | any, buildTarget: string) { | ||
if (project.targets && | ||
project.targets[buildTarget] && | ||
project.targets[buildTarget].options) { | ||
|
||
return project.targets[buildTarget].options; | ||
} | ||
|
||
// TODO(devversion): consider removing this architect check if the CLI completely switched | ||
// over to `targets`, and the `architect` support has been removed. | ||
// See: https://github.com/angular/angular-cli/commit/307160806cb48c95ecb8982854f452303801ac9f | ||
if (project.architect && | ||
project.architect[buildTarget] && | ||
project.architect[buildTarget].options) { | ||
|
||
return project.architect[buildTarget].options; | ||
} | ||
|
||
throw new Error(`Cannot determine project target configuration for: ${buildTarget}.`); | ||
} |