Skip to content

Commit

Permalink
feat(webui): setup webui server
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Apr 19, 2024
1 parent 01d3988 commit 583de0f
Show file tree
Hide file tree
Showing 9 changed files with 569 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build

on:
push:
pull_request:

jobs:
lint:
runs-on: ubuntu-latest

steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
- name: Install
run: yarn --no-immutable
- name: Lint
run: yarn lint

build:
runs-on: ubuntu-latest

steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
- name: Install
run: yarn --no-immutable
- name: Build
run: yarn build

test:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: [18, 20]

steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install
run: yarn --no-immutable
- name: Unit Test
run: yarn test:json
- name: Report Coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage/coverage-final.json
name: codecov
21 changes: 21 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Stale

on:
schedule:
- cron: 30 7 * * *

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v4
with:
stale-issue-label: stale
stale-issue-message: |
This issue is stale because it has been open 30 days with no activity.
Remove stale label or comment or this will be closed in 5 days.
close-issue-message: |
This issue was closed because it has been stalled for 5 days with no activity.
days-before-issue-stale: 30
days-before-issue-close: 5
any-of-labels: needs repro, await feedback
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019-present Shigma

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
80 changes: 80 additions & 0 deletions plugins/webui/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"name": "@cordisjs/plugin-webui",
"description": "Web User Interface for Koishi",
"version": "0.28.3",
"main": "lib/node/index.js",
"types": "lib/index.d.ts",
"exports": {
".": {
"node": {
"require": "./lib/node/index.js",
"import": "./lib/node/index.mjs"
},
"browser": "./lib/browser/index.mjs",
"types": "./lib/index.d.ts"
},
"./src/*": "./src/*",
"./package.json": "./package.json"
},
"files": [
"app",
"lib",
"dist",
"src"
],
"author": "Shigma <shigma10826@gmail.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/cordisjs/webui.git",
"directory": "plugins/webui"
},
"bugs": {
"url": "https://github.com/cordisjs/webui/issues"
},
"keywords": [
"cordis",
"plugin",
"frontend",
"webui",
"console",
"service"
],
"cordis": {
"description": {
"en": "Web UI interface",
"zh": "网页控制台"
},
"service": {
"implements": [
"webui"
]
}
},
"peerDependencies": {
"@cordisjs/client": "^0.28.3",
"cordis": "^3.13.6"
},
"peerDependenciesMeta": {
"@cordisjs/client": {
"optional": true
}
},
"devDependencies": {
"@cordisjs/client": "^0.28.3",
"@cordisjs/loader": "^0.8.6",
"@cordisjs/server": "^0.1.8",
"@maikolib/vite-plugin-yaml": "^1.0.1",
"@types/uuid": "^8.3.4",
"@vitejs/plugin-vue": "^4.6.2",
"unocss": "^0.58.6",
"vite": "^4.5.3"
},
"dependencies": {
"@cordisjs/webui": "^0.28.3",
"cosmokit": "^1.6.2",
"open": "^8.4.2",
"uuid": "^8.3.2",
"ws": "^8.16.0"
}
}
25 changes: 25 additions & 0 deletions plugins/webui/src/browser/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Schema } from 'cordis'
import { makeArray } from 'cosmokit'
import { Console, Entry } from '@cordisjs/webui'
import {} from '@cordisjs/loader'

export * from '@cordisjs/webui'

class BrowserConsole extends Console {
start() {
this.accept(this.ctx.loader[Symbol.for('koishi.socket')])
}

resolveEntry(files: Entry.Files) {
if (typeof files === 'string' || Array.isArray(files)) return makeArray(files)
return makeArray(files.prod)
}
}

namespace BrowserConsole {
export interface Config {}

export const Config: Schema<Config> = Schema.object({})
}

export default BrowserConsole
5 changes: 5 additions & 0 deletions plugins/webui/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// placeholder file, do not modify
import Console from './node'

export default Console
export * from './node'
Loading

0 comments on commit 583de0f

Please sign in to comment.