Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/Tencent/cherry-markdown into…
Browse files Browse the repository at this point in the history
… feat/571
  • Loading branch information
ufec committed Jul 6, 2024
2 parents 9176a4b + ea24b9d commit b90330e
Show file tree
Hide file tree
Showing 44 changed files with 626 additions and 60 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/pr-reviewer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: PR Reviewer

on: workflow_call

jobs:
review:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Print PR details
run: |
echo "The PR ID is ${{ github.event.pull_request.id }}"
echo "The PR number is ${{ github.event.pull_request.number }}"
echo "The PR title is ${{ github.event.pull_request.title }}"
echo "The PR branch is ${{ github.event.pull_request.head.ref }}"
- run: npm install cos-nodejs-sdk-v5

- name: Download build dist
uses: actions/download-artifact@v4
with:
name: build-dist
path: dist

- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: build-examples
path: examples

- name: Upload to COS
uses: actions/github-script@v7
with:
script: |
const COS = require('cos-nodejs-sdk-v5');
const fs = require('fs');
const path = require('path');
const cos = new COS({
SecretId: '${{ secrets.COS_SECRETID }}',
SecretKey: '${{ secrets.COS_SECRETKEY }}',
});
const uploadDirectory = (directoryPath, keyPrefix) => {
const uploadPromises = [];
const files = fs.readdirSync(directoryPath);
files.forEach(file => {
const filePath = path.join(directoryPath, file);
const key = `${keyPrefix}/${file}`;
if (fs.lstatSync(filePath).isDirectory()) {
uploadPromises.push(uploadDirectory(filePath, key));
} else {
uploadPromises.push(uploadFile(filePath, key));
}
});
return Promise.all(uploadPromises);
};
const uploadFile = (filePath, key) => {
return new Promise((resolve, reject) => {
cos.uploadFile({
Bucket: 'cherrymd-1301618266',
Region: 'ap-singapore',
Key: key,
FilePath: filePath,
SliceSize: 1024 * 1024 * 5, /* 触发分块上传的阈值,超过5MB使用分块上传,非必须 */
ContentDisposition: 'inline',
CacheControl: 'no-cache',
Headers: {
'Cache-control': 'no-cache',
'Content-Disposition': 'inline',
},
}, function(err, data) {
if (err) {
reject(err);
} else {
resolve(data);
}
});
});
};
(async () => {
try {
await uploadDirectory('dist', 'pr${{ github.event.pull_request.number }}/dist');
await uploadDirectory('examples', 'pr${{ github.event.pull_request.number }}/examples');
console.log('Upload success');
} catch (err) {
console.error('Upload failed:', err);
}
})();
- name: Add Comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.request('POST /repos/{owner}/{repo}/issues/{issue_number}/comments', {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: `
### 【预览链接】
- https://cherrymd.com/pr${{ github.event.pull_request.number }}/examples/index.html
`
});
85 changes: 85 additions & 0 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: PR Test

on:
pull_request_target:
branches: [main, dev]

jobs:
build:
runs-on: ubuntu-latest
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}

steps:
- uses: actions/checkout@v2
with:
ref: '${{ env.HEAD_SHA }}'

- name: Get changed files and operations
run: |
# 使用 GitHub API 获取变更文件列表及其操作
DIFF_DOCUMENTS=$(gh api repos/${{ github.repository }}/compare/${{ env.BASE_SHA }}...${{ env.HEAD_SHA }} \
--jq '.files | .[] | select(.status|IN("added", "modified", "renamed", "copied", "changed")) | .filename')
echo "Changed files and operations: ${DIFF_DOCUMENTS}"
# 忽略 .github/workflows 下的文件
GIT_DIFF_FILES=$(echo "${DIFF_DOCUMENTS}" | grep -vE '^\.github\/workflows\/.*' | xargs)
echo "GIT_DIFF_FILES=${GIT_DIFF_FILES}" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/checkout@v2
if: ${{ env.GIT_DIFF_FILES }}
with:
repository: ${{ github.repository }}
ref: '${{ env.BASE_SHA }}'
path: base-repo

- name: Replace changed files
if: ${{ env.GIT_DIFF_FILES }}
run: |
for file in ${{ env.GIT_DIFF_FILES }}; do
cp "$file" "base-repo/$file"
done
- name: Use Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: 16.x
cache: 'yarn'

- name: Install dependencies
uses: borales/actions-yarn@v3.0.0
with:
cmd: install

- name: Lint Changed Files
if: ${{ env.GIT_DIFF_FILES }}
run: |
for file in ${{ env.GIT_DIFF_FILES }}; do
yarn eslint "$file"
done
- name: Run Build
uses: borales/actions-yarn@v3.0.0
with:
cmd: build

- name: Archive build dist
uses: actions/upload-artifact@v4
with:
name: build-dist
path: dist

- name: Archive examples
uses: actions/upload-artifact@v4
with:
name: build-examples
path: examples

review:
needs: build
permissions: write-all
uses: ./.github/workflows/pr-reviewer.yml
secrets: inherit
4 changes: 2 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# . "$(dirname -- "$0")/_/husky.sh"

npx --no-install lint-staged
# npx --no-install lint-staged
34 changes: 34 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [0.8.44](https://github.com/Tencent/cherry-markdown/compare/v0.8.43...v0.8.44) (2024-06-25)

### Bug Fixes

* [#808](https://github.com/Tencent/cherry-markdown/issues/808) ([d63a4a0](https://github.com/Tencent/cherry-markdown/commit/d63a4a0228b19a759eee4870d821310c375ead3c))

### [0.8.43](https://github.com/Tencent/cherry-markdown/compare/v0.8.42...v0.8.43) (2024-06-24)


### Features

* [#696](https://github.com/Tencent/cherry-markdown/issues/696) 构建产物里额外提供预览区样式的文件 ([#783](https://github.com/Tencent/cherry-markdown/issues/783)) ([e33c0d6](https://github.com/Tencent/cherry-markdown/commit/e33c0d68bf5a5d2324d6a118a32f7372d5052d1f))
* [#767](https://github.com/Tencent/cherry-markdown/issues/767) 代码块、行内代码相关提示交互优化 ([#787](https://github.com/Tencent/cherry-markdown/issues/787)) ([4e05ac6](https://github.com/Tencent/cherry-markdown/commit/4e05ac696323c6dc6bd8d1961ab3adcbb44e7d92))
* [#769](https://github.com/Tencent/cherry-markdown/issues/769) 代码块主题缓存 ([#781](https://github.com/Tencent/cherry-markdown/issues/781)) ([912c25e](https://github.com/Tencent/cherry-markdown/commit/912c25e268a57bfd0c15f82de2c8b992db945ef7))
* [#774](https://github.com/Tencent/cherry-markdown/issues/774) 增加选区改变事件 selectionChange ([1859e20](https://github.com/Tencent/cherry-markdown/commit/1859e2080f908ee19f0aeb057631807ded5feded))
* [#790](https://github.com/Tencent/cherry-markdown/issues/790) 锚点/toc滚动兼容滚动条在window的情况 ([42be1bc](https://github.com/Tencent/cherry-markdown/commit/42be1bc8b2ee066acc5281f2907be4ab207dd26f))
* 独立一个markdown样式文件(含主题) ([467d870](https://github.com/Tencent/cherry-markdown/commit/467d87043ace777f05afd04958a982a358376a0f))
* 优化高亮区的显示逻辑,改成每次高亮只亮3秒,不再常驻高亮 ([6365f27](https://github.com/Tencent/cherry-markdown/commit/6365f27453949ab08db8fa7a55f8b406502bf6c4))
* 增加表格和加粗斜体语法对流式输出场景的适配 ([b1a07a7](https://github.com/Tencent/cherry-markdown/commit/b1a07a7f782c363d29d11681331a49bf5e318264))
* 增加流式会话的例子 ([0de1a93](https://github.com/Tencent/cherry-markdown/commit/0de1a9372dee6c336208a20cfda8c0900c1776f0))
* 增加一些小api ([e7bc008](https://github.com/Tencent/cherry-markdown/commit/e7bc0085f15a2b5c5255f0781240646a073bbbc0))


### Bug Fixes

* [#778](https://github.com/Tencent/cherry-markdown/issues/778) 修复国际化漏掉的地方 ([5bb2b26](https://github.com/Tencent/cherry-markdown/commit/5bb2b265193f5c0fe3a9f969a3d16f8c8ad13e94))
* [#782](https://github.com/Tencent/cherry-markdown/issues/782) 补上英文 ([d5e4d47](https://github.com/Tencent/cherry-markdown/commit/d5e4d470129a02ea580488959aae12b75f63808c))
* 修复afterInit失效的问题 ([8c03f95](https://github.com/Tencent/cherry-markdown/commit/8c03f959a93312ab8dcc0ae27b298d9a7f557bf3))
* 修复vscode插件自动打开预览的问题 ([036f070](https://github.com/Tencent/cherry-markdown/commit/036f070b3d0a724075366dbd3b1fe4f92d6154f7))
* 右侧编辑列表过程中, 输入回车后, 再次编辑此列表, 数据会异常 [#751](https://github.com/Tencent/cherry-markdown/issues/751) ([#772](https://github.com/Tencent/cherry-markdown/issues/772)) ([38ee8dc](https://github.com/Tencent/cherry-markdown/commit/38ee8dc21acece973946e5955dcf3b2c941d7401))
* 自定义icon兼容自定义菜单 & 完善propTypes校验 ([#791](https://github.com/Tencent/cherry-markdown/issues/791)) ([335b9bd](https://github.com/Tencent/cherry-markdown/commit/335b9bd6434d376ff0615695efdf39bd35df13f6)), closes [#589](https://github.com/Tencent/cherry-markdown/issues/589)
* **vscodePlugin:** activation timing for VSCode extension ([#773](https://github.com/Tencent/cherry-markdown/issues/773)) ([15e019f](https://github.com/Tencent/cherry-markdown/commit/15e019f0d2d210535207b4c372e5ebebb4a779e5))
* **vscodePlugin:** first open markdown will not activate the extension ([#784](https://github.com/Tencent/cherry-markdown/issues/784)) ([a1c24d2](https://github.com/Tencent/cherry-markdown/commit/a1c24d228f5d6510355f0264309f3251f8bd75f2))

### [0.8.42](https://github.com/Tencent/cherry-markdown/compare/v0.8.41...v0.8.42) (2024-05-27)


Expand Down
1 change: 1 addition & 0 deletions README.CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- [表格编辑](https://tencent.github.io/cherry-markdown/examples/table.html)
- [标题自动序号](https://tencent.github.io/cherry-markdown/examples/head_num.html)
- [流式输入模式(AI chart场景)](https://tencent.github.io/cherry-markdown/examples/ai_chat.html)
- [VIM 编辑模式](https://tencent.github.io/cherry-markdown/examples/vim.html)


-----
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ English | [简体中文](./README.CN.md)
- [table wysiwyg](https://tencent.github.io/cherry-markdown/examples/table.html)
- [headers with auto num](https://tencent.github.io/cherry-markdown/examples/head_num.html)
- [流式输入模式(AI chart场景)](https://tencent.github.io/cherry-markdown/examples/ai_chat.html)
- [VIM 编辑模式](https://tencent.github.io/cherry-markdown/examples/vim.html)

-----

Expand Down
Loading

0 comments on commit b90330e

Please sign in to comment.