@angular/core 20.0.0-next.2 → 20.0.0-next.4
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.
- package/event_dispatcher.d-pVP0-wST.d.ts +345 -0
- package/fesm2022/core.mjs +614 -428
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/injector-BlLwZ2sr.mjs +24 -0
- package/fesm2022/injector-BlLwZ2sr.mjs.map +1 -0
- package/fesm2022/primitives/di.mjs +5 -18
- package/fesm2022/primitives/di.mjs.map +1 -1
- package/fesm2022/primitives/event-dispatch.mjs +1 -1
- package/fesm2022/primitives/signals.mjs +4 -589
- package/fesm2022/primitives/signals.mjs.map +1 -1
- package/fesm2022/rxjs-interop.mjs +1 -8
- package/fesm2022/rxjs-interop.mjs.map +1 -1
- package/fesm2022/testing.mjs +2 -10
- package/fesm2022/testing.mjs.map +1 -1
- package/fesm2022/untracked-DkcXpNb_.mjs +620 -0
- package/fesm2022/untracked-DkcXpNb_.mjs.map +1 -0
- package/index.d.ts +7589 -7510
- package/{navigation_types.d-u4EOrrdZ.d.ts → navigation_types.d-DgDrF5rp.d.ts} +2 -2
- package/package.json +2 -2
- package/primitives/di/index.d.ts +25 -10
- package/primitives/event-dispatch/index.d.ts +5 -340
- package/primitives/signals/index.d.ts +5 -208
- package/rxjs-interop/index.d.ts +1 -10
- package/schematics/bundles/{apply_import_manager-CyRT0UvU.js → apply_import_manager-CeNv8GIG.js} +6 -6
- package/schematics/bundles/{checker-DF8ZaFW5.js → checker-k591b6WQ.js} +856 -180
- package/schematics/bundles/cleanup-unused-imports.js +42 -69
- package/schematics/bundles/{compiler_host-Da636uJ8.js → compiler_host-DwM3ugW3.js} +2 -2
- package/schematics/bundles/control-flow-migration.js +34 -13
- package/schematics/bundles/imports-CIX-JgAN.js +1 -1
- package/schematics/bundles/{program-BZk27Ndu.js → index-B4OAlHh8.js} +2234 -2097
- package/schematics/bundles/{index-DnkWgagp.js → index-BhELUmYx.js} +11 -11
- package/schematics/bundles/inject-flags.js +18 -52
- package/schematics/bundles/inject-migration.js +3 -3
- package/schematics/bundles/leading_space-D9nQ8UQC.js +1 -1
- package/schematics/bundles/{migrate_ts_type_references-DtkOnnv0.js → migrate_ts_type_references-Be0TNYen.js} +20 -20
- package/schematics/bundles/ng_decorators-DznZ5jMl.js +1 -1
- package/schematics/bundles/nodes-B16H9JUd.js +1 -1
- package/schematics/bundles/output-migration.js +62 -90
- package/schematics/bundles/project_tsconfig_paths-CDVxT6Ov.js +1 -1
- package/schematics/bundles/property_name-BBwFuqMe.js +1 -1
- package/schematics/bundles/route-lazy-loading.js +3 -3
- package/schematics/bundles/{project_paths-Jtbi76Bs.js → run_in_devkit-CkvEksWP.js} +262 -197
- package/schematics/bundles/self-closing-tags-migration.js +41 -71
- package/schematics/bundles/signal-input-migration.js +69 -97
- package/schematics/bundles/signal-queries-migration.js +80 -108
- package/schematics/bundles/signals.js +11 -11
- package/schematics/bundles/standalone-migration.js +8 -22
- package/schematics/bundles/symbol-VPWguRxr.js +25 -0
- package/schematics/bundles/test-bed-get.js +98 -0
- package/schematics/migrations.json +5 -0
- package/testing/index.d.ts +2 -4
- package/weak_ref.d-BZ7gyRag.d.ts +216 -0
- package/fesm2022/weak_ref-DrMdAIDh.mjs +0 -12
- package/fesm2022/weak_ref-DrMdAIDh.mjs.map +0 -1
- package/schematics/bundles/index-vGJcp5M7.js +0 -30
- package/weak_ref.d-ttyj86RV.d.ts +0 -9
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/**
|
|
3
|
-
* @license Angular v20.0.0-next.
|
|
3
|
+
* @license Angular v20.0.0-next.4
|
|
4
4
|
* (c) 2010-2025 Google LLC. https://angular.io/
|
|
5
5
|
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
-
var core = require('@angular-devkit/core');
|
|
10
|
-
var posixPath = require('node:path/posix');
|
|
11
9
|
var os = require('os');
|
|
12
10
|
var ts = require('typescript');
|
|
13
|
-
var checker = require('./checker-
|
|
14
|
-
var
|
|
11
|
+
var checker = require('./checker-k591b6WQ.js');
|
|
12
|
+
var index = require('./index-B4OAlHh8.js');
|
|
13
|
+
var schematics = require('@angular-devkit/schematics');
|
|
14
|
+
var core = require('@angular-devkit/core');
|
|
15
|
+
var posixPath = require('node:path/posix');
|
|
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);
|
|
@@ -31,8 +33,8 @@ function _interopNamespaceDefault(e) {
|
|
|
31
33
|
return Object.freeze(n);
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
var posixPath__namespace = /*#__PURE__*/_interopNamespaceDefault(posixPath);
|
|
35
36
|
var os__namespace = /*#__PURE__*/_interopNamespaceDefault(os);
|
|
37
|
+
var posixPath__namespace = /*#__PURE__*/_interopNamespaceDefault(posixPath);
|
|
36
38
|
|
|
37
39
|
/// <reference types="node" />
|
|
38
40
|
class NgtscCompilerHost {
|
|
@@ -187,7 +189,7 @@ function readConfiguration(project, existingOptions, host = checker.getFileSyste
|
|
|
187
189
|
errors: [error],
|
|
188
190
|
rootNames: [],
|
|
189
191
|
options: {},
|
|
190
|
-
emitFlags:
|
|
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 =
|
|
203
|
+
let emitFlags = index.EmitFlags.Default;
|
|
202
204
|
if (!(options['skipMetadataEmit'] || options['flatModuleOutFile'])) {
|
|
203
|
-
emitFlags |=
|
|
205
|
+
emitFlags |= index.EmitFlags.Metadata;
|
|
204
206
|
}
|
|
205
207
|
if (options['skipTemplateCodegen']) {
|
|
206
|
-
emitFlags = emitFlags & ~
|
|
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:
|
|
221
|
+
code: index.UNKNOWN_ERROR_CODE,
|
|
220
222
|
},
|
|
221
223
|
];
|
|
222
|
-
return { project: '', errors, rootNames: [], options: {}, emitFlags:
|
|
224
|
+
return { project: '', errors, rootNames: [], options: {}, emitFlags: index.EmitFlags.Default };
|
|
223
225
|
}
|
|
224
226
|
}
|
|
225
227
|
function createParseConfigHost(host, fs = checker.getFileSystem()) {
|
|
@@ -258,187 +260,6 @@ function getExtendedConfigPathWorker(configFile, extendsValue, host, fs) {
|
|
|
258
260
|
return null;
|
|
259
261
|
}
|
|
260
262
|
|
|
261
|
-
/**
|
|
262
|
-
* Angular compiler file system implementation that leverages an
|
|
263
|
-
* CLI schematic virtual file tree.
|
|
264
|
-
*/
|
|
265
|
-
class DevkitMigrationFilesystem {
|
|
266
|
-
tree;
|
|
267
|
-
constructor(tree) {
|
|
268
|
-
this.tree = tree;
|
|
269
|
-
}
|
|
270
|
-
extname(path) {
|
|
271
|
-
return core.extname(path);
|
|
272
|
-
}
|
|
273
|
-
isRoot(path) {
|
|
274
|
-
return path === core.normalize('/');
|
|
275
|
-
}
|
|
276
|
-
isRooted(path) {
|
|
277
|
-
return this.normalize(path).startsWith('/');
|
|
278
|
-
}
|
|
279
|
-
dirname(file) {
|
|
280
|
-
return this.normalize(core.dirname(file));
|
|
281
|
-
}
|
|
282
|
-
join(basePath, ...paths) {
|
|
283
|
-
return this.normalize(core.join(basePath, ...paths));
|
|
284
|
-
}
|
|
285
|
-
relative(from, to) {
|
|
286
|
-
return this.normalize(core.relative(from, to));
|
|
287
|
-
}
|
|
288
|
-
basename(filePath, extension) {
|
|
289
|
-
return posixPath__namespace.basename(filePath, extension);
|
|
290
|
-
}
|
|
291
|
-
normalize(path) {
|
|
292
|
-
return core.normalize(path);
|
|
293
|
-
}
|
|
294
|
-
resolve(...paths) {
|
|
295
|
-
const normalizedPaths = paths.map((p) => core.normalize(p));
|
|
296
|
-
// In dev-kit, the NodeJS working directory should never be
|
|
297
|
-
// considered, so `/` is the last resort over `cwd`.
|
|
298
|
-
return this.normalize(posixPath__namespace.resolve(core.normalize('/'), ...normalizedPaths));
|
|
299
|
-
}
|
|
300
|
-
pwd() {
|
|
301
|
-
return '/';
|
|
302
|
-
}
|
|
303
|
-
isCaseSensitive() {
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
exists(path) {
|
|
307
|
-
return statPath(this.tree, path) !== null;
|
|
308
|
-
}
|
|
309
|
-
readFile(path) {
|
|
310
|
-
return this.tree.readText(path);
|
|
311
|
-
}
|
|
312
|
-
readFileBuffer(path) {
|
|
313
|
-
const buffer = this.tree.read(path);
|
|
314
|
-
if (buffer === null) {
|
|
315
|
-
throw new Error(`File does not exist: ${path}`);
|
|
316
|
-
}
|
|
317
|
-
return buffer;
|
|
318
|
-
}
|
|
319
|
-
readdir(path) {
|
|
320
|
-
const dir = this.tree.getDir(path);
|
|
321
|
-
return [
|
|
322
|
-
...dir.subdirs,
|
|
323
|
-
...dir.subfiles,
|
|
324
|
-
];
|
|
325
|
-
}
|
|
326
|
-
lstat(path) {
|
|
327
|
-
const stat = statPath(this.tree, path);
|
|
328
|
-
if (stat === null) {
|
|
329
|
-
throw new Error(`File does not exist for "lstat": ${path}`);
|
|
330
|
-
}
|
|
331
|
-
return stat;
|
|
332
|
-
}
|
|
333
|
-
stat(path) {
|
|
334
|
-
const stat = statPath(this.tree, path);
|
|
335
|
-
if (stat === null) {
|
|
336
|
-
throw new Error(`File does not exist for "stat": ${path}`);
|
|
337
|
-
}
|
|
338
|
-
return stat;
|
|
339
|
-
}
|
|
340
|
-
realpath(filePath) {
|
|
341
|
-
return filePath;
|
|
342
|
-
}
|
|
343
|
-
getDefaultLibLocation() {
|
|
344
|
-
return 'node_modules/typescript/lib';
|
|
345
|
-
}
|
|
346
|
-
ensureDir(path) {
|
|
347
|
-
// Migrations should compute replacements and not write directly.
|
|
348
|
-
throw new Error('DevkitFilesystem#ensureDir is not supported.');
|
|
349
|
-
}
|
|
350
|
-
writeFile(path, data) {
|
|
351
|
-
// Migrations should compute replacements and not write directly.
|
|
352
|
-
throw new Error('DevkitFilesystem#writeFile is not supported.');
|
|
353
|
-
}
|
|
354
|
-
removeFile(path) {
|
|
355
|
-
// Migrations should compute replacements and not write directly.
|
|
356
|
-
throw new Error('DevkitFilesystem#removeFile is not supported.');
|
|
357
|
-
}
|
|
358
|
-
copyFile(from, to) {
|
|
359
|
-
// Migrations should compute replacements and not write directly.
|
|
360
|
-
throw new Error('DevkitFilesystem#copyFile is not supported.');
|
|
361
|
-
}
|
|
362
|
-
moveFile(from, to) {
|
|
363
|
-
// Migrations should compute replacements and not write directly.
|
|
364
|
-
throw new Error('DevkitFilesystem#moveFile is not supported.');
|
|
365
|
-
}
|
|
366
|
-
removeDeep(path) {
|
|
367
|
-
// Migrations should compute replacements and not write directly.
|
|
368
|
-
throw new Error('DevkitFilesystem#removeDeep is not supported.');
|
|
369
|
-
}
|
|
370
|
-
chdir(_path) {
|
|
371
|
-
throw new Error('FileSystem#chdir is not supported.');
|
|
372
|
-
}
|
|
373
|
-
symlink() {
|
|
374
|
-
throw new Error('FileSystem#symlink is not supported.');
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
/** Stats the given path in the virtual tree. */
|
|
378
|
-
function statPath(tree, path) {
|
|
379
|
-
let fileInfo = null;
|
|
380
|
-
let dirInfo = null;
|
|
381
|
-
try {
|
|
382
|
-
fileInfo = tree.get(path);
|
|
383
|
-
}
|
|
384
|
-
catch (e) {
|
|
385
|
-
if (e.constructor.name === 'PathIsDirectoryException') {
|
|
386
|
-
dirInfo = tree.getDir(path);
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
throw e;
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
if (fileInfo !== null || dirInfo !== null) {
|
|
393
|
-
return {
|
|
394
|
-
isDirectory: () => dirInfo !== null,
|
|
395
|
-
isFile: () => fileInfo !== null,
|
|
396
|
-
isSymbolicLink: () => false,
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
return null;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Groups the given replacements per project relative
|
|
404
|
-
* file path.
|
|
405
|
-
*
|
|
406
|
-
* This allows for simple execution of the replacements
|
|
407
|
-
* against a given file. E.g. via {@link applyTextUpdates}.
|
|
408
|
-
*/
|
|
409
|
-
function groupReplacementsByFile(replacements) {
|
|
410
|
-
const result = new Map();
|
|
411
|
-
for (const { projectFile, update } of replacements) {
|
|
412
|
-
if (!result.has(projectFile.rootRelativePath)) {
|
|
413
|
-
result.set(projectFile.rootRelativePath, []);
|
|
414
|
-
}
|
|
415
|
-
result.get(projectFile.rootRelativePath).push(update);
|
|
416
|
-
}
|
|
417
|
-
return result;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Synchronously combines unit data for the given migration.
|
|
422
|
-
*
|
|
423
|
-
* Note: This helper is useful for testing and execution of
|
|
424
|
-
* Tsurge migrations in non-batchable environments. In general,
|
|
425
|
-
* prefer parallel execution of combining via e.g. Beam combiners.
|
|
426
|
-
*/
|
|
427
|
-
async function synchronouslyCombineUnitData(migration, unitDatas) {
|
|
428
|
-
if (unitDatas.length === 0) {
|
|
429
|
-
return null;
|
|
430
|
-
}
|
|
431
|
-
if (unitDatas.length === 1) {
|
|
432
|
-
return unitDatas[0];
|
|
433
|
-
}
|
|
434
|
-
let combined = unitDatas[0];
|
|
435
|
-
for (let i = 1; i < unitDatas.length; i++) {
|
|
436
|
-
const other = unitDatas[i];
|
|
437
|
-
combined = await migration.combine(combined, other);
|
|
438
|
-
}
|
|
439
|
-
return combined;
|
|
440
|
-
}
|
|
441
|
-
|
|
442
263
|
/**
|
|
443
264
|
* By default, Tsurge will always create an Angular compiler program
|
|
444
265
|
* for projects analyzed and migrated. This works perfectly fine in
|
|
@@ -488,7 +309,7 @@ function createPlainTsProgram(tsHost, tsconfig, optionOverrides) {
|
|
|
488
309
|
* an instance of the Angular compiler for the project.
|
|
489
310
|
*/
|
|
490
311
|
function createNgtscProgram(tsHost, tsconfig, optionOverrides) {
|
|
491
|
-
const ngtscProgram = new
|
|
312
|
+
const ngtscProgram = new index.NgtscProgram(tsconfig.rootNames, {
|
|
492
313
|
...tsconfig.options,
|
|
493
314
|
...defaultMigrationTsOptions,
|
|
494
315
|
...optionOverrides,
|
|
@@ -668,13 +489,257 @@ function isWithinBasePath(fs, base, path) {
|
|
|
668
489
|
return checker.isLocalRelativePath(fs.relative(base, path));
|
|
669
490
|
}
|
|
670
491
|
|
|
671
|
-
|
|
492
|
+
/**
|
|
493
|
+
* Angular compiler file system implementation that leverages an
|
|
494
|
+
* CLI schematic virtual file tree.
|
|
495
|
+
*/
|
|
496
|
+
class DevkitMigrationFilesystem {
|
|
497
|
+
tree;
|
|
498
|
+
constructor(tree) {
|
|
499
|
+
this.tree = tree;
|
|
500
|
+
}
|
|
501
|
+
extname(path) {
|
|
502
|
+
return core.extname(path);
|
|
503
|
+
}
|
|
504
|
+
isRoot(path) {
|
|
505
|
+
return path === core.normalize('/');
|
|
506
|
+
}
|
|
507
|
+
isRooted(path) {
|
|
508
|
+
return this.normalize(path).startsWith('/');
|
|
509
|
+
}
|
|
510
|
+
dirname(file) {
|
|
511
|
+
return this.normalize(core.dirname(file));
|
|
512
|
+
}
|
|
513
|
+
join(basePath, ...paths) {
|
|
514
|
+
return this.normalize(core.join(basePath, ...paths));
|
|
515
|
+
}
|
|
516
|
+
relative(from, to) {
|
|
517
|
+
return this.normalize(core.relative(from, to));
|
|
518
|
+
}
|
|
519
|
+
basename(filePath, extension) {
|
|
520
|
+
return posixPath__namespace.basename(filePath, extension);
|
|
521
|
+
}
|
|
522
|
+
normalize(path) {
|
|
523
|
+
return core.normalize(path);
|
|
524
|
+
}
|
|
525
|
+
resolve(...paths) {
|
|
526
|
+
const normalizedPaths = paths.map((p) => core.normalize(p));
|
|
527
|
+
// In dev-kit, the NodeJS working directory should never be
|
|
528
|
+
// considered, so `/` is the last resort over `cwd`.
|
|
529
|
+
return this.normalize(posixPath__namespace.resolve(core.normalize('/'), ...normalizedPaths));
|
|
530
|
+
}
|
|
531
|
+
pwd() {
|
|
532
|
+
return '/';
|
|
533
|
+
}
|
|
534
|
+
isCaseSensitive() {
|
|
535
|
+
return true;
|
|
536
|
+
}
|
|
537
|
+
exists(path) {
|
|
538
|
+
return statPath(this.tree, path) !== null;
|
|
539
|
+
}
|
|
540
|
+
readFile(path) {
|
|
541
|
+
return this.tree.readText(path);
|
|
542
|
+
}
|
|
543
|
+
readFileBuffer(path) {
|
|
544
|
+
const buffer = this.tree.read(path);
|
|
545
|
+
if (buffer === null) {
|
|
546
|
+
throw new Error(`File does not exist: ${path}`);
|
|
547
|
+
}
|
|
548
|
+
return buffer;
|
|
549
|
+
}
|
|
550
|
+
readdir(path) {
|
|
551
|
+
const dir = this.tree.getDir(path);
|
|
552
|
+
return [
|
|
553
|
+
...dir.subdirs,
|
|
554
|
+
...dir.subfiles,
|
|
555
|
+
];
|
|
556
|
+
}
|
|
557
|
+
lstat(path) {
|
|
558
|
+
const stat = statPath(this.tree, path);
|
|
559
|
+
if (stat === null) {
|
|
560
|
+
throw new Error(`File does not exist for "lstat": ${path}`);
|
|
561
|
+
}
|
|
562
|
+
return stat;
|
|
563
|
+
}
|
|
564
|
+
stat(path) {
|
|
565
|
+
const stat = statPath(this.tree, path);
|
|
566
|
+
if (stat === null) {
|
|
567
|
+
throw new Error(`File does not exist for "stat": ${path}`);
|
|
568
|
+
}
|
|
569
|
+
return stat;
|
|
570
|
+
}
|
|
571
|
+
realpath(filePath) {
|
|
572
|
+
return filePath;
|
|
573
|
+
}
|
|
574
|
+
getDefaultLibLocation() {
|
|
575
|
+
return 'node_modules/typescript/lib';
|
|
576
|
+
}
|
|
577
|
+
ensureDir(path) {
|
|
578
|
+
// Migrations should compute replacements and not write directly.
|
|
579
|
+
throw new Error('DevkitFilesystem#ensureDir is not supported.');
|
|
580
|
+
}
|
|
581
|
+
writeFile(path, data) {
|
|
582
|
+
// Migrations should compute replacements and not write directly.
|
|
583
|
+
throw new Error('DevkitFilesystem#writeFile is not supported.');
|
|
584
|
+
}
|
|
585
|
+
removeFile(path) {
|
|
586
|
+
// Migrations should compute replacements and not write directly.
|
|
587
|
+
throw new Error('DevkitFilesystem#removeFile is not supported.');
|
|
588
|
+
}
|
|
589
|
+
copyFile(from, to) {
|
|
590
|
+
// Migrations should compute replacements and not write directly.
|
|
591
|
+
throw new Error('DevkitFilesystem#copyFile is not supported.');
|
|
592
|
+
}
|
|
593
|
+
moveFile(from, to) {
|
|
594
|
+
// Migrations should compute replacements and not write directly.
|
|
595
|
+
throw new Error('DevkitFilesystem#moveFile is not supported.');
|
|
596
|
+
}
|
|
597
|
+
removeDeep(path) {
|
|
598
|
+
// Migrations should compute replacements and not write directly.
|
|
599
|
+
throw new Error('DevkitFilesystem#removeDeep is not supported.');
|
|
600
|
+
}
|
|
601
|
+
chdir(_path) {
|
|
602
|
+
throw new Error('FileSystem#chdir is not supported.');
|
|
603
|
+
}
|
|
604
|
+
symlink() {
|
|
605
|
+
throw new Error('FileSystem#symlink is not supported.');
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
/** Stats the given path in the virtual tree. */
|
|
609
|
+
function statPath(tree, path) {
|
|
610
|
+
let fileInfo = null;
|
|
611
|
+
let dirInfo = null;
|
|
612
|
+
try {
|
|
613
|
+
fileInfo = tree.get(path);
|
|
614
|
+
}
|
|
615
|
+
catch (e) {
|
|
616
|
+
if (e.constructor.name === 'PathIsDirectoryException') {
|
|
617
|
+
dirInfo = tree.getDir(path);
|
|
618
|
+
}
|
|
619
|
+
else {
|
|
620
|
+
throw e;
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (fileInfo !== null || dirInfo !== null) {
|
|
624
|
+
return {
|
|
625
|
+
isDirectory: () => dirInfo !== null,
|
|
626
|
+
isFile: () => fileInfo !== null,
|
|
627
|
+
isSymbolicLink: () => false,
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
return null;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/**
|
|
634
|
+
* Groups the given replacements per project relative
|
|
635
|
+
* file path.
|
|
636
|
+
*
|
|
637
|
+
* This allows for simple execution of the replacements
|
|
638
|
+
* against a given file. E.g. via {@link applyTextUpdates}.
|
|
639
|
+
*/
|
|
640
|
+
function groupReplacementsByFile(replacements) {
|
|
641
|
+
const result = new Map();
|
|
642
|
+
for (const { projectFile, update } of replacements) {
|
|
643
|
+
if (!result.has(projectFile.rootRelativePath)) {
|
|
644
|
+
result.set(projectFile.rootRelativePath, []);
|
|
645
|
+
}
|
|
646
|
+
result.get(projectFile.rootRelativePath).push(update);
|
|
647
|
+
}
|
|
648
|
+
return result;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Synchronously combines unit data for the given migration.
|
|
653
|
+
*
|
|
654
|
+
* Note: This helper is useful for testing and execution of
|
|
655
|
+
* Tsurge migrations in non-batchable environments. In general,
|
|
656
|
+
* prefer parallel execution of combining via e.g. Beam combiners.
|
|
657
|
+
*/
|
|
658
|
+
async function synchronouslyCombineUnitData(migration, unitDatas) {
|
|
659
|
+
if (unitDatas.length === 0) {
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
if (unitDatas.length === 1) {
|
|
663
|
+
return unitDatas[0];
|
|
664
|
+
}
|
|
665
|
+
let combined = unitDatas[0];
|
|
666
|
+
for (let i = 1; i < unitDatas.length; i++) {
|
|
667
|
+
const other = unitDatas[i];
|
|
668
|
+
combined = await migration.combine(combined, other);
|
|
669
|
+
}
|
|
670
|
+
return combined;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/*!
|
|
674
|
+
* @license
|
|
675
|
+
* Copyright Google LLC All Rights Reserved.
|
|
676
|
+
*
|
|
677
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
678
|
+
* found in the LICENSE file at https://angular.dev/license
|
|
679
|
+
*/
|
|
680
|
+
/** Runs a Tsurge within an Angular Devkit context. */
|
|
681
|
+
async function runMigrationInDevkit(config) {
|
|
682
|
+
const { buildPaths, testPaths } = await project_tsconfig_paths.getProjectTsConfigPaths(config.tree);
|
|
683
|
+
if (!buildPaths.length && !testPaths.length) {
|
|
684
|
+
throw new schematics.SchematicsException('Could not find any tsconfig file. Cannot run the migration.');
|
|
685
|
+
}
|
|
686
|
+
const fs = new DevkitMigrationFilesystem(config.tree);
|
|
687
|
+
checker.setFileSystem(fs);
|
|
688
|
+
const migration = config.getMigration(fs);
|
|
689
|
+
const unitResults = [];
|
|
690
|
+
const programInfos = [...buildPaths, ...testPaths].map((tsconfigPath) => {
|
|
691
|
+
config.beforeProgramCreation?.(tsconfigPath);
|
|
692
|
+
const baseInfo = migration.createProgram(tsconfigPath, fs);
|
|
693
|
+
const info = migration.prepareProgram(baseInfo);
|
|
694
|
+
config.afterProgramCreation?.(info, fs);
|
|
695
|
+
return { info, tsconfigPath };
|
|
696
|
+
});
|
|
697
|
+
for (const { info, tsconfigPath } of programInfos) {
|
|
698
|
+
config.beforeUnitAnalysis?.(tsconfigPath);
|
|
699
|
+
unitResults.push(await migration.analyze(info));
|
|
700
|
+
}
|
|
701
|
+
config.afterAllAnalyzed?.();
|
|
702
|
+
const combined = await synchronouslyCombineUnitData(migration, unitResults);
|
|
703
|
+
if (combined === null) {
|
|
704
|
+
config.afterAnalysisFailure?.();
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
const globalMeta = await migration.globalMeta(combined);
|
|
708
|
+
let replacements;
|
|
709
|
+
if (migration instanceof TsurgeFunnelMigration) {
|
|
710
|
+
replacements = (await migration.migrate(globalMeta)).replacements;
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
replacements = [];
|
|
714
|
+
for (const { info } of programInfos) {
|
|
715
|
+
const result = await migration.migrate(globalMeta, info);
|
|
716
|
+
replacements.push(...result.replacements);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
const replacementsPerFile = new Map();
|
|
720
|
+
const changesPerFile = groupReplacementsByFile(replacements);
|
|
721
|
+
for (const [file, changes] of changesPerFile) {
|
|
722
|
+
if (!replacementsPerFile.has(file)) {
|
|
723
|
+
replacementsPerFile.set(file, changes);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
for (const [file, changes] of replacementsPerFile) {
|
|
727
|
+
const recorder = config.tree.beginUpdate(file);
|
|
728
|
+
for (const c of changes) {
|
|
729
|
+
recorder
|
|
730
|
+
.remove(c.data.position, c.data.end - c.data.position)
|
|
731
|
+
.insertRight(c.data.position, c.data.toInsert);
|
|
732
|
+
}
|
|
733
|
+
config.tree.commitUpdate(recorder);
|
|
734
|
+
}
|
|
735
|
+
config.whenDone?.(await migration.stats(globalMeta));
|
|
736
|
+
}
|
|
737
|
+
|
|
672
738
|
exports.Replacement = Replacement;
|
|
673
739
|
exports.TextUpdate = TextUpdate;
|
|
674
740
|
exports.TsurgeComplexMigration = TsurgeComplexMigration;
|
|
675
741
|
exports.TsurgeFunnelMigration = TsurgeFunnelMigration;
|
|
676
742
|
exports.confirmAsSerializable = confirmAsSerializable;
|
|
677
743
|
exports.createBaseProgramInfo = createBaseProgramInfo;
|
|
678
|
-
exports.groupReplacementsByFile = groupReplacementsByFile;
|
|
679
744
|
exports.projectFile = projectFile;
|
|
680
|
-
exports.
|
|
745
|
+
exports.runMigrationInDevkit = runMigrationInDevkit;
|