Skip to content

Commit

Permalink
Merge branch 'main' into dev/ui
Browse files Browse the repository at this point in the history
  • Loading branch information
YangFong committed Dec 15, 2024
2 parents 2d7359a + d37aedb commit de5371d
Show file tree
Hide file tree
Showing 32 changed files with 7,925 additions and 6,390 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/preview-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
npm run build:h5-netlify
- name: Upload dist artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: dist
path: dist
Expand All @@ -37,7 +37,7 @@ jobs:

- name: Upload PR number
if: ${{ always() }}
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: pr
path: ./pr-id.txt
12 changes: 6 additions & 6 deletions .github/workflows/preview-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' && github.repository == 'doocs/md'
steps:
- name: Download PR artifact
uses: dawidd6/action-download-artifact@v6
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: pr
Expand All @@ -22,7 +22,7 @@ jobs:
run: echo "id=$(<pr-id.txt)" >> "$GITHUB_OUTPUT"

- name: Download dist artifact
uses: dawidd6/action-download-artifact@v6
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success
Expand All @@ -35,7 +35,7 @@ jobs:
npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
- name: Upload status comment
uses: actions-cool/maintain-one-comment@v3
uses: actions-cool/maintain-one-comment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Expand All @@ -49,7 +49,7 @@ jobs:

- name: The job failed
if: ${{ failure() }}
uses: actions-cool/maintain-one-comment@v3
uses: actions-cool/maintain-one-comment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Expand All @@ -66,7 +66,7 @@ jobs:
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'failure' && github.repository == 'doocs/md'
steps:
- name: Download PR artifact
uses: dawidd6/action-download-artifact@v6
uses: dawidd6/action-download-artifact@v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: pr
Expand All @@ -76,7 +76,7 @@ jobs:
run: echo "id=$(<pr-id.txt)" >> "$GITHUB_OUTPUT"

- name: The job failed
uses: actions-cool/maintain-one-comment@v3
uses: actions-cool/maintain-one-comment@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
body: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- run: npm install
- run: npm run build-cli
- run: npm run build:cli
- run: cd md-cli && npm ci && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ yarn.lock
pnpm-lock.yaml
auto-imports.d.ts
components.d.ts

.wxt
.output
web-ext.config.ts
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<div align="center">

[![status](https://img.shields.io/github/actions/workflow/status/doocs/md/build.yml?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/actions) [![node](https://img.shields.io/badge/node-%3E%3D20-42cc23?style=flat-square&labelColor=564341)](https://nodejs.org/en/about/previous-releases) [![release](https://img.shields.io/github/v/release/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/releases) [![license](https://img.shields.io/github/license/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](./LICENSE) [![pr](https://img.shields.io/badge/prs-welcome-42cc23?style=flat-square&labelColor=564341)](https://github.com/doocs/md/pulls)<br>[![stars](https://img.shields.io/github/stars/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/stargazers) [![forks](https://img.shields.io/github/forks/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md)
[![status](https://img.shields.io/github/actions/workflow/status/doocs/md/build.yml?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/actions) [![node](https://img.shields.io/badge/node-%3E%3D20-42cc23?style=flat-square&labelColor=564341)](https://nodejs.org/en/about/previous-releases) [![pr](https://img.shields.io/badge/prs-welcome-42cc23?style=flat-square&labelColor=564341)](https://github.com/doocs/md/pulls) [![stars](https://img.shields.io/github/stars/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/stargazers) [![forks](https://img.shields.io/github/forks/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md)<br> [![release](https://img.shields.io/github/v/release/doocs/md?style=flat-square&labelColor=564341&color=42cc23)](https://github.com/doocs/md/releases) [![npm](https://img.shields.io/npm/v/@doocs/md-cli?style=flat-square&labelColor=564341&color=42cc23)](https://www.npmjs.com/package/@doocs/md-cli) [![docker](https://img.shields.io/badge/docker-latest-42cc23?style=flat-square&labelColor=564341)](https://hub.docker.com/r/doocs/md)

</div>

Expand Down
84 changes: 44 additions & 40 deletions bin/release.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,48 @@
import fs from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';
import packageJson from '../md-cli/package.json' assert { type: 'json' };
import child_process from 'child_process';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

(async function () {
const fs = require('fs');
const path = require('path');
const packageJson = require('../md-cli/package.json');
const child_process = require('child_process');
// 自动更新版本
// version可以传递如 6.1.1 | patch | minor | major
const execCommand = arr => (Array.isArray(arr) ? arr : [arr]).forEach(c => {
try {
console.log(`start: ${c}...`)
console.log(child_process.execSync(c).toString('utf8'))
} catch (error) {
console.log('\x1B[31m%s\x1B[0m', error.stdout.toString())
process.exit(1)
}
})
const getNewVersion = (oldVersion, version = 'patch') => {
const execCommand = (arr) =>
(Array.isArray(arr) ? arr : [arr]).forEach((c) => {
try {
console.log(`start: ${c}...`);
console.log(child_process.execSync(c).toString("utf8"));
} catch (error) {
console.log("\x1B[31m%s\x1B[0m", error.stdout.toString());
process.exit(1);
}
});
const getNewVersion = (oldVersion, version = "patch") => {
// [<newversion> | major | minor | patch]
if (/^([0-9]+\.*)+$/.test(version)) return version
const types = ['major', 'minor', 'patch']
const index = types.indexOf(version)
if (/^([0-9]+\.*)+$/.test(version)) return version;
const types = ["major", "minor", "patch"];
const index = types.indexOf(version);
if (index >= 0) {
const versionArr = oldVersion.split('.')
versionArr[index] = Number(versionArr[index]) + 1
return versionArr.map((e, i) => i > index ? 0 : e).join('.')
}
return getNewVersion(oldVersion)
const versionArr = oldVersion.split(".");
versionArr[index] = Number(versionArr[index]) + 1;
return versionArr.map((e, i) => (i > index ? 0 : e)).join(".");
}
const newVersionObj = {
version: getNewVersion(packageJson.version, process.argv[2]),
};
fs.writeFileSync(
path.resolve(__dirname, '../md-cli/package.json'),
JSON.stringify(Object.assign({}, packageJson, newVersionObj), null, 2) +
'\n'
);
console.log(newVersionObj);
execCommand([
`git commit -a -m 'chore: update version cli-v${newVersionObj.version}'`,
`git tag cli-v${newVersionObj.version}`,
'git push && git push --tags',
])
console.log('\x1B[32m%s\x1B[0m', '发布完成,请关注github CI构建')
}())
return getNewVersion(oldVersion);
};
const newVersionObj = {
version: getNewVersion(packageJson.version, process.argv[2]),
};
await fs.writeFile(
path.resolve(__dirname, "../md-cli/package.json"),
JSON.stringify(Object.assign({}, packageJson, newVersionObj), null, 2) +
"\n"
);
console.log(newVersionObj);
execCommand([
`git commit -a -m 'chore: update version cli-v${newVersionObj.version}'`,
`git tag cli-v${newVersionObj.version}`,
"git push && git push --tags",
]);
console.log("\x1B[32m%s\x1B[0m", "发布完成,请关注 GitHub CI 构建");
})();
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default antfu({
unocss: true,
typescript: true,
formatters: true,
ignores: [`.github`, `bin`, `md-cli`, `src/assets`],
ignores: [`.github`, `bin`, `md-cli`, `src/assets`, `example`],
}, {
rules: {
'semi': [`error`, `never`],
Expand Down
16 changes: 16 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Example

## worker.js

公众号openapi接口代理服务示例,该项目将请求转发至微信公众号api。

开发调试:

```
cd example
npx wrangler dev worker.js
```

部署:

请将其部署到cloudflare workers。
36 changes: 36 additions & 0 deletions example/worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @typedef {object} Env
* @property
*/

export default {
/**
* @param {Request} request
* @param {Env} env
* @param {ExecutionContext} ctx
* @returns {Promise<Response>}
*/
async fetch(request, env, ctx) {
const url = new URL(request.url)
const targetUrl = `https://api.weixin.qq.com`
const proxyRequest = new Request(targetUrl + url.pathname + url.search, {
method: request.method,
headers: request.headers,
body: request.body,
})
const response = await fetch(proxyRequest)
const proxyResponse = new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: response.headers,
})
setCorsHeaders(proxyResponse.headers)
return proxyResponse
},
}
// 设置 CORS 头部
function setCorsHeaders(headers) {
headers.set(`Access-Control-Allow-Origin`, `*`)
headers.set(`Access-Control-Allow-Methods`, `GET, POST, PUT, DELETE`)
headers.set(`Access-Control-Allow-Headers`, `*`)
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
}
</script>
<script>
MathJax = {
window.MathJax = {
loader: { load: ['[tex]/ams'] },
tex: { packages: { '[+]': ['ams'] }, tags: 'ams' },
svg: { fontCache: 'none' },
Expand Down
50 changes: 50 additions & 0 deletions md-cli/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# md-cli

A powerful yet simple tool for rendering Markdown documents locally during development.

## Installation

To get started with `md-cli`, you can install it either globally or locally, depending on your needs.

### Install locally

If you only need it for a specific project, you can install it locally by running:

```bash
npm install @doocs/md-cli
```

### Install globally

For global access across all your projects, install it globally with:

```bash
npm install -g @doocs/md-cli
```

## Usage

Once installed, running `md-cli` is a breeze. Here’s how to get started:

### Default setup

To launch `md-cli` with the default settings, simply run:

```bash
md-cli
```

### Custom port

If you prefer to run `md-cli` on a different port, say `8899`, just specify it like this:

```bash
md-cli port=8899
```

## Maintainers

- [yanglbme](https://github.com/yanglbme) – Core maintainer.
- [YangFong](https://github.com/yangfong) – Core maintainer.
- [xw](https://github.com/wll8) – Contributor.
- [thinkasany](https://www.npmjs.com/~thinkerwing) – Contributor.
2 changes: 1 addition & 1 deletion md-cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ new Promise(async () => {
;[port, testPort, replayPort] = await Promise.all([port, port+1, port+2].map(item => getPort({port: item}) )).catch(err => console.log(`err`, err))
const line = Object.entries({
...arg,
proxy: `https://doocs.gitee.io/`,
proxy: `https://doocs-md.pages.dev`,
port,
testPort,
replayPort,
Expand Down
Loading

0 comments on commit de5371d

Please sign in to comment.