(pkg: string, name: string)
| 21 | const DIR_TYPES = resolve(__dirname, '../types/packages') |
| 22 | |
| 23 | export async function getTypeDefinition(pkg: string, name: string): Promise<string | undefined> { |
| 24 | const typingFilepath = join(DIR_TYPES, `${pkg}/${name}/index.d.ts`) |
| 25 | |
| 26 | if (!existsSync(typingFilepath)) |
| 27 | return |
| 28 | |
| 29 | let types = await fs.readFile(typingFilepath, 'utf-8') |
| 30 | |
| 31 | if (!types) |
| 32 | return |
| 33 | |
| 34 | // clean up types |
| 35 | types = types |
| 36 | .replace(/import\(.*?\)\./g, '') |
| 37 | .replace(/import[\s\S]+?from ?["'][\s\S]+?["']/g, '') |
| 38 | .replace(/export \{\}/g, '') |
| 39 | |
| 40 | const prettier = await import('prettier') |
| 41 | return (await prettier |
| 42 | .format( |
| 43 | types, |
| 44 | { |
| 45 | semi: false, |
| 46 | parser: 'typescript', |
| 47 | }, |
| 48 | )) |
| 49 | .trim() |
| 50 | } |
| 51 | |
| 52 | export async function updateImport({ packages, functions }: PackageIndexes) { |
| 53 | for (const { name, dir, manualImport } of Object.values(packages)) { |
nothing calls this directly
no outgoing calls
no test coverage detected