|
| 1 | +let nodeContent = `` |
| 2 | + |
| 3 | +// nodeContent += await readFile( |
| 4 | +// kitPath("node_modules/@types/node/process.d.ts"), |
| 5 | +// "utf8" |
| 6 | +// ) |
| 7 | + |
| 8 | +// nodeContent += await readFile( |
| 9 | +// kitPath("node_modules/@types/node/child_process.d.ts"), |
| 10 | +// "utf8" |
| 11 | +// ) |
| 12 | + |
| 13 | +// let nodeTypesDir = path.resolve( |
| 14 | +// "node_modules", |
| 15 | +// "@types", |
| 16 | +// "node" |
| 17 | +// ) |
| 18 | +// let nodeTypeFiles = (await readdir(nodeTypesDir)).filter( |
| 19 | +// f => f.endsWith(".d.ts") |
| 20 | +// ) |
| 21 | + |
| 22 | +// for (let file of nodeTypeFiles) { |
| 23 | +// nodeContent += await readFile( |
| 24 | +// path.resolve(nodeTypesDir, file), |
| 25 | +// "utf8" |
| 26 | +// ) |
| 27 | +// } |
| 28 | + |
| 29 | +// nodeContent = nodeContent.replace( |
| 30 | +// /declare module '(\w+)'/g, |
| 31 | +// "declare module $1" |
| 32 | +// ) |
| 33 | + |
| 34 | +let kitContent = `` |
| 35 | + |
| 36 | +// exclude itself 😇 |
| 37 | + |
| 38 | +let defs = ( |
| 39 | + await readdir(path.resolve("src", "types")) |
| 40 | +).filter(f => !f.includes("kit-editor")) |
| 41 | + |
| 42 | +console.log(defs) |
| 43 | + |
| 44 | +for (let def of defs) { |
| 45 | + kitContent += await readFile( |
| 46 | + path.resolve("src", "types", def), |
| 47 | + "utf8" |
| 48 | + ) |
| 49 | +} |
| 50 | + |
| 51 | +let globalTypesDir = path.resolve( |
| 52 | + "node_modules", |
| 53 | + "@johnlindquist", |
| 54 | + "globals", |
| 55 | + "types" |
| 56 | +) |
| 57 | + |
| 58 | +let globalTypeDirs = (await readdir(globalTypesDir)).filter( |
| 59 | + dir => !dir.endsWith(".ts") |
| 60 | +) |
| 61 | + |
| 62 | +console.log(globalTypeDirs) |
| 63 | + |
| 64 | +// GlobalsAPI |
| 65 | +kitContent += await readFile( |
| 66 | + path.resolve(globalTypesDir, "index.d.ts"), |
| 67 | + "utf8" |
| 68 | +) |
| 69 | + |
| 70 | +// content = `declare module '@johnlindquist/kit' { |
| 71 | + |
| 72 | +// ${content} |
| 73 | + |
| 74 | +// }` |
| 75 | + |
| 76 | +kitContent = kitContent.replace( |
| 77 | + /import {(.|\n)*?} from ".*?"/gim, |
| 78 | + "" |
| 79 | +) |
| 80 | + |
| 81 | +kitContent = kitContent.replace(/export {(.|\n)*?}/gim, "") |
| 82 | + |
| 83 | +await writeFile( |
| 84 | + "./src/types/kit-editor.d.ts", |
| 85 | + nodeContent + kitContent, |
| 86 | + "utf8" |
| 87 | +) |
| 88 | + |
| 89 | +export {} |
0 commit comments