diff --git a/README.md b/README.md
index 76c9d692..9045298f 100644
--- a/README.md
+++ b/README.md
@@ -18,10 +18,9 @@
- [X] [zhi-env](https://github.com/terwer/zhi/tree/main/libs/zhi-env) ![zhi-env](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-env%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-log](https://github.com/terwer/zhi/tree/main/libs/zhi-log) ![zhi-log](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-log%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-common](https://github.com/terwer/zhi/tree/main/libs/zhi-common) ![zhi-common](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-common%2Fpackage.json&query=%24.version&label=release)
- - [ ] [zhi-common-basic](https://github.com/terwer/zhi/tree/main/libs/zhi-common-basic)
- - [ ] [zhi-common-json-validate](https://github.com/terwer/zhi/tree/main/libs/zhi-common-json-validate)
+ - [X] [zhi-common-json-validate](https://github.com/terwer/zhi/tree/main/libs/zhi-common-json-validate) ![zhi-common-json-validate](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-common-json-validate%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-common-markdown](https://github.com/terwer/zhi/tree/main/libs/zhi-common-markdown) ![zhi-common-markdown](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-common-markdown%2Fpackage.json&query=%24.version&label=release)
- - [ ] [zhi-common-version](https://github.com/terwer/zhi/tree/main/libs/zhi-common-version)
+ - [X] [zhi-common-version](https://github.com/terwer/zhi/tree/main/libs/zhi-common-version) ![zhi-common-version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-common-version%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-infra](https://github.com/terwer/zhi/tree/main/libs/zhi-infra) ![zhi-infra](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-infra%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-cmd](https://github.com/terwer/zhi/tree/main/libs/zhi-cmd) ![zhi-infra](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-cmd%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-blog-api](https://github.com/terwer/zhi/tree/main/libs/zhi-blog-api) ![zhi-blog-api](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-blog-api%2Fpackage.json&query=%24.version&label=release)
@@ -33,7 +32,7 @@
- [X] [zhi-siyuan-api](https://github.com/terwer/zhi/tree/main/libs/zhi-siyuan-api) ![zhi-siyuan-api](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-siyuan-api%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-picgo-core](https://github.com/terwer/zhi/tree/main/libs/zhi-picgo-core) ![zhi-picgo-core](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-picgo-core%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-siyuan-picgo](https://github.com/terwer/zhi/tree/main/libs/zhi-siyuan-picgo) ![zhi-siyuan-picgo](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-siyuan-picgo%2Fpackage.json&query=%24.version&label=release)
- - [ ] [zhi-chatgpt](https://github.com/terwer/zhi/tree/main/libs/zhi-chatgpt) ![zhi-chatgpt](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-chatgpt%2Fpackage.json&query=%24.version&label=release)
+ - [X] [zhi-chatgpt](https://github.com/terwer/zhi/tree/main/libs/zhi-chatgpt) ![zhi-chatgpt](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-chatgpt%2Fpackage.json&query=%24.version&label=release)
### scaffold && docs
diff --git a/README_zh_CN.md b/README_zh_CN.md
index 9df4590a..67c2ec75 100644
--- a/README_zh_CN.md
+++ b/README_zh_CN.md
@@ -18,10 +18,9 @@
- [X] [zhi-env](https://github.com/terwer/zhi/tree/main/libs/zhi-env) ![zhi-env](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-env%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-log](https://github.com/terwer/zhi/tree/main/libs/zhi-log) ![zhi-log](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-log%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-common](https://github.com/terwer/zhi/tree/main/libs/zhi-common) ![zhi-common](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-common%2Fpackage.json&query=%24.version&label=release)
- - [ ] [zhi-common-basic](https://github.com/terwer/zhi/tree/main/libs/zhi-common-basic)
- - [ ] [zhi-common-json-validate](https://github.com/terwer/zhi/tree/main/libs/zhi-common-json-validate)
+ - [X] [zhi-common-json-validate](https://github.com/terwer/zhi/tree/main/libs/zhi-common-json-validate) ![zhi-common-json-validate](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-common-json-validate%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-common-markdown](https://github.com/terwer/zhi/tree/main/libs/zhi-common-markdown) ![zhi-common-markdown](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-common-markdown%2Fpackage.json&query=%24.version&label=release)
- - [ ] [zhi-common-version](https://github.com/terwer/zhi/tree/main/libs/zhi-common-version)
+ - [X] [zhi-common-version](https://github.com/terwer/zhi/tree/main/libs/zhi-common-version) ![zhi-common-version](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-common-version%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-infra](https://github.com/terwer/zhi/tree/main/libs/zhi-infra) ![zhi-infra](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-infra%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-cmd](https://github.com/terwer/zhi/tree/main/libs/zhi-cmd) ![zhi-infra](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-cmd%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-blog-api](https://github.com/terwer/zhi/tree/main/libs/zhi-blog-api) ![zhi-blog-api](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-blog-api%2Fpackage.json&query=%24.version&label=release)
@@ -33,7 +32,7 @@
- [X] [zhi-siyuan-api](https://github.com/terwer/zhi/tree/main/libs/zhi-siyuan-api) ![zhi-siyuan-api](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-siyuan-api%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-picgo-core](https://github.com/terwer/zhi/tree/main/libs/zhi-picgo-core) ![zhi-picgo-core](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-picgo-core%2Fpackage.json&query=%24.version&label=release)
- [X] [zhi-siyuan-picgo](https://github.com/terwer/zhi/tree/main/libs/zhi-siyuan-picgo) ![zhi-siyuan-picgo](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-siyuan-picgo%2Fpackage.json&query=%24.version&label=release)
- - [ ] [zhi-chatgpt](https://github.com/terwer/zhi/tree/main/libs/zhi-chatgpt) ![zhi-chatgpt](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-chatgpt%2Fpackage.json&query=%24.version&label=release)
+ - [X] [zhi-chatgpt](https://github.com/terwer/zhi/tree/main/libs/zhi-chatgpt) ![zhi-chatgpt](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fraw.githubusercontent.com%2Fterwer%2Fzhi%2Fmain%2Flibs%2Fzhi-chatgpt%2Fpackage.json&query=%24.version&label=release)
### 脚手架 && 文档
diff --git a/libs/zhi-cmd/CHANGELOG.md b/libs/zhi-cmd/CHANGELOG.md
index 9523a2e1..9bd9483f 100644
--- a/libs/zhi-cmd/CHANGELOG.md
+++ b/libs/zhi-cmd/CHANGELOG.md
@@ -1,5 +1,11 @@
# zhi-cmd
+## 0.2.0
+
+### Minor Changes
+
+- feat: add json validate and version
+
## 0.1.1
### Patch Changes
diff --git a/libs/zhi-cmd/package.json b/libs/zhi-cmd/package.json
index 4f43fdc3..c3be12bf 100644
--- a/libs/zhi-cmd/package.json
+++ b/libs/zhi-cmd/package.json
@@ -1,9 +1,9 @@
{
"name": "zhi-cmd",
- "version": "0.1.1",
+ "version": "0.2.0",
"type": "module",
"description": "commond utils for siyuan-note",
- "main": "./dist/index.js",
+ "main": "./dist/index.cjs",
"typings": "./dist/index.d.ts",
"repository": "terwer/zhi",
"homepage": "https://github.com/terwer/zhi/tree/main/apps/zhi-cmd",
diff --git a/libs/zhi-common-json-validate/.eslintrc.cjs b/libs/zhi-common-json-validate/.eslintrc.cjs
new file mode 100644
index 00000000..a1993b7b
--- /dev/null
+++ b/libs/zhi-common-json-validate/.eslintrc.cjs
@@ -0,0 +1,4 @@
+module.exports = {
+ root: true,
+ extends: ["./node_modules/@terwer/eslint-config-custom/typescript/index.cjs"],
+}
diff --git a/libs/zhi-common-json-validate/.gitignore b/libs/zhi-common-json-validate/.gitignore
new file mode 100644
index 00000000..1f1025f2
--- /dev/null
+++ b/libs/zhi-common-json-validate/.gitignore
@@ -0,0 +1,2 @@
+.idea
+.DS_Store
\ No newline at end of file
diff --git a/libs/zhi-common-json-validate/.prettierignore b/libs/zhi-common-json-validate/.prettierignore
new file mode 100644
index 00000000..8f9d2dfa
--- /dev/null
+++ b/libs/zhi-common-json-validate/.prettierignore
@@ -0,0 +1,11 @@
+# platform
+
+# Ignore artifacts:
+dist
+node_modules
+
+# Ignore all dts files:
+*.d.ts
+
+# lib
+/pnpm-lock.yaml
diff --git a/libs/zhi-common-json-validate/.prettierrc.cjs b/libs/zhi-common-json-validate/.prettierrc.cjs
new file mode 100644
index 00000000..eec8622f
--- /dev/null
+++ b/libs/zhi-common-json-validate/.prettierrc.cjs
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2023, Terwer . All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Terwer designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Terwer in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
+ * or visit www.terwer.space if you need additional information or have any
+ * questions.
+ */
+
+module.exports = {
+ semi: false,
+ singleQuote: false,
+ printWidth: 120
+}
diff --git a/libs/zhi-common-json-validate/CHANGELOG.md b/libs/zhi-common-json-validate/CHANGELOG.md
new file mode 100644
index 00000000..9da69ee3
--- /dev/null
+++ b/libs/zhi-common-json-validate/CHANGELOG.md
@@ -0,0 +1,7 @@
+# zhi-common-json-validate
+
+## 0.1.0
+
+### Minor Changes
+
+- feat: add json validate and version
diff --git a/libs/zhi-common-json-validate/README.md b/libs/zhi-common-json-validate/README.md
new file mode 100644
index 00000000..77a0cfc2
--- /dev/null
+++ b/libs/zhi-common-json-validate/README.md
@@ -0,0 +1,41 @@
+# zhi-common-json-validate
+
+utilized for the execution of json schema validation
+
+## Usage
+
+```js
+// usage
+```
+
+## Deps
+
+```
+## Congregations! zhi-common-json-validate need no deps, it is just pure js code 🎉
+```
+
+## Dev
+
+```bash
+pnpm dev -F zhi-common-json-validate
+```
+
+## Build
+
+```bash
+pnpm build -F zhi-common-json-validate
+```
+
+## Test
+
+Execute the unit tests via [vitest](https://vitest.dev)
+
+```bash
+pnpm test -F zhi-common-json-validate
+```
+
+## Publish
+
+```bash
+pnpm publish -F zhi-common-json-validate --tag latest
+```
\ No newline at end of file
diff --git a/libs/zhi-common-json-validate/index.html b/libs/zhi-common-json-validate/index.html
new file mode 100644
index 00000000..9ecb5ed8
--- /dev/null
+++ b/libs/zhi-common-json-validate/index.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+ Vite + Vue + TS
+
+
+ This file is for lib hot-load test only, see /src/index.ts
+
+
+
diff --git a/libs/zhi-common-json-validate/package.json b/libs/zhi-common-json-validate/package.json
new file mode 100644
index 00000000..5d8f6a91
--- /dev/null
+++ b/libs/zhi-common-json-validate/package.json
@@ -0,0 +1,37 @@
+{
+ "name": "zhi-common-json-validate",
+ "version": "0.1.0",
+ "type": "module",
+ "description": "utilized for the execution of json schema validation",
+ "main": "./dist/index.cjs",
+ "typings": "./dist/index.d.ts",
+ "repository": "terwer/zhi",
+ "homepage": "https://github.com/terwer/zhi/tree/main/libs/zhi-common-json-validate",
+ "author": "terwer",
+ "license": "MIT",
+ "files": [
+ "dist",
+ "README.md"
+ ],
+ "keywords": [
+ "zhi",
+ "lib"
+ ],
+ "scripts": {
+ "serve": "vite",
+ "dev": "vite build --watch",
+ "build": "vite build",
+ "start": "vite preview",
+ "test": "npx vitest --watch"
+ },
+ "devDependencies": {
+ "@terwer/eslint-config-custom": "workspace:*",
+ "@terwer/vite-config-custom": "workspace:*"
+ },
+ "dependencies": {
+ "ajv": "^8.12.0"
+ },
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/libs/zhi-common-json-validate/src/index.spec.ts b/libs/zhi-common-json-validate/src/index.spec.ts
new file mode 100644
index 00000000..1bbf6edb
--- /dev/null
+++ b/libs/zhi-common-json-validate/src/index.spec.ts
@@ -0,0 +1,7 @@
+import { describe, it } from "vitest"
+
+describe("index", () => {
+ it("test index", () => {
+ console.log("hello")
+ })
+})
\ No newline at end of file
diff --git a/libs/zhi-common-json-validate/src/index.ts b/libs/zhi-common-json-validate/src/index.ts
new file mode 100644
index 00000000..067ea3a6
--- /dev/null
+++ b/libs/zhi-common-json-validate/src/index.ts
@@ -0,0 +1,2 @@
+import JsonValidateUtil from "./lib/jsonValidateUtil"
+export { JsonValidateUtil }
diff --git a/libs/zhi-common-json-validate/src/lib/jsonValidateUtil.ts b/libs/zhi-common-json-validate/src/lib/jsonValidateUtil.ts
new file mode 100644
index 00000000..39e42719
--- /dev/null
+++ b/libs/zhi-common-json-validate/src/lib/jsonValidateUtil.ts
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2023, Terwer . All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Terwer designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Terwer in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
+ * or visit www.terwer.space if you need additional information or have any
+ * questions.
+ */
+
+import Ajv, { JSONSchemaType } from "ajv"
+
+/**
+ * Json 验证相关
+ */
+class JsonValidateUtil {
+ private static ajv = new Ajv()
+ public static validateJson(schema: JSONSchemaType, data: T): { valid: boolean; error?: string } {
+ const valid = this.ajv.validate(schema, data)
+ if (valid) {
+ return { valid }
+ } else {
+ return { valid, error: this.ajv.errorsText() }
+ }
+ }
+
+ public static validateObjectSchema(schemaObject: object, dataObject: object): { valid: boolean; error?: string } {
+ const valid = this.ajv.validate(schemaObject, dataObject)
+ if (valid) {
+ return { valid }
+ } else {
+ return { valid, error: this.ajv.errorsText() }
+ }
+ }
+}
+
+export default JsonValidateUtil
diff --git a/libs/zhi-common-json-validate/tsconfig.json b/libs/zhi-common-json-validate/tsconfig.json
new file mode 100644
index 00000000..08cfe0c6
--- /dev/null
+++ b/libs/zhi-common-json-validate/tsconfig.json
@@ -0,0 +1,42 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "useDefineForClassFields": true,
+ "module": "ESNext",
+ "lib": [
+ "ES2020",
+ "DOM",
+ "DOM.Iterable"
+ ],
+ "skipLibCheck": true,
+ /* Bundler mode */
+ "moduleResolution": "Node",
+ // "allowImportingTsExtensions": true,
+ "allowSyntheticDefaultImports": true,
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "preserve",
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true,
+ "types": [
+ "node",
+ "vite/client"
+ ]
+ },
+ "include": [
+ "src/**/*.ts",
+ "src/**/*.d.ts",
+ "src/**/*.tsx",
+ "src/**/*.vue"
+ ],
+ "references": [
+ {
+ "path": "./tsconfig.node.json"
+ }
+ ],
+ "root": "."
+}
diff --git a/libs/zhi-common-json-validate/tsconfig.node.json b/libs/zhi-common-json-validate/tsconfig.node.json
new file mode 100644
index 00000000..7065ca9a
--- /dev/null
+++ b/libs/zhi-common-json-validate/tsconfig.node.json
@@ -0,0 +1,10 @@
+{
+ "compilerOptions": {
+ "composite": true,
+ "skipLibCheck": true,
+ "module": "ESNext",
+ "moduleResolution": "Node",
+ "allowSyntheticDefaultImports": true
+ },
+ "include": ["vite.config.ts"]
+}
diff --git a/libs/zhi-common-json-validate/vite.config.ts b/libs/zhi-common-json-validate/vite.config.ts
new file mode 100644
index 00000000..a4d689c5
--- /dev/null
+++ b/libs/zhi-common-json-validate/vite.config.ts
@@ -0,0 +1,68 @@
+///
+
+import { resolve } from "path"
+import { defineConfig } from "vite"
+import { viteStaticCopy } from "vite-plugin-static-copy"
+import dts from "vite-plugin-dts"
+import minimist from "minimist"
+import livereload from "rollup-plugin-livereload"
+
+const args = minimist(process.argv.slice(2))
+const isWatch = args.watch || args.w || false
+const devDistDir = "./dist"
+const distDir = isWatch ? devDistDir : "./dist"
+// const distDir = devDistDir
+
+console.log("isWatch=>", isWatch)
+console.log("distDir=>", distDir)
+
+export default defineConfig({
+ plugins: [
+ dts(),
+
+ viteStaticCopy({
+ targets: [
+ {
+ src: "README.md",
+ dest: "./",
+ },
+ {
+ src: "package.json",
+ dest: "./",
+ },
+ ],
+ }),
+ ],
+
+ build: {
+ // 输出路径
+ outDir: distDir,
+ emptyOutDir: false,
+
+ // 构建后是否生成 source map 文件
+ sourcemap: false,
+
+ lib: {
+ // Could also be a dictionary or array of multiple entry points
+ entry: resolve(__dirname, "src/index.ts"),
+ // the proper extensions will be added
+ fileName: "index",
+ formats: ["cjs"],
+ },
+ rollupOptions: {
+ plugins: [...(isWatch ? [livereload(devDistDir)] : [])],
+ // make sure to externalize deps that shouldn't be bundled
+ // into your library
+ external: [],
+ output: {
+ entryFileNames: "[name].cjs",
+ },
+ },
+ },
+
+ test: {
+ globals: true,
+ environment: "jsdom",
+ include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
+ },
+} as any)
diff --git a/libs/zhi-common-version/.eslintrc.cjs b/libs/zhi-common-version/.eslintrc.cjs
new file mode 100644
index 00000000..a1993b7b
--- /dev/null
+++ b/libs/zhi-common-version/.eslintrc.cjs
@@ -0,0 +1,4 @@
+module.exports = {
+ root: true,
+ extends: ["./node_modules/@terwer/eslint-config-custom/typescript/index.cjs"],
+}
diff --git a/libs/zhi-common-version/.gitignore b/libs/zhi-common-version/.gitignore
new file mode 100644
index 00000000..1f1025f2
--- /dev/null
+++ b/libs/zhi-common-version/.gitignore
@@ -0,0 +1,2 @@
+.idea
+.DS_Store
\ No newline at end of file
diff --git a/libs/zhi-common-version/.prettierignore b/libs/zhi-common-version/.prettierignore
new file mode 100644
index 00000000..8f9d2dfa
--- /dev/null
+++ b/libs/zhi-common-version/.prettierignore
@@ -0,0 +1,11 @@
+# platform
+
+# Ignore artifacts:
+dist
+node_modules
+
+# Ignore all dts files:
+*.d.ts
+
+# lib
+/pnpm-lock.yaml
diff --git a/libs/zhi-common-version/.prettierrc.cjs b/libs/zhi-common-version/.prettierrc.cjs
new file mode 100644
index 00000000..eec8622f
--- /dev/null
+++ b/libs/zhi-common-version/.prettierrc.cjs
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2023, Terwer . All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Terwer designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Terwer in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
+ * or visit www.terwer.space if you need additional information or have any
+ * questions.
+ */
+
+module.exports = {
+ semi: false,
+ singleQuote: false,
+ printWidth: 120
+}
diff --git a/libs/zhi-common-version/CHANGELOG.md b/libs/zhi-common-version/CHANGELOG.md
new file mode 100644
index 00000000..ae15b1c0
--- /dev/null
+++ b/libs/zhi-common-version/CHANGELOG.md
@@ -0,0 +1,7 @@
+# zhi-common-version
+
+## 0.1.0
+
+### Minor Changes
+
+- feat: add json validate and version
diff --git a/libs/zhi-common-version/README.md b/libs/zhi-common-version/README.md
new file mode 100644
index 00000000..35e4d301
--- /dev/null
+++ b/libs/zhi-common-version/README.md
@@ -0,0 +1,41 @@
+# zhi-common-version
+
+comparison and computation pertaining to version related aspects
+
+## Usage
+
+```js
+// usage
+```
+
+## Deps
+
+```
+## Congregations! zhi-common-version need no deps, it is just pure js code 🎉
+```
+
+## Dev
+
+```bash
+pnpm dev -F zhi-common-version
+```
+
+## Build
+
+```bash
+pnpm build -F zhi-common-version
+```
+
+## Test
+
+Execute the unit tests via [vitest](https://vitest.dev)
+
+```bash
+pnpm test -F zhi-common-version
+```
+
+## Publish
+
+```bash
+pnpm publish -F zhi-common-version --tag latest
+```
\ No newline at end of file
diff --git a/libs/zhi-common-version/index.html b/libs/zhi-common-version/index.html
new file mode 100644
index 00000000..9ecb5ed8
--- /dev/null
+++ b/libs/zhi-common-version/index.html
@@ -0,0 +1,12 @@
+
+
+
+
+
+ Vite + Vue + TS
+
+
+ This file is for lib hot-load test only, see /src/index.ts
+
+
+
diff --git a/libs/zhi-common-version/package.json b/libs/zhi-common-version/package.json
new file mode 100644
index 00000000..8b4af93e
--- /dev/null
+++ b/libs/zhi-common-version/package.json
@@ -0,0 +1,37 @@
+{
+ "name": "zhi-common-version",
+ "version": "0.1.0",
+ "type": "module",
+ "description": "comparison and computation pertaining to version related aspects",
+ "main": "./dist/index.cjs",
+ "typings": "./dist/index.d.ts",
+ "repository": "terwer/zhi",
+ "homepage": "https://github.com/terwer/zhi/tree/main/libs/zhi-common-version",
+ "author": "terwer",
+ "license": "MIT",
+ "files": [
+ "dist",
+ "README.md"
+ ],
+ "keywords": [
+ "zhi",
+ "lib"
+ ],
+ "scripts": {
+ "serve": "vite",
+ "dev": "vite build --watch",
+ "build": "vite build",
+ "start": "vite preview",
+ "test": "npx vitest --watch"
+ },
+ "devDependencies": {
+ "@terwer/eslint-config-custom": "workspace:*",
+ "@terwer/vite-config-custom": "workspace:*"
+ },
+ "dependencies": {
+ "compare-versions": "^6.1.0"
+ },
+ "publishConfig": {
+ "access": "public"
+ }
+}
diff --git a/libs/zhi-common-version/src/index.spec.ts b/libs/zhi-common-version/src/index.spec.ts
new file mode 100644
index 00000000..1bbf6edb
--- /dev/null
+++ b/libs/zhi-common-version/src/index.spec.ts
@@ -0,0 +1,7 @@
+import { describe, it } from "vitest"
+
+describe("index", () => {
+ it("test index", () => {
+ console.log("hello")
+ })
+})
\ No newline at end of file
diff --git a/libs/zhi-common-version/src/index.ts b/libs/zhi-common-version/src/index.ts
new file mode 100644
index 00000000..448be177
--- /dev/null
+++ b/libs/zhi-common-version/src/index.ts
@@ -0,0 +1,3 @@
+import VersionUtil from "./lib/versionUtil"
+
+export { VersionUtil }
diff --git a/libs/zhi-common-version/src/lib/versionUtil.ts b/libs/zhi-common-version/src/lib/versionUtil.ts
new file mode 100644
index 00000000..5aead486
--- /dev/null
+++ b/libs/zhi-common-version/src/lib/versionUtil.ts
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2023, Terwer . All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Terwer designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Terwer in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
+ * or visit www.terwer.space if you need additional information or have any
+ * questions.
+ */
+
+import { compareVersions } from "compare-versions"
+
+/**
+ * 版本比较相关
+ */
+class VersionUtil {
+ /**
+ * Compare [semver](https://semver.org/) version strings
+ * This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
+ *
+ * @param v1 - First version to compare
+ * @param v2 - Second version to compare
+ * @returns boolean true if v1 is higher than v2
+ */
+ public static greater(v1: string, v2: string): boolean {
+ return compareVersions(v1, v2) > 0
+ }
+
+ /**
+ * Compare [semver](https://semver.org/) version strings
+ * This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
+ *
+ * @param v1 - First version to compare
+ * @param v2 - Second version to compare
+ * @returns boolean true if v1 is equal to v2
+ */
+ public static equal(v1: string, v2: string): boolean {
+ return compareVersions(v1, v2) === 0
+ }
+
+ /**
+ * Compare [semver](https://semver.org/) version strings
+ * This library supports the full semver specification, including comparing versions with different number of digits like `1.0.0`, `1.0`, `1`, and pre-release versions like `1.0.0-alpha`.
+ *
+ * @param v1 - First version to compare
+ * @param v2 - Second version to compare
+ * @returns boolean true if v1 is lesser than v2
+ */
+ public static lesser(v1: string, v2: string): boolean {
+ return compareVersions(v1, v2) < 0
+ }
+}
+
+export default VersionUtil
diff --git a/libs/zhi-common-version/tsconfig.json b/libs/zhi-common-version/tsconfig.json
new file mode 100644
index 00000000..08cfe0c6
--- /dev/null
+++ b/libs/zhi-common-version/tsconfig.json
@@ -0,0 +1,42 @@
+{
+ "compilerOptions": {
+ "target": "ES2020",
+ "useDefineForClassFields": true,
+ "module": "ESNext",
+ "lib": [
+ "ES2020",
+ "DOM",
+ "DOM.Iterable"
+ ],
+ "skipLibCheck": true,
+ /* Bundler mode */
+ "moduleResolution": "Node",
+ // "allowImportingTsExtensions": true,
+ "allowSyntheticDefaultImports": true,
+ "resolveJsonModule": true,
+ "isolatedModules": true,
+ "noEmit": true,
+ "jsx": "preserve",
+ /* Linting */
+ "strict": true,
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noFallthroughCasesInSwitch": true,
+ "types": [
+ "node",
+ "vite/client"
+ ]
+ },
+ "include": [
+ "src/**/*.ts",
+ "src/**/*.d.ts",
+ "src/**/*.tsx",
+ "src/**/*.vue"
+ ],
+ "references": [
+ {
+ "path": "./tsconfig.node.json"
+ }
+ ],
+ "root": "."
+}
diff --git a/libs/zhi-common-version/tsconfig.node.json b/libs/zhi-common-version/tsconfig.node.json
new file mode 100644
index 00000000..7065ca9a
--- /dev/null
+++ b/libs/zhi-common-version/tsconfig.node.json
@@ -0,0 +1,10 @@
+{
+ "compilerOptions": {
+ "composite": true,
+ "skipLibCheck": true,
+ "module": "ESNext",
+ "moduleResolution": "Node",
+ "allowSyntheticDefaultImports": true
+ },
+ "include": ["vite.config.ts"]
+}
diff --git a/libs/zhi-common-version/vite.config.ts b/libs/zhi-common-version/vite.config.ts
new file mode 100644
index 00000000..a4d689c5
--- /dev/null
+++ b/libs/zhi-common-version/vite.config.ts
@@ -0,0 +1,68 @@
+///
+
+import { resolve } from "path"
+import { defineConfig } from "vite"
+import { viteStaticCopy } from "vite-plugin-static-copy"
+import dts from "vite-plugin-dts"
+import minimist from "minimist"
+import livereload from "rollup-plugin-livereload"
+
+const args = minimist(process.argv.slice(2))
+const isWatch = args.watch || args.w || false
+const devDistDir = "./dist"
+const distDir = isWatch ? devDistDir : "./dist"
+// const distDir = devDistDir
+
+console.log("isWatch=>", isWatch)
+console.log("distDir=>", distDir)
+
+export default defineConfig({
+ plugins: [
+ dts(),
+
+ viteStaticCopy({
+ targets: [
+ {
+ src: "README.md",
+ dest: "./",
+ },
+ {
+ src: "package.json",
+ dest: "./",
+ },
+ ],
+ }),
+ ],
+
+ build: {
+ // 输出路径
+ outDir: distDir,
+ emptyOutDir: false,
+
+ // 构建后是否生成 source map 文件
+ sourcemap: false,
+
+ lib: {
+ // Could also be a dictionary or array of multiple entry points
+ entry: resolve(__dirname, "src/index.ts"),
+ // the proper extensions will be added
+ fileName: "index",
+ formats: ["cjs"],
+ },
+ rollupOptions: {
+ plugins: [...(isWatch ? [livereload(devDistDir)] : [])],
+ // make sure to externalize deps that shouldn't be bundled
+ // into your library
+ external: [],
+ output: {
+ entryFileNames: "[name].cjs",
+ },
+ },
+ },
+
+ test: {
+ globals: true,
+ environment: "jsdom",
+ include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
+ },
+} as any)
diff --git a/libs/zhi-infra/CHANGELOG.md b/libs/zhi-infra/CHANGELOG.md
index 62f2e4ad..c595353b 100644
--- a/libs/zhi-infra/CHANGELOG.md
+++ b/libs/zhi-infra/CHANGELOG.md
@@ -1,5 +1,11 @@
# zhi-infra
+## 0.2.0
+
+### Minor Changes
+
+- feat: add json validate and version
+
## 0.1.2
### Patch Changes
diff --git a/libs/zhi-infra/package.json b/libs/zhi-infra/package.json
index b902da1e..073d69ae 100644
--- a/libs/zhi-infra/package.json
+++ b/libs/zhi-infra/package.json
@@ -1,9 +1,9 @@
{
"name": "zhi-infra",
- "version": "0.1.2",
+ "version": "0.2.0",
"type": "module",
"description": "basic issues for zhi",
- "main": "./dist/index.js",
+ "main": "./dist/index.cjs",
"typings": "./dist/index.d.ts",
"repository": "terwer/zhi",
"homepage": "https://github.com/terwer/zhi/tree/main/apps/zhi-server-infra",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 7f1b89ed..8af2aa75 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -146,6 +146,19 @@ importers:
specifier: ^4.0.5
version: 4.0.5
+ libs/zhi-common-json-validate:
+ dependencies:
+ ajv:
+ specifier: ^8.12.0
+ version: 8.12.0
+ devDependencies:
+ '@terwer/eslint-config-custom':
+ specifier: workspace:*
+ version: link:../../tools/eslint-config-custom
+ '@terwer/vite-config-custom':
+ specifier: workspace:*
+ version: link:../../tools/vite-config-custom
+
libs/zhi-common-markdown:
dependencies:
showdown:
@@ -165,6 +178,19 @@ importers:
specifier: ^2.0.1
version: 2.0.1
+ libs/zhi-common-version:
+ dependencies:
+ compare-versions:
+ specifier: ^6.1.0
+ version: 6.1.0
+ devDependencies:
+ '@terwer/eslint-config-custom':
+ specifier: workspace:*
+ version: link:../../tools/eslint-config-custom
+ '@terwer/vite-config-custom':
+ specifier: workspace:*
+ version: link:../../tools/vite-config-custom
+
libs/zhi-device:
devDependencies:
'@terwer/eslint-config-custom':
@@ -4679,6 +4705,10 @@ packages:
array-ify: 1.0.0
dot-prop: 5.3.0
+ /compare-versions@6.1.0:
+ resolution: {integrity: sha512-LNZQXhqUvqUTotpZ00qLSaify3b4VFD588aRr8MKFw4CMUr98ytzCW5wDH5qx/DEY5kCDXcbcRuCqL0szEf2tg==}
+ dev: false
+
/concat-map@0.0.1:
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}