Skip to content

Commit

Permalink
feat: 抽取代码到zhi-sdk-抽取公共模块
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Mar 12, 2023
1 parent 43c35ff commit 825a826
Show file tree
Hide file tree
Showing 59 changed files with 9,735 additions and 1,140 deletions.
File renamed without changes.
6 changes: 1 addition & 5 deletions apps/blog/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import eslint from "vite-plugin-eslint"

const isDev = process.env.NODE_ENV === "development"
const appBase = isDev ? "/" : "/appearance/themes/zhi/apps/blog/dist/"
console.log("isDev=>", isDev)
Expand All @@ -12,9 +10,7 @@ export default defineNuxtConfig({
strict: true,
typeCheck: true,
},
vite: {
plugins: [eslint()],
},
vite: {},
app: {
baseURL: appBase,
},
Expand Down
8 changes: 2 additions & 6 deletions apps/blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"version": "1.0.0",
"description": "zhi blog module",
"scripts": {
"watch:css": "stylus --watch app.styl --out ./public/app.css",
"watch:css": "stylus --watch blog.styl --out ./public/blog.css",
"build": "pnpm build:css && pnpm build:js",
"build:css": "stylus --compress app.styl --out ./public/app.css",
"build:css": "stylus --compress blog.styl --out ./public/blog.css",
"build:js": "nuxt build",
"dev": "pnpm build:css && nuxt dev",
"generate": "pnpm build:css && nuxt generate",
Expand All @@ -29,12 +29,8 @@
"stylelint-stylus": "^0.18.0",
"stylus": "^0.59.0",
"typescript": "^4.9.5",
"vite-plugin-eslint": "^1.8.1",
"vue-tsc": "^1.2.0"
},
"dependencies": {
"zhi-sdk": "^1.0.8"
},
"keywords": [
"zhi",
"blog"
Expand Down
6 changes: 3 additions & 3 deletions apps/blog/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</template>

<script lang="ts" setup>
import ZhiUtil from "~/utils/ZhiUtil"
import ZhiUtil from "../../common"
import { version } from "~/package.json"
import ThemeFromEnum from "~/enums/themeFromEnum"
import { ThemeFromEnum } from "../../common"
const zhiSdk = ZhiUtil.zhiSdk()
const logger = zhiSdk.getLogger()
Expand All @@ -18,5 +18,5 @@ function hello(from: string): void {
logger.info(common.strUtil.f("Hello, {0} {1} v{2}! You are from {3}", "zhi", "theme", version, from))
}
hello(ThemeFromEnum.ThemeFrom_Siyuan)
hello(ThemeFromEnum.ThemeFrom_Blog)
</script>
76 changes: 0 additions & 76 deletions apps/blog/pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions apps/blog/public/blog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
body{background:#00f;font-size:14px}
31 changes: 31 additions & 0 deletions apps/common/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
root: true,

env: {
browser: true,
node: true,
es2021: true,
},

parser: "vue-eslint-parser",

parserOptions: {
ecmaVersion: 12,
sourceType: "module",
tsconfigRootDir: __dirname,
parser: "@typescript-eslint/parser",
project: ["./tsconfig.json"],
extraFileExtensions: [".vue"],
},

plugins: ["@typescript-eslint", "prettier"],

extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"],

rules: {
// Note: you must disable the base rule as it can report incorrect errors
semi: "off",
quotes: "off",
"prettier/prettier": "error",
},
}
1 change: 1 addition & 0 deletions apps/common/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.json linguist-language=JSON-with-Comments
32 changes: 32 additions & 0 deletions apps/common/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
version: 2
updates:
# Fetch and update latest `npm` packages
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
time: "00:00"
open-pull-requests-limit: 10
reviewers:
- terwer
assignees:
- terwer
commit-message:
prefix: fix
prefix-development: chore
include: scope
# Fetch and update latest `github-actions` pkgs
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: "00:00"
open-pull-requests-limit: 10
reviewers:
- terwer
assignees:
- terwer
commit-message:
prefix: fix
prefix-development: chore
include: scope
48 changes: 48 additions & 0 deletions apps/common/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: ci

on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 7
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies and build for production
run: pnpm ci
38 changes: 38 additions & 0 deletions apps/common/.github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
push:
branches:
- main
name: release-please
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
package-name: release-please-action
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]'

# Checkout
- uses: actions/checkout@v3
if: ${{ steps.release.outputs.release_created }}
# Setup node
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: "https://registry.npmjs.org"
if: ${{ steps.release.outputs.release_created }}
# Setup pnpm
- uses: pnpm/action-setup@v2
with:
version: 7.29.0
if: ${{ steps.release.outputs.release_created }}
# Install dependencies
- run: pnpm package
if: ${{ steps.release.outputs.release_created }}
# Publish to npm
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: ${{ steps.release.outputs.release_created }}
30 changes: 30 additions & 0 deletions apps/common/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# JetBrains
.idea

# Node
node_modules
lib
typings
vite*.mjs

# Docs
etc
temp

# scripts
script/__pycache__
script/venv

# Vite
coverage
.env
*.local

# Vercel
.vercel
docs/.vitepress/dist
docs/.vitepress/cache
docs/doc

# Mac
.DS_Store
Loading

0 comments on commit 825a826

Please sign in to comment.