|
1 | 1 | import { glob } from 'fast-glob' |
2 | 2 | import { copyFile, mkdir } from 'fs/promises' |
3 | | -import { dirname, join, relative } from 'path' |
| 3 | +import { join } from 'path' |
4 | 4 |
|
5 | 5 | const buildTypes = async () => { |
6 | | - console.log('🔧 Including restricted-apis type in built files...') |
| 6 | + console.log('🔧 Copying type definition files to dist...') |
7 | 7 |
|
8 | 8 | // Define paths relative to the scripts directory |
9 | 9 | const packageRoot = join(import.meta.dir, '../..') |
10 | | - const sourceFile = join(packageRoot, 'src/sdk/types/restricted-apis.d.ts') |
11 | | - const destFile = join(packageRoot, 'dist/restricted-apis.d.ts') |
| 10 | + const sourceDir = join(packageRoot, 'src/sdk/types') |
| 11 | + const destDir = join(packageRoot, 'dist/sdk/types') |
12 | 12 |
|
13 | | - // Ensure the dist directory exists |
14 | | - await mkdir(dirname(destFile), { recursive: true }) |
| 13 | + // Ensure the destination directory exists |
| 14 | + await mkdir(destDir, { recursive: true }) |
15 | 15 |
|
16 | | - // Copy the file |
17 | | - await copyFile(sourceFile, destFile) |
| 16 | + // Find all .d.ts files in the source directory |
| 17 | + const typeFiles = await glob('*.d.ts', { |
| 18 | + cwd: sourceDir, |
| 19 | + absolute: false, |
| 20 | + }) |
18 | 21 |
|
19 | | - console.log('✅ Included restricted-apis type in the build.') |
| 22 | + // Copy each file |
| 23 | + for (const file of typeFiles) { |
| 24 | + const sourceFile = join(sourceDir, file) |
| 25 | + const destFile = join(destDir, file) |
| 26 | + await copyFile(sourceFile, destFile) |
| 27 | + console.log(` ✓ Copied ${file}`) |
| 28 | + } |
| 29 | + |
| 30 | + console.log(`✅ Copied ${typeFiles.length} type definition file(s) to dist/sdk/types`) |
20 | 31 | } |
21 | 32 |
|
22 | 33 | export const main = buildTypes |
0 commit comments