Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Generate projects, even if project don't have any components. Improved UIDL validations for root and component UIDL #500

Merged
merged 2 commits into from
Nov 5, 2020

Conversation

JayaKrishnaNamburu
Copy link
Member

@JayaKrishnaNamburu JayaKrishnaNamburu commented Nov 5, 2020

#487

We use ComponentUIDL to carry out all operations needs for generating components. But we use the ComponentUIDL for maintaining root in ProjectUIDL. But there are slight changes needed in order to validate.

Root Component UIDL

  • name
  • node
  • propDefinitions
  • stateDefinitions
  • importDefinitions
  • peerDefinitions
  • styleSetDefinitions
  • outputOptions
  • seo

Component UIDL

  • name
  • node
  • propDefinitions
  • stateDefinitions
  • importDefinitions
  • outputOptions
  • seo

In root the stateDefinitions are not optional but in component they are optional. Since in root we need them to construct routes. So, ti handle this unique validations no we have two diff validators for components. componentUIDLValidator and rootComponentUIDLValidator.

By default the @teleporthq/teleport-component-generator uses componentUIDLValidator unless a flag is explicitly passed to use rootComponentValidator.

Like this

const result = await generator.generateProject(uidl, { isRootComponent: true})

When this flag is passed, it starts to validate the component using rootComponentValidator. This is automatically handled by our project generators while validating a project.

  • A small bug-fix to generate projects even when components are not used and defined in the projectUIDL

@JayaKrishnaNamburu JayaKrishnaNamburu linked an issue Nov 5, 2020 that may be closed by this pull request
@JayaKrishnaNamburu JayaKrishnaNamburu added this to the 0.15 milestone Nov 5, 2020
@codecov
Copy link

codecov bot commented Nov 5, 2020

Codecov Report

Merging #500 into development will decrease coverage by 0.04%.
The diff coverage is 79.41%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development     #500      +/-   ##
===============================================
- Coverage        76.87%   76.83%   -0.05%     
===============================================
  Files              156      156              
  Lines             5527     5542      +15     
  Branches          1232     1237       +5     
===============================================
+ Hits              4249     4258       +9     
- Misses            1210     1215       +5     
- Partials            68       69       +1     
Impacted Files Coverage Δ
...ages/teleport-uidl-validator/src/decoders/utils.ts 96.29% <ø> (ø)
...ges/teleport-uidl-validator/src/validator/index.ts 88.37% <28.57%> (-11.63%) ⬇️
packages/teleport-component-generator/src/index.ts 89.06% <66.66%> (-1.27%) ⬇️
packages/teleport-project-generator/src/index.ts 64.41% <85.71%> (+0.21%) ⬆️
...es/teleport-project-generator/src/file-handlers.ts 78.20% <100.00%> (ø)
...t-uidl-validator/src/decoders/component-decoder.ts 100.00% <100.00%> (ø)
...ages/teleport-uidl-validator/src/decoders/index.ts 100.00% <100.00%> (ø)
...ort-uidl-validator/src/decoders/project-decoder.ts 100.00% <100.00%> (ø)
packages/teleport-uidl-validator/src/index.ts 100.00% <100.00%> (ø)
...ges/teleport-uidl-validator/src/validator/utils.ts 80.14% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d3a3677...ee8f248. Read the comment docs.

@JayaKrishnaNamburu JayaKrishnaNamburu merged commit 45b2775 into development Nov 5, 2020
@JayaKrishnaNamburu JayaKrishnaNamburu changed the title Refactor: Generate projects even if project don't have any components, And improved UIDL validations for root and component UIDL Refactor: Generate projects, even if project don't have any components. Improved UIDL validations for root and component UIDL Nov 6, 2020
@JayaKrishnaNamburu JayaKrishnaNamburu changed the title Refactor: Generate projects, even if project don't have any components. Improved UIDL validations for root and component UIDL Bug: Generate projects, even if project don't have any components. Improved UIDL validations for root and component UIDL Nov 6, 2020
@JayaKrishnaNamburu JayaKrishnaNamburu deleted the refactor/uidl-validatons branch March 10, 2021 17:06
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.

ProjectValidator fails if there are no components
1 participant