Generator allows fetching the template from private repositories like Verdaccio, Nexus, npm, etc.
By default, the generator fetches the template from the public npm registry configured in the npm configuration.
To fetch the template from a private registry, you need to provide the registry URL and authentication details in the .npmrc. For more information read the docs.
However, you can override the default behavior by providing the registry URL and authentication details as arguments of the commandline.
Private registry using .npmrc:
1npm config set registry http://verdaccio:4873
2npm config set //verdaccio:4873/:_auth=$(echo -n 'username:password' | base64)
- npm config set registry : Provide the registry URL that points to the registry URL.
- npm config set _auth : Provide the base64 encoded value that represents the username and password for basic auth.
- npm config set _authToken : Provide the access token generated by the registry.
Private registry overriding arguments:
- registry.url: The URL of the registry where the private template is located. Defaults to
registry.npmjs.org
. - registry.auth: An optional parameter to pass the npm registry username and password encoded with base64, formatted as
username:password
. For example, if the username and password areadmin
andnimda
, you need to encode them with the base64 value likeadmin:nimda
which results inYWRtaW46bmltZGE=
. - registry.token: An optional parameter to pass to the npm registry authentication token. To get the token, you can first authenticate with the registry using
npm login
and then grab the generated token from the.npmrc
file.
Pulling private template using library:
1const generator = new Generator('@asyncapi/html-template', 'output',
2 {
3 debug: true,
4 registry: {
5 url: 'http://verdaccio:4873',
6 auth: 'YWRtaW46bmltZGE='
7 // base64 encoded username and password
8 // represented as admin:nimda
9
10 }
11 });
Assuming you host @asyncapi/html-template
in a private package registry like Verdaccio. To pull this template, you need to provide registry.url
option that points to the registry URL and registry.auth
as a base64 encoded value that represents the username and password. Instead of username and password, you can also pass registry.token
.