@shined/doctor 0.0.32 → 0.0.34
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.
- package/README.md +148 -0
- package/README.zh-CN.md +139 -0
- package/es/cli.mjs +5 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# Doctor Engine
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/@shined/doctor)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
A high-performance code quality inspection tool powered by Rust and Node.js.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 🚀 **High Performance**: Built with Rust for maximum speed and efficiency
|
|
11
|
+
- 🔍 **Comprehensive Analysis**: Supports multiple programming languages and frameworks
|
|
12
|
+
- ⚡ **Parallel Processing**: Utilizes multi-threading for faster code scanning
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @shined/doctor
|
|
18
|
+
# or
|
|
19
|
+
yarn add @shined/doctor
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @shined/doctor
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick Start
|
|
25
|
+
|
|
26
|
+
```javascript
|
|
27
|
+
import { Standards } from "@shined/doctor";
|
|
28
|
+
|
|
29
|
+
// Initialize Standards checker
|
|
30
|
+
const standards = Standards.create(process.cwd());
|
|
31
|
+
|
|
32
|
+
// Run all validations
|
|
33
|
+
const results = await standards.validateAll({
|
|
34
|
+
withDashboard: true,
|
|
35
|
+
quiet: false,
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Configuration
|
|
40
|
+
|
|
41
|
+
Create a `.sfconfig/spec.json` file in your project root:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"globals": {
|
|
46
|
+
"yourGlobalVar": "writable"
|
|
47
|
+
},
|
|
48
|
+
"ignore": ["**/node_modules/**", "**/dist/**", "**/build/**", "**/target/**"]
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The tool will also check for:
|
|
53
|
+
|
|
54
|
+
- `.npmrc` - NPM registry configuration
|
|
55
|
+
- `.node-version` - Node.js version specification
|
|
56
|
+
- `package.json` - Package configuration
|
|
57
|
+
|
|
58
|
+
## CLI Usage
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
# Install globally
|
|
62
|
+
npm install -g @shined/doctor
|
|
63
|
+
|
|
64
|
+
# Run analysis on current directory
|
|
65
|
+
npx @shined/doctor
|
|
66
|
+
|
|
67
|
+
# Run with verbose output
|
|
68
|
+
npx @shined/doctor --verbose
|
|
69
|
+
|
|
70
|
+
# Run with custom working directory
|
|
71
|
+
npx @shined/doctor --cwd /path/to/project
|
|
72
|
+
|
|
73
|
+
# Show help
|
|
74
|
+
npx @shined/doctor --help
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The command will:
|
|
78
|
+
|
|
79
|
+
- Check project health
|
|
80
|
+
- Show error count if any errors are found
|
|
81
|
+
- Display execution time
|
|
82
|
+
- Exit with code 1 if errors are found
|
|
83
|
+
|
|
84
|
+
## API Reference
|
|
85
|
+
|
|
86
|
+
### Class: Standards
|
|
87
|
+
|
|
88
|
+
Main class for code quality validation.
|
|
89
|
+
|
|
90
|
+
#### Static Methods
|
|
91
|
+
|
|
92
|
+
- `create(cwd: string): Standards` - Create a new Standards instance
|
|
93
|
+
|
|
94
|
+
#### Instance Methods
|
|
95
|
+
|
|
96
|
+
- `validateNpmrc(): Promise<Array<Messages>>` - Validate npmrc configuration
|
|
97
|
+
- `validateNodeVersion(): Promise<Array<Messages>>` - Validate Node.js version
|
|
98
|
+
- `validatePackageJson(): Promise<Array<Messages>>` - Validate package.json
|
|
99
|
+
- `validateLint(): Promise<Array<Messages>>` - Run linting validation
|
|
100
|
+
- `validateAll(opts?: RenderOpts): Promise<Array<Messages>>` - Run all validations
|
|
101
|
+
|
|
102
|
+
#### RenderOpts Interface
|
|
103
|
+
|
|
104
|
+
| Option | Type | Description |
|
|
105
|
+
| -------------- | ------- | ----------------------- |
|
|
106
|
+
| withDashboard | boolean | Enable dashboard view |
|
|
107
|
+
| maxRenderCount | number | Maximum items to render |
|
|
108
|
+
| quiet | boolean | Suppress output |
|
|
109
|
+
|
|
110
|
+
### Utility Functions
|
|
111
|
+
|
|
112
|
+
#### Code Statistics
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
function cloc(paths: string[], opts?: { ignore?: string[] }): LanguageStats[];
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### Debug Functions
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
function initializeLogger(level?: LogLevel): void;
|
|
122
|
+
function unSafeInnerLint(
|
|
123
|
+
globArgs: GlobArgs,
|
|
124
|
+
category: NaPiCategory
|
|
125
|
+
): Promise<Diagnostic[]>;
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Contributing
|
|
129
|
+
|
|
130
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT © [Your Name]
|
|
135
|
+
|
|
136
|
+
## Support
|
|
137
|
+
|
|
138
|
+
- Documentation: [Link to docs]
|
|
139
|
+
- Issues: [GitHub Issues]
|
|
140
|
+
- Discord: [Discord Channel]
|
|
141
|
+
|
|
142
|
+
## Acknowledgments
|
|
143
|
+
|
|
144
|
+
Built with:
|
|
145
|
+
|
|
146
|
+
- [Rust](https://www.rust-lang.org/)
|
|
147
|
+
- [Node.js](https://nodejs.org/)
|
|
148
|
+
- [oxc](https://github.com/oxc-project/oxc)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Doctor Engine
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/@shined/doctor)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
基于 Rust 和 Node.js 构建的高性能代码质量检查工具。
|
|
7
|
+
|
|
8
|
+
[English](./README.md) | 简体中文
|
|
9
|
+
|
|
10
|
+
## 特性
|
|
11
|
+
|
|
12
|
+
- 🚀 **高性能**:使用 Rust 构建,确保最大速度和效率
|
|
13
|
+
- 🔍 **全面分析**:支持多种编程语言和框架
|
|
14
|
+
- ⚡ **并行处理**:利用多线程进行更快的代码扫描
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @shined/doctor
|
|
20
|
+
# 或者
|
|
21
|
+
yarn add @shined/doctor
|
|
22
|
+
# 或者
|
|
23
|
+
pnpm add @shined/doctor
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## 快速开始
|
|
27
|
+
|
|
28
|
+
```javascript
|
|
29
|
+
import { Standards } from "@shined/doctor";
|
|
30
|
+
|
|
31
|
+
// 初始化 Standards 检查器
|
|
32
|
+
const standards = Standards.create(process.cwd());
|
|
33
|
+
|
|
34
|
+
// 运行所有验证
|
|
35
|
+
const results = await standards.validateAll();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 配置
|
|
39
|
+
|
|
40
|
+
在项目根目录创建 `.sfconfig/spec.json` 文件:
|
|
41
|
+
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"globals": {
|
|
45
|
+
"yourGlobalVar": "writable"
|
|
46
|
+
},
|
|
47
|
+
"ignore": ["**/node_modules/**", "**/dist/**", "**/build/**", "**/target/**"]
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
工具还会检查以下配置文件:
|
|
52
|
+
|
|
53
|
+
- `.npmrc` - NPM 注册表配置
|
|
54
|
+
- `.node-version` - Node.js 版本规范
|
|
55
|
+
- `package.json` - 包配置
|
|
56
|
+
|
|
57
|
+
## 命令行使用
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
# 全局安装
|
|
61
|
+
npm install -g @shined/doctor
|
|
62
|
+
|
|
63
|
+
# 在当前目录运行分析
|
|
64
|
+
npx @shined/doctor
|
|
65
|
+
|
|
66
|
+
# 显示详细输出
|
|
67
|
+
npx @shined/doctor --verbose
|
|
68
|
+
|
|
69
|
+
# 指定工作目录
|
|
70
|
+
npx @shined/doctor --cwd /path/to/project
|
|
71
|
+
|
|
72
|
+
# 显示帮助信息
|
|
73
|
+
npx @shined/doctor --help
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
命令将会:
|
|
77
|
+
|
|
78
|
+
- 检查项目健康状况
|
|
79
|
+
- 显示发现的错误数量
|
|
80
|
+
- 显示执行时间
|
|
81
|
+
- 如果发现错误则以代码 1 退出
|
|
82
|
+
|
|
83
|
+
## API 参考
|
|
84
|
+
|
|
85
|
+
### Standards 类
|
|
86
|
+
|
|
87
|
+
代码质量验证的主类。
|
|
88
|
+
|
|
89
|
+
#### 静态方法
|
|
90
|
+
|
|
91
|
+
- `create(cwd: string): Standards` - 创建新的 Standards 实例
|
|
92
|
+
|
|
93
|
+
#### 实例方法
|
|
94
|
+
|
|
95
|
+
- `validateNpmrc(): Promise<Array<Messages>>` - 验证 npmrc 配置
|
|
96
|
+
- `validateNodeVersion(): Promise<Array<Messages>>` - 验证 Node.js 版本
|
|
97
|
+
- `validatePackageJson(): Promise<Array<Messages>>` - 验证 package.json
|
|
98
|
+
- `validateLint(): Promise<Array<Messages>>` - 运行代码检查验证
|
|
99
|
+
- `validateAll(): Promise<Array<Messages>>` - 运行所有验证
|
|
100
|
+
|
|
101
|
+
### 工具函数
|
|
102
|
+
|
|
103
|
+
#### 代码统计
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
function cloc(paths: string[], opts?: { ignore?: string[] }): LanguageStats[];
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### 调试函数
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
function initializeLogger(level?: LogLevel): void;
|
|
113
|
+
function unSafeInnerLint(
|
|
114
|
+
globArgs: GlobArgs,
|
|
115
|
+
category: NaPiCategory
|
|
116
|
+
): Promise<Diagnostic[]>;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## 贡献
|
|
120
|
+
|
|
121
|
+
欢迎贡献!请查看我们的[贡献指南](CONTRIBUTING.md)了解详情。
|
|
122
|
+
|
|
123
|
+
## 许可证
|
|
124
|
+
|
|
125
|
+
MIT © [Your Name]
|
|
126
|
+
|
|
127
|
+
## 支持
|
|
128
|
+
|
|
129
|
+
- 文档:[链接到文档]
|
|
130
|
+
- 问题:[GitHub Issues]
|
|
131
|
+
- Discord:[Discord 频道]
|
|
132
|
+
|
|
133
|
+
## 致谢
|
|
134
|
+
|
|
135
|
+
基于以下技术构建:
|
|
136
|
+
|
|
137
|
+
- [Rust](https://www.rust-lang.org/)
|
|
138
|
+
- [Node.js](https://nodejs.org/)
|
|
139
|
+
- [oxc](https://github.com/oxc-project/oxc)
|
package/es/cli.mjs
CHANGED
|
@@ -8,7 +8,11 @@ cli.command('', 'check project health').option('-v, --verbose', 'Verbose output'
|
|
|
8
8
|
const cwd = options.cwd || process.cwd();
|
|
9
9
|
const standards = await __WEBPACK_EXTERNAL_MODULE__shined_doctor_binding_71127777__.Standards.create(cwd);
|
|
10
10
|
const res = await standards.validateAll();
|
|
11
|
-
|
|
11
|
+
const errorCount = res.reduce((count, msg)=>count + msg.diagnostics.filter((d)=>"Error" === d.severity).length, 0);
|
|
12
|
+
if (errorCount > 0) {
|
|
13
|
+
console.log(`Found ${errorCount} errors`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
12
16
|
const end = __WEBPACK_EXTERNAL_MODULE_node_perf_hooks_81520749__.performance.now();
|
|
13
17
|
console.log(`Time taken: ${end - start} milliseconds`);
|
|
14
18
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shined/doctor",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.34",
|
|
4
4
|
"main": "es/index.mjs",
|
|
5
5
|
"types": "es/index.d.mts",
|
|
6
6
|
"bin": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"cac": "^6.7.14",
|
|
23
|
-
"@shined/doctor-binding": "0.0.
|
|
23
|
+
"@shined/doctor-binding": "0.0.34"
|
|
24
24
|
},
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/sheinsight/doctor-engine/issues"
|