Ai
1 Star 0 Fork 451

咸鱼郑某/element-plus

forked from element-plus/element-plus 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gc.sh 1.52 KB
一键复制 编辑 原始数据 按行查看 历史
三咲智子 提交于 2021-09-23 08:12 +08:00 . refactor: replace yarn with pnpm (#3571)
#! /bin/bash
NAME=$1
FILE_PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")/../packages" && pwd)
re="[[:space:]]+"
if [ "$#" -ne 1 ] || [[ $NAME =~ $re ]] || [ "$NAME" == "" ]; then
echo "Usage: pnpm gc \${name} with no space"
exit 1
fi
DIRNAME="$FILE_PATH/components/$NAME"
INPUT_NAME=$NAME
if [ -d "$DIRNAME" ]; then
echo "$NAME component already exists, please change it"
exit 1
fi
NORMALIZED_NAME=""
for i in $(echo $NAME | sed 's/[_|-]\([a-z]\)/\ \1/;s/^\([a-z]\)/\ \1/'); do
C=$(echo "${i:0:1}" | tr "[:lower:]" "[:upper:]")
NORMALIZED_NAME="$NORMALIZED_NAME${C}${i:1}"
done
NAME=$NORMALIZED_NAME
mkdir -p "$DIRNAME"
mkdir -p "$DIRNAME/src"
mkdir -p "$DIRNAME/__tests__"
cat > $DIRNAME/src/index.vue <<EOF
<template>
<div>
<slot></slot>
</div>
</template>
<script lang='ts'>
import { defineComponent } from 'vue'
export default defineComponent({
name: 'El${NAME}',
props: { },
setup(props) {
// init here
},
})
</script>
<style>
</style>
EOF
cat <<EOF >"$DIRNAME/index.ts"
import { App } from 'vue'
import ${NAME} from './src/index.vue'
${NAME}.install = (app: App): void => {
app.component(${NAME}.name, ${NAME})
}
export default ${NAME}
EOF
cat > $DIRNAME/__tests__/$INPUT_NAME.spec.ts <<EOF
import { mount } from '@vue/test-utils'
import $NAME from '../src/index.vue'
const AXIOM = 'Rem is the best girl'
describe('$NAME.vue', () => {
test('render test', () => {
const wrapper = mount($NAME, {
slots: {
default: AXIOM,
},
})
expect(wrapper.text()).toEqual(AXIOM)
})
})
EOF
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/ZHFHZ/element-plus.git
git@gitee.com:ZHFHZ/element-plus.git
ZHFHZ
element-plus
element-plus
dev

搜索帮助