sina-meta-serialize
A tool to serilize classes in vue files and can be used for designer. All processes are in compiling stage.
Usage
To serialize dozens of vue files:
const customSerializeVueFiles = ;const fs = ;const path = ;const glob = ; const config: CustomSerializerConfig = serializeDecoratorNameList: "Component" "Prop" "Inject" "Design" entryDecoratorFilters: "Component" withSinaFormatTransformer: true serializeType: "component"; { const output = ; fs;} ;
Or you can just pass a directory to a export function customSerializeVueByDirectory
:
const customSerializeVueByDirectory = ;const fs = ;const path = ;const config = serializeDecoratorNameList: "SComponent" "Design" "dataType" entryDecoratorFilters: "SComponent" withSinaFormatTransformer: true serializeType: "component"; ; { const output = await ; fs;}
If you are serializing a page (not component), you should use:
const customSerializeVueByDirectory = ;const fs = ;const path = ; const config = serializeDecoratorNameList: "Spage" "Design" "dataType" entryDecoratorFilters: "Spage" withSinaFormatTransformer: true viewDirname: "taskEnvelop" serializeType: "page"; ; { const output = await ; fs;}
The serializeType
indicates type of this serialization, it can be either "page"
or "component"
, and you should also offer a viewDirname
property to tell which child folder the serialization excutes if you are serializing a page.
Interface
customSerializeVueByDirectory(path, config)
accept a directory path and process all vue files in it. Parameter path
is the location of target directory. Parameter config
is some configuration to specify serialization functions.
config
includes:
-
serializeDecoratorNameList: Accept a string array to specify decorators which should be serialized.
-
entryDecoratorFilters: Accept a string array to define decorators which entry class should be decorated by. Only classes with those decorators will be serialized.
-
withSinaFormatTransformer: Accept a boolean. If this is
true
then the output will be transformed into format sina desire. Otherwise it will be normal format. -
serializeType: Accept a string. Can be
"component"
or"page"
. -
viewDirname: Accept a string. If the
serializeType
is set to"page"
, then this config should be provided to indicate which child folder to be serialized.