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

add watch option #73

Closed
derberg opened this issue Sep 20, 2021 · 11 comments
Closed

add watch option #73

derberg opened this issue Sep 20, 2021 · 11 comments
Labels
enhancement New feature or request

Comments

@derberg
Copy link
Member

derberg commented Sep 20, 2021

Reason/Context

We need native way for watching AsyncAPI resource and reiterate given command on it. So basically asyncapi validate -w works in a way that whenever users introduce change in a file, validation runs on it again without invoking it.

sure user can now just install watcher like brew install watch and do watch asyncapi validate, but this should be considered as a temporary workaround that is not a good UX.

Description

When working on this functionality we need to look on current functionality on Generator CLI and its current issues, to fix them here in the CLI -> asyncapi/generator#537 (comment)

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Jan 19, 2022
@derberg derberg removed the stale label Jan 19, 2022
@imabp
Copy link
Member

imabp commented Jan 31, 2022

We need native way for watching AsyncAPI resource...

@derberg Do you mean Native as the NodeJS Runtime or based on operating system?

  • If NodeJS Runtime, an oclif hook is required to watch over the file and run the command using nodejs built in module fs. here

Would like to take up this issue :)

@imabp
Copy link
Member

imabp commented Feb 6, 2022

A question @derberg
Do we need watch option as a global flag, or specific to validate ?

@derberg
Copy link
Member Author

derberg commented Feb 7, 2022

best would be if it is global but that you need to enable it for given command 😄

so validate, diff, should have it, but new, start not really. So would be awesome to have it generic in a sense that when we add new generate command, we easily enable watch for it

@derberg
Copy link
Member Author

derberg commented Feb 8, 2022

we already do some watching here

chokidar.watch(filePath).on('all', (event, path) => {
.

so it is a matter of making a global function that can be reused by a command that needs it

@imabp
Copy link
Member

imabp commented Feb 8, 2022

That means the flow goes like this 👇

  1. Create a global function for watch using chokidar
  2. Conditional check --watch flag
  3. If conditional check is true run the global function.

Correct me, if somewhere missing any point

@imabp
Copy link
Member

imabp commented Feb 8, 2022

@derberg please review, #220
Relax and watch specification files 🍻
image

@imabp
Copy link
Member

imabp commented Feb 9, 2022

@derberg The watcher PR is ready to review: #220

I got a bit in stuck moment when writing test for --watch flag using Mocha, @fmvilas because

  • Mocha is unable to close the stream once the test is completed, (as watch mode works in stream), hence npm run test runs for indefinite period of time.

Need some solutions on how do we approach it? Mocking Streams or any other way ?

@derberg
Copy link
Member Author

derberg commented Feb 9, 2022

tbh I'm not sure, I would first try to check if chokidar community figured it out already, maybe something is already in their issues, or you can check others that use chokidar and how they solved testing. I would go first this direction to see how others tacked it

@imabp
Copy link
Member

imabp commented Feb 21, 2022

@derberg, we can close this issue, as #220 is merged :)

@derberg
Copy link
Member Author

derberg commented Mar 1, 2022

@imabp well done 👏🏼

@derberg derberg closed this as completed Mar 1, 2022
@imabp imabp mentioned this issue Mar 5, 2022
16 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants