|
7 | 7 | */
|
8 | 8 | import {
|
9 | 9 | experimental,
|
| 10 | + json, |
10 | 11 | logging,
|
11 | 12 | normalize,
|
12 | 13 | schema,
|
@@ -42,6 +43,7 @@ import {
|
42 | 43 | getProjectByCwd,
|
43 | 44 | getSchematicDefaults,
|
44 | 45 | getWorkspace,
|
| 46 | + getWorkspaceRaw, |
45 | 47 | } from '../utilities/config';
|
46 | 48 | import { parseJsonSchemaToOptions } from '../utilities/json-schema';
|
47 | 49 | import { BaseCommandOptions, Command } from './command';
|
@@ -357,6 +359,43 @@ export abstract class SchematicCommand<
|
357 | 359 | collectionName = schematic.collection.description.name;
|
358 | 360 | schematicName = schematic.description.name;
|
359 | 361 |
|
| 362 | + // TODO: Remove warning check when 'targets' is default |
| 363 | + if (collectionName !== '@schematics/angular') { |
| 364 | + const [ast, configPath] = getWorkspaceRaw('local'); |
| 365 | + if (ast) { |
| 366 | + const projectsKeyValue = ast.properties.find(p => p.key.value === 'projects'); |
| 367 | + if (!projectsKeyValue || projectsKeyValue.value.kind !== 'object') { |
| 368 | + return; |
| 369 | + } |
| 370 | + |
| 371 | + const positions: json.Position[] = []; |
| 372 | + for (const projectKeyValue of projectsKeyValue.value.properties) { |
| 373 | + const projectNode = projectKeyValue.value; |
| 374 | + if (projectNode.kind !== 'object') { |
| 375 | + continue; |
| 376 | + } |
| 377 | + const targetsKeyValue = projectNode.properties.find(p => p.key.value === 'targets'); |
| 378 | + if (targetsKeyValue) { |
| 379 | + positions.push(targetsKeyValue.start); |
| 380 | + } |
| 381 | + } |
| 382 | + |
| 383 | + if (positions.length > 0) { |
| 384 | + const warning = tags.oneLine` |
| 385 | + WARNING: This command may not execute successfully. |
| 386 | + The package/collection may not support the 'targets' field within '${configPath}'. |
| 387 | + This can be corrected by renaming the following 'targets' fields to 'architect': |
| 388 | + `; |
| 389 | + |
| 390 | + const locations = positions |
| 391 | + .map((p, i) => `${i + 1}) Line: ${p.line + 1}; Column: ${p.character + 1}`) |
| 392 | + .join('\n'); |
| 393 | + |
| 394 | + this.logger.warn(warning + '\n' + locations + '\n'); |
| 395 | + } |
| 396 | + } |
| 397 | + } |
| 398 | + |
360 | 399 | // Set the options of format "path".
|
361 | 400 | let o: Option[] | null = null;
|
362 | 401 | let args: Arguments;
|
|
0 commit comments