mirror of
https://github.com/shoelace-style/webawesome.git
synced 2026-01-12 04:09:12 +00:00
add cem-custom-data-generator
This commit is contained in:
@@ -28,7 +28,6 @@ fs.mkdirSync(outdir, { recursive: true });
|
||||
execSync(`node scripts/make-metadata.js --outdir "${outdir}"`, { stdio: 'inherit' });
|
||||
execSync(`node scripts/make-search.js --outdir "${outdir}"`, { stdio: 'inherit' });
|
||||
execSync(`node scripts/make-react.js --outdir "${outdir}"`, { stdio: 'inherit' });
|
||||
execSync(`node scripts/make-vscode-data.js --outdir "${outdir}"`, { stdio: 'inherit' });
|
||||
execSync(`node scripts/make-web-types.js --outdir "${outdir}"`, { stdio: 'inherit' });
|
||||
execSync(`node scripts/make-themes.js --outdir "${outdir}"`, { stdio: 'inherit' });
|
||||
execSync(`node scripts/make-icons.js --outdir "${outdir}"`, { stdio: 'inherit' });
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
//
|
||||
// This script generates vscode.html-custom-data.json (for IntelliSense).
|
||||
//
|
||||
// You must generate dist/custom-elements.json before running this script.
|
||||
//
|
||||
import commandLineArgs from 'command-line-args';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { getAllComponents } from './shared.js';
|
||||
|
||||
const { outdir } = commandLineArgs({ name: 'outdir', type: String });
|
||||
const metadata = JSON.parse(fs.readFileSync(path.join(outdir, 'custom-elements.json'), 'utf8'));
|
||||
|
||||
console.log('Generating custom data for VS Code');
|
||||
|
||||
const components = getAllComponents(metadata);
|
||||
const vscode = { tags: [] };
|
||||
|
||||
components.map(component => {
|
||||
const name = component.tagName;
|
||||
const attributes = component.attributes?.map(attr => {
|
||||
const type = attr.type?.text;
|
||||
let values = [];
|
||||
|
||||
if (type) {
|
||||
type.split('|').map(val => {
|
||||
val = val.trim();
|
||||
|
||||
// Only accept values that are strings and numbers
|
||||
const isString = val.startsWith(`'`);
|
||||
const isNumber = Number(val).toString() === val;
|
||||
|
||||
if (isString) {
|
||||
// Remove quotes
|
||||
val = val.replace(/^'/, '').replace(/'$/, '');
|
||||
}
|
||||
|
||||
if (isNumber || isString) {
|
||||
values.push({ name: val });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (values.length === 0) {
|
||||
values = undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
name: attr.name,
|
||||
description: attr.description,
|
||||
values
|
||||
};
|
||||
});
|
||||
|
||||
vscode.tags.push({ name, attributes });
|
||||
});
|
||||
|
||||
fs.writeFileSync(path.join(outdir, 'vscode.html-custom-data.json'), JSON.stringify(vscode, null, 2), 'utf8');
|
||||
Reference in New Issue
Block a user