-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
500 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# zhi-blog-api | ||
|
||
a common blog interface | ||
|
||
## Building | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
Run `nx build zhi-blog-api` to build the library. | ||
|
||
## Running unit tests | ||
|
||
Run `nx test zhi-blog-api` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "zhi-blog-api", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"description": "a common blog interface", | ||
"repository": "terwer/zhi", | ||
"homepage": "https://terwer.space", | ||
"author": "terwer", | ||
"license": "GPL", | ||
"keywords": [ | ||
"zhi-blog-api", | ||
"zhi", | ||
"blog", | ||
"api", | ||
"blog-api" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "zhi-blog-api", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/zhi-blog-api/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nrwl/vite:build", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/packages/zhi-blog-api" | ||
} | ||
}, | ||
"publish": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "node tools/scripts/publish.mjs zhi-blog-api {args.ver} {args.tag}" | ||
}, | ||
"dependsOn": ["build"] | ||
}, | ||
"test": { | ||
"executor": "@nrwl/vite:test", | ||
"outputs": ["coverage/packages/zhi-blog-api"], | ||
"options": { | ||
"passWithNoTests": true, | ||
"reportsDirectory": "../../coverage/packages/zhi-blog-api" | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nrwl/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["packages/zhi-blog-api/**/*.ts"] | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./lib/zhi-blog-api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { zhiBlogApi } from "./zhi-blog-api" | ||
|
||
describe("zhiBlogApi", () => { | ||
it("should work", () => { | ||
expect(zhiBlogApi()).toEqual("zhi-blog-api") | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function zhiBlogApi(): string { | ||
return "zhi-blog-api" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "esnext", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"types": ["vitest"] | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../dist/out-tsc", | ||
"types": ["vitest/globals", "vitest/importMeta", "vite/client", "node"] | ||
}, | ||
"include": [ | ||
"vite.config.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.test.tsx", | ||
"src/**/*.spec.tsx", | ||
"src/**/*.test.js", | ||
"src/**/*.spec.js", | ||
"src/**/*.test.jsx", | ||
"src/**/*.spec.jsx", | ||
"src/**/*.d.ts" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/// <reference types="vitest" /> | ||
import { defineConfig } from "vite" | ||
|
||
import viteTsConfigPaths from "vite-tsconfig-paths" | ||
import dts from "vite-plugin-dts" | ||
import { join } from "path" | ||
|
||
export default defineConfig({ | ||
cacheDir: "../../node_modules/.vite/zhi-blog-api", | ||
|
||
plugins: [ | ||
dts({ | ||
entryRoot: "src", | ||
tsConfigFilePath: join(__dirname, "tsconfig.lib.json"), | ||
skipDiagnostics: true, | ||
}), | ||
|
||
viteTsConfigPaths({ | ||
root: "../../", | ||
}), | ||
], | ||
|
||
// Uncomment this if you are using workers. | ||
// worker: { | ||
// plugins: [ | ||
// viteTsConfigPaths({ | ||
// root: '../../', | ||
// }), | ||
// ], | ||
// }, | ||
|
||
// Configuration for building your library. | ||
// See: https://vitejs.dev/guide/build.html#library-mode | ||
build: { | ||
lib: { | ||
// Could also be a dictionary or array of multiple entry points. | ||
entry: "src/index.ts", | ||
name: "zhi-blog-api", | ||
fileName: "index", | ||
// Change this to the formats you want to support. | ||
// Don't forgot to update your package.json as well. | ||
formats: ["es", "cjs"], | ||
}, | ||
rollupOptions: { | ||
// External packages that should not be bundled into your library. | ||
external: [], | ||
}, | ||
}, | ||
|
||
test: { | ||
globals: true, | ||
cache: { | ||
dir: "../../node_modules/.vitest", | ||
}, | ||
environment: "jsdom", | ||
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"], | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"extends": ["../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# zhi-sdk | ||
|
||
a simple sdk for siyuan-note, blog, and more | ||
|
||
## Usage | ||
|
||
```bash | ||
pnpm add zhi-sdk | ||
``` | ||
|
||
```ts | ||
import ZhiSdk from "zhi-sdk" | ||
import Env from "zhi-env" | ||
|
||
// init zhiSdk | ||
const zhiSdk = new ZhiSdk() | ||
|
||
// init zhiSdk with env | ||
const env = new Env(import.meta.env) | ||
const zhiSdk = new ZhiSdk(env) | ||
|
||
// siyuanAPI | ||
const siyuanApi = zhiSdk.siyuanApi | ||
console.log(siyuanApi.serverApi.VERSION) | ||
console.log(siyuanApi.clientApi.VERSION) | ||
|
||
// blogApi | ||
const blogApi = zhiSdk.blogApi | ||
console.log(blogApi.VERSION) | ||
|
||
// common | ||
const msg = "message" | ||
const fmsg = zhiSdk.common.strUtil.f("This a {0}", msg) | ||
console.log(fmsg) | ||
``` | ||
|
||
## Deps | ||
|
||
``` | ||
├── zhi-log | ||
├── zhi-common | ||
├── zhi-blog-api | ||
├── zhi-siyuan-api | ||
``` | ||
|
||
## Architecture | ||
|
||
`zhi-sdk` consist a set of component apis, each component will have their own dependency trees | ||
|
||
- zhi-sdk | ||
- zhi-env | ||
- zhi-log | ||
- zhi-common | ||
- browserUtil | ||
- dateUtil | ||
- deviceUtil | ||
- electronUtil | ||
- strUtil | ||
- versionUtil | ||
- zhi-core | ||
- zhi-ui | ||
- zhi-middleware | ||
- zhi-siyuan-api | ||
- zhi-siyuan-server-api | ||
- zhi-siyuan-client-api | ||
- zhi-siyuan-util | ||
- zhi-blog-api | ||
- zhi-metaweblog-api | ||
- zhi-wordpress | ||
- zhi-cnblogs | ||
- zhi-common-blog-api | ||
- zhi-yuque | ||
- zhi-http-custom-api | ||
- zhi-blog-zhihu | ||
- zhi-blog-csdn | ||
|
||
## Building | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
Run `nx build zhi-sdk` to build the library. | ||
|
||
## Running unit tests | ||
|
||
Run `nx test zhi-sdk` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "zhi-sdk", | ||
"version": "1.3.0", | ||
"type": "module", | ||
"description": "a simple sdk for siyuan-note, blog, and more", | ||
"repository": "terwer/zhi", | ||
"homepage": "https://terwer.space", | ||
"author": "terwer", | ||
"license": "GPL", | ||
"keywords": [ | ||
"zhi-sdk", | ||
"zhi", | ||
"sdk", | ||
"siyuan-note", | ||
"blog" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "zhi-sdk", | ||
"$schema": "../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "packages/zhi-sdk/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nrwl/vite:build", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/packages/zhi-sdk" | ||
} | ||
}, | ||
"publish": { | ||
"executor": "nx:run-commands", | ||
"options": { | ||
"command": "node tools/scripts/publish.mjs zhi-sdk {args.ver} {args.tag}" | ||
}, | ||
"dependsOn": ["build"] | ||
}, | ||
"test": { | ||
"executor": "@nrwl/vite:test", | ||
"outputs": ["coverage/packages/zhi-sdk"], | ||
"options": { | ||
"passWithNoTests": true, | ||
"reportsDirectory": "../../coverage/packages/zhi-sdk" | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nrwl/linter:eslint", | ||
"outputs": ["{options.outputFile}"], | ||
"options": { | ||
"lintFilePatterns": ["packages/zhi-sdk/**/*.ts"] | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./lib/zhi-sdk" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { zhiSdk } from "./zhi-sdk" | ||
|
||
describe("zhiSdk", () => { | ||
it("should work", () => { | ||
expect(zhiSdk()).toEqual("zhi-sdk") | ||
}) | ||
}) |
Oops, something went wrong.