Skip to content

Commit 9de25ec

Browse files
authored
feat: create new handbook command + test setup for scripts (#46)
Implemented a new repository for handling scripts. In this new repo, a script for creating a new handbook was also added! Issue CHA-330 https://linear.app/defi-wonderland/issue/CHA-330/template-for-new-handbooks <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added scripts to automate creating new handbook sites and copying shared static assets. * Introduced a dedicated scripts workspace with supporting configuration and documentation. * Added automated tests and test setup utilities for scripts. * Integrated a GitHub Actions workflow to run script tests on pull requests. * **Bug Fixes** * Improved handling and validation of site creation and static asset copying. * **Documentation** * Updated and expanded documentation for handbook site creation and script usage. * **Chores** * Updated package and workspace configurations to reflect new package naming and structure. * Enhanced .gitignore files to exclude temporary test files and directories. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 788628a commit 9de25ec

22 files changed

Lines changed: 2016 additions & 49 deletions

.github/workflows/test-scripts.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Test Scripts
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
branches:
7+
- dev
8+
- main
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 18.x
21+
22+
- name: Install pnpm
23+
uses: pnpm/action-setup@v2
24+
with:
25+
version: 9
26+
cache: pnpm
27+
28+
- name: Install dependencies
29+
run: pnpm install --frozen-lockfile
30+
31+
- name: Run tests
32+
working-directory: scripts
33+
run: pnpm test

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
.docusaurus
1212
.cache-loader
1313

14+
# Test temporary files
15+
.tmp/
16+
1417
# Misc
1518
.DS_Store
1619
.env

README.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,30 @@ The static site will be generated in the `sites/[name]/build` directory.
5050

5151
## 🛠️ Creating a New Site
5252

53-
TBD (CHA-330)
53+
To create a new handbook site from the template:
54+
55+
```bash
56+
pnpm create-handbook <site-name>
57+
```
58+
59+
This will:
60+
1. Create a new site in `sites/<site-name>` based on the template
61+
2. Update the package.json with the correct site name
62+
3. Set up all necessary configurations
63+
64+
**Example:**
65+
```bash
66+
pnpm create-handbook my-new-handbook
67+
```
68+
69+
After creation, you can build and start the new site:
70+
```bash
71+
cd sites/my-new-handbook
72+
pnpm build:assets
73+
pnpm start
74+
```
75+
76+
**Note:** Site names can only contain letters, numbers, hyphens, and underscores.
5477

5578
## Contributing
5679

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33
"private": true,
44
"workspaces": [
55
"packages/*",
6-
"sites/*"
6+
"sites/*",
7+
"scripts"
78
],
9+
"scripts": {
10+
"create-handbook": "ts-node scripts/src/create-handbook.ts"
11+
},
812
"devDependencies": {
913
"turbo": "1.11.0",
1014
"typescript": "5.6.2",
1115
"eslint": "9.28.0",
12-
"prettier": "3.2.5"
16+
"prettier": "3.2.5",
17+
"ts-node": "10.9.2"
1318
},
1419
"engines": {
1520
"node": ">=18.0"

packages/common-config/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "@common-config",
2+
"name": "@handbook/common-config",
33
"version": "1.0.0",
44
"private": true,
55
"main": "src/index.ts",
@@ -11,7 +11,10 @@
1111
"exports": {
1212
"./styles/global.css": "./static/common/styles/global.css",
1313
"./preset": "./dist/preset/index.js",
14-
"./copy-static": "./dist/scripts/copyStaticTo.js"
14+
"./preset/commonDocusaurusConfig": {
15+
"types": "./preset/commonDocusaurusConfig.ts",
16+
"default": "./dist/preset/commonDocusaurusConfig.js"
17+
}
1518
},
1619
"scripts": {
1720
"build": "tsc"

packages/common-config/scripts/copyStaticTo.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)