-
-
Notifications
You must be signed in to change notification settings - Fork 237
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
feat: allow generator to pull from private npm repo #1061
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Welcome to AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide 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.
@derberg Hello Sir. I updated the PR according to your instructions. Can you please review :) |
sorry, few days delay from my side, not feeling well @aeworxet fyi ☝🏼 |
@magicmatatjahu @jonaslagoni Can you please review this |
Hey there, sorry a lot for delay. There are some improvements we need here:
|
Thanks for the suggestions working on them |
@derberg I have done some changes how can i test it locally i checked the documentation but cannot able to find the suitable method how to test the changes locally can you tell me some points . So that i can ensure to test before pushing |
5da6c56
to
b36c18e
Compare
Working on fix it |
678ceec
to
4af7923
Compare
@derberg Done, Do we need to add documentation in generator or update in AsyncapiDoc |
Thanks working on fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added few comments
also please see why tests are failing
last but not least please specify how did you test new functionality to make sure it works - like integration test I mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments
I'm wondering how we could test it to make sure private registry works. Setting up automated test will be huge, but maybe we could at least have a short instruction for manual testing whenever we modify this functionality 🤔
so basically:
- one line command with docker to start local npm with custom auth -> https://developer.entando.com/v6.1/tutorials/ecr/how-to-create-local-npm-registry.html
- one line command to publish https://github.com/asyncapi/cli/tree/master/test/fixtures/minimaltemplate to this local npm
- and then one liner to start generation using private registry 🤔
you know, like developer guide
Added small doc @derberg |
@asyncapi/bounty_team |
@derberg I used verdaccio to create private repository in the local. |
@derberg Can you please check before you go for holidays 🙏🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for not reviewing before holidays, I just had to many topics to close
docs/installing-privateTemplate.md
Outdated
|
||
**Step 1:** Settuping Private Repository in Local: | ||
|
||
Installing [verdaccio](https://verdaccio.org/) using below command: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking, wouldn't it be better to hide all of this and just extend https://github.com/asyncapi/generator/tree/master/test/test-project that is responsible for testing generator in isolated environment 🤔
If I'm correct you would just have to:
- extend https://github.com/asyncapi/generator/blob/master/test/test-project/docker-compose.yml to handle startup of the verdaccio registory
- here you have example https://verdaccio.org/docs/docker#using-docker-compose
- you could add
htpasswd
file with username and password https://github.com/juanpicado/verdaccio-end-to-end-tests/blob/main/verdaccio/htpasswd and pass to it in docker compose command - you could also add packages that are available there by default https://github.com/juanpicado/verdaccio-end-to-end-tests/blob/main/verdaccio/verdaccio.yaml - that could be html-template that is already used in other tests (the specific version )
so with above you are getting rid of step 1-4 from this instruction
and to get rid last step:
- you would just add new file, like we already have
test-global.test.js
, that would do what you have in step 5, so programatically trigger generator and then evaluate if generation worked like a charm - you would have to add a script in https://github.com/asyncapi/generator/blob/master/test/test-project/package.json#L5-L6 that would be fired after step 15 in https://github.com/asyncapi/generator/blob/master/test/test-project/test.sh
Thoughts? this way we get one document less to maintain, and out of the box good quality integration test that would work out of the box as we have GitHub Action workflow for it -> https://github.com/asyncapi/generator/blob/master/.github/workflows/pr-testing-with-test-project.yml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking, wouldn't it be better to hide all of this and just extend https://github.com/asyncapi/generator/tree/master/test/test-project that is responsible for testing generator in isolated environment 🤔
If I'm correct you would just have to:
extend https://github.com/asyncapi/generator/blob/master/test/test-project/docker-compose.yml to handle startup of the verdaccio registory
- here you have example https://verdaccio.org/docs/docker#using-docker-compose
- you could add
htpasswd
file with username and password https://github.com/juanpicado/verdaccio-end-to-end-tests/blob/main/verdaccio/htpasswd and pass to it in docker compose command- you could also add packages that are available there by default https://github.com/juanpicado/verdaccio-end-to-end-tests/blob/main/verdaccio/verdaccio.yaml - that could be html-template that is already used in other tests (the specific version )
so with above you are getting rid of step 1-4 from this instruction
and to get rid last step:
- you would just add new file, like we already have
test-global.test.js
, that would do what you have in step 5, so programatically trigger generator and then evaluate if generation worked like a charm- you would have to add a script in https://github.com/asyncapi/generator/blob/master/test/test-project/package.json#L5-L6 that would be fired after step 15 in https://github.com/asyncapi/generator/blob/master/test/test-project/test.sh
Thoughts? this way we get one document less to maintain, and out of the box good quality integration test that would work out of the box as we have GitHub Action workflow for it -> https://github.com/asyncapi/generator/blob/master/.github/workflows/pr-testing-with-test-project.yml
@derberg I have tried using docker but we have to manually publish the template the repository, after providing the username and password in config, we have to still login, i have tried https://github.com/verdaccio/verdaccio/tree/master/docker-examples/v4/https-portal-example this example but also we have to manually publish the repo, Event the official video is publishing the repo manually [ We have to manually ]login https://www.youtube.com/watch?v=zRI0skF1f8I&t=234s&ab_channel=Docker
- Also i cannot pass parameters in the cli for login and publishing the repository.
I guess existing the small doc is sufficient to help developers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please push to repo what you have in regards to verdaccio
so I can try to help on my side. But first I need to see what configs you already tried
Sure @derberg
|
Sonar Cloud issue can be avoided because it is suggested to use optional changing that will cause lint issue |
docs/using-private-template.md
Outdated
title: "Using private templates" | ||
weight: 180 | ||
--- | ||
[Generator](https://www.asyncapi.com/tools/generator) allows to fetch the template from the private repositories like verdaccio, nexus, npm etc. Let's understand how can use the Generator to fetch the templates from the private repositories. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Generator](https://www.asyncapi.com/tools/generator) allows to fetch the template from the private repositories like verdaccio, nexus, npm etc. Let's understand how can use the Generator to fetch the templates from the private repositories. | |
Generator allows to fetch the template from the private repositories like verdaccio, nexus, npm etc. |
no need to have one more sentence + link to generator - as long these are generator docs 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done @derberg
docs/using-private-template.md
Outdated
|
||
* **token:** Optional parameter to pass npm registry auth token that you can grab from .npmrc file | ||
|
||
## Example to pull Private template: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Example to pull Private template: | |
## Pulling private template using library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done @derberg
docs/using-private-template.md
Outdated
const generator = new Generator('@asyncapi/html-template', outputDir, | ||
{ | ||
debug: true, | ||
install: true, | ||
forceWrite: true, | ||
templateParams: { | ||
singleFile: true | ||
}, | ||
registry: { | ||
url: 'http://verdaccio:4873', | ||
auth: 'YWRtaW46bmltZGE=' | ||
// base64 encoded username and password | ||
// represented as admin:nimda | ||
|
||
} | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const generator = new Generator('@asyncapi/html-template', outputDir, | |
{ | |
debug: true, | |
install: true, | |
forceWrite: true, | |
templateParams: { | |
singleFile: true | |
}, | |
registry: { | |
url: 'http://verdaccio:4873', | |
auth: 'YWRtaW46bmltZGE=' | |
// base64 encoded username and password | |
// represented as admin:nimda | |
} | |
}); | |
const generator = new Generator('@asyncapi/html-template', 'output', | |
{ | |
debug: true, | |
registry: { | |
url: 'http://verdaccio:4873', | |
auth: 'YWRtaW46bmltZGE=' | |
// base64 encoded username and password | |
// represented as admin:nimda | |
} | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done @derberg
docs/using-private-template.md
Outdated
} | ||
}); | ||
``` | ||
Let's suppose the template name as @asyncapi/html-template is present in the private repository, In order to pull the template from the private repository, we need to pass the url and auth as a parameters. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's suppose the template name as @asyncapi/html-template is present in the private repository, In order to pull the template from the private repository, we need to pass the url and auth as a parameters. | |
Let's assume you host `@asyncapi/html-template` in private package registry like Verdaccio. In order to pull this template you need to provide `registry.url` option that points to the registry URL and `registry.auth` as base64 encoded value that represents username and password. Instead of username and password you can also pass `registry.token`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done @derberg
docs/using-private-template.md
Outdated
[Generator](https://www.asyncapi.com/tools/generator) allows to fetch the template from the private repositories like verdaccio, nexus, npm etc. Let's understand how can use the Generator to fetch the templates from the private repositories. | ||
|
||
|
||
## Parameters that needs to pass in Generator to pull private template: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Parameters that needs to pass in Generator to pull private template: | |
## Private registry options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done @derberg
docs/using-private-template.md
Outdated
* **URL:** The URL of the registry where is private template is present. | ||
* **Auth:** Optional parameter to pass npm registry username and password encoded with base64, formatted like username:password value should be encoded. | ||
|
||
**For example**: if the username and password is admin and nimda, we need to base64 encoded of admin:nimda. | ||
|
||
* **token:** Optional parameter to pass npm registry auth token that you can grab from .npmrc file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* **URL:** The URL of the registry where is private template is present. | |
* **Auth:** Optional parameter to pass npm registry username and password encoded with base64, formatted like username:password value should be encoded. | |
**For example**: if the username and password is admin and nimda, we need to base64 encoded of admin:nimda. | |
* **token:** Optional parameter to pass npm registry auth token that you can grab from .npmrc file | |
* **registry.url**: The URL of the registry where is private template is present. Defaults to `registry.npmjs.org` | |
* **registry.auth**: Optional parameter to pass npm registry username and password encoded with base64, formatted like `username:password`. For example if the username and password is `admin` and `nimda`, you need to encode with base64 value like `admin:nimda` which results in `YWRtaW46bmltZGE=`. | |
* **registry.token** : Optional parameter to pass to npm registry auth token. To get the token you can first authenticate with registry using `npm login` and then grab generated token from `.npmrc` file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done @derberg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done 👏🏼
That was a big task, something that I definitely did not expect will be so advanced
but as a result we have lots of bugs solved, much better testing setup and very good reliable integration tests
@Florence-Njeri this PR has some docs, please have a look and approve 🙏🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Editorial review
Quality Gate passedThe SonarCloud Quality Gate passed, but some issues were introduced. 1 New issue |
/rtm |
🎉 This PR is included in version 1.17.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Resolves #538
Resolves #1100
Description: