libs/ngx-pfe/schematics/ng-update/v51-input-signal-reads/manual-review.ts
A place the migration left untouched because there is no safe mechanical rewrite.
Properties |
| file |
file:
|
Type : string
|
|
The file, or the component |
| line |
line:
|
Type : number
|
|
1-based. |
| reason |
reason:
|
Type : string
|
| snippet |
snippet:
|
Type : string
|
export interface ManualReviewItem {
/** The file, or the component `.ts` for an inline template. */
file: string;
/** 1-based. */
line: number;
snippet: string;
reason: string;
}
export type ReportSink = (message: string) => void;
export function reportManualReviewItems(items: ManualReviewItem[], report: ReportSink): void {
if (items.length === 0) return;
const seen = new Set<string>();
const byFile = new Map<string, ManualReviewItem[]>();
for (const item of items) {
const key = `${item.file}:${item.line}:${item.reason}`;
if (seen.has(key)) continue;
seen.add(key);
const bucket = byFile.get(item.file) ?? [];
bucket.push(item);
byFile.set(item.file, bucket);
}
const lines: string[] = [
'',
`The input-signal-reads migration left ${seen.size} location(s) unchanged because`,
'they cannot be migrated automatically. Please review and update them manually:',
'',
];
for (const [file, fileItems] of byFile) {
lines.push(` ${file}`);
for (const item of fileItems.sort((a, b) => a.line - b.line)) {
lines.push(` L${item.line} ${item.snippet}`);
lines.push(` ↳ ${item.reason}`);
}
lines.push('');
}
report(lines.join('\n'));
}
export function toSnippet(text: string): string {
return text.replace(/\s+/g, ' ').trim();
}