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

Generating docs in git tracked directory throws an error #1053

Closed
ldynia opened this issue Oct 20, 2023 · 2 comments
Closed

Generating docs in git tracked directory throws an error #1053

ldynia opened this issue Oct 20, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@ldynia
Copy link

ldynia commented Oct 20, 2023

Describe the bug

While generating docs in a directory that is git tracked, the program throws an error.

How to Reproduce

# Install ag
sudo npm install -g @asyncapi/generator

# Create a test directory and track its content with git
mkdir test
cd test/
git init 

# Generate docs
ag https://bit.ly/asyncapi @asyncapi/html-template -o example
Something went wrong:
Error: "/home/lukasz/test/example" is in a git repository with unstaged changes. Please commit your changes before proceeding or add proper directory to .gitignore file. You can also use the --force-write flag to skip this rule (not recommended).
    at Generator.verifyTargetDir (/usr/local/lib/node_modules/@asyncapi/generator/lib/generator.js:1010:71)
    at async Generator.setupFSOutput (/usr/local/lib/node_modules/@asyncapi/generator/lib/generator.js:232:7)

Expected behavior

The program should not throw an error and should generate HTML documentation.

@ldynia ldynia added the bug Something isn't working label Oct 20, 2023
@github-actions
Copy link
Contributor

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@ldynia
Copy link
Author

ldynia commented Oct 20, 2023

I fixed this issue with the --force-write flag. I wish it were set to true by default :)

ag @asyncapi/html-template --help
Usage: ag [options] <asyncapi> <template>

Options:
  -V, --version                  output the version number
  -d, --disable-hook [hooks...]  disable a specific hook type or hooks from given hook type
  --debug                        enable more specific errors in the console
  -i, --install                  installs the template and its dependencies (defaults to false)
  -n, --no-overwrite <glob>      glob or path of the file(s) to skip when regenerating
  -o, --output <outputDir>       directory where to put the generated files (defaults to current directory) (default: "/home/lukasz/test")
  -p, --param <name=value>       additional param to pass to templates
  --force-write                  force writing of the generated files to given directory even if it is a git repo with unstaged files or not empty dir (defaults to false)
  --watch-template               watches the template directory and the AsyncAPI document, and re-generate the files when changes occur. Ignores the output directory. This flag should be
                                 used only for template development.
  --map-base-url <url:folder>    maps all schema references from base url to local folder
  -h, --help                     display help for command

@ldynia ldynia closed this as completed Oct 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant