Skip to content

Commit

Permalink
feat: ✨ upgrade logseq sdk version and replace yarn with pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed May 27, 2024
1 parent 5e62bf7 commit 1b0e637
Show file tree
Hide file tree
Showing 19 changed files with 5,683 additions and 4,657 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_LOGSEQ_API_SERVER=http://127.0.0.1:12315
VITE_LOGSEQ_API_TOKEN=123
1 change: 1 addition & 0 deletions .env.plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_MODE=plugin
1 change: 1 addition & 0 deletions .env.web
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_MODE=web
26 changes: 17 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,34 @@ on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
release:
name: Release
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
node-version: 14
version: 8
run_install: false

- name: Install dependencies
run: yarn
run: pnpm install

- name: Build
run: yarn build
run: pnpm build:plugin

- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
41 changes: 36 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,46 @@
[![License](https://img.shields.io/github/license/haydenull/logseq-plugin-react-boilerplate?color=blue)](https://github.com/haydenull/logseq-plugin-react-boilerplate/blob/main/LICENSE)

## Demo
![demo](./demo.gif)
![demo](./screenshots/demo.gif)

## Pre Requirements
1. [nodejs](https://nodejs.org/)
2. [pnpm](https://pnpm.io/)

## Usage
1. Use this template create your own plugin
2. change `package.json` to your own plugin name
2. change `package.json` name to your own plugin name
3. change LICENSE to your own license
4. use `yarn dev` to run your plugin in browser
5. use `yarn build` to build your plugin and load it in logseq
4. change logo.png to your own logo
5. run `pnpm install` to install dependencies

### Browser mode with HMR

1. run `pnpm dev` to start vite server
2. Open HTTP APIs server Feature in logseq settings
![](./screenshots/settings-api-server-feature.png)
3. add [Authorization tokens](https://haydenut.notion.site/English-fd47d1843e654f5485a07ef4935ed365?pvs=25#7a7a57de5a77480a84d30bc610d235c5) in logseq
* API_SERVER=http://127.0.0.1:12315
* API_TOKEN=123
![](./screenshots/api-server.png)
4. open `localhost:5173` in browser

> [!TIP]
> Browser mode cannot access logseq plugin settings, you can add a file `mocks/settings.local.json` to mock.
## Release

### Plugin mode
This mode doesn't support HMR, you need to run `pnpm build` and reload plugin in logseq to see the changes
1. run `pnpm build:plugin` to build plugin
2. Open Plugins feature in logseq settings
![](./screenshots/settings-plugin-feature.png)
3. Click `Load unpacked plugin` and select this project folder
![](./screenshots/load-plugin.png)

## Release new version
1. push to `main` branch
2. github ci will auto create a new release

## Publish to [logseq marketplace](https://github.com/logseq/marketplace)

Create PR to add your plugin message to [logseq/marketplace](https://github.com/logseq/marketplace)
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite App</title>
<title>Logseq Plugin</title>
</head>
<body>
<div id="root"></div>
Expand Down
16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
"icon": "logo.png"
},
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"dev": "vite --mode web",
"build:plugin": "tsc && vite build --mode plugin",
"build:web": "tsc && vite build --mode web",
"preview": "vite preview"
},
"dependencies": {
"@logseq/libs": "^0.0.10",
"antd": "^5.0.2",
"@logseq/libs": "^0.0.17",
"react": "^18.2.0",
"react-dom": "^18.2.0"
},
"devDependencies": {
"@haydenull/fabric": "^0.2.6",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
Expand All @@ -27,10 +28,13 @@
"@types/react-dom": "^18.0.9",
"@vitejs/plugin-react": "^2.2.0",
"autoprefixer": "^10.4.2",
"eslint": "^8.57.0",
"logseq-proxy": "^0.1.2",
"postcss": "^8.4.5",
"semantic-release": "^21.1.2",
"tailwindcss": "^3.2.4",
"typescript": "^4.9.3",
"vite": "^3.2.4",
"vite": "^4.5.3",
"vite-plugin-importer": "^0.2.5"
}
}
}
Loading

0 comments on commit 1b0e637

Please sign in to comment.