Skip to content

Commit b700393

Browse files
committed
feat: Modified the build script to build a metadata.json
1 parent e0d498c commit b700393

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

scripts/build.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,17 @@ const { resourceDefinitions } = initializeResult;
6363
const resourceTypes = resourceDefinitions.map((i) => i.type);
6464

6565
const schemasMap = new Map<string, JSONSchema>()
66+
const metadataList: Record<string, unknown>[] = [];
6667
for (const type of resourceTypes) {
6768
const resourceInfo = await sendMessageAndAwaitResponse(plugin, {
6869
cmd: 'getResourceInfo',
6970
data: { type }
7071
})
7172

7273
schemasMap.set(type, resourceInfo.schema);
74+
75+
const { schema: _schema, ...metadataWithoutSchema } = resourceInfo;
76+
metadataList.push(metadataWithoutSchema);
7377
}
7478

7579
const mergedSchemas = [...schemasMap.entries()].map(([type, schema]) => {
@@ -117,6 +121,10 @@ fs.writeFileSync(schemaOutputPath, JSON.stringify(codifySchema, null, 2));
117121

118122
console.log('Successfully wrote schema to ./dist/schemas.json')
119123

124+
const metadataOutputPath = path.resolve(distFolder, 'metadata.json');
125+
fs.writeFileSync(metadataOutputPath, JSON.stringify(metadataList, null, 2));
126+
console.log('Successfully wrote metadata to ./dist/metadata.json')
127+
120128

121129
plugin.kill(9);
122130
process.exit(0);

0 commit comments

Comments
 (0)