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

readme is missing documentation for the new commands #123

Closed
Souvikns opened this issue Nov 3, 2021 · 30 comments · Fixed by #556, #602 or #603
Closed

readme is missing documentation for the new commands #123

Souvikns opened this issue Nov 3, 2021 · 30 comments · Fixed by #556, #602 or #603
Assignees
Labels
bounty AsyncAPI Bounty program related label bug Something isn't working level/medium AsyncAPI Bounty program related label released

Comments

@Souvikns
Copy link
Member

Souvikns commented Nov 3, 2021

Oclif has a way to generate command help documentation if we are going with that we just need to set it up.

@Souvikns Souvikns added bug Something isn't working documentation labels Nov 3, 2021
@fmvilas
Copy link
Member

fmvilas commented Nov 3, 2021

Yeah, just watch out that it might generate documentation of commands separated by colons (:) instead of spaces.

@BOLT04
Copy link
Member

BOLT04 commented Jan 30, 2022

Hi @Souvikns 👋, automating this would be really interesting so that when we add new commands, the docs on the README are automatically updated. I had a look on the package.json and there is already a script for the readme, are we already using it on GitHub actions?

I'd like to help with this issue if no one is working on it 🙂. I messed around with oclif readme command to see the output, and I just want to clarify if the generated docs are correct:

Usage

$ npm install -g @asyncapi/cli
$ asyncapi COMMAND
running command...
$ asyncapi (-v|--version|version)
@asyncapi/cli/0.12.7 linux-x64 node-v16.13.0
$ asyncapi --help [COMMAND]
USAGE
  $ asyncapi COMMAND
...

Commands

asyncapi config

access configs

USAGE
  $ asyncapi config

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config.ts

asyncapi config:context

USAGE
  $ asyncapi config context

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config/context.ts

asyncapi config:context:add CONTEXT-NAME SPEC-FILE-PATH

Add or modify a context in the store

USAGE
  $ asyncapi config context add CONTEXT-NAME SPEC-FILE-PATH

ARGUMENTS
  CONTEXT-NAME    context name
  SPEC-FILE-PATH  file path of the spec file

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config/context/add.ts

asyncapi config:context:current

Shows the current context that is being used

USAGE
  $ asyncapi config context current

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config/context/current.ts

asyncapi config:context:list

List all the stored context in the store

USAGE
  $ asyncapi config context list

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config/context/list.ts

asyncapi config:context:remove CONTEXT-NAME

Delete a context from the store

USAGE
  $ asyncapi config context remove CONTEXT-NAME

ARGUMENTS
  CONTEXT-NAME  Name of the context to delete

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config/context/remove.ts

asyncapi config:context:use CONTEXT-NAME

Set a context as current

USAGE
  $ asyncapi config context use CONTEXT-NAME

ARGUMENTS
  CONTEXT-NAME  name of the saved context

OPTIONS
  -h, --help  show CLI help

See code: src/commands/config/context/use.ts

asyncapi new

creates a new asyncapi file

USAGE
  $ asyncapi new

OPTIONS
  -e, --example=example      name of the example to use
  -h, --help                 show CLI help
  -n, --file-name=file-name  name of the file
  -p, --port=port            port in which to start Studio
  -s, --studio               open in Studio
  --no-tty                   do not use an interactive terminal

See code: src/commands/new.ts

asyncapi start

starts a new local instance of Studio

USAGE
  $ asyncapi start

OPTIONS
  -h, --help  show CLI help

See code: src/commands/start.ts

asyncapi start:studio

starts a new local instance of Studio

USAGE
  $ asyncapi start studio

OPTIONS
  -f, --file=file  path to the AsyncAPI file to link with Studio
  -h, --help       show CLI help
  -p, --port=port  port in which to start Studio

See code: src/commands/start/studio.ts

asyncapi validate [SPEC-FILE]

validate asyncapi file

USAGE
  $ asyncapi validate [SPEC-FILE]

ARGUMENTS
  SPEC-FILE  spec path, url, or context-name

OPTIONS
  -h, --help  show CLI help

See code: src/commands/validate.ts

Unfortunately, I wasn't able to test the current CLI commands by installing the asyncapi/cli package, I believe this error: [MODULE_NOT_FOUND] Error Plugin: @asyncapi/cli: Cannot find module '@oclif/plugin-help/lib/command' Require stack: is related to #192 😢

Feel free to give me any feedback on my assumption, I appreciate it 👍.

@Souvikns
Copy link
Member Author

Awesome @BOLT04 the generated docs are correct 👍🏻. No one is working on this issue as of now so you can take it up.

Yeah the CLI is kinda breaking in production but it works fine in the development and you can just clone the repo and run /bin/run in the project to run the CLI. Currently working on #203 to fix the issue. I think you have to wait for this as we are updating oclif version and the oclif readme command might work differently from right now.

@derberg
Copy link
Member

derberg commented Jan 31, 2022

the only problem with the generated stuff is : that should be spaces. So asyncapi config:context is actually asyncapi config context

@Souvikns
Copy link
Member Author

The new version has some inbuilt support for topic separators maybe this would help.

@BOLT04
Copy link
Member

BOLT04 commented Jan 31, 2022

ok, then for this issue we'll wait on #203 👍 . Then setup the topicSeparator on the package.json and build a new workflow to automatically run this script when there is a push to master. The next step would be to open a PR with those changes to be merged.

Is there a better way to run this script what does everyone think?

@github-actions
Copy link
Contributor

github-actions bot commented Jun 1, 2022

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 Jun 1, 2022
@BOLT04
Copy link
Member

BOLT04 commented Jun 1, 2022

hi @Souvikns, since #203 is done could we resume this issue, wdyt 🙂 ?

@github-actions github-actions bot removed the stale label Jun 2, 2022
@Souvikns
Copy link
Member Author

Souvikns commented Jun 2, 2022

@BOLT04, cli documentation was a part of GSoD, but don't know what is the status. asyncapi/website#602, #232 were planned for this. I don't know if anyone is working on CLI documentation right now. Give me some time, I will check on the status and update you.

@imabp
Copy link
Member

imabp commented Jun 2, 2022

@Souvikns we can continue on the CLI command reference using this tool
And I will be writing the getting started document

@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2022

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 Oct 1, 2022
@derberg
Copy link
Member

derberg commented Oct 11, 2022

I think this one is still valid

@Souvikns Souvikns removed the stale label Oct 11, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

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 Feb 9, 2023
@derberg
Copy link
Member

derberg commented Apr 3, 2023

this is still valid, although I'm not sure what the solution is

@github-actions github-actions bot removed the stale label Apr 4, 2023
@derberg
Copy link
Member

derberg commented Apr 17, 2023

Ok, looks like thanks to the fact that we recently upgraded to almost latest oclif version, we can use oclif readme command.

So the scope for this one is:

I will add this issue to trial of AsyncAPI Bounty -> https://github.com/orgs/asyncapi/discussions/541#discussioncomment-5532370

@derberg derberg added bounty AsyncAPI Bounty program related label level/medium AsyncAPI Bounty program related label labels Apr 19, 2023
@thulieblack
Copy link
Member

This issue is part of the AsyncAPI Bounty Program, interested contributors need to follow the guidelines below to ensure fairness and timely completion of assigned tasks:

Task Assignment

The assignment of tasks will be prioritized in the following order:

  • AsyncAPI maintainers (from any repository)
  • Regular contributors (individuals who have merged three or more pull requests)
  • Other (if an individual doesn't fall under the above, the maintainer can determine the criteria i.e regular volunteers, etc)

We encouraged everyone to apply as long as the task is for you (falls under your skill set). We will not be using the first comment - get assigned method for assignments. Instead, we will provide 3 days to consider all individuals interested before assigning any bounty task.

Deadline

To maintain accountability and ensure the timely completion of the deadline for this task will be 4- 6 weeks from the date of assignment. If a contributor requires an extension on their task, it should be communicated and approved by the maintainer.

Issue Tracking and Updates

Contributors must provide weekly updates on the task they are working on to help maintainers stay informed of progress. If a contributor fails to provide an update, they will be reminded via a ping. If a contributor fails to provide an update after three pings over three weeks, we will assume they have silently dropped the issue, and it will be reassigned to someone else.

Issue Drop-outs

Any contributor who drops an assigned issue will be penalized and will not be eligible to participate in the bounty program for 6 months. We understand that unforeseen circumstances can arise, and dropping an assigned issue may be unavoidable in some cases. However, we believe that enforcing this penalty is necessary to ensure the effectiveness of the bounty program, respect maintainer time, and honor the efforts of other contributors who could have solved the issue but were unable to do so due to the drop-out.

We encourage all contributors to follow these guidelines to ensure a fair and timely completion of tasks assigned through our bounty program.

@volta-net volta-net bot closed this as completed Apr 25, 2023
@derberg derberg reopened this Apr 25, 2023
@mhmohona
Copy link
Contributor

I would like to work on this issue.

@derberg
Copy link
Member

derberg commented May 9, 2023

@mhmohona I just assigned this issue to you to make it clear for others you work on it

@mediba123 we actually have automation that updates table of contents in readme and also a contribution guide. Did you check it before making that comment? 😄

@thulieblack
Copy link
Member

@mhmohona how is the task going so far??

@mhmohona
Copy link
Contributor

Hello @thulieblack, I am alsmot done with the task.

@derberg
Copy link
Member

derberg commented May 29, 2023

@mhmohona hey, so it looks like automation worked, scripts got triggered and we got #601 but as you can see, commands section is empty 🤔

@derberg
Copy link
Member

derberg commented May 29, 2023

@mhmohona I'm pretty sure it is because of some delay on oclif readme command, and the JS code just needs to wait.

can you open a followup PR with fix like below:

/* eslint-disable @typescript-eslint/no-var-requires */
const {writeFile, readFile} = require('fs').promises;

// Define the paths to the README and usage files
const README_PATH = './scripts/README.md'; // File path for the generated README file
const USAGE_PATH = './docs/usage.md'; // File path for the usage documentation file

const header = `---
title: 'Usage'
weight: 40
---

<!-- 

This file is automatically generated from updateUsageDocs.js script. In package.json in line 158-161 lines the following steps has been executed in order to run this script successfully - 

* generate:readme:create: It creates the initial content for the README file by printing the usage and commands tags using printf and redirects the output to scripts/README.md file.
* generate:readme:commands: It changes the directory to the scripts folder and executes the oclif readme command. This command generates the usage and commands sections based on the CLI commands and updates the content in the scripts/README.md file.
* generate:assets: This script combines the two previously mentioned scripts (generate:readme:toc and generate:commands) to generate the necessary assets, such as the README file and usage documentation.
* generate:commands: This script executes the following steps:
 - Runs the generate:readme:create script to create the initial content for the README file.
 - Executes the generate:readme:commands script to generate the usage and commands sections based on the CLI commands.
 - Runs the updateUsageDocs.js script using Node.js to update the usage documentation file with the contents of the generated README file.
 - Deletes the scripts/README.md file using the rimraf command.

-->

The AsyncAPI CLI makes it easier to work with AsyncAPI documents.
`;

// Define an async function to write the header and the README contents to the usage documentation file
async function run() {
  try {
    await writeFile(USAGE_PATH, header);
    const readmeContents = await readContents();
    // Append the contents of the README file to the usage documentation file
    await writeFile(USAGE_PATH, readmeContents, { flag: 'a' });
  } catch (e) {
    console.error(e);
  }
}

run();

async function readContents() {
  let readmeContents;
  let commandsContent = '';

  while (commandsContent.length === 0) {
    readmeContents = await readFile(README_PATH, 'utf8');
    
    // Check if the content between <!-- commands --> and <!-- commandsstop --> is empty
    const commandsStartText = '<!-- commands -->';
    const commandStartIndex = readmeContents.indexOf(commandsStartText);
    const commandStopIndex = readmeContents.indexOf('<!-- commandsstop -->');
    //cutting the content between the above mentioned tags, removing white spaces and checking if there is some text as it will mean text was added by oclif
    commandsContent = readmeContents.slice(commandStartIndex + commandsStartText.length, commandStopIndex).trim();

    if (commandsContent.length === 0) {
      console.log('No content between <!-- commands --> and <!-- commandsstop -->. Trying again...');
    } else {
      console.log('Content found!');
    }

    await delay(3000); // 3-second delay
  }

  return readmeContents;
}

function delay(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

@mhmohona
Copy link
Contributor

Thank you so much for pointing this @derberg! I have updated the code and created new PR.

I thought of adding it but then thought it might be unnecessary but it seems it is needed. :3

@derberg
Copy link
Member

derberg commented May 29, 2023

ok, so 😄 it didn't work

workflow was running for over 3min and below was just logged out

No content between <!-- commands --> and <!-- commandsstop -->. Trying again...

I don't think it is normal so I cancelled the run. Not sure yet what is the solution

@derberg
Copy link
Member

derberg commented May 29, 2023

I can't figure from their code what might be wrong, but we can log more things in the GitHub Action

so please open another PR with change in the package.json where you run oclif readme so it is DEBUG=* oclif readme

so basically make sure it says "generate:readme:commands": "cd scripts && DEBUG=* oclif readme",

this will give us a lot of insights and info where it stucks with commands generation

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.45.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@derberg
Copy link
Member

derberg commented May 30, 2023

@mhmohona is still doesn't work, logs show

2023-05-30T04:42:52.932Z config:@asyncapi/cli loading IDs from /home/runner/work/cli/cli/lib/commands
2023-05-30T04:42:52.939Z config:@asyncapi/cli found commands []

while on local I get

config:@asyncapi/cli loading IDs from /Users/wookiee/sources/cli/lib/commands +0ms
  config:@asyncapi/cli found commands [
  'bundle',                'convert',
  'diff',                  'optimize',
  'validate',              'config',
  'config:versions',       'generate:fromTemplate',
  'generate',              'generate:models',
  'new:file',              'new:glee',
  'new',                   'new:project',
  'start',                 'start:studio',
  'config:context:add',    'config:context:current',
  'config:context',        'config:context:list',
  'config:context:remove', 'config:context:use'
]

so looks like oclif cannot figure what commands are available, but I do not know why

@derberg
Copy link
Member

derberg commented May 30, 2023

we could add a step in CI that checks run: ls /home/runner/work/cli/cli/lib/commands as maybe it is empty but I'm not sure, I'm kinda sure /home/runner/work/cli/cli is correct.

@derberg
Copy link
Member

derberg commented May 31, 2023

@mhmohona congrats, topic completed. Look what we got on the website thanks to your work ❤️ -> https://www.asyncapi.com/docs/tools/cli/usage

@thulieblack another bounty issue completed, over to you

cc @Souvikns fyi usage docs are not automatically updated 💪🏼

@thulieblack
Copy link
Member

Hey, @mhmohona, congratulations on completing your issue!!

This is how'll claim your bounty:

  1. Go to AsyncAPI Open Collective page
  2. Submit an expense and add details for the bounty issue
    image
  3. Voila! You get your coins🤑 !!

@aeworxet aeworxet moved this to Completed in Bounty Program Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty AsyncAPI Bounty program related label bug Something isn't working level/medium AsyncAPI Bounty program related label released
Projects
Status: Completed
8 participants