mirror of
https://github.com/doocs/md.git
synced 2025-01-22 20:04:39 +08:00
chore: update cli (#460)
This commit is contained in:
parent
ec7a46f4da
commit
dbb1af10a8
4
.github/workflows/preview-build.yml
vendored
4
.github/workflows/preview-build.yml
vendored
@ -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
|
||||
@ -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
.github/workflows/preview-deploy.yml
vendored
12
.github/workflows/preview-deploy.yml
vendored
@ -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
|
||||
@ -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
|
||||
@ -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: |
|
||||
@ -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: |
|
||||
@ -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
|
||||
@ -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: |
|
||||
|
@ -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('.')
|
||||
const versionArr = oldVersion.split(".");
|
||||
versionArr[index] = Number(versionArr[index]) + 1;
|
||||
return versionArr.map((e, i) => (i > index ? 0 : e)).join(".");
|
||||
}
|
||||
return getNewVersion(oldVersion)
|
||||
}
|
||||
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 构建");
|
||||
})();
|
||||
|
@ -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,
|
||||
|
3748
md-cli/package-lock.json
generated
3748
md-cli/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@doocs/md-cli",
|
||||
"version": "0.0.7",
|
||||
"version": "0.0.8",
|
||||
"description": "✍ 一款高度简洁的微信 Markdown 编辑器:支持 Markdown 所有基础语法、色盘取色、一键复制并粘贴到公众号后台、多图上传、一键下载文档、自定义 CSS 样式、一键重置等特性",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
Loading…
Reference in New Issue
Block a user