Migrate to bun

This commit is contained in:
Anbraten 2024-02-25 11:05:48 +01:00
parent cb3efd2cd9
commit e9e0772211
22 changed files with 69 additions and 10031 deletions

View file

@ -84,6 +84,7 @@
"ignorePaths": [
"**/node_modules/**/*",
"pnpm-lock.yaml",
"bun.lockb",
".gitignore",
".git/**/*",
".cspell.json",

View file

@ -73,17 +73,17 @@ tasks:
before: |
cd web/
init: |
pnpm install
bun install
command: |
pnpm start
bun start
- name: Docs
before: |
cd docs/
init: |
pnpm install
pnpm build:woodpecker-plugins
bun install
bun build:woodpecker-plugins
command: |
pnpm start --port 4000
bun start --port 4000
ports:
- port: 3000

View file

@ -2,6 +2,7 @@ build/
docs/versioned_docs/
docs/.docusaurus/
docs/pnpm-lock.yaml
docs/bun.lockb
dist/
CHANGELOG.md

2
.vscode/launch.json vendored
View file

@ -38,7 +38,7 @@
"name": "Woodpecker UI",
"type": "node",
"request": "launch",
"runtimeExecutable": "pnpm",
"runtimeExecutable": "bun",
"runtimeArgs": ["start"],
"cwd": "${workspaceFolder}/web",
"resolveSourceMapLocations": ["${workspaceFolder}/web/**", "!**/node_modules/**"],

View file

@ -3,18 +3,17 @@ when:
variables:
- &golang_image 'docker.io/golang:1.22.0'
- &node_image 'docker.io/node:21-alpine'
- &bun_image 'docker.io/oven/bun:1.0-alpine'
- &xgo_image 'docker.io/techknowlogick/xgo:go-1.22.0'
- &xgo_version 'go-1.21.2'
steps:
build-web:
image: *node_image
image: *bun_image
directory: web/
commands:
- corepack enable
- pnpm install --frozen-lockfile
- pnpm build
- bun install --frozen-lockfile
- bun build
vendor:
image: *golang_image

View file

@ -1,6 +1,6 @@
variables:
- &golang_image 'docker.io/golang:1.22.0'
- &node_image 'docker.io/node:21-alpine'
- &bun_image 'docker.io/oven/bun:1.0-alpine'
- &xgo_image 'docker.io/techknowlogick/xgo:go-1.22.0'
- &xgo_version 'go-1.21.2'
- &buildx_plugin 'docker.io/woodpeckerci/plugin-docker-buildx:3.1.0'
@ -68,12 +68,11 @@ steps:
# S e r v e r #
###############
build-web:
image: *node_image
image: *bun_image
directory: web/
commands:
- corepack enable
- pnpm install --frozen-lockfile
- pnpm build
- bun install --frozen-lockfile
- bun build
when:
- event: pull_request
evaluate: 'CI_COMMIT_PULL_REQUEST_LABELS contains "build_pr_images"'

View file

@ -1,6 +1,6 @@
variables:
- &golang_image 'docker.io/golang:1.21.5'
- &node_image 'docker.io/node:21-alpine'
- &bun_image 'docker.io/oven/bun:1.0-alpine'
- &alpine_image 'docker.io/alpine:3.19'
- path: &when_path
- 'docs/**'
@ -48,12 +48,11 @@ steps:
- event: manual
build:
image: *node_image
image: *bun_image
directory: docs/
commands:
- corepack enable
- pnpm install --frozen-lockfile
- pnpm build
- bun install --frozen-lockfile
- bun build
when:
- path: *when_path
event: [tag, pull_request, push]

View file

@ -6,7 +6,7 @@ when:
- renovate/*
variables:
- &node_image 'docker.io/node:21-alpine'
- &bun_image 'docker.io/oven/bun:1.0-alpine'
- &when
path:
# related config files
@ -18,49 +18,48 @@ variables:
steps:
install-dependencies:
image: *node_image
image: *bun_image
directory: web/
commands:
- corepack enable
- pnpm install --frozen-lockfile
- bun install --frozen-lockfile
when: *when
lint:
depends_on:
- install-dependencies
image: *node_image
image: *bun_image
directory: web/
commands:
- corepack enable
- pnpm lint
- bun lint
when: *when
formatcheck:
depends_on:
- install-dependencies
image: *node_image
image: *bun_image
directory: web/
commands:
- corepack enable
- pnpm format:check
- bun format:check
when: *when
typecheck:
depends_on:
- install-dependencies
image: *node_image
image: *bun_image
directory: web/
commands:
- corepack enable
- pnpm typecheck
- bun typecheck
when: *when
test:
depends_on:
- install-dependencies
image: *node_image
image: *bun_image
directory: web/
commands:
- corepack enable
- pnpm test
- bun test
when: *when

View file

@ -140,7 +140,7 @@ install-tools: ## Install development tools
fi
ui-dependencies: ## Install UI dependencies
(cd web/; pnpm install --frozen-lockfile)
(cd web/; bun install --frozen-lockfile)
##@ Test
@ -150,7 +150,7 @@ lint: install-tools ## Lint code
golangci-lint run
lint-ui: ui-dependencies ## Lint UI code
(cd web/; pnpm lint --quiet)
(cd web/; bun lint --quiet)
test-agent: ## Test agent code
go test -race -cover -coverprofile agent-coverage.out -timeout 30s go.woodpecker-ci.org/woodpecker/v2/cmd/agent go.woodpecker-ci.org/woodpecker/v2/agent/...
@ -169,10 +169,10 @@ test-server-datastore-coverage: ## Test server datastore with coverage report
go test -race -cover -coverprofile datastore-coverage.out -timeout 120s go.woodpecker-ci.org/woodpecker/v2/server/store/...
test-ui: ui-dependencies ## Test UI code
(cd web/; pnpm run lint)
(cd web/; pnpm run format:check)
(cd web/; pnpm run typecheck)
(cd web/; pnpm run test)
(cd web/; bun lint)
(cd web/; bun format:check)
(cd web/; bun typecheck)
(cd web/; bun test)
test-lib: ## Test lib code
go test -race -cover -coverprofile coverage.out -timeout 30s $(shell go list ./... | grep -v '/cmd\|/agent\|/cli\|/server')
@ -183,7 +183,7 @@ test: test-agent test-server test-server-datastore test-cli test-lib ## Run all
##@ Build
build-ui: ## Build UI
(cd web/; pnpm install --frozen-lockfile; pnpm build)
(cd web/; bun install --frozen-lockfile; bun build)
build-server: build-ui generate-swagger ## Build server
CGO_ENABLED=${CGO_ENABLED} GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags '${LDFLAGS}' -o dist/woodpecker-server${BIN_SUFFIX} go.woodpecker-ci.org/woodpecker/v2/cmd/server

View file

@ -5,13 +5,13 @@ This website is built using [Docusaurus 3](https://docusaurus.io/), a modern sta
## Installation
```bash
pnpm install
bun install
```
## Local Development
```bash
pnpm start
bun start
```
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
@ -19,7 +19,7 @@ This command starts a local development server and opens up a browser window. Mo
## Build
```bash
pnpm build
bun build
```
This command generates static content into the `build` directory and can be served using any static contents hosting service.
@ -31,5 +31,5 @@ Deployment happen via [CI](https://github.com/woodpecker-ci/woodpecker/blob/d59f
To manually build the website and push it exec:
```sh
GIT_USER=woodpecker-bot USE_SSH=true DEPLOYMENT_BRANCH=main pnpm deploy
GIT_USER=woodpecker-bot USE_SSH=true DEPLOYMENT_BRANCH=main bun deploy
```

BIN
docs/bun.lockb Executable file

Binary file not shown.

View file

@ -32,12 +32,12 @@ Install make on:
- [Windows](https://stackoverflow.com/a/32127632/8461267)
- Mac OS: `brew install make`
### Install Node.js & `pnpm`
### Install Node.js & `bun`
Install [Node.js (>=14)](https://nodejs.org/en/download/) if you want to build Woodpecker's UI or documentation.
For dependency installation (`node_modules`) of UI and documentation of Woodpecker the package manager pnpm is used.
[This guide](https://pnpm.io/installation) describes the installation of `pnpm`.
For dependency installation (`node_modules`) of UI and documentation of Woodpecker the package manager bun is used.
[This guide](https://bun.sh/docs/installation) describes the installation of `bun`.
### Install `pre-commit` (optional)

View file

@ -1,16 +1,16 @@
# UI Development
To develop the UI you need to install [Node.js and pnpm](./01-getting-started.md#install-nodejs--pnpm). In addition it is recommended to use VS-Code with the recommended plugin selection to get features like auto-formatting, linting and typechecking. The UI is written with [Vue 3](https://v3.vuejs.org/) as Single-Page-Application accessing the Woodpecker REST api.
To develop the UI you need to install [Node.js and bun](./01-getting-started.md#install-nodejs--bun). In addition it is recommended to use VS-Code with the recommended plugin selection to get features like auto-formatting, linting and typechecking. The UI is written with [Vue 3](https://v3.vuejs.org/) as Single-Page-Application accessing the Woodpecker REST api.
## Setup
The UI code is placed in `web/`. Change to that folder in your terminal with `cd web/` and install all dependencies by running `pnpm install`. For production builds the generated UI code is integrated into the Woodpecker server by using [go-embed](https://pkg.go.dev/embed).
The UI code is placed in `web/`. Change to that folder in your terminal with `cd web/` and install all dependencies by running `bun install`. For production builds the generated UI code is integrated into the Woodpecker server by using [go-embed](https://pkg.go.dev/embed).
Testing UI changes would require us to rebuild the UI after each adjustment to the code by running `pnpm build` and restarting the Woodpecker server. To avoid this you can make use of the dev-proxy integrated into the Woodpecker server. This integrated dev-proxy will forward all none api request to a separate http-server which will only serve the UI files.
Testing UI changes would require us to rebuild the UI after each adjustment to the code by running `bun build` and restarting the Woodpecker server. To avoid this you can make use of the dev-proxy integrated into the Woodpecker server. This integrated dev-proxy will forward all none api request to a separate http-server which will only serve the UI files.
![UI Proxy architecture](./ui-proxy.svg)
Start the UI server locally with [hot-reloading](https://stackoverflow.com/a/41429055/8461267) by running: `pnpm start`. To enable the forwarding of requests to the UI server you have to enable the dev-proxy inside the Woodpecker server by adding `WOODPECKER_DEV_WWW_PROXY=http://localhost:8010` to your `.env` file.
Start the UI server locally with [hot-reloading](https://stackoverflow.com/a/41429055/8461267) by running: `bun start`. To enable the forwarding of requests to the UI server you have to enable the dev-proxy inside the Woodpecker server by adding `WOODPECKER_DEV_WWW_PROXY=http://localhost:8010` to your `.env` file.
After starting the Woodpecker server as explained in the [debugging](./01-getting-started.md#debugging) section, you should now be able to access the UI under [http://localhost:8000](http://localhost:8000).
## Tools and frameworks

View file

@ -2,19 +2,19 @@
The documentation is using docusaurus as framework. You can learn more about it from its [official documentation](https://docusaurus.io/docs/).
If you only want to change some text it probably is enough if you just search for the corresponding [Markdown](https://www.markdownguide.org/basic-syntax/) file inside the `docs/docs/` folder and adjust it. If you want to change larger parts and test the rendered documentation you can run docusaurus locally. Similarly to the UI you need to install [Node.js and pnpm](./01-getting-started.md#install-nodejs--pnpm). After that you can run and build docusaurus locally by using the following commands:
If you only want to change some text it probably is enough if you just search for the corresponding [Markdown](https://www.markdownguide.org/basic-syntax/) file inside the `docs/docs/` folder and adjust it. If you want to change larger parts and test the rendered documentation you can run docusaurus locally. Similarly to the UI you need to install [Node.js and bun](./01-getting-started.md#install-nodejs--bun). After that you can run and build docusaurus locally by using the following commands:
```bash
cd docs/
pnpm install
bun install
# build plugins used by the docs
pnpm build:woodpecker-plugins
bun build:woodpecker-plugins
# start docs with hot-reloading, so you can change the docs and directly see the changes in the browser without reloading it manually
pnpm start
bun start
# or build the docs to deploy it to some static page hosting
pnpm build
bun build
```

View file

@ -4,8 +4,8 @@
"private": true,
"scripts": {
"start": "cd ../ && make docs && cd docs && docusaurus start",
"build": "pnpm build:woodpecker-plugins && docusaurus build",
"build:woodpecker-plugins": "cd plugins/woodpecker-plugins && pnpm i && pnpm build",
"build": "bun build:woodpecker-plugins && docusaurus build",
"build:woodpecker-plugins": "cd plugins/woodpecker-plugins && bun i && bun build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
@ -51,11 +51,12 @@
"@types/react-router-dom": "^5.3.3",
"typescript": "^5.3.3"
},
"pnpm": {
"overrides": {
"trim": "^0.0.3",
"got": "^11.8.5",
"follow-redirects@<1.15.4": ">=1.15.4"
}
"workspaces": [
"plugins/*"
],
"overrides": {
"trim": "^0.0.3",
"got": "^11.8.5",
"follow-redirects@<1.15.4": ">=1.15.4"
}
}

View file

@ -5,8 +5,8 @@
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"start": "pnpm run style && concurrently 'tsc -w' 'tsc -w -p tsconfig.jsx.json'",
"build": "pnpm run style && tsc && tsc -p tsconfig.jsx.json",
"start": "bun style && concurrently 'tsc -w' 'tsc -w -p tsconfig.jsx.json'",
"build": "bun style && tsc && tsc -p tsconfig.jsx.json",
"style": "mkdir -p dist/theme/ && cp src/theme/style.css dist/theme/style.css"
},
"devDependencies": {

File diff suppressed because it is too large Load diff

View file

@ -1,3 +0,0 @@
packages:
- '.'
- 'plugins/**'

View file

@ -1,4 +1,5 @@
pnpm-lock.yaml
bun.lockb
dist
coverage/
LICENSE

BIN
web/bun.lockb Executable file

Binary file not shown.

View file

@ -68,9 +68,7 @@
"vue-tsc": "^1.8.27",
"windicss": "^3.5.6"
},
"pnpm": {
"overrides": {
"semver@<7.5.2": ">=7.5.2"
}
"overrides": {
"semver@<7.5.2": ">=7.5.2"
}
}

View file

@ -19,7 +19,7 @@ function woodpeckerInfoPlugin() {
const info =
'1) Please add `WOODPECKER_DEV_WWW_PROXY=http://localhost:8010` to your `.env` file.\n' +
'After starting the woodpecker server as well you should now be able to access the UI at http://localhost:8000/\n\n' +
'2) If you want to run the vite dev server (`pnpm start`) within a container please set `VITE_DEV_SERVER_HOST=0.0.0.0`.';
'2) If you want to run the vite dev server (`bun start`) within a container please set `VITE_DEV_SERVER_HOST=0.0.0.0`.';
// eslint-disable-next-line no-console
console.log(info);
},