Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit b430316

Browse files
committed
feat: 为ts项目添加lint钩子
1 parent 44281e0 commit b430316

File tree

10 files changed

+32
-26
lines changed

10 files changed

+32
-26
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ $ npm run analyze // 可视化分析客户端打包的资源详情
208208
欢迎直接扫码加入钉钉群
209209
<img src="https://img.alicdn.com/tfs/TB1CONSclGE3KVjSZFhXXckaFXa-750-990.jpg" width="300">
210210

211+
## 本地如何调试源码并贡献你的代码
212+
213+
请查看该[wiki](https://github.com/ykfe/egg-react-ssr/wiki/%E6%9C%AC%E5%9C%B0%E5%A6%82%E4%BD%95%E8%B0%83%E8%AF%95%E6%BA%90%E7%A0%81%E5%B9%B6%E8%B4%A1%E7%8C%AE%E4%BD%A0%E7%9A%84%E4%BB%A3%E7%A0%81)
214+
211215
## Contributors
212216

213217
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"example": "example"
99
},
1010
"scripts": {
11-
"standard": "standard",
11+
"standard": "standard --fix",
1212
"install": "lerna bootstrap",
1313
"test": "echo \"Error: no test specified\" && exit 1",
1414
"docs:dev": "vuepress dev docs",

packages/yk-cli/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"main": "./bin/index.js",
66
"types": "types/index.d.ts",
77
"scripts": {
8-
"lint": "tslint --project . src/**/*.ts",
9-
"lint:fix": "tslint --fix src/**/*.ts",
8+
"lint": "tslint -c tslint.json -p .",
9+
"lint:fix": "tslint -c tslint.json -p . --fix",
1010
"build": "rm -rf ./bin && tsc --project ./tsconfig.json --sourceMap false",
1111
"start": "node --inspect=19229 ./bin/index.js",
1212
"dev": "rm -rf ./bin && tsc -w"
@@ -24,6 +24,9 @@
2424
"@typescript-eslint/eslint-plugin"
2525
]
2626
},
27+
"pre-commit": [
28+
"lint:fix"
29+
],
2730
"dependencies": {
2831
"download-git-repo": "^2.0.0",
2932
"inquirer": "6.3.1",
@@ -37,6 +40,7 @@
3740
"@types/nunjucks": "^3.1.1",
3841
"@types/shelljs": "^0.8.5",
3942
"@types/yargs": "^13.0.0",
43+
"pre-commit": "^1.2.2",
4044
"tslint": "^5.17.0",
4145
"tslint-config-standard": "^8.0.1",
4246
"typescript": "^3.5.2"

packages/yk-cli/src/check.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,19 @@ import shell from 'shelljs'
1313
*/
1414
export function checkRepeat (option: Optional): Promise<void> {
1515
const { appName } = option
16-
return new Promise<void>((resolve, reject) => {
16+
return new Promise<void>(async (resolve, reject) => {
1717
if (fs.existsSync(`./${appName}`)) {
18-
inquirer.prompt([{
18+
const answers: any = await inquirer.prompt([{
1919
type: 'confirm',
2020
message: `当前文件夹下含有您要创建 ${appName} 的应用名称文件,是否强制删除文件 继续初始化?`,
2121
name: 'delete',
2222
default: 'Yes'
23-
}]).then(async (answers: any) => {
24-
if (answers.delete) {
25-
shell.rm('-rf', `./${appName}`)
26-
console.log(`原文件已经成功删除...`)
27-
resolve()
28-
} else process.exit()
29-
})
23+
}])
24+
if (answers.delete) {
25+
shell.rm('-rf', `./${appName}`)
26+
console.log(`原文件已经成功删除...`)
27+
resolve()
28+
} else process.exit()
3029
} else resolve()
3130
}).catch(err => processError(err))
3231
}

packages/yk-cli/src/config.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import inquirer from 'inquirer'
1010
* @returns {Promise<void>}
1111
*/
1212
export function getConfig (option: Optional): Promise<void> {
13-
return new Promise<void>((resolve, reject) => {
14-
inquirer.prompt([{
13+
return new Promise<void>(async (resolve, reject) => {
14+
const answers: any = await inquirer.prompt([{
1515
type: 'input',
1616
message: '应用名称:',
1717
name: 'appName',
@@ -25,9 +25,9 @@ export function getConfig (option: Optional): Promise<void> {
2525
'javascript'
2626
// 'typescript(开发中)'
2727
]
28-
}]).then((answers: any) => {
29-
Object.assign(option, answers)
30-
resolve()
31-
})
28+
}])
29+
30+
Object.assign(option, answers)
31+
resolve()
3232
}).catch(err => processError(err))
3333
}

packages/yk-cli/src/update.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { getWithPromise, execWithPromise, processError, resolveApp } from './uti
22
import ora from 'ora'
33
const spinner = ora('发现本地版本较旧,尝试更新yk-cli脚手架')
44
const url = 'https://raw.githubusercontent.com/ykfe/egg-react-ssr/master/packages/yk-cli/package.json'
5+
56
/**
67
* 判断NPM包自动更新
78
*

packages/yk-cli/types/package.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import { Optional } from './interface/option';
66
* @param {Optional} option 应用全局配置
77
* @returns {Promise<void>}
88
*/
9-
export declare function processPackage(option: Optional): Promise<void>;
9+
export declare function processPackage(option: Optional): void;

packages/yk-cli/types/update.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
* @param {Optional} option 全局应用配置
66
* @returns {Promise<void>}
77
*/
8-
export declare function update(): Promise<void>;
8+
export declare function updateCli(): Promise<void>;

packages/yk-cli/types/util/index.d.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
import { exec } from 'child_process';
33
import { Optional } from '../interface/option';
44
export declare const processError: (err: string) => void;
5-
export declare const execPromise: typeof exec.__promisify__;
6-
export declare const downloadPromise: Function;
5+
export declare const execWithPromise: typeof exec.__promisify__;
6+
export declare const downloadWithPromise: Function;
77
export declare const resolveApp: (source: string) => string;
8-
export declare const getPromise: object;
9-
8+
export declare const getWithPromise: object;
109
/**
1110
* http
1211
* 缓存判断是否有效处理
@@ -15,7 +14,6 @@ export declare const getPromise: object;
1514
* @returns {Promise<boolean>}
1615
*/
1716
export declare function getVersionEffective(option: Optional): Promise<boolean>;
18-
1917
/**
2018
* 渲染 Nunjuncks
2119
*

packages/yk-cli/types/webpackconfig.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ import { Optional } from './interface/option';
66
* @param {Optional} option
77
* @returns {Promise<void>}
88
*/
9-
export declare function processWebpack(option: Optional): Promise<void>;
9+
export declare function processWebpack(option: Optional): void;

0 commit comments

Comments
 (0)