-
Notifications
You must be signed in to change notification settings - Fork 19
/
index.ts
22 lines (19 loc) · 831 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { nonNullable } from '@wakaru/shared/array'
import { executeTransformationRules } from '@wakaru/shared/runner'
import { transformationRules } from './transformations'
import type { FileInfo } from 'jscodeshift'
export * from './transformations'
export function runDefaultTransformationRules<P extends Record<string, any>>(
fileInfo: FileInfo,
params: P = {} as any,
) {
return executeTransformationRules(fileInfo.source, fileInfo.path, transformationRules, params)
}
export function runTransformationRules<P extends Record<string, any>>(
fileInfo: FileInfo,
ruleIds: string[],
params: P = {} as any,
) {
const rules = ruleIds.map(id => transformationRules.find(rule => rule.id === id)).filter(nonNullable)
return executeTransformationRules(fileInfo.source, fileInfo.path, rules, params)
}