Skip to content

feat(cli): lb4 repository implementation#1659

Merged
marioestradarosa merged 6 commits into
loopbackio:masterfrom
marioestradarosa:feat-add-lb-repository
Sep 19, 2018
Merged

feat(cli): lb4 repository implementation#1659
marioestradarosa merged 6 commits into
loopbackio:masterfrom
marioestradarosa:feat-add-lb-repository

Conversation

@marioestradarosa

@marioestradarosa marioestradarosa commented Aug 30, 2018

Copy link
Copy Markdown
Contributor

Done

  • Filtering out the soap and rest connectors from the data source list
  • Inferring the repository class (KV or CRUD) based on the connector property for JSON datasource
  • Allow multiple selection of models
  • Infers the id property name from the model Class based on 3 scenarios
    • The current template generated by lb4 model command
    • A JSON object inside the @model decorator
    • A JSON definition inside the class model
  • Prompts for the property name in case the infer process couldn't find the primary key property
  • Currently it is generating the repository based on the two repository types (KV or CRUD)
  • support for --config is inherited from the base generators
  • properly display an error message if it can't fine a src/datasources or src/models directory
  • Add basic documentation for the feature
  • Use name argument as the repository name
  • add shared functions in utils to define the path and artifact names for repositories and datasources
  • fixed lib/ArtifactGenerator to support multiple index files

Command line feature

  • Now we can supply the arguments from the command line. The arguments are checked against all the artifacts implemented already (ie: id inferring list, datasource list, model list) and if not valid, it falls back to the prompt.

Syntax: Use them interchangeably
lb4 repository name --datasource --model --id

Example:
lb4 repository --datasource dbmem --model=pluto --id=IDPK

It will generate the repository for pluto with id property name IDPK. It is checked if dbmem is a valid datasource, pluto (changed to Pluto) is a valid model and if its id can't be inferred then it falls back to use the id argument supplied. All validations are performed against the list of artifacts already loaded form their respective directories.

Test Status

  • Test on Default generated models using CRUD connector
  • Test on models defined by @model decorator using CRUD connector
  • Test on Default generated models using KV connector
  • Test on models defined by @model decorator using KV connector
  • Test on failing providing or selecting a model.
    • at this point the user should have selected a valid datasource, otherwise this point will never get reached
  • Test on multi-word models
  • Test on command line interface --model --id from a none-id inferred model file
  • Test failing when the datasource list is empty.
    • the datasources are not KV or CRUD, and thus it returns an empty list
    • or the datasource directory is empty
  • Add test for supporting config file
  • Add test for support of name argument
  • Add test for multiple repository generation

Preconditions checked

check the following directories in this order

  • check if the src/datasources exists, displaying an approriate error
  • check if the src/models exists

Implements #1588

Checklist

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants