Skip to content

Commit 4895f57

Browse files
authored
Merge pull request #4 from anish2690/feat/types
fix: type definition support
2 parents 9624070 + d3bf082 commit 4895f57

File tree

10 files changed

+14857
-1948
lines changed

10 files changed

+14857
-1948
lines changed

.github/commit-convention.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
## Git Commit Message Convention
2+
3+
> This is adapted from [Angular's commit convention](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-angular).
4+
5+
#### TL;DR:
6+
7+
Messages must be matched by the following regex:
8+
9+
```text
10+
/^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip)(\(.+\))?: .{1,50}/
11+
```
12+
13+
#### Examples
14+
15+
Appears under "Features" header, `link` subheader:
16+
17+
```
18+
feat(link): add `force` option
19+
```
20+
21+
Appears under "Bug Fixes" header, `view` subheader, with a link to issue #28:
22+
23+
```
24+
fix(view): handle keep-alive with aborted navigations
25+
26+
close #28
27+
```
28+
29+
Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation:
30+
31+
```
32+
perf: improve guard extraction
33+
34+
BREAKING CHANGE: The 'beforeRouteEnter' option has been removed.
35+
```
36+
37+
The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header.
38+
39+
```
40+
revert: feat(compiler): add 'comments' option
41+
42+
This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
43+
```
44+
45+
### Full Message Format
46+
47+
A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**:
48+
49+
```
50+
<type>(<scope>): <subject>
51+
<BLANK LINE>
52+
<body>
53+
<BLANK LINE>
54+
<footer>
55+
```
56+
57+
The **header** is mandatory and the **scope** of the header is optional.
58+
59+
### Revert
60+
61+
If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body, it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.
62+
63+
### Type
64+
65+
If the prefix is `feat`, `fix` or `perf`, it will appear in the changelog. However, if there is any [BREAKING CHANGE](#footer), the commit will always appear in the changelog.
66+
67+
Other prefixes are up to your discretion. Suggested prefixes are `docs`, `chore`, `style`, `refactor`, and `test` for non-changelog related tasks.
68+
69+
### Scope
70+
71+
The scope could be anything specifying the place of the commit change. For example `core`, `compiler`, `ssr`, `v-model`, `transition` etc...
72+
73+
### Subject
74+
75+
The subject contains a succinct description of the change:
76+
77+
- use the imperative, present tense: "change" not "changed" nor "changes"
78+
- don't capitalize the first letter
79+
- no dot (.) at the end
80+
81+
### Body
82+
83+
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
84+
The body should include the motivation for the change and contrast this with previous behavior.
85+
86+
### Footer
87+
88+
The footer should contain any information about **Breaking Changes** and is also the place to
89+
reference GitHub issues that this commit **Closes**.
90+
91+
**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.

.gitignore

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
node_modules
2+
demo_dist
3+
coverage
4+
npm-debug.log
5+
yarn-error.log
6+
.nyc_output
7+
coverage.lcov
28
dist
3-
demo_dist
9+
package-lock.json
10+
.DS_Store
11+
temp

api-extractor.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// this the shared base config for all packages.
2+
{
3+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
4+
5+
"mainEntryPointFilePath": "./dist/src/index.d.ts",
6+
7+
"apiReport": {
8+
"enabled": true,
9+
"reportFolder": "<projectFolder>/temp/"
10+
},
11+
12+
"docModel": {
13+
"enabled": true
14+
},
15+
16+
"dtsRollup": {
17+
"enabled": true,
18+
"untrimmedFilePath": "./dist/<unscopedPackageName>.d.ts"
19+
},
20+
21+
"tsdocMetadata": {
22+
"enabled": false
23+
},
24+
25+
"messages": {
26+
"compilerMessageReporting": {
27+
"default": {
28+
"logLevel": "warning"
29+
}
30+
},
31+
32+
"extractorMessageReporting": {
33+
"default": {
34+
"logLevel": "warning",
35+
"addToApiReportFile": true
36+
},
37+
38+
"ae-missing-release-tag": {
39+
"logLevel": "none"
40+
}
41+
},
42+
43+
"tsdocMessageReporting": {
44+
"default": {
45+
"logLevel": "warning"
46+
}
47+
}
48+
}
49+
}

package.json

Lines changed: 80 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
11
{
22
"name": "vue-draggable-next",
3-
"version": "1.0.8",
4-
"description": "",
3+
"version": "2.0.0",
4+
"description": "Build Draggable component using vue 3",
55
"main": "dist/vue-draggable-next.cjs.js",
6-
"browser": "dist/vue-draggable-next.esm.js",
76
"unpkg": "dist/vue-draggable-next.global.js",
87
"jsdelivr": "dist/vue-draggable-next.global.js",
98
"module": "dist/vue-draggable-next.esm-bundler.js",
9+
"types": "dist/vue-draggable-next.d.ts",
10+
"sideEffects": false,
11+
"author": {
12+
"name": "Anish George",
13+
"email": "[email protected]"
14+
},
1015
"scripts": {
1116
"build": "rollup -c rollup.config.js",
12-
"dev": "vite serve",
13-
"start": "vite serve --mode production",
14-
"demo:build": "cross-env NODE_ENV=production vite build",
15-
"release": "bash scripts/release.sh",
1617
"build:dts": "api-extractor run --local --verbose",
18+
"release": "bash scripts/release.sh",
19+
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
20+
"size": "size-limit",
1721
"lint": "prettier -c --parser typescript \"{src,__tests__,e2e}/**/*.[jt]s?(x)\"",
1822
"lint:fix": "yarn run lint --write",
19-
"test:types": "tsc --build tsconfig.json"
20-
},
21-
"repository": {
22-
"type": "git",
23-
"url": "https://github.com/anish2690/vue-draggable-next.git"
24-
},
25-
"author": {
26-
"name": "Anish George",
27-
"email": "[email protected]"
28-
},
29-
"license": "MIT",
30-
"engines": {
31-
"node": ">=10.16.0"
23+
"test:types": "tsc --build tsconfig.json",
24+
"test:unit": "jest --coverage",
25+
"test": "yarn run test:types && yarn run test:unit && yarn run build && yarn run build:dts",
26+
"playground:dev": "vite serve",
27+
"playground:start": "vite serve --mode production",
28+
"playground:build": "cross-env NODE_ENV=production vite build"
3229
},
30+
"files": [
31+
"dist/*.js",
32+
"dist/vue-draggable-next.d.ts",
33+
"LICENSE",
34+
"README.md"
35+
],
3336
"keywords": [
3437
"typescript",
3538
"javascript",
@@ -40,30 +43,66 @@
4043
"vue-draggable",
4144
"vue-draggable-next"
4245
],
43-
"dependencies": {
44-
"sortablejs": "^1.10.2"
45-
},
46+
"license": "MIT",
4647
"devDependencies": {
47-
"@rollup/plugin-commonjs": "^14.0.0",
48-
"@rollup/plugin-node-resolve": "^8.4.0",
49-
"@rollup/plugin-replace": "^2.3.3",
50-
"@tailwindcss/ui": "^0.5.0",
51-
"@types/sortablejs": "^1.10.5",
52-
"@vue/compiler-sfc": "^3.0.0",
48+
"@microsoft/api-extractor": "7.8.1",
49+
"@rollup/plugin-alias": "^3.1.1",
50+
"@rollup/plugin-commonjs": "^16.0.0",
51+
"@rollup/plugin-node-resolve": "^10.0.0",
52+
"@rollup/plugin-replace": "^2.3.4",
53+
"@size-limit/preset-small-lib": "^4.7.0",
54+
"@tailwindcss/ui": "^0.7.2",
55+
"@types/jest": "^26.0.15",
56+
"@types/jsdom": "^16.2.5",
57+
"@types/sortablejs": "^1.10.6",
58+
"@vue/test-utils": "^2.0.0-beta.8",
59+
"codecov": "^3.8.1",
60+
"conventional-changelog-cli": "^2.1.1",
5361
"cross-env": "^7.0.2",
62+
"jest": "^26.5.3",
63+
"lint-staged": "^10.5.1",
5464
"pascalcase": "^1.0.0",
55-
"prettier": "^2.0.5",
56-
"rollup-plugin-terser": "^6.1.0",
57-
"rollup-plugin-typescript2": "^0.27.1",
58-
"tailwindcss": "^1.7.5",
59-
"ts-node": "^8.10.2",
60-
"typescript": "^3.9.7",
61-
"vite": "^1.0.0-rc.4",
62-
"vue": "^3.0.0",
63-
"vuex": "^4.0.0-beta.4"
65+
"prettier": "^2.1.2",
66+
"rollup": "^2.33.1",
67+
"rollup-plugin-terser": "^7.0.2",
68+
"rollup-plugin-typescript2": "^0.29.0",
69+
"size-limit": "^4.7.0",
70+
"sortablejs": "^1.12.0",
71+
"tailwindcss": "^1.9.6",
72+
"ts-jest": "^26.4.1",
73+
"typescript": "^4.0.5",
74+
"vite": "^1.0.0-rc.9",
75+
"vue": "^3.0.2",
76+
"vuex": "^4.0.0-rc.1",
77+
"yorkie": "^2.0.0"
78+
},
79+
"gitHooks": {
80+
"pre-commit": "lint-staged",
81+
"commit-msg": "node scripts/verifyCommit.js"
82+
},
83+
"lint-staged": {
84+
"*.js": [
85+
"prettier --write"
86+
],
87+
"*.ts?(x)": [
88+
"prettier --parser=typescript --write"
89+
]
6490
},
91+
"size-limit": [
92+
{
93+
"path": "size-checks/basic.js"
94+
}
95+
],
6596
"peerDependencies": {
66-
"sortablejs": "^1.10.2",
97+
"sortablejs": "^1.12.0",
6798
"vue": "^3.0.0"
68-
}
69-
}
99+
},
100+
"repository": {
101+
"type": "git",
102+
"url": "git+https://github.com/anish2690/vue-draggable-next.git"
103+
},
104+
"bugs": {
105+
"url": "https://github.com/anish2690/vue-draggable-next/issues"
106+
},
107+
"homepage": "https://github.com/anish2690/vue-draggable-next#readme"
108+
}

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const outputConfigs = {
4646
format: `iife`,
4747
},
4848
esm: {
49-
file: pkg.browser,
49+
file: pkg.browser || pkg.module.replace('-bundler.js', '-browser.js'),
5050
format: `es`,
5151
},
5252
}

scripts/verifyCommit.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Invoked on the commit-msg git hook by yorkie.
2+
3+
const chalk = require('chalk')
4+
const msgPath = process.env.GIT_PARAMS
5+
const msg = require('fs').readFileSync(msgPath, 'utf-8').trim()
6+
7+
const commitRE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
8+
9+
if (!commitRE.test(msg)) {
10+
console.log()
11+
console.error(
12+
` ${chalk.bgRed.white(' ERROR ')} ${chalk.red(
13+
`invalid commit message format.`
14+
)}\n\n` +
15+
chalk.red(
16+
` Proper commit message format is required for automated changelog generation. Examples:\n\n`
17+
) +
18+
` ${chalk.green(
19+
`fix(view): handle keep-alive with aborted navigations`
20+
)}\n` +
21+
` ${chalk.green(
22+
`fix(view): handle keep-alive with aborted navigations (close #28)`
23+
)}\n\n` +
24+
chalk.red(` See .github/commit-convention.md for more details.\n`)
25+
)
26+
process.exit(1)
27+
}

src/VueDraggableNext.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Sortable from 'sortablejs'
22
import { insertNodeAt, camelize, console, removeNode } from './util/helper'
3-
import { h, defineComponent, VNode, resolveComponent } from 'vue'
3+
import { h, VNode, resolveComponent, defineComponent } from 'vue'
44
// TODO
55
interface OpenObject {
66
[key: string]: any

tsconfig.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
{
2-
"include": ["src/global.d.ts", "src/**/*.ts", "__tests__/**/*.ts"],
2+
"include": [
3+
"src/global.d.ts",
4+
"src/**/*.ts",
5+
"__tests__/**/*.ts"
6+
],
37
"compilerOptions": {
48
"baseUrl": ".",
59
"rootDir": ".",
610
"outDir": "dist",
711
"sourceMap": false,
812
"noEmit": true,
9-
1013
"target": "esnext",
1114
"module": "esnext",
1215
"moduleResolution": "node",
1316
"allowJs": true,
14-
1517
"noUnusedLocals": true,
1618
"strictNullChecks": true,
1719
"noImplicitAny": true,
1820
"noImplicitThis": true,
1921
"noImplicitReturns": true,
2022
"strict": true,
2123
"isolatedModules": false,
22-
2324
"experimentalDecorators": true,
2425
"resolveJsonModule": true,
2526
"esModuleInterop": true,
2627
"removeComments": false,
2728
"jsx": "preserve",
28-
"lib": ["esnext", "dom"]
29+
"lib": [
30+
"esnext",
31+
"dom"
32+
]
2933
}
30-
}
34+
}

0 commit comments

Comments
 (0)