Skip to content

Commit c980125

Browse files
authored
chore(demo): add better demo scripts
2 parents ff16d51 + 91374a3 commit c980125

File tree

5 files changed

+715
-257
lines changed

5 files changed

+715
-257
lines changed

README.md

Lines changed: 63 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -254,73 +254,106 @@ Below is a list of available namespaces to use:
254254

255255
## 🚀 Demo Projects
256256

257-
This repository includes demo projects located in the `/demo` directory to help you get started with using the client. The actual Strapi application is located in the `.strapi-app` directory.
257+
This repository includes demo projects located in the `/demo` directory to help you get started with using the client. The actual Strapi app is located in the `.strapi-app` directory.
258258

259259
### Demo Structure
260260

261-
- **`.strapi-app`**: This is the main Strapi application used for the demo projects.
262-
- **`demo/node-typescript`**: A Node.js project using TypeScript.
263-
- **`demo/node-javascript`**: A Node.js project using JavaScript.
261+
- **`.strapi-app`**: the main Strapi app used for the demo projects.
262+
- **`demo/node-typescript`**: a Node.js project using TypeScript.
263+
- **`demo/node-javascript`**: a Node.js project using JavaScript.
264+
- **`demo/next-server-components`**: a Next.js project using TypeScript and server components.
264265

265-
### Using Demo Scripts
266+
### Using Demo Commands
266267

267-
The `package.json` includes several scripts to help you manage and run the demo projects. These scripts are designed to streamline the process of setting up and running the demo projects, making it easier for developers to test and interact with the client.
268+
The repository supports running demo-related commands directly using the format `pnpm demo <command>`.
268269

269-
The most important basic commands to get started are:
270+
To display the entire list of available commands, use `pnpm demo help`
270271

271-
- **`demo:setup`**: A comprehensive setup command that installs dependencies, sets up the environment, builds the projects, and seeds the demo application. This is a one-stop command to prepare everything needed to run the demos.
272+
#### Comprehensive Setup:
273+
274+
- **`pnpm demo setup`**
275+
A complete setup command that installs dependencies, sets up the environment,
276+
builds the projects, and seeds the database with initial data for the demo app.
277+
278+
It is a one-stop command for preparing everything.
272279

273280
```bash
274-
pnpm run demo:setup
281+
pnpm demo setup
275282
```
276283

277-
- **`demo:run`**: Runs the Strapi application server in development mode. This command is useful for testing and developing.
284+
#### Development:
285+
286+
- **`pnpm demo app:start`**
287+
Starts the Strapi demo app in development mode. This is useful for testing and making changes to the Strapi backend.
278288

279289
```bash
280-
pnpm run demo:run
290+
pnpm demo app:start
281291
```
282292

283-
- **`demo:seed:clean`**: Cleans the existing data and re-seeds the Strapi demo application. This command is helpful for resetting the demo data to its initial state.
293+
#### Database Seeding:
294+
295+
- **`pnpm demo app:seed`**
296+
Seeds the Strapi app with sample data. Use this when you want to populate your Strapi app with default content.
284297

285298
```bash
286-
pnpm run demo:seed:clean
299+
pnpm demo app:seed
287300
```
288301

289-
The following scripts shouldn't need to be used generally, but are also available to run individual parts of the setup or reset process:
290-
291-
- **`demo:build`**: Builds the main project and the TypeScript and JavaScript demo projects. This command ensures that all necessary build steps are completed for the demo projects to run.
302+
- **`pnpm demo app:seed:clean`**
303+
Cleans the existing database and re-seeds the Strapi demo app.
304+
This is helpful if you want to reset the demo data to its initial state.
292305

293306
```bash
294-
pnpm run demo:build
307+
pnpm demo app:seed:clean
295308
```
296309

297-
- **`demo:install`**: Installs all dependencies for the main project and all demo projects, including TypeScript, JavaScript, HTML, and Next.js demos. This command is essential to prepare the environment for running the demos.
310+
#### Build and Install:
311+
312+
- **`pnpm demo build`**
313+
Builds the main Strapi app and all demo projects.
314+
315+
Use this to prepare the projects for use, ensuring all components are compiled and ready.
298316

299317
```bash
300-
pnpm run demo:install
318+
pnpm demo build
301319
```
302320

303-
- **`demo:env`**: Sets up the environment for the Strapi demo application by copying the example environment file if it doesn't already exist.
321+
- **`pnpm demo install`**
322+
Installs dependencies for the main Strapi app and all demo applications.
323+
324+
This command ensures that all required packages are downloaded and ready to go.
304325

305326
```bash
306-
pnpm run demo:env
327+
pnpm demo install
307328
```
308329

309-
- **`demo:seed`**: Seeds the Strapi application with example data. This script also generates `.env` files with API tokens for the `node-typescript` and `node-javascript` projects.
330+
#### Environment Setup:
331+
332+
- **`pnpm demo app:env:setup`**
333+
Sets up the `.env` file for the main Strapi app by copying the example `.env.example` file if no `.env` file exists.
334+
335+
This ensures the environment is configured appropriately.
310336

311337
```bash
312-
pnpm run demo:seed
338+
pnpm demo app:env:setup
313339
```
314340

315-
### Adding New Projects
341+
---
316342

317-
If you add new projects to the `/demo` directory, you will need to update the seed script located at `/demo/.strapi-app/scripts/seed.js` with the new project paths to ensure they are properly configured and seeded.
343+
#### Adding New Projects
318344

319-
### Future Plans
345+
New projects added to the `/demo` directory are automatically picked up by the demo scripts.
346+
Thus, no explicit configuration updates are required for these commands to work with new demo directories.
320347

321-
We plan to expand the demo projects to include:
348+
**Note:** if a project needs to be built to be used, add a `build` script
349+
to its `package.json` so that the demo scripts automatically run it.
322350

323-
- A basic HTML project.
324-
- A Next.js project.
351+
---
352+
353+
#### Future Plans
354+
355+
We plan to expand the demo projects to include:
325356

326-
These additions will provide more examples of how to integrate the client into different types of applications.
357+
- A basic HTML project
358+
- A Vue.js project (with or without server components)
359+
- A Svelte project

0 commit comments

Comments
 (0)