-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
7,925 additions
and
6,390 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,7 @@ yarn.lock | |
pnpm-lock.yaml | ||
auto-imports.d.ts | ||
components.d.ts | ||
|
||
.wxt | ||
.output | ||
web-ext.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 构建"); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`, `*`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.