Skip to content

Commit

Permalink
chore: 使用 zhi-cli 重构项目
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Mar 9, 2023
1 parent 2e61cfe commit de3518c
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ theme.css
theme.js
vendor
zhi.js
dist-cjs
dist-cjs
*.d.ts
*.map
2 changes: 2 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import { build } from "vite"
import path from "path"
import dts from "vite-plugin-dts"

// libraries
const libraries = [
Expand All @@ -46,6 +47,7 @@ const libraries = [
for (const libItem of libraries) {
await build({
configFile: false,
plugins: [dts()],
resolve: {
alias: [
{
Expand Down
2 changes: 1 addition & 1 deletion config/api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
*/
"mainEntryPointFilePath": "<projectFolder>/lib/src/index.d.ts",
"mainEntryPointFilePath": "<projectFolder>/theme.d.ts",

/**
* A list of NPM package names whose exports should be treated as part of this package.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"ts-node": "^10.9.1",
"typescript": "^4.9.5",
"vite": "^4.1.4",
"vite-plugin-dts": "^2.1.0",
"vitepress": "1.0.0-alpha.50",
"vitepress-plugin-autobar": "^1.0.8",
"vitest": "^0.29.2"
Expand Down
78 changes: 78 additions & 0 deletions pnpm-lock.yaml

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

10 changes: 0 additions & 10 deletions script/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,6 @@
scriptutils.rm_files("./src/**/*.js")
scriptutils.rm_files("./src/*.js")

if scriptutils.is_dir_empty("./lib/src"):
scriptutils.rm_folder("./lib/src")

# lib
scriptutils.rm_files("./lib/**/*.d.ts")
scriptutils.rm_files("./lib/*.d.ts")

scriptutils.rm_files("./lib/**/*.map")
scriptutils.rm_files("./lib/*.map")

# none default dts
scriptutils.rm_files("./typings/*alpha.d.ts")
scriptutils.rm_files("./typings/*beta.d.ts")
Expand Down
4 changes: 3 additions & 1 deletion src/apps/zhi/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import DependencyItem from "~/src/models/DependencyItem"
* @author terwer
* @since 1.0.0
*/
export class Bootstrap {
class Bootstrap {
private static lifecycle: Lifecycle

static {
Expand All @@ -47,3 +47,5 @@ export class Bootstrap {
return Promise.resolve(Bootstrap.lifecycle.dynamicImports)
}
}

export default Bootstrap
2 changes: 1 addition & 1 deletion src/apps/zhi/zhi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import ThemeFromEnum from "~/src/enums/themeFromEnum"
import strUtil from "~/src/utils/strUtil"
import DependencyItem from "~/src/models/DependencyItem"
import ZhiUtil from "~/src/utils/ZhiUtil"
import { Bootstrap } from "~/src/apps/zhi/bootstrap"
import Bootstrap from "~/src/apps/zhi/bootstrap"

/**
* 主题入口
Expand Down
4 changes: 4 additions & 0 deletions theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import Zhi from "~/src/apps/zhi/zhi"
import ZhiUtil from "~/src/utils/ZhiUtil"
import siyuanUtil from "~/src/utils/siyuanUtil"
import Bootstrap from "~/src/apps/zhi/bootstrap"
import Lifecycle from "~/src/apps/zhi/Lifecycle"
import DependencyItem from "~/src/models/DependencyItem"

// 特别提醒1⚠️:此文件是主题的唯一入口,会在构建时自动生成js文件
// 特别提醒2⚠️:该文件由思源笔记自动加载,请勿主动调用此文件中的任何方法
Expand Down Expand Up @@ -88,3 +91,4 @@ class Theme {
})()

export default Theme
export { Bootstrap, Lifecycle, DependencyItem }
3 changes: 2 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@

import path from "path"
import { defineConfig } from "vite"
import dts from "vite-plugin-dts"

export default defineConfig({
plugins: [],
plugins: [dts()],
resolve: {
alias: [
{
Expand Down

0 comments on commit de3518c

Please sign in to comment.