@maiyunnet/kebab 9.15.5 → 9.15.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.
package/doc/kebab-rag.md CHANGED
@@ -1361,7 +1361,7 @@ index/variables/VER.md
1361
1361
 
1362
1362
  # Variable: VER
1363
1363
 
1364
- > `const` **VER**: `"9.15.5"` = `'9.15.5'`
1364
+ > `const` **VER**: `"9.15.6"` = `'9.15.6'`
1365
1365
 
1366
1366
  Defined in: [index.ts:10](https://github.com/maiyunnet/kebab/blob/master/index.ts#L10)
1367
1367
 
@@ -3351,7 +3351,7 @@ lib/core/functions/clone.md
3351
3351
 
3352
3352
  > **clone**\<`T`\>(`obj`): `T`
3353
3353
 
3354
- Defined in: [lib/core.ts:1336](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1336)
3354
+ Defined in: [lib/core.ts:1350](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1350)
3355
3355
 
3356
3356
  完整的克隆一份数组/对象
3357
3357
 
@@ -3415,7 +3415,7 @@ lib/core/functions/debug.md
3415
3415
 
3416
3416
  > **debug**(`message?`, ...`optionalParams`): `void`
3417
3417
 
3418
- Defined in: [lib/core.ts:1382](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1382)
3418
+ Defined in: [lib/core.ts:1396](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1396)
3419
3419
 
3420
3420
  打印调试信息,线上环境不会打印
3421
3421
 
@@ -3450,7 +3450,7 @@ lib/core/functions/display.md
3450
3450
 
3451
3451
  > **display**(`message?`, ...`optionalParams`): `void`
3452
3452
 
3453
- Defined in: [lib/core.ts:1395](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1395)
3453
+ Defined in: [lib/core.ts:1409](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1409)
3454
3454
 
3455
3455
  向控制台直接显示内容,一般情况下禁止使用
3456
3456
 
@@ -3538,6 +3538,13 @@ Defined in: [lib/core.ts:680](https://github.com/maiyunnet/kebab/blob/master/lib
3538
3538
 
3539
3539
  `string`
3540
3540
 
3541
+ #### timeout?
3542
+
3543
+ `number`
3544
+
3545
+ 命令超时毫秒数,超时后终止命令并以失败返回
3546
+ 默认无超时限制:不传时命令可一直运行直至完成,与 cp.exec 默认行为一致
3547
+
3541
3548
  ## Returns
3542
3549
 
3543
3550
  `Promise`\<`string` \| `false`\>
@@ -3555,7 +3562,7 @@ lib/core/functions/getLog.md
3555
3562
 
3556
3563
  > **getLog**(`opt`): `Promise`\<`false` \| \{ `list`: `any`[] \| `string`[][]; `total`: `number`; \}\>
3557
3564
 
3558
- Defined in: [lib/core.ts:1248](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1248)
3565
+ Defined in: [lib/core.ts:1262](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1262)
3559
3566
 
3560
3567
  获取日志内容为一个数组
3561
3568
 
@@ -3728,7 +3735,7 @@ lib/core/functions/loadEnv.md
3728
3735
 
3729
3736
  > **loadEnv**(`dir`): `Promise`\<`void`\>
3730
3737
 
3731
- Defined in: [lib/core.ts:1447](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1447)
3738
+ Defined in: [lib/core.ts:1461](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1461)
3732
3739
 
3733
3740
  加载 .env 文件到 process.env,若文件不存在则跳过
3734
3741
 
@@ -3757,7 +3764,7 @@ lib/core/functions/log.md
3757
3764
 
3758
3765
  > **log**(`opt`, `msg`, `fend?`): `void`
3759
3766
 
3760
- Defined in: [lib/core.ts:1135](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1135)
3767
+ Defined in: [lib/core.ts:1149](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1149)
3761
3768
 
3762
3769
  写入文件日志
3763
3770
 
@@ -3798,7 +3805,7 @@ lib/core/functions/ls.md
3798
3805
 
3799
3806
  > **ls**(`opt`): `Promise`\<`object`[]\>
3800
3807
 
3801
- Defined in: [lib/core.ts:1297](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1297)
3808
+ Defined in: [lib/core.ts:1311](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1311)
3802
3809
 
3803
3810
  获取目录内文件/文件夹列表
3804
3811
 
@@ -4168,7 +4175,7 @@ lib/core/functions/removeGlobal.md
4168
4175
 
4169
4176
  > **removeGlobal**(`key`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4170
4177
 
4171
- Defined in: [lib/core.ts:952](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L952)
4178
+ Defined in: [lib/core.ts:966](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L966)
4172
4179
 
4173
4180
  移除某个跨线程/跨内网服务器全局变量
4174
4181
 
@@ -4203,7 +4210,7 @@ lib/core/functions/resolveEnvVars.md
4203
4210
 
4204
4211
  > **resolveEnvVars**(`obj`): `void`
4205
4212
 
4206
- Defined in: [lib/core.ts:1477](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1477)
4213
+ Defined in: [lib/core.ts:1491](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1491)
4207
4214
 
4208
4215
  将配置对象中的 ${ENV_VAR} 占位符替换为 process.env 的值
4209
4216
 
@@ -4232,7 +4239,7 @@ lib/core/functions/sendNpm.md
4232
4239
 
4233
4240
  > **sendNpm**(`path`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4234
4241
 
4235
- Defined in: [lib/core.ts:851](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L851)
4242
+ Defined in: [lib/core.ts:865](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L865)
4236
4243
 
4237
4244
  向本机或局域网 RPC 发送 npm install 操作
4238
4245
 
@@ -4267,7 +4274,7 @@ lib/core/functions/sendPackage.md
4267
4274
 
4268
4275
  > **sendPackage**(`content`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4269
4276
 
4270
- Defined in: [lib/core.ts:1075](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1075)
4277
+ Defined in: [lib/core.ts:1089](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1089)
4271
4278
 
4272
4279
  向本机或局域网 RPC 发送 package.json 更新操作
4273
4280
 
@@ -4302,7 +4309,7 @@ lib/core/functions/sendPm2.md
4302
4309
 
4303
4310
  > **sendPm2**(`name`, `action?`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4304
4311
 
4305
- Defined in: [lib/core.ts:803](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L803)
4312
+ Defined in: [lib/core.ts:817](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L817)
4306
4313
 
4307
4314
  向本机或局域网 RPC 发送 PM2 操作
4308
4315
 
@@ -4343,7 +4350,7 @@ lib/core/functions/sendProject.md
4343
4350
 
4344
4351
  > **sendProject**(`path`, `key`, `value`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4345
4352
 
4346
- Defined in: [lib/core.ts:1027](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1027)
4353
+ Defined in: [lib/core.ts:1041](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1041)
4347
4354
 
4348
4355
  向本机或局域网 RPC 发送项目配置更新操作
4349
4356
 
@@ -4390,7 +4397,7 @@ lib/core/functions/sendReload.md
4390
4397
 
4391
4398
  > **sendReload**(`hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4392
4399
 
4393
- Defined in: [lib/core.ts:700](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L700)
4400
+ Defined in: [lib/core.ts:706](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L706)
4394
4401
 
4395
4402
  向主进程(或局域网同代码机子)发送广播将进行 reload 操作,等待回传
4396
4403
  主要作用除代码热更新以外的其他情况
@@ -4418,7 +4425,7 @@ lib/core/functions/sendRestart.md
4418
4425
 
4419
4426
  > **sendRestart**(`hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4420
4427
 
4421
- Defined in: [lib/core.ts:749](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L749)
4428
+ Defined in: [lib/core.ts:759](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L759)
4422
4429
 
4423
4430
  向主进程(或局域网同代码机子)发送广播将进行 restart 操作,停止监听并启动新进程,老进程在连接全部断开后自行销毁
4424
4431
  主要用作不间断的代码热更新
@@ -4493,7 +4500,7 @@ lib/core/functions/setGlobal.md
4493
4500
 
4494
4501
  > **setGlobal**(`key`, `data`, `hosts?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4495
4502
 
4496
- Defined in: [lib/core.ts:902](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L902)
4503
+ Defined in: [lib/core.ts:916](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L916)
4497
4504
 
4498
4505
  设置跨线程/指定的局域网主机的全局变量
4499
4506
 
@@ -4592,7 +4599,7 @@ lib/core/functions/updateCode.md
4592
4599
 
4593
4600
  > **updateCode**(`sourcePath`, `path`, `hosts?`, `config?`, `strict?`): `Promise`\<`Record`\<`string`, \{ `result`: `boolean`; `return`: `string`; \}\>\>
4594
4601
 
4595
- Defined in: [lib/core.ts:967](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L967)
4602
+ Defined in: [lib/core.ts:981](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L981)
4596
4603
 
4597
4604
  上传并覆盖代码文件,config.json、kebab.json、.js.map、.ts, .gitignore 不会被覆盖和新创建
4598
4605
 
@@ -4645,7 +4652,7 @@ lib/core/functions/writeEventStreamHead.md
4645
4652
 
4646
4653
  > **writeEventStreamHead**(`res`): `void`
4647
4654
 
4648
- Defined in: [lib/core.ts:1417](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1417)
4655
+ Defined in: [lib/core.ts:1431](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1431)
4649
4656
 
4650
4657
  ## Parameters
4651
4658
 
@@ -4670,7 +4677,7 @@ lib/core/functions/writeHead.md
4670
4677
 
4671
4678
  > **writeHead**(`res`, `statusCode`, `headers?`): `void`
4672
4679
 
4673
- Defined in: [lib/core.ts:1406](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1406)
4680
+ Defined in: [lib/core.ts:1420](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1420)
4674
4681
 
4675
4682
  让 res 发送头部(前提是头部没有被发送才能调用本方法
4676
4683
 
@@ -4711,7 +4718,7 @@ lib/core/functions/write.md
4711
4718
 
4712
4719
  > **write**(`res`, `data`): `void`
4713
4720
 
4714
- Defined in: [lib/core.ts:1429](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1429)
4721
+ Defined in: [lib/core.ts:1443](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1443)
4715
4722
 
4716
4723
  向 res 发送数据
4717
4724
 
@@ -4886,7 +4893,7 @@ lib/core/interfaces/ILogOptions.md
4886
4893
 
4887
4894
  # Interface: ILogOptions
4888
4895
 
4889
- Defined in: [lib/core.ts:1118](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1118)
4896
+ Defined in: [lib/core.ts:1132](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1132)
4890
4897
 
4891
4898
  log 设置的选项
4892
4899
 
@@ -4896,7 +4903,7 @@ log 设置的选项
4896
4903
 
4897
4904
  > `optional` **cookie?**: `Record`\<`string`, `string`\>
4898
4905
 
4899
- Defined in: [lib/core.ts:1124](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1124)
4906
+ Defined in: [lib/core.ts:1138](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1138)
4900
4907
 
4901
4908
  ***
4902
4909
 
@@ -4904,7 +4911,7 @@ Defined in: [lib/core.ts:1124](https://github.com/maiyunnet/kebab/blob/master/li
4904
4911
 
4905
4912
  > `optional` **get?**: `Record`\<`string`, `any`\>
4906
4913
 
4907
- Defined in: [lib/core.ts:1123](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1123)
4914
+ Defined in: [lib/core.ts:1137](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1137)
4908
4915
 
4909
4916
  ***
4910
4917
 
@@ -4912,7 +4919,7 @@ Defined in: [lib/core.ts:1123](https://github.com/maiyunnet/kebab/blob/master/li
4912
4919
 
4913
4920
  > `optional` **headers?**: `IncomingHttpHeaders`
4914
4921
 
4915
- Defined in: [lib/core.ts:1126](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1126)
4922
+ Defined in: [lib/core.ts:1140](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1140)
4916
4923
 
4917
4924
  ***
4918
4925
 
@@ -4920,7 +4927,7 @@ Defined in: [lib/core.ts:1126](https://github.com/maiyunnet/kebab/blob/master/li
4920
4927
 
4921
4928
  > `optional` **hostname?**: `string`
4922
4929
 
4923
- Defined in: [lib/core.ts:1121](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1121)
4930
+ Defined in: [lib/core.ts:1135](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1135)
4924
4931
 
4925
4932
  ***
4926
4933
 
@@ -4928,7 +4935,7 @@ Defined in: [lib/core.ts:1121](https://github.com/maiyunnet/kebab/blob/master/li
4928
4935
 
4929
4936
  > `optional` **path?**: `string`
4930
4937
 
4931
- Defined in: [lib/core.ts:1119](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1119)
4938
+ Defined in: [lib/core.ts:1133](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1133)
4932
4939
 
4933
4940
  ***
4934
4941
 
@@ -4936,7 +4943,7 @@ Defined in: [lib/core.ts:1119](https://github.com/maiyunnet/kebab/blob/master/li
4936
4943
 
4937
4944
  > `optional` **req?**: `IncomingMessage` \| `Http2ServerRequest` \| `null`
4938
4945
 
4939
- Defined in: [lib/core.ts:1122](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1122)
4946
+ Defined in: [lib/core.ts:1136](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1136)
4940
4947
 
4941
4948
  ***
4942
4949
 
@@ -4944,7 +4951,7 @@ Defined in: [lib/core.ts:1122](https://github.com/maiyunnet/kebab/blob/master/li
4944
4951
 
4945
4952
  > `optional` **session?**: `Record`\<`string`, `any`\>
4946
4953
 
4947
- Defined in: [lib/core.ts:1125](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1125)
4954
+ Defined in: [lib/core.ts:1139](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1139)
4948
4955
 
4949
4956
  ***
4950
4957
 
@@ -4952,7 +4959,7 @@ Defined in: [lib/core.ts:1125](https://github.com/maiyunnet/kebab/blob/master/li
4952
4959
 
4953
4960
  > `optional` **urlFull?**: `string`
4954
4961
 
4955
- Defined in: [lib/core.ts:1120](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1120)
4962
+ Defined in: [lib/core.ts:1134](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L1134)
4956
4963
 
4957
4964
  lib/core/type-aliases/TPm2Action.md
4958
4965
  ---
@@ -4967,7 +4974,7 @@ lib/core/type-aliases/TPm2Action.md
4967
4974
 
4968
4975
  > **TPm2Action** = `"start"` \| `"stop"` \| `"restart"`
4969
4976
 
4970
- Defined in: [lib/core.ts:795](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L795)
4977
+ Defined in: [lib/core.ts:809](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L809)
4971
4978
 
4972
4979
  PM2 操作类型
4973
4980
 
@@ -5041,7 +5048,7 @@ lib/core/variables/global.md
5041
5048
 
5042
5049
  > `const` **global**: `Record`\<`string`, `any`\> = `{}`
5043
5050
 
5044
- Defined in: [lib/core.ts:894](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L894)
5051
+ Defined in: [lib/core.ts:908](https://github.com/maiyunnet/kebab/blob/master/lib/core.ts#L908)
5045
5052
 
5046
5053
  跨进程全局变量
5047
5054
 
package/index.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  * --- 本文件用来定义每个目录实体地址的常量 ---
6
6
  */
7
7
  /** --- 当前系统版本号 --- */
8
- export declare const VER = "9.15.5";
8
+ export declare const VER = "9.15.6";
9
9
  /** --- 框架根目录,以 / 结尾 --- */
10
10
  export declare const ROOT_PATH: string;
11
11
  /** --- 框架的 LIB,以 / 结尾 --- */
package/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  * --- 本文件用来定义每个目录实体地址的常量 ---
7
7
  */
8
8
  /** --- 当前系统版本号 --- */
9
- export const VER = '9.15.5';
9
+ export const VER = '9.15.6';
10
10
  // --- 服务端用的路径 ---
11
11
  const imu = decodeURIComponent(import.meta.url).replace('file://', '').replace(/^\/(\w:)/, '$1');
12
12
  /** --- /xxx/xxx --- */
package/lib/core.d.ts CHANGED
@@ -181,6 +181,11 @@ export declare function passThroughAppend(passThrough: stream.PassThrough, data:
181
181
  */
182
182
  export declare function exec(command: string, options?: {
183
183
  'cwd'?: string;
184
+ /**
185
+ * --- 命令超时毫秒数,超时后终止命令并以失败返回 ---
186
+ * --- 默认无超时限制:不传时命令可一直运行直至完成,与 cp.exec 默认行为一致 ---
187
+ */
188
+ 'timeout'?: number;
184
189
  }): Promise<string | false>;
185
190
  /**
186
191
  * --- 向主进程(或局域网同代码机子)发送广播将进行 reload 操作,等待回传 ---
package/lib/core.js CHANGED
@@ -602,6 +602,7 @@ export function exec(command, options = {}) {
602
602
  return new Promise(function (resolve) {
603
603
  cp.exec(command, {
604
604
  'cwd': options.cwd,
605
+ 'timeout': options.timeout,
605
606
  }, function (err, stdout) {
606
607
  if (err) {
607
608
  resolve(false);
@@ -630,6 +631,10 @@ export async function sendReload(hosts) {
630
631
  if (hosts === 'config') {
631
632
  hosts = globalConfig.hosts;
632
633
  }
634
+ // --- 未传或 config 展开后为空数组,均回退到本机 ---
635
+ if (!hosts?.length) {
636
+ hosts = ['127.0.0.1'];
637
+ }
633
638
  // --- 局域网模式 ---
634
639
  const time = lTime.stamp();
635
640
  /** --- 返回成功的 host --- */
@@ -675,6 +680,10 @@ export async function sendRestart(hosts) {
675
680
  if (hosts === 'config') {
676
681
  hosts = globalConfig.hosts;
677
682
  }
683
+ // --- 未传或 config 展开后为空数组,均回退到本机 ---
684
+ if (!hosts?.length) {
685
+ hosts = ['127.0.0.1'];
686
+ }
678
687
  // --- 局域网模式 ---
679
688
  const time = lTime.stamp();
680
689
  /** --- 返回成功的 host --- */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiyunnet/kebab",
3
- "version": "9.15.5",
3
+ "version": "9.15.6",
4
4
  "description": "Simple, easy-to-use, and fully-featured Node.js framework that is ready-to-use out of the box.",
5
5
  "type": "module",
6
6
  "keywords": [
package/sys/master.js CHANGED
@@ -83,6 +83,37 @@ function normalizeArchivePath(archivePath) {
83
83
  }
84
84
  return `/${normalized}`;
85
85
  }
86
+ /**
87
+ * --- 递归判断 JSON 内容中是否包含受保护的配置参数 ---
88
+ * @param value 待检查的 JSON 值
89
+ * @returns 是否包含 pwd 或 skey 参数
90
+ */
91
+ function hasSensitiveConfigKey(value) {
92
+ if (Array.isArray(value)) {
93
+ return value.some(item => hasSensitiveConfigKey(item));
94
+ }
95
+ if ((value === null) || (typeof value !== 'object')) {
96
+ return false;
97
+ }
98
+ for (const key of Object.keys(value)) {
99
+ if ((key === 'pwd') || (key === 'skey')) {
100
+ return true;
101
+ }
102
+ if (hasSensitiveConfigKey(value[key])) {
103
+ return true;
104
+ }
105
+ }
106
+ return false;
107
+ }
108
+ /**
109
+ * --- 判断 ZIP 内的 kebab.json 是否包含受保护的配置参数 ---
110
+ * @param content ZIP 文件内容
111
+ * @returns 是否包含 pwd 或 skey 参数
112
+ */
113
+ function hasSensitiveConfig(content) {
114
+ const json = lText.parseJson(typeof content === 'string' ? content : content.toString('utf8'));
115
+ return (json !== false) && hasSensitiveConfigKey(json);
116
+ }
86
117
  /**
87
118
  * --- 等待指定 worker 开始监听端口就绪 ---
88
119
  * @param worker 要等待的 worker 对象
@@ -265,13 +296,17 @@ function createRpcListener() {
265
296
  res.end('Path not found');
266
297
  return;
267
298
  }
299
+ // --- npm install 上限与 sendNpm 客户端超时一致,超时后终止,避免无限期运行 ---
300
+ const npmTimeout = 300_000;
268
301
  let rtn = await lCore.exec('npm i --omit=dev', {
269
302
  'cwd': msg.path,
303
+ 'timeout': npmTimeout,
270
304
  });
271
305
  if (rtn === false) {
272
306
  // --- 部分项目可能存在 peerDependencies 冲突,失败后降级为 legacy-peer-deps 再试一次 ---
273
307
  rtn = await lCore.exec('npm i --omit=dev --legacy-peer-deps', {
274
308
  'cwd': msg.path,
309
+ 'timeout': npmTimeout,
275
310
  });
276
311
  }
277
312
  if (rtn === false) {
@@ -490,8 +525,12 @@ function createRpcListener() {
490
525
  // --- 开发、依赖、缓存、构建产物目录不覆盖 ---
491
526
  continue;
492
527
  }
493
- if ((pat === 'conf/' && fname === 'config.json') || fname === 'kebab.json') {
494
- // --- 特殊文件不能覆盖 ---
528
+ if (fname === 'kebab.json' && hasSensitiveConfig(ls[archivePath])) {
529
+ // --- 包含密码或密钥的 kebab.json 不覆盖,避免部署包覆盖现有敏感配置 ---
530
+ continue;
531
+ }
532
+ if (pat === 'conf/' && fname === 'config.json') {
533
+ // --- 全局配置文件不能覆盖 ---
495
534
  continue;
496
535
  }
497
536
  if (fname.endsWith('.js.map') || fname.endsWith('.ts') || fname.endsWith('.tsx') || fname.endsWith('.scss') || fname.endsWith('.gitignore') || fname.endsWith('.DS_Store')) {