i18-fe-automator-beta 2.1.0 → 2.1.1
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/commonjs/index.js +53 -24
- package/dist/esm/index.mjs +53 -24
- package/package.json +1 -1
package/dist/commonjs/index.js
CHANGED
|
@@ -25,7 +25,6 @@ var stripAnsi = require('strip-ansi');
|
|
|
25
25
|
require('shelljs');
|
|
26
26
|
var process$1 = require('child_process');
|
|
27
27
|
var _ = require('lodash');
|
|
28
|
-
require('nanoid');
|
|
29
28
|
var request$1 = require('request-promise');
|
|
30
29
|
require('os');
|
|
31
30
|
require('console');
|
|
@@ -399,7 +398,13 @@ async function upload$1(cliOpts = {}) {
|
|
|
399
398
|
const cliUsername = cliOpts.username || undefined;
|
|
400
399
|
const cliPassword = cliOpts.password || undefined;
|
|
401
400
|
const cache = Boolean(cliOpts.cache);
|
|
402
|
-
|
|
401
|
+
// 传了任一CLI参数即视为一键意图, 跳过"是否上传"确认(传参即意图)
|
|
402
|
+
const oneClick =
|
|
403
|
+
cliEnv !== undefined ||
|
|
404
|
+
cliFiles !== undefined ||
|
|
405
|
+
cliUsername !== undefined ||
|
|
406
|
+
cliPassword !== undefined ||
|
|
407
|
+
cache;
|
|
403
408
|
// CLI参数校验前置(快速失败, 不进交互)
|
|
404
409
|
if (cliEnv !== undefined) {
|
|
405
410
|
const envArr = cliEnv
|
|
@@ -520,12 +525,12 @@ async function upload$1(cliOpts = {}) {
|
|
|
520
525
|
]);
|
|
521
526
|
envValue = res.env;
|
|
522
527
|
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
528
|
+
// 统一解析: 去掉to-前缀(兼容交互选择值) → 按逗号拆分
|
|
529
|
+
const envList = envValue
|
|
530
|
+
.replace(/^to-/, "")
|
|
531
|
+
.split(",")
|
|
532
|
+
.map((item) => item.trim())
|
|
533
|
+
.filter(Boolean);
|
|
529
534
|
const isPro = envList.length === 1 && envList[0] === "pro";
|
|
530
535
|
// 3.凭据: CLI参数 > --cache缓存 > 交互(展示缓存默认值), 解析后回写缓存
|
|
531
536
|
const secret = await resolveSecretQuestions({
|
|
@@ -942,6 +947,11 @@ async function excelFn(cliOpts = {}) {
|
|
|
942
947
|
},
|
|
943
948
|
]);
|
|
944
949
|
language = res.language;
|
|
950
|
+
// 用户选择不翻译则直接退出(一键模式传 --lang 视为翻译, 不进入该询问)
|
|
951
|
+
if (!res.isTranslate) {
|
|
952
|
+
console.log(chalk.green(`已跳过${language}列翻译`));
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
945
955
|
}
|
|
946
956
|
const content = data.slice(1);
|
|
947
957
|
const zhArr = content.map((row) => {
|
|
@@ -1214,8 +1224,9 @@ async function sassMain(rawCliOpts = {}) {
|
|
|
1214
1224
|
async function syncSassFlow(cliOpts) {
|
|
1215
1225
|
const { from: cliFrom, to: cliTo, app: cliApp } = cliOpts;
|
|
1216
1226
|
const envList = ["mit", "sit", "uat"];
|
|
1227
|
+
// 传了任一同步参数即视为一键意图, 自动同意使用须知(传参即意图)
|
|
1217
1228
|
const oneClick =
|
|
1218
|
-
cliFrom !== undefined
|
|
1229
|
+
cliFrom !== undefined || cliTo !== undefined || cliApp !== undefined;
|
|
1219
1230
|
if (!oneClick) {
|
|
1220
1231
|
const { notice } = await inquirer.prompt([
|
|
1221
1232
|
{
|
|
@@ -1290,14 +1301,36 @@ async function syncSassFlow(cliOpts) {
|
|
|
1290
1301
|
console.log(chalk.red(`查询${from}环境应用列表失败: ${e.message || e}`));
|
|
1291
1302
|
process.exit(1);
|
|
1292
1303
|
}
|
|
1293
|
-
|
|
1294
|
-
{
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1304
|
+
if (!applicationList.length) {
|
|
1305
|
+
console.log(chalk.red(`${from}环境未找到该应用`));
|
|
1306
|
+
process.exit(1);
|
|
1307
|
+
}
|
|
1308
|
+
// 一键模式: 唯一匹配或精确匹配CLI传入的应用名时自动选中(与新增按钮权限流程一致)
|
|
1309
|
+
let appName;
|
|
1310
|
+
if (applicationList.length === 1) {
|
|
1311
|
+
appName = applicationList[0].name;
|
|
1312
|
+
console.log(chalk.gray(`唯一匹配,已自动选中: ${appName}`));
|
|
1313
|
+
} else if (oneClick) {
|
|
1314
|
+
const exactMatch = applicationList.find((item) => item.name === cliApp);
|
|
1315
|
+
if (!exactMatch) {
|
|
1316
|
+
console.log(
|
|
1317
|
+
chalk.red(`${from}环境未精确匹配到应用: ${cliApp}, 请更换关键字`)
|
|
1318
|
+
);
|
|
1319
|
+
process.exit(1);
|
|
1320
|
+
}
|
|
1321
|
+
appName = exactMatch.name;
|
|
1322
|
+
console.log(chalk.gray(`精确匹配,已自动选中: ${appName}`));
|
|
1323
|
+
} else {
|
|
1324
|
+
const res = await inquirer.prompt([
|
|
1325
|
+
{
|
|
1326
|
+
message: "请选择应用名称",
|
|
1327
|
+
name: "appName",
|
|
1328
|
+
type: "rawlist",
|
|
1329
|
+
choices: applicationList,
|
|
1330
|
+
},
|
|
1331
|
+
]);
|
|
1332
|
+
appName = res.appName;
|
|
1333
|
+
}
|
|
1301
1334
|
const appId = applicationList.find((item) => item.name === appName).id;
|
|
1302
1335
|
let fromButtonList;
|
|
1303
1336
|
try {
|
|
@@ -2952,7 +2985,8 @@ function getGitChangedFiles() {
|
|
|
2952
2985
|
return allFiles;
|
|
2953
2986
|
} catch (error) {
|
|
2954
2987
|
// git命令失败(如不在git仓库中运行)属于使用错误, 以退出码1结束
|
|
2955
|
-
|
|
2988
|
+
console.log(chalk.red("获取git修改文件失败,请确保在git仓库中运行"));
|
|
2989
|
+
process.exit(1);
|
|
2956
2990
|
}
|
|
2957
2991
|
}
|
|
2958
2992
|
// const spinner = ora();
|
|
@@ -3452,12 +3486,7 @@ function translateUtil(appid, key, projectName, isLintFix, isMergeDecision) {
|
|
|
3452
3486
|
let EN = result[index1].dst;
|
|
3453
3487
|
EN = EN[0].toUpperCase() + EN.slice(1);
|
|
3454
3488
|
item1.EN = EN;
|
|
3455
|
-
|
|
3456
|
-
// item1.key = nanoid().replace("_", "a");
|
|
3457
|
-
item1.key = id + "-" + key;
|
|
3458
|
-
} else {
|
|
3459
|
-
item1.key = id + "-" + key;
|
|
3460
|
-
}
|
|
3489
|
+
item1.key = id + "-" + key;
|
|
3461
3490
|
}
|
|
3462
3491
|
});
|
|
3463
3492
|
resolve(true);
|
package/dist/esm/index.mjs
CHANGED
|
@@ -23,7 +23,6 @@ import stripAnsi from 'strip-ansi';
|
|
|
23
23
|
import 'shelljs';
|
|
24
24
|
import process$1, { execSync } from 'child_process';
|
|
25
25
|
import _ from 'lodash';
|
|
26
|
-
import 'nanoid';
|
|
27
26
|
import request$1 from 'request-promise';
|
|
28
27
|
import 'os';
|
|
29
28
|
import 'console';
|
|
@@ -377,7 +376,13 @@ async function upload$1(cliOpts = {}) {
|
|
|
377
376
|
const cliUsername = cliOpts.username || undefined;
|
|
378
377
|
const cliPassword = cliOpts.password || undefined;
|
|
379
378
|
const cache = Boolean(cliOpts.cache);
|
|
380
|
-
|
|
379
|
+
// 传了任一CLI参数即视为一键意图, 跳过"是否上传"确认(传参即意图)
|
|
380
|
+
const oneClick =
|
|
381
|
+
cliEnv !== undefined ||
|
|
382
|
+
cliFiles !== undefined ||
|
|
383
|
+
cliUsername !== undefined ||
|
|
384
|
+
cliPassword !== undefined ||
|
|
385
|
+
cache;
|
|
381
386
|
// CLI参数校验前置(快速失败, 不进交互)
|
|
382
387
|
if (cliEnv !== undefined) {
|
|
383
388
|
const envArr = cliEnv
|
|
@@ -498,12 +503,12 @@ async function upload$1(cliOpts = {}) {
|
|
|
498
503
|
]);
|
|
499
504
|
envValue = res.env;
|
|
500
505
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
506
|
+
// 统一解析: 去掉to-前缀(兼容交互选择值) → 按逗号拆分
|
|
507
|
+
const envList = envValue
|
|
508
|
+
.replace(/^to-/, "")
|
|
509
|
+
.split(",")
|
|
510
|
+
.map((item) => item.trim())
|
|
511
|
+
.filter(Boolean);
|
|
507
512
|
const isPro = envList.length === 1 && envList[0] === "pro";
|
|
508
513
|
// 3.凭据: CLI参数 > --cache缓存 > 交互(展示缓存默认值), 解析后回写缓存
|
|
509
514
|
const secret = await resolveSecretQuestions({
|
|
@@ -920,6 +925,11 @@ async function excelFn(cliOpts = {}) {
|
|
|
920
925
|
},
|
|
921
926
|
]);
|
|
922
927
|
language = res.language;
|
|
928
|
+
// 用户选择不翻译则直接退出(一键模式传 --lang 视为翻译, 不进入该询问)
|
|
929
|
+
if (!res.isTranslate) {
|
|
930
|
+
console.log(chalk.green(`已跳过${language}列翻译`));
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
923
933
|
}
|
|
924
934
|
const content = data.slice(1);
|
|
925
935
|
const zhArr = content.map((row) => {
|
|
@@ -1192,8 +1202,9 @@ async function sassMain(rawCliOpts = {}) {
|
|
|
1192
1202
|
async function syncSassFlow(cliOpts) {
|
|
1193
1203
|
const { from: cliFrom, to: cliTo, app: cliApp } = cliOpts;
|
|
1194
1204
|
const envList = ["mit", "sit", "uat"];
|
|
1205
|
+
// 传了任一同步参数即视为一键意图, 自动同意使用须知(传参即意图)
|
|
1195
1206
|
const oneClick =
|
|
1196
|
-
cliFrom !== undefined
|
|
1207
|
+
cliFrom !== undefined || cliTo !== undefined || cliApp !== undefined;
|
|
1197
1208
|
if (!oneClick) {
|
|
1198
1209
|
const { notice } = await inquirer.prompt([
|
|
1199
1210
|
{
|
|
@@ -1268,14 +1279,36 @@ async function syncSassFlow(cliOpts) {
|
|
|
1268
1279
|
console.log(chalk.red(`查询${from}环境应用列表失败: ${e.message || e}`));
|
|
1269
1280
|
process.exit(1);
|
|
1270
1281
|
}
|
|
1271
|
-
|
|
1272
|
-
{
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1282
|
+
if (!applicationList.length) {
|
|
1283
|
+
console.log(chalk.red(`${from}环境未找到该应用`));
|
|
1284
|
+
process.exit(1);
|
|
1285
|
+
}
|
|
1286
|
+
// 一键模式: 唯一匹配或精确匹配CLI传入的应用名时自动选中(与新增按钮权限流程一致)
|
|
1287
|
+
let appName;
|
|
1288
|
+
if (applicationList.length === 1) {
|
|
1289
|
+
appName = applicationList[0].name;
|
|
1290
|
+
console.log(chalk.gray(`唯一匹配,已自动选中: ${appName}`));
|
|
1291
|
+
} else if (oneClick) {
|
|
1292
|
+
const exactMatch = applicationList.find((item) => item.name === cliApp);
|
|
1293
|
+
if (!exactMatch) {
|
|
1294
|
+
console.log(
|
|
1295
|
+
chalk.red(`${from}环境未精确匹配到应用: ${cliApp}, 请更换关键字`)
|
|
1296
|
+
);
|
|
1297
|
+
process.exit(1);
|
|
1298
|
+
}
|
|
1299
|
+
appName = exactMatch.name;
|
|
1300
|
+
console.log(chalk.gray(`精确匹配,已自动选中: ${appName}`));
|
|
1301
|
+
} else {
|
|
1302
|
+
const res = await inquirer.prompt([
|
|
1303
|
+
{
|
|
1304
|
+
message: "请选择应用名称",
|
|
1305
|
+
name: "appName",
|
|
1306
|
+
type: "rawlist",
|
|
1307
|
+
choices: applicationList,
|
|
1308
|
+
},
|
|
1309
|
+
]);
|
|
1310
|
+
appName = res.appName;
|
|
1311
|
+
}
|
|
1279
1312
|
const appId = applicationList.find((item) => item.name === appName).id;
|
|
1280
1313
|
let fromButtonList;
|
|
1281
1314
|
try {
|
|
@@ -2930,7 +2963,8 @@ function getGitChangedFiles() {
|
|
|
2930
2963
|
return allFiles;
|
|
2931
2964
|
} catch (error) {
|
|
2932
2965
|
// git命令失败(如不在git仓库中运行)属于使用错误, 以退出码1结束
|
|
2933
|
-
|
|
2966
|
+
console.log(chalk.red("获取git修改文件失败,请确保在git仓库中运行"));
|
|
2967
|
+
process.exit(1);
|
|
2934
2968
|
}
|
|
2935
2969
|
}
|
|
2936
2970
|
// const spinner = ora();
|
|
@@ -3430,12 +3464,7 @@ function translateUtil(appid, key, projectName, isLintFix, isMergeDecision) {
|
|
|
3430
3464
|
let EN = result[index1].dst;
|
|
3431
3465
|
EN = EN[0].toUpperCase() + EN.slice(1);
|
|
3432
3466
|
item1.EN = EN;
|
|
3433
|
-
|
|
3434
|
-
// item1.key = nanoid().replace("_", "a");
|
|
3435
|
-
item1.key = id + "-" + key;
|
|
3436
|
-
} else {
|
|
3437
|
-
item1.key = id + "-" + key;
|
|
3438
|
-
}
|
|
3467
|
+
item1.key = id + "-" + key;
|
|
3439
3468
|
}
|
|
3440
3469
|
});
|
|
3441
3470
|
resolve(true);
|