@angular/core 19.2.5 → 19.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/{event_dispatcher.d-PWnbqZDx.d.ts → event_dispatcher.d-DlbccpYq.d.ts} +3 -3
  2. package/fesm2022/core.mjs +9 -6
  3. package/fesm2022/core.mjs.map +1 -1
  4. package/fesm2022/primitives/di.mjs +1 -1
  5. package/fesm2022/primitives/event-dispatch.mjs +1 -1
  6. package/fesm2022/primitives/signals.mjs +3 -3
  7. package/fesm2022/rxjs-interop.mjs +2 -2
  8. package/fesm2022/rxjs-interop.mjs.map +1 -1
  9. package/fesm2022/testing.mjs +148 -97
  10. package/fesm2022/testing.mjs.map +1 -1
  11. package/fesm2022/{untracked-CS7WUAzb.mjs → untracked-BKcld_ew.mjs} +3 -3
  12. package/fesm2022/{untracked-CS7WUAzb.mjs.map → untracked-BKcld_ew.mjs.map} +1 -1
  13. package/index.d.ts +6 -5
  14. package/{navigation_types.d-Lh6SmhKv.d.ts → navigation_types.d-fAxd92YV.d.ts} +3 -3
  15. package/package.json +1 -1
  16. package/primitives/di/index.d.ts +1 -1
  17. package/primitives/event-dispatch/index.d.ts +3 -3
  18. package/primitives/signals/index.d.ts +3 -3
  19. package/rxjs-interop/index.d.ts +2 -2
  20. package/schematics/bundles/{apply_import_manager-CTrezOPF.js → apply_import_manager-DFADpdFu.js} +3 -3
  21. package/schematics/bundles/{checker-CQvNmpT3.js → checker-DoX_7XCa.js} +7 -8
  22. package/schematics/bundles/cleanup-unused-imports.js +42 -64
  23. package/schematics/bundles/{compiler_host-IULKT7OF.js → compiler_host-BUKEE1cA.js} +2 -2
  24. package/schematics/bundles/control-flow-migration.js +3 -3
  25. package/schematics/bundles/explicit-standalone-flag.js +3 -3
  26. package/schematics/bundles/imports-CIX-JgAN.js +1 -1
  27. package/schematics/bundles/{program-XYcLSXb1.js → index-B4b0V0Vo.js} +36 -12
  28. package/schematics/bundles/{index-BKWl7N44.js → index-CpZKzrqM.js} +6 -6
  29. package/schematics/bundles/inject-migration.js +3 -3
  30. package/schematics/bundles/leading_space-D9nQ8UQC.js +1 -1
  31. package/schematics/bundles/{migrate_ts_type_references-CHRyhQvi.js → migrate_ts_type_references-DQVDid4G.js} +5 -5
  32. package/schematics/bundles/ng_decorators-DznZ5jMl.js +1 -1
  33. package/schematics/bundles/nodes-B16H9JUd.js +1 -1
  34. package/schematics/bundles/output-migration.js +108 -78
  35. package/schematics/bundles/pending-tasks.js +3 -3
  36. package/schematics/bundles/{project_paths-CTgTxqrW.js → project_paths-C3etOlgT.js} +88 -13
  37. package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.js +1 -1
  38. package/schematics/bundles/property_name-BBwFuqMe.js +1 -1
  39. package/schematics/bundles/provide-initializer.js +3 -3
  40. package/schematics/bundles/route-lazy-loading.js +3 -3
  41. package/schematics/bundles/self-closing-tags-migration.js +39 -64
  42. package/schematics/bundles/signal-input-migration.js +64 -87
  43. package/schematics/bundles/signal-queries-migration.js +69 -92
  44. package/schematics/bundles/signals.js +11 -11
  45. package/schematics/bundles/standalone-migration.js +5 -6
  46. package/testing/index.d.ts +5 -21
  47. package/{weak_ref.d-DOjz-6fK.d.ts → weak_ref.d-DWHPG08n.d.ts} +3 -3
  48. package/schematics/bundles/index-CH_G_p3D.js +0 -30
@@ -1,18 +1,20 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.2.5
3
+ * @license Angular v19.2.6
4
4
  * (c) 2010-2025 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
7
7
  'use strict';
8
8
 
9
+ var index = require('./index-B4b0V0Vo.js');
10
+ var schematics = require('@angular-devkit/schematics');
9
11
  var core = require('@angular-devkit/core');
10
12
  var posixPath = require('node:path/posix');
11
13
  var os = require('os');
12
14
  var ts = require('typescript');
13
- var checker = require('./checker-CQvNmpT3.js');
14
- var program = require('./program-XYcLSXb1.js');
15
+ var checker = require('./checker-DoX_7XCa.js');
15
16
  require('path');
17
+ var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.js');
16
18
 
17
19
  function _interopNamespaceDefault(e) {
18
20
  var n = Object.create(null);
@@ -187,7 +189,7 @@ function readConfiguration(project, existingOptions, host = checker.getFileSyste
187
189
  errors: [error],
188
190
  rootNames: [],
189
191
  options: {},
190
- emitFlags: program.EmitFlags.Default,
192
+ emitFlags: index.EmitFlags.Default,
191
193
  };
192
194
  }
193
195
  const existingCompilerOptions = {
@@ -198,12 +200,12 @@ function readConfiguration(project, existingOptions, host = checker.getFileSyste
198
200
  };
199
201
  const parseConfigHost = createParseConfigHost(host, fs);
200
202
  const { options, errors, fileNames: rootNames, projectReferences, } = ts.parseJsonConfigFileContent(config, parseConfigHost, basePath, existingCompilerOptions, configFileName);
201
- let emitFlags = program.EmitFlags.Default;
203
+ let emitFlags = index.EmitFlags.Default;
202
204
  if (!(options['skipMetadataEmit'] || options['flatModuleOutFile'])) {
203
- emitFlags |= program.EmitFlags.Metadata;
205
+ emitFlags |= index.EmitFlags.Metadata;
204
206
  }
205
207
  if (options['skipTemplateCodegen']) {
206
- emitFlags = emitFlags & ~program.EmitFlags.Codegen;
208
+ emitFlags = emitFlags & ~index.EmitFlags.Codegen;
207
209
  }
208
210
  return { project: projectFile, rootNames, projectReferences, options, errors, emitFlags };
209
211
  }
@@ -216,10 +218,10 @@ function readConfiguration(project, existingOptions, host = checker.getFileSyste
216
218
  start: undefined,
217
219
  length: undefined,
218
220
  source: 'angular',
219
- code: program.UNKNOWN_ERROR_CODE,
221
+ code: index.UNKNOWN_ERROR_CODE,
220
222
  },
221
223
  ];
222
- return { project: '', errors, rootNames: [], options: {}, emitFlags: program.EmitFlags.Default };
224
+ return { project: '', errors, rootNames: [], options: {}, emitFlags: index.EmitFlags.Default };
223
225
  }
224
226
  }
225
227
  function createParseConfigHost(host, fs = checker.getFileSystem()) {
@@ -488,7 +490,7 @@ function createPlainTsProgram(tsHost, tsconfig, optionOverrides) {
488
490
  * an instance of the Angular compiler for the project.
489
491
  */
490
492
  function createNgtscProgram(tsHost, tsconfig, optionOverrides) {
491
- const ngtscProgram = new program.NgtscProgram(tsconfig.rootNames, {
493
+ const ngtscProgram = new index.NgtscProgram(tsconfig.rootNames, {
492
494
  ...tsconfig.options,
493
495
  ...defaultMigrationTsOptions,
494
496
  ...optionOverrides,
@@ -607,6 +609,81 @@ class TsurgeFunnelMigration extends TsurgeBaseMigration {
607
609
  class TsurgeComplexMigration extends TsurgeBaseMigration {
608
610
  }
609
611
 
612
+ /*!
613
+ * @license
614
+ * Copyright Google LLC All Rights Reserved.
615
+ *
616
+ * Use of this source code is governed by an MIT-style license that can be
617
+ * found in the LICENSE file at https://angular.dev/license
618
+ */
619
+ exports.MigrationStage = void 0;
620
+ (function (MigrationStage) {
621
+ /** The migration is analyzing an entrypoint */
622
+ MigrationStage[MigrationStage["Analysis"] = 0] = "Analysis";
623
+ /** The migration is about to migrate an entrypoint */
624
+ MigrationStage[MigrationStage["Migrate"] = 1] = "Migrate";
625
+ })(exports.MigrationStage || (exports.MigrationStage = {}));
626
+ /** Runs a Tsurge within an Angular Devkit context. */
627
+ async function runMigrationInDevkit(config) {
628
+ const { buildPaths, testPaths } = await project_tsconfig_paths.getProjectTsConfigPaths(config.tree);
629
+ if (!buildPaths.length && !testPaths.length) {
630
+ throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run the migration.');
631
+ }
632
+ const tsconfigPaths = [...buildPaths, ...testPaths];
633
+ const fs = new DevkitMigrationFilesystem(config.tree);
634
+ checker.setFileSystem(fs);
635
+ const migration = config.getMigration(fs);
636
+ const unitResults = [];
637
+ const isFunnelMigration = migration instanceof TsurgeFunnelMigration;
638
+ for (const tsconfigPath of tsconfigPaths) {
639
+ config.beforeProgramCreation?.(tsconfigPath, exports.MigrationStage.Analysis);
640
+ const baseInfo = migration.createProgram(tsconfigPath, fs);
641
+ const info = migration.prepareProgram(baseInfo);
642
+ config.afterProgramCreation?.(info, fs, exports.MigrationStage.Analysis);
643
+ config.beforeUnitAnalysis?.(tsconfigPath);
644
+ unitResults.push(await migration.analyze(info));
645
+ }
646
+ config.afterAllAnalyzed?.();
647
+ const combined = await synchronouslyCombineUnitData(migration, unitResults);
648
+ if (combined === null) {
649
+ config.afterAnalysisFailure?.();
650
+ return;
651
+ }
652
+ const globalMeta = await migration.globalMeta(combined);
653
+ let replacements;
654
+ if (isFunnelMigration) {
655
+ replacements = (await migration.migrate(globalMeta)).replacements;
656
+ }
657
+ else {
658
+ replacements = [];
659
+ for (const tsconfigPath of tsconfigPaths) {
660
+ config.beforeProgramCreation?.(tsconfigPath, exports.MigrationStage.Migrate);
661
+ const baseInfo = migration.createProgram(tsconfigPath, fs);
662
+ const info = migration.prepareProgram(baseInfo);
663
+ config.afterProgramCreation?.(info, fs, exports.MigrationStage.Migrate);
664
+ const result = await migration.migrate(globalMeta, info);
665
+ replacements.push(...result.replacements);
666
+ }
667
+ }
668
+ const replacementsPerFile = new Map();
669
+ const changesPerFile = groupReplacementsByFile(replacements);
670
+ for (const [file, changes] of changesPerFile) {
671
+ if (!replacementsPerFile.has(file)) {
672
+ replacementsPerFile.set(file, changes);
673
+ }
674
+ }
675
+ for (const [file, changes] of replacementsPerFile) {
676
+ const recorder = config.tree.beginUpdate(file);
677
+ for (const c of changes) {
678
+ recorder
679
+ .remove(c.data.position, c.data.end - c.data.position)
680
+ .insertRight(c.data.position, c.data.toInsert);
681
+ }
682
+ config.tree.commitUpdate(recorder);
683
+ }
684
+ config.whenDone?.(await migration.stats(globalMeta));
685
+ }
686
+
610
687
  /** A text replacement for the given file. */
611
688
  class Replacement {
612
689
  projectFile;
@@ -668,13 +745,11 @@ function isWithinBasePath(fs, base, path) {
668
745
  return checker.isLocalRelativePath(fs.relative(base, path));
669
746
  }
670
747
 
671
- exports.DevkitMigrationFilesystem = DevkitMigrationFilesystem;
672
748
  exports.Replacement = Replacement;
673
749
  exports.TextUpdate = TextUpdate;
674
750
  exports.TsurgeComplexMigration = TsurgeComplexMigration;
675
751
  exports.TsurgeFunnelMigration = TsurgeFunnelMigration;
676
752
  exports.confirmAsSerializable = confirmAsSerializable;
677
753
  exports.createBaseProgramInfo = createBaseProgramInfo;
678
- exports.groupReplacementsByFile = groupReplacementsByFile;
679
754
  exports.projectFile = projectFile;
680
- exports.synchronouslyCombineUnitData = synchronouslyCombineUnitData;
755
+ exports.runMigrationInDevkit = runMigrationInDevkit;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.2.5
3
+ * @license Angular v19.2.6
4
4
  * (c) 2010-2025 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.2.5
3
+ * @license Angular v19.2.6
4
4
  * (c) 2010-2025 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.2.5
3
+ * @license Angular v19.2.6
4
4
  * (c) 2010-2025 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -9,11 +9,11 @@
9
9
  var schematics = require('@angular-devkit/schematics');
10
10
  var p = require('path');
11
11
  var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.js');
12
- var compiler_host = require('./compiler_host-IULKT7OF.js');
12
+ var compiler_host = require('./compiler_host-BUKEE1cA.js');
13
13
  var ts = require('typescript');
14
14
  var imports = require('./imports-CIX-JgAN.js');
15
15
  require('@angular-devkit/core');
16
- require('./checker-CQvNmpT3.js');
16
+ require('./checker-DoX_7XCa.js');
17
17
  require('os');
18
18
  require('fs');
19
19
  require('module');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.2.5
3
+ * @license Angular v19.2.6
4
4
  * (c) 2010-2025 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
@@ -9,10 +9,10 @@
9
9
  var schematics = require('@angular-devkit/schematics');
10
10
  var fs = require('fs');
11
11
  var p = require('path');
12
- var compiler_host = require('./compiler_host-IULKT7OF.js');
12
+ var compiler_host = require('./compiler_host-BUKEE1cA.js');
13
13
  var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.js');
14
14
  var ts = require('typescript');
15
- var checker = require('./checker-CQvNmpT3.js');
15
+ var checker = require('./checker-DoX_7XCa.js');
16
16
  var property_name = require('./property_name-BBwFuqMe.js');
17
17
  require('os');
18
18
  require('@angular-devkit/core');
@@ -1,19 +1,17 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.2.5
3
+ * @license Angular v19.2.6
4
4
  * (c) 2010-2025 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
7
7
  'use strict';
8
8
 
9
- var schematics = require('@angular-devkit/schematics');
10
- var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.js');
11
- var project_paths = require('./project_paths-CTgTxqrW.js');
12
- require('os');
13
9
  var ts = require('typescript');
14
- var checker = require('./checker-CQvNmpT3.js');
15
- require('./program-XYcLSXb1.js');
10
+ require('os');
11
+ var checker = require('./checker-DoX_7XCa.js');
12
+ require('./index-B4b0V0Vo.js');
16
13
  require('path');
14
+ var project_paths = require('./project_paths-C3etOlgT.js');
17
15
  var ng_decorators = require('./ng_decorators-DznZ5jMl.js');
18
16
  var property_name = require('./property_name-BBwFuqMe.js');
19
17
  require('@angular-devkit/core');
@@ -21,6 +19,8 @@ require('node:path/posix');
21
19
  require('fs');
22
20
  require('module');
23
21
  require('url');
22
+ require('@angular-devkit/schematics');
23
+ require('./project_tsconfig_paths-CDVxT6Ov.js');
24
24
  require('./imports-CIX-JgAN.js');
25
25
 
26
26
  /**
@@ -393,65 +393,40 @@ function removeDuplicateReplacements(replacements) {
393
393
 
394
394
  function migrate(options) {
395
395
  return async (tree, context) => {
396
- const { buildPaths, testPaths } = await project_tsconfig_paths.getProjectTsConfigPaths(tree);
397
- if (!buildPaths.length && !testPaths.length) {
398
- throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run self-closing tags migration.');
399
- }
400
- const fs = new project_paths.DevkitMigrationFilesystem(tree);
401
- checker.setFileSystem(fs);
402
- const migration = new SelfClosingTagsMigration({
403
- shouldMigrate: (file) => {
404
- return (file.rootRelativePath.startsWith(fs.normalize(options.path)) &&
405
- !/(^|\/)node_modules\//.test(file.rootRelativePath));
396
+ await project_paths.runMigrationInDevkit({
397
+ tree,
398
+ getMigration: (fs) => new SelfClosingTagsMigration({
399
+ shouldMigrate: (file) => {
400
+ return (file.rootRelativePath.startsWith(fs.normalize(options.path)) &&
401
+ !/(^|\/)node_modules\//.test(file.rootRelativePath));
402
+ },
403
+ }),
404
+ beforeProgramCreation: (tsconfigPath, stage) => {
405
+ if (stage === project_paths.MigrationStage.Analysis) {
406
+ context.logger.info(`Preparing analysis for: ${tsconfigPath}...`);
407
+ }
408
+ else {
409
+ context.logger.info(`Running migration for: ${tsconfigPath}...`);
410
+ }
411
+ },
412
+ beforeUnitAnalysis: (tsconfigPath) => {
413
+ context.logger.info(`Scanning for component tags: ${tsconfigPath}...`);
414
+ },
415
+ afterAllAnalyzed: () => {
416
+ context.logger.info(``);
417
+ context.logger.info(`Processing analysis data between targets...`);
418
+ context.logger.info(``);
419
+ },
420
+ afterAnalysisFailure: () => {
421
+ context.logger.error('Migration failed unexpectedly with no analysis data');
422
+ },
423
+ whenDone: ({ counters }) => {
424
+ const { touchedFilesCount, replacementCount } = counters;
425
+ context.logger.info('');
426
+ context.logger.info(`Successfully migrated to self-closing tags 🎉`);
427
+ context.logger.info(` -> Migrated ${replacementCount} components to self-closing tags in ${touchedFilesCount} component files.`);
406
428
  },
407
429
  });
408
- const unitResults = [];
409
- const programInfos = [...buildPaths, ...testPaths].map((tsconfigPath) => {
410
- context.logger.info(`Preparing analysis for: ${tsconfigPath}..`);
411
- const baseInfo = migration.createProgram(tsconfigPath, fs);
412
- const info = migration.prepareProgram(baseInfo);
413
- return { info, tsconfigPath };
414
- });
415
- // Analyze phase. Treat all projects as compilation units as
416
- // this allows us to support references between those.
417
- for (const { info, tsconfigPath } of programInfos) {
418
- context.logger.info(`Scanning for component tags: ${tsconfigPath}..`);
419
- unitResults.push(await migration.analyze(info));
420
- }
421
- context.logger.info(``);
422
- context.logger.info(`Processing analysis data between targets..`);
423
- context.logger.info(``);
424
- const combined = await project_paths.synchronouslyCombineUnitData(migration, unitResults);
425
- if (combined === null) {
426
- context.logger.error('Migration failed unexpectedly with no analysis data');
427
- return;
428
- }
429
- const globalMeta = await migration.globalMeta(combined);
430
- const replacementsPerFile = new Map();
431
- for (const { tsconfigPath } of programInfos) {
432
- context.logger.info(`Migrating: ${tsconfigPath}..`);
433
- const { replacements } = await migration.migrate(globalMeta);
434
- const changesPerFile = project_paths.groupReplacementsByFile(replacements);
435
- for (const [file, changes] of changesPerFile) {
436
- if (!replacementsPerFile.has(file)) {
437
- replacementsPerFile.set(file, changes);
438
- }
439
- }
440
- }
441
- context.logger.info(`Applying changes..`);
442
- for (const [file, changes] of replacementsPerFile) {
443
- const recorder = tree.beginUpdate(file);
444
- for (const c of changes) {
445
- recorder
446
- .remove(c.data.position, c.data.end - c.data.position)
447
- .insertLeft(c.data.position, c.data.toInsert);
448
- }
449
- tree.commitUpdate(recorder);
450
- }
451
- const { counters: { touchedFilesCount, replacementCount }, } = await migration.stats(globalMeta);
452
- context.logger.info('');
453
- context.logger.info(`Successfully migrated to self-closing tags 🎉`);
454
- context.logger.info(` -> Migrated ${replacementCount} components to self-closing tags in ${touchedFilesCount} component files.`);
455
430
  };
456
431
  }
457
432
 
@@ -1,29 +1,29 @@
1
1
  'use strict';
2
2
  /**
3
- * @license Angular v19.2.5
3
+ * @license Angular v19.2.6
4
4
  * (c) 2010-2025 Google LLC. https://angular.io/
5
5
  * License: MIT
6
6
  */
7
7
  'use strict';
8
8
 
9
- var schematics = require('@angular-devkit/schematics');
10
- var migrate_ts_type_references = require('./migrate_ts_type_references-CHRyhQvi.js');
9
+ var migrate_ts_type_references = require('./migrate_ts_type_references-DQVDid4G.js');
11
10
  var ts = require('typescript');
12
11
  require('os');
13
- var checker = require('./checker-CQvNmpT3.js');
14
- var program = require('./program-XYcLSXb1.js');
12
+ var checker = require('./checker-DoX_7XCa.js');
13
+ var index$1 = require('./index-B4b0V0Vo.js');
15
14
  require('path');
16
- var project_paths = require('./project_paths-CTgTxqrW.js');
17
- var index = require('./index-BKWl7N44.js');
15
+ var project_paths = require('./project_paths-C3etOlgT.js');
16
+ var index = require('./index-CpZKzrqM.js');
18
17
  var assert = require('assert');
19
- var apply_import_manager = require('./apply_import_manager-CTrezOPF.js');
20
- var project_tsconfig_paths = require('./project_tsconfig_paths-CDVxT6Ov.js');
18
+ var apply_import_manager = require('./apply_import_manager-DFADpdFu.js');
19
+ require('@angular-devkit/core');
20
+ require('node:path/posix');
21
21
  require('./leading_space-D9nQ8UQC.js');
22
22
  require('fs');
23
23
  require('module');
24
24
  require('url');
25
- require('@angular-devkit/core');
26
- require('node:path/posix');
25
+ require('@angular-devkit/schematics');
26
+ require('./project_tsconfig_paths-CDVxT6Ov.js');
27
27
 
28
28
  /**
29
29
  * Class that holds information about a given directive and its input fields.
@@ -275,8 +275,8 @@ function prepareAnalysisInfo(userProgram, compiler, programAbsoluteRootPaths) {
275
275
  }
276
276
  const typeChecker = userProgram.getTypeChecker();
277
277
  const reflector = new checker.TypeScriptReflectionHost(typeChecker);
278
- const evaluator = new program.PartialEvaluator(reflector, typeChecker, null);
279
- const dtsMetadataReader = new program.DtsMetadataReader(typeChecker, reflector);
278
+ const evaluator = new index$1.PartialEvaluator(reflector, typeChecker, null);
279
+ const dtsMetadataReader = new index$1.DtsMetadataReader(typeChecker, reflector);
280
280
  return {
281
281
  metaRegistry: metaReader,
282
282
  dtsMetadataReader,
@@ -1433,82 +1433,59 @@ function createMigrationHost(info, config) {
1433
1433
 
1434
1434
  function migrate(options) {
1435
1435
  return async (tree, context) => {
1436
- const { buildPaths, testPaths } = await project_tsconfig_paths.getProjectTsConfigPaths(tree);
1437
- if (!buildPaths.length && !testPaths.length) {
1438
- throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run signal input migration.');
1439
- }
1440
- const fs = new project_paths.DevkitMigrationFilesystem(tree);
1441
- checker.setFileSystem(fs);
1442
- const migration = new SignalInputMigration({
1443
- bestEffortMode: options.bestEffortMode,
1444
- insertTodosForSkippedFields: options.insertTodos,
1445
- shouldMigrateInput: (input) => {
1446
- return (input.file.rootRelativePath.startsWith(fs.normalize(options.path)) &&
1447
- !/(^|\/)node_modules\//.test(input.file.rootRelativePath));
1436
+ await project_paths.runMigrationInDevkit({
1437
+ tree,
1438
+ getMigration: (fs) => new SignalInputMigration({
1439
+ bestEffortMode: options.bestEffortMode,
1440
+ insertTodosForSkippedFields: options.insertTodos,
1441
+ shouldMigrateInput: (input) => {
1442
+ return (input.file.rootRelativePath.startsWith(fs.normalize(options.path)) &&
1443
+ !/(^|\/)node_modules\//.test(input.file.rootRelativePath));
1444
+ },
1445
+ }),
1446
+ beforeProgramCreation: (tsconfigPath, stage) => {
1447
+ if (stage === project_paths.MigrationStage.Analysis) {
1448
+ context.logger.info(`Preparing analysis for: ${tsconfigPath}...`);
1449
+ }
1450
+ else {
1451
+ context.logger.info(`Running migration for: ${tsconfigPath}...`);
1452
+ }
1448
1453
  },
1449
- });
1450
- const analysisPath = fs.resolve(options.analysisDir);
1451
- const unitResults = [];
1452
- const programInfos = [...buildPaths, ...testPaths].map((tsconfigPath) => {
1453
- context.logger.info(`Preparing analysis for: ${tsconfigPath}..`);
1454
- const baseInfo = migration.createProgram(tsconfigPath, fs);
1455
- const info = migration.prepareProgram(baseInfo);
1456
- // Support restricting the analysis to subfolders for larger projects.
1457
- if (analysisPath !== '/') {
1458
- info.sourceFiles = info.sourceFiles.filter((sf) => sf.fileName.startsWith(analysisPath));
1459
- info.fullProgramSourceFiles = info.fullProgramSourceFiles.filter((sf) => sf.fileName.startsWith(analysisPath));
1460
- }
1461
- return { info, tsconfigPath };
1462
- });
1463
- // Analyze phase. Treat all projects as compilation units as
1464
- // this allows us to support references between those.
1465
- for (const { info, tsconfigPath } of programInfos) {
1466
- context.logger.info(`Scanning for inputs: ${tsconfigPath}..`);
1467
- unitResults.push(await migration.analyze(info));
1468
- }
1469
- context.logger.info(``);
1470
- context.logger.info(`Processing analysis data between targets..`);
1471
- context.logger.info(``);
1472
- const combined = await project_paths.synchronouslyCombineUnitData(migration, unitResults);
1473
- if (combined === null) {
1474
- context.logger.error('Migration failed unexpectedly with no analysis data');
1475
- return;
1476
- }
1477
- const globalMeta = await migration.globalMeta(combined);
1478
- const replacementsPerFile = new Map();
1479
- for (const { info, tsconfigPath } of programInfos) {
1480
- context.logger.info(`Migrating: ${tsconfigPath}..`);
1481
- const { replacements } = await migration.migrate(globalMeta, info);
1482
- const changesPerFile = project_paths.groupReplacementsByFile(replacements);
1483
- for (const [file, changes] of changesPerFile) {
1484
- if (!replacementsPerFile.has(file)) {
1485
- replacementsPerFile.set(file, changes);
1454
+ afterProgramCreation: (info, fs) => {
1455
+ const analysisPath = fs.resolve(options.analysisDir);
1456
+ // Support restricting the analysis to subfolders for larger projects.
1457
+ if (analysisPath !== '/') {
1458
+ info.sourceFiles = info.sourceFiles.filter((sf) => sf.fileName.startsWith(analysisPath));
1459
+ info.fullProgramSourceFiles = info.fullProgramSourceFiles.filter((sf) => sf.fileName.startsWith(analysisPath));
1486
1460
  }
1487
- }
1488
- }
1489
- context.logger.info(`Applying changes..`);
1490
- for (const [file, changes] of replacementsPerFile) {
1491
- const recorder = tree.beginUpdate(file);
1492
- for (const c of changes) {
1493
- recorder
1494
- .remove(c.data.position, c.data.end - c.data.position)
1495
- .insertLeft(c.data.position, c.data.toInsert);
1496
- }
1497
- tree.commitUpdate(recorder);
1498
- }
1499
- const { counters } = await migration.stats(globalMeta);
1500
- const migratedInputs = counters.sourceInputs - counters.incompatibleInputs;
1501
- context.logger.info('');
1502
- context.logger.info(`Successfully migrated to signal inputs 🎉`);
1503
- context.logger.info(` -> Migrated ${migratedInputs}/${counters.sourceInputs} inputs.`);
1504
- if (counters.incompatibleInputs > 0 && !options.insertTodos) {
1505
- context.logger.warn(`To see why ${counters.incompatibleInputs} inputs couldn't be migrated`);
1506
- context.logger.warn(`consider re-running with "--insert-todos" or "--best-effort-mode".`);
1507
- }
1508
- if (options.bestEffortMode) {
1509
- context.logger.warn(`You ran with best effort mode. Manually verify all code ` +
1510
- `works as intended, and fix where necessary.`);
1511
- }
1461
+ },
1462
+ beforeUnitAnalysis: (tsconfigPath) => {
1463
+ context.logger.info(`Scanning for inputs: ${tsconfigPath}...`);
1464
+ },
1465
+ afterAllAnalyzed: () => {
1466
+ context.logger.info(``);
1467
+ context.logger.info(`Processing analysis data between targets...`);
1468
+ context.logger.info(``);
1469
+ },
1470
+ afterAnalysisFailure: () => {
1471
+ context.logger.error('Migration failed unexpectedly with no analysis data');
1472
+ },
1473
+ whenDone: ({ counters }) => {
1474
+ const { sourceInputs, incompatibleInputs } = counters;
1475
+ const migratedInputs = sourceInputs - incompatibleInputs;
1476
+ context.logger.info('');
1477
+ context.logger.info(`Successfully migrated to signal inputs 🎉`);
1478
+ context.logger.info(` -> Migrated ${migratedInputs}/${sourceInputs} inputs.`);
1479
+ if (incompatibleInputs > 0 && !options.insertTodos) {
1480
+ context.logger.warn(`To see why ${incompatibleInputs} inputs couldn't be migrated`);
1481
+ context.logger.warn(`consider re-running with "--insert-todos" or "--best-effort-mode".`);
1482
+ }
1483
+ if (options.bestEffortMode) {
1484
+ context.logger.warn(`You ran with best effort mode. Manually verify all code ` +
1485
+ `works as intended, and fix where necessary.`);
1486
+ }
1487
+ },
1488
+ });
1512
1489
  };
1513
1490
  }
1514
1491