create-mcp-kit 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/index.js +19 -16
  2. package/package.json +8 -3
  3. package/template/client-js/.env.hbs +0 -0
  4. package/template/client-js/.gitignore.hbs +112 -0
  5. package/template/client-js/.nvmrc.hbs +1 -0
  6. package/template/client-js/.prettierrc.hbs +13 -0
  7. package/template/client-js/LICENSE.hbs +21 -0
  8. package/template/client-js/_github/workflows/build.yml.hbs +39 -0
  9. package/template/client-js/_github/workflows/npm-publish.yml.hbs +41 -0
  10. package/template/client-js/_husky/commit-msg.hbs +3 -0
  11. package/template/client-js/_husky/pre-commit.hbs +3 -0
  12. package/template/client-js/changelog-option.js.hbs +89 -0
  13. package/template/client-js/commitlint.config.js.hbs +27 -0
  14. package/template/client-js/eslint.config.js.hbs +48 -0
  15. package/template/client-js/jsconfig.json.hbs +21 -0
  16. package/template/client-js/lint-staged.config.js.hbs +5 -0
  17. package/template/client-js/package.json.hbs +66 -0
  18. package/template/client-js/scripts/base.js.hbs +65 -0
  19. package/template/client-js/scripts/build.js.hbs +4 -0
  20. package/template/client-js/scripts/dev.js.hbs +7 -0
  21. package/template/client-js/src/index.js.hbs +153 -0
  22. package/template/client-js/tests/index.test.js.hbs +22 -0
  23. package/template/client-js/tests/utils.js.hbs +18 -0
  24. package/template/client-js/vitest.config.js.hbs +27 -0
  25. package/template/client-js/vitest.global.js.hbs +21 -0
  26. package/template/client-ts/.env.hbs +0 -0
  27. package/template/client-ts/.gitignore.hbs +112 -0
  28. package/template/client-ts/.nvmrc.hbs +1 -0
  29. package/template/client-ts/.prettierrc.hbs +13 -0
  30. package/template/client-ts/LICENSE.hbs +21 -0
  31. package/template/client-ts/_github/workflows/build.yml.hbs +39 -0
  32. package/template/client-ts/_github/workflows/npm-publish.yml.hbs +41 -0
  33. package/template/client-ts/_husky/commit-msg.hbs +3 -0
  34. package/template/client-ts/_husky/pre-commit.hbs +3 -0
  35. package/template/client-ts/changelog-option.js.hbs +89 -0
  36. package/template/client-ts/commitlint.config.js.hbs +27 -0
  37. package/template/client-ts/eslint.config.js.hbs +55 -0
  38. package/template/client-ts/lint-staged.config.js.hbs +5 -0
  39. package/template/client-ts/package.json.hbs +73 -0
  40. package/template/client-ts/scripts/base.js.hbs +65 -0
  41. package/template/client-ts/scripts/build.js.hbs +4 -0
  42. package/template/client-ts/scripts/dev.js.hbs +7 -0
  43. package/template/client-ts/src/index.ts.hbs +153 -0
  44. package/template/client-ts/tests/index.test.ts.hbs +22 -0
  45. package/template/client-ts/tests/utils.ts.hbs +22 -0
  46. package/template/client-ts/tsconfig.json.hbs +21 -0
  47. package/template/client-ts/vitest.config.ts.hbs +27 -0
  48. package/template/client-ts/vitest.global.ts.hbs +21 -0
  49. package/template/server-js/jsconfig.json.hbs +5 -1
  50. package/template/server-js/package.json.hbs +6 -4
  51. package/template/server-js/src/services/web.js.hbs +1 -1
  52. package/template/server-js/tests/utils.js.hbs +18 -0
  53. package/template/server-js/vitest.config.js.hbs +17 -0
  54. package/template/server-js/vitest.global.js.hbs +25 -0
  55. package/template/server-js/vitest.setup.js.hbs +31 -8
  56. package/template/server-ts/package.json.hbs +9 -7
  57. package/template/server-ts/src/services/web.ts.hbs +1 -1
  58. package/template/server-ts/tests/utils.ts.hbs +22 -0
  59. package/template/server-ts/tsconfig.json.hbs +5 -1
  60. package/template/server-ts/vitest.config.ts.hbs +17 -0
  61. package/template/server-ts/vitest.global.ts.hbs +25 -0
  62. package/template/server-ts/vitest.setup.ts.hbs +31 -14
@@ -0,0 +1,65 @@
1
+ import path from 'path'
2
+ import { fileURLToPath } from 'url'
3
+ import { spawn } from 'child_process'
4
+ import { rimraf } from 'rimraf'
5
+
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
7
+ const isProd = process.env.NODE_ENV === 'production'
8
+ const isDev = process.env.NODE_ENV === 'local'
9
+ let nodeProcess = null
10
+
11
+ {{#if (or (includes transports 'streamable') (includes transports 'sse'))}}
12
+ if (isDev) {
13
+ spawn('npx', ['-y', '@my-mcp-hub/node-mcp-server', 'web'], {
14
+ stdio: 'inherit',
15
+ })
16
+ }
17
+
18
+ {{/if}}
19
+ /** @type {import('esbuild').BuildOptions} */
20
+ export const config = {
21
+ entryPoints: [path.resolve(__dirname, '../src/index.js')],
22
+ outfile: path.resolve(__dirname, '../build/index.js'),
23
+ format: 'esm',
24
+ bundle: true,
25
+ sourcemap: isDev,
26
+ minify: isProd,
27
+ platform: 'node',
28
+ external: ['dotenv', 'timers/promises', '@modelcontextprotocol/sdk'],
29
+ alias: {
30
+ '@': path.resolve(__dirname, '../src'),
31
+ },
32
+ plugins: [
33
+ {
34
+ name: 'build-plugin',
35
+ setup(build) {
36
+ build.onStart(async result => {
37
+ await before(result)
38
+ })
39
+ build.onEnd(async result => {
40
+ await after(result)
41
+ })
42
+ },
43
+ },
44
+ ],
45
+ }
46
+
47
+ const before = async () => {
48
+ await rimraf('build')
49
+ }
50
+
51
+ const after = async result => {
52
+ if (isDev) {
53
+ if (result.errors.length === 0) {
54
+ console.log('✅ Rebuild succeeded')
55
+ } else {
56
+ console.error('❌ Rebuild failed')
57
+ }
58
+ if (nodeProcess) {
59
+ nodeProcess.kill('SIGINT')
60
+ }
61
+ nodeProcess = spawn('node', ['./src/index.js'], {
62
+ stdio: 'inherit',
63
+ })
64
+ }
65
+ }
@@ -0,0 +1,4 @@
1
+ import esbuild from 'esbuild'
2
+ import { config } from './base.js'
3
+
4
+ esbuild.build(config).catch(() => process.exit(1))
@@ -0,0 +1,7 @@
1
+ import { context } from 'esbuild'
2
+ import { config } from './base.js'
3
+
4
+ const ctx = await context(config)
5
+ await ctx.watch()
6
+
7
+ console.log('🔍 Watching for changes...')
@@ -0,0 +1,153 @@
1
+ import 'dotenv/config'
2
+ import { setTimeout as sleep } from 'timers/promises'
3
+ import { Client } from '@modelcontextprotocol/sdk/client/index.js'
4
+ {{#if (includes transports 'stdio')}}
5
+ import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
6
+ {{/if}}
7
+ {{#if (includes transports 'streamable')}}
8
+ import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'
9
+ {{/if}}
10
+ {{#if (includes transports 'sse')}}
11
+ import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js'
12
+ {{/if}}
13
+ {{#if (includes transports 'stdio')}}
14
+
15
+ export async function testStdioTransport() {
16
+ console.log('start stdio client transport')
17
+ const client = new Client({
18
+ name: 'mcp-stdio-client',
19
+ version: '1.0.0',
20
+ })
21
+
22
+ const stdioClientTransport = new StdioClientTransport({
23
+ command: 'npx',
24
+ args: ['-y', '@my-mcp-hub/node-mcp-server'],
25
+ env: {
26
+ ...process.env,
27
+ },
28
+ })
29
+
30
+ try {
31
+ await client.connect(stdioClientTransport)
32
+ console.log('stdio client transport connected')
33
+
34
+ const { tools } = await client.listTools()
35
+ console.log(tools.map(item => item.name))
36
+ console.log('stdio client transport tools listed')
37
+
38
+ const callResult = await client.callTool({
39
+ name: 'GetData',
40
+ arguments: {
41
+ keyword: 'Hello',
42
+ },
43
+ })
44
+ console.log(callResult.content)
45
+ console.log('stdio client transport call tool done')
46
+ } catch (error) {
47
+ console.error('stdio transport error:', error)
48
+ } finally {
49
+ await client.close()
50
+ console.log('stdio client transport closed')
51
+ }
52
+
53
+ console.log('stdio client transport done\n\n')
54
+ await sleep(1000)
55
+ }
56
+ {{/if}}
57
+ {{#if (includes transports 'streamable')}}
58
+
59
+ export async function testStreamableHttpTransport() {
60
+ console.log('start streamable http client transport')
61
+ const client = new Client({
62
+ name: 'mcp-http-client',
63
+ version: '1.0.0',
64
+ })
65
+
66
+ const streamableBaseUrl = new URL('http://localhost:8401/mcp')
67
+ const streamableClientTransport = new StreamableHTTPClientTransport(streamableBaseUrl)
68
+
69
+ try {
70
+ await client.connect(streamableClientTransport)
71
+ console.log('streamable http client transport connected')
72
+
73
+ const { tools } = await client.listTools()
74
+ console.log(tools.map(item => item.name))
75
+ console.log('streamable http client transport tools listed')
76
+
77
+ const callResult = await client.callTool({
78
+ name: 'GetData',
79
+ arguments: {
80
+ keyword: 'Hello',
81
+ },
82
+ })
83
+ console.log(callResult.content)
84
+ console.log('streamable http client transport call tool done')
85
+ } catch (error) {
86
+ console.error('streamable http transport error:', error)
87
+ } finally {
88
+ await client.close()
89
+ console.log('streamable http client transport closed')
90
+ }
91
+
92
+ console.log('streamable http client transport done\n\n')
93
+ await sleep(1000)
94
+ }
95
+ {{/if}}
96
+ {{#if (includes transports 'sse')}}
97
+
98
+ export async function testSSETransport() {
99
+ console.log('start sse client transport')
100
+ const client = new Client({
101
+ name: 'mcp-sse-client',
102
+ version: '1.0.0',
103
+ })
104
+
105
+ const sseBaseUrl = new URL('http://localhost:8401/sse')
106
+ const sseClientTransport = new SSEClientTransport(sseBaseUrl)
107
+
108
+ try {
109
+ await client.connect(sseClientTransport)
110
+ console.log('sse client transport connected')
111
+
112
+ const { tools } = await client.listTools()
113
+ console.log(tools.map(item => item.name))
114
+ console.log('sse client transport tools listed')
115
+
116
+ const callResult = await client.callTool({
117
+ name: 'GetData',
118
+ arguments: {
119
+ keyword: 'Hello',
120
+ },
121
+ })
122
+ console.log(callResult.content)
123
+ console.log('sse client transport call tool done')
124
+ } catch (error) {
125
+ console.error('sse transport error:', error)
126
+ } finally {
127
+ await client.close()
128
+ console.log('sse client transport closed')
129
+ }
130
+
131
+ console.log('sse client transport done\n\n')
132
+ await sleep(1000)
133
+ }
134
+ {{/if}}
135
+
136
+ async function main() {
137
+ try {
138
+ {{#if (includes transports 'stdio')}}
139
+ await testStdioTransport()
140
+ {{/if}}
141
+ {{#if (includes transports 'streamable')}}
142
+ await testStreamableHttpTransport()
143
+ {{/if}}
144
+ {{#if (includes transports 'sse')}}
145
+ await testSSETransport()
146
+ {{/if}}
147
+ } catch (error) {
148
+ console.error('Main error:', error)
149
+ process.exit(1)
150
+ }
151
+ }
152
+
153
+ await main()
@@ -0,0 +1,22 @@
1
+ {{#if (includes plugins 'vitest')}}
2
+ import { describe, test } from 'vitest'
3
+ import { {{#each transports}} {{~#if (eq this "stdio")}}testStdioTransport{{/if}} {{~#if (eq this "streamable")}}testStreamableHttpTransport{{/if}} {{~#if (eq this "sse")}}testSSETransport{{/if}}{{~#unless @last}}, {{/unless}}{{/each}} } from '@/index.js'
4
+
5
+ describe('MCP client', () => {
6
+ {{#if (includes transports 'stdio')}}
7
+ test('stdio transport', async () => {
8
+ await testStdioTransport()
9
+ })
10
+ {{/if}}
11
+ {{#if (includes transports 'streamable')}}
12
+ test('streamable http transport', async () => {
13
+ await testStreamableHttpTransport()
14
+ })
15
+ {{/if}}
16
+ {{#if (includes transports 'sse')}}
17
+ test('sse transport', async () => {
18
+ await testSSETransport()
19
+ })
20
+ {{/if}}
21
+ })
22
+ {{/if}}
@@ -0,0 +1,18 @@
1
+ {{#if (includes plugins 'vitest')}}
2
+ export function waitForValue(getterFn, checkInterval = 100, timeout = 10000) {
3
+ return new Promise((resolve, reject) => {
4
+ const start = Date.now()
5
+
6
+ const intervalId = setInterval(() => {
7
+ const value = getterFn()
8
+ if (value) {
9
+ clearInterval(intervalId)
10
+ resolve(value)
11
+ } else if (Date.now() - start > timeout) {
12
+ clearInterval(intervalId)
13
+ reject(new Error('Timeout waiting for value'))
14
+ }
15
+ }, checkInterval)
16
+ })
17
+ }
18
+ {{/if}}
@@ -0,0 +1,27 @@
1
+ {{#if (includes plugins 'vitest')}}
2
+ import { defineConfig } from 'vitest/config'
3
+
4
+ export default defineConfig({
5
+ resolve: {
6
+ alias: {
7
+ '@': '/src',
8
+ },
9
+ },
10
+ test: {
11
+ {{#if (or (includes transports 'streamable') (includes transports 'sse'))}}
12
+ globalSetup: ['./vitest.global.js'],
13
+ {{/if}}
14
+ coverage: {
15
+ include: ['src/**/*.js'],
16
+ reporter: ['text', 'lcov', 'html'],
17
+ },
18
+ pool: 'threads',
19
+ poolOptions: {
20
+ threads: {
21
+ maxThreads: 1,
22
+ minThreads: 1,
23
+ },
24
+ },
25
+ },
26
+ })
27
+ {{/if}}
@@ -0,0 +1,21 @@
1
+ {{#if (and (includes plugins 'vitest') (or (includes transports 'streamable') (includes transports 'sse')))}}
2
+ import { spawn } from 'child_process'
3
+ import { waitForValue } from './tests/utils'
4
+
5
+ export default async function setup() {
6
+ const webProcess = spawn('npx', ['-y', '@my-mcp-hub/node-mcp-server', 'web'], {
7
+ stdio: 'pipe',
8
+ })
9
+ let webStarted = false
10
+ webProcess.stdout.on('data', async (data) => {
11
+ const output = data.toString()
12
+ if (output.includes('MCP server started')) {
13
+ webStarted = true
14
+ }
15
+ });
16
+ await waitForValue(() => webStarted)
17
+ return () => {
18
+ webProcess.kill('SIGINT')
19
+ }
20
+ }
21
+ {{/if}}
File without changes
@@ -0,0 +1,112 @@
1
+ .DS_Store
2
+ .idea/
3
+ # Logs
4
+ logs
5
+ *.log
6
+ npm-debug.log*
7
+ yarn-debug.log*
8
+ yarn-error.log*
9
+ lerna-debug.log*
10
+
11
+ # Diagnostic reports (https://nodejs.org/api/report.html)
12
+ report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
13
+
14
+ # Runtime data
15
+ pids
16
+ *.pid
17
+ *.seed
18
+ *.pid.lock
19
+
20
+ # Directory for instrumented libs generated by jscoverage/JSCover
21
+ lib-cov
22
+
23
+ # Coverage directory used by tools like istanbul
24
+ coverage
25
+ *.lcov
26
+
27
+ # nyc test coverage
28
+ .nyc_output
29
+
30
+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
31
+ .grunt
32
+
33
+ # Bower dependency directory (https://bower.io/)
34
+ bower_components
35
+
36
+ # node-waf configuration
37
+ .lock-wscript
38
+
39
+ # Compiled binary addons (https://nodejs.org/api/addons.html)
40
+ build/Release
41
+
42
+ # Dependency directories
43
+ node_modules/
44
+ jspm_packages/
45
+
46
+ # TypeScript v1 declaration files
47
+ typings/
48
+
49
+ # TypeScript cache
50
+ *.tsbuildinfo
51
+
52
+ # Optional npm cache directory
53
+ .npm
54
+
55
+ # Optional eslint cache
56
+ .eslintcache
57
+
58
+ # Microbundle cache
59
+ .rpt2_cache/
60
+ .rts2_cache_cjs/
61
+ .rts2_cache_es/
62
+ .rts2_cache_umd/
63
+
64
+ # Optional REPL history
65
+ .node_repl_history
66
+
67
+ # Output of 'npm pack'
68
+ *.tgz
69
+
70
+ # Yarn Integrity file
71
+ .yarn-integrity
72
+
73
+ # dotenv environment variables file
74
+ #.env
75
+ .env.test
76
+
77
+ # parcel-bundler cache (https://parceljs.org/)
78
+ .cache
79
+
80
+ # Next.js build output
81
+ .next
82
+
83
+ # Nuxt.js build / generate output
84
+ .nuxt
85
+ dist
86
+
87
+ # Gatsby files
88
+ .cache/
89
+ # Comment in the public line in if your project uses Gatsby and *not* Next.js
90
+ # https://nextjs.org/blog/next-9-1#public-directory-support
91
+ # public
92
+
93
+ # vuepress build output
94
+ .vuepress/dist
95
+
96
+ # Serverless directories
97
+ .serverless/
98
+
99
+ # FuseBox cache
100
+ .fusebox/
101
+
102
+ # DynamoDB Local files
103
+ .dynamodb/
104
+
105
+ # TernJS port file
106
+ .tern-port
107
+
108
+ /docs/.vitepress/cache/
109
+
110
+ stats.html
111
+
112
+ build/
@@ -0,0 +1 @@
1
+ v22
@@ -0,0 +1,13 @@
1
+ {{#if (includes plugins 'style')}}
2
+ {
3
+ "tabWidth": 2,
4
+ "printWidth": 120,
5
+ "useTabs": false,
6
+ "semi": false,
7
+ "singleQuote": true,
8
+ "trailingComma": "all",
9
+ "bracketSpacing": true,
10
+ "jsxBracketSameLine": false,
11
+ "arrowParens": "avoid"
12
+ }
13
+ {{/if}}
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) {{year}} {{projectName}}
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.
@@ -0,0 +1,39 @@
1
+ {{#if (includes plugins 'github-action')}}
2
+ name: build
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ build:
11
+ if: github.repository == '{{projectName}}'
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v4
16
+ with:
17
+ fetch-depth: 0
18
+
19
+ - name: Install Node
20
+ uses: actions/setup-node@v4
21
+ with:
22
+ node-version: 22
23
+ cache: npm
24
+
25
+ - name: Install Package
26
+ run: npm i
27
+
28
+ - name: Lint
29
+ run: npm run lint
30
+
31
+ - name: Build Package
32
+ run: npm run build
33
+
34
+ - name: Test Package
35
+ run: npm run coverage
36
+
37
+ - name: Coveralls
38
+ uses: coverallsapp/github-action@v2
39
+ {{/if}}
@@ -0,0 +1,41 @@
1
+ {{#if (includes plugins 'github-action')}}
2
+ name: npm-publish
3
+
4
+ on:
5
+ release:
6
+ types: [created]
7
+
8
+ jobs:
9
+ build:
10
+ if: github.repository == '{{projectName}}'
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: read
14
+ id-token: write
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v4
18
+ with:
19
+ fetch-depth: 0
20
+
21
+ - name: Install Node
22
+ uses: actions/setup-node@v4
23
+ with:
24
+ node-version: 22
25
+ registry-url: https://registry.npmjs.org/
26
+ cache: npm
27
+
28
+ - name: Install Package
29
+ run: npm i
30
+
31
+ - name: Lint
32
+ run: npm run lint
33
+
34
+ - name: Build Package
35
+ run: npm run build
36
+
37
+ - name: Publish NPM Package
38
+ run: npm publish --provenance --access public
39
+ env:
40
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
41
+ {{/if}}
@@ -0,0 +1,3 @@
1
+ {{#if (includes plugins 'commitlint')}}
2
+ npx --no-install commitlint --edit $1
3
+ {{/if}}
@@ -0,0 +1,3 @@
1
+ {{#if (includes plugins 'style')}}
2
+ npx lint-staged
3
+ {{/if}}
@@ -0,0 +1,89 @@
1
+ {{#if (includes plugins 'changelog')}}
2
+ import compareFunc from 'compare-func'
3
+
4
+ export default {
5
+ writerOpts: {
6
+ transform: (commit, context) => {
7
+ let discard = true
8
+ const issues = []
9
+
10
+ const newCommit = {
11
+ ...commit,
12
+ notes: commit.notes.map(note => ({
13
+ ...note,
14
+ title: 'BREAKING CHANGES',
15
+ })),
16
+ }
17
+
18
+ if (newCommit.notes.length > 0) {
19
+ discard = false
20
+ }
21
+
22
+ const typeMap = {
23
+ feat: '✨ Features | 新功能',
24
+ fix: '🐛 Bug Fixes | Bug 修复',
25
+ perf: '⚡ Performance Improvements | 性能优化',
26
+ revert: '⏪ Reverts | 回退',
27
+ refactor: '♻ Code Refactoring | 代码重构',
28
+ test: '✅ Tests | 测试',
29
+ build: '👷‍ Build System | 构建',
30
+ chore: '🎫 Chores | 其他更新',
31
+ style: '💄 Styles | 风格',
32
+ ci: '🔧 Continuous Integration | CI 配置',
33
+ docs: '📝 Documentation | 文档',
34
+ }
35
+
36
+ if (typeMap[newCommit.type]) {
37
+ newCommit.type = typeMap[newCommit.type]
38
+ } else if (newCommit.type === 'revert' || newCommit.revert) {
39
+ newCommit.type = typeMap['revert']
40
+ } else if (discard) {
41
+ return
42
+ }
43
+
44
+ if (newCommit.scope === '*') {
45
+ newCommit.scope = ''
46
+ }
47
+
48
+ if (typeof newCommit.hash === 'string') {
49
+ newCommit.shortHash = newCommit.hash.substring(0, 7)
50
+ }
51
+
52
+ if (typeof newCommit.subject === 'string') {
53
+ let url = context.repository ? `${context.host}/${context.owner}/${context.repository}` : context.repoUrl
54
+
55
+ if (url) {
56
+ url = `${url}/issues/`
57
+ newCommit.subject = newCommit.subject.replace(/#([0-9]+)/g, (_, issue) => {
58
+ issues.push(issue)
59
+ return `[#${issue}](${url}${issue})`
60
+ })
61
+ }
62
+
63
+ if (context.host) {
64
+ newCommit.subject = newCommit.subject.replace(/\B@([a-z0-9](?:-?[a-z0-9/]){0,38})/g, (_, username) => {
65
+ if (username.includes('/')) {
66
+ return `@${username}`
67
+ }
68
+ return `[@${username}](${context.host}/${username})`
69
+ })
70
+ }
71
+ }
72
+
73
+ newCommit.references = newCommit.references.filter(reference => {
74
+ if (issues.indexOf(reference.issue) === -1) {
75
+ return true
76
+ }
77
+ return false
78
+ })
79
+
80
+ return newCommit
81
+ },
82
+ groupBy: 'type',
83
+ commitGroupsSort: 'title',
84
+ commitsSort: ['scope', 'subject'],
85
+ noteGroupsSort: 'title',
86
+ notesSort: compareFunc,
87
+ },
88
+ }
89
+ {{/if}}
@@ -0,0 +1,27 @@
1
+ {{#if (includes plugins 'commitlint')}}
2
+ export default {
3
+ extends: ['@commitlint/config-conventional'],
4
+ rules: {
5
+ 'type-enum': [
6
+ 2,
7
+ 'always',
8
+ [
9
+ 'feat',
10
+ 'fix',
11
+ 'docs',
12
+ 'style',
13
+ 'refactor',
14
+ 'perf',
15
+ 'test',
16
+ 'build',
17
+ 'ci',
18
+ 'chore',
19
+ 'revert',
20
+ 'build',
21
+ 'release',
22
+ ],
23
+ ],
24
+ 'subject-case': [0],
25
+ },
26
+ }
27
+ {{/if}}