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

fix: template generation failing #1426

Merged
merged 2 commits into from
May 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/commands/generate/fromTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export default class Template extends Command {
output = parsedArgs.output;
}

const parsedFlags = this.parseFlags(flags['disable-hook'], flags['param'], flags['map-base-url'],flags['registry.url'],flags['registry.auth'],flags['registry.token']);
const parsedFlags = this.parseFlags(flags['disable-hook'], flags['param'], flags['map-base-url'], flags['registry.url'], flags['registry.auth'], flags['registry.token']);
const options = {
forceWrite: flags['force-write'],
install: flags.install,
Expand Down Expand Up @@ -245,9 +245,14 @@ export default class Template extends Command {
}
}
private async registryValidation(registryUrl?:string, registryAuth?:string, registryToken?:string) {
const response= await fetch(registryUrl as string);
if (response.status === 401&&!registryAuth&&!registryToken) {
throw new Error('Need to pass either registryAuth in username:password encoded in Base64 or need to pass registryToken');
if (!registryUrl) { return; }
try {
const response = await fetch(registryUrl as string);
if (response.status === 401 && !registryAuth && !registryToken) {
this.error('You Need to pass either registryAuth in username:password encoded in Base64 or need to pass registryToken', { exit: 1 });
}
} catch (error: any) {
this.error(`Can't fetch registryURL: ${registryUrl}`, { exit: 1 });
}
}
private paramParser(inputs?: string[]) {
Expand Down
Loading