chore: remove vetur type generator (#7517)
parent
23c620ea3a
commit
48a3ceb921
|
@ -6,7 +6,6 @@ import { genWebTypes } from './web-types';
|
||||||
import { outputFileSync, readFileSync } from 'fs-extra';
|
import { outputFileSync, readFileSync } from 'fs-extra';
|
||||||
import type { Options, VueTag } from './type';
|
import type { Options, VueTag } from './type';
|
||||||
import { getComponentName, normalizePath, toKebabCase } from './utils';
|
import { getComponentName, normalizePath, toKebabCase } from './utils';
|
||||||
import { genVeturAttributes, genVeturTags } from './vetur';
|
|
||||||
import { flatMap } from 'lodash';
|
import { flatMap } from 'lodash';
|
||||||
|
|
||||||
async function readMarkdown(options: Options): Promise<Map<String, VueTag>> {
|
async function readMarkdown(options: Options): Promise<Map<String, VueTag>> {
|
||||||
|
@ -78,13 +77,6 @@ export async function parseAndWrite(options: Options): Promise<Number> {
|
||||||
const tagsFromTypings = await readTypings(options);
|
const tagsFromTypings = await readTypings(options);
|
||||||
const tags = mergeTags([tagsFromMarkdown, tagsFromTypings]);
|
const tags = mergeTags([tagsFromMarkdown, tagsFromTypings]);
|
||||||
const webTypes = genWebTypes(tags, options);
|
const webTypes = genWebTypes(tags, options);
|
||||||
const veturTags = genVeturTags(tags);
|
|
||||||
const veturAttributes = genVeturAttributes(tags);
|
|
||||||
outputFileSync(join(options.outputDir, 'tags.json'), JSON.stringify(veturTags, null, 2));
|
|
||||||
outputFileSync(
|
|
||||||
join(options.outputDir, 'attributes.json'),
|
|
||||||
JSON.stringify(veturAttributes, null, 2),
|
|
||||||
);
|
|
||||||
outputFileSync(join(options.outputDir, 'web-types.json'), JSON.stringify(webTypes, null, 2));
|
outputFileSync(join(options.outputDir, 'web-types.json'), JSON.stringify(webTypes, null, 2));
|
||||||
return tags.length;
|
return tags.length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,25 +34,6 @@ export type VueTag = {
|
||||||
description?: string;
|
description?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type VeturTag = {
|
|
||||||
description?: string;
|
|
||||||
attributes: string[];
|
|
||||||
};
|
|
||||||
|
|
||||||
export type VeturTags = Record<string, VeturTag>;
|
|
||||||
|
|
||||||
export type VeturAttribute = {
|
|
||||||
type: string;
|
|
||||||
description: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type VeturAttributes = Record<string, VeturAttribute>;
|
|
||||||
|
|
||||||
export type VeturResult = {
|
|
||||||
tags: VeturTags;
|
|
||||||
attributes: VeturAttributes;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type Options = {
|
export type Options = {
|
||||||
name: string;
|
name: string;
|
||||||
path: PathLike;
|
path: PathLike;
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
import type { VueTag, VeturTags, VeturAttributes } from './type';
|
|
||||||
|
|
||||||
export function genVeturTags(tags: VueTag[]) {
|
|
||||||
const veturTags: VeturTags = {};
|
|
||||||
|
|
||||||
tags.forEach(tag => {
|
|
||||||
veturTags[tag.name] = {
|
|
||||||
attributes: tag.attributes ? tag.attributes.map(item => item.name) : [],
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return veturTags;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function genVeturAttributes(tags: VueTag[]) {
|
|
||||||
const veturAttributes: VeturAttributes = {};
|
|
||||||
|
|
||||||
tags.forEach(tag => {
|
|
||||||
if (tag.attributes) {
|
|
||||||
tag.attributes.forEach(attr => {
|
|
||||||
veturAttributes[`${tag.name}/${attr.name}`] = {
|
|
||||||
type: attr.value.type,
|
|
||||||
description: `${attr.description}, Default: ${attr.default}`,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return veturAttributes;
|
|
||||||
}
|
|
Loading…
Reference in New Issue