-
Notifications
You must be signed in to change notification settings - Fork 770
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(): generate experimental web-components.json (#1256)
- Loading branch information
1 parent
a7d5e3a
commit 8924561
Showing
3 changed files
with
31 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import * as d from '../../declarations'; | ||
import { WEB_COMPONENTS_JSON_FILE_NAME } from '../../util/constants'; | ||
import { normalizePath } from '../util'; | ||
|
||
export async function generateWebComponentsJson(config: d.Config, compilerCtx: d.CompilerCtx, distOutputs: d.OutputTargetDist[], docsData: d.JsonDocs) { | ||
const json = { | ||
'tags': docsData.components.map(cmp => ({ | ||
'label': cmp.tag, | ||
'description': cmp.readme, | ||
'attributes': cmp.props.filter(p => p.attr).map(p => ({ | ||
'label': p.attr, | ||
'description': p.docs, | ||
'required': p.required | ||
})) | ||
})) | ||
}; | ||
const jsonContent = JSON.stringify(json, null, 2); | ||
await Promise.all(distOutputs.map(async distOutput => { | ||
const filePath = normalizePath(config.sys.path.join(distOutput.buildDir, WEB_COMPONENTS_JSON_FILE_NAME)); | ||
await compilerCtx.fs.writeFile(filePath, jsonContent); | ||
})); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters