-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
- Loading branch information
1 parent
8a5b0c1
commit dbc97b1
Showing
16 changed files
with
139 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
'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 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. | ||
|
||
```ts | ||
import { dev, build, preview, sync, type AstroInlineConfig } from 'astro'; | ||
|
||
// 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', | ||
// Standard Astro config 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); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export type * from './dist/@types/astro.js'; | ||
export * from './dist/core/index.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 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. | ||
* | ||
* @experimental The JavaScript API is experimental | ||
*/ | ||
// 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. | ||
* | ||
* @experimental The JavaScript API is experimental | ||
*/ | ||
// Wrap `_sync` to prevent exposing the second internal options parameter | ||
export const sync = (inlineConfig: AstroInlineConfig) => _sync(inlineConfig); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/astro/test/units/dev/collections-mixed-content-errors.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters