0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

[ci] format

This commit is contained in:
natemoo-re 2023-08-31 17:37:00 +00:00 committed by astrobot-houston
parent b21038c193
commit d7579f36d7

View file

@ -1,12 +1,12 @@
/* eslint-disable no-console */
import type yargs from 'yargs-parser';
import * as colors from 'kleur/colors';
import { execSync } from 'node:child_process';
import { arch, platform } from 'node:os';
import prompts from 'prompts';
import type yargs from 'yargs-parser';
import { resolveConfig } from '../../core/config/index.js';
import { ASTRO_VERSION } from '../../core/constants.js';
import { flagsToAstroInlineConfig } from '../flags.js';
import { execSync } from 'node:child_process';
interface InfoOptions {
flags: yargs.Arguments;
@ -18,13 +18,13 @@ export async function printInfo({ flags }: InfoOptions) {
['Node', process.version],
['System', getSystem()],
['Package Manager', getPackageManager()],
]
];
const inlineConfig = flagsToAstroInlineConfig(flags);
try {
const { userConfig } = await resolveConfig(inlineConfig, 'info');
rows.push(['Output', userConfig.output ?? 'static'])
rows.push(['Adapter', userConfig.adapter?.name ?? 'none'])
rows.push(['Output', userConfig.output ?? 'static']);
rows.push(['Adapter', userConfig.adapter?.name ?? 'none']);
const integrations = (userConfig?.integrations ?? [])
.filter(Boolean)
.flat()
@ -52,13 +52,18 @@ async function copyToClipboard(text: string) {
name: 'shouldCopy',
message: 'Copy to clipboard?',
initial: true,
})
});
if (!shouldCopy) return;
const command = system === 'darwin' ? 'pbcopy' : 'clip';
try {
execSync(`echo ${JSON.stringify(text.trim())} | ${command}`, { encoding: 'utf8', stdio: 'ignore' });
execSync(`echo ${JSON.stringify(text.trim())} | ${command}`, {
encoding: 'utf8',
stdio: 'ignore',
});
} catch (e) {
console.error(colors.red(`\nSorry, something went wrong!`) + ` Please copy the text above manually.`);
console.error(
colors.red(`\nSorry, something went wrong!`) + ` Please copy the text above manually.`
);
}
}
@ -66,7 +71,7 @@ const PLATFORM_TO_OS: Partial<Record<ReturnType<typeof platform>, string>> = {
darwin: 'macOS',
win32: 'Windows',
linux: 'Linux',
}
};
function getSystem() {
const system = PLATFORM_TO_OS[platform()] ?? platform();
@ -75,7 +80,7 @@ function getSystem() {
function getPackageManager() {
if (!process.env.npm_config_user_agent) {
return 'unknown'
return 'unknown';
}
const specifier = process.env.npm_config_user_agent.split(' ')[0];
const name = specifier.substring(0, specifier.lastIndexOf('/'));
@ -91,7 +96,7 @@ function printRow(label: string, value: string | string[]) {
if (rest.length > 0) {
for (const entry of rest) {
plaintext += `\n${' '.repeat(MAX_PADDING)}${entry}`;
richtext += `\n${' '.repeat(MAX_PADDING)}${colors.green(entry)}`
richtext += `\n${' '.repeat(MAX_PADDING)}${colors.green(entry)}`;
}
}
plaintext += '\n';