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

[BUG] Very out of date package JSON, breaking documentation example. #1562

Closed
2 tasks done
ghost opened this issue Oct 29, 2024 · 16 comments
Closed
2 tasks done

[BUG] Very out of date package JSON, breaking documentation example. #1562

ghost opened this issue Oct 29, 2024 · 16 comments
Labels
bug Something isn't working

Comments

@ghost
Copy link

ghost commented Oct 29, 2024

Describe the bug.

The documentation example https://www.asyncapi.com/tools/generator is to run using:

docker run --rm -it --user=root -v ${PWD}/example:/app/example -v ${PWD}/output:/app/output \
asyncapi/cli generate fromTemplate https://bit.ly/asyncapi @asyncapi/html-template -o example

However, the versions in the asyncapi/cli:2.8.0 (and many others) are out of date: package.json.

{
  "name": "@asyncapi/cli",
  "description": "All in one CLI for all AsyncAPI tools",
  "version": "2.8.0",
  "author": "@asyncapi",
  "bin": {
    "asyncapi": "./bin/run_bin"
  },
  "bugs": "https://github.com/asyncapi/cli/issues",
  "dependencies": {
    "@asyncapi/avro-schema-parser": "^3.0.23",
    "@asyncapi/bundler": "^0.6.3",
    "@asyncapi/converter": "^1.6.2",
    "@asyncapi/diff": "^0.4.1",
    "@asyncapi/generator": "^1.17.25",

resulting in the following errors:

◑  Generation in progress. Keep calm and wait a bit..Template @asyncapi/html-template successfully installed in /usr/local/lib/node_modules/@asyncapi/cli/node_modules/@asyncapi/generator/node_modules/@asyncapi/html-template.
Version of used template is 3.0.0.
◇  Generation failed
Generator Error: This template is not compatible with the current version of the generator (1.17.25). This template is compatible with the following version range: >=2.0.0 <3.0.0.

Expected behavior

Working example from homepage

Screenshots

image

How to Reproduce

Run the example from the homepage: https://www.asyncapi.com/tools/generator

🥦 Browser

None

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

No, someone else can work on it

@ghost ghost added the bug Something isn't working label Oct 29, 2024
@github-project-automation github-project-automation bot moved this to To Triage in CLI - Kanban Oct 29, 2024
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.

@ghost
Copy link
Author

ghost commented Oct 29, 2024

For example, current generator version is: 2.4.1 https://github.com/asyncapi/generator/releases

Container for the CLI:2.8.0 is running the following versions:

@asyncapi/cli/2.8.0 linux-x64 node-v20.18.0
  ├@asyncapi/avro-schema-parser/3.0.24
  ├@asyncapi/bundler/0.6.4
  ├@asyncapi/converter/1.6.2
  ├@asyncapi/diff/0.4.1
  ├@asyncapi/generator/1.17.25
  ├@asyncapi/modelina-cli/4.0.0-next.62
  ├@asyncapi/openapi-schema-parser/3.0.24
  ├@asyncapi/optimizer/1.0.4
  ├@asyncapi/parser/3.3.0
  ├@asyncapi/protobuf-schema-parser/3.2.14
  ├@asyncapi/raml-dt-schema-parser/4.0.24
  └@asyncapi/studio/0.20.2

Repository: https://github.com/asyncapi/cli

@bernarth
Copy link

bernarth commented Nov 1, 2024

The error Generator Error: This template is not compatible with the current version of the generator (1.17.25). This template is compatible with the following version range: >=2.0.0 <3.0.0. is happening to me as well. I think the latest version of the generator should be used instead ( current version here ) which is 2.5.0 today

@abiola-deimos
Copy link

Does anyone know what the workaround is?

@bernarth
Copy link

bernarth commented Nov 7, 2024

I am using html-template so, I am using an specific version of it. -> 2.3.14
With the example above it could be something like: docker run --rm -it --user=root -v ${PWD}/example:/app/example -v ${PWD}/output:/app/output \ asyncapi/cli generate fromTemplate https://bit.ly/asyncapi @asyncapi/[email protected] -o example

You can use a compatible version (if you are using html-template here )

@yenidunya
Copy link

The error Generator Error: This template is not compatible with the current version of the generator (1.17.25). This template is compatible with the following version range: >=2.0.0 <3.0.0. is happening to me as well. I think the latest version of the generator should be used instead ( current version here ) which is 2.5.0 today

tried changing it in package.json and then installing cli. installed version of the generator seems OK but then I received following error while using generate:

    return oclifHandler(err.message);
           ^

TypeError: oclifHandler is not a function

@bernarth
Copy link

I tried the same. But, when installing the CLI it comes with an older version of the installed packages which causes conflicts.

@yenidunya
Copy link

yenidunya commented Nov 27, 2024

using the option --use-new-generator with generate overcomes the problem

@alsofr
Copy link

alsofr commented Dec 2, 2024

I'm running into a similar issue when running asyncapi generate with the latest version (2.11.1) of asyncapi install.
No docker involved, just a simple command line argument. I've tried install via brew or via pkg, with the current or with an older version, and I'm still getting the same error:

asyncapi generate golang -packageName=model my-asynapi-file.json -o model.go

/opt/homebrew/Cellar/asyncapi/2.11.1/libexec/lib/node_modules/@asyncapi/cli/bin/run_bin:12
    return oclifHandler(err.message);
           ^

TypeError: oclifHandler is not a function
    at /opt/homebrew/Cellar/asyncapi/2.11.1/libexec/lib/node_modules/@asyncapi/cli/bin/run_bin:12:12

Looking at the code, the problem seems to be linked to a problem loading @oclif/core/handle.

const oclif = require('@oclif/core');

oclif.run()
  .then(require('@oclif/core/flush'))
  .catch((err) => {
    const oclifHandler = require('@oclif/core/handle');
    return oclifHandler(err.message);
  });

However, things look consistent in the package.json:

image

@Shurtu-gal
Copy link
Collaborator

Shurtu-gal commented Dec 16, 2024

Hello people,
Just to put some context here to keep backward compatibility we are currently maintaining two versions of generator currently:- 2.4.1 and 1.7.25.

So, to use templates requiring newer version please use the flag --use-new-generator as mentioned here

Edit: For more context #1513 and #1388

@alsofr
Copy link

alsofr commented Dec 17, 2024

Hi @Shurtu-gal , could you please explain how to use this flag with the asyncapi generate golang command? The flag doesn't seem to have any effect there

@Shurtu-gal
Copy link
Collaborator

Hi @Shurtu-gal , could you please explain how to use this flag with the asyncapi generate golang command? The flag doesn't seem to have any effect there

This command is there for generating models and uses modelina under the hood. So this flag doesn't make sense there.

Could you specify your problem?

@alsofr
Copy link

alsofr commented Dec 17, 2024

I mentioned it a bit earlier
#1562 (comment)

Sorry for piggy-backing on this issue, the error message was the same so I assumed the issues must be related.

If the --use-new-generator flag is only for the fromTemplate mode, how do I fix the generate problem?

@Shurtu-gal
Copy link
Collaborator

Shurtu-gal commented Dec 17, 2024

I mentioned it a bit earlier #1562 (comment)

Sorry for piggy-backing on this issue, the error message was the same so I assumed the issues must be related.

If the --use-new-generator flag is only for the fromTemplate mode, how do I fix the generate problem?

The command should be asyncapi generate models golang --packageName=model my-asynapi-file.json -o model.go

@alsofr
Copy link

alsofr commented Dec 17, 2024

Thanks!, I was missing the "models" keyword! :)

@Shurtu-gal
Copy link
Collaborator

Closing this issue then. Feel free to open it and comment in case any thing is still unresolved.

@github-project-automation github-project-automation bot moved this from To Triage to Done in CLI - Kanban Dec 19, 2024
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
Archived in project
Development

No branches or pull requests

5 participants