Skip to content

Commit e2fa5b3

Browse files
committed
chore: setup husky
1 parent aa7e383 commit e2fa5b3

File tree

4 files changed

+176
-111
lines changed

4 files changed

+176
-111
lines changed

.gitignore

Lines changed: 104 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,106 @@
1-
# 编译生成的文件
2-
**/dist
3-
**/build
4-
**/out
5-
6-
# 开发过程中产生的文件
7-
**/node_modules
8-
**/bower_components
9-
**/jspm_packages
10-
**/flow-typed
11-
**/coverage
12-
13-
# 自动生成的文件和文件夹
14-
**/target
15-
**/.idea
16-
**/vendor
17-
**/tmp
18-
19-
# 常见的日志文件
20-
**/*.log
21-
**/*.log.*
22-
23-
# 常见的编辑器缓存文件
24-
**/*.swp
25-
**/*.swo
26-
**/*.swn
27-
28-
# 常见的文档编辑软件产生的文件
29-
~$*
30-
*.~
31-
*.bak
32-
*.tmp
33-
34-
# OSX 系统文件
35-
**/.DS_Store
36-
37-
# Windows 系统文件
38-
**/Thumbs.db
39-
**/Desktop.ini
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
dist
84+
85+
# Gatsby files
86+
.cache/
87+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
88+
# https://nextjs.org/blog/next-9-1#public-directory-support
89+
# public
90+
91+
# vuepress build output
92+
.vuepress/dist
93+
94+
# Serverless directories
95+
.serverless/
96+
97+
# FuseBox cache
98+
.fusebox/
99+
100+
# DynamoDB Local files
101+
.dynamodb/
102+
103+
# TernJS port file
104+
.tern-port
40105

41106
my-jwc-app

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
npm run lint-staged

package.json

Lines changed: 60 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,62 @@
11
{
2-
"name": "create-jwc",
3-
"version": "0.0.0",
4-
"description": "A Command Line Tool to create jwc.js project",
5-
"main": "index.js",
6-
"type": "module",
7-
"scripts": {
8-
"dev": "unbuild --stub",
9-
"build": "unbuild",
10-
"typecheck": "tsc --noEmit",
11-
"prepublishOnly": "npm run build",
12-
"lint": "eslint ."
13-
},
14-
"husky": {
15-
"hooks": {
16-
"pre-commit": "exit 0"
17-
}
18-
},
19-
"keywords": [
20-
"jwcjs"
21-
],
22-
"author": "wibus-wee <[email protected]>",
23-
"bugs": {
24-
"url": "https://github.com/jwcjs/create-jwc/issues"
25-
},
26-
"homepage": "https://github.com/jwcjs/create-jwc#readme",
27-
"repository": {
28-
"type": "git",
29-
"url": "git+https://github.com/jwcjs/create-jwc.git"
30-
},
31-
"bin": {
32-
"create-jwc": "index.js"
33-
},
34-
"license": "MIT",
35-
"devDependencies": {
36-
"@types/minimist": "^1.2.2",
37-
"@types/node": "^18.11.17",
38-
"@types/prompts": "^2.4.2",
39-
"@typescript-eslint/eslint-plugin": "^5.47.0",
40-
"@typescript-eslint/parser": "^5.47.0",
41-
"cross-spawn": "^7.0.3",
42-
"eslint": "^8.30.0",
43-
"eslint-config-prettier": "^8.5.0",
44-
"eslint-plugin-prettier": "^4.2.1",
45-
"husky": "^8.0.2",
46-
"kolorist": "^1.6.0",
47-
"lint-staged": "^13.1.0",
48-
"minimist": "^1.2.7",
49-
"prettier": "^2.8.1",
50-
"prompts": "^2.4.2",
51-
"rimraf": "^3.0.2",
52-
"ts-node": "^10.9.1",
53-
"typescript": "^4.9.4",
54-
"unbuild": "^1.0.2"
55-
},
56-
"lint-staged": {
57-
"*.{js,ts,css,json}": [
58-
"prettier --write"
59-
]
60-
}
2+
"name": "create-jwc",
3+
"version": "0.0.0",
4+
"description": "A Command Line Tool to create jwc.js project",
5+
"main": "index.js",
6+
"type": "module",
7+
"scripts": {
8+
"dev": "unbuild --stub",
9+
"build": "unbuild",
10+
"typecheck": "tsc --noEmit",
11+
"prepublishOnly": "npm run build",
12+
"lint": "eslint .",
13+
"lint-staged": "lint-staged"
14+
},
15+
"husky": {
16+
"hooks": {
17+
"pre-commit": "lint-staged"
18+
}
19+
},
20+
"keywords": [
21+
"jwcjs"
22+
],
23+
"author": "wibus-wee <[email protected]>",
24+
"bugs": {
25+
"url": "https://github.com/jwcjs/create-jwc/issues"
26+
},
27+
"homepage": "https://github.com/jwcjs/create-jwc#readme",
28+
"repository": {
29+
"type": "git",
30+
"url": "git+https://github.com/jwcjs/create-jwc.git"
31+
},
32+
"bin": {
33+
"create-jwc": "index.js"
34+
},
35+
"license": "MIT",
36+
"devDependencies": {
37+
"@types/minimist": "^1.2.2",
38+
"@types/node": "^18.11.17",
39+
"@types/prompts": "^2.4.2",
40+
"@typescript-eslint/eslint-plugin": "^5.47.0",
41+
"@typescript-eslint/parser": "^5.47.0",
42+
"cross-spawn": "^7.0.3",
43+
"eslint": "^8.30.0",
44+
"eslint-config-prettier": "^8.5.0",
45+
"eslint-plugin-prettier": "^4.2.1",
46+
"husky": "^8.0.2",
47+
"kolorist": "^1.6.0",
48+
"lint-staged": "^13.1.0",
49+
"minimist": "^1.2.7",
50+
"prettier": "^2.8.1",
51+
"prompts": "^2.4.2",
52+
"rimraf": "^3.0.2",
53+
"ts-node": "^10.9.1",
54+
"typescript": "^4.9.4",
55+
"unbuild": "^1.0.2"
56+
},
57+
"lint-staged": {
58+
"*.{js,ts,css,json}": [
59+
"prettier --write"
60+
]
61+
}
6162
}

src/index.ts

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,6 @@ function emptyDir(dir: string) {
7878
}
7979
}
8080

81-
function pkgFromUserAgent(userAgent: string | undefined) {
82-
if (!userAgent) return undefined;
83-
const pkgSpec = userAgent.split(" ")[0];
84-
const pkgSpecArr = pkgSpec.split("/");
85-
return {
86-
name: pkgSpecArr[0],
87-
version: pkgSpecArr[1],
88-
};
89-
}
90-
9181
const defaultTargetDir = "my-jwc-app";
9282

9383
const renameFiles: Record<string, string | undefined> = {
@@ -175,9 +165,9 @@ async function init() {
175165
{
176166
title: "pnpm",
177167
value: "pnpm",
178-
}
168+
},
179169
],
180-
}
170+
},
181171
],
182172
{
183173
onCancel: () => {
@@ -190,7 +180,12 @@ async function init() {
190180
process.exit(1);
191181
}
192182

193-
const { template: userTemplate, overwrite, packageName, packageManager } = result;
183+
const {
184+
template: userTemplate,
185+
overwrite,
186+
packageName,
187+
packageManager,
188+
} = result;
194189
const root = path.join(cwd, dir);
195190

196191
if (overwrite) {

0 commit comments

Comments
 (0)