Skip to content

Commit a7d88b8

Browse files
committed
feat: initial commit
0 parents  commit a7d88b8

29 files changed

Lines changed: 7494 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [20.x]
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Use Node.js ${{ matrix.node-version }}
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: ${{ matrix.node-version }}
24+
cache: 'npm'
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run linter
30+
run: npm run lint
31+
32+
- name: Run type check
33+
run: npm run typecheck
34+
35+
- name: Run tests
36+
run: npm run test
37+
38+
- name: Build
39+
run: npm run build

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
.DS_Store
12+
dist
13+
dist-ssr
14+
coverage
15+
*.local
16+
17+
# Editor directories and files
18+
.vscode/*
19+
!.vscode/extensions.json
20+
.idea
21+
*.suo
22+
*.ntvs*
23+
*.njsproj
24+
*.sln
25+
*.sw?

.npmignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
playground/
2+
tests/
3+
src/
4+
.github/
5+
.gitignore
6+
.prettierrc.json
7+
.prettierignore
8+
eslint.config.js
9+
tsconfig.json
10+
tsconfig.app.json
11+
tsconfig.vitest.json
12+
vite.config.ts
13+
vitest.config.ts
14+
*.log
15+
.DS_Store

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist
2+
node_modules
3+
coverage
4+
*.log

.prettierrc.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": false,
3+
"singleQuote": true,
4+
"printWidth": 100,
5+
"trailingComma": "all",
6+
"arrowParens": "always",
7+
"endOfLine": "lf"
8+
}

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"Vue.volar",
4+
"dbaeumer.vscode-eslint",
5+
"esbenp.prettier-vscode",
6+
"vitest.explorer"
7+
]
8+
}

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2025-12-19
9+
10+
### Added
11+
- Initial template setup
12+
- Sample Vue component with TypeScript
13+
- Sample composable
14+
- Plugin installation with options
15+
- Playground for local development
16+
- Vitest and Vue Test Utils setup
17+
- ESLint and Prettier configuration
18+
- GitHub Actions CI workflow
19+
- Comprehensive documentation

CONTRIBUTING.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Contributing to Vue Plugin Template
2+
3+
Thank you for your interest in contributing! Here are some guidelines to help you get started.
4+
5+
## Development Setup
6+
7+
1. Fork the repository
8+
2. Clone your fork: `git clone https://github.com/your-username/vue-plugin-template.git`
9+
3. Install dependencies: `npm install`
10+
4. Create a branch: `git checkout -b feature/your-feature`
11+
12+
## Development Workflow
13+
14+
1. Make your changes in the appropriate directory:
15+
- `src/` for plugin code
16+
- `tests/` for tests
17+
- `playground/` for playground examples
18+
19+
2. Run tests: `npm run test`
20+
3. Run linter: `npm run lint`
21+
4. Format code: `npm run format`
22+
23+
## Testing
24+
25+
- Write tests for any new features
26+
- Ensure all tests pass before submitting
27+
- Aim for high test coverage
28+
29+
## Pull Request Process
30+
31+
1. Update the README.md with details of changes if needed
32+
2. Ensure all tests pass and code is linted
33+
3. Update the version number if applicable
34+
4. Submit your PR with a clear description of the changes
35+
36+
## Code Style
37+
38+
- Follow the existing code style
39+
- Use TypeScript for all new code
40+
- Write clear, descriptive commit messages
41+
- Add comments for complex logic
42+
43+
## Questions?
44+
45+
Feel free to open an issue for any questions or concerns.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Vue Plugin Template
2+
3+
A comprehensive template for creating Vue 3 plugins with TypeScript, testing, and development tools pre-configured.
4+
5+
## 🚀 Features
6+
7+
-**Vue 3** support with TypeScript
8+
-**Local playground** for testing your plugin during development
9+
-**Unit testing** with Vitest and Vue Test Utils
10+
-**Linting** with ESLint and Prettier
11+
-**GitHub Actions** CI/CD pipeline
12+
-**Build configuration** for npm package publishing
13+
-**Example components** and composables
14+
15+
## 🏁 Getting Started
16+
17+
### 1. Clone this template
18+
19+
```bash
20+
git clone https://github.com/monterail/vue-plugin-template.git
21+
cd vue-plugin-template
22+
```
23+
24+
### 2. Install dependencies
25+
26+
```bash
27+
npm install
28+
```
29+
30+
### 3. Customize your plugin
31+
32+
Update the following files:
33+
34+
- `package.json` - Change name, description, author, etc.
35+
- `src/index.ts` - Rename your plugin and customize functionality
36+
- `src/components/` - Add or modify components
37+
- `src/composables/` - Add or modify composables
38+
- `README.md` - Update documentation for your plugin
39+
40+
### 4. Start development
41+
42+
```bash
43+
# Run the playground for local development
44+
npm run dev
45+
46+
# Or run tests in watch mode
47+
npm run test:watch
48+
```
49+
50+
## 🛠️ Development
51+
52+
### Basic Plugin Structure
53+
54+
```typescript
55+
// src/index.ts
56+
import type { App, Plugin } from 'vue'
57+
58+
export interface MyPluginOptions {
59+
// Your options here
60+
}
61+
62+
const MyPlugin: Plugin = {
63+
install(app: App, options: MyPluginOptions = {}) {
64+
// Register components
65+
app.component('MyComponent', MyComponent)
66+
67+
// Add global properties
68+
app.config.globalProperties.$myPlugin = {
69+
// Your global methods
70+
}
71+
72+
// Provide data
73+
app.provide('myData', someData)
74+
}
75+
}
76+
77+
export default MyPlugin
78+
```
79+
80+
### Registering Components
81+
82+
```typescript
83+
// Register globally
84+
app.component('MyComponent', MyComponent)
85+
86+
// Register with prefix
87+
const prefix = options.prefix || 'My'
88+
app.component(`${prefix}Component`, MyComponent)
89+
```
90+
91+
### Adding Global Properties
92+
93+
```typescript
94+
app.config.globalProperties.$myPlugin = {
95+
greet: (name: string) => `Hello, ${name}!`
96+
}
97+
98+
// TypeScript types
99+
declare module '@vue/runtime-core' {
100+
export interface ComponentCustomProperties {
101+
$myPlugin: {
102+
greet: (name: string) => string
103+
}
104+
}
105+
}
106+
```
107+
108+
### Creating Composables
109+
110+
```typescript
111+
// src/composables/useMyPlugin.ts
112+
import { ref, computed } from 'vue'
113+
114+
export function useMyPlugin() {
115+
const count = ref(0)
116+
const double = computed(() => count.value * 2)
117+
118+
const increment = () => count.value++
119+
120+
return { count, double, increment }
121+
}
122+
```
123+
124+
## 🔧 Using Your Published Plugin
125+
126+
Once published, users can install and use your plugin:
127+
128+
```bash
129+
npm install your-plugin-name
130+
```
131+
132+
```typescript
133+
// main.ts
134+
import { createApp } from 'vue'
135+
import App from './App.vue'
136+
import MyPlugin from 'your-plugin-name'
137+
138+
const app = createApp(App)
139+
140+
app.use(MyPlugin, {
141+
// Plugin options
142+
})
143+
144+
app.mount('#app')
145+
```
146+
147+
```vue
148+
<!-- Using in components -->
149+
<template>
150+
<MyComponent />
151+
</template>
152+
153+
<script setup>
154+
import { useMyPlugin } from 'your-plugin-name'
155+
156+
const { count, increment } = useMyPlugin()
157+
</script>
158+
```
159+
160+
## 🤝 Contributing
161+
162+
Contributions are welcome! Please feel free to submit a Pull Request.
163+
164+
## 📄 License
165+
166+
MIT
167+
168+
## 🙏 Acknowledgments
169+
170+
Built with:
171+
- [Vue 3](https://vuejs.org/)
172+
- [Vite](https://vitejs.dev/)
173+
- [Vitest](https://vitest.dev/)
174+
- [TypeScript](https://www.typescriptlang.org/)
175+
- [Vue Test Utils](https://test-utils.vuejs.org/)
176+
177+
---
178+
179+
**Happy plugin building! 🎉**
180+
181+
If you find this template helpful, please give it a ⭐️ on GitHub!

0 commit comments

Comments
 (0)