File tree Expand file tree Collapse file tree 2 files changed +67
-1
lines changed
Expand file tree Collapse file tree 2 files changed +67
-1
lines changed Original file line number Diff line number Diff line change 55 "scripts" : {
66 "dev" : " vite" ,
77 "build" : " vite build" ,
8- "cz" : " npx git-cz"
8+ "cz" : " npx git-cz" ,
9+ "gc" : " sh ./scripts/gc.sh"
910 },
1011 "dependencies" : {
1112 "vue" : " ^3.0.0-rc.1" ,
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ export NAME=$1
4+
5+ export FILE_PATH=$( cd " $( dirname " ${BASH_SOURCE[0]} " ) /../packages" && pwd)
6+
7+ re=" [[:space:]]+"
8+
9+ if [ " $# " -ne 1 ] || [[ $NAME =~ $re ]] || [ " $NAME " == " " ]; then
10+ echo " Usage: yarn gc \$ {name} with no space"
11+ exit 1
12+ fi
13+
14+ DIRNAME=" $FILE_PATH /$NAME "
15+
16+ if [ -d " $DIRNAME " ]; then
17+ echo " $NAME component already exists, please change it"
18+ exit 1
19+ fi
20+ NORMALIZED_NAME=" "
21+ for i in $( echo $NAME | sed ' s/[_|-]\([a-z]\)/\ \1/;s/^\([a-z]\)/\ \1/' ) ; do
22+ C=$( echo " ${i: 0: 1} " | tr " [:lower:]" " [:upper:]" )
23+ NORMALIZED_NAME=" $NORMALIZED_NAME ${C}${i: 1} "
24+ done
25+ NAME=$NORMALIZED_NAME
26+
27+ TEMPLATE_INDEX_VUE=" <template>\n
28+ <div>\n
29+ </div>\n
30+ </template>\n
31+ <script lang='ts'>\n
32+ export default {\n
33+ NAME: 'El${NAME} ',\n
34+ props: {\n
35+ },\n
36+ setup(props,ctx) { }\n
37+ };\n
38+ </script>\n
39+ <style>\n
40+ </style>\n
41+ "
42+
43+ TEMPLATE_INDEX_TS=" \n
44+ import { App } from 'vue'\n
45+ import ${NAME} from './src/index.vue'\n
46+ export default (app: App) => {\n
47+ app.component(${NAME} .name, ${NAME} )\n
48+ }
49+ "
50+ TEMPLATE_PKG_JSON=" \n
51+ {\n
52+ \" name\" : \" eleplus-${NAME} \" ,\n
53+ \" description\" : \"\" ,\n
54+ \" version\" : \" 0.1.0\" ,\n
55+ \" main\" : \" ./index.ts\" ,\n
56+ \" license\" : \" MIT\" ,\n
57+ \" dependencies\" : {}\n
58+ }\n
59+ "
60+
61+ mkdir -p " $DIRNAME "
62+ mkdir -p " $DIRNAME /src"
63+ echo $TEMPLATE_INDEX_VUE >> " $DIRNAME /src/index.vue"
64+ echo $TEMPLATE_INDEX_TS >> " $DIRNAME /index.ts"
65+ echo $TEMPLATE_PKG_JSON >> " $DIRNAME /package.json"
You can’t perform that action at this time.
0 commit comments