leancloud-auto
v1.1.1
Published
Automatically generate LeanCloud classes and docs from schema definition.
Downloads
2
Readme
leancloud-auto
Automatically generate LeanCloud
classes and docs from schema definition.
Which make it easy to migrate to LeanCloud from other data source.
Install
# use yarn
$ yarn global add leancloud-auto
# or use npm
$ npm install -g leancloud-auto
Usage
There are something that to be explained firstly, the following docs use the keywords Schema
and Class
, which are both referred to LeanCloud Class. It is called Class
in cloud, while called Schema
at local.
Generate classes from a local schema file
leanauto init -i appId -k appKey -m masterKey ./schema.json
This command will first create some classes which defined in file schema.json
. Then compare the generated schema with the local schema and tell you whether they are perfectly matched.
Feel free to use this command, it would not delete your original schema or data. But you should make sure that the same schema not exists when runing this command, otherwise your original schema would be dirted.
Generate docs from local schemas or cloud schemas
# from cloud schema
leanauto doc -i appId -k appKey -m masterKey -o ./structure.html
# from local schema
leanauto doc ./schema.json -o ./structure.html
This command will generate documents of the specified schema, representing as HTML
tables. Open it in browser then have a look.
If not specify the -o
option, it will print the markdown style string in terminal instead of writing to a HTML file.
Generate GraphQL
language schema
leanauto graphql ./schema.json -d ./graphql
This command will generate some files named {{className}}.js, which could simply integrate with GraphQL by another tool egg-graphql.
Test
See test/test.js.