Skip to content

Commit

Permalink
Improve basic development experience (Koenkk#1844)
Browse files Browse the repository at this point in the history
* feat: Add nvm support

* feat: Add support for single device include when working in devmode

* feat: Add ability to change dev port

* feat: Wording fix

* feat: Bump node version recommendation to 18
  • Loading branch information
mdziekon authored Jan 26, 2023
1 parent 59a62ea commit 75f620d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
32 changes: 30 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,12 @@ Docgen includes some scripts to help testing the page.

## VuePress

Use Node.js 16 for building VuePress (other versions like Node.js 18 are not supported)
Use Node.js 18 for building VuePress (other versions are not officially supported).

```bash
# Switch to node 18 (for nvm or nvm-compatible tool users)
nvm use

# Install dependencies
npm ci
```
Expand All @@ -74,13 +77,38 @@ npm run dev
The `dev`-Mode **excludes** the huge amount device-pages which slows down the build process drastically.
If you are interested in the device-pages you could include them by using the `npm run dev:devices` npm-run script.

#### Include specific device

When running in `dev`-Mode, you can also specify a device (but this device only) which you would like to include in the build process.
Useful when working on improving notes of just one device.
`INCLUDE_DEVICE` variable should be supplied with device's filename (see [`/docs/devices`](/docs/devices/) folder), without the `.md.` extension.

```bash
# Run vuepress in dev mode with specific device included
npx cross-env INCLUDE_DEVICE=<DEVICE_FILE_NAME> npm run dev

# Example for TS011F_plug_1
npx cross-env INCLUDE_DEVICE=TS011F_plug_1 npm run dev
```

#### Change development port

You can change development server port when the default one (8080) is taken on your system.

```bash
# Run vuepress in dev mode on specified port
npx cross-env DEV_PORT=<PORT_NUMBER> npm run dev

# Example for port no 15080
npx cross-env DEV_PORT=15080 npm run dev
```

## Docker

You can also just use a docker-image include Node.js.

```bash
$ docker run --rm -v $PWD:/app -u $UID -ti node:16 bash
$ docker run --rm -v $PWD:/app -u $UID -ti node:18-slim bash
node@87e1438ef553:/$ cd /app
node@87e1438ef553:/app$ npm ci
node@87e1438ef553:/app$ npm run dev
Expand Down
6 changes: 6 additions & 0 deletions vuepress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ const pagePatterns = ['**/*.md', '!.vuepress', '!node_modules'];
if (process.env.EXCLUDE_DEVICES) {
pagePatterns.push('!devices');
}
if (process.env.INCLUDE_DEVICE) {
pagePatterns.push(`devices/${process.env.INCLUDE_DEVICE}.md`);
}

const devServerPort = (process.env.DEV_PORT ? parseInt(process.env.DEV_PORT, 10) : undefined);

const conf = defineUserConfig({
port: devServerPort,
base: getBase(),
title: 'Zigbee2MQTT' + ( isDevelop ? ' develop' : '' ),
description: 'Zigbee to MQTT bridge, get rid of your proprietary Zigbee bridges',
Expand Down

0 comments on commit 75f620d

Please sign in to comment.