From 712781ea0a52a8ce284a3f048ff863c28c18e4a3 Mon Sep 17 00:00:00 2001 From: markthree <1801982702@qq.com> Date: Thu, 20 Jan 2022 23:25:01 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __unconfig_vite.config.ts | 18 ------------ package.json | 2 +- pnpm-lock.yaml | 38 +++++++++++++++++++++--- scripts/create.ts | 61 --------------------------------------- 4 files changed, 35 insertions(+), 84 deletions(-) delete mode 100644 __unconfig_vite.config.ts diff --git a/__unconfig_vite.config.ts b/__unconfig_vite.config.ts deleted file mode 100644 index dbd8b80..0000000 --- a/__unconfig_vite.config.ts +++ /dev/null @@ -1,18 +0,0 @@ - -let __unconfig_data; -let __unconfig_stub = function (data) { __unconfig_data = data }; -__unconfig_stub.default = (data) => { __unconfig_data = data }; -import { resolve } from 'path' -import Tov from './presets/tov' -import { defineConfig } from 'vite' - -const __unconfig_default = defineConfig({ - resolve: { - alias: { - '~/': `${resolve(__dirname, 'src')}/` - } - }, - plugins: [Tov()] -}) - -if (typeof __unconfig_default === "function") __unconfig_default();export default __unconfig_data; \ No newline at end of file diff --git a/package.json b/package.json index 78eb5eb..ce2ed12 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ }, "devDependencies": { "@iconify-json/mdi": "^1.0.12", - "@markthree/node-shared": "^1.2.1", + "@markthree/node-shared": "^1.3.0", "@types/nprogress": "^0.2.0", "@vitejs/plugin-vue": "^2.0.1", "@vueuse/components": "^7.5.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 875dc77..8de8128 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -2,7 +2,7 @@ lockfileVersion: 5.3 specifiers: '@iconify-json/mdi': ^1.0.12 - '@markthree/node-shared': ^1.2.1 + '@markthree/node-shared': ^1.3.0 '@types/nprogress': ^0.2.0 '@vitejs/plugin-vue': ^2.0.1 '@vueuse/components': ^7.5.3 @@ -39,7 +39,7 @@ dependencies: devDependencies: '@iconify-json/mdi': 1.0.12 - '@markthree/node-shared': 1.2.1 + '@markthree/node-shared': 1.3.0 '@types/nprogress': 0.2.0 '@vitejs/plugin-vue': 2.0.1_vite@2.7.10+vue@3.2.26 '@vueuse/components': 7.5.3_vue@3.2.26 @@ -150,8 +150,8 @@ packages: engines: {node: '>=8'} dev: true - /@markthree/node-shared/1.2.1: - resolution: {integrity: sha512-FJ7InznFRClBfqvm/KC+G/pbSNI3JvJGSXcwPUFDwKuvDb9AUhyxjx+pef/fDQx0nAXrxxI+4eDp7jsXz4BHAw==} + /@markthree/node-shared/1.3.0: + resolution: {integrity: sha512-9j6avolPnx6GX37HprSeNgmuLYSdc9qbLaEBsFF/TscgRLAQskffuUj4t1O/8y5DQ6lv0V9KzG3sRNPOB7qYOg==} dependencies: '@types/fs-extra': 9.0.13 '@types/inquirer': 8.1.3 @@ -161,6 +161,7 @@ packages: commander: 8.3.0 execa: 6.0.0 fs-extra: 10.0.0 + handlebars: 4.7.7 inquirer: 8.2.0 ora: 6.0.1 p-retry: 5.0.0 @@ -1666,6 +1667,19 @@ packages: strip-bom-string: 1.0.0 dev: true + /handlebars/4.7.7: + resolution: {integrity: sha512-aAcXm5OAfE/8IXkcZvCepKU3VzW1/39Fb5ZuqMtgI/hT8X2YgoMvBY5dLhq/cpOvw7Lk1nK/UF71aLG/ZnVYRA==} + engines: {node: '>=0.4.7'} + hasBin: true + dependencies: + minimist: 1.2.5 + neo-async: 2.6.2 + source-map: 0.6.1 + wordwrap: 1.0.0 + optionalDependencies: + uglify-js: 3.14.5 + dev: true + /has-bigints/1.0.1: resolution: {integrity: sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==} dev: true @@ -2215,6 +2229,10 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true + /neo-async/2.6.2: + resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} + dev: true + /normalize-path/3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} @@ -2910,6 +2928,14 @@ packages: resolution: {integrity: sha512-6t9LrLk3FhqTS+GW3IqlITtfRB5JAVr5MMNjpBECfK827W+Vh5Ilw/LhTcHWrt6b3hkeBvcbjx4Ti7QVFzmcww==} dev: true + /uglify-js/3.14.5: + resolution: {integrity: sha512-qZukoSxOG0urUTvjc2ERMTcAy+BiFh3weWAkeurLwjrCba73poHmG3E36XEjd/JGukMzwTL7uCxZiAexj8ppvQ==} + engines: {node: '>=0.8.0'} + hasBin: true + requiresBuild: true + dev: true + optional: true + /unbox-primitive/1.0.1: resolution: {integrity: sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==} dependencies: @@ -3468,6 +3494,10 @@ packages: babel-walk: 3.0.0-canary-5 dev: true + /wordwrap/1.0.0: + resolution: {integrity: sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=} + dev: true + /wrap-ansi/7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} diff --git a/scripts/create.ts b/scripts/create.ts index 5c028a5..e3da4d0 100644 --- a/scripts/create.ts +++ b/scripts/create.ts @@ -7,64 +7,3 @@ import { } from '@markthree/node-shared' const usePath = createPath(__dirname) - -const types = [ - { - type: 'list', - name: 'type', - message: '你希望自动创建以下哪种类型', - choices: ['page', 'component'] - } -] - -const names = [ - { - type: 'input', - name: 'name', - message: '请输入名称' - } -] - -const loading = createTerminalLoading() - -const fail = (msg: string) => loading.fail(msg) -const succeed = (msg: string) => loading.succeed(msg) - -const reConfirm = async () => { - const { confirm } = await prompt([ - { - type: 'confirm', - name: 'confirm', - message: '该文件已存在,是否覆盖' - } - ]) - return confirm -} - -const runAutoCreate = async () => { - const { type } = await prompt(types) - const isComponent = type === 'component' - if (isComponent) { - return createComponentWithTemplate() - } -} - -runAutoCreate() - -const createComponentWithTemplate = async () => { - const src = usePath('./template/component.vue') - - const { name } = await prompt(names) - const dest = usePath(`../src/components/${name}.vue`) - const componentExists = pathExistsSync(dest) - if (componentExists) { - const confirm = await reConfirm() - if (confirm) { - await copy(src, dest) - return succeed('该文件已被覆盖初始化') - } - return fail('创建失败') - } - await copy(src, dest) - succeed('创建成功') -}