Skip to content

add watch option #73

Closed
Closed

Description

@derberg

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)

Activity

  1. added
    enhancement
    on Sep 20, 2021
  2. github-actions commented on Jan 19, 2022

    @github-actions
    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 ❤️

  3. imabp commented on Jan 31, 2022

    @imabp
    Contributor

    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 :)

  4. imabp commented on Feb 6, 2022

    @imabp
    Contributor

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

  5. derberg commented on Feb 7, 2022

    @derberg
    MemberAuthor

    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

  6. derberg commented on Feb 8, 2022

    @derberg
    MemberAuthor

    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

  7. imabp commented on Feb 8, 2022

    @imabp
    Contributor

    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

  8. imabp commented on Feb 8, 2022

    @imabp
    Contributor

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

  9. imabp commented on Feb 9, 2022

    @imabp
    Contributor

    @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 ?

  10. derberg commented on Feb 9, 2022

    @derberg
    MemberAuthor

    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

  11. imabp commented on Feb 21, 2022

    @imabp
    Contributor

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

  12. derberg commented on Mar 1, 2022

    @derberg
    MemberAuthor

    @imabp well done 👏🏼

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions