Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: update pnpm scripts (#2350)

boojackdfaf2ee29ca7
diff --git a/.github/workflows/frontend-tests.yml b/.github/workflows/frontend-tests.yml
index 687f61f6f..3b42dd860 100644
--- a/.github/workflows/frontend-tests.yml
+++ b/.github/workflows/frontend-tests.yml
@@ -15,9 +15,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: bufbuild/buf-setup-action@v1
- - run: buf generate
- working-directory: proto
- uses: pnpm/[email protected]
with:
version: 8
@@ -28,6 +25,8 @@ jobs:
cache-dependency-path: "web/pnpm-lock.yaml"
- run: pnpm install
working-directory: web
+ - run: pnpm type-gen
+ working-directory: web
- name: Run eslint check
run: pnpm lint
working-directory: web
@@ -36,9 +35,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- - uses: bufbuild/buf-setup-action@v1
- - run: buf generate
- working-directory: proto
- uses: pnpm/[email protected]
with:
version: 8
@@ -49,6 +45,8 @@ jobs:
cache-dependency-path: "web/pnpm-lock.yaml"
- run: pnpm install
working-directory: web
+ - run: pnpm type-gen
+ working-directory: web
- name: Run frontend build
run: pnpm build
working-directory: web
diff --git a/Dockerfile b/Dockerfile
index 331be9d1c..8286ca0f6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,24 +1,12 @@
-# Build protobuf.
-FROM golang:1.21-alpine AS protobuf
-WORKDIR /protobuf-generate
-
-COPY . .
-
-RUN GO111MODULE=on GOBIN=/usr/local/bin go install github.com/bufbuild/buf/cmd/[email protected]
-
-WORKDIR /protobuf-generate/proto
-
-RUN buf generate
-
# Build frontend dist.
FROM node:18-alpine AS frontend
WORKDIR /frontend-build
-COPY ./web .
+COPY . .
-COPY --from=protobuf /protobuf-generate/web/src/types/proto ./src/types/proto
+WORKDIR /frontend-build/web
-RUN corepack enable && pnpm i --frozen-lockfile
+RUN corepack enable && pnpm i --frozen-lockfile && pnpm type-gen
RUN pnpm build
@@ -27,7 +15,7 @@ FROM golang:1.21-alpine AS backend
WORKDIR /backend-build
COPY . .
-COPY --from=frontend /frontend-build/dist ./server/dist
+COPY --from=frontend /frontend-build/web/dist ./server/dist
RUN CGO_ENABLED=0 go build -o memos ./main.go
diff --git a/docs/development.md b/docs/development.md
index 60a93ccf8..711886ccc 100644
--- a/docs/development.md
+++ b/docs/development.md
@@ -10,34 +10,33 @@ Memos is built with a curated tech stack. It is optimized for developer experien
- [Go](https://golang.org/doc/install)
- [Air](https://github.com/cosmtrek/air#installation) for backend live reload
-- [Buf](https://buf.build/docs/installation)
- [Node.js](https://nodejs.org/)
- [pnpm](https://pnpm.io/installation)
## Steps
-1. pull source code
+1. Pull the source code
```bash
git clone https://github.com/usememos/memos
```
-2. start backend using air(with live reload)
+2. Start backend server with `air`(with live reload)
```bash
air -c scripts/.air.toml
```
-3. generate TypeScript code from protobuf with `buf`
+3. Install frontend dependencies and generate TypeScript code from protobuf
```
- cd proto && buf generate
+ cd web && pnpm i && pnpm type-gen
```
-4. start frontend dev server
+4. Start the dev server of frontend
```bash
- cd web && pnpm i && pnpm dev
+ cd web && pnpm dev
```
Memos should now be running at [http://localhost:3001](http://localhost:3001) and change either frontend or backend code would trigger live reload.
diff --git a/web/package.json b/web/package.json
index 3f3835b65..09f7ebc00 100644
--- a/web/package.json
+++ b/web/package.json
@@ -3,8 +3,10 @@
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
- "lint": "tsc && eslint --ext .js,.ts,.tsx, src",
- "lint-fix": "eslint --ext .js,.ts,.tsx, src --fix"
+ "lint": "eslint --ext .js,.ts,.tsx, src",
+ "lint-fix": "eslint --ext .js,.ts,.tsx, src --fix",
+ "type-gen": "cd ../proto && buf generate",
+ "type-check": "tsc"
},
"packageManager": "[email protected]",
"dependencies": {
@@ -40,6 +42,7 @@
"zustand": "4.4.1"
},
"devDependencies": {
+ "@bufbuild/buf": "^1.27.0",
"@trivago/prettier-plugin-sort-imports": "^3.4.0",
"@types/katex": "^0.16.3",
"@types/lodash-es": "^4.17.9",
diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml
index 7e83755b9..22b1157cc 100644
--- a/web/pnpm-lock.yaml
+++ b/web/pnpm-lock.yaml
@@ -97,6 +97,9 @@ dependencies:
version: 4.4.1(@types/[email protected])([email protected])
devDependencies:
+ '@bufbuild/buf':
+ specifier: ^1.27.0
+ version: 1.27.0
'@trivago/prettier-plugin-sort-imports':
specifier: ^3.4.0
version: 3.4.0([email protected])
@@ -425,6 +428,74 @@ packages:
'@babel/helper-validator-identifier': 7.22.20
to-fast-properties: 2.0.0
+ /@bufbuild/[email protected]:
+ resolution: {integrity: sha512-Bsdo9BkkIlIgBpQJ2jyIXl9ggSqDdSJ12euxgU1y4pbT5iD11mdiUA7eq5/ssxLJilUrUGj2Gk1h1KbYG/JfVA==}
+ engines: {node: '>=12'}
+ cpu: [arm64]
+ os: [darwin]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@bufbuild/[email protected]:
+ resolution: {integrity: sha512-aJmSZvO6uNxHST8+kN5cukv7/ZLgDnvklp+r6uyokocg5sk1rgWQVBqiVtGmoDWwPbotpMhb3EuqtwN9hdNrOg==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [darwin]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@bufbuild/[email protected]:
+ resolution: {integrity: sha512-1NPHARYENNVWOK3bQxbnYsMLU09em4/kdyAnCwyGkNhr+pWUlWdCBu3X5tdrRW+mnhjeagIcomTMhgVjxIAS7g==}
+ engines: {node: '>=12'}
+ cpu: [arm64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@bufbuild/[email protected]:
+ resolution: {integrity: sha512-3LMTSJlwJAeOfjPuB0NBK+1Yfg1Bybadt+c1X/vF8XSXut1u0Ju1/fbRDz75BF4AlMidMQPdGS+vPWmPcb51hA==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [linux]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@bufbuild/[email protected]:
+ resolution: {integrity: sha512-Za5d3obNvSfLZAlQW8IAWtv1Yv0gQTFDVMPyYiOh70rKIfKIxrWZxT4E4nzFLZZ54VQDFoUl81bAjOYLOgaspQ==}
+ engines: {node: '>=12'}
+ cpu: [arm64]
+ os: [win32]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@bufbuild/[email protected]:
+ resolution: {integrity: sha512-OzVK4Fz162Z6fFHAAZhHPW2GiCXjweCG/hwjOtFt2gza1t3ImYp0CwxJI6ePGY+th3Y9yu8rY0iHiI59ezMa4Q==}
+ engines: {node: '>=12'}
+ cpu: [x64]
+ os: [win32]
+ requiresBuild: true
+ dev: true
+ optional: true
+
+ /@bufbuild/[email protected]:
+ resolution: {integrity: sha512-vR/ke6gUNgGSC3z7WkHLcbO+ur+zvGTC4ohHsLo2dZqEWysWySjNpcU70SKdIN3G5M4fSS1ki6MkZPes3E+83w==}
+ engines: {node: '>=12'}
+ hasBin: true
+ requiresBuild: true
+ optionalDependencies:
+ '@bufbuild/buf-darwin-arm64': 1.27.0
+ '@bufbuild/buf-darwin-x64': 1.27.0
+ '@bufbuild/buf-linux-aarch64': 1.27.0
+ '@bufbuild/buf-linux-x64': 1.27.0
+ '@bufbuild/buf-win32-arm64': 1.27.0
+ '@bufbuild/buf-win32-x64': 1.27.0
+ dev: true
+
/@emotion/[email protected]:
resolution: {integrity: sha512-m4HEDZleaaCH+XgDDsPF15Ht6wTLsgDTeR3WYj9Q/k76JtWhrJjcP4+/XlG8LGT/Rol9qUfOIztXeA84ATpqPQ==}
dependencies: