mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-20 21:42:38 +08:00
refactor(@angular/cli): cleanup config schematic defaults
This commit is contained in:
parent
8e169b8a10
commit
cbc824a20c
@ -146,8 +146,8 @@ export function getPackageManager(): string {
|
|||||||
|
|
||||||
if (workspace) {
|
if (workspace) {
|
||||||
const project = getProjectByCwd(workspace);
|
const project = getProjectByCwd(workspace);
|
||||||
if (project && workspace.getProject(project).cli) {
|
if (project && workspace.getProjectCli(project)) {
|
||||||
const value = workspace.getProject(project).cli['packageManager'];
|
const value = workspace.getProjectCli(project)['packageManager'];
|
||||||
if (typeof value == 'string') {
|
if (typeof value == 'string') {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -175,13 +175,13 @@ export function getDefaultSchematicCollection(): string {
|
|||||||
|
|
||||||
if (workspace) {
|
if (workspace) {
|
||||||
const project = getProjectByCwd(workspace);
|
const project = getProjectByCwd(workspace);
|
||||||
if (project && workspace.getProject(project).schematics) {
|
if (project && workspace.getProjectCli(project)) {
|
||||||
const value = workspace.getProject(project).schematics['defaultCollection'];
|
const value = workspace.getProjectCli(project)['defaultCollection'];
|
||||||
if (typeof value == 'string') {
|
if (typeof value == 'string') {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
} else if (workspace.getSchematics()) {
|
} else if (workspace.getCli()) {
|
||||||
const value = workspace.getSchematics()['defaultCollection'];
|
const value = workspace.getCli()['defaultCollection'];
|
||||||
if (typeof value == 'string') {
|
if (typeof value == 'string') {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -189,8 +189,8 @@ export function getDefaultSchematicCollection(): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
workspace = getWorkspace('global');
|
workspace = getWorkspace('global');
|
||||||
if (workspace && workspace.getSchematics()) {
|
if (workspace && workspace.getCli()) {
|
||||||
const value = workspace.getSchematics()['defaultCollection'];
|
const value = workspace.getCli()['defaultCollection'];
|
||||||
if (typeof value == 'string') {
|
if (typeof value == 'string') {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -199,13 +199,46 @@ export function getDefaultSchematicCollection(): string {
|
|||||||
return '@schematics/angular';
|
return '@schematics/angular';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getSchematicDefaults(collection: string, schematic: string, project?: string): {} {
|
||||||
|
let result = {};
|
||||||
|
|
||||||
|
let workspace = getWorkspace('global');
|
||||||
|
if (workspace && workspace.getSchematics()) {
|
||||||
|
const collectionObject = workspace.getSchematics()[collection];
|
||||||
|
if (typeof collectionObject == 'object' && !Array.isArray(collectionObject)) {
|
||||||
|
result = collectionObject[schematic] || {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
workspace = getWorkspace('local');
|
||||||
|
|
||||||
|
if (workspace) {
|
||||||
|
if (workspace.getSchematics()) {
|
||||||
|
const collectionObject = workspace.getSchematics()[collection];
|
||||||
|
if (typeof collectionObject == 'object' && !Array.isArray(collectionObject)) {
|
||||||
|
result = { ...result, ...(collectionObject[schematic] as {}) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project = project || getProjectByCwd(workspace);
|
||||||
|
if (project && workspace.getProjectSchematics(project)) {
|
||||||
|
const collectionObject = workspace.getProjectSchematics(project)[collection];
|
||||||
|
if (typeof collectionObject == 'object' && !Array.isArray(collectionObject)) {
|
||||||
|
result = { ...result, ...(collectionObject[schematic] as {}) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
export function isWarningEnabled(warning: string): boolean {
|
export function isWarningEnabled(warning: string): boolean {
|
||||||
let workspace = getWorkspace('local');
|
let workspace = getWorkspace('local');
|
||||||
|
|
||||||
if (workspace) {
|
if (workspace) {
|
||||||
const project = getProjectByCwd(workspace);
|
const project = getProjectByCwd(workspace);
|
||||||
if (project && workspace.getProject(project).cli) {
|
if (project && workspace.getProjectCli(project)) {
|
||||||
const warnings = workspace.getProject(project).cli['warnings'];
|
const warnings = workspace.getProjectCli(project)['warnings'];
|
||||||
if (typeof warnings == 'object' && !Array.isArray(warnings)) {
|
if (typeof warnings == 'object' && !Array.isArray(warnings)) {
|
||||||
const value = warnings[warning];
|
const value = warnings[warning];
|
||||||
if (typeof value == 'boolean') {
|
if (typeof value == 'boolean') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user