Skip to content

Commit

Permalink
feat(cli): lower registry timeout, comment out console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayevans committed Jul 11, 2024
1 parent 0fab231 commit 11367ce
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/cli/loadTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import fs from 'node:fs';
import path from 'node:path';
import ora, { Ora } from 'ora';

const REG_PROXY_TIMEOUT = 600;

export const loadTemplate = async (
templateName: string,
options: { quiet?: boolean } = {}
Expand Down Expand Up @@ -53,25 +55,25 @@ export const loadTemplate = async (
const proxyUrl = `https://scffld-api.azurewebsites.net/TemplateProxy/${parts.join(
'/'
)}${revision !== 'HEAD' ? `/${revision}` : ''}`;
console.info(`\nFetching from proxy: ${proxyUrl}`);
// console.info(`\nFetching from proxy: ${proxyUrl}`);
const response = await fetch(proxyUrl, {
signal: AbortSignal.timeout(3000),
signal: AbortSignal.timeout(REG_PROXY_TIMEOUT),
});
if (response.ok && response.body) {
templateContent = await response.text();
if (templateContent && templateContent.indexOf('---') !== -1) {
if (fetchSpinner !== undefined && !quiet) {
fetchSpinner.succeed();
}
console.info(`\nGot template content from '${proxyUrl}'`);
// console.info(`\nGot template content from '${proxyUrl}'`);
return templateContent;
}
}
} catch (e) {
// Catch errors & fallback to direct GitHub access
console.warn('\nError from proxy:', e);
// console.warn('\nError from proxy:', e);
}
console.warn('\nSomething broke in the proxy, fallback to GH');
// console.warn('\nSomething broke in the proxy, fallback to GH');
url = `https://raw.githubusercontent.com/scffld-dev/website/${revision}/templates/${parts.join(
'/'
)}${templateName.endsWith('.md') ? '' : '.md'}`;
Expand Down

0 comments on commit 11367ce

Please sign in to comment.