@share-crm/sharedev-cli 0.0.4-rc.32 → 0.0.4-rc.33
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/dist/sharedev.js +382 -3
- package/package.json +1 -1
package/dist/sharedev.js
CHANGED
|
@@ -9611,6 +9611,90 @@ function registerApprovalNamespace(program, runtimeContext) {
|
|
|
9611
9611
|
}
|
|
9612
9612
|
|
|
9613
9613
|
|
|
9614
|
+
/***/ },
|
|
9615
|
+
|
|
9616
|
+
/***/ 9959
|
|
9617
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
9618
|
+
|
|
9619
|
+
|
|
9620
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
9621
|
+
exports.registerBiNamespace = registerBiNamespace;
|
|
9622
|
+
const index_ts_1 = __webpack_require__(1474);
|
|
9623
|
+
/**
|
|
9624
|
+
* 注册 bi 命名空间(透传命令,全部参数直接透传操作中心 data)
|
|
9625
|
+
* 命令路径与操作中心 commandPath 完全一致,通过 PassthroughCommandManager 声明一次即可
|
|
9626
|
+
*/
|
|
9627
|
+
function registerBiNamespace(program, runtimeContext) {
|
|
9628
|
+
const bi = program.command('bi').description('BI development workspace commands');
|
|
9629
|
+
const passthrough = new index_ts_1.PassthroughCommandManager(bi, { namespace: 'bi', runtimeContext });
|
|
9630
|
+
passthrough
|
|
9631
|
+
.command('dev-goal')
|
|
9632
|
+
.command('goal-list-rules')
|
|
9633
|
+
.description('List goal rules via shareCli execute (passthrough to operation center)')
|
|
9634
|
+
.option('--name <name>', 'Goal rule name')
|
|
9635
|
+
.option('--page-size <number>', 'Page size (number)', (value) => parseInt(value, 10))
|
|
9636
|
+
.option('--page-number <number>', 'Page number (number)', (value) => parseInt(value, 10))
|
|
9637
|
+
.option('--goal-rule-id <goalRuleId>', 'Goal rule id')
|
|
9638
|
+
.option('--goal-rule-detail-id <goalRuleDetailId>', 'Goal rule detail id')
|
|
9639
|
+
.option('--time-zone-list <list>', 'Time zone list (comma separated, converted to array)', (value) => value
|
|
9640
|
+
.split(',')
|
|
9641
|
+
.map((item) => item.trim())
|
|
9642
|
+
.filter(Boolean))
|
|
9643
|
+
.route({
|
|
9644
|
+
examples: [
|
|
9645
|
+
'$ sharedev bi dev-goal goal-list-rules --name demo --page-size 10 --page-number 1 --time-zone-list "Asia/Shanghai,UTC"',
|
|
9646
|
+
],
|
|
9647
|
+
});
|
|
9648
|
+
passthrough
|
|
9649
|
+
.command('dev-goal')
|
|
9650
|
+
.command('goal-get-rule')
|
|
9651
|
+
.description('Get goal rule via shareCli execute (passthrough to operation center)')
|
|
9652
|
+
.requiredOption('--rule-id <ruleId>', 'Goal rule id')
|
|
9653
|
+
.map('ruleId', 'rule_id')
|
|
9654
|
+
.route({
|
|
9655
|
+
examples: [
|
|
9656
|
+
'$ sharedev bi dev-goal goal-get-rule --rule-id xxx',
|
|
9657
|
+
],
|
|
9658
|
+
});
|
|
9659
|
+
passthrough
|
|
9660
|
+
.command('dev-goal')
|
|
9661
|
+
.command('goal-get-value-header')
|
|
9662
|
+
.description('Get goal value header via shareCli execute (passthrough to operation center)')
|
|
9663
|
+
.requiredOption('--goal-rule-id <goalRuleId>', 'Goal rule id')
|
|
9664
|
+
.requiredOption('--fiscal-year <fiscalYear>', 'Fiscal year')
|
|
9665
|
+
.map('goalRuleId', 'goal_rule_id')
|
|
9666
|
+
.map('fiscalYear', 'fiscal_year')
|
|
9667
|
+
.route({
|
|
9668
|
+
examples: [
|
|
9669
|
+
'$ sharedev bi dev-goal goal-get-value-header --goal-rule-id xxx --fiscal-year 2026',
|
|
9670
|
+
],
|
|
9671
|
+
});
|
|
9672
|
+
passthrough
|
|
9673
|
+
.command('dev-goal')
|
|
9674
|
+
.command('goal-list-values')
|
|
9675
|
+
.description('List goal values via shareCli execute (passthrough to operation center)')
|
|
9676
|
+
.requiredOption('--object-describe-api-name <objectDescribeApiName>', 'Object describe api name')
|
|
9677
|
+
.requiredOption('--search-query-info <searchQueryInfo>', 'Search query info')
|
|
9678
|
+
.map('objectDescribeApiName', 'object_describe_api_name')
|
|
9679
|
+
.map('searchQueryInfo', 'search_query_info')
|
|
9680
|
+
.route({
|
|
9681
|
+
examples: [
|
|
9682
|
+
'$ sharedev bi dev-goal goal-list-values --object-describe-api-name AccountObj --search-query-info "{}"',
|
|
9683
|
+
],
|
|
9684
|
+
});
|
|
9685
|
+
passthrough
|
|
9686
|
+
.command('dev-goal')
|
|
9687
|
+
.command('goal-save-values')
|
|
9688
|
+
.description('Save goal values via shareCli execute (passthrough to operation center)')
|
|
9689
|
+
.requiredOption('--datas <json>', 'Goal values data (JSON string, parsed to array/object)', (value) => JSON.parse(value))
|
|
9690
|
+
.route({
|
|
9691
|
+
examples: [
|
|
9692
|
+
'$ sharedev bi dev-goal goal-save-values --datas \'[{"name":"a"},{"name":"b"}]\'',
|
|
9693
|
+
],
|
|
9694
|
+
});
|
|
9695
|
+
}
|
|
9696
|
+
|
|
9697
|
+
|
|
9614
9698
|
/***/ },
|
|
9615
9699
|
|
|
9616
9700
|
/***/ 4781
|
|
@@ -10938,6 +11022,7 @@ const interface_dev_ts_1 = __webpack_require__(8965);
|
|
|
10938
11022
|
const sales_ts_1 = __webpack_require__(4056);
|
|
10939
11023
|
const data_ts_1 = __webpack_require__(7170);
|
|
10940
11024
|
const email_ts_1 = __webpack_require__(4952);
|
|
11025
|
+
const bi_ts_1 = __webpack_require__(9959);
|
|
10941
11026
|
const access_ts_1 = __webpack_require__(1696);
|
|
10942
11027
|
const app_dev_ts_1 = __webpack_require__(4041);
|
|
10943
11028
|
function registerNamespaces(program, context) {
|
|
@@ -10964,6 +11049,7 @@ function registerNamespaces(program, context) {
|
|
|
10964
11049
|
(0, sales_ts_1.registerSalesNamespace)(program, context);
|
|
10965
11050
|
(0, data_ts_1.registerDataNamespace)(program, context);
|
|
10966
11051
|
(0, email_ts_1.registerEmailNamespace)(program, context);
|
|
11052
|
+
(0, bi_ts_1.registerBiNamespace)(program, context);
|
|
10967
11053
|
(0, access_ts_1.registerAccessNamespace)(program, context);
|
|
10968
11054
|
(0, app_dev_ts_1.registerAppDevNamespace)(program, context);
|
|
10969
11055
|
}
|
|
@@ -14123,6 +14209,259 @@ const fetchLatestNpmVersion = (packageName, timeoutMs = 1500) => new Promise((re
|
|
|
14123
14209
|
exports.fetchLatestNpmVersion = fetchLatestNpmVersion;
|
|
14124
14210
|
|
|
14125
14211
|
|
|
14212
|
+
/***/ },
|
|
14213
|
+
|
|
14214
|
+
/***/ 1474
|
|
14215
|
+
(__unused_webpack_module, exports, __webpack_require__) {
|
|
14216
|
+
|
|
14217
|
+
|
|
14218
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
14219
|
+
exports.PassthroughCommandBuilder = exports.PassthroughCommandManager = void 0;
|
|
14220
|
+
const command_ts_1 = __webpack_require__(528);
|
|
14221
|
+
const logger_ts_1 = __webpack_require__(3333);
|
|
14222
|
+
const request_execute_ts_1 = __webpack_require__(8554);
|
|
14223
|
+
const isShareCliExecuteResponse = (value) => Boolean(value && typeof value === 'object');
|
|
14224
|
+
/**
|
|
14225
|
+
* 解析 --data JSON 字符串为对象(空值返回空对象)
|
|
14226
|
+
*/
|
|
14227
|
+
const parsePassthroughJson = (raw) => {
|
|
14228
|
+
if (typeof raw !== 'string' || !raw.trim()) {
|
|
14229
|
+
throw new Error('--data must be a valid JSON string.');
|
|
14230
|
+
}
|
|
14231
|
+
const parsed = JSON.parse(raw);
|
|
14232
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
14233
|
+
throw new Error('--data must be a JSON object.');
|
|
14234
|
+
}
|
|
14235
|
+
return parsed;
|
|
14236
|
+
};
|
|
14237
|
+
/**
|
|
14238
|
+
* 将 commander 短横线选项名转为小驼峰(--obj-desc-api-name -> objDescApiName)
|
|
14239
|
+
* 与 commander 内部 opts() 的属性名转换规则保持一致
|
|
14240
|
+
*/
|
|
14241
|
+
const kebabToCamel = (name) => {
|
|
14242
|
+
const trimmed = name.replace(/^--?/, '');
|
|
14243
|
+
const segments = trimmed.split('-').filter(Boolean);
|
|
14244
|
+
return segments[0] + segments.slice(1).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1)).join('');
|
|
14245
|
+
};
|
|
14246
|
+
/**
|
|
14247
|
+
* 从 commander 命令层级收集 CLI 路径(不含根 program 可执行名)
|
|
14248
|
+
* page -> ['page'];object-dev > print-template > page -> ['object-dev', 'print-template', 'page']
|
|
14249
|
+
*/
|
|
14250
|
+
const resolveCommandPathFromCli = (command) => {
|
|
14251
|
+
const names = [];
|
|
14252
|
+
let current = command;
|
|
14253
|
+
while (current && current.parent) {
|
|
14254
|
+
names.unshift(current.name());
|
|
14255
|
+
current = current.parent;
|
|
14256
|
+
}
|
|
14257
|
+
return names;
|
|
14258
|
+
};
|
|
14259
|
+
/**
|
|
14260
|
+
* 在父命令下查找或创建子命令:多个透传命令共享同一层级(如多个 dev-goal 子命令)时复用已有命令
|
|
14261
|
+
*/
|
|
14262
|
+
const findOrCreateCommand = (parent, name) => {
|
|
14263
|
+
const existing = parent.commands.find((command) => command.name() === name);
|
|
14264
|
+
return existing ?? parent.command(name);
|
|
14265
|
+
};
|
|
14266
|
+
/**
|
|
14267
|
+
* 透传命令管理器
|
|
14268
|
+
*
|
|
14269
|
+
* 用于 CLI 指令路径与操作中心 commandPath 一致、参数直接透传后端的命令注册。
|
|
14270
|
+
* 包装 commander 保持链式调用语法,自动完成:
|
|
14271
|
+
* - CLI 短横线参数自动转换为接口接受的小驼峰参数(commander opts 原生行为)
|
|
14272
|
+
* - 通过 .requiredOption() 声明参数必需性
|
|
14273
|
+
* - 可选 .dataOption() 提供 --data 原样 JSON 合并
|
|
14274
|
+
* - 自动提供 --yes 透传 NEED_CONFIRM 确认标记
|
|
14275
|
+
* - 统一处理响应(success === true && code === 'OK' 判定成功)
|
|
14276
|
+
*
|
|
14277
|
+
* 用法:
|
|
14278
|
+
* ```ts
|
|
14279
|
+
* const passthrough = new PassthroughCommandManager(objectDev, {
|
|
14280
|
+
* namespace: 'object-dev',
|
|
14281
|
+
* runtimeContext
|
|
14282
|
+
* });
|
|
14283
|
+
* // 方式一:显式指定操作中心 commandPath
|
|
14284
|
+
* passthrough
|
|
14285
|
+
* .command('page')
|
|
14286
|
+
* .description('Page print templates')
|
|
14287
|
+
* .option('--obj-desc-api-name <apiName>', 'Object describe api name')
|
|
14288
|
+
* .option('--page-number <number>', 'Page number', parseInt)
|
|
14289
|
+
* .requiredOption('--template-id <templateId>', 'Template id')
|
|
14290
|
+
* .route({ commandPath: getShareCliCommandPath('printTemplate', 'page') });
|
|
14291
|
+
*
|
|
14292
|
+
* // 方式二:不传 commandPath,自动收集 CLI 命令层级路径(object-dev print-template page -> 对应数组)
|
|
14293
|
+
* passthrough
|
|
14294
|
+
* .command('page')
|
|
14295
|
+
* .option('--obj-desc-api-name <apiName>', 'Object describe api name')
|
|
14296
|
+
* .route();
|
|
14297
|
+
* ```
|
|
14298
|
+
*/
|
|
14299
|
+
class PassthroughCommandManager {
|
|
14300
|
+
constructor(command, options) {
|
|
14301
|
+
this.parentCommand = command;
|
|
14302
|
+
this.options = options;
|
|
14303
|
+
}
|
|
14304
|
+
/**
|
|
14305
|
+
* 创建透传子命令(commander 链式入口);已存在同名子命令时复用(共享层级)
|
|
14306
|
+
*/
|
|
14307
|
+
command(name) {
|
|
14308
|
+
return new PassthroughCommandBuilder(findOrCreateCommand(this.parentCommand, name), this.options);
|
|
14309
|
+
}
|
|
14310
|
+
}
|
|
14311
|
+
exports.PassthroughCommandManager = PassthroughCommandManager;
|
|
14312
|
+
/**
|
|
14313
|
+
* 透传子命令构建器:包装 commander Command,保持链式调用语法
|
|
14314
|
+
*/
|
|
14315
|
+
class PassthroughCommandBuilder {
|
|
14316
|
+
constructor(command, options) {
|
|
14317
|
+
/** CLI 行为参数(不透传至后端),记录 commander opts 中的小驼峰键名 */
|
|
14318
|
+
this.rawKeys = [];
|
|
14319
|
+
/** 自定义参数名转换规则:commander opts 小驼峰键名 -> 后端字段名(如 ruleId -> rule_id) */
|
|
14320
|
+
this.paramMappings = new Map();
|
|
14321
|
+
/** 是否启用 --data 原样 JSON 合并 */
|
|
14322
|
+
this.dataEnabled = false;
|
|
14323
|
+
this.childCommand = command;
|
|
14324
|
+
this.options = options;
|
|
14325
|
+
}
|
|
14326
|
+
/**
|
|
14327
|
+
* 嵌套创建透传子命令(commander 链式入口),用于多级 CLI 路径(如 object-dev > print-template > page)
|
|
14328
|
+
* 已存在同名子命令时复用(多个透传命令共享同一层级)
|
|
14329
|
+
*/
|
|
14330
|
+
command(name) {
|
|
14331
|
+
return new PassthroughCommandBuilder(findOrCreateCommand(this.childCommand, name), this.options);
|
|
14332
|
+
}
|
|
14333
|
+
/**
|
|
14334
|
+
* 命令描述(commander 原生语法)
|
|
14335
|
+
*/
|
|
14336
|
+
description(text) {
|
|
14337
|
+
this.childCommand.description(text);
|
|
14338
|
+
return this;
|
|
14339
|
+
}
|
|
14340
|
+
/**
|
|
14341
|
+
* 声明透传参数(commander 原生语法,短横线参数自动转小驼峰透传)
|
|
14342
|
+
* @param flags commander 选项声明,如 '--obj-desc-api-name <apiName>'
|
|
14343
|
+
* @param description 选项描述
|
|
14344
|
+
* @param parseArg 可选值解析函数(如 parseInt 转数字),commander 原生支持
|
|
14345
|
+
*/
|
|
14346
|
+
option(flags, description, parseArg) {
|
|
14347
|
+
if (parseArg) {
|
|
14348
|
+
this.childCommand.option(flags, description ?? '', parseArg);
|
|
14349
|
+
}
|
|
14350
|
+
else {
|
|
14351
|
+
this.childCommand.option(flags, description);
|
|
14352
|
+
}
|
|
14353
|
+
return this;
|
|
14354
|
+
}
|
|
14355
|
+
/**
|
|
14356
|
+
* 声明必填透传参数(commander 原生语法,缺失时 commander 自动报错退出)
|
|
14357
|
+
*/
|
|
14358
|
+
requiredOption(flags, description, parseArg) {
|
|
14359
|
+
if (parseArg) {
|
|
14360
|
+
this.childCommand.requiredOption(flags, description ?? '', parseArg);
|
|
14361
|
+
}
|
|
14362
|
+
else {
|
|
14363
|
+
this.childCommand.requiredOption(flags, description);
|
|
14364
|
+
}
|
|
14365
|
+
return this;
|
|
14366
|
+
}
|
|
14367
|
+
/**
|
|
14368
|
+
* 声明 CLI 行为参数(不透传至后端),如 --json 输出开关
|
|
14369
|
+
*/
|
|
14370
|
+
rawOption(flags, description) {
|
|
14371
|
+
this.childCommand.option(flags, description);
|
|
14372
|
+
this.rawKeys.push(kebabToCamel(flags));
|
|
14373
|
+
return this;
|
|
14374
|
+
}
|
|
14375
|
+
/**
|
|
14376
|
+
* 自定义参数名转换规则:默认短横线参数自动转小驼峰透传,当后端字段名与默认转换不一致时使用
|
|
14377
|
+
* 如 CLI --rule-id(默认转 ruleId),后端要求 rule_id:.map('ruleId', 'rule_id')
|
|
14378
|
+
* @param cliKey commander opts 中的小驼峰键名
|
|
14379
|
+
* @param backendKey 透传给后端的字段名
|
|
14380
|
+
*/
|
|
14381
|
+
map(cliKey, backendKey) {
|
|
14382
|
+
this.paramMappings.set(cliKey, backendKey);
|
|
14383
|
+
return this;
|
|
14384
|
+
}
|
|
14385
|
+
/**
|
|
14386
|
+
* 启用 --data <json>:JSON 原样解析后合并进操作中心 data(兼容旧透传用法)
|
|
14387
|
+
*/
|
|
14388
|
+
dataOption(description) {
|
|
14389
|
+
this.childCommand.option('--data <json>', description ?? 'Request body (JSON), merged into operation center data');
|
|
14390
|
+
this.dataEnabled = true;
|
|
14391
|
+
return this;
|
|
14392
|
+
}
|
|
14393
|
+
/**
|
|
14394
|
+
* 追加 help 示例
|
|
14395
|
+
*/
|
|
14396
|
+
examples(lines) {
|
|
14397
|
+
this.childCommand.addHelpText('after', `\nExamples:\n${lines.map((line) => ` ${line}`).join('\n')}`);
|
|
14398
|
+
return this;
|
|
14399
|
+
}
|
|
14400
|
+
/**
|
|
14401
|
+
* 绑定操作中心 commandPath 并注册自动透传 action(链式收尾)
|
|
14402
|
+
* 收集全部声明的透传参数(短横线已转小驼峰),排除 CLI 行为参数与 --data/--yes
|
|
14403
|
+
* commandPath 缺省时自动收集当前 CLI 命令层级路径作为操作中心 commandPath
|
|
14404
|
+
*/
|
|
14405
|
+
route(options = {}) {
|
|
14406
|
+
const { commandPath, description, examples, yes } = options;
|
|
14407
|
+
const resolvedCommandPath = commandPath ?? resolveCommandPathFromCli(this.childCommand);
|
|
14408
|
+
if (description) {
|
|
14409
|
+
this.childCommand.description(description);
|
|
14410
|
+
}
|
|
14411
|
+
if (examples && examples.length > 0) {
|
|
14412
|
+
this.examples(examples);
|
|
14413
|
+
}
|
|
14414
|
+
if (yes !== false) {
|
|
14415
|
+
this.childCommand.option('--yes', 'Skip confirmation if the command returns NEED_CONFIRM');
|
|
14416
|
+
}
|
|
14417
|
+
const traceName = resolvedCommandPath.join('.');
|
|
14418
|
+
this.childCommand.action((0, command_ts_1.createCommandAction)(this.options.namespace, traceName, this.options.runtimeContext, async ({ options: rawOptions }) => {
|
|
14419
|
+
const raw = rawOptions;
|
|
14420
|
+
const data = {};
|
|
14421
|
+
// --data JSON 原样合并(声明后优先,独立参数叠加其后)
|
|
14422
|
+
if (this.dataEnabled && raw.data !== undefined) {
|
|
14423
|
+
Object.assign(data, parsePassthroughJson(raw.data));
|
|
14424
|
+
}
|
|
14425
|
+
// 收集声明的透传参数:commander 已将短横线参数转为小驼峰,排除 CLI 行为参数与保留参数
|
|
14426
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
14427
|
+
if (key === 'data' || key === 'yes') {
|
|
14428
|
+
continue;
|
|
14429
|
+
}
|
|
14430
|
+
if (this.rawKeys.includes(key)) {
|
|
14431
|
+
continue;
|
|
14432
|
+
}
|
|
14433
|
+
if (value === undefined) {
|
|
14434
|
+
continue;
|
|
14435
|
+
}
|
|
14436
|
+
// 应用自定义参数名转换规则(如 ruleId -> rule_id),未声明时保持默认小驼峰
|
|
14437
|
+
const backendKey = this.paramMappings.get(key) ?? key;
|
|
14438
|
+
data[backendKey] = value;
|
|
14439
|
+
}
|
|
14440
|
+
// --yes 透传 NEED_CONFIRM 确认标记
|
|
14441
|
+
const others = raw.yes === true ? { yes: true } : undefined;
|
|
14442
|
+
logger_ts_1.loggerService.startLoading(`${resolvedCommandPath.join(' ')} ...`);
|
|
14443
|
+
try {
|
|
14444
|
+
const response = await (0, request_execute_ts_1.executeShareCliCommand)(resolvedCommandPath, data, others);
|
|
14445
|
+
if (!isShareCliExecuteResponse(response)) {
|
|
14446
|
+
logger_ts_1.loggerService.error('Invalid response from operation center.');
|
|
14447
|
+
return;
|
|
14448
|
+
}
|
|
14449
|
+
if (!(response.success === true && response.code === 'OK')) {
|
|
14450
|
+
logger_ts_1.loggerService.error(response.message || 'Unknown error.');
|
|
14451
|
+
return;
|
|
14452
|
+
}
|
|
14453
|
+
logger_ts_1.loggerService.success(`${resolvedCommandPath.join(' ')} executed.`);
|
|
14454
|
+
}
|
|
14455
|
+
finally {
|
|
14456
|
+
logger_ts_1.loggerService.stopLoading();
|
|
14457
|
+
}
|
|
14458
|
+
}));
|
|
14459
|
+
return this;
|
|
14460
|
+
}
|
|
14461
|
+
}
|
|
14462
|
+
exports.PassthroughCommandBuilder = PassthroughCommandBuilder;
|
|
14463
|
+
|
|
14464
|
+
|
|
14126
14465
|
/***/ },
|
|
14127
14466
|
|
|
14128
14467
|
/***/ 2351
|
|
@@ -14545,9 +14884,18 @@ const logger_ts_1 = __webpack_require__(3333);
|
|
|
14545
14884
|
const trace_ts_1 = __webpack_require__(3632);
|
|
14546
14885
|
const debug_ts_1 = __webpack_require__(654);
|
|
14547
14886
|
const pkgMeta_ts_1 = __webpack_require__(5016);
|
|
14887
|
+
const normalize_ts_1 = __importDefault(__webpack_require__(9268));
|
|
14548
14888
|
function generateTraceId() {
|
|
14549
14889
|
return `E-E.cli-sharedev-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
14550
14890
|
}
|
|
14891
|
+
/**
|
|
14892
|
+
* 检测当前系统语言并归一化为 Accept-Language 头值(如 zh-CN / en-US)。
|
|
14893
|
+
* 按 LC_ALL / LC_MESSAGES / LANG 优先级读取环境变量;无法识别时回退 zh-CN(项目默认中文)。
|
|
14894
|
+
*/
|
|
14895
|
+
function detectSystemLanguage() {
|
|
14896
|
+
const raw = process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG;
|
|
14897
|
+
return normalize_ts_1.default.normalizeAcceptLanguage(raw) ?? 'zh-CN';
|
|
14898
|
+
}
|
|
14551
14899
|
function shouldWriteDebugLog(config) {
|
|
14552
14900
|
if (config?.__sharedevNoDebug || config?.__sharedevSkipInterceptor) {
|
|
14553
14901
|
return false;
|
|
@@ -14639,7 +14987,8 @@ class RequestService {
|
|
|
14639
14987
|
baseURL: settings.domain,
|
|
14640
14988
|
timeout: 30000,
|
|
14641
14989
|
headers: {
|
|
14642
|
-
Authorization: settings.certificate
|
|
14990
|
+
Authorization: settings.certificate,
|
|
14991
|
+
'Accept-Language': detectSystemLanguage()
|
|
14643
14992
|
}
|
|
14644
14993
|
});
|
|
14645
14994
|
this.axiosInstance.interceptors.request.use((config) => {
|
|
@@ -39449,6 +39798,36 @@ const normalizeText = (value) => typeof value === 'string'
|
|
|
39449
39798
|
? value.replace(/[\r\n\t]+/g, ' ').trim()
|
|
39450
39799
|
: typeof value === 'boolean' || typeof value === 'number' && Number.isFinite(value)
|
|
39451
39800
|
? String(value) : '';
|
|
39801
|
+
/**
|
|
39802
|
+
* 将系统语言环境变量(如 zh_CN.UTF-8 / en_US.utf8 / zh-CN / de_DE.UTF-8@euro)归一化为 Accept-Language 头格式(如 zh-CN / en-US / zh)。
|
|
39803
|
+
* - 忽略字符集后缀(.UTF-8)与修饰符(@euro)
|
|
39804
|
+
* - 语言转小写、地区转大写
|
|
39805
|
+
* - 无法识别(空 / C / POSIX / 非语言格式)返回 undefined,由调用方决定回退
|
|
39806
|
+
*/
|
|
39807
|
+
const normalizeAcceptLanguage = (value) => {
|
|
39808
|
+
const raw = normalizeString(value);
|
|
39809
|
+
if (!raw) {
|
|
39810
|
+
return undefined;
|
|
39811
|
+
}
|
|
39812
|
+
const cleaned = raw.split(/[@.]/u, 1)[0].trim();
|
|
39813
|
+
if (!cleaned) {
|
|
39814
|
+
return undefined;
|
|
39815
|
+
}
|
|
39816
|
+
const upper = cleaned.toUpperCase();
|
|
39817
|
+
if (upper === 'C' || upper === 'POSIX') {
|
|
39818
|
+
return undefined;
|
|
39819
|
+
}
|
|
39820
|
+
const [language, region] = cleaned.split(/[_-]/u);
|
|
39821
|
+
const normalizedLanguage = language?.toLowerCase();
|
|
39822
|
+
if (!normalizedLanguage || !/^[a-z]{2,3}$/u.test(normalizedLanguage)) {
|
|
39823
|
+
return undefined;
|
|
39824
|
+
}
|
|
39825
|
+
if (!region) {
|
|
39826
|
+
return normalizedLanguage;
|
|
39827
|
+
}
|
|
39828
|
+
const normalizedRegion = region.toUpperCase();
|
|
39829
|
+
return /^[A-Z]{2}$/u.test(normalizedRegion) ? `${normalizedLanguage}-${normalizedRegion}` : normalizedLanguage;
|
|
39830
|
+
};
|
|
39452
39831
|
const normalizeDateTime = (value) => {
|
|
39453
39832
|
const timestamp = typeof value === 'number'
|
|
39454
39833
|
? value
|
|
@@ -39541,7 +39920,7 @@ const compareSemver = (a, b) => {
|
|
|
39541
39920
|
}
|
|
39542
39921
|
return 0;
|
|
39543
39922
|
};
|
|
39544
|
-
const normalize = { normalizeString, asString, isRecord, jsonStringToBoolean, normalizeText, normalizeDateTime, validateLocalKey, parseSemver, compareSemver };
|
|
39923
|
+
const normalize = { normalizeString, asString, isRecord, jsonStringToBoolean, normalizeText, normalizeDateTime, validateLocalKey, parseSemver, compareSemver, normalizeAcceptLanguage };
|
|
39545
39924
|
exports["default"] = normalize;
|
|
39546
39925
|
|
|
39547
39926
|
|
|
@@ -53807,7 +54186,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
|
|
|
53807
54186
|
/***/ 8330
|
|
53808
54187
|
(module) {
|
|
53809
54188
|
|
|
53810
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@share-crm/sharedev-cli","version":"0.0.4-rc.
|
|
54189
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@share-crm/sharedev-cli","version":"0.0.4-rc.33","private":false,"description":"sharedev command line tool","type":"module","main":"dist/sharedev.js","bin":{"sharedev":"./bin/cli.mjs"},"author":{"name":"sharecrm-npm"},"files":["dist","bin","README.md"],"scripts":{"build":"tsc --noEmit && webpack --config build/webpack/webpack.prod.cjs","build:debug":"tsc --noEmit && webpack --config build/webpack/webpack.debug.cjs","build:bin":"bun build --compile --target=bun-darwin-x64 src/cli.ts --outfile scripts/sharedev-darwin-x64 && bun build --compile --target=bun-darwin-arm64 src/cli.ts --outfile scripts/sharedev-darwin-arm64 && bun build --compile --target=bun-windows-x64 src/cli.ts --outfile scripts/sharedev-windows-x64.exe","build:all":"npm run build && npm run build:bin","dev":"tsc --noEmit --watch & webpack --config build/webpack/webpack.dev.cjs --watch","dev2":"node src/cli.ts","typecheck":"tsc --noEmit","prettier":"prettier --write ./src/**/*.ts","test":"vitest run","test:watch":"vitest","test:coverage":"vitest run --coverage"},"dependencies":{"@clack/prompts":"^1.1.0","@mariozechner/pi-coding-agent":"^0.62.0","axios":"~1.13.0","chalk":"^5.6.2","commander":"^14.0.1","extract-zip":"^2.0.1","fast-xml-parser":"^5.2.5","fs-extra":"^11.3.2","lodash-es":"^4.18.1","ora":"^9.3.0","terser-webpack-plugin":"^5.6.1"},"devDependencies":{"@types/extract-zip":"^2.0.3","@types/fs-extra":"^11.0.4","@types/lodash-es":"^4.17.12","@types/node":"^24.3.0","@vitest/coverage-v8":"^4.1.8","ts-loader":"^9.5.4","typescript":"^5.9.2","vitest":"^3.2.6","webpack":"^5.101.3","webpack-cli":"^6.0.1","webpack-merge":"^6.0.1"},"packageManager":"pnpm@10.17.0"}');
|
|
53811
54190
|
|
|
53812
54191
|
/***/ }
|
|
53813
54192
|
|