index.ts — astro Source File
Architecture documentation for index.ts, a typescript file in the astro codebase. 13 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR f7d3fd10_bcd7_7c85_17b8_a4feb9026da8["index.ts"] 0b371444_fc7b_922f_b8b5_b663fe1868ae["../config/config.js"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> 0b371444_fc7b_922f_b8b5_b663fe1868ae be05b58c_f851_32bc_6dab_b19e296f04b4["../config/settings.js"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> be05b58c_f851_32bc_6dab_b19e296f04b4 5c1f16d1_f599_2e31_eb17_4c8b8189d4ed["../errors/dev/utils.js"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> 5c1f16d1_f599_2e31_eb17_4c8b8189d4ed 8db17b08_b9e5_db7e_cd39_46be76c6d5ad["../core/messages.js"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> 8db17b08_b9e5_db7e_cd39_46be76c6d5ad e9868a50_a3db_d2ef_89ae_e9f3592bf265["./defaults.js"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> e9868a50_a3db_d2ef_89ae_e9f3592bf265 a170ca6a_e9d2_0356_ff6d_60b52ee58679["../preferences/index.js"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> a170ca6a_e9d2_0356_ff6d_60b52ee58679 e9b74c5a_8d34_34a7_e196_5e41b87214aa["../types/astro.js"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> e9b74c5a_8d34_34a7_e196_5e41b87214aa 9323e55c_9236_cd3d_d0b3_e20df52a4e84["../flags.js"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> 9323e55c_9236_cd3d_d0b3_e20df52a4e84 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> d9a92db9_c95e_9165_13ac_24b3d859d946 b4a76fc8_3591_85b4_7b57_55ab21d1030d["node:util"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> b4a76fc8_3591_85b4_7b57_55ab21d1030d d9073335_b3f3_9f7a_62f3_5035edaf179b["dlv"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> d9073335_b3f3_9f7a_62f3_5035edaf179b 590998ce_4969_7d40_b2ad_78725f5cf594["flattie"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> 590998ce_4969_7d40_b2ad_78725f5cf594 10250468_0e83_bd69_43e9_3bcef2294a91["piccolore"] f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 --> 10250468_0e83_bd69_43e9_3bcef2294a91 style f7d3fd10_bcd7_7c85_17b8_a4feb9026da8 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { fileURLToPath } from 'node:url';
import { formatWithOptions } from 'node:util';
import dlv from 'dlv';
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.js';
import { DEFAULT_PREFERENCES } from '../../preferences/defaults.js';
import { coerce, isValidKey, type PreferenceKey } from '../../preferences/index.js';
import type { AstroSettings } from '../../types/astro.js';
import { createLoggerFromFlags, type Flags, flagsToAstroInlineConfig } from '../flags.js';
const { bgGreen, black, bold, dim, yellow } = colors;
interface PreferencesOptions {
flags: Flags;
}
const PREFERENCES_SUBCOMMANDS = [
'get',
'set',
'enable',
'disable',
'delete',
'reset',
'list',
] as const;
type Subcommand = (typeof PREFERENCES_SUBCOMMANDS)[number];
type AnnotatedValue = { annotation: string; value: string | number | boolean };
type AnnotatedValues = Record<string, AnnotatedValue>;
function isValidSubcommand(subcommand: string): subcommand is Subcommand {
return PREFERENCES_SUBCOMMANDS.includes(subcommand as Subcommand);
}
export async function preferences(
subcommand: string,
key: string,
value: string | undefined,
{ flags }: PreferencesOptions,
): Promise<number> {
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: [
[
// ... (325 more lines)
Domain
Subdomains
Functions
Dependencies
- ../config/config.js
- ../config/settings.js
- ../core/messages.js
- ../errors/dev/utils.js
- ../flags.js
- ../preferences/index.js
- ../types/astro.js
- ./defaults.js
- dlv
- flattie
- node:url
- node:util
- piccolore
Source
Frequently Asked Questions
What does index.ts do?
index.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What functions are defined in index.ts?
index.ts defines 16 function(s): annotate, annotatedFormat, disablePreference, enablePreference, formatAnnotated, formatTable, getPreference, isValidSubcommand, listPreferences, longest, and 6 more.
What does index.ts depend on?
index.ts imports 13 module(s): ../config/config.js, ../config/settings.js, ../core/messages.js, ../errors/dev/utils.js, ../flags.js, ../preferences/index.js, ../types/astro.js, ./defaults.js, and 5 more.
Where is index.ts in the architecture?
index.ts is located at packages/astro/src/cli/preferences/index.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/cli/preferences).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free