qingtui-h5package-sdk 0.0.2 → 0.1.0

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 CHANGED
@@ -1,6 +1,5 @@
1
1
  # qingtui-h5package-sdk
2
2
 
3
-
4
3
  ## 安装
5
4
 
6
5
  ```bash
@@ -10,6 +9,7 @@ npm install qingtui-h5package-sdk --save-dev
10
9
  ## 命令列表
11
10
 
12
11
  ### pack
12
+
13
13
  本地离线包资源打包,在本地输出打包后的离线资源文件,文件格式为.zip。
14
14
  用法:
15
15
 
@@ -17,8 +17,9 @@ npm install qingtui-h5package-sdk --save-dev
17
17
  npx h5package pack
18
18
  ```
19
19
 
20
+ ## 配置文件
20
21
 
21
- ## 打包配置文件 Config
22
+ 在项目根目录下新建 localresource.json
22
23
 
23
24
  ```js
24
25
  {
@@ -45,4 +46,3 @@ npx h5package pack
45
46
  externalAssets: string[];
46
47
  }
47
48
  ```
48
-
@@ -7,8 +7,7 @@ exports.PackagePacker = exports.urlToPath = exports.MAX_PATH_LENGTH = void 0;
7
7
  const archiver_1 = __importDefault(require("archiver"));
8
8
  const fs_extra_1 = __importDefault(require("fs-extra"));
9
9
  const path_1 = __importDefault(require("path"));
10
- const download_1 = __importDefault(require("download"));
11
- const glob_1 = __importDefault(require("glob"));
10
+ const glob_1 = require("glob");
12
11
  // 文件路径最大长度是100,扣除"web_assets/"目录,实际最大长度是89;
13
12
  exports.MAX_PATH_LENGTH = 88;
14
13
  function urlToPath(url) {
@@ -73,7 +72,7 @@ class PackagePacker {
73
72
  }
74
73
  async appendDirectory(url, directory) {
75
74
  const prefixURL = new URL(url);
76
- const files = glob_1.default.sync('**/*', { cwd: directory, nodir: true });
75
+ const files = (0, glob_1.globSync)('**/*', { cwd: directory, nodir: true });
77
76
  for (const file of files) {
78
77
  const filename = path_1.default.join(directory, file);
79
78
  const fullUrl = new URL(path_1.default.join(prefixURL.pathname, file), prefixURL.origin).toString();
@@ -81,7 +80,11 @@ class PackagePacker {
81
80
  }
82
81
  }
83
82
  async appendUrl(url) {
84
- const content = await (0, download_1.default)(url);
83
+ // got 12+ 为纯 ESM 包,CJS 产物中需通过动态 import 加载
84
+ const { default: got } = await import('got');
85
+ // 显式声明 responseType 并先 await 响应,避免将 CancelableRequest 误传给 append
86
+ const response = await got(url, { responseType: 'buffer' });
87
+ const content = response.body;
85
88
  this.arch.append(content, { name: urlToPath(url) });
86
89
  }
87
90
  async appendBizData(bizData) {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "qingtui-h5package-sdk",
3
- "version": "0.0.2",
3
+ "version": "0.1.0",
4
4
  "description": "轻推H5离线包工具",
5
5
  "main": "dist/index.js",
6
6
  "directories": {
7
7
  "dist": "dist"
8
8
  },
9
9
  "bin": {
10
- "h5package": "./dist/cli/h5package.js"
10
+ "h5package": "dist/cli/h5package.js"
11
11
  },
12
12
  "files": [
13
13
  "dist"
@@ -23,40 +23,35 @@
23
23
  "keywords": [
24
24
  "qingtui"
25
25
  ],
26
- "author": "paseo",
26
+ "author": "qingtui@developer",
27
27
  "license": "MIT",
28
28
  "devDependencies": {
29
29
  "@changesets/cli": "^2.26.0",
30
30
  "@tsconfig/node12": "^1.0.11",
31
31
  "@tsconfig/node14": "^1.0.3",
32
32
  "@types/ali-oss": "^6.16.6",
33
- "@types/archiver": "^5.3.1",
34
- "@types/download": "^8.0.1",
33
+ "@types/archiver": "^6.0.4",
35
34
  "@types/fs-extra": "^9.0.13",
36
35
  "@types/jest": "^29.2.3",
37
36
  "@types/node": "^18.11.9",
38
- "@types/uuid": "^8.3.4",
39
37
  "@typescript-eslint/eslint-plugin": "^5.44.0",
40
38
  "@typescript-eslint/parser": "^5.44.0",
41
39
  "cz-conventional-changelog": "^3.3.0",
42
- "decompress": "^4.2.1",
43
40
  "eslint": "^8.28.0",
44
41
  "jest": "^29.3.1",
45
42
  "ts-jest": "^29.0.3",
46
43
  "typescript": "^4.9.3"
47
44
  },
48
45
  "dependencies": {
49
- "archiver": "^5.3.1",
46
+ "archiver": "^7.0.1",
50
47
  "commander": "^9.4.1",
51
- "download": "^8.0.0",
52
48
  "fs-extra": "^10.1.0",
53
- "glob": "^8.0.3",
54
- "md5-file": "^5.0.0",
55
- "uri-js": "^4.4.1",
56
- "uuid": "^9.0.0"
49
+ "glob": "^10.4.3",
50
+ "got": "^13.0.0",
51
+ "md5-file": "^5.0.0"
57
52
  },
58
53
  "engines": {
59
- "node": ">=14.0.0"
54
+ "node": ">=16.0.0"
60
55
  },
61
56
  "publishConfig": {
62
57
  "registry": "https://registry.npmjs.org/"