Initial commit: New MoreminiMore website with fresh design

This commit is contained in:
MoreminiMore
2026-04-22 01:59:05 +07:00
commit 76409638cc
14010 changed files with 2052041 additions and 0 deletions

6
node_modules/astro/dist/cli/add/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { type Flags } from '../flags.js';
interface AddOptions {
flags: Flags;
}
export declare function add(names: string[], { flags }: AddOptions): Promise<void>;
export {};

1053
node_modules/astro/dist/cli/add/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

6
node_modules/astro/dist/cli/build/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { type Flags } from '../flags.js';
interface BuildOptions {
flags: Flags;
}
export declare function build({ flags }: BuildOptions): Promise<void>;
export {};

33
node_modules/astro/dist/cli/build/index.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
import _build from "../../core/build/index.js";
import { printHelp } from "../../core/messages/runtime.js";
import { flagsToAstroInlineConfig } from "../flags.js";
async function build({ flags }) {
if (flags?.help || flags?.h) {
printHelp({
commandName: "astro build",
usage: "[...flags]",
tables: {
Flags: [
["--outDir <directory>", `Specify the output directory for the build.`],
["--mode", `Specify the mode of the project. Defaults to "production".`],
[
"--devOutput",
"Output a development-based build similar to code transformed in `astro dev`."
],
[
"--force",
"Clear the content layer and content collection cache, forcing a full rebuild."
],
["--help (-h)", "See all available flags."]
]
},
description: `Builds your site for deployment.`
});
return;
}
const inlineConfig = flagsToAstroInlineConfig(flags);
await _build(inlineConfig, { devOutput: !!flags.devOutput });
}
export {
build
};

2
node_modules/astro/dist/cli/check/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { type Flags } from '../flags.js';
export declare function check(flags: Flags): Promise<boolean | void>;

37
node_modules/astro/dist/cli/check/index.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
import path from "node:path";
import { ensureProcessNodeEnv } from "../../core/util.js";
import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
import { getPackage } from "../install-package.js";
async function check(flags) {
ensureProcessNodeEnv("production");
const logger = createLoggerFromFlags(flags);
const getPackageOpts = {
skipAsk: !!flags.yes || !!flags.y,
cwd: flags.root
};
const checkPackage = await getPackage(
"@astrojs/check",
logger,
getPackageOpts,
["typescript"]
);
const typescript = await getPackage("typescript", logger, getPackageOpts);
if (!checkPackage || !typescript) {
logger.error(
"check",
"The `@astrojs/check` and `typescript` packages are required for this command to work. Please manually install them into your project and try again."
);
return;
}
if (!flags.noSync && !flags.help) {
const { default: sync } = await import("../../core/sync/index.js");
await sync(flagsToAstroInlineConfig(flags));
}
const { check: checker, parseArgsAsCheckConfig } = checkPackage;
const config = parseArgsAsCheckConfig(process.argv);
logger.info("check", `Getting diagnostics for Astro files in ${path.resolve(config.root)}...`);
return await checker(config);
}
export {
check
};

View File

@@ -0,0 +1,17 @@
import type { AstroLogger } from '../../../core/logger/core.js';
import type { KeyGenerator } from '../definitions.js';
interface Options {
logger: AstroLogger;
keyGenerator: KeyGenerator;
}
export declare const createKeyCommand: {
help: {
commandName: string;
tables: {
Flags: [string, string][];
};
description: string;
};
run({ logger, keyGenerator }: Options): Promise<void>;
};
export {};

View File

@@ -0,0 +1,22 @@
import { defineCommand } from "../../domain/command.js";
const createKeyCommand = defineCommand({
help: {
commandName: "astro create-key",
tables: {
Flags: [["--help (-h)", "See all available flags."]]
},
description: "Generates a key to encrypt props passed to server islands."
},
async run({ logger, keyGenerator }) {
const key = await keyGenerator.generate();
logger.info(
"crypto",
`Generated a key to encrypt props passed to server islands. To reuse the same key across builds, set this value as ASTRO_KEY in an environment variable on your build server.
ASTRO_KEY=${key}`
);
}
});
export {
createKeyCommand
};

View File

@@ -0,0 +1,3 @@
export interface KeyGenerator {
generate: () => Promise<string>;
}

View File

View File

@@ -0,0 +1,4 @@
import type { KeyGenerator } from '../definitions.js';
export declare class CryptoKeyGenerator implements KeyGenerator {
generate(): Promise<string>;
}

View File

@@ -0,0 +1,11 @@
import { createKey, encodeKey } from "../../../core/encryption.js";
class CryptoKeyGenerator {
async generate() {
const key = await createKey();
const encoded = await encodeKey(key);
return encoded;
}
}
export {
CryptoKeyGenerator
};

4
node_modules/astro/dist/cli/db/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import type { Arguments } from 'yargs-parser';
export declare function db({ flags }: {
flags: Arguments;
}): Promise<void>;

25
node_modules/astro/dist/cli/db/index.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import { resolveConfig } from "../../core/config/config.js";
import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
import { getPackage } from "../install-package.js";
async function db({ flags }) {
const logger = createLoggerFromFlags(flags);
const getPackageOpts = {
skipAsk: !!flags.yes || !!flags.y,
cwd: flags.root
};
const dbPackage = await getPackage("@astrojs/db", logger, getPackageOpts, []);
if (!dbPackage) {
logger.error(
"check",
"The `@astrojs/db` package is required for this command to work. Please manually install it in your project and try again."
);
return;
}
const { cli } = dbPackage;
const inlineConfig = flagsToAstroInlineConfig(flags);
const { astroConfig } = await resolveConfig(inlineConfig, "build");
await cli({ flags, config: astroConfig });
}
export {
db
};

38
node_modules/astro/dist/cli/definitions.d.ts generated vendored Normal file
View File

@@ -0,0 +1,38 @@
import type { StdioOptions } from 'node:child_process';
import type { AnyCommand } from './domain/command.js';
import type { HelpPayload } from './domain/help-payload.js';
export interface HelpDisplay {
shouldFire: () => boolean;
show: (payload: HelpPayload) => void;
}
export interface TextStyler {
bgWhite: (msg: string) => string;
black: (msg: string) => string;
dim: (msg: string) => string;
green: (msg: string) => string;
bold: (msg: string) => string;
bgGreen: (msg: string) => string;
cyan: (msg: string) => string;
}
export interface AstroVersionProvider {
readonly version: string;
}
export interface CommandRunner {
run: <T extends AnyCommand>(command: T, ...args: Parameters<T['run']>) => ReturnType<T['run']> | undefined;
}
export interface CommandExecutorOptions {
cwd?: string;
env?: Record<string, string | undefined>;
shell?: boolean;
input?: string;
stdio?: StdioOptions;
}
export interface CommandExecutor {
execute: (command: string, args?: Array<string>, options?: CommandExecutorOptions) => Promise<{
stdout: string;
}>;
}
export interface OperatingSystemProvider {
readonly name: NodeJS.Platform;
readonly displayName: string;
}

0
node_modules/astro/dist/cli/definitions.js generated vendored Normal file
View File

6
node_modules/astro/dist/cli/dev/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { type Flags } from '../flags.js';
interface DevOptions {
flags: Flags;
}
export declare function dev({ flags }: DevOptions): Promise<import("../../core/dev/dev.js").DevServer | undefined>;
export {};

36
node_modules/astro/dist/cli/dev/index.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
import colors from "piccolore";
import devServer from "../../core/dev/index.js";
import { printHelp } from "../../core/messages/runtime.js";
import { flagsToAstroInlineConfig } from "../flags.js";
async function dev({ flags }) {
if (flags.help || flags.h) {
printHelp({
commandName: "astro dev",
usage: "[...flags]",
tables: {
Flags: [
["--mode", `Specify the mode of the project. Defaults to "development".`],
["--port", `Specify which port to run on. Defaults to 4321.`],
["--host", `Listen on all addresses, including LAN and public addresses.`],
["--host <custom-address>", `Expose on a network IP address at <custom-address>`],
["--open", "Automatically open the app in the browser on server start"],
["--force", "Clear the content layer cache, forcing a full rebuild."],
[
"--allowed-hosts",
"Specify a comma-separated list of allowed hosts or allow any hostname."
],
["--help (-h)", "See all available flags."]
]
},
description: `Check ${colors.cyan(
"https://docs.astro.build/en/reference/cli-reference/#astro-dev"
)} for more information.`
});
return;
}
const inlineConfig = flagsToAstroInlineConfig(flags);
return await devServer(inlineConfig);
}
export {
dev
};

21
node_modules/astro/dist/cli/docs/core/open-docs.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import type { AstroLogger } from '../../../core/logger/core.js';
import type { CommandExecutor, OperatingSystemProvider } from '../../definitions.js';
import type { CloudIdeProvider } from '../definitions.js';
interface Options {
url: string;
operatingSystemProvider: OperatingSystemProvider;
logger: AstroLogger;
commandExecutor: CommandExecutor;
cloudIdeProvider: CloudIdeProvider;
}
export declare const openDocsCommand: {
help: {
commandName: string;
tables: {
Flags: [string, string][];
};
description: string;
};
run({ url, operatingSystemProvider, logger, commandExecutor, cloudIdeProvider }: Options): Promise<void>;
};
export {};

42
node_modules/astro/dist/cli/docs/core/open-docs.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
import { defineCommand } from "../../domain/command.js";
function getExecInputForPlatform(platform) {
switch (platform) {
case "android":
case "linux":
return ["xdg-open"];
case "darwin":
return ["open"];
case "win32":
return ["cmd", ["/c", "start"]];
case "gitpod":
return ["/ide/bin/remote-cli/gitpod-code", ["--openExternal"]];
default:
return null;
}
}
const openDocsCommand = defineCommand({
help: {
commandName: "astro docs",
tables: {
Flags: [["--help (-h)", "See all available flags."]]
},
description: `Launches the Astro Docs website directly from the terminal.`
},
async run({ url, operatingSystemProvider, logger, commandExecutor, cloudIdeProvider }) {
const platform = cloudIdeProvider.name ?? operatingSystemProvider.name;
const input = getExecInputForPlatform(platform);
if (!input) {
logger.error(
"SKIP_FORMAT",
`It looks like your platform ("${platform}") isn't supported!
To view Astro's docs, please visit ${url}`
);
return;
}
const [command, args = []] = input;
await commandExecutor.execute(command, [...args, encodeURI(url)]);
}
});
export {
openDocsCommand
};

4
node_modules/astro/dist/cli/docs/definitions.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import type { CloudIde } from './domain/cloud-ide.js';
export interface CloudIdeProvider {
readonly name: CloudIde | null;
}

0
node_modules/astro/dist/cli/docs/definitions.js generated vendored Normal file
View File

View File

@@ -0,0 +1 @@
export type CloudIde = 'gitpod';

0
node_modules/astro/dist/cli/docs/domain/cloud-ide.js generated vendored Normal file
View File

View File

@@ -0,0 +1,5 @@
import type { CloudIdeProvider } from '../definitions.js';
import type { CloudIde } from '../domain/cloud-ide.js';
export declare class ProcessCloudIdeProvider implements CloudIdeProvider {
readonly name: CloudIde | null;
}

View File

@@ -0,0 +1,6 @@
class ProcessCloudIdeProvider {
name = Boolean(process.env.GITPOD_REPO_ROOT) ? "gitpod" : null;
}
export {
ProcessCloudIdeProvider
};

8
node_modules/astro/dist/cli/domain/command.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import type { HelpPayload } from './help-payload.js';
interface Command<T extends (...args: Array<any>) => any> {
help: HelpPayload;
run: T;
}
export type AnyCommand = Command<(...args: Array<any>) => any>;
export declare function defineCommand<T extends AnyCommand>(command: T): T;
export {};

6
node_modules/astro/dist/cli/domain/command.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
function defineCommand(command) {
return command;
}
export {
defineCommand
};

7
node_modules/astro/dist/cli/domain/help-payload.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export interface HelpPayload {
commandName: string;
headline?: string;
usage?: string;
tables?: Record<string, [command: string, help: string][]>;
description?: string;
}

0
node_modules/astro/dist/cli/domain/help-payload.js generated vendored Normal file
View File

6
node_modules/astro/dist/cli/exec.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { type Options } from 'tinyexec';
/**
* Improve tinyexec error logging and set `throwOnError` to `true` by default
* @deprecated use CommandExecutor instead
*/
export declare function exec(command: string, args?: string[], options?: Partial<Options>): PromiseLike<import("tinyexec").Output>;

23
node_modules/astro/dist/cli/exec.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import { NonZeroExitError, x } from "tinyexec";
function exec(command, args, options) {
return x(command, args, {
throwOnError: true,
...options
}).then(
(o) => o,
(e) => {
if (e instanceof NonZeroExitError) {
const fullCommand = args?.length ? `${command} ${args.map((a) => a.includes(" ") ? `"${a}"` : a).join(" ")}` : command;
const message = `The command \`${fullCommand}\` exited with code ${e.exitCode}`;
const newError = new Error(message, e.cause ? { cause: e.cause } : void 0);
newError.stderr = e.output?.stderr;
newError.stdout = e.output?.stdout;
throw newError;
}
throw e;
}
);
}
export {
exec
};

11
node_modules/astro/dist/cli/flags.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import type { Arguments } from 'yargs-parser';
import type { AstroLogger } from '../core/logger/core.js';
import type { AstroInlineConfig } from '../types/public/config.js';
export type Flags = Arguments;
/** @deprecated Use AstroConfigResolver instead */
export declare function flagsToAstroInlineConfig(flags: Flags): AstroInlineConfig;
/**
* The `logging` is usually created from an `AstroInlineConfig`, but some flows like `add`
* doesn't read the AstroConfig directly, so we create a `logging` object from the CLI flags instead.
*/
export declare function createLoggerFromFlags(flags: Flags): AstroLogger;

37
node_modules/astro/dist/cli/flags.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
import { createNodeLogger, nodeLogDestination } from "../core/logger/node.js";
function flagsToAstroInlineConfig(flags) {
return {
// Inline-only configs
configFile: typeof flags.config === "string" ? flags.config : void 0,
mode: typeof flags.mode === "string" ? flags.mode : void 0,
logLevel: flags.verbose ? "debug" : flags.silent ? "silent" : void 0,
force: flags.force ? true : void 0,
// Astro user configs
root: typeof flags.root === "string" ? flags.root : void 0,
site: typeof flags.site === "string" ? flags.site : void 0,
base: typeof flags.base === "string" ? flags.base : void 0,
outDir: typeof flags.outDir === "string" ? flags.outDir : void 0,
server: {
port: typeof flags.port === "number" ? flags.port : void 0,
host: typeof flags.host === "string" || typeof flags.host === "boolean" ? flags.host : void 0,
open: typeof flags.open === "string" || typeof flags.open === "boolean" ? flags.open : void 0,
allowedHosts: typeof flags.allowedHosts === "string" ? flags.allowedHosts.split(",") : typeof flags.allowedHosts === "boolean" && flags.allowedHosts === true ? flags.allowedHosts : []
}
};
}
function createLoggerFromFlags(flags) {
const logging = {
destination: nodeLogDestination,
level: "info"
};
if (flags.verbose) {
logging.level = "debug";
} else if (flags.silent) {
logging.level = "silent";
}
return createNodeLogger({ logLevel: logging.level });
}
export {
createLoggerFromFlags,
flagsToAstroInlineConfig
};

2
node_modules/astro/dist/cli/help/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import type { HelpPayload } from '../domain/help-payload.js';
export declare const DEFAULT_HELP_PAYLOAD: HelpPayload;

34
node_modules/astro/dist/cli/help/index.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
const DEFAULT_HELP_PAYLOAD = {
commandName: "astro",
usage: "[command] [...flags]",
headline: "Build faster websites.",
tables: {
Commands: [
["add", "Add an integration."],
["build", "Build your project and write it to disk."],
["check", "Check your project for errors."],
["create-key", "Create a cryptography key"],
["db", "Manage your Astro database."],
["dev", "Start the development server."],
["docs", "Open documentation in your web browser."],
["info", "List info about your current Astro setup."],
["preview", "Preview your build locally."],
["sync", "Generate content collection types."],
["preferences", "Configure user preferences."],
["telemetry", "Configure telemetry settings."]
],
"Global Flags": [
["--config <path>", "Specify your config file."],
["--root <path>", "Specify your project root folder."],
["--site <url>", "Specify your project site."],
["--base <pathname>", "Specify your project base."],
["--verbose", "Enable verbose logging."],
["--silent", "Disable all logging."],
["--version", "Show the version number and exit."],
["--help", "Show this help message."]
]
}
};
export {
DEFAULT_HELP_PAYLOAD
};

2
node_modules/astro/dist/cli/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
/** The primary CLI action */
export declare function cli(argv: string[]): Promise<void>;

242
node_modules/astro/dist/cli/index.js generated vendored Normal file
View File

@@ -0,0 +1,242 @@
import yargs from "yargs-parser";
function resolveCommand(flags) {
const cmd = flags._[2];
if (flags.version) return "version";
const supportedCommands = /* @__PURE__ */ new Set([
"add",
"sync",
"telemetry",
"preferences",
"dev",
"build",
"preview",
"check",
"create-key",
"docs",
"db",
"info",
"login",
"logout",
"link",
"init"
]);
if (supportedCommands.has(cmd)) {
return cmd;
}
return "help";
}
async function runCommand(cmd, flags) {
const [
{ createLoggerFromFlags },
{ piccoloreTextStyler: textStyler },
{ BuildTimeAstroVersionProvider },
{ LoggerHelpDisplay },
{ CliCommandRunner }
] = await Promise.all([
import("./flags.js"),
import("./infra/piccolore-text-styler.js"),
import("./infra/build-time-astro-version-provider.js"),
import("./infra/logger-help-display.js"),
import("./infra/cli-command-runner.js")
]);
const logger = createLoggerFromFlags(flags);
const astroVersionProvider = new BuildTimeAstroVersionProvider();
const helpDisplay = new LoggerHelpDisplay({
logger,
flags,
textStyler,
astroVersionProvider
});
const runner = new CliCommandRunner({ helpDisplay });
switch (cmd) {
/** Display --help flag */
case "help": {
const { DEFAULT_HELP_PAYLOAD } = await import("./help/index.js");
helpDisplay.show(DEFAULT_HELP_PAYLOAD);
return;
}
/** Display --version flag */
case "version": {
const { formatVersion } = await import("./utils/format-version.js");
logger.info(
"SKIP_FORMAT",
formatVersion({ name: "astro", textStyler, astroVersionProvider })
);
return;
}
case "info": {
const [
{ ProcessOperatingSystemProvider },
{ CliAstroConfigResolver },
{ ProcessPackageManagerUserAgentProvider },
{ ProcessNodeVersionProvider },
{ CliDebugInfoProvider },
{ TinyexecCommandExecutor },
{ getPackageManager },
{ StyledDebugInfoFormatter },
{ ClackPrompt },
{ TinyclipClipboard },
{ PassthroughTextStyler },
{ infoCommand }
] = await Promise.all([
import("./infra/process-operating-system-provider.js"),
import("./info/infra/cli-astro-config-resolver.js"),
import("./info/infra/process-package-manager-user-agent-provider.js"),
import("./info/infra/process-node-version-provider.js"),
import("./info/infra/cli-debug-info-provider.js"),
import("./infra/tinyexec-command-executor.js"),
import("./info/core/get-package-manager.js"),
import("./info/infra/styled-debug-info-formatter.js"),
import("./info/infra/clack-prompt.js"),
import("./info/infra/tinyclip-clipboard.js"),
import("./infra/passthrough-text-styler.js"),
import("./info/core/info.js")
]);
const operatingSystemProvider = new ProcessOperatingSystemProvider();
const astroConfigResolver = new CliAstroConfigResolver({ flags });
const commandExecutor = new TinyexecCommandExecutor();
const packageManagerUserAgentProvider = new ProcessPackageManagerUserAgentProvider();
const nodeVersionProvider = new ProcessNodeVersionProvider();
const debugInfoProvider = new CliDebugInfoProvider({
config: await astroConfigResolver.resolve(),
astroVersionProvider,
operatingSystemProvider,
packageManager: await getPackageManager({
packageManagerUserAgentProvider,
commandExecutor
}),
nodeVersionProvider
});
const prompt = new ClackPrompt({ force: flags.copy });
const clipboard = new TinyclipClipboard({
logger,
prompt
});
return await runner.run(infoCommand, {
logger,
debugInfoProvider,
getDebugInfoFormatter: ({ pretty }) => new StyledDebugInfoFormatter({
textStyler: pretty ? textStyler : new PassthroughTextStyler()
}),
clipboard
});
}
case "create-key": {
const [{ CryptoKeyGenerator }, { createKeyCommand }] = await Promise.all([
import("./create-key/infra/crypto-key-generator.js"),
import("./create-key/core/create-key.js")
]);
const keyGenerator = new CryptoKeyGenerator();
return await runner.run(createKeyCommand, { logger, keyGenerator });
}
case "docs": {
const [
{ TinyexecCommandExecutor },
{ ProcessOperatingSystemProvider },
{ ProcessCloudIdeProvider },
{ openDocsCommand }
] = await Promise.all([
import("./infra/tinyexec-command-executor.js"),
import("./infra/process-operating-system-provider.js"),
import("./docs/infra/process-cloud-ide-provider.js"),
import("./docs/core/open-docs.js")
]);
const commandExecutor = new TinyexecCommandExecutor();
const operatingSystemProvider = new ProcessOperatingSystemProvider();
const cloudIdeProvider = new ProcessCloudIdeProvider();
return await runner.run(openDocsCommand, {
url: "https://docs.astro.build/",
logger,
commandExecutor,
operatingSystemProvider,
cloudIdeProvider
});
}
case "telemetry": {
const { update } = await import("./telemetry/index.js");
const subcommand = flags._[3]?.toString();
await update(subcommand, { flags });
return;
}
case "sync": {
const { sync } = await import("./sync/index.js");
await sync({ flags });
return;
}
case "preferences": {
const { preferences } = await import("./preferences/index.js");
const [subcommand, key, value] = flags._.slice(3).map((v) => v.toString());
const exitCode = await preferences(subcommand, key, value, { flags });
return process.exit(exitCode);
}
}
if (flags.verbose) {
const { enableVerboseLogging } = await import("../core/logger/node.js");
enableVerboseLogging();
}
const { notify } = await import("./telemetry/index.js");
await notify();
switch (cmd) {
case "add": {
const { add } = await import("./add/index.js");
const packages = flags._.slice(3);
await add(packages, { flags });
return;
}
case "db":
case "login":
case "logout":
case "link":
case "init": {
const { db } = await import("./db/index.js");
await db({ flags });
return;
}
case "dev": {
const { dev } = await import("./dev/index.js");
const server = await dev({ flags });
if (server) {
return await new Promise(() => {
});
}
return;
}
case "build": {
const { build } = await import("./build/index.js");
await build({ flags });
return;
}
case "preview": {
const { preview } = await import("./preview/index.js");
const server = await preview({ flags });
if (server) {
return await server.closed();
}
return;
}
case "check": {
const { check } = await import("./check/index.js");
const checkServer = await check(flags);
if (flags.watch) {
return await new Promise(() => {
});
} else {
return process.exit(typeof checkServer === "boolean" && checkServer ? 1 : 0);
}
}
}
throw new Error(`Error running ${cmd} -- no command found.`);
}
async function cli(argv) {
const flags = yargs(argv, { boolean: ["global"], alias: { g: "global" } });
const cmd = resolveCommand(flags);
try {
await runCommand(cmd, flags);
} catch (err) {
const { throwAndExit } = await import("./throw-and-exit.js");
await throwAndExit(cmd, err);
}
}
export {
cli
};

View File

@@ -0,0 +1,8 @@
import type { CommandExecutor } from '../../definitions.js';
import type { PackageManager, PackageManagerUserAgentProvider } from '../definitions.js';
interface Options {
packageManagerUserAgentProvider: PackageManagerUserAgentProvider;
commandExecutor: CommandExecutor;
}
export declare function getPackageManager({ packageManagerUserAgentProvider, commandExecutor, }: Options): Promise<PackageManager>;
export {};

View File

@@ -0,0 +1,37 @@
async function getPackageManager({
packageManagerUserAgentProvider,
commandExecutor
}) {
if (!packageManagerUserAgentProvider.userAgent) {
const { NoopPackageManager } = await import("../infra/noop-package-manager.js");
return new NoopPackageManager();
}
const specifier = packageManagerUserAgentProvider.userAgent.split(" ")[0];
const _name = specifier.substring(0, specifier.lastIndexOf("/"));
const name = _name === "npminstall" ? "cnpm" : _name;
switch (name) {
case "pnpm": {
const { PnpmPackageManager } = await import("../infra/pnpm-package-manager.js");
return new PnpmPackageManager({ commandExecutor });
}
case "npm": {
const { NpmPackageManager } = await import("../infra/npm-package-manager.js");
return new NpmPackageManager({ commandExecutor });
}
case "yarn": {
const { YarnPackageManager } = await import("../infra/yarn-package-manager.js");
return new YarnPackageManager({ commandExecutor });
}
case "bun": {
const { BunPackageManager } = await import("../infra/bun-package-manager.js");
return new BunPackageManager();
}
default: {
const { NoopPackageManager } = await import("../infra/noop-package-manager.js");
return new NoopPackageManager();
}
}
}
export {
getPackageManager
};

21
node_modules/astro/dist/cli/info/core/info.d.ts generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import type { AstroLogger } from '../../../core/logger/core.js';
import type { Clipboard, DebugInfoFormatter, DebugInfoProvider } from '../definitions.js';
interface Options {
debugInfoProvider: DebugInfoProvider;
getDebugInfoFormatter: (options: {
pretty: boolean;
}) => DebugInfoFormatter;
logger: AstroLogger;
clipboard: Clipboard;
}
export declare const infoCommand: {
help: {
commandName: string;
tables: {
Flags: [string, string][];
};
description: string;
};
run({ debugInfoProvider, getDebugInfoFormatter, logger, clipboard }: Options): Promise<void>;
};
export {};

21
node_modules/astro/dist/cli/info/core/info.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import { defineCommand } from "../../domain/command.js";
const infoCommand = defineCommand({
help: {
commandName: "astro info",
tables: {
Flags: [
["--help (-h)", "See all available flags."],
["--copy", "Force copy of the output."]
]
},
description: "Reports useful information about your current Astro environment. Useful for providing information when opening an issue."
},
async run({ debugInfoProvider, getDebugInfoFormatter, logger, clipboard }) {
const debugInfo = await debugInfoProvider.get();
logger.info("SKIP_FORMAT", getDebugInfoFormatter({ pretty: true }).format(debugInfo));
await clipboard.copy(getDebugInfoFormatter({ pretty: false }).format(debugInfo));
}
});
export {
infoCommand
};

30
node_modules/astro/dist/cli/info/definitions.d.ts generated vendored Normal file
View File

@@ -0,0 +1,30 @@
import type { AstroConfig } from '../../types/public/index.js';
import type { DebugInfo } from './domain/debug-info.js';
export interface DebugInfoProvider {
get: () => Promise<DebugInfo>;
}
export interface DebugInfoFormatter {
format: (info: DebugInfo) => string;
}
export interface Clipboard {
copy: (text: string) => Promise<void>;
}
export interface PackageManager {
readonly name: string;
getPackageVersion: (name: string) => Promise<string | undefined>;
}
export interface AstroConfigResolver {
resolve: () => Promise<AstroConfig>;
}
export interface Prompt {
confirm: (input: {
message: string;
defaultValue?: boolean;
}) => Promise<boolean>;
}
export interface PackageManagerUserAgentProvider {
readonly userAgent: string | null;
}
export interface NodeVersionProvider {
readonly version: string;
}

0
node_modules/astro/dist/cli/info/definitions.js generated vendored Normal file
View File

View File

@@ -0,0 +1 @@
export type DebugInfo = Array<[string, string | Array<string>]>;

View File

View File

@@ -0,0 +1,5 @@
import type { PackageManager } from '../definitions.js';
export declare class BunPackageManager implements PackageManager {
readonly name: string;
getPackageVersion(): Promise<string | undefined>;
}

View File

@@ -0,0 +1,9 @@
class BunPackageManager {
name = "bun";
async getPackageVersion() {
return void 0;
}
}
export {
BunPackageManager
};

View File

@@ -0,0 +1,11 @@
import type { Prompt } from '../definitions.js';
export declare class ClackPrompt implements Prompt {
#private;
constructor({ force }: {
force: boolean;
});
confirm({ message, defaultValue, }: {
message: string;
defaultValue?: boolean;
}): Promise<boolean>;
}

24
node_modules/astro/dist/cli/info/infra/clack-prompt.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import { confirm } from "@clack/prompts";
class ClackPrompt {
#force;
constructor({ force }) {
this.#force = force;
}
async confirm({
message,
defaultValue
}) {
if (this.#force) {
return true;
}
const response = await confirm({
message,
initialValue: defaultValue,
withGuide: false
});
return response === true;
}
}
export {
ClackPrompt
};

View File

@@ -0,0 +1,10 @@
import type { AstroConfig } from '../../../types/public/index.js';
import type { Flags } from '../../flags.js';
import type { AstroConfigResolver } from '../definitions.js';
export declare class CliAstroConfigResolver implements AstroConfigResolver {
#private;
constructor({ flags }: {
flags: Flags;
});
resolve(): Promise<AstroConfig>;
}

View File

@@ -0,0 +1,36 @@
import { resolveConfig } from "../../../core/config/config.js";
class CliAstroConfigResolver {
// TODO: find something better
#flags;
constructor({ flags }) {
this.#flags = flags;
}
async resolve() {
const { astroConfig } = await resolveConfig(
// TODO: consider testing flags => astro inline config
{
// Inline-only configs
configFile: typeof this.#flags.config === "string" ? this.#flags.config : void 0,
mode: typeof this.#flags.mode === "string" ? this.#flags.mode : void 0,
logLevel: this.#flags.verbose ? "debug" : this.#flags.silent ? "silent" : void 0,
force: this.#flags.force ? true : void 0,
// Astro user configs
root: typeof this.#flags.root === "string" ? this.#flags.root : void 0,
site: typeof this.#flags.site === "string" ? this.#flags.site : void 0,
base: typeof this.#flags.base === "string" ? this.#flags.base : void 0,
outDir: typeof this.#flags.outDir === "string" ? this.#flags.outDir : void 0,
server: {
port: typeof this.#flags.port === "number" ? this.#flags.port : void 0,
host: typeof this.#flags.host === "string" || typeof this.#flags.host === "boolean" ? this.#flags.host : void 0,
open: typeof this.#flags.open === "string" || typeof this.#flags.open === "boolean" ? this.#flags.open : void 0,
allowedHosts: typeof this.#flags.allowedHosts === "string" ? this.#flags.allowedHosts.split(",") : typeof this.#flags.allowedHosts === "boolean" && this.#flags.allowedHosts === true ? this.#flags.allowedHosts : []
}
},
"info"
);
return astroConfig;
}
}
export {
CliAstroConfigResolver
};

View File

@@ -0,0 +1,15 @@
import type { AstroConfig } from '../../../types/public/index.js';
import type { AstroVersionProvider, OperatingSystemProvider } from '../../definitions.js';
import type { DebugInfoProvider, NodeVersionProvider, PackageManager } from '../definitions.js';
import type { DebugInfo } from '../domain/debug-info.js';
export declare class CliDebugInfoProvider implements DebugInfoProvider {
#private;
constructor({ config, astroVersionProvider, packageManager, operatingSystemProvider, nodeVersionProvider, }: {
config: Pick<AstroConfig, 'output' | 'adapter' | 'integrations'>;
astroVersionProvider: AstroVersionProvider;
packageManager: PackageManager;
operatingSystemProvider: OperatingSystemProvider;
nodeVersionProvider: NodeVersionProvider;
});
get(): Promise<DebugInfo>;
}

View File

@@ -0,0 +1,57 @@
function withVersion(name, version) {
let result = name;
if (version) {
result += ` (${version})`;
}
return result;
}
class CliDebugInfoProvider {
#config;
#astroVersionProvider;
#packageManager;
#operatingSystemProvider;
#nodeVersionProvider;
constructor({
config,
astroVersionProvider,
packageManager,
operatingSystemProvider,
nodeVersionProvider
}) {
this.#config = config;
this.#astroVersionProvider = astroVersionProvider;
this.#packageManager = packageManager;
this.#operatingSystemProvider = operatingSystemProvider;
this.#nodeVersionProvider = nodeVersionProvider;
}
async get() {
const debugInfo = [
["Astro", `v${this.#astroVersionProvider.version}`],
["Node", this.#nodeVersionProvider.version],
["System", this.#operatingSystemProvider.displayName],
["Package Manager", this.#packageManager.name],
["Output", this.#config.output]
];
const viteVersion = await this.#packageManager.getPackageVersion("vite");
if (viteVersion) {
debugInfo.splice(1, 0, ["Vite", viteVersion]);
}
debugInfo.push([
"Adapter",
this.#config.adapter ? withVersion(
this.#config.adapter.name,
await this.#packageManager.getPackageVersion(this.#config.adapter.name)
) : "none"
]);
const integrations = await Promise.all(
this.#config.integrations.map(
async ({ name }) => withVersion(name, await this.#packageManager.getPackageVersion(name))
)
);
debugInfo.push(["Integrations", integrations.length > 0 ? integrations : "none"]);
return debugInfo;
}
}
export {
CliDebugInfoProvider
};

View File

@@ -0,0 +1,18 @@
import type { AstroConfig } from '../../../types/public/index.js';
import type { AstroVersionProvider, OperatingSystemProvider } from '../../definitions.js';
import type { DebugInfoProvider, NodeVersionProvider, PackageManager } from '../definitions.js';
import type { DebugInfo } from '../domain/debug-info.js';
/**
* Returns debug info without any package versions, to avoid slowing down the dev server
*/
export declare class DevDebugInfoProvider implements DebugInfoProvider {
#private;
constructor({ config, astroVersionProvider, packageManager, operatingSystemProvider, nodeVersionProvider, }: {
config: Pick<AstroConfig, 'output' | 'adapter' | 'integrations'>;
astroVersionProvider: AstroVersionProvider;
packageManager: PackageManager;
operatingSystemProvider: OperatingSystemProvider;
nodeVersionProvider: NodeVersionProvider;
});
get(): Promise<DebugInfo>;
}

View File

@@ -0,0 +1,36 @@
class DevDebugInfoProvider {
#config;
#astroVersionProvider;
#packageManager;
#operatingSystemProvider;
#nodeVersionProvider;
constructor({
config,
astroVersionProvider,
packageManager,
operatingSystemProvider,
nodeVersionProvider
}) {
this.#config = config;
this.#astroVersionProvider = astroVersionProvider;
this.#packageManager = packageManager;
this.#operatingSystemProvider = operatingSystemProvider;
this.#nodeVersionProvider = nodeVersionProvider;
}
async get() {
const debugInfo = [
["Astro", `v${this.#astroVersionProvider.version}`],
["Node", this.#nodeVersionProvider.version],
["System", this.#operatingSystemProvider.displayName],
["Package Manager", this.#packageManager.name],
["Output", this.#config.output],
["Adapter", this.#config.adapter?.name ?? "none"]
];
const integrations = this.#config.integrations.map((integration) => integration.name);
debugInfo.push(["Integrations", integrations.length > 0 ? integrations : "none"]);
return debugInfo;
}
}
export {
DevDebugInfoProvider
};

View File

@@ -0,0 +1,5 @@
import type { PackageManager } from '../definitions.js';
export declare class NoopPackageManager implements PackageManager {
readonly name: string;
getPackageVersion(): Promise<string | undefined>;
}

View File

@@ -0,0 +1,9 @@
class NoopPackageManager {
name = "unknown";
async getPackageVersion() {
return void 0;
}
}
export {
NoopPackageManager
};

View File

@@ -0,0 +1,10 @@
import type { CommandExecutor } from '../../definitions.js';
import type { PackageManager } from '../definitions.js';
export declare class NpmPackageManager implements PackageManager {
#private;
readonly name: string;
constructor({ commandExecutor }: {
commandExecutor: CommandExecutor;
});
getPackageVersion(name: string): Promise<string | undefined>;
}

View File

@@ -0,0 +1,32 @@
class NpmPackageManager {
name = "npm";
#commandExecutor;
constructor({ commandExecutor }) {
this.#commandExecutor = commandExecutor;
}
async getPackageVersion(name) {
try {
const { stdout } = await this.#commandExecutor.execute(
"npm",
["ls", name, "--json", "--depth=1"],
{
shell: true
}
);
const parsedNpmOutput = JSON.parse(stdout);
if (!parsedNpmOutput.dependencies) {
return void 0;
}
if (parsedNpmOutput.dependencies[name]) {
return `v${parsedNpmOutput.dependencies[name].version}`;
}
const astro = parsedNpmOutput.dependencies.astro;
return astro ? `v${astro.dependencies[name].version}` : void 0;
} catch {
return void 0;
}
}
}
export {
NpmPackageManager
};

View File

@@ -0,0 +1,10 @@
import type { CommandExecutor } from '../../definitions.js';
import type { PackageManager } from '../definitions.js';
export declare class PnpmPackageManager implements PackageManager {
#private;
readonly name: string;
constructor({ commandExecutor }: {
commandExecutor: CommandExecutor;
});
getPackageVersion(name: string): Promise<string | undefined>;
}

View File

@@ -0,0 +1,33 @@
function formatPnpmVersionOutput(versionOutput) {
return versionOutput.startsWith("link:") ? "Local" : `v${versionOutput}`;
}
class PnpmPackageManager {
name = "pnpm";
#commandExecutor;
constructor({ commandExecutor }) {
this.#commandExecutor = commandExecutor;
}
async getPackageVersion(name) {
try {
const { stdout } = await this.#commandExecutor.execute("pnpm", ["why", name, "--json"], {
shell: true
});
const parsedOutput = JSON.parse(stdout);
const deps = parsedOutput[0].dependencies;
if (parsedOutput.length === 0 || !deps) {
return void 0;
}
const userProvidedDependency = deps[name];
if (userProvidedDependency) {
return formatPnpmVersionOutput(userProvidedDependency.version);
}
const astroDependency = deps.astro?.dependencies[name];
return astroDependency ? formatPnpmVersionOutput(astroDependency.version) : void 0;
} catch {
return void 0;
}
}
}
export {
PnpmPackageManager
};

View File

@@ -0,0 +1,4 @@
import type { NodeVersionProvider } from '../definitions.js';
export declare class ProcessNodeVersionProvider implements NodeVersionProvider {
readonly version: string;
}

View File

@@ -0,0 +1,6 @@
class ProcessNodeVersionProvider {
version = process.version;
}
export {
ProcessNodeVersionProvider
};

View File

@@ -0,0 +1,4 @@
import type { PackageManagerUserAgentProvider } from '../definitions.js';
export declare class ProcessPackageManagerUserAgentProvider implements PackageManagerUserAgentProvider {
readonly userAgent: string | null;
}

View File

@@ -0,0 +1,7 @@
class ProcessPackageManagerUserAgentProvider {
// https://docs.npmjs.com/cli/v8/using-npm/config#user-agent
userAgent = process.env.npm_config_user_agent ?? null;
}
export {
ProcessPackageManagerUserAgentProvider
};

View File

@@ -0,0 +1,10 @@
import type { TextStyler } from '../../definitions.js';
import type { DebugInfoFormatter } from '../definitions.js';
import type { DebugInfo } from '../domain/debug-info.js';
export declare class StyledDebugInfoFormatter implements DebugInfoFormatter {
#private;
constructor({ textStyler, }: {
textStyler: TextStyler;
});
format(info: DebugInfo): string;
}

View File

@@ -0,0 +1,29 @@
class StyledDebugInfoFormatter {
#textStyler;
#maxPadding = 25;
constructor({
textStyler
}) {
this.#textStyler = textStyler;
}
format(info) {
let output = "";
for (const [label, value] of info) {
const padding = this.#maxPadding - label.length;
const [first, ...rest] = Array.isArray(value) ? value : [value];
let richtext = `
${this.#textStyler.bold(label)}${" ".repeat(padding)}${this.#textStyler.green(first)}`;
if (rest.length > 0) {
for (const entry of rest) {
richtext += `
${" ".repeat(this.#maxPadding)}${this.#textStyler.green(entry)}`;
}
}
output += richtext;
}
return output.trim();
}
}
export {
StyledDebugInfoFormatter
};

View File

@@ -0,0 +1,10 @@
import type { AstroLogger } from '../../../core/logger/core.js';
import type { Clipboard, Prompt } from '../definitions.js';
export declare class TinyclipClipboard implements Clipboard {
#private;
constructor({ logger, prompt, }: {
logger: AstroLogger;
prompt: Prompt;
});
copy(text: string): Promise<void>;
}

View File

@@ -0,0 +1,32 @@
import { writeText } from "tinyclip";
class TinyclipClipboard {
#logger;
#prompt;
constructor({
logger,
prompt
}) {
this.#logger = logger;
this.#prompt = prompt;
}
async copy(text) {
if (!await this.#prompt.confirm({
message: "Copy to clipboard?",
defaultValue: true
})) {
return;
}
try {
await writeText(text.trim());
this.#logger.info("SKIP_FORMAT", "Copied to clipboard!");
} catch {
this.#logger.error(
"SKIP_FORMAT",
"Sorry, something went wrong! Please copy the text above manually."
);
}
}
}
export {
TinyclipClipboard
};

View File

@@ -0,0 +1,10 @@
import type { CommandExecutor } from '../../definitions.js';
import type { PackageManager } from '../definitions.js';
export declare class YarnPackageManager implements PackageManager {
#private;
readonly name: string;
constructor({ commandExecutor }: {
commandExecutor: CommandExecutor;
});
getPackageVersion(name: string): Promise<string | undefined>;
}

View File

@@ -0,0 +1,34 @@
function getYarnOutputDepVersion(dependency, outputLine) {
const parsed = JSON.parse(outputLine);
for (const [key, value] of Object.entries(parsed.children)) {
if (key.startsWith(`${dependency}@`)) {
return `v${value.locator.split(":").pop()}`;
}
}
}
class YarnPackageManager {
name = "yarn";
#commandExecutor;
constructor({ commandExecutor }) {
this.#commandExecutor = commandExecutor;
}
async getPackageVersion(name) {
try {
const { stdout } = await this.#commandExecutor.execute("yarn", ["why", name, "--json"], {
shell: true
});
const hasUserDefinition = stdout.includes("workspace:.");
for (const line of stdout.split("\n")) {
if (hasUserDefinition && line.includes("workspace:."))
return getYarnOutputDepVersion(name, line);
if (!hasUserDefinition && line.includes("astro@"))
return getYarnOutputDepVersion(name, line);
}
} catch {
return void 0;
}
}
}
export {
YarnPackageManager
};

View File

@@ -0,0 +1,4 @@
import type { AstroVersionProvider } from '../definitions.js';
export declare class BuildTimeAstroVersionProvider implements AstroVersionProvider {
readonly version: string;
}

View File

@@ -0,0 +1,7 @@
class BuildTimeAstroVersionProvider {
// Injected during the build through esbuild define
version = "6.1.8";
}
export {
BuildTimeAstroVersionProvider
};

View File

@@ -0,0 +1,9 @@
import type { CommandRunner, HelpDisplay } from '../definitions.js';
import type { AnyCommand } from '../domain/command.js';
export declare class CliCommandRunner implements CommandRunner {
#private;
constructor({ helpDisplay, }: {
helpDisplay: HelpDisplay;
});
run<T extends AnyCommand>(command: T, ...args: Parameters<T['run']>): ReturnType<T['run']> | undefined;
}

View File

@@ -0,0 +1,18 @@
class CliCommandRunner {
#helpDisplay;
constructor({
helpDisplay
}) {
this.#helpDisplay = helpDisplay;
}
run(command, ...args) {
if (this.#helpDisplay.shouldFire()) {
this.#helpDisplay.show(command.help);
return;
}
return command.run(...args);
}
}
export {
CliCommandRunner
};

View File

@@ -0,0 +1,15 @@
import type { AstroLogger } from '../../core/logger/core.js';
import type { AstroVersionProvider, HelpDisplay, TextStyler } from '../definitions.js';
import type { HelpPayload } from '../domain/help-payload.js';
import type { Flags } from '../flags.js';
export declare class LoggerHelpDisplay implements HelpDisplay {
#private;
constructor({ logger, textStyler, astroVersionProvider, flags, }: {
logger: AstroLogger;
textStyler: TextStyler;
astroVersionProvider: AstroVersionProvider;
flags: Flags;
});
shouldFire(): boolean;
show({ commandName, description, headline, tables, usage }: HelpPayload): void;
}

View File

@@ -0,0 +1,71 @@
import { formatVersion } from "../utils/format-version.js";
class LoggerHelpDisplay {
#logger;
#textStyler;
#astroVersionProvider;
// TODO: find something better
#flags;
constructor({
logger,
textStyler,
astroVersionProvider,
flags
}) {
this.#logger = logger;
this.#textStyler = textStyler;
this.#astroVersionProvider = astroVersionProvider;
this.#flags = flags;
}
shouldFire() {
return !!(this.#flags.help || this.#flags.h);
}
show({ commandName, description, headline, tables, usage }) {
const linebreak = () => "";
const title = (label) => ` ${this.#textStyler.bgWhite(this.#textStyler.black(` ${label} `))}`;
const table = (rows, { padding }) => {
const split = process.stdout.columns < 60;
let raw = "";
for (const row of rows) {
if (split) {
raw += ` ${row[0]}
`;
} else {
raw += `${`${row[0]}`.padStart(padding)}`;
}
raw += " " + this.#textStyler.dim(row[1]) + "\n";
}
return raw.slice(0, -1);
};
let message = [];
if (headline) {
message.push(
linebreak(),
`${formatVersion({ name: commandName, textStyler: this.#textStyler, astroVersionProvider: this.#astroVersionProvider })} ${headline}`
);
}
if (usage) {
message.push(
linebreak(),
` ${this.#textStyler.green(commandName)} ${this.#textStyler.bold(usage)}`
);
}
if (tables) {
let calculateTablePadding2 = function(rows) {
return rows.reduce((val, [first]) => Math.max(val, first.length), 0) + 2;
};
var calculateTablePadding = calculateTablePadding2;
const tableEntries = Object.entries(tables);
const padding = Math.max(...tableEntries.map(([, rows]) => calculateTablePadding2(rows)));
for (const [tableTitle, tableRows] of tableEntries) {
message.push(linebreak(), title(tableTitle), table(tableRows, { padding }));
}
}
if (description) {
message.push(linebreak(), `${description}`);
}
this.#logger.info("SKIP_FORMAT", message.join("\n") + "\n");
}
}
export {
LoggerHelpDisplay
};

View File

@@ -0,0 +1,10 @@
import type { TextStyler } from '../definitions.js';
export declare class PassthroughTextStyler implements TextStyler {
bgWhite(msg: string): string;
black(msg: string): string;
dim(msg: string): string;
green(msg: string): string;
bold(msg: string): string;
bgGreen(msg: string): string;
cyan(msg: string): string;
}

View File

@@ -0,0 +1,26 @@
class PassthroughTextStyler {
bgWhite(msg) {
return msg;
}
black(msg) {
return msg;
}
dim(msg) {
return msg;
}
green(msg) {
return msg;
}
bold(msg) {
return msg;
}
bgGreen(msg) {
return msg;
}
cyan(msg) {
return msg;
}
}
export {
PassthroughTextStyler
};

View File

@@ -0,0 +1,2 @@
import type { TextStyler } from '../definitions.js';
export declare const piccoloreTextStyler: TextStyler;

View File

@@ -0,0 +1,5 @@
import colors from "piccolore";
const piccoloreTextStyler = colors;
export {
piccoloreTextStyler
};

View File

@@ -0,0 +1,6 @@
import type { OperatingSystemProvider } from '../definitions.js';
export declare class ProcessOperatingSystemProvider implements OperatingSystemProvider {
#private;
readonly name: NodeJS.Platform;
readonly displayName: string;
}

View File

@@ -0,0 +1,12 @@
class ProcessOperatingSystemProvider {
#platformToOs = {
darwin: "macOS",
win32: "Windows",
linux: "Linux"
};
name = process.platform;
displayName = `${this.#platformToOs[this.name] ?? this.name} (${process.arch})`;
}
export {
ProcessOperatingSystemProvider
};

View File

@@ -0,0 +1,6 @@
import type { CommandExecutor, CommandExecutorOptions } from '../definitions.js';
export declare class TinyexecCommandExecutor implements CommandExecutor {
execute(command: string, args?: Array<string>, options?: CommandExecutorOptions): Promise<{
stdout: string;
}>;
}

View File

@@ -0,0 +1,34 @@
import { NonZeroExitError, x } from "tinyexec";
class TinyexecCommandExecutor {
async execute(command, args, options) {
const proc = x(command, args, {
throwOnError: true,
nodeOptions: {
cwd: options?.cwd,
env: options?.env,
shell: options?.shell,
stdio: options?.stdio
}
});
if (options?.input) {
proc.process?.stdin?.end(options.input);
}
return await proc.then(
(o) => o,
(e) => {
if (e instanceof NonZeroExitError) {
const fullCommand = args?.length ? `${command} ${args.map((a) => a.includes(" ") ? `"${a}"` : a).join(" ")}` : command;
const message = `The command \`${fullCommand}\` exited with code ${e.exitCode}`;
const newError = new Error(message, e.cause ? { cause: e.cause } : void 0);
newError.stderr = e.output?.stderr;
newError.stdout = e.output?.stdout;
throw newError;
}
throw e;
}
);
}
}
export {
TinyexecCommandExecutor
};

10
node_modules/astro/dist/cli/install-package.d.ts generated vendored Normal file
View File

@@ -0,0 +1,10 @@
import type { AstroLogger } from '../core/logger/core.js';
type GetPackageOptions = {
skipAsk?: boolean;
optional?: boolean;
cwd?: string;
};
export declare function getPackage<T>(packageName: string, logger: AstroLogger, options: GetPackageOptions, otherDeps?: string[]): Promise<T | undefined>;
export declare function fetchPackageJson(scope: string | undefined, name: string, tag: string): Promise<Record<string, any> | Error>;
export declare function fetchPackageVersions(packageName: string): Promise<string[] | Error>;
export {};

137
node_modules/astro/dist/cli/install-package.js generated vendored Normal file
View File

@@ -0,0 +1,137 @@
import { createRequire } from "node:module";
import * as clack from "@clack/prompts";
import ci from "ci-info";
import { detect, resolveCommand } from "package-manager-detector";
import colors from "piccolore";
import { exec } from "./exec.js";
const require2 = createRequire(import.meta.url);
const { bold, cyan, dim, magenta } = colors;
async function getPackage(packageName, logger, options, otherDeps = []) {
try {
require2.resolve(packageName, { paths: [options.cwd ?? process.cwd()] });
const packageImport = await import(packageName);
return packageImport;
} catch {
if (options.optional) return void 0;
let message = `To continue, Astro requires the following dependency to be installed: ${bold(
packageName
)}.`;
if (ci.isCI) {
message += ` Packages cannot be installed automatically in CI environments.`;
}
logger.info("SKIP_FORMAT", message);
if (ci.isCI) {
return void 0;
}
const result = await installPackage([packageName, ...otherDeps], options, logger);
if (result) {
const packageImport = await import(packageName);
return packageImport;
} else {
return void 0;
}
}
}
async function installPackage(packageNames, options, logger) {
const cwd = options.cwd ?? process.cwd();
const packageManager = await detect({
cwd,
// Include the `install-metadata` strategy to have the package manager that's
// used for installation take precedence
strategies: ["install-metadata", "lockfile", "packageManager-field"]
});
const installCommand = resolveCommand(packageManager?.agent ?? "npm", "add", []);
if (!installCommand) return false;
if (installCommand.command === "deno") {
packageNames = packageNames.map((name) => `npm:${name}`);
}
const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(" ")} ${cyan(packageNames.join(" "))}`;
logger.info(
"SKIP_FORMAT",
`
${magenta("Astro will run the following command:")}
${dim(
"If you skip this step, you can always run it yourself later"
)}`
);
clack.box(coloredOutput, void 0, {
rounded: true,
withGuide: false,
width: "auto"
});
let response;
if (options.skipAsk) {
response = true;
} else {
response = await clack.confirm({
message: colors.bold("Continue?"),
initialValue: true,
withGuide: false
}) === true;
}
if (Boolean(response)) {
const spinner = clack.spinner({ withGuide: false });
spinner.start("Installing dependencies...");
try {
await exec(installCommand.command, [...installCommand.args, ...packageNames], {
nodeOptions: {
cwd,
// reset NODE_ENV to ensure install command run in dev mode
env: { NODE_ENV: void 0 }
}
});
spinner.stop("Dependencies installed.");
return true;
} catch (err) {
logger.debug("add", "Error installing dependencies", err);
spinner.error("Failed to install dependencies.");
return false;
}
} else {
return false;
}
}
async function fetchPackageJson(scope, name, tag) {
const packageName = `${scope ? `${scope}/` : ""}${name}`;
const registry = await getRegistry();
const res = await fetch(`${registry}/${packageName}/${tag}`);
if (res.status >= 200 && res.status < 300) {
return await res.json();
} else if (res.status === 404) {
return new Error();
} else {
return new Error(`Failed to fetch ${registry}/${packageName}/${tag} - GET ${res.status}`);
}
}
async function fetchPackageVersions(packageName) {
const registry = await getRegistry();
const res = await fetch(`${registry}/${packageName}`, {
headers: { accept: "application/vnd.npm.install-v1+json" }
});
if (res.status >= 200 && res.status < 300) {
return await res.json().then((data) => Object.keys(data.versions));
} else if (res.status === 404) {
return new Error();
} else {
return new Error(`Failed to fetch ${registry}/${packageName} - GET ${res.status}`);
}
}
let _registry;
async function getRegistry() {
if (_registry) return _registry;
const fallback = "https://registry.npmjs.org";
const packageManager = (await detect())?.name || "npm";
try {
const { stdout } = await exec(packageManager, ["config", "get", "registry"]);
_registry = stdout.trim()?.replace(/\/$/, "") || fallback;
if (!new URL(_registry).host) _registry = fallback;
} catch {
_registry = fallback;
}
return _registry;
}
export {
fetchPackageJson,
fetchPackageVersions,
getPackage
};

6
node_modules/astro/dist/cli/preferences/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { type Flags } from '../flags.js';
interface PreferencesOptions {
flags: Flags;
}
export declare function preferences(subcommand: string, key: string, value: string | undefined, { flags }: PreferencesOptions): Promise<number>;
export {};

301
node_modules/astro/dist/cli/preferences/index.js generated vendored Normal file
View File

@@ -0,0 +1,301 @@
import { fileURLToPath } from "node:url";
import { formatWithOptions } from "node:util";
import { flattie } from "flattie";
import colors from "piccolore";
import { resolveConfig } from "../../core/config/config.js";
import { createSettings } from "../../core/config/settings.js";
import { collectErrorMetadata } from "../../core/errors/dev/utils.js";
import * as msg from "../../core/messages/runtime.js";
import { DEFAULT_PREFERENCES } from "../../preferences/defaults.js";
import dlv from "../../preferences/dlv.js";
import { coerce, isValidKey } from "../../preferences/index.js";
import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
const { bgGreen, black, bold, dim, yellow } = colors;
const PREFERENCES_SUBCOMMANDS = [
"get",
"set",
"enable",
"disable",
"delete",
"reset",
"list"
];
function isValidSubcommand(subcommand) {
return PREFERENCES_SUBCOMMANDS.includes(subcommand);
}
async function preferences(subcommand, key, value, { flags }) {
if (!isValidSubcommand(subcommand) || flags?.help || flags?.h) {
msg.printHelp({
commandName: "astro preferences",
usage: "[command]",
tables: {
Commands: [
["list", "Pretty print all current preferences"],
["list --json", "Log all current preferences as a JSON object"],
["get [key]", "Log current preference value"],
["set [key] [value]", "Update preference value"],
["reset [key]", "Reset preference value to default"],
["enable [key]", "Set a boolean preference to true"],
["disable [key]", "Set a boolean preference to false"]
],
Flags: [
[
"--global",
"Scope command to global preferences (all Astro projects) rather than the current project"
]
]
}
});
return 0;
}
const inlineConfig = flagsToAstroInlineConfig(flags);
const logger = createLoggerFromFlags(flags);
const { astroConfig } = await resolveConfig(inlineConfig ?? {}, "dev");
const settings = await createSettings(
astroConfig,
inlineConfig.logLevel,
fileURLToPath(astroConfig.root)
);
const opts = {
location: flags.global ? "global" : void 0,
json: !!flags.json
};
if (subcommand === "list") {
return listPreferences(settings, opts);
}
if (subcommand === "enable" || subcommand === "disable") {
key = `${key}.enabled`;
}
if (!isValidKey(key)) {
logger.error("preferences", `Unknown preference "${key}"
`);
return 1;
}
if (subcommand === "set" && value === void 0) {
const type = typeof dlv(DEFAULT_PREFERENCES, key);
console.error(
msg.formatErrorMessage(
collectErrorMetadata(new Error(`Please provide a ${type} value for "${key}"`)),
true
)
);
return 1;
}
switch (subcommand) {
case "get":
return getPreference(settings, key, opts);
case "set":
return setPreference(settings, key, value, opts);
case "reset":
case "delete":
return resetPreference(settings, key, opts);
case "enable":
return enablePreference(settings, key, opts);
case "disable":
return disablePreference(settings, key, opts);
}
}
async function getPreference(settings, key, { location = "project" }) {
try {
let value = await settings.preferences.get(key, { location });
if (value && typeof value === "object" && !Array.isArray(value)) {
if (Object.keys(value).length === 0) {
value = dlv(DEFAULT_PREFERENCES, key);
console.log(msg.preferenceDefaultIntro(key));
}
prettyPrint({ [key]: value });
return 0;
}
if (value === void 0) {
const defaultValue = await settings.preferences.get(key);
console.log(msg.preferenceDefault(key, defaultValue));
return 0;
}
console.log(msg.preferenceGet(key, value));
return 0;
} catch {
}
return 1;
}
async function setPreference(settings, key, value, { location }) {
try {
const defaultType = typeof dlv(DEFAULT_PREFERENCES, key);
if (typeof coerce(key, value) !== defaultType) {
throw new Error(`${key} expects a "${defaultType}" value!`);
}
await settings.preferences.set(key, coerce(key, value), { location });
console.log(msg.preferenceSet(key, value));
return 0;
} catch (e) {
if (e instanceof Error) {
console.error(msg.formatErrorMessage(collectErrorMetadata(e), true));
return 1;
}
throw e;
}
}
async function enablePreference(settings, key, { location }) {
try {
await settings.preferences.set(key, true, { location });
console.log(msg.preferenceEnabled(key.replace(".enabled", "")));
return 0;
} catch {
}
return 1;
}
async function disablePreference(settings, key, { location }) {
try {
await settings.preferences.set(key, false, { location });
console.log(msg.preferenceDisabled(key.replace(".enabled", "")));
return 0;
} catch {
}
return 1;
}
async function resetPreference(settings, key, { location }) {
try {
await settings.preferences.set(key, void 0, { location });
console.log(msg.preferenceReset(key));
return 0;
} catch {
}
return 1;
}
function annotate(flat, annotation) {
return Object.fromEntries(
Object.entries(flat).map(([key, value]) => [key, { annotation, value }])
);
}
function userValues(flatDefault, flatProject, flatGlobal) {
const result = {};
for (const key of Object.keys(flatDefault)) {
if (key in flatProject) {
result[key] = {
value: flatProject[key],
annotation: ""
};
if (key in flatGlobal) {
result[key].annotation += ` (also modified globally)`;
}
} else if (key in flatGlobal) {
result[key] = { value: flatGlobal[key], annotation: "(global)" };
}
}
return result;
}
async function listPreferences(settings, { location, json }) {
if (json) {
const resolved = await settings.preferences.getAll();
console.log(JSON.stringify(resolved, null, 2));
return 0;
}
const { global, project, fromAstroConfig, defaults } = await settings.preferences.list({
location
});
const flatProject = flattie(project);
const flatGlobal = flattie(global);
const flatDefault = flattie(defaults);
const flatUser = userValues(flatDefault, flatProject, flatGlobal);
const userKeys = Object.keys(flatUser);
if (userKeys.length > 0) {
const badge = bgGreen(black(` Your Preferences `));
const table = formatTable(flatUser, ["Preference", "Value"]);
console.log(["", badge, table].join("\n"));
} else {
const badge = bgGreen(black(` Your Preferences `));
const message = dim("No preferences set");
console.log(["", badge, "", message].join("\n"));
}
const flatUnset = annotate(Object.assign({}, flatDefault), "");
for (const key of userKeys) {
delete flatUnset[key];
}
const unsetKeys = Object.keys(flatUnset);
if (unsetKeys.length > 0) {
const badge = bgGreen(black(` Default Preferences `));
const table = formatTable(flatUnset, ["Preference", "Value"]);
console.log(["", badge, table].join("\n"));
} else {
const badge = bgGreen(black(` Default Preferences `));
const message = dim("All preferences have been set");
console.log(["", badge, "", message].join("\n"));
}
if (fromAstroConfig.devToolbar?.enabled === false && flatUser["devToolbar.enabled"]?.value !== false) {
console.log(
yellow(
"The dev toolbar is currently disabled. To enable it, set devToolbar: {enabled: true} in your astroConfig file."
)
);
}
return 0;
}
function prettyPrint(value) {
const flattened = flattie(value);
const table = formatTable(flattened, ["Preference", "Value"]);
console.log(table);
}
const chars = {
h: "\u2500",
hThick: "\u2501",
hThickCross: "\u253F",
v: "\u2502",
vRight: "\u251C",
vRightThick: "\u251D",
vLeft: "\u2524",
vLeftThick: "\u2525",
hTop: "\u2534",
hBottom: "\u252C",
topLeft: "\u256D",
topRight: "\u256E",
bottomLeft: "\u2570",
bottomRight: "\u256F"
};
function annotatedFormat(mv) {
return mv.annotation ? `${mv.value} ${mv.annotation}` : mv.value.toString();
}
function formatAnnotated(mv, style = (v) => v.toString()) {
return mv.annotation ? `${style(String(mv.value))} ${dim(mv.annotation)}` : style(String(mv.value));
}
function formatTable(object, columnLabels) {
const [colA, colB] = columnLabels;
const colALength = [colA, ...Object.keys(object)].reduce(longest, 0) + 3;
const colBLength = [colB, ...Object.values(object).map(annotatedFormat)].reduce(longest, 0) + 3;
function formatRow(_i, a, b, style = (v) => v.toString()) {
return `${dim(chars.v)} ${style(a)} ${space(colALength - a.length - 2)} ${dim(
chars.v
)} ${formatAnnotated(b, style)} ${space(colBLength - annotatedFormat(b).length - 3)} ${dim(
chars.v
)}`;
}
const top = dim(
`${chars.topLeft}${chars.h.repeat(colALength + 1)}${chars.hBottom}${chars.h.repeat(
colBLength
)}${chars.topRight}`
);
const bottom = dim(
`${chars.bottomLeft}${chars.h.repeat(colALength + 1)}${chars.hTop}${chars.h.repeat(
colBLength
)}${chars.bottomRight}`
);
const divider = dim(
`${chars.vRightThick}${chars.hThick.repeat(colALength + 1)}${chars.hThickCross}${chars.hThick.repeat(colBLength)}${chars.vLeftThick}`
);
const rows = [top, formatRow(-1, colA, { value: colB, annotation: "" }, bold), divider];
let i = 0;
for (const [key, value] of Object.entries(object)) {
rows.push(formatRow(i, key, value, (v) => formatWithOptions({ colors: true }, v)));
i++;
}
rows.push(bottom);
return rows.join("\n");
}
function space(len) {
return " ".repeat(len);
}
const longest = (a, b) => {
const { length: len } = b.toString();
return a > len ? a : len;
};
export {
preferences
};

6
node_modules/astro/dist/cli/preview/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { type Flags } from '../flags.js';
interface PreviewOptions {
flags: Flags;
}
export declare function preview({ flags }: PreviewOptions): Promise<import("../../index.js").PreviewServer | undefined>;
export {};

34
node_modules/astro/dist/cli/preview/index.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
import colors from "piccolore";
import { printHelp } from "../../core/messages/runtime.js";
import previewServer from "../../core/preview/index.js";
import { flagsToAstroInlineConfig } from "../flags.js";
async function preview({ flags }) {
if (flags?.help || flags?.h) {
printHelp({
commandName: "astro preview",
usage: "[...flags]",
tables: {
Flags: [
["--port", `Specify which port to run on. Defaults to 4321.`],
["--host", `Listen on all addresses, including LAN and public addresses.`],
["--host <custom-address>", `Expose on a network IP address at <custom-address>`],
["--open", "Automatically open the app in the browser on server start"],
[
"--allowed-hosts",
"Specify a comma-separated list of allowed hosts or allow any hostname."
],
["--help (-h)", "See all available flags."]
]
},
description: `Starts a local server to serve your static dist/ directory. Check ${colors.cyan(
"https://docs.astro.build/en/reference/cli-reference/#astro-preview"
)} for more information.`
});
return;
}
const inlineConfig = flagsToAstroInlineConfig(flags);
return await previewServer(inlineConfig);
}
export {
preview
};

6
node_modules/astro/dist/cli/sync/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { type Flags } from '../flags.js';
interface SyncOptions {
flags: Flags;
}
export declare function sync({ flags }: SyncOptions): Promise<0 | undefined>;
export {};

23
node_modules/astro/dist/cli/sync/index.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import { printHelp } from "../../core/messages/runtime.js";
import _sync from "../../core/sync/index.js";
import { flagsToAstroInlineConfig } from "../flags.js";
async function sync({ flags }) {
if (flags?.help || flags?.h) {
printHelp({
commandName: "astro sync",
usage: "[...flags]",
tables: {
Flags: [
["--force", "Clear the content layer cache, forcing a full rebuild."],
["--help (-h)", "See all available flags."]
]
},
description: `Generates TypeScript types for all Astro modules.`
});
return 0;
}
await _sync(flagsToAstroInlineConfig(flags), { telemetry: true });
}
export {
sync
};

7
node_modules/astro/dist/cli/telemetry/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import { type Flags } from '../flags.js';
interface TelemetryOptions {
flags: Flags;
}
export declare function notify(): Promise<void>;
export declare function update(subcommand: string, { flags }: TelemetryOptions): Promise<void>;
export {};

48
node_modules/astro/dist/cli/telemetry/index.js generated vendored Normal file
View File

@@ -0,0 +1,48 @@
import * as msg from "../../core/messages/runtime.js";
import { telemetry } from "../../events/index.js";
import { createLoggerFromFlags } from "../flags.js";
async function notify() {
await telemetry.notify(() => {
console.log(msg.telemetryNotice() + "\n");
return true;
});
}
async function update(subcommand, { flags }) {
const isValid = ["enable", "disable", "reset"].includes(subcommand);
const logger = createLoggerFromFlags(flags);
if (flags.help || flags.h || !isValid) {
msg.printHelp({
commandName: "astro telemetry",
usage: "[command]",
tables: {
Commands: [
["enable", "Enable anonymous data collection."],
["disable", "Disable anonymous data collection."],
["reset", "Reset anonymous data collection settings."]
]
}
});
return;
}
switch (subcommand) {
case "enable": {
telemetry.setEnabled(true);
logger.info("SKIP_FORMAT", msg.telemetryEnabled());
return;
}
case "disable": {
telemetry.setEnabled(false);
logger.info("SKIP_FORMAT", msg.telemetryDisabled());
return;
}
case "reset": {
telemetry.clear();
logger.info("SKIP_FORMAT", msg.telemetryReset());
return;
}
}
}
export {
notify,
update
};

2
node_modules/astro/dist/cli/throw-and-exit.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
/** Display error and exit */
export declare function throwAndExit(cmd: string, err: unknown): Promise<void>;

25
node_modules/astro/dist/cli/throw-and-exit.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import { collectErrorMetadata } from "../core/errors/dev/index.js";
import { isAstroConfigZodError } from "../core/errors/errors.js";
import { createSafeError } from "../core/errors/index.js";
import { debug } from "../core/logger/core.js";
import { formatErrorMessage } from "../core/messages/runtime.js";
import { eventError, telemetry } from "../events/index.js";
async function throwAndExit(cmd, err) {
if (isAstroConfigZodError(err)) {
process.exit(1);
}
let telemetryPromise;
let errorMessage;
function exitWithErrorMessage() {
console.error(errorMessage);
process.exit(1);
}
const errorWithMetadata = collectErrorMetadata(createSafeError(err));
telemetryPromise = telemetry.record(eventError({ cmd, err: errorWithMetadata, isFatal: true }));
errorMessage = formatErrorMessage(errorWithMetadata, true);
setTimeout(exitWithErrorMessage, 400);
await telemetryPromise.catch((err2) => debug("telemetry", `record() error: ${err2.message}`)).then(exitWithErrorMessage);
}
export {
throwAndExit
};

View File

@@ -0,0 +1,8 @@
import type { AstroVersionProvider, TextStyler } from '../definitions.js';
interface Options {
name: string;
textStyler: TextStyler;
astroVersionProvider: AstroVersionProvider;
}
export declare function formatVersion({ name, textStyler, astroVersionProvider }: Options): string;
export {};

8
node_modules/astro/dist/cli/utils/format-version.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
function formatVersion({ name, textStyler, astroVersionProvider }) {
return ` ${textStyler.bgGreen(textStyler.black(` ${name} `))} ${textStyler.green(
`v${astroVersionProvider.version}`
)}`;
}
export {
formatVersion
};