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

refactor: updated and decoupled contextService logic #72

Merged
merged 6 commits into from
Sep 22, 2021
Merged

refactor: updated and decoupled contextService logic #72

merged 6 commits into from
Sep 22, 2021

Conversation

Souvikns
Copy link
Member

Description
This is the start of the process to move the context commands under config. In this PR I have focused on updating the contextService because of the issue discussed here. I would like to clarify what I have done here.

  • I have recreated context service but this time decoupling as much as possible.
  • Context does a good job to support the validate command as it needs only one spec file path. But to support libraries like cupid and diff where more than one spec file path is needed context shall evolve as well. For that, I have created a separate IContext interface that could be easily updated.
  • To support the future ambition of loading context files from the root directory and to be sharable I have created a separate class ContextAllocator to load context files accordingly. For now, it is loading the context file from the root file itself. This also helps in testing allowing us to create mock classes to check functionalities.
  • Now ContextService does not throw an error if the contextFile is not present in the root dir instead it loads undefined context.

Related issue(s)

See also #38 and #37

Copy link
Member

@magicmatatjahu magicmatatjahu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good, but I have problem with IContextAllocator idea and implemenation.

src/config/context/model.ts Outdated Show resolved Hide resolved
src/config/context/model.ts Outdated Show resolved Hide resolved
src/config/context/model.ts Outdated Show resolved Hide resolved
Copy link
Member

@magicmatatjahu magicmatatjahu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall good, only this problem with console.warn Please wait for Łukasz. We'll see what he says.

Please also change the title of PR to the chore: or refactor: because as I see, you didn't use new services in source code, but only define it, so it's not feat/fix :)

src/config/context/model.ts Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Sep 21, 2021

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@derberg
Copy link
Member

derberg commented Sep 22, 2021

I see that @magicmatatjahu reviews, so no need to wait for me with approval as it is pure refactor.

also, if it is pure refactor, nothing touching the functionality, this should not trigger a release but be a refactor: commit

@magicmatatjahu
Copy link
Member

@Souvikns Please change title and merge commit with refactor: prefix.

@Souvikns Souvikns changed the title feat: updated and decoupled contextService logic refactor: updated and decoupled contextService logic Sep 22, 2021
@Souvikns Souvikns merged commit cdc2294 into asyncapi:context-patch Sep 22, 2021
Souvikns added a commit that referenced this pull request Oct 5, 2021
* feat: updated and decoupled contextService logic

* feat: creating new context when root context file is missing.

* feat: removed registry & stringify issue

* chore: returning context or undefined in contextAllocator save method

* feat: added warning for saving file.

* feat: lint fixes
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.

3 participants