Home > vue-metamorph > findManualMigrations
findManualMigrations() function
Runs manual migration plugins against source code and returns reports identifying nodes that require human attention. Does not modify the code.
Signature:
typescript
export declare function findManualMigrations(code: string, filename: string, plugins: ManualMigrationPlugin[], opts?: Record<string, any>): ManualMigrationReport[];Parameters
Parameter | Type | Description |
|---|---|---|
code | string | Source code string |
filename | string | The file name (determines parser selection) |
plugins | Manual migration plugins to run | |
opts | Record<string, any> | (Optional) Additional options passed through to plugins |
Returns:
Array of reports, each identifying a node and message
Example
ts
import { findManualMigrations, type ManualMigrationPlugin } from 'vue-metamorph';
const plugin: ManualMigrationPlugin = {
type: 'manual',
name: 'find-deprecated-api',
find({ scriptASTs, report, utils: { traverseScriptAST } }) {
for (const ast of scriptASTs) {
traverseScriptAST(ast, {
visitCallExpression(path) {
if (path.node.callee.type === 'Identifier'
&& path.node.callee.name === 'deprecatedFn') {
report(path.node, 'Replace deprecatedFn with newFn');
}
return this.traverse(path);
},
});
}
},
};
const reports = findManualMigrations(code, 'file.vue', [plugin]);
// Each report: { message, file, snippet, pluginName, lineStart, lineEnd, columnStart, columnEnd }