( collection: string, schematic: string, project?: string | null, )
| 348 | } |
| 349 | |
| 350 | export async function getSchematicDefaults( |
| 351 | collection: string, |
| 352 | schematic: string, |
| 353 | project?: string | null, |
| 354 | ): Promise<{}> { |
| 355 | const result = {}; |
| 356 | const mergeOptions = (source: json.JsonValue | undefined): void => { |
| 357 | if (isJsonObject(source)) { |
| 358 | // Merge options from the qualified name |
| 359 | Object.assign(result, source[`${collection}:${schematic}`]); |
| 360 | |
| 361 | // Merge options from nested collection schematics |
| 362 | const collectionOptions = source[collection]; |
| 363 | if (isJsonObject(collectionOptions)) { |
| 364 | Object.assign(result, collectionOptions[schematic]); |
| 365 | } |
| 366 | } |
| 367 | }; |
| 368 | |
| 369 | // Global level schematic options |
| 370 | const globalOptions = await getWorkspace('global'); |
| 371 | mergeOptions(globalOptions?.extensions['schematics']); |
| 372 | |
| 373 | const workspace = await getWorkspace('local'); |
| 374 | if (workspace) { |
| 375 | // Workspace level schematic options |
| 376 | mergeOptions(workspace.extensions['schematics']); |
| 377 | |
| 378 | project = project || getProjectByCwd(workspace); |
| 379 | if (project) { |
| 380 | // Project level schematic options |
| 381 | mergeOptions(workspace.projects.get(project)?.extensions['schematics']); |
| 382 | } |
| 383 | } |
| 384 | |
| 385 | return result; |
| 386 | } |
| 387 | |
| 388 | export async function isWarningEnabled(warning: string): Promise<boolean> { |
| 389 | const getWarning = (source: json.JsonValue | undefined): boolean | undefined => { |
no test coverage detected