full site update

This commit is contained in:
2025-07-24 18:46:24 +02:00
parent bfe2b90d8d
commit 37a6e0ab31
6912 changed files with 540482 additions and 361712 deletions

View File

@@ -1,4 +1,4 @@
import type { AstroConfig, AstroUserConfig } from '../../@types/astro.js';
import type { AstroConfig, AstroUserConfig } from '../../types/public/config.js';
import { type Flags } from '../flags.js';
interface InfoOptions {
flags: Flags;
@@ -8,4 +8,5 @@ export declare function getInfoOutput({ userConfig, print, }: {
print: boolean;
}): Promise<string>;
export declare function printInfo({ flags }: InfoOptions): Promise<void>;
export declare function readFromClipboard(): string;
export {};

View File

@@ -1,4 +1,4 @@
import { execSync } from "node:child_process";
import { spawnSync } from "node:child_process";
import { arch, platform } from "node:os";
import * as colors from "kleur/colors";
import prompts from "prompts";
@@ -33,48 +33,55 @@ async function printInfo({ flags }) {
applyPolyfill();
const { userConfig } = await resolveConfig(flagsToAstroInlineConfig(flags), "info");
const output = await getInfoOutput({ userConfig, print: true });
await copyToClipboard(output);
await copyToClipboard(output, flags.copy);
}
async function copyToClipboard(text) {
async function copyToClipboard(text, force) {
text = text.trim();
const system = platform();
let command = "";
let args = [];
if (system === "darwin") {
command = "pbcopy";
} else if (system === "win32") {
command = "clip";
} else {
const unixCommands = [
["xclip", "-sel clipboard -l 1"],
["wl-copy", '"$0"']
["xclip", ["-selection", "clipboard", "-l", "1"]],
["wl-copy", []]
];
for (const [unixCommand, args] of unixCommands) {
for (const [unixCommand, unixArgs] of unixCommands) {
try {
const output = execSync(`which ${unixCommand}`, { encoding: "utf8", stdio: "pipe" });
if (output[0] !== "/") {
continue;
const output = spawnSync("which", [unixCommand], { encoding: "utf8" });
if (output.stdout.trim()) {
command = unixCommand;
args = unixArgs;
break;
}
command = `${unixCommand} ${args}`;
} catch {
continue;
}
}
if (!command) return;
}
console.log();
const { shouldCopy } = await prompts({
type: "confirm",
name: "shouldCopy",
message: "Copy to clipboard?",
initial: true
});
if (!shouldCopy) return;
try {
execSync(command.replaceAll("$0", text), {
stdio: "ignore",
input: text,
encoding: "utf8"
if (!command) {
console.error(colors.red("\nClipboard command not found!"));
console.info("Please manually copy the text above.");
return;
}
if (!force) {
const { shouldCopy } = await prompts({
type: "confirm",
name: "shouldCopy",
message: "Copy to clipboard?",
initial: true
});
if (!shouldCopy) return;
}
try {
const result = spawnSync(command, args, { input: text, stdio: ["pipe", "ignore", "ignore"] });
if (result.error) {
throw result.error;
}
console.info(colors.green("Copied to clipboard!"));
} catch {
console.error(
colors.red(`
@@ -82,6 +89,42 @@ Sorry, something went wrong!`) + ` Please copy the text above manually.`
);
}
}
function readFromClipboard() {
const system = platform();
let command = "";
let args = [];
if (system === "darwin") {
command = "pbpaste";
} else if (system === "win32") {
command = "powershell";
args = ["-command", "Get-Clipboard"];
} else {
const unixCommands = [
["xclip", ["-sel", "clipboard", "-o"]],
["wl-paste", []]
];
for (const [unixCommand, unixArgs] of unixCommands) {
try {
const output = spawnSync("which", [unixCommand], { encoding: "utf8" });
if (output.stdout.trim()) {
command = unixCommand;
args = unixArgs;
break;
}
} catch {
continue;
}
}
}
if (!command) {
throw new Error("Clipboard read command not found!");
}
const result = spawnSync(command, args, { encoding: "utf8" });
if (result.error) {
throw result.error;
}
return result.stdout.trim();
}
const PLATFORM_TO_OS = {
darwin: "macOS",
win32: "Windows",
@@ -115,11 +158,12 @@ ${" ".repeat(MAX_PADDING)}${colors.green(entry)}`;
}
plaintext += "\n";
if (print) {
console.log(richtext);
console.info(richtext);
}
return plaintext;
}
export {
getInfoOutput,
printInfo
printInfo,
readFromClipboard
};