refactor: add plop tool
This commit is contained in:
parent
e0297f4a9b
commit
28530b2744
|
@ -23,7 +23,8 @@
|
|||
"lint:style": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
|
||||
"lint:lint-staged": "lint-staged -c ./.husky/lintstagedrc.js",
|
||||
"lint:pretty": "pretty-quick --staged",
|
||||
"postinstall": "husky install"
|
||||
"postinstall": "husky install",
|
||||
"plop": "plop"
|
||||
},
|
||||
"dependencies": {
|
||||
"@iconify/iconify": "^2.1.2",
|
||||
|
@ -43,6 +44,7 @@
|
|||
"nprogress": "^0.2.0",
|
||||
"pinia": "^2.0.12",
|
||||
"pinia-plugin-persist": "^1.0.0",
|
||||
"plop": "^3.0.5",
|
||||
"qrcode": "^1.5.0",
|
||||
"qs": "^6.10.3",
|
||||
"vue": "3.2.31",
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
const PAGE_PATH = 'src/views/'
|
||||
|
||||
const toUpperCase = (str) => str.charAt(0).toUpperCase() + str.slice(1)
|
||||
|
||||
module.exports = {
|
||||
description: 'Create a new Module',
|
||||
prompts: [
|
||||
{
|
||||
type: 'input',
|
||||
name: 'pagePath',
|
||||
message: 'What is the path to the page?'
|
||||
},
|
||||
{
|
||||
type: 'input',
|
||||
name: 'moduleName',
|
||||
message: 'What is the name of the module?'
|
||||
}
|
||||
],
|
||||
actions: (data) => {
|
||||
const { pagePath, moduleName } = data
|
||||
const upperFirstName = toUpperCase(moduleName)
|
||||
|
||||
const actions = []
|
||||
if (moduleName) {
|
||||
actions.push({
|
||||
type: 'add',
|
||||
path: `${PAGE_PATH}${pagePath}/${moduleName}/index.vue`,
|
||||
templateFile: 'plop/template/newModule/index.hbs',
|
||||
data: {
|
||||
name: moduleName,
|
||||
upperFirstName
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return actions
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<script setup lang='ts'>
|
||||
import { ElButton } from 'element-plus' import { useI18n } from '@/hooks/web/useI18n' import { ref
|
||||
} from 'vue' defineOptions({ name: '{{upperFirstName}}', components: { ElButton }, setup() {} })
|
||||
const { t } = useI18n()
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<ElButton type='primary'>{{name}}</ElButton>
|
||||
</ContentWrap>
|
||||
</template>
|
|
@ -0,0 +1,7 @@
|
|||
const createNewModule = require('./plop/generator/newModule')
|
||||
|
||||
function Cli(plop) {
|
||||
plop.setGenerator('newModule', createNewModule)
|
||||
}
|
||||
|
||||
module.exports = Cli
|
3454
pnpm-lock.yaml
3454
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue