Skip to content

Commit

Permalink
feat: add template-vue-typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
lvqq committed Sep 17, 2022
1 parent 12ca863 commit b596cf8
Show file tree
Hide file tree
Showing 25 changed files with 849 additions and 16 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ jobs:
- name: Link
run: cd packages && cd create-cap && pnpm link --global

- name: Test
- name: Test Tempalte
run: pnpm run test:template

- name: Test CI
run: pnpm run test:ci

- name: Coveralls
Expand Down
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
registry = https://registry.npmjs.org
access = public
enable-pre-post-scripts = true
enable-pre-post-scripts = true
auto-install-peers = true
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"init": "node ./scripts/init.js",
"test": "vitest run --silent",
"test:ci": "vitest run --coverage",
"test:template": "pnpm -r --filter=./packages/template-* run test",
"lint": "eslint --fix --quiet packages/*/src/**/*.{ts,tsx}",
"changelog": "pnpm -r --filter=@tooltik/create-cap run changelog"
},
Expand Down
1 change: 1 addition & 0 deletions packages/create-cap/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const TemplatesNameMap = {
TypeScript: '@tooltik/template-typescript',
'React + TypeScript': '@tooltik/template-react-typescript',
'Vue + TypeScript': '@tooltik/template-vue-typescript',
} as const;

export const GitIgnoreFile = `
Expand Down
2 changes: 2 additions & 0 deletions packages/template-vue-typescript/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
34 changes: 34 additions & 0 deletions packages/template-vue-typescript/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{

"root": true,
"env": {
"commonjs": true,
"es2021": true,
"node": true
},
"extends": [
"eslint:recommended",
"airbnb-base",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:vue/vue3-recommended",
"prettier"
],
"plugins": ["@typescript-eslint", "import", "prettier"],
"parser": "vue-eslint-parser",
"parserOptions": {
"parser": "@typescript-eslint/parser",
"sourceType": "module",
"ecmaVersion": 2021,
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"prettier/prettier": "error",
"import/no-unresolved": 0,
"import/extensions": 0,
"import/prefer-default-export": 0,
"import/no-extraneous-dependencies": 0
}
}
59 changes: 59 additions & 0 deletions packages/template-vue-typescript/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: CI

on:
push:
branches:
- main

pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set node v14
uses: actions/setup-node@v3
with:
node-version: '14'

- name: Install
run: npm install

- name: Lint
run: npm run lint

typecheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set node v14
uses: actions/setup-node@v3
with:
node-version: '14'

- name: Install
run: npm install

- name: Typecheck
run: npm run typecheck

test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set node v14
uses: actions/setup-node@v3
with:
node-version: '14'

- name: Install
run: npm install

- name: Build
run: npm run test
21 changes: 21 additions & 0 deletions packages/template-vue-typescript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Coverage
coverage

# Compiled
build
dist

# Dependency directories
node_modules

# OS X temporary files
.DS_Store

# VSCode settings
.vscode
4 changes: 4 additions & 0 deletions packages/template-vue-typescript/.husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx lint-staged
3 changes: 3 additions & 0 deletions packages/template-vue-typescript/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
test
6 changes: 6 additions & 0 deletions packages/template-vue-typescript/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 80,
"tabWidth": 2,
"semi": true,
"singleQuote": true
}
13 changes: 13 additions & 0 deletions packages/template-vue-typescript/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
42 changes: 42 additions & 0 deletions packages/template-vue-typescript/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "@tooltik/template-vue-typescript",
"version": "0.1.0-beta.1",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"preview": "vite preview",
"prepare": "husky install",
"typecheck": "tsc",
"test": "vitest run",
"lint": "eslint --fix --quiet --ext .ts,.vue src"
},
"dependencies": {
"vue": "^3.2.37"
},
"devDependencies": {
"@testing-library/vue": "^6.6.1",
"@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2",
"@vitejs/plugin-vue": "^3.1.0",
"@vitejs/plugin-vue-jsx": "^2.0.1",
"eslint": "^8.23.0",
"eslint-plugin-vue": "^9.5.1",
"husky": "^8.0.1",
"jsdom": "^20.0.0",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"typescript": "^4.6.4",
"vite": "^3.1.0",
"vitest": "^0.23.2",
"vue-eslint-parser": "^9.1.0",
"vue-tsc": "^0.40.4"
},
"lint-staged": {
"**/*.{ts,vue}": [
"eslint --fix --quiet",
"prettier --write",
"git add"
]
}
}
1 change: 1 addition & 0 deletions packages/template-vue-typescript/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions packages/template-vue-typescript/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script setup lang="ts">
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://vuejs.org/api/sfc-script-setup.html#script-setup
import HelloWorld from './components/HelloWorld.vue';
</script>

<template>
<a href="https://vitejs.dev" target="_blank">
<img src="/vite.svg" class="logo" alt="Vite logo" />
</a>
<a href="https://vuejs.org/" target="_blank">
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
</a>
<HelloWorld msg="Vite + Vue" />
</template>

<style scoped>
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
1 change: 1 addition & 0 deletions packages/template-vue-typescript/src/assets/vue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions packages/template-vue-typescript/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<script setup lang="ts">
import { ref } from 'vue';
defineProps<{ msg: string }>();
const count = ref(0);
</script>

<template>
<h1>{{ msg }}</h1>

<div class="card">
<button type="button" @click="count++">count is {{ count }}</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test HMR
</p>
</div>

<p>
Check out
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank"
>create-vue</a
>, the official Vue + Vite starter
</p>
<p>
Install
<a href="https://github.com/johnsoncodehk/volar" target="_blank">Volar</a>
in your IDE for a better DX
</p>
<p class="read-the-docs">Click on the Vite and Vue logos to learn more</p>
</template>

<style scoped>
.read-the-docs {
color: #888;
}
</style>
5 changes: 5 additions & 0 deletions packages/template-vue-typescript/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createApp } from 'vue';
import './style.css';
import App from './App.vue';

createApp(App).mount('#app');
81 changes: 81 additions & 0 deletions packages/template-vue-typescript/src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

.card {
padding: 2em;
}

#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
Loading

0 comments on commit b596cf8

Please sign in to comment.