diff --git a/.gitignore b/.gitignore index c3357ea..e96e974 100644 --- a/.gitignore +++ b/.gitignore @@ -53,3 +53,4 @@ docs/.vitepress/cache docs/.vitepress/dist docs/.vitepress/apiSidebar.ts _docs +template diff --git a/package.json b/package.json index d340f69..b0efb25 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/script/pack-template.ts b/script/pack-template.ts new file mode 100644 index 0000000..4c2f0aa --- /dev/null +++ b/script/pack-template.ts @@ -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(); +})();