Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Cross1111 authored Oct 11, 2024
2 parents db2f4fd + b0ea003 commit 6f8fc02
Show file tree
Hide file tree
Showing 93 changed files with 12,846 additions and 17,463 deletions.
197 changes: 197 additions & 0 deletions .github/workflows/pr-merge-dev-npm_preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
name: PR Merge Dev NPM Preview

# task:
# 1. 仅在主仓库中运行 (done)
# 2. 仅在pr合并时运行 (done)
# 3. 当pr合并时,获取pr合并后的commit id (done)
# 4. 根据commit id 修改package.json中的版本号和名称 (done)
# 5. 发布到npm (done)
# 6. 发布成功后,将发布的版本号和链接回复到当前pr下(done)
# 7. 发布成功后,将发布的版本号和链接回复到本repo的相关issue中 (done)
# 8. 修改README.md —— 提示dev版本需谨慎使用 (done)

on:
pull_request_target:
types:
- closed

permissions:
pull-requests: write
issues: write

jobs:
dev-deploy:
# 不需要在fork仓库的pr中运行, 仅当pr合并时运行
if: github.repository == 'Tencent/cherry-markdown' && github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
# 检出仓库代码
- name: Checkout repository
uses:
actions/checkout@v4

# 获取PR合并后的SHA
- name: Get merge commit SHA
run: |
if [ "${{ github.event.pull_request.merged }}" == "true" ]; then
SHORT_SHA=$(echo "${{ github.event.pull_request.merge_commit_sha }}" | cut -c1-7)
echo "MERGE_COMMIT_SHORT_SHA=$SHORT_SHA" >> "$GITHUB_ENV"
else
echo "Not a merged PR, skipping"
fi

# 根据commit id 修改package.json中的版本号和名称
- name: dev package version and name
run: |
if [ -f package.json ]; then
# 获取当前版本号并添加 merge commit SHA
VERSION=$(node -p "require('./package.json').version")-dev.${{ env.MERGE_COMMIT_SHORT_SHA }}
# 设置环境变量
echo "PACKAGE_VERSION=$VERSION" >> "$GITHUB_ENV"
package_name="@cherry-markdown-publisher/preview-dev"
echo "PACKAGE_NAME=$package_name" >> "$GITHUB_ENV"
# 打印当前版本号
echo "Current version: $PACKAGE_VERSION"
# 修改 package.json 中的 name 和 version,并检查 scripts 中是否存在 publish 属性,如果存在则移除
jq --arg package_name "$package_name" --arg package_version "$VERSION" '
.name=$package_name |
.version=$package_version |
if .scripts.publish then del(.scripts.publish) else . end
' package.json > temp.json && mv temp.json package.json
# 打印修改后的 name 和 version
echo "Updated package.json:"
cat package.json | jq '.name, .version'
echo "$PACKAGE_VERSION"
# 检查 scripts 中是否存在 publish 属性,如果存在则移除
if jq -e '.scripts.publish' package.json > /dev/null; then
jq 'del(.scripts.publish)' package.json > temp.json && mv temp.json package.json
fi
else
echo "package.json 文件不存在"
fi
# 重写或创建 README.md 文件
echo -e '<p align="center"><img src="logo/new_logo.png" alt="cherry logo" width="50%"/></p>\n' > README.md
echo -e '# Cherry Markdown Writer\n' >> README.md
echo -e '> !WARNING\n This is a dev preview version of `Cherry Markdown`, please use it with caution. No responsibility for production versions.\n' >> README.md
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "18"
registry-url: https://registry.npmjs.org/

- name: yarn install
run: |
npm i yarn -g
yarn install
- name: build
run: yarn build

- name: npm publish
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Comment on related issues
id: get-issues
uses: actions/github-script@v7
with:
result-encoding: string
retries: 3
retry-exempt-status-codes: 400,401
script: |
let issue_array =[context.issue.number];
// 添加issue到数组并去重
const addIssueToArray = (newIssues) => {
issue_array.push(...newIssues);
issue_array = [...new Set(issue_array)];
};
try {
// 获取pr的issue编号并且转换成数字数组
const getIssueRegex =(issueText)=>{
const issueRegex = /#(\d+)/g
return Array.from(issueText?.matchAll(issueRegex), match => parseInt(match[1], 10));
};
const comment = `谢谢您的大力支持,请安装和此相关的测试版进行极速体验:
\`\`\`shell
npm install ${process.env.PACKAGE_NAME}@${process.env.PACKAGE_VERSION}
\`\`\`
[查看npm发布版本](https://www.npmjs.com/package/${process.env.PACKAGE_NAME}/v/${process.env.PACKAGE_VERSION}),请注意这是一个开发预览版本,请谨慎使用!`;

// 发布评论到issue
const createComment= async (issueNumbers) => {
if(typeof value === 'number' && !isNaN(value)) return;
issueNumbers.forEach(async (issueNumber) => {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
body: comment
});
});
};

// 获取当前提交的pr信息[title,body]
const { data: pullCommits } =
await github.rest.pulls.get({
owner:context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
const pullCommitsIssueTitleNumbers = getIssueRegex(pullCommits.title);
addIssueToArray(pullCommitsIssueTitleNumbers);
const pullCommitsIssueBodyNumbers = getIssueRegex(pullCommits.body);
addIssueToArray(pullCommitsIssueBodyNumbers);

console.log('pullCommits-title',pullCommitsIssueTitleNumbers);
console.log('pullCommits-body',pullCommitsIssueBodyNumbers);

// 获取当前pr的issue信息[body]
const { data: listPrIssue } =
await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
listPrIssue.forEach((item) => {
const listPrIssueIssueNumbers = getIssueRegex(item.body);
addIssueToArray(listPrIssueIssueNumbers);

console.log('listPrIssue',item.body);
console.log('listPrIssue',listPrIssueIssueNumbers);
});

// 获取当前pr的 review 信息[body]
const { data: listReviewComments } =
await github.rest.pulls.listReviewComments({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
listReviewComments.forEach((item) => {
const listReviewCommentsIssueNumbers = getIssueRegex(item.body);
addIssueToArray(listReviewCommentsIssueNumbers);

console.log('listReviewComments',item.body);
console.log('listReviewComments',listReviewCommentsIssueNumbers);
});

createComment(issue_array);
}catch(error){
console.log('error',error);
}
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ jobs:
review:
needs: build
permissions: write-all
uses: ./.github/workflows/pr-reviewer.yml
uses: ./.github/workflows/pr-reviewer-COS.yml
secrets: inherit
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,9 @@ pnpm-lock.yaml
/docs/.vitepress/cache/
/docs/.vitepress/dist/


#vscodePlugin
/vscodePlugin/yarn.lock

# config
examples/cherry-markdown-publish/src/common/config/*.yaml
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,57 @@

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.49](https://github.com/Tencent/cherry-markdown/compare/v0.8.48...v0.8.49) (2024-09-27)


### Features

* [#927](https://github.com/Tencent/cherry-markdown/issues/927) 增加对html标签里style属性过滤的配置 ([858f862](https://github.com/Tencent/cherry-markdown/commit/858f86285da2c92a54cc05668629f1b14c691a61))
* 表格增加删除列操作 ([#843](https://github.com/Tencent/cherry-markdown/issues/843)) ([d8ed2ec](https://github.com/Tencent/cherry-markdown/commit/d8ed2ecb561c73b586799b022808a34d71ad0acc))
* 优化快捷键工具栏,增加不可修改的快捷键信息 ([93de3b1](https://github.com/Tencent/cherry-markdown/commit/93de3b136e7b1e518768cbce5d5e2975dd0369ca))


### Bug Fixes

* [#923](https://github.com/Tencent/cherry-markdown/issues/923) 支持多个括号 ([a3da98b](https://github.com/Tencent/cherry-markdown/commit/a3da98b994b72dc375f6040884f1bca876d766f0))
* [#925](https://github.com/Tencent/cherry-markdown/issues/925) 默认关掉codemirror对github特殊链接格式的支持 ([22d691b](https://github.com/Tencent/cherry-markdown/commit/22d691ba04af77e69770740098aadf0642535377))
* 增加ci脚本的鲁棒性 ([a9611d9](https://github.com/Tencent/cherry-markdown/commit/a9611d9ef5d3b62d740045bd256ac546e4227802))
* github-bot message npm version ([#918](https://github.com/Tencent/cherry-markdown/issues/918)) ([88e1a48](https://github.com/Tencent/cherry-markdown/commit/88e1a489a40882d4415f4e4c2e87021575d28b3a))
* rename npm-dev-test package ([#917](https://github.com/Tencent/cherry-markdown/issues/917)) ([40f7d6b](https://github.com/Tencent/cherry-markdown/commit/40f7d6b708e534a77441f86dbfa8374956ec4911))


### Code Refactoring

* 优化表格所见即所得编辑里,拖拽行列、删除行列的交互和功能 ([77bf4db](https://github.com/Tencent/cherry-markdown/commit/77bf4db26dbc6f05bacef9cda66afffbfa702216))


### Css or Code Change

* 优化配色 ([ed4d8f4](https://github.com/Tencent/cherry-markdown/commit/ed4d8f4cd90bd7005e88e1721fd43a55fdb602be))

### [0.8.48](https://github.com/Tencent/cherry-markdown/compare/v0.8.47...v0.8.48) (2024-09-23)


### Features

* [#900](https://github.com/Tencent/cherry-markdown/issues/900) “引用“语法支持嵌套,并支持嵌套其他语法(如表格、代码块、列表、信息面板等) ([d7a887d](https://github.com/Tencent/cherry-markdown/commit/d7a887dc8d8a4f70214d984b4fafea1fd6c88b44))
* [#900](https://github.com/Tencent/cherry-markdown/issues/900) “引用“语法支持嵌套,并支持嵌套其他语法(如表格、代码块、列表、信息面板等)fix lint ([9366d1e](https://github.com/Tencent/cherry-markdown/commit/9366d1eecb2107e93eb42eb38fab18407f3817ad))
* 支持设置编辑器的值 ([bcb1b23](https://github.com/Tencent/cherry-markdown/commit/bcb1b232bcfae5e06a651d1ce7e34f670b1a334c))


### Bug Fixes

* [#879](https://github.com/Tencent/cherry-markdown/issues/879) 修复脚注在滚动条在html时无法滚动的问题 ([ad1362a](https://github.com/Tencent/cherry-markdown/commit/ad1362ac8ab164182e3f849f75b1d6a7f39d586f))
* [#898](https://github.com/Tencent/cherry-markdown/issues/898) 修复配置代码块主题失效的问题 ([90f3c1d](https://github.com/Tencent/cherry-markdown/commit/90f3c1db578cc8cfa4305cb5e2537a7fc2033e81))
* [#898](https://github.com/Tencent/cherry-markdown/issues/898) 修复配置主题失效的问题 ([191206b](https://github.com/Tencent/cherry-markdown/commit/191206b965a4d6b1ebd6ac5867569aa786b24460))
* [#898](https://github.com/Tencent/cherry-markdown/issues/898) 修复配置主题失效的问题 ([afa5a7f](https://github.com/Tencent/cherry-markdown/commit/afa5a7f4bf9d5bc0dd420843673eba8f5a54dfe7))
* [#903](https://github.com/Tencent/cherry-markdown/issues/903) 修复联想功能引入的性能问题 ([fbf1f0c](https://github.com/Tencent/cherry-markdown/commit/fbf1f0cbf67f7a6ce41493428f928acd200a5271))
* [#910](https://github.com/Tencent/cherry-markdown/issues/910) 图片和超链接支持一对括号(时间有限,先只支持一对括号,再多的后续再考虑实现) ([e609e95](https://github.com/Tencent/cherry-markdown/commit/e609e95ef776ae831af629c9ffa479e6d7cdd88e))
* [#910](https://github.com/Tencent/cherry-markdown/issues/910) 图片和超链接支持一对括号(时间有限,先只支持一对括号,再多的后续再考虑实现) ([688b7eb](https://github.com/Tencent/cherry-markdown/commit/688b7ebe888730933bbb69824f5bb59cc95c520f))
* [#913](https://github.com/Tencent/cherry-markdown/issues/913) 文章目录支持国际化 ([#915](https://github.com/Tencent/cherry-markdown/issues/915)) ([52f01c9](https://github.com/Tencent/cherry-markdown/commit/52f01c90681bd79d443d843dbc6a7c0c9361ab03))
* 对于配置config 类型的修复 ([#890](https://github.com/Tencent/cherry-markdown/issues/890)) ([588f862](https://github.com/Tencent/cherry-markdown/commit/588f862a83e78193047f5c8690fe909d36051bc3))
* 修复为支持引用嵌套导致页面报错的问题 ([e930143](https://github.com/Tencent/cherry-markdown/commit/e930143a12b95e98d303e1f0b4c1c8c8a5f50cc3))

### [0.8.47](https://github.com/Tencent/cherry-markdown/compare/v0.8.46...v0.8.47) (2024-09-03)


Expand Down
2 changes: 1 addition & 1 deletion client/src/components/CherryMarkdown/cherry.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,4 +283,4 @@ const initCherryMarkdown = () => {
})
}

export default initCherryMarkdown;
export default initCherryMarkdown;
4 changes: 2 additions & 2 deletions dist/addons/advance/cherry-table-echarts-plugin.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/addons/cherry-code-block-mermaid-plugin.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/addons/cherry-code-block-plantuml-plugin.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.core.common.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.core.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.css
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.engine.core.common.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.engine.core.esm.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.engine.core.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.esm.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.js.map

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

4 changes: 2 additions & 2 deletions dist/cherry-markdown.markdown.css
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.markdown.min.css
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.min.css
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/cherry-markdown.min.js
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/fonts/ch-icon.eot
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/fonts/ch-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions dist/fonts/ch-icon.ttf
Git LFS file not shown
4 changes: 2 additions & 2 deletions dist/fonts/ch-icon.woff
Git LFS file not shown
Loading

0 comments on commit 6f8fc02

Please sign in to comment.