Skip to content

Commit 93308d8

Browse files
generate types package.json
1 parent a029afe commit 93308d8

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

.github/workflows/types.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,39 @@ jobs:
2727
- name: Build types
2828
run: npm run build:types
2929

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+
3063
- name: Deploy to 'types' branch
3164
uses: JamesIves/github-pages-deploy-action@v4
3265
with:

0 commit comments

Comments
 (0)