index.ts — astro Source File
Architecture documentation for index.ts, a typescript file in the astro codebase. 8 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR ec2c5796_49f3_c23d_04c9_a07265587893["index.ts"] c6914598_8933_ca4d_5510_f4d0211d27b8["./options.js"] ec2c5796_49f3_c23d_04c9_a07265587893 --> c6914598_8933_ca4d_5510_f4d0211d27b8 3955a637_4c78_0528_fe7c_92190a232cb0["node:module"] ec2c5796_49f3_c23d_04c9_a07265587893 --> 3955a637_4c78_0528_fe7c_92190a232cb0 c52a5f83_66e3_37d7_9ebb_767f7129bc62["node:path"] ec2c5796_49f3_c23d_04c9_a07265587893 --> c52a5f83_66e3_37d7_9ebb_767f7129bc62 e03b3a62_3266_b65a_a8da_3c480b864c38["language-server"] ec2c5796_49f3_c23d_04c9_a07265587893 --> e03b3a62_3266_b65a_a8da_3c480b864c38 3699dd72_81f4_3049_2117_947fd1634dc4["chokidar"] ec2c5796_49f3_c23d_04c9_a07265587893 --> 3699dd72_81f4_3049_2117_947fd1634dc4 80b99928_2154_ad65_1f34_9c854d2c9ec5["colors"] ec2c5796_49f3_c23d_04c9_a07265587893 --> 80b99928_2154_ad65_1f34_9c854d2c9ec5 7ca62b16_8990_ba4d_5a67_db195636c248["yargs"] ec2c5796_49f3_c23d_04c9_a07265587893 --> 7ca62b16_8990_ba4d_5a67_db195636c248 6b2b2203_c177_3f66_491b_a79a468068d3["helpers"] ec2c5796_49f3_c23d_04c9_a07265587893 --> 6b2b2203_c177_3f66_491b_a79a468068d3 style ec2c5796_49f3_c23d_04c9_a07265587893 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { createRequire } from 'node:module';
import path from 'node:path';
import { AstroCheck } from '@astrojs/language-server';
import { watch } from 'chokidar';
import { bold, dim, red, yellow } from 'kleur/colors';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { options } from './options.js';
/**
* Given a list of arguments from the command line (such as `process.argv`), return parsed and processed options
*/
export function parseArgsAsCheckConfig(args: string[]) {
return yargs(hideBin(args)).options(options).parseSync();
}
export type Flags = Pick<ReturnType<typeof parseArgsAsCheckConfig>, keyof typeof options>;
export async function check(flags: Partial<Flags> & { watch: true }): Promise<void>;
export async function check(flags: Partial<Flags> & { watch: false }): Promise<boolean>;
export async function check(flags: Partial<Flags>): Promise<boolean | void>;
/**
* Print diagnostics according to the given flags, and return whether or not the program should exit with an error code.
*/
export async function check(flags: Partial<Flags>): Promise<boolean | void> {
const workspaceRoot = path.resolve(flags.root ?? process.cwd());
const require = createRequire(import.meta.url);
const checker = new AstroCheck(workspaceRoot, require.resolve('typescript'), flags.tsconfig);
let req = 0;
if (flags.watch) {
function createWatcher(rootPath: string, extensions: string[]) {
return watch(rootPath, {
ignored(pathStr, stats) {
if (pathStr.includes('node_modules') || pathStr.includes('.git')) return true;
if (stats?.isFile() && !extensions.includes(path.extname(pathStr))) return true;
return false;
},
ignoreInitial: true,
});
}
// Dynamically get the list of extensions to watch from the files already included in the project
const checkedExtensions = Array.from(
new Set(checker.linter.getRootFileNames().map((fileName) => path.extname(fileName))),
);
createWatcher(workspaceRoot, checkedExtensions)
.on('add', (fileName) => {
checker.linter.fileCreated(fileName);
update();
})
.on('unlink', (fileName) => {
checker.linter.fileDeleted(fileName);
update();
})
.on('change', (fileName) => {
checker.linter.fileUpdated(fileName);
update();
});
// ... (63 more lines)
Domain
Subdomains
Functions
Types
Dependencies
- ./options.js
- chokidar
- colors
- helpers
- language-server
- node:module
- node:path
- yargs
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 2 function(s): check, parseArgsAsCheckConfig.
What does index.ts depend on?
index.ts imports 8 module(s): ./options.js, chokidar, colors, helpers, language-server, node:module, node:path, yargs.
Where is index.ts in the architecture?
index.ts is located at packages/language-tools/astro-check/src/index.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/language-tools/astro-check/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free