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

feat: support private registry options in asyncapi generate fromTemplate command #1091

Conversation

Shiva953
Copy link
Contributor

Description

  • This pull request introduces new flags in the asyncapi generate fromTemplate command, in order to support private registry options such that user can pass custom registry.url and specific authorization method, like registry.auth or registry.token

Related issue(s)
#1081

@Shiva953
Copy link
Contributor Author

cc @derberg @Souvikns

Comment on lines +107 to +111
'registry-auth': Flags.string({
description: 'The registry username and password encoded with base64, formatted as username:password'
}),
'registry-token': Flags.string({
description: 'The npm registry authentication token, that can be passed instead of base64 encoded username and password'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think it will make more sense if we take registryUsername and registryPassword as input from the user

Suggested change
'registry-auth': Flags.string({
description: 'The registry username and password encoded with base64, formatted as username:password'
}),
'registry-token': Flags.string({
description: 'The npm registry authentication token, that can be passed instead of base64 encoded username and password'
'registry-username': Flags.string({
description: 'The username for the private registry.',
}),
'registry-password': Flags.string({
description: 'The password for the private registry.',
}),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that was also my initial concern I raised under the issue. Though in the example described here we are directly providing the base64 encoded value, wouldn't it make sense to do the same here too?

@@ -122,6 +132,9 @@ export default class Template extends Command {
noOverwriteGlobs: flags['no-overwrite'],
mapBaseUrlToFolder: parsedFlags.mapBaseUrlToFolder,
disabledHooks: parsedFlags.disableHooks,
registryUrl: parsedFlags.registryUrl,
registryAuth: flags['registry-auth'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registry auth should be change with base 64 value as mentioned in this
You can do this in something like this

const registryAuth = registryUsername && registryPassword
    ? Buffer.from(`${registryUsername}:${registryPassword}`).toString('base64')
    : undefined;

@@ -122,6 +132,9 @@ export default class Template extends Command {
noOverwriteGlobs: flags['no-overwrite'],
mapBaseUrlToFolder: parsedFlags.mapBaseUrlToFolder,
disabledHooks: parsedFlags.disableHooks,
registryUrl: parsedFlags.registryUrl,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the default URL of registryUrl should be https://registry.npmjs.org

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@Shiva953
Copy link
Contributor Author

Shiva953 commented Feb 5, 2024

any updates on this?

@Souvikns
Copy link
Member

@Shiva953 can you check, some tests are not passing

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please take a look into generator and how new flag works. There is documentation available.

option on generator is called registry and it is an object of 3 values

url - auth - token

you need to adjust your code accordingly and only stuff that is available

so if username and password is not available - then you cannot use it 😄

the way people should use generator in CI is always through token and auth that represents encoded username and password

it is all because of security

so you need to enable CLI user to pass all there different flags (which you already have - you just have to properly pass them to generator

@Amzani
Copy link
Collaborator

Amzani commented Apr 29, 2024

@Shiva953 any updates ?

@Amzani
Copy link
Collaborator

Amzani commented May 14, 2024

We can close this PR as it's already solved: #1399
Thanks @Shiva953 @AayushSaini101

@Amzani Amzani closed this May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants