|
27 | 27 | - name: Build types |
28 | 28 | run: npm run build:types |
29 | 29 |
|
| 30 | + - name: Generate package.json |
| 31 | + run: | |
| 32 | + node -e " |
| 33 | + const fs = require('fs'); |
| 34 | + const rootPkg = require('./package.json'); |
| 35 | + |
| 36 | + // Define the package.json for the 'types' branch |
| 37 | + // It reuses many fields from the root package.json |
| 38 | + const typesPkg = { |
| 39 | + name: rootPkg.name, |
| 40 | + version: rootPkg.version, |
| 41 | + description: rootPkg.description ? `${rootPkg.description} (Types-only branch)` : `Types for ${rootPkg.name}`, |
| 42 | + main: 'index.js', |
| 43 | + types: 'index.d.ts', // Assumes 'index.d.ts' is the main entry point in your 'types' dir |
| 44 | + repository: rootPkg.repository, |
| 45 | + author: rootPkg.author, |
| 46 | + license: rootPkg.license, |
| 47 | + keywords: rootPkg.keywords, |
| 48 | + bugs: rootPkg.bugs, |
| 49 | + homepage: rootPkg.homepage |
| 50 | + }; |
| 51 | + |
| 52 | + // Write the new package.json into the 'types' directory |
| 53 | + fs.writeFileSync('./types/package.json', JSON.stringify(typesPkg, null, 2)); |
| 54 | + console.log('Generated package.json in ./types/package.json'); |
| 55 | + |
| 56 | + // Optional: Create a dummy index.js to satisfy the 'main' field |
| 57 | + if (!fs.existsSync('./types/index.js')) { |
| 58 | + fs.writeFileSync('./types/index.js', '// This file is intentionally blank. See package.json for types entry point.\n'); |
| 59 | + console.log('Created dummy ./types/index.js'); |
| 60 | + } |
| 61 | + " |
| 62 | +
|
30 | 63 | - name: Deploy to 'types' branch |
31 | 64 | uses: JamesIves/github-pages-deploy-action@v4 |
32 | 65 | with: |
|
0 commit comments