Skip to content

Commit

Permalink
refactor: sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
aooiuu committed Jul 15, 2024
1 parent f68ee13 commit f4edbee
Show file tree
Hide file tree
Showing 43 changed files with 579 additions and 845 deletions.
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"*.d.ts"
],
"scripts": {
"start": "esno index.ts",
"start": "tsx index.ts",
"release": "bumpp -r --no-push",
"clean": "rimraf packages/*/dist --glob",
"clean:npm": "rimraf packages/*/node_modules --glob && rimraf node_modules",
Expand All @@ -39,7 +39,6 @@
"run:vsc": "npm-run-all core:build build:web-w",
"docs": "npm -C docs run docs:dev",
"build:docs": "npm -C docs run docs:build",
"server": "npm -C packages/server run dev",
"run:server": "run-p server run:web",
"test": "jest",
"coveralls": "jest --coverage",
Expand All @@ -54,6 +53,7 @@
"vscode:build-tpl": "npm -C packages/web run vscode:build",
"vscode:build-vsx": "npm -C packages/vscode run build",
"vscode:build": "npm-run-all vscode:build-tpl vscode:build-vsx",
"server": "npm -C packages/server run dev",
"server:build": "npm -C packages/server run build",
"cli:build-tpl": "npm -C packages/web run cli:build",
"cli:build-js": "npm -C packages/cli run build",
Expand All @@ -70,8 +70,10 @@
"@types/mime": "3.0.4",
"@types/uuid": "^9.0.8",
"bumpp": "^9.4.1",
"cross-env": "^7.0.3",
"husky": "^8.0.0",
"npm-run-all": "^4.1.5",
"tsx": "^4.16.2",
"unbuild": "^2.0.0"
},
"lint-staged": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"any-reader": "./bin/index.mjs"
},
"scripts": {
"build": "esno ./scripts/publish.cjs && unbuild"
"build": "tsx ./scripts/publish.cjs && unbuild"
},
"keywords": [],
"author": "aooiuu <aooiu@qq.com>",
Expand Down
3 changes: 1 addition & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"dist"
],
"scripts": {
"start": "esno src/start.ts",
"start": "tsx src/start.ts",
"build": "unbuild",
"stub": "unbuild --stub"
},
Expand All @@ -45,7 +45,6 @@
"@types/node": "^18.16.19",
"@types/xmldom": "^0.1.34",
"eslint": "^8.44.0",
"esno": "^0.16.3",
"jest": "^29.7.0",
"ts-jest": "^29.1.1",
"typescript": "^5.1.6"
Expand Down
24 changes: 24 additions & 0 deletions packages/rule-utils/src/rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,27 @@ export function createRule(rule: Rule | any): Rule {
viewStyle: 0,
}, rule)
}

/**
*
* @param {string} str
* @returns {boolean}
*/
export function isEsoStr(str: string): boolean {
return str.startsWith('eso://')
}

/**
*
* @param rule
* @returns {boolean}
*/
export function isRule(rule: any): boolean {
if (typeof rule === 'string')
return isEsoStr(rule)

if (typeof rule !== 'object')
return false

return rule.id && rule.host && typeof rule.contentType !== 'undefined'
}
5 changes: 2 additions & 3 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"scripts": {
"build": "unbuild",
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "esno watch src/run.ts"
"dev": "tsx watch src/run.ts"
},
"dependencies": {
"@any-reader/core": "workspace:^",
Expand All @@ -43,7 +43,6 @@
"@types/koa-router": "^7.4.8",
"@types/koa-session": "^6.4.5",
"@types/koa-static": "^4.0.4",
"@types/koa__cors": "^5.0.0",
"esno": "^0.16.3"
"@types/koa__cors": "^5.0.0"
}
}
4 changes: 2 additions & 2 deletions packages/server/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { bodyParser } from '@koa/bodyparser'
import cors from '@koa/cors'
import serve from 'koa-static'
import session from 'koa-session'
import { Api } from '@any-reader/shared'
import { createApp } from '@any-reader/shared'
import { createRoute } from './routes'

const __filename = fileURLToPath(import.meta.url)
Expand All @@ -18,7 +18,7 @@ const CONFIG_PATH = path.join(ROOT_PATH, 'config.desktop.json')
const app = new Koa()

export async function start(port = 8898, root = resolve(__dirname, 'public')) {
const api = new Api({
const api = createApp({
configPath: CONFIG_PATH,
})
const router = createRoute(api)
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/routes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Router from 'koa-router'
import bcrypt from 'bcryptjs'
import type { Api } from '@any-reader/shared'
import type { App } from '@any-reader/shared'

export function createRoute(api: Api) {
export function createRoute(api: App) {
const router = new Router()

router.post('/login', (ctx) => {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default defineBuildConfig({
externals: [],
clean: true,
declaration: true,
sourcemap: true,
rollup: {
inlineDependencies: true,
emitCJS: true,
Expand Down
4 changes: 1 addition & 3 deletions packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
],
"scripts": {
"build": "unbuild",
"stub": "unbuild --stub",
"start": "esno src/start.ts"
"stub": "unbuild --stub"
},
"dependencies": {
"@any-reader/core": "workspace:^",
Expand All @@ -50,7 +49,6 @@
"@types/encoding-japanese": "^2.0.5",
"@types/lodash-es": "^4.17.12",
"@types/node": "^18.16.19",
"esno": "^0.16.3",
"reflect-metadata": "^0.2.2",
"rollup": "^3.26.0",
"rollup-plugin-dts": "^5.3.0",
Expand Down
Loading

0 comments on commit f4edbee

Please sign in to comment.