Home / File/ open-docs.ts — astro Source File

open-docs.ts — astro Source File

Architecture documentation for open-docs.ts, a typescript file in the astro codebase. 4 imports, 0 dependents.

File typescript CoreAstro RenderingEngine 4 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  e747d472_6996_c37d_df20_4820655907c4["open-docs.ts"]
  d3861967_b647_84d2_ff48_15013353bd56["../core/logger/core.js"]
  e747d472_6996_c37d_df20_4820655907c4 --> d3861967_b647_84d2_ff48_15013353bd56
  7db42c05_e873_0887_a39f_34451c181149["../definitions.js"]
  e747d472_6996_c37d_df20_4820655907c4 --> 7db42c05_e873_0887_a39f_34451c181149
  9eb8242b_fdf4_2f0a_cd20_f5365a0c228e["../domain/command.js"]
  e747d472_6996_c37d_df20_4820655907c4 --> 9eb8242b_fdf4_2f0a_cd20_f5365a0c228e
  6698b87d_3f31_e098_772c_127c08cd96ab["../definitions.js"]
  e747d472_6996_c37d_df20_4820655907c4 --> 6698b87d_3f31_e098_772c_127c08cd96ab
  style e747d472_6996_c37d_df20_4820655907c4 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import type { Logger } from '../../../core/logger/core.js';
import type { CommandExecutor, OperatingSystemProvider } from '../../definitions.js';
import { defineCommand } from '../../domain/command.js';
import type { CloudIdeProvider } from '../definitions.js';

interface Options {
	url: string;
	operatingSystemProvider: OperatingSystemProvider;
	logger: Logger;
	commandExecutor: CommandExecutor;
	cloudIdeProvider: CloudIdeProvider;
}

function getExecInputForPlatform(platform: string): [command: string, args?: Array<string>] | null {
	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;
	}
}

export 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 }: Options) {
		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!\nTo view Astro's docs, please visit ${url}`,
			);
			return;
		}
		const [command, args = []] = input;
		await commandExecutor.execute(command, [...args, encodeURI(url)]);
	},
});

Domain

Subdomains

Types

Dependencies

  • ../core/logger/core.js
  • ../definitions.js
  • ../definitions.js
  • ../domain/command.js

Frequently Asked Questions

What does open-docs.ts do?
open-docs.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 open-docs.ts?
open-docs.ts defines 2 function(s): getExecInputForPlatform, openDocsCommand.run.
What does open-docs.ts depend on?
open-docs.ts imports 4 module(s): ../core/logger/core.js, ../definitions.js, ../definitions.js, ../domain/command.js.
Where is open-docs.ts in the architecture?
open-docs.ts is located at packages/astro/src/cli/docs/core/open-docs.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/cli/docs/core).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free