Skip to content

Commit c19de2c

Browse files
authored
refactor(package): split docs workspace from root package.json (#649)
1 parent 813380c commit c19de2c

13 files changed

Lines changed: 149 additions & 32 deletions

.github/CONTRIBUTING.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ make test && make sa && make lint
5454

5555
### Documentation Setup (Optional)
5656

57-
For documentation changes:
57+
Docs live in their own workspace under `docs/` with an isolated `package.json`.
5858

5959
```bash
6060
nvm use # Uses .nvmrc version
61+
cd docs
6162
npm ci
62-
npm run docs:dev
63+
npm run dev
6364
```
6465

6566
## Making Changes
@@ -197,13 +198,14 @@ Then create the PR on GitHub, fill out the template, and link related issues.
197198

198199
## Documentation
199200

200-
Documentation is built with [VitePress](https://vitepress.dev/).
201+
Documentation is built with [VitePress](https://vitepress.dev/) and lives in `docs/` as its own npm workspace.
201202

202203
```bash
203204
nvm use
205+
cd docs
204206
npm ci
205-
npm run docs:dev # Start dev server
206-
npm run docs:build # Build and test
207+
npm run dev # Start dev server
208+
npm run build # Build and test
207209
```
208210

209211
**Guidelines:** Keep it simple, include examples, test all code examples.

.github/RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This is a guide to knowing the steps to create a new release.
55
1. Update the version in [BASHUNIT_VERSION](../bashunit)
66
1. Update the version in [LATEST_BASHUNIT_VERSION](../install.sh)
77
1. Update the version in [CHANGELOG.md](../CHANGELOG.md)
8-
1. Update the version in [package.json](../package.json)
8+
1. Update the version in [package.json](../package.json) and [docs/package.json](../docs/package.json)
99
1. Build the project `./build.sh bin`
1010
1. This will generate `bin/bashunit` and `bin/checksum`
1111
1. Update the checksum(sha256) in [package.json](../package.json)

.github/workflows/check-docs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ jobs:
2626
with:
2727
node-version: 20
2828
cache: npm
29+
cache-dependency-path: docs/package-lock.json
2930

3031
- name: Install dependencies
32+
working-directory: docs
3133
run: npm ci
3234

3335
- name: Build with VitePress
34-
run: npm run docs:build
36+
working-directory: docs
37+
run: npm run build

.github/workflows/publish-docs.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ jobs:
2828
with:
2929
node-version: 20
3030
cache: npm
31+
cache-dependency-path: docs/package-lock.json
3132

3233
- name: Install dependencies
34+
working-directory: docs
3335
run: npm ci
3436

3537
- name: Build with VitePress
36-
run: npm run docs:build
38+
working-directory: docs
39+
run: npm run build
3740

3841
- name: Publish to Cloudflare Pages
3942
uses: cloudflare/pages-action@v1

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
- Publish bashunit to the npm registry: `npm install -g bashunit` ships the prebuilt single-file binary; new `npm-publish.yml` workflow publishes on release (#244)
99

1010
### Changed
11+
- Split documentation into its own npm workspace under `docs/`: VitePress dependencies and `docs:*` scripts moved out of the root `package.json` so the published npm package stays slim. CI workflows, release script and contributing docs updated for the new `cd docs && npm ci` workflow; `make docs/{install,dev,build,preview}` shortcuts added
1112
- Centralize all ANSI escape emission through the existing `_BASHUNIT_COLOR_*` constants. `src/coverage.sh` and the `--watch` screen-clear in `src/main.sh` no longer hardcode escape sequences (#247)
1213
- Speed up coverage report generation by collapsing the per-line non-executable pattern checks in `bashunit::coverage::is_executable_line` into a single combined `grep` invocation (#636)
1314
- Speed up coverage report generation further by combining executable + hit counting into a single source-file pass (`bashunit::coverage::compute_file_coverage`) shared across text/lcov/html reporters, removing per-line `get_line_hits` scans of the coverage data file (#636)

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ help:
4848
@echo " pre_commit/run Function that will be called when the pre-commit hook runs"
4949
@echo " sa Run shellcheck static analysis tool"
5050
@echo " lint Run editorconfig linter tool"
51+
@echo " docs/install Install docs npm dependencies (in docs/)"
52+
@echo " docs/dev Start the VitePress dev server"
53+
@echo " docs/build Build the documentation site"
54+
@echo " docs/preview Preview the built documentation"
5155

5256
SRC_SCRIPTS_DIR=src
5357
TEST_SCRIPTS_DIR=tests
@@ -98,3 +102,15 @@ ifndef LINTER_CHECKER
98102
else
99103
@editorconfig-checker && printf "\e[1m\e[32m%s\e[0m\n" "editorconfig-check: OK!"
100104
endif
105+
106+
docs/install:
107+
@cd docs && npm ci
108+
109+
docs/dev:
110+
@cd docs && npm run dev
111+
112+
docs/build:
113+
@cd docs && npm run build
114+
115+
docs/preview:
116+
@cd docs && npm run preview
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "bashunit-docs",
3+
"version": "0.35.0",
4+
"description": "Docs for bashunit a simple testing library for bash scripts",
5+
"private": true,
6+
"repository": "git@github.com:TypedDevs/bashunit.git",
7+
"author": "TypedDevs <team@typeddevs.com>",
8+
"license": "MIT",
9+
"type": "module",
10+
"scripts": {
11+
"dev": "vitepress dev .",
12+
"build": "vitepress build .",
13+
"preview": "vitepress preview ."
14+
},
15+
"dependencies": {
16+
"chart.js": "^4.4.9",
17+
"vanilla-tilt": "^1.8.1"
18+
},
19+
"devDependencies": {
20+
"vitepress": "^1.6.3",
21+
"vue": "^3.5.16"
22+
}
23+
}

docs/project-overview.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ Pull requests are welcome! Please read the [contribution guide](https://github.c
3838
For documentation changes you can preview locally with:
3939

4040
```bash
41+
cd docs
4142
npm ci
42-
npm run docs:dev
43+
npm run dev
4344
```
4445

45-
Before submitting your pull request ensure that `npm run docs:build` succeeds and that the test suite passes.
46+
Before submitting your pull request ensure that `npm run build` (run from `docs/`) succeeds and that the test suite passes.
4647

4748
## Further reading
4849

package.json

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"bugs": {
1212
"url": "https://github.com/TypedDevs/bashunit/issues"
1313
},
14-
"author": "TypedDevs <team@typeddevs.com>",
14+
"author": "Chemaclass <chemaclass@outlook.es>",
1515
"license": "MIT",
1616
"type": "module",
1717
"bin": {
@@ -35,18 +35,5 @@
3535
"bashunit",
3636
"tdd",
3737
"assertions"
38-
],
39-
"scripts": {
40-
"docs:dev": "vitepress dev docs",
41-
"docs:build": "vitepress build docs",
42-
"docs:preview": "vitepress preview docs"
43-
},
44-
"dependencies": {
45-
"chart.js": "^4.4.9",
46-
"vanilla-tilt": "^1.8.1"
47-
},
48-
"devDependencies": {
49-
"vitepress": "^1.6.3",
50-
"vue": "^3.5.16"
51-
}
38+
]
5239
}

0 commit comments

Comments
 (0)