From 435a4541df437452b1ea32766b5e411c181488c4 Mon Sep 17 00:00:00 2001 From: bluwy Date: Tue, 8 Aug 2023 23:27:43 +0800 Subject: [PATCH 1/7] Export JS API --- .changeset/many-pears-explode.md | 5 +++++ packages/astro/index.d.ts | 2 ++ packages/astro/package.json | 7 +++--- packages/astro/src/@types/astro.ts | 22 ++++++++++++++++++- packages/astro/src/cli/build/index.ts | 4 +--- packages/astro/src/cli/sync/index.ts | 2 +- packages/astro/src/core/README.md | 4 +++- packages/astro/src/core/build/index.ts | 12 +++++++--- packages/astro/src/core/dev/dev.ts | 5 ++++- packages/astro/src/core/index.ts | 22 +++++++++++++++++++ packages/astro/src/core/preview/index.ts | 9 ++++---- packages/astro/src/core/sync/index.ts | 11 ++++++---- packages/astro/test/test-utils.js | 7 +++--- .../collections-mixed-content-errors.test.js | 2 +- packages/astro/tsconfig.json | 2 +- 15 files changed, 89 insertions(+), 27 deletions(-) create mode 100644 .changeset/many-pears-explode.md create mode 100644 packages/astro/index.d.ts create mode 100644 packages/astro/src/core/index.ts diff --git a/.changeset/many-pears-explode.md b/.changeset/many-pears-explode.md new file mode 100644 index 000000000000..2cb789bbfda0 --- /dev/null +++ b/.changeset/many-pears-explode.md @@ -0,0 +1,5 @@ +--- +'astro': major +--- + +Export `dev`, `build`, `preview`, and `sync` APIs from `astro`. This replaces the previous entrypoint code which runs the Astro CLI programmatically. diff --git a/packages/astro/index.d.ts b/packages/astro/index.d.ts new file mode 100644 index 000000000000..a9e679be17d9 --- /dev/null +++ b/packages/astro/index.d.ts @@ -0,0 +1,2 @@ +export type * from './dist/@types/astro.js'; +export * from './dist/core/index.js'; diff --git a/packages/astro/package.json b/packages/astro/package.json index 8e505e8b0991..7cec6356e2a1 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -12,7 +12,7 @@ }, "bugs": "https://github.com/withastro/astro/issues", "homepage": "https://astro.build", - "types": "./dist/@types/astro.d.ts", + "types": "./index.d.ts", "typesVersions": { "*": { "app": [ @@ -28,8 +28,8 @@ }, "exports": { ".": { - "types": "./dist/@types/astro.d.ts", - "default": "./astro.js" + "types": "./index.d.ts", + "default": "./dist/core/index.js" }, "./env": "./env.d.ts", "./types": "./types.d.ts", @@ -86,6 +86,7 @@ "tsconfigs", "dist", "astro.js", + "index.d.ts", "config.d.ts", "config.mjs", "zod.d.ts", diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index dbebe4adf436..10bf0651bed7 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1342,11 +1342,31 @@ export interface AstroConfig extends z.output { } export interface AstroInlineConfig extends AstroUserConfig, AstroInlineOnlyConfig {} export interface AstroInlineOnlyConfig { + /** + * A custom path to the Astro config file. If relative, it'll resolve based on the current working directory. + * Set to false to disable loading any config files. + * + * If this value is undefined or unset, Astro will search for an `astro.config.(js,mjs,ts)` file relative to + * the `root` and load the config file if found. + */ configFile?: string | false; + /** + * The current mode used when building your site to generate either "development" or "production" code. + */ mode?: RuntimeMode; + /** + * The logging level to filter messages logged by Astro. + * - "debug": Log all messages and debug information. + * - "info": Log all messages. + * - "warn": Log only warnings and errors. + * - "error": Log only errors. + * - "silent": Log no messages. + * + * @default "info" + */ logLevel?: LoggerLevel; /** - * @internal for testing only + * @internal for testing only, use `logLevel` instead. */ logging?: LogOptions; } diff --git a/packages/astro/src/cli/build/index.ts b/packages/astro/src/cli/build/index.ts index 9e26108a2d13..dd44823d1427 100644 --- a/packages/astro/src/cli/build/index.ts +++ b/packages/astro/src/cli/build/index.ts @@ -25,7 +25,5 @@ export async function build({ flags }: BuildOptions) { const inlineConfig = flagsToAstroInlineConfig(flags); - await _build(inlineConfig, { - teardownCompiler: true, - }); + await _build(inlineConfig); } diff --git a/packages/astro/src/cli/sync/index.ts b/packages/astro/src/cli/sync/index.ts index 66a277e4635d..8650bf904655 100644 --- a/packages/astro/src/cli/sync/index.ts +++ b/packages/astro/src/cli/sync/index.ts @@ -1,6 +1,6 @@ import type yargs from 'yargs-parser'; import { printHelp } from '../../core/messages.js'; -import { sync as _sync } from '../../core/sync/index.js'; +import _sync from '../../core/sync/index.js'; import { flagsToAstroInlineConfig } from '../flags.js'; interface SyncOptions { diff --git a/packages/astro/src/core/README.md b/packages/astro/src/core/README.md index 7f5e4f89c894..a53cf766ed9b 100644 --- a/packages/astro/src/core/README.md +++ b/packages/astro/src/core/README.md @@ -1,5 +1,7 @@ # `core/` -Code that executes within the top-level Node context. Contains the main Astro logic for the `build` and `dev` commands, and also manages the Vite server and SSR. +Code that executes within the top-level Node context. Contains the main Astro logic for the `build`, `dev`, `preview`, and `sync` commands, and also manages the Vite server and SSR. + +The `core/index.ts` file is the main entrypoint for the `astro` package. [See CONTRIBUTING.md](../../../../CONTRIBUTING.md) for a code overview. diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 5b1ecf4040f3..9e6aa99aee4f 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -37,14 +37,20 @@ export interface BuildOptions { /** * Teardown the compiler WASM instance after build. This can improve performance when * building once, but may cause a performance hit if building multiple times in a row. + * + * @internal only used for testing + * @default true */ teardownCompiler?: boolean; } -/** `astro build` */ +/** + * Builds your site for deployment. By default, this will generate static files and place them in a dist/ directory. + * If SSR is enabled, this will generate the necessary server files to serve your site. + */ export default async function build( inlineConfig: AstroInlineConfig, - options: BuildOptions + options?: BuildOptions ): Promise { applyPolyfill(); const logging = createNodeLogging(inlineConfig); @@ -82,7 +88,7 @@ class AstroBuilder { } this.settings = settings; this.logging = options.logging; - this.teardownCompiler = options.teardownCompiler ?? false; + this.teardownCompiler = options.teardownCompiler ?? true; this.routeCache = new RouteCache(this.logging); this.origin = settings.config.site ? new URL(settings.config.site).origin diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index b14656d26bc6..a4115dc4c8d3 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -18,7 +18,10 @@ export interface DevServer { stop(): Promise; } -/** `astro dev` */ +/** + * Runs Astro’s development server. This is a local HTTP server that doesn’t bundle assets. + * It uses Hot Module Replacement (HMR) to update your browser as you save changes in your editor. + */ export default async function dev(inlineConfig: AstroInlineConfig): Promise { const devStart = performance.now(); await telemetry.record([]); diff --git a/packages/astro/src/core/index.ts b/packages/astro/src/core/index.ts new file mode 100644 index 000000000000..0dc8a7caeffb --- /dev/null +++ b/packages/astro/src/core/index.ts @@ -0,0 +1,22 @@ +// This is the main entrypoint when importing the `astro` package. + +import type { AstroInlineConfig } from '../@types/astro.js'; +import { default as _build } from './build/index.js'; +import { default as _sync } from './sync/index.js'; + +export { default as dev } from './dev/index.js'; +export { default as preview } from './preview/index.js'; + +/** + * Builds your site for deployment. By default, this will generate static files and place them in a dist/ directory. + * If SSR is enabled, this will generate the necessary server files to serve your site. + */ +// Wrap `_build` to prevent exposing the second internal options parameter +export const build = (inlineConfig: AstroInlineConfig) => _build(inlineConfig); + +/** + * Generates TypeScript types for all Astro modules. This sets up a `src/env.d.ts` file for type inferencing, + * and defines the `astro:content` module for the Content Collections API. + */ +// Wrap `_sync` to prevent exposing the second internal options parameter +export const sync = (inlineConfig: AstroInlineConfig) => _sync(inlineConfig); diff --git a/packages/astro/src/core/preview/index.ts b/packages/astro/src/core/preview/index.ts index fdd5d6fe7c7b..28b61f9fcfb7 100644 --- a/packages/astro/src/core/preview/index.ts +++ b/packages/astro/src/core/preview/index.ts @@ -10,10 +10,11 @@ import { createSettings } from '../config/settings.js'; import createStaticPreviewServer from './static-preview-server.js'; import { getResolvedHostForHttpServer } from './util.js'; -/** The primary dev action */ -export default async function preview( - inlineConfig: AstroInlineConfig -): Promise { +/** + * Starts a local server to serve your static dist/ directory. This command is useful for previewing + * your build locally, before deploying it. It is not designed to be run in production. + */ +export default async function preview(inlineConfig: AstroInlineConfig): Promise { const logging = createNodeLogging(inlineConfig); const { userConfig, astroConfig } = await resolveConfig(inlineConfig ?? {}, 'preview'); telemetry.record(eventCliSession('preview', userConfig)); diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index be51f0039b02..d899f4f67c3d 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -22,8 +22,7 @@ export type ProcessExit = 0 | 1; export type SyncOptions = { /** - * Only used for testing - * @internal + * @internal only used for testing */ fs?: typeof fsMod; }; @@ -32,7 +31,11 @@ export type SyncInternalOptions = SyncOptions & { logging: LogOptions; }; -export async function sync( +/** + * Generates TypeScript types for all Astro modules. This sets up a `src/env.d.ts` file for type inferencing, + * and defines the `astro:content` module for the Content Collections API. + */ +export default async function sync( inlineConfig: AstroInlineConfig, options?: SyncOptions ): Promise { @@ -48,7 +51,7 @@ export async function sync( command: 'build', }); - return await syncInternal(settings, { logging, fs: options?.fs }); + return await syncInternal(settings, { ...options, logging }); } /** diff --git a/packages/astro/test/test-utils.js b/packages/astro/test/test-utils.js index a58d417d79d9..69fd635c7d73 100644 --- a/packages/astro/test/test-utils.js +++ b/packages/astro/test/test-utils.js @@ -6,15 +6,14 @@ import path from 'node:path'; import { fileURLToPath } from 'node:url'; import stripAnsi from 'strip-ansi'; import { check } from '../dist/cli/check/index.js'; +import { dev, preview } from '../dist/core/index.js'; import build from '../dist/core/build/index.js'; +import sync from '../dist/core/sync/index.js'; import { RESOLVED_SPLIT_MODULE_ID } from '../dist/core/build/plugins/plugin-ssr.js'; import { getVirtualModulePageNameFromPath } from '../dist/core/build/plugins/util.js'; import { makeSplitEntryPointFileName } from '../dist/core/build/static-build.js'; import { mergeConfig, resolveConfig } from '../dist/core/config/index.js'; -import dev from '../dist/core/dev/index.js'; import { nodeLogDestination } from '../dist/core/logger/node.js'; -import preview from '../dist/core/preview/index.js'; -import { sync } from '../dist/core/sync/index.js'; // Disable telemetry when running tests process.env.ASTRO_TELEMETRY_DISABLED = true; @@ -148,7 +147,7 @@ export async function loadFixture(inlineConfig) { return { build: async (extraInlineConfig = {}) => { process.env.NODE_ENV = 'production'; - return build(mergeConfig(inlineConfig, extraInlineConfig)); + return build(mergeConfig(inlineConfig, extraInlineConfig), { teardownCompiler: false }); }, sync: async (extraInlineConfig = {}, opts) => { return sync(mergeConfig(inlineConfig, extraInlineConfig), opts); diff --git a/packages/astro/test/units/dev/collections-mixed-content-errors.test.js b/packages/astro/test/units/dev/collections-mixed-content-errors.test.js index 34461534699d..a8e282a88163 100644 --- a/packages/astro/test/units/dev/collections-mixed-content-errors.test.js +++ b/packages/astro/test/units/dev/collections-mixed-content-errors.test.js @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { fileURLToPath } from 'node:url'; -import { sync as _sync } from '../../../dist/core/sync/index.js'; +import _sync from '../../../dist/core/sync/index.js'; import { createFsWithFallback } from '../test-utils.js'; const root = new URL('../../fixtures/content-mixed-errors/', import.meta.url); diff --git a/packages/astro/tsconfig.json b/packages/astro/tsconfig.json index 63854a31decc..d8bd9b19752b 100644 --- a/packages/astro/tsconfig.json +++ b/packages/astro/tsconfig.json @@ -1,6 +1,6 @@ { "extends": "../../tsconfig.base.json", - "include": ["src", "index.d.ts"], + "include": ["src"], "compilerOptions": { "allowJs": true, "declarationDir": "./dist", From 8f6fbdddbdeeca34e7304bf712c722a701c46037 Mon Sep 17 00:00:00 2001 From: bluwy Date: Thu, 10 Aug 2023 17:31:17 +0800 Subject: [PATCH 2/7] Fix check --- packages/astro/src/cli/check/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/astro/src/cli/check/index.ts b/packages/astro/src/cli/check/index.ts index 428027154a89..6ae11d576cef 100644 --- a/packages/astro/src/cli/check/index.ts +++ b/packages/astro/src/cli/check/index.ts @@ -27,7 +27,7 @@ export async function check(flags: Arguments) { // Run sync before check to make sure types are generated. // NOTE: In the future, `@astrojs/check` can expose a `before lint` hook so that this works during `astro check --watch` too. // For now, we run this once as usually `astro check --watch` is ran alongside `astro dev` which also calls `astro sync`. - const { sync } = await import('../../core/sync/index.js'); + const { default: sync } = await import('../../core/sync/index.js'); const inlineConfig = flagsToAstroInlineConfig(flags); const exitCode = await sync(inlineConfig); if (exitCode !== 0) { From b302430d3702d1449f0db9ff352db78253bed02e Mon Sep 17 00:00:00 2001 From: bluwy Date: Thu, 10 Aug 2023 17:33:36 +0800 Subject: [PATCH 3/7] Mark experimental --- packages/astro/src/core/build/index.ts | 2 ++ packages/astro/src/core/dev/dev.ts | 2 ++ packages/astro/src/core/index.ts | 4 ++++ packages/astro/src/core/preview/index.ts | 2 ++ packages/astro/src/core/sync/index.ts | 2 ++ 5 files changed, 12 insertions(+) diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index 9e6aa99aee4f..f05b0fb46e89 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -47,6 +47,8 @@ export interface BuildOptions { /** * Builds your site for deployment. By default, this will generate static files and place them in a dist/ directory. * If SSR is enabled, this will generate the necessary server files to serve your site. + * + * @experimental The JavaScript API is experimental */ export default async function build( inlineConfig: AstroInlineConfig, diff --git a/packages/astro/src/core/dev/dev.ts b/packages/astro/src/core/dev/dev.ts index a4115dc4c8d3..115cbe825827 100644 --- a/packages/astro/src/core/dev/dev.ts +++ b/packages/astro/src/core/dev/dev.ts @@ -21,6 +21,8 @@ export interface DevServer { /** * Runs Astro’s development server. This is a local HTTP server that doesn’t bundle assets. * It uses Hot Module Replacement (HMR) to update your browser as you save changes in your editor. + * + * @experimental The JavaScript API is experimental */ export default async function dev(inlineConfig: AstroInlineConfig): Promise { const devStart = performance.now(); diff --git a/packages/astro/src/core/index.ts b/packages/astro/src/core/index.ts index 0dc8a7caeffb..31d868311455 100644 --- a/packages/astro/src/core/index.ts +++ b/packages/astro/src/core/index.ts @@ -10,6 +10,8 @@ export { default as preview } from './preview/index.js'; /** * Builds your site for deployment. By default, this will generate static files and place them in a dist/ directory. * If SSR is enabled, this will generate the necessary server files to serve your site. + * + * @experimental The JavaScript API is experimental */ // Wrap `_build` to prevent exposing the second internal options parameter export const build = (inlineConfig: AstroInlineConfig) => _build(inlineConfig); @@ -17,6 +19,8 @@ export const build = (inlineConfig: AstroInlineConfig) => _build(inlineConfig); /** * Generates TypeScript types for all Astro modules. This sets up a `src/env.d.ts` file for type inferencing, * and defines the `astro:content` module for the Content Collections API. + * + * @experimental The JavaScript API is experimental */ // Wrap `_sync` to prevent exposing the second internal options parameter export const sync = (inlineConfig: AstroInlineConfig) => _sync(inlineConfig); diff --git a/packages/astro/src/core/preview/index.ts b/packages/astro/src/core/preview/index.ts index 28b61f9fcfb7..d5b2b2db76bf 100644 --- a/packages/astro/src/core/preview/index.ts +++ b/packages/astro/src/core/preview/index.ts @@ -13,6 +13,8 @@ import { getResolvedHostForHttpServer } from './util.js'; /** * Starts a local server to serve your static dist/ directory. This command is useful for previewing * your build locally, before deploying it. It is not designed to be run in production. + * + * @experimental The JavaScript API is experimental */ export default async function preview(inlineConfig: AstroInlineConfig): Promise { const logging = createNodeLogging(inlineConfig); diff --git a/packages/astro/src/core/sync/index.ts b/packages/astro/src/core/sync/index.ts index d899f4f67c3d..e1d432465dda 100644 --- a/packages/astro/src/core/sync/index.ts +++ b/packages/astro/src/core/sync/index.ts @@ -34,6 +34,8 @@ export type SyncInternalOptions = SyncOptions & { /** * Generates TypeScript types for all Astro modules. This sets up a `src/env.d.ts` file for type inferencing, * and defines the `astro:content` module for the Content Collections API. + * + * @experimental The JavaScript API is experimental */ export default async function sync( inlineConfig: AstroInlineConfig, From 3cde58927a72b1e3df56173bc9d95d92d43dfa71 Mon Sep 17 00:00:00 2001 From: bluwy Date: Mon, 14 Aug 2023 21:57:16 +0800 Subject: [PATCH 4/7] Improve changeset --- .changeset/many-pears-explode.md | 31 +++++++++++++++++++++++++++++- packages/astro/src/@types/astro.ts | 6 ++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.changeset/many-pears-explode.md b/.changeset/many-pears-explode.md index 2cb789bbfda0..98f84d536613 100644 --- a/.changeset/many-pears-explode.md +++ b/.changeset/many-pears-explode.md @@ -2,4 +2,33 @@ 'astro': major --- -Export `dev`, `build`, `preview`, and `sync` APIs from `astro`. This replaces the previous entrypoint code which runs the Astro CLI programmatically. +Export experimental `dev`, `build`, `preview`, and `sync` APIs from `astro`. These APIs allow you to run Astro's commands programmatically, and replaces the previous entrypoint that runs the Astro CLI. + +While these APIs are experimental, the inline config parameter is relatively stable without foreseeable changes. However, the returned results of these APIs are more likely to change in the future. + +```ts +import { dev, build, preview, sync, type AstroInlineConfig } from 'astro'; + +// Inline Astro config that takes highest priority over the user config +const inlineConfig: AstroInlineConfig = { + // Inline-specific options... + configFile: './astro.config.mjs', + logLevel: 'info', + // Other Astro options... + site: 'https://example.com', +}; + +// Start the Astro dev server +const devServer = await dev(inlineConfig); +await devServer.stop(); + +// Build your Astro project +await build(inlineConfig); + +// Preview your built project +const previewServer = await preview(inlineConfig); +await previewServer.stop(); + +// Generate types for your Astro project +await sync(inlineConfig); +``` diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 37d6e1fb45b5..f5a365f3ab8d 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1357,6 +1357,10 @@ export interface AstroConfig extends z.output { // TypeScript still confirms zod validation matches this type. integrations: AstroIntegration[]; } +/** + * An inline Astro config that takes highest priority when merging with the user config, + * and includes inline-specific options to configure how Astro runs. + */ export interface AstroInlineConfig extends AstroUserConfig, AstroInlineOnlyConfig {} export interface AstroInlineOnlyConfig { /** @@ -1365,6 +1369,8 @@ export interface AstroInlineOnlyConfig { * * If this value is undefined or unset, Astro will search for an `astro.config.(js,mjs,ts)` file relative to * the `root` and load the config file if found. + * + * The inline config passed in this object will take highest priority when merging with the loaded user config. */ configFile?: string | false; /** From 0035e62f82d8063ab229057dc1f16fe077728a53 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Tue, 15 Aug 2023 00:58:41 +0800 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: Chris Swithinbank --- .changeset/many-pears-explode.md | 5 +++-- packages/astro/src/@types/astro.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.changeset/many-pears-explode.md b/.changeset/many-pears-explode.md index 98f84d536613..b54e8957a9ad 100644 --- a/.changeset/many-pears-explode.md +++ b/.changeset/many-pears-explode.md @@ -9,12 +9,13 @@ While these APIs are experimental, the inline config parameter is relatively sta ```ts import { dev, build, preview, sync, type AstroInlineConfig } from 'astro'; -// Inline Astro config that takes highest priority over the user config +// Inline Astro config object. +// Provide a path to a configuration file to load or set options directly inline. const inlineConfig: AstroInlineConfig = { // Inline-specific options... configFile: './astro.config.mjs', logLevel: 'info', - // Other Astro options... + // Standard Astro config options... site: 'https://example.com', }; diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index f5a365f3ab8d..4588ef067867 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1374,7 +1374,7 @@ export interface AstroInlineOnlyConfig { */ configFile?: string | false; /** - * The current mode used when building your site to generate either "development" or "production" code. + * The mode used when building your site to generate either "development" or "production" code. */ mode?: RuntimeMode; /** From f7c32803f7ec1dc3117f86725f1970e9953b4c93 Mon Sep 17 00:00:00 2001 From: bluwy Date: Wed, 16 Aug 2023 17:50:42 +0800 Subject: [PATCH 6/7] Update logging jsdoc --- packages/astro/src/@types/astro.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 031b69752587..7089dd1807b9 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -141,7 +141,7 @@ export interface CLIFlags { */ export interface AstroGlobal< Props extends Record = Record, - Self = AstroComponentFactory + Self = AstroComponentFactory, > extends AstroGlobalPartial, AstroSharedContext { /** @@ -1348,7 +1348,7 @@ export interface AstroInlineOnlyConfig { * * If this value is undefined or unset, Astro will search for an `astro.config.(js,mjs,ts)` file relative to * the `root` and load the config file if found. - * + * * The inline config passed in this object will take highest priority when merging with the loaded user config. */ configFile?: string | false; @@ -1358,11 +1358,11 @@ export interface AstroInlineOnlyConfig { mode?: RuntimeMode; /** * The logging level to filter messages logged by Astro. - * - "debug": Log all messages and debug information. - * - "info": Log all messages. - * - "warn": Log only warnings and errors. - * - "error": Log only errors. - * - "silent": Log no messages. + * - "debug": Log everything, including noisy debugging diagnostics. + * - "info": Log informational messages, warnings, and errors. + * - "warn": Log warnings and errors. + * - "error": Log errors only. + * - "silent": No logging. * * @default "info" */ From 969f3ba5a7338deb591a60d76d5ff70486866572 Mon Sep 17 00:00:00 2001 From: Bjorn Lu Date: Thu, 17 Aug 2023 21:21:03 +0800 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: Sarah Rainsberger --- .changeset/many-pears-explode.md | 2 +- packages/astro/src/core/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/many-pears-explode.md b/.changeset/many-pears-explode.md index b54e8957a9ad..1e2a30edc227 100644 --- a/.changeset/many-pears-explode.md +++ b/.changeset/many-pears-explode.md @@ -2,7 +2,7 @@ 'astro': major --- -Export experimental `dev`, `build`, `preview`, and `sync` APIs from `astro`. These APIs allow you to run Astro's commands programmatically, and replaces the previous entrypoint that runs the Astro CLI. +Export experimental `dev`, `build`, `preview`, and `sync` APIs from `astro`. These APIs allow you to run Astro's commands programmatically, and replaces the previous entry point that runs the Astro CLI. While these APIs are experimental, the inline config parameter is relatively stable without foreseeable changes. However, the returned results of these APIs are more likely to change in the future. diff --git a/packages/astro/src/core/README.md b/packages/astro/src/core/README.md index 6e7d5546df81..ef4dd8750ba7 100644 --- a/packages/astro/src/core/README.md +++ b/packages/astro/src/core/README.md @@ -2,7 +2,7 @@ Code that executes within the top-level Node context. Contains the main Astro logic for the `build`, `dev`, `preview`, and `sync` commands, and also manages the Vite server and SSR. -The `core/index.ts` file is the main entrypoint for the `astro` package. +The `core/index.ts` file is the main entry point for the `astro` package. [See CONTRIBUTING.md](../../../../CONTRIBUTING.md) for a code overview.