cloudflared-manager 0.1.2 → 0.1.3

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.
@@ -1002,13 +1002,21 @@ function buildSetupReviewMenu(type, baseArgs, state) {
1002
1002
  ];
1003
1003
 
1004
1004
  if (isAdd) {
1005
+ prelude.push(colorize(`覆盖已有 DNS 记录: ${formatEnabled(state.overwriteDns)}`, COLORS.dim, COLORS.gray));
1006
+ prelude.push(colorize(`跳过本地连通性检查: ${formatEnabled(state.skipCheck)}`, COLORS.dim, COLORS.gray));
1005
1007
  prelude.push(colorize(`立即启动: ${formatEnabled(state.start)}`, COLORS.dim, COLORS.gray));
1006
1008
  prelude.push(colorize(`激活为默认配置: ${formatEnabled(state.activate)}`, COLORS.dim, COLORS.gray));
1009
+ if (state.overwriteDns) commandArgs.push("--overwrite-dns");
1010
+ if (state.skipCheck) commandArgs.push("--skip-check");
1007
1011
  if (state.start) commandArgs.push("--start");
1008
1012
  } else {
1009
1013
  prelude.push(colorize(`同时确保 DNS 路由存在: ${formatEnabled(state.ensureDns)}`, COLORS.dim, COLORS.gray));
1014
+ prelude.push(colorize(`覆盖已有 DNS 记录: ${formatEnabled(state.overwriteDns)}`, COLORS.dim, COLORS.gray));
1015
+ prelude.push(colorize(`跳过本地连通性检查: ${formatEnabled(state.skipCheck)}`, COLORS.dim, COLORS.gray));
1010
1016
  prelude.push(colorize(`激活为默认配置: ${formatEnabled(state.activate)}`, COLORS.dim, COLORS.gray));
1011
1017
  if (state.ensureDns) commandArgs.push("--ensure-dns");
1018
+ if (state.ensureDns && state.overwriteDns) commandArgs.push("--overwrite-dns");
1019
+ if (state.skipCheck) commandArgs.push("--skip-check");
1012
1020
  }
1013
1021
  if (state.activate) commandArgs.push("--activate");
1014
1022
 
@@ -1022,12 +1030,24 @@ function buildSetupReviewMenu(type, baseArgs, state) {
1022
1030
  { value: "4", label: "重新录入 ingress 规则", hint: `当前共 ${state.specs.length} 条`, kind: "secondary" },
1023
1031
  {
1024
1032
  value: "5",
1025
- label: isAdd ? "切换“立即启动”" : "切换“确保 DNS 路由存在”",
1026
- hint: `当前: ${isAdd ? formatEnabled(state.start) : formatEnabled(state.ensureDns)}`,
1033
+ label: isAdd ? "切换“覆盖已有 DNS”" : "切换“确保 DNS 路由存在”",
1034
+ hint: `当前: ${isAdd ? formatEnabled(state.overwriteDns) : formatEnabled(state.ensureDns)}`,
1027
1035
  kind: "assist",
1028
1036
  },
1029
1037
  {
1030
1038
  value: "6",
1039
+ label: isAdd ? "切换“跳过连通性检查”" : "切换“覆盖已有 DNS”",
1040
+ hint: `当前: ${isAdd ? formatEnabled(state.skipCheck) : formatEnabled(state.overwriteDns)}`,
1041
+ kind: "assist",
1042
+ },
1043
+ {
1044
+ value: "7",
1045
+ label: isAdd ? "切换“立即启动”" : "切换“跳过连通性检查”",
1046
+ hint: `当前: ${isAdd ? formatEnabled(state.start) : formatEnabled(state.skipCheck)}`,
1047
+ kind: "assist",
1048
+ },
1049
+ {
1050
+ value: "8",
1031
1051
  label: "切换“激活为默认配置”",
1032
1052
  hint: `当前: ${formatEnabled(state.activate)}`,
1033
1053
  kind: "assist",
@@ -1104,7 +1124,14 @@ function buildIngressChangeReviewMenu(type, baseArgs, state, preview) {
1104
1124
 
1105
1125
  prelude.push(colorize("变更后:", COLORS.bold, COLORS.white));
1106
1126
  prelude.push(...renderRuleObjects(preview.nextRules).map((line) => colorize(line, COLORS.dim, COLORS.gray)));
1107
- prelude.push(colorize(`暂不重启: ${formatEnabled(state.noRestart)}`, COLORS.dim, COLORS.gray));
1127
+ if (type === "add") {
1128
+ prelude.push(colorize(`覆盖已有 DNS 记录: ${formatEnabled(state.overwriteDns)}`, COLORS.dim, COLORS.gray));
1129
+ prelude.push(colorize(`跳过本地连通性检查: ${formatEnabled(state.skipCheck)}`, COLORS.dim, COLORS.gray));
1130
+ prelude.push(colorize(`暂不重启: ${formatEnabled(state.noRestart)}`, COLORS.dim, COLORS.gray));
1131
+ prelude.push(colorize(`激活为默认配置: ${formatEnabled(state.activate)}`, COLORS.dim, COLORS.gray));
1132
+ } else {
1133
+ prelude.push(colorize(`暂不重启: ${formatEnabled(state.noRestart)}`, COLORS.dim, COLORS.gray));
1134
+ }
1108
1135
 
1109
1136
  let commandArgs;
1110
1137
  if (type === "modify") {
@@ -1117,24 +1144,41 @@ function buildIngressChangeReviewMenu(type, baseArgs, state, preview) {
1117
1144
  } else {
1118
1145
  commandArgs = ["ingress-remove", state.name, ...buildRemoveArgs(state.specs)];
1119
1146
  }
1147
+ if (type === "add") {
1148
+ if (state.overwriteDns) commandArgs.push("--overwrite-dns");
1149
+ if (state.skipCheck) commandArgs.push("--skip-check");
1150
+ }
1120
1151
  if (state.noRestart) {
1121
1152
  commandArgs.push("--no-restart");
1122
1153
  }
1154
+ if (type === "add" && state.activate) {
1155
+ commandArgs.push("--activate");
1156
+ }
1123
1157
 
1124
1158
  prelude.push(colorize("命令预览:", COLORS.bold, COLORS.cyan));
1125
1159
  prelude.push(...renderCommandPreview(baseArgs, commandArgs).map((line) => colorize(line, COLORS.dim, COLORS.gray)));
1126
1160
 
1127
- const items = [
1128
- { value: "1", label: "执行变更", hint: "调用底层 shell 脚本真正落地", kind: "primary" },
1129
- {
1130
- value: "2",
1131
- label: type === "modify" ? "重新录入修改规则" : type === "add" ? "重新录入新增规则" : "重新录入删除规则",
1132
- hint: `当前共 ${state.specs.length} 条`,
1133
- kind: "secondary",
1134
- },
1135
- { value: "3", label: "切换“暂不重启”", hint: `当前: ${formatEnabled(state.noRestart)}`, kind: "assist" },
1136
- { value: "0", label: "取消当前流程", hint: "不执行这次变更", kind: "danger", back: true },
1137
- ];
1161
+ const items = type === "add"
1162
+ ? [
1163
+ { value: "1", label: "执行变更", hint: "调用底层 shell 脚本真正落地", kind: "primary" },
1164
+ { value: "2", label: "重新录入新增规则", hint: `当前共 ${state.specs.length} 条`, kind: "secondary" },
1165
+ { value: "3", label: "切换“覆盖已有 DNS”", hint: `当前: ${formatEnabled(state.overwriteDns)}`, kind: "assist" },
1166
+ { value: "4", label: "切换“跳过连通性检查”", hint: `当前: ${formatEnabled(state.skipCheck)}`, kind: "assist" },
1167
+ { value: "5", label: "切换“暂不重启”", hint: `当前: ${formatEnabled(state.noRestart)}`, kind: "assist" },
1168
+ { value: "6", label: "切换“激活为默认配置”", hint: `当前: ${formatEnabled(state.activate)}`, kind: "assist" },
1169
+ { value: "0", label: "取消当前流程", hint: "不执行这次变更", kind: "danger", back: true },
1170
+ ]
1171
+ : [
1172
+ { value: "1", label: "执行变更", hint: "调用底层 shell 脚本真正落地", kind: "primary" },
1173
+ {
1174
+ value: "2",
1175
+ label: type === "modify" ? "重新录入修改规则" : "重新录入删除规则",
1176
+ hint: `当前共 ${state.specs.length} 条`,
1177
+ kind: "secondary",
1178
+ },
1179
+ { value: "3", label: "切换“暂不重启”", hint: `当前: ${formatEnabled(state.noRestart)}`, kind: "assist" },
1180
+ { value: "0", label: "取消当前流程", hint: "不执行这次变更", kind: "danger", back: true },
1181
+ ];
1138
1182
 
1139
1183
  return {
1140
1184
  key: `${type}_ingress_review`,
@@ -1198,7 +1242,10 @@ async function runIngressAddWizard(rl, baseArgs, name) {
1198
1242
  name,
1199
1243
  currentRules,
1200
1244
  specs: await collectRequiredIngressSpecs(rl),
1245
+ overwriteDns: false,
1246
+ skipCheck: false,
1201
1247
  noRestart: true,
1248
+ activate: false,
1202
1249
  };
1203
1250
 
1204
1251
  while (true) {
@@ -1217,8 +1264,17 @@ async function runIngressAddWizard(rl, baseArgs, name) {
1217
1264
  state.specs = await collectRequiredIngressSpecs(rl);
1218
1265
  break;
1219
1266
  case "3":
1267
+ state.overwriteDns = !state.overwriteDns;
1268
+ break;
1269
+ case "4":
1270
+ state.skipCheck = !state.skipCheck;
1271
+ break;
1272
+ case "5":
1220
1273
  state.noRestart = !state.noRestart;
1221
1274
  break;
1275
+ case "6":
1276
+ state.activate = !state.activate;
1277
+ break;
1222
1278
  case "0":
1223
1279
  return null;
1224
1280
  default:
@@ -1338,6 +1394,8 @@ async function runAddWizard(rl, baseArgs) {
1338
1394
  name: "",
1339
1395
  tunnelName: "",
1340
1396
  specs: [],
1397
+ overwriteDns: false,
1398
+ skipCheck: false,
1341
1399
  start: false,
1342
1400
  activate: false,
1343
1401
  };
@@ -1372,9 +1430,15 @@ async function runAddWizard(rl, baseArgs) {
1372
1430
  state.specs = await collectRequiredIngressSpecs(rl);
1373
1431
  break;
1374
1432
  case "5":
1375
- state.start = !state.start;
1433
+ state.overwriteDns = !state.overwriteDns;
1376
1434
  break;
1377
1435
  case "6":
1436
+ state.skipCheck = !state.skipCheck;
1437
+ break;
1438
+ case "7":
1439
+ state.start = !state.start;
1440
+ break;
1441
+ case "8":
1378
1442
  state.activate = !state.activate;
1379
1443
  break;
1380
1444
  case "0":
@@ -1393,6 +1457,8 @@ async function runAdoptWizard(rl, baseArgs) {
1393
1457
  tunnelName: "",
1394
1458
  specs: [],
1395
1459
  ensureDns: false,
1460
+ overwriteDns: false,
1461
+ skipCheck: false,
1396
1462
  activate: false,
1397
1463
  };
1398
1464
 
@@ -1433,8 +1499,20 @@ async function runAdoptWizard(rl, baseArgs) {
1433
1499
  break;
1434
1500
  case "5":
1435
1501
  state.ensureDns = !state.ensureDns;
1502
+ if (!state.ensureDns) {
1503
+ state.overwriteDns = false;
1504
+ }
1436
1505
  break;
1437
1506
  case "6":
1507
+ state.overwriteDns = !state.overwriteDns;
1508
+ if (state.overwriteDns) {
1509
+ state.ensureDns = true;
1510
+ }
1511
+ break;
1512
+ case "7":
1513
+ state.skipCheck = !state.skipCheck;
1514
+ break;
1515
+ case "8":
1438
1516
  state.activate = !state.activate;
1439
1517
  break;
1440
1518
  case "0":
@@ -1871,6 +1949,8 @@ async function handleAction(rl, baseArgs, action, context = {}) {
1871
1949
  return { keepRunning: true };
1872
1950
  }
1873
1951
  args = ["add", addState.name, "--tunnel-name", addState.tunnelName, ...buildIngressArgs(addState.specs)];
1952
+ if (addState.overwriteDns) args.push("--overwrite-dns");
1953
+ if (addState.skipCheck) args.push("--skip-check");
1874
1954
  if (addState.start) args.push("--start");
1875
1955
  if (addState.activate) args.push("--activate");
1876
1956
  runShell(baseArgs, args);
@@ -1888,6 +1968,8 @@ async function handleAction(rl, baseArgs, action, context = {}) {
1888
1968
  }
1889
1969
  args = ["adopt", adoptState.name, "--tunnel-name", adoptState.tunnelName, ...buildIngressArgs(adoptState.specs)];
1890
1970
  if (adoptState.ensureDns) args.push("--ensure-dns");
1971
+ if (adoptState.ensureDns && adoptState.overwriteDns) args.push("--overwrite-dns");
1972
+ if (adoptState.skipCheck) args.push("--skip-check");
1891
1973
  if (adoptState.activate) args.push("--activate");
1892
1974
  runShell(baseArgs, args);
1893
1975
  return { keepRunning: true };
@@ -1937,7 +2019,10 @@ async function handleAction(rl, baseArgs, action, context = {}) {
1937
2019
  return { keepRunning: true };
1938
2020
  }
1939
2021
  args = ["ingress-add", name, ...buildIngressArgs(addState.specs)];
2022
+ if (addState.overwriteDns) args.push("--overwrite-dns");
2023
+ if (addState.skipCheck) args.push("--skip-check");
1940
2024
  if (addState.noRestart) args.push("--no-restart");
2025
+ if (addState.activate) args.push("--activate");
1941
2026
  runShell(baseArgs, args);
1942
2027
  return { keepRunning: true };
1943
2028
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflared-manager",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Interactive wrapper and shell-first manager for cloudflared tunnels",
5
5
  "type": "module",
6
6
  "bin": {