2.1.0 • Published 5 years ago

sina-meta-serialize v2.1.0

Weekly downloads
84
License
-
Repository
-
Last release
5 years ago

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,
} = require("sina-meta-serialize");
const fs = require("fs");
const path = require("path");
const glob = require("glob");

const config: CustomSerializerConfig = {
  serializeDecoratorNameList: ["Component", "Prop", "Inject", "Design"],
  entryDecoratorFilters: ["Component"],
  withSinaFormatTransformer: true
};

function main() {
  const output = customSerializeVueFiles(["./src/index.vue", "./src/card.vue"], config);
  fs.writeFileSync("classes.json", JSON.stringify(output, undefined, 2));
}

main()

Or you can just pass a directory to a export function customSerializeVueByDirectory:

const { customSerializeVueByDirectory } = require("sina-meta-serialize");
const fs = require("fs");
const path = require("path")
const config = {
  serializeDecoratorNameList: [
    "SComponent",
    "Design",
    "dataType"
  ],
  entryDecoratorFilters: ["SComponent"],
  withSinaFormatTransformer: true
};

main();

async function main() {
  const output = await customSerializeVueByDirectory(path.join(__dirname, "./src"), config);
  fs.writeFileSync("./result.json", JSON.stringify(output, undefined, 2));
}

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.

2.1.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.4.0-alpha.0

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.5

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago