mm_https 1.6.5 → 1.6.6

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.
@@ -0,0 +1,68 @@
1
+ const jsdoc = require('eslint-plugin-jsdoc');
2
+
3
+ module.exports = [
4
+ {
5
+ files: ['lib/**/*.js'],
6
+ languageOptions: {
7
+ ecmaVersion: 2020,
8
+ sourceType: 'script'
9
+ },
10
+ plugins: {
11
+ jsdoc: jsdoc
12
+ },
13
+ rules: {
14
+ // JSDoc相关规则 - 设置为error级别强制要求
15
+ 'jsdoc/require-jsdoc': ['error', {
16
+ require: {
17
+ FunctionDeclaration: true,
18
+ MethodDefinition: true,
19
+ ClassDeclaration: true,
20
+ ArrowFunctionExpression: true
21
+ }
22
+ }],
23
+ 'jsdoc/check-param-names': 'off',
24
+ 'jsdoc/check-tag-names': 'off',
25
+ 'jsdoc/check-types': 'off',
26
+ 'jsdoc/require-param': 'off',
27
+ 'jsdoc/require-param-description': 'off',
28
+ 'jsdoc/require-returns': 'off',
29
+ 'jsdoc/require-returns-description': 'off',
30
+
31
+ // 基础语法规则
32
+ 'no-unused-vars': ['error', { args: 'none', vars: 'all' }],
33
+ 'no-console': 'warn',
34
+
35
+ // 代码风格规则
36
+ 'indent': ['error', 2],
37
+ 'quotes': ['error', 'single'],
38
+ 'semi': ['error', 'always'],
39
+ 'comma-dangle': ['error', 'never'],
40
+ 'no-trailing-spaces': 'error',
41
+ 'eol-last': 'error',
42
+ 'max-len': ['error', { code: 100 }],
43
+ 'max-lines-per-function': ['error', { max: 40 }],
44
+ 'complexity': ['error', 12],
45
+ 'max-depth': ['error', 4],
46
+ 'max-params': ['error', 4],
47
+
48
+ // 命名规则
49
+ 'id-length': ['error', {
50
+ min: 1,
51
+ max: 20,
52
+ properties: 'always'
53
+ }]
54
+ }
55
+ },
56
+ {
57
+ files: ['test/**/*.js'],
58
+ languageOptions: {
59
+ ecmaVersion: 2020,
60
+ sourceType: 'script'
61
+ },
62
+ rules: {
63
+ // 测试文件中允许使用console
64
+ 'no-console': 'off',
65
+ 'no-unused-vars': 'off'
66
+ }
67
+ }
68
+ ];
package/index.js CHANGED
@@ -56,9 +56,21 @@ class Http {
56
56
  var headers = this.changeHeaders(config.headers);
57
57
  Object.assign(this._headers, headers);
58
58
  }
59
+
60
+ this._logger = $.log || console;
59
61
  }
60
62
  }
61
63
 
64
+ /**
65
+ * 日志记录
66
+ * @param {string} level - 日志级别
67
+ * @param {string} message - 日志消息
68
+ * @param {...*} args - 日志参数
69
+ */
70
+ Http.prototype.log = function (level, message, ...args) {
71
+ this._logger[level](`[${this.constructor.name}] ${message}`, ...args);
72
+ }
73
+
62
74
  /**
63
75
  * 设置Cookie
64
76
  * @param {Object|String} cookies - Cookie字符串
@@ -351,7 +363,7 @@ Http.prototype.request = function (options) {
351
363
  });
352
364
 
353
365
  req.on("error", function (err) {
354
- $.log.debug("错误", err);
366
+ self.log("debug", "错误", err);
355
367
  resolve({
356
368
  status: 0,
357
369
  message: err.message
@@ -437,7 +449,7 @@ Http.prototype.download = async function (url, filename, auto, headers, cookie)
437
449
  filePath = null;
438
450
  }
439
451
  } else {
440
- $.log.debug('保存文件名(filename)不能为!');
452
+ this.log("debug", '保存文件名(filename)不能为!');
441
453
  }
442
454
  }
443
455
  return filePath;
@@ -450,10 +462,6 @@ Http.prototype.clear = function () {
450
462
  this._cookies = {};
451
463
  };
452
464
 
453
- if (global.$ && !$.Http) {
454
- $.Http = Http;
455
- }
456
-
457
465
  /**
458
466
  * 导出构造函数
459
467
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_https",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "description": "超级美眉HTTP请求模块 - 支持自动Cookie管理、代理设置、文件下载等功能",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -34,7 +34,7 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "https-proxy-agent": "^7.0.6",
37
- "iconv-lite": "^0.7.0",
38
- "mm_expand": "^1.9.7"
37
+ "iconv-lite": "^0.7.1",
38
+ "mm_expand": "^2.0.0"
39
39
  }
40
40
  }
@@ -1,99 +0,0 @@
1
- # mm_https模块 npm发布检查清单
2
-
3
- ## ✅ 已完成的项目
4
-
5
- ### 1. 代码重构和规范
6
- - [x] 类名和方法名使用小驼峰命名法
7
- - [x] 私有成员使用下划线前缀
8
- - [x] 变量名使用小写蛇形命名法
9
- - [x] 完整的JSDoc注释
10
- - [x] 符合ES6类和原型方法范式
11
-
12
- ### 2. 测试文件优化
13
- - [x] 创建适合npm发布的测试文件
14
- - [x] 包含基础功能测试
15
- - [x] 包含高级功能测试
16
- - [x] 包含错误处理测试
17
- - [x] 所有测试通过
18
-
19
- ### 3. 配置文件优化
20
- - [x] 更新package.json描述和关键词
21
- - [x] 添加Node.js版本要求
22
- - [x] 优化依赖管理
23
-
24
- ### 4. 功能验证
25
- - [x] 语法检查通过
26
- - [x] 依赖关系正常
27
- - [x] 模块功能完整
28
-
29
- ## 📋 npm发布前检查
30
-
31
- ### 版本管理
32
- - [ ] 确认当前版本号:1.6.4
33
- - [ ] 是否需要更新版本号
34
- - [ ] 更新CHANGELOG.md(如有)
35
-
36
- ### 文档检查
37
- - [ ] README.md内容完整且准确
38
- - [ ] 示例代码正确
39
- - [ ] 安装说明清晰
40
-
41
- ### 发布准备
42
- - [ ] 登录npm账号:`npm login`
43
- - [ ] 检查包名可用性:`npm search mm_https`
44
- - [ ] 执行发布命令:`npm publish`
45
-
46
- ## 🚀 发布命令
47
-
48
- ```bash
49
- # 登录npm(如果未登录)
50
- npm login
51
-
52
- # 检查包名是否可用
53
- npm search mm_https
54
-
55
- # 发布到npm
56
- npm publish
57
-
58
- # 或者发布为公开包(如果需要)
59
- npm publish --access public
60
- ```
61
-
62
- ## 📦 安装使用
63
-
64
- 发布后,用户可以通过以下方式安装:
65
-
66
- ```bash
67
- npm install mm_https
68
- ```
69
-
70
- 使用示例:
71
- ```javascript
72
- const { Http } = require('mm_https');
73
-
74
- async function example() {
75
- const http = new Http();
76
- const res = await http.get('https://httpbin.org/get');
77
- console.log(res.body);
78
- }
79
- ```
80
-
81
- ## 🔧 开发命令
82
-
83
- ```bash
84
- # 运行测试
85
- npm test
86
-
87
- # 开发模式
88
- npm run dev
89
-
90
- # 安装依赖
91
- npm install
92
- ```
93
-
94
- ## 📞 支持信息
95
-
96
- - 作者:邱文武
97
- - 许可证:ISC
98
- - 问题反馈:https://gitee.com/qiuwenwu91/mm_https/issues
99
- - 主页:https://gitee.com/qiuwenwu91/mm_https#readme