Skip to content

Commit 5d19e4e

Browse files
committed
feat: add implementation for the first version
0 parents  commit 5d19e4e

37 files changed

+5337
-0
lines changed

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.eslintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "@antfu",
3+
"rules": {
4+
"curly": "off"
5+
}
6+
}

.github/FUNDING.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# These are supported funding model platforms
2+
3+
github: [ansidev]
4+
# patreon: # Replace with a single Patreon username
5+
# open_collective: # Replace with a single Open Collective username
6+
ko_fi: ansidev
7+
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
# liberapay: # Replace with a single Liberapay username
10+
# issuehunt: # Replace with a single IssueHunt username
11+
# otechie: # Replace with a single Otechie username
12+
# lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13+
custom: ['https://www.paypal.me/ansidev', 'https://www.buymeacoffee.com/ansidev']

.github/workflows/example_vitejs.yml

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: example
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
9+
pull_request:
10+
branches:
11+
- main
12+
- develop
13+
14+
env:
15+
DEPLOY_DIR: examples/vite/dist
16+
17+
jobs:
18+
build_and_deploy:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v3
23+
24+
- name: Setup pnpm
25+
uses: pnpm/action-setup@v2.2.4
26+
with:
27+
version: '7.x'
28+
run_install: false
29+
30+
- name: Get pnpm store directory
31+
id: pnpm-cache
32+
run: |
33+
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
34+
35+
- name: Setup pnpm cache
36+
uses: actions/cache@v3
37+
with:
38+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
39+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
40+
restore-keys: |
41+
${{ runner.os }}-pnpm-store-
42+
43+
- name: Install dependencies
44+
run: pnpm install
45+
46+
- name: Build
47+
env:
48+
VITE_COUNTER_ANALYTICS_ID: ${{ secrets.VITE_COUNTER_ANALYTICS_ID }}
49+
run: pnpm run build:example
50+
51+
- name: Deploy preview
52+
env:
53+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
54+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
55+
run: |
56+
pnpm add -g netlify-cli
57+
netlify deploy -a ${{ env.NETLIFY_AUTH_TOKEN }} -s ${{ env.NETLIFY_SITE_ID }} -d ${{ env.DEPLOY_DIR }} -m "$(git log -1 --pretty=%B)"

.github/workflows/publish.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: publish_npm_package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
env:
9+
DEPLOY_DIR: examples/vite/dist
10+
11+
jobs:
12+
build_and_publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v3
17+
18+
- name: Setup pnpm
19+
uses: pnpm/action-setup@v2.2.4
20+
with:
21+
version: '7.x'
22+
run_install: false
23+
24+
- name: Get pnpm store directory
25+
id: pnpm-cache
26+
run: |
27+
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
28+
29+
- name: Setup pnpm cache
30+
uses: actions/cache@v3
31+
with:
32+
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
33+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
34+
restore-keys: |
35+
${{ runner.os }}-pnpm-store-
36+
37+
- name: Install dependencies
38+
run: pnpm install
39+
40+
- name: Build
41+
env:
42+
VITE_COUNTER_ANALYTICS_ID: ${{ secrets.VITE_COUNTER_ANALYTICS_ID }}
43+
run: pnpm run build:example
44+
45+
- name: Set publish tag
46+
run: |
47+
[[ "${GITHUB_REF#refs/*/v}" =~ ^([0-9]+\.)?([0-9]+\.)?(\*|[0-9]+)$ ]] && echo "PUBLISH_TAG=latest" >> $GITHUB_ENV || echo "PUBLISH_TAG=rc" >> $GITHUB_ENV
48+
49+
- name: Deploy example
50+
env:
51+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
52+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
53+
run: |
54+
pnpm add -g netlify-cli
55+
[[ "${PUBLISH_TAG}" == "latest" ]] && netlify deploy -a ${{ env.NETLIFY_AUTH_TOKEN }} -s ${{ env.NETLIFY_SITE_ID }} -d ${{ env.DEPLOY_DIR }} -m "$(git log -1 --pretty=%B)" -p || netlify deploy -a ${{ env.NETLIFY_AUTH_TOKEN }} -s ${{ env.NETLIFY_SITE_ID }} -d ${{ env.DEPLOY_DIR }} -m "$(git log -1 --pretty=%B)"
56+
57+
- name: Publish NPM package
58+
env:
59+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
60+
run: |
61+
pnpm config set "//registry.npmjs.org/:_authToken" "${{ env.NPM_TOKEN }}"
62+
pnpm publish --access public --tag ${{ env.PUBLISH_TAG }}

.gitignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?
25+
26+
# Local Netlify folder
27+
.netlify
28+
29+
# Task files
30+
Taskfile.yaml
31+
Taskfile.*.yaml
32+
Taskfile.yml
33+
Taskfile.*.yml

.husky/commit-msg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit "$1"

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
git-checks=false
2+
publish-branch=main

.vscode/extensions.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"recommendations": ["Vue.volar"]
3+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 - present Le Minh Tri
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

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<img src="/counter.svg" alt="Counter Analytics" height="100" />
2+
3+
# Counter Analytics Vue 3 integration
4+
5+
[![npm version](https://img.shields.io/npm/v/counter-analytics-vue.svg)](https://www.npmjs.com/package/counter-analytics-vue)
6+
[![Build Status](https://github.com/ansidev/counter-analytics-vue/workflows/publish_npm_package/badge.svg)](https://github.com/ansidev/counter-analytics-vue/actions/workflows/publish.yml)
7+
[![Sourcegraph](https://sourcegraph.com/github.com/ansidev/counter-analytics-vue/-/badge.svg)](https://sourcegraph.com/github.com/ansidev/counter-analytics-vue?badge)
8+
[![Netlify Status](https://api.netlify.com/api/v1/badges/d1146628-1539-4582-8764-15f4108e978d/deploy-status)](https://app.netlify.com/sites/counter-analytics-vue/deploys)
9+
10+
Unofficial [Counter Analytics](https://go2.vn/dr9ng) integration for Vue.js.
11+
12+
## Integration
13+
14+
### Install
15+
16+
Run the following command to install in your project:
17+
18+
```
19+
npm install counter-analytics-vue
20+
```
21+
22+
Or with yarn:
23+
24+
```
25+
yarn add counter-analytics-vue
26+
```
27+
28+
Or with pnpm:
29+
30+
```
31+
pnpm add counter-analytics-vue
32+
```
33+
34+
### Basic usage
35+
36+
You can now import, and use the Counter Analytics hook on your project:
37+
38+
```typescript
39+
// ./src/main.ts
40+
41+
import { createApp } from 'vue'
42+
import CounterAnalytics from 'counter-analytics-vue'
43+
44+
const app = createApp({})
45+
46+
app.use(CounterAnalytics, {
47+
id: 'COUNTER_ANALYTICS_ID',
48+
utcOffset: 0,
49+
})
50+
```
51+
52+
### Advanced options
53+
You can use `useCounterAnalytics` hook, it accepts an option object as the parameter.
54+
55+
You can always [create an issue](https://github.com/ansidev/counter-analytics-vue/issues/new) in case of any questions! 😀
56+
57+
## Contribution
58+
59+
Feel free to contribute to the source code by opening a pull requests.
60+
61+
For any questions, you can [open an issue](https://github.com/ansidev/counter-analytics-vue/issues/new), refer to the official [Counter project](https://github.com/ihucos/counter.dev) or reach them at `hey@counter.dev`.
62+
63+
## Donate
64+
65+
You can support this project by donating me at:
66+
- [Paypal](https://paypal.me/ansidev)
67+
- [Ko-fi](https://ko-fi.com/ansidev)
68+
- [Buy me a coffee](https://buymeacoffee.com/ansidev)
69+
70+
## License
71+
72+
This source code is available under the [MIT LICENSE](/LICENSE).

commitlint.config.cjs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional']
3+
}

examples/vite/.gitignore

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

examples/vite/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../README.md

examples/vite/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Vite + Vue + TS + Counter Analytics</title>
7+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
8+
</head>
9+
<body>
10+
<div id="app" class="markdown-body"></div>
11+
<script type="module" src="/src/main.ts"></script>
12+
</body>
13+
</html>

examples/vite/package.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "example-counter-analytics-vue-vite",
3+
"private": true,
4+
"version": "1.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vue-tsc --noEmit && vite build",
9+
"preview": "vite preview"
10+
},
11+
"dependencies": {
12+
"vue": "^3.2.45",
13+
"counter-analytics-vue": "workspace:*"
14+
},
15+
"devDependencies": {
16+
"@vitejs/plugin-vue": "^4.0.0",
17+
"typescript": "^4.9.4",
18+
"vite-plugin-vue-markdown": "^0.22.1",
19+
"vite": "^4.0.3",
20+
"vue-tsc": "^1.0.16"
21+
}
22+
}

examples/vite/public/counter.svg

+12
Loading

examples/vite/public/counter_alt.svg

+5
Loading

examples/vite/public/vite.svg

+1
Loading

examples/vite/public/vue.svg

+1
Loading

0 commit comments

Comments
 (0)