From 95598e0c7ccc1464065370a88173bfae0a0834a3 Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Mon, 1 Sep 2025 16:19:10 -0400 Subject: [PATCH 1/2] add CLI reference documentation page --- src/pages/docs/reference/appendix.md | 2 +- src/pages/docs/reference/cli.md | 43 +++++++++++++++++++ src/pages/docs/reference/index.md | 1 + .../docs/reference/rendering-strategies.md | 2 +- 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/pages/docs/reference/cli.md diff --git a/src/pages/docs/reference/appendix.md b/src/pages/docs/reference/appendix.md index 9f326bab..2b6f72e3 100644 --- a/src/pages/docs/reference/appendix.md +++ b/src/pages/docs/reference/appendix.md @@ -1,6 +1,6 @@ --- layout: docs -order: 4 +order: 5 tocHeading: 2 --- diff --git a/src/pages/docs/reference/cli.md b/src/pages/docs/reference/cli.md new file mode 100644 index 00000000..344feb6a --- /dev/null +++ b/src/pages/docs/reference/cli.md @@ -0,0 +1,43 @@ +--- +layout: docs +title: CLI +label: CLI +order: 3 +tocHeading: 2 +--- + +# CLI + +Although the most common way to interact with Greenwood is through [npm scripts in your _package.json_](/docs/introduction/setup/#commands), it is also possible to interact with the CLI programmatically in JavaScript. + +## Commands + +You can see all available commands by passing the `--help` flag to the CLI entrypoint: + +```shell +$ ./node_modules/.bin/greenwood --help +------------------------------------------------------- +Welcome to Greenwood (v0.33.0) ♻️ +------------------------------------------------------- + +Usage: greenwood + +Options: + -h, --help Show help information + -V, --version Show version number + +Commands: + build Generate a production build. + develop Start a local development server. + serve Start a production server. +``` + +## Usage + +For interactive usage, you can import the CLI and call the `run` function with either the **build**, **develop**, or **serve** commands. + +```js +import { run } from "@greenwood/cli/src/index.js"; + +run("build"); +``` diff --git a/src/pages/docs/reference/index.md b/src/pages/docs/reference/index.md index bafff109..d0b48896 100644 --- a/src/pages/docs/reference/index.md +++ b/src/pages/docs/reference/index.md @@ -11,5 +11,6 @@ The content is broken down across these sections: - [Configuration](/docs/reference/configuration/) - All of Greenwood's configuration options - [Plugins API](/docs/reference/plugins-api/) - Learn how to create your own plugins +- [CLI](/docs/reference/cli/) - Interacting with the Greenwood CLI programmatically - [Rendering Strategies](/docs/reference/rendering-strategies/) - Techniques and tips for various rendering options like CSR, SSR, and prerendering - [Appendix](/docs/reference/appendix/) - Supplemental topics like Greenwood's build output, internal build state, and DOM emulation handling diff --git a/src/pages/docs/reference/rendering-strategies.md b/src/pages/docs/reference/rendering-strategies.md index 54fb8803..b223fc07 100644 --- a/src/pages/docs/reference/rendering-strategies.md +++ b/src/pages/docs/reference/rendering-strategies.md @@ -1,6 +1,6 @@ --- layout: docs -order: 3 +order: 4 tocHeading: 2 --- From 40fa95c45d1c5668ced87e11d264ea5f00d37e69 Mon Sep 17 00:00:00 2001 From: Owen Buckley Date: Sat, 6 Sep 2025 09:40:03 -0400 Subject: [PATCH 2/2] phrasing --- src/pages/docs/reference/cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/docs/reference/cli.md b/src/pages/docs/reference/cli.md index 344feb6a..8b6431da 100644 --- a/src/pages/docs/reference/cli.md +++ b/src/pages/docs/reference/cli.md @@ -34,7 +34,7 @@ Commands: ## Usage -For interactive usage, you can import the CLI and call the `run` function with either the **build**, **develop**, or **serve** commands. +For programmatic usage, you can import the CLI and call the `run` function with either the **build**, **develop**, or **serve** commands. ```js import { run } from "@greenwood/cli/src/index.js";