[ci] format
This commit is contained in:
parent
e8d4e56803
commit
2acfef741f
7 changed files with 48 additions and 40 deletions
|
@ -19,30 +19,36 @@ type CLICommand = 'help' | 'version' | 'dev' | 'build' | 'preview' | 'reload' |
|
|||
|
||||
/** Display --help flag */
|
||||
function printHelp() {
|
||||
linebreak()
|
||||
linebreak();
|
||||
headline('astro', 'Futuristic web development tool.');
|
||||
linebreak()
|
||||
linebreak();
|
||||
title('Commands');
|
||||
table([
|
||||
['dev', 'Run Astro in development mode.'],
|
||||
['build', 'Build a pre-compiled production-ready site.'],
|
||||
['preview', 'Preview your build locally before deploying.'],
|
||||
['check', 'Check your project for errors.'],
|
||||
['--version', 'Show the version number and exit.'],
|
||||
['--help', 'Show this help message.'],
|
||||
], { padding: 28, prefix: ' astro ' });
|
||||
linebreak()
|
||||
table(
|
||||
[
|
||||
['dev', 'Run Astro in development mode.'],
|
||||
['build', 'Build a pre-compiled production-ready site.'],
|
||||
['preview', 'Preview your build locally before deploying.'],
|
||||
['check', 'Check your project for errors.'],
|
||||
['--version', 'Show the version number and exit.'],
|
||||
['--help', 'Show this help message.'],
|
||||
],
|
||||
{ padding: 28, prefix: ' astro ' }
|
||||
);
|
||||
linebreak();
|
||||
title('Flags');
|
||||
table([
|
||||
['--config <path>', 'Specify the path to the Astro config file.'],
|
||||
['--project-root <path>', 'Specify the path to the project root folder.'],
|
||||
['--no-sitemap', 'Disable sitemap generation (build only).'],
|
||||
['--legacy-build', 'Use the build strategy prior to 0.24.0'],
|
||||
['--experimental-ssr', 'Enable SSR compilation.'],
|
||||
['--drafts', 'Include markdown draft pages in the build.'],
|
||||
['--verbose', 'Enable verbose logging'],
|
||||
['--silent', 'Disable logging'],
|
||||
], { padding: 28, prefix: ' ' });
|
||||
table(
|
||||
[
|
||||
['--config <path>', 'Specify the path to the Astro config file.'],
|
||||
['--project-root <path>', 'Specify the path to the project root folder.'],
|
||||
['--no-sitemap', 'Disable sitemap generation (build only).'],
|
||||
['--legacy-build', 'Use the build strategy prior to 0.24.0'],
|
||||
['--experimental-ssr', 'Enable SSR compilation.'],
|
||||
['--drafts', 'Include markdown draft pages in the build.'],
|
||||
['--verbose', 'Enable verbose logging'],
|
||||
['--silent', 'Disable logging'],
|
||||
],
|
||||
{ padding: 28, prefix: ' ' }
|
||||
);
|
||||
|
||||
// Logging utils
|
||||
function linebreak() {
|
||||
|
@ -55,22 +61,22 @@ function printHelp() {
|
|||
function title(label: string) {
|
||||
console.log(` ${colors.bgWhite(colors.black(` ${label} `))}`);
|
||||
}
|
||||
function table(rows: [string, string][], opts: { padding: number, prefix: string }) {
|
||||
const split = rows.some(row => {
|
||||
function table(rows: [string, string][], opts: { padding: number; prefix: string }) {
|
||||
const split = rows.some((row) => {
|
||||
const message = `${opts.prefix}${' '.repeat(opts.padding)}${row[1]}`;
|
||||
return message.length > process.stdout.columns;
|
||||
})
|
||||
});
|
||||
for (const row of rows) {
|
||||
row.forEach((col, i) => {
|
||||
if (i === 0) {
|
||||
process.stdout.write(`${opts.prefix}${colors.bold(pad(`${col}`, opts.padding - opts.prefix.length))}`)
|
||||
process.stdout.write(`${opts.prefix}${colors.bold(pad(`${col}`, opts.padding - opts.prefix.length))}`);
|
||||
} else {
|
||||
if (split) {
|
||||
process.stdout.write('\n ');
|
||||
}
|
||||
process.stdout.write(colors.dim(col) + '\n')
|
||||
process.stdout.write(colors.dim(col) + '\n');
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ function getLoggerLocale(): string {
|
|||
const dt = new Intl.DateTimeFormat(getLoggerLocale(), {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit'
|
||||
second: '2-digit',
|
||||
});
|
||||
|
||||
let lastMessage: string;
|
||||
|
@ -74,12 +74,12 @@ export const defaultLogDestination = new Writable({
|
|||
(dest as typeof process.stdout).moveCursor(0, -1);
|
||||
}
|
||||
}
|
||||
message = `${message} ${yellow(`(x${lastMessageCount})`)}`
|
||||
message = `${message} ${yellow(`(x${lastMessageCount})`)}`;
|
||||
} else {
|
||||
lastMessage = message;
|
||||
lastMessageCount = 1;
|
||||
}
|
||||
dest.write(getPrefix())
|
||||
dest.write(getPrefix());
|
||||
dest.write(message);
|
||||
dest.write('\n');
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ export function devStart({
|
|||
`${dim('┃')} Network ${bold(cyan(toDisplayUrl(networkAddress)))}`,
|
||||
'',
|
||||
];
|
||||
return messages.map(msg => ` ${msg}`).join('\n');
|
||||
return messages.map((msg) => ` ${msg}`).join('\n');
|
||||
}
|
||||
|
||||
/** Display port in use */
|
||||
|
|
|
@ -115,7 +115,7 @@ async function handleRequest(
|
|||
} catch (_err: any) {
|
||||
info(logging, 'serve', msg.req({ url: pathname, statusCode: 500 }));
|
||||
const err = createSafeError(_err);
|
||||
error(logging, 'error', msg.err(err))
|
||||
error(logging, 'error', msg.err(err));
|
||||
handle500Response(viteServer, origin, req, res, err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ export async function handleHotUpdate(ctx: HmrContext, config: AstroConfig, logg
|
|||
invalidateCompilation(config, file);
|
||||
}
|
||||
|
||||
const mod = ctx.modules.find(m => m.file === ctx.file);
|
||||
const mod = ctx.modules.find((m) => m.file === ctx.file);
|
||||
const file = ctx.file.replace(config.projectRoot.pathname, '/');
|
||||
if (ctx.file.endsWith('.astro')) {
|
||||
ctx.server.ws.send({ type: 'custom', event: 'astro:update', data: { file } });
|
||||
|
|
|
@ -32,7 +32,6 @@ describe('astro cli', () => {
|
|||
expect(messages[0]).to.contain('started in');
|
||||
});
|
||||
|
||||
|
||||
const hostnames = [undefined, '0.0.0.0', '127.0.0.1'];
|
||||
|
||||
hostnames.forEach((hostname) => {
|
||||
|
@ -51,10 +50,10 @@ describe('astro cli', () => {
|
|||
const localURL = new URL(local);
|
||||
const networkURL = new URL(network);
|
||||
|
||||
expect(localURL.hostname).to.be.equal('localhost', `Expected local URL to be on localhost`)
|
||||
expect(localURL.hostname).to.be.equal('localhost', `Expected local URL to be on localhost`);
|
||||
// Note: our tests run in parallel so this could be 3000+!
|
||||
expect(Number.parseInt(localURL.port)).to.be.greaterThanOrEqual(3000, `Expected Port to be >= 3000`)
|
||||
expect(networkURL.hostname).to.be.equal(hostname ?? '127.0.0.1', `Expected Network URL to use passed hostname`)
|
||||
expect(Number.parseInt(localURL.port)).to.be.greaterThanOrEqual(3000, `Expected Port to be >= 3000`);
|
||||
expect(networkURL.hostname).to.be.equal(hostname ?? '127.0.0.1', `Expected Network URL to use passed hostname`);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -136,7 +136,10 @@ export async function parseCliDevStart(proc) {
|
|||
|
||||
proc.kill();
|
||||
stdout = stripAnsi(stdout);
|
||||
const messages = stdout.split('\n').filter(ln => !!ln.trim()).map(ln => ln.replace(/[🚀┃]/g, '').replace(/\s+/g, ' ').trim());
|
||||
const messages = stdout
|
||||
.split('\n')
|
||||
.filter((ln) => !!ln.trim())
|
||||
.map((ln) => ln.replace(/[🚀┃]/g, '').replace(/\s+/g, ' ').trim());
|
||||
return { messages };
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue