feat: 样板打包脚本

This commit is contained in:
unanmed 2025-10-11 17:22:32 +08:00
parent c339825f5e
commit 17f771c644
3 changed files with 52 additions and 1 deletions

1
.gitignore vendored
View File

@ -53,3 +53,4 @@ docs/.vitepress/cache
docs/.vitepress/dist
docs/.vitepress/apiSidebar.ts
_docs
template

View File

@ -14,7 +14,8 @@
"build:lib": "vue-tsc --noEmit && tsx script/build-lib.ts",
"docs:dev": "concurrently -k -n SIDEBAR,VITEPRESS -c blue,green \"tsx docs/.vitepress/api.ts\" \"vitepress dev docs\"",
"docs:build": "vitepress build docs",
"docs:preview": "vitepress preview docs"
"docs:preview": "vitepress preview docs",
"pack:template": "tsx script/pack-template.ts"
},
"dependencies": {
"@ant-design/icons-vue": "^6.1.0",

49
script/pack-template.ts Normal file
View File

@ -0,0 +1,49 @@
/* eslint-disable no-console */
import { copy, emptyDir, ensureDir } from 'fs-extra';
import { resolve } from 'path';
const base = resolve(process.cwd());
const template = resolve(base, 'template');
async function packTemplate() {
await ensureDir(template);
await emptyDir(template);
// 复制必要文件
const toCopy = [
'.vscode',
'packages',
'packages-user',
'public',
'script',
'src',
'.gitignore',
'.madgerc',
'.prettierignore',
'.prettierrc',
'eslint.config.js',
'index.html',
'LICENSE',
'package.json',
'pnpm-lock.yaml',
'pnpm-workspace.yaml',
'README.md',
'tsconfig.json',
'tsconfig.node.json',
'vite.config.ts'
];
await Promise.all(
toCopy.map(v =>
copy(resolve(base, v), resolve(template, v), {
filter: src => !src.includes('node_modules')
})
)
);
console.log(`样板打包完成`);
}
(() => {
packTemplate();
})();