Skip to content

Commit

Permalink
Merge pull request #297 from terwer/dev
Browse files Browse the repository at this point in the history
feat: add picgo siyuan lib
  • Loading branch information
terwer committed Mar 14, 2024
2 parents 86aee84 + c21177b commit 8e47dde
Show file tree
Hide file tree
Showing 21 changed files with 1,152 additions and 4 deletions.
4 changes: 4 additions & 0 deletions libs/zhi-picgo-siyuan/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: ["./node_modules/@terwer/eslint-config-custom/typescript/index.cjs"],
}
2 changes: 2 additions & 0 deletions libs/zhi-picgo-siyuan/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
.DS_Store
11 changes: 11 additions & 0 deletions libs/zhi-picgo-siyuan/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# platform

# Ignore artifacts:
dist
node_modules

# Ignore all dts files:
*.d.ts

# lib
/pnpm-lock.yaml
30 changes: 30 additions & 0 deletions libs/zhi-picgo-siyuan/.prettierrc.cjs
Original file line number Diff line number Diff line change
@@ -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
}
41 changes: 41 additions & 0 deletions libs/zhi-picgo-siyuan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# zhi-picgo-siyuan

picgo lib for siyuan-note

## Usage

```js
// usage
```

## Deps

```
## Congregations! zhi-picgo-siyuan need no deps, it is just pure js code 🎉
```

## Dev

```bash
pnpm dev -F zhi-picgo-siyuan
```

## Build

```bash
pnpm build -F zhi-picgo-siyuan
```

## Test

Execute the unit tests via [vitest](https://vitest.dev)

```bash
pnpm test -F zhi-picgo-siyuan
```

## Publish

```bash
pnpm publish -F zhi-picgo-siyuan --tag latest
```
41 changes: 41 additions & 0 deletions libs/zhi-picgo-siyuan/dist/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# zhi-picgo-siyuan

picgo lib for siyuan-note

## Usage

```js
// usage
```

## Deps

```
## Congregations! zhi-picgo-siyuan need no deps, it is just pure js code 🎉
```

## Dev

```bash
pnpm dev -F zhi-picgo-siyuan
```

## Build

```bash
pnpm build -F zhi-picgo-siyuan
```

## Test

Execute the unit tests via [vitest](https://vitest.dev)

```bash
pnpm test -F zhi-picgo-siyuan
```

## Publish

```bash
pnpm publish -F zhi-picgo-siyuan --tag latest
```
8 changes: 8 additions & 0 deletions libs/zhi-picgo-siyuan/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { MainFunction } from "zhi-lib-base";
/**
* 初始化入口
*
* @param args
*/
declare const main: MainFunction;
export default main;
1 change: 1 addition & 0 deletions libs/zhi-picgo-siyuan/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions libs/zhi-picgo-siyuan/dist/index.spec.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {};
37 changes: 37 additions & 0 deletions libs/zhi-picgo-siyuan/dist/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "zhi-picgo-siyuan",
"version": "1.5.1",
"type": "module",
"description": "picgo lib for siyuan-note",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"repository": "terwer/zhi",
"homepage": "https://github.com/terwer/zhi/tree/main/libs/zhi-picgo-siyuan",
"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": "^1.3.6",
"@terwer/vite-config-custom": "^0.7.6"
},
"dependencies": {
"zhi-lib-base": "^0.8.0"
},
"publishConfig": {
"access": "public"
}
}
12 changes: 12 additions & 0 deletions libs/zhi-picgo-siyuan/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
</head>
<body>
This file is for lib hot load test only, see <a href="/src/index.ts">/src/index.ts</a>
<script type="module" src="/src/index.ts"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions libs/zhi-picgo-siyuan/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "zhi-picgo-siyuan",
"version": "1.5.1",
"type": "module",
"description": "picgo lib for siyuan-note",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"repository": "terwer/zhi",
"homepage": "https://github.com/terwer/zhi/tree/main/libs/zhi-picgo-siyuan",
"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": "^1.3.6",
"@terwer/vite-config-custom": "^0.7.6"
},
"dependencies": {
"zhi-lib-base": "^0.8.0"
},
"publishConfig": {
"access": "public"
}
}
7 changes: 7 additions & 0 deletions libs/zhi-picgo-siyuan/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, it } from "vitest"

describe("index", () => {
it("test index", () => {
console.log("hello")
})
})
14 changes: 14 additions & 0 deletions libs/zhi-picgo-siyuan/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { simpleLogger, MainFunction } from "zhi-lib-base"

/**
* 初始化入口
*
* @param args
*/
const main: MainFunction = async (args: any[]) => {
const logger = simpleLogger("main", "zhi", false)
logger.info(`main start ${args}`)
return "ok"
}

export default main
42 changes: 42 additions & 0 deletions libs/zhi-picgo-siyuan/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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": "."
}
10 changes: 10 additions & 0 deletions libs/zhi-picgo-siyuan/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
68 changes: 68 additions & 0 deletions libs/zhi-picgo-siyuan/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/// <reference types="vitest" />

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].js",
},
},
},

test: {
globals: true,
environment: "jsdom",
include: ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
},
})
5 changes: 3 additions & 2 deletions packages/picgo-plugin-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"vue-i18n": "^9.10.1",
"vue-router": "^4.3.0",
"zhi-common": "^1.31.0",
"zhi-lib-base": "^0.8.0"
"zhi-lib-base": "^0.8.0",
"zhi-picgo-siyuan": "workspace:*"
}
}
}

0 comments on commit 8e47dde

Please sign in to comment.