@@ -128,12 +128,17 @@ async function run() {
128
128
}
129
129
130
130
let schemasCode = "" ;
131
+ let schemasTypes = "" ;
131
132
132
133
for ( const name of schemaFileNames ) {
133
134
schemasCode += `["${ name . replace (
134
135
".json" ,
135
136
"" ,
136
- ) } "]: require("./generated/${ name } "),`;
137
+ ) } "]: (await import("./generated/${ name } ", { with: { type: "json" } })).default,`;
138
+ schemasTypes += `"${ name . replace (
139
+ ".json" ,
140
+ "" ,
141
+ ) } ": Record<string, unknown>;`;
137
142
}
138
143
139
144
writeFileSync (
@@ -149,17 +154,26 @@ They are all generated, your changes would be overwritten with the next update.
149
154
"packages/openapi-webhooks/index.js" ,
150
155
await prettier . format (
151
156
`
152
- module.exports = {
153
- schemas: {
154
- ${ schemasCode }
155
- }
157
+ export const schemas = {
158
+ ${ schemasCode }
156
159
}
157
160
` ,
158
161
{
159
162
parser : "babel" ,
160
163
} ,
161
164
) ,
162
165
) ;
166
+ writeFileSync ( `packages/openapi-webhooks/types.d.ts` , await prettier . format (
167
+ `
168
+ export declare const schemas: {
169
+ ${ schemasTypes }
170
+ }
171
+ ` ,
172
+ {
173
+ parser : "typescript" ,
174
+ } ,
175
+ )
176
+ ) ;
163
177
writeFileSync (
164
178
`packages/openapi-webhooks/package.json` ,
165
179
await prettier . format (
@@ -170,7 +184,7 @@ They are all generated, your changes would be overwritten with the next update.
170
184
"GitHub's official Webhooks OpenAPI spec with Octokit extensions" ,
171
185
main : "index.js" ,
172
186
files : [ "generated/*" , "index.js" ] ,
173
- type : "commonjs " ,
187
+ type : "module " ,
174
188
repository : {
175
189
type : "git" ,
176
190
url : "git+https://github.com/octokit/openapi-webhooks.git" ,
@@ -183,6 +197,9 @@ They are all generated, your changes would be overwritten with the next update.
183
197
access : "public" ,
184
198
provenance : true ,
185
199
} ,
200
+ engines : {
201
+ node : "^18.20.0 || >= 20.10.0" ,
202
+ }
186
203
} ) ,
187
204
{ parser : "json-stringify" } ,
188
205
) ,
0 commit comments