my-singbox 2.0.0-next.0 → 2.0.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
@@ -13,20 +13,13 @@ sh install.sh && export PATH="$HOME/.local/node/bin:$PATH"
13
13
 
14
14
  The installer installs Node >= 22 to `~/.local/node` without sudo; it skips installation if Node >= 22 is already on PATH.
15
15
 
16
- > **The npm package `my-singbox` is not published yet, so `npx my-singbox ...` does not work for now.** Examples below use `npx my-singbox <cmd>`. Until the package is published, use one of these routes instead (both tested):
17
- >
18
- > ```bash
19
- > # A) from a checkout of this repository
20
- > git clone --branch ts-version https://github.com/zht7063/my-singbox.git && cd my-singbox
21
- > npm ci && npm run build
22
- > node dist/cli.js doctor # replaces "npx my-singbox doctor"
23
- >
24
- > # B) install a packed tarball
25
- > npm pack
26
- > npm install -g ./my-singbox-*.tgz # then run "my-singbox <cmd>"
27
- > ```
28
- >
29
- > Run commands from the deployment directory (for example `/opt/sing-box`). For route A, call `node /path/to/my-singbox/dist/cli.js <cmd>` with the absolute path.
16
+ Install the CLI from npm:
17
+
18
+ ```bash
19
+ npm i -g my-singbox # then run "my-singbox <cmd>"
20
+ ```
21
+
22
+ Or run it without installing: `npx my-singbox <cmd>`. Examples below use `npx my-singbox <cmd>`; after a global install, drop `npx`. Run commands from the deployment directory (for example `/opt/sing-box`).
30
23
 
31
24
  ## Usage
32
25
 
package/README_CN.md CHANGED
@@ -13,20 +13,13 @@ sh install.sh && export PATH="$HOME/.local/node/bin:$PATH"
13
13
 
14
14
  安装程序无需 sudo,将 Node >= 22 安装到 `~/.local/node`;如果 PATH 中已有 Node >= 22,则跳过安装。
15
15
 
16
- > **npm 包 `my-singbox` 尚未发布,目前 `npx my-singbox ...` 无法使用。** 下文示例写作 `npx my-singbox <cmd>`。包发布之前,请改用下面任一方式(均已验证):
17
- >
18
- > ```bash
19
- > # A) 从本仓库的检出目录运行
20
- > git clone --branch ts-version https://github.com/zht7063/my-singbox.git && cd my-singbox
21
- > npm ci && npm run build
22
- > node dist/cli.js doctor # 代替 "npx my-singbox doctor"
23
- >
24
- > # B) 安装打包后的 tarball
25
- > npm pack
26
- > npm install -g ./my-singbox-*.tgz # 之后运行 "my-singbox <cmd>"
27
- > ```
28
- >
29
- > 请在部署目录(例如 `/opt/sing-box`)中运行命令。方式 A 请使用绝对路径:`node /path/to/my-singbox/dist/cli.js <cmd>`。
16
+ 从 npm 安装命令行工具:
17
+
18
+ ```bash
19
+ npm i -g my-singbox # 之后运行 "my-singbox <cmd>"
20
+ ```
21
+
22
+ 也可以无需安装直接运行:`npx my-singbox <cmd>`。下文示例写作 `npx my-singbox <cmd>`;全局安装后可省略 `npx`。请在部署目录(例如 `/opt/sing-box`)中运行命令。
30
23
 
31
24
  ## 使用
32
25
 
package/dist/cli.js CHANGED
@@ -8036,7 +8036,7 @@ async function genConfig(io) {
8036
8036
  const project = resolve2(io.cwd ?? process.cwd());
8037
8037
  const envPath = resolve2(project, ".env");
8038
8038
  if (!existsSync3(envPath))
8039
- throw new CliError(".env does not exist. Run scripts/gen-keys.sh first.");
8039
+ throw new CliError(".env does not exist. Run my-singbox gen-keys first.");
8040
8040
  const template = findTemplate("config.json.template", project);
8041
8041
  const path = resolve2(project, "config.json");
8042
8042
  if (existsSync3(path))
@@ -8115,7 +8115,7 @@ async function confClash(io) {
8115
8115
  const project = resolve3(io.cwd ?? process.cwd());
8116
8116
  const envPath = resolve3(project, ".env");
8117
8117
  if (!existsSync4(envPath))
8118
- throw new CliError(".env does not exist. Run scripts/gen-keys.sh first.");
8118
+ throw new CliError(".env does not exist. Run my-singbox gen-keys first.");
8119
8119
  const template = findTemplate("clash.yaml.template", project);
8120
8120
  const path = resolve3(project, "clash.yaml");
8121
8121
  if (existsSync4(path))
@@ -8257,7 +8257,7 @@ function addIspToClash(text, realityPrivateKey) {
8257
8257
  const doc = (0, import_yaml2.parseDocument)(text);
8258
8258
  if (doc.errors.length) throw new IspError("clash.yaml is not valid YAML.");
8259
8259
  const proxies = doc.get("proxies", true);
8260
- const missing = `clash.yaml has no usable node named "${NODE_SS}" and "${NODE_VLESS}". It was probably generated by an older version (My-sing-box / My-VLESS-Reality). Delete clash.yaml, run scripts/conf-clash.sh to regenerate it, re-import it in your clients, then re-run this script.`;
8260
+ const missing = `clash.yaml has no usable node named "${NODE_SS}" and "${NODE_VLESS}". It was probably generated by an older version (My-sing-box / My-VLESS-Reality). Delete clash.yaml, run my-singbox conf-clash to regenerate it, re-import it in your clients, then re-run my-singbox isp-outbound --add.`;
8261
8261
  if (!(0, import_yaml2.isSeq)(proxies)) throw new IspError(missing);
8262
8262
  let changed = false;
8263
8263
  for (const [base, name, basePort, port] of [
@@ -8291,7 +8291,7 @@ function addIspToClash(text, realityPrivateKey) {
8291
8291
  const group = (0, import_yaml2.isSeq)(groups) ? groups.items.find((g) => (0, import_yaml2.isMap)(g) && g.get("name") === GROUP_MAIN) : void 0;
8292
8292
  const list = (0, import_yaml2.isMap)(group) ? group.get("proxies", true) : void 0;
8293
8293
  if (!(0, import_yaml2.isSeq)(list))
8294
- throw new IspError(`clash.yaml has no '${GROUP_MAIN}' proxy group with a 'proxies:' list in the expected format (generated by scripts/conf-clash.sh). Regenerate clash.yaml, re-import it in your clients, then re-run this script.`);
8294
+ throw new IspError(`clash.yaml has no '${GROUP_MAIN}' proxy group with a 'proxies:' list in the expected format (generated by my-singbox conf-clash). Regenerate clash.yaml, re-import it in your clients, then re-run my-singbox isp-outbound --add.`);
8295
8295
  for (const name of [NODE_SS_ISP, NODE_VLESS_ISP]) {
8296
8296
  if (!list.items.some((item) => (0, import_yaml2.isScalar)(item) && item.value === name)) {
8297
8297
  list.add(name);
@@ -8721,7 +8721,7 @@ async function ispOutbound(io, opts) {
8721
8721
  };
8722
8722
  const preflightConfig = () => {
8723
8723
  if (!isFile(path("config.json")))
8724
- throw new IspError("config.json does not exist. Run scripts/gen-config.sh first.");
8724
+ throw new IspError("config.json does not exist. Run my-singbox gen-config first.");
8725
8725
  const text = readFileSync6(path("config.json"), "utf8");
8726
8726
  let config;
8727
8727
  try {
@@ -8754,7 +8754,7 @@ async function ispOutbound(io, opts) {
8754
8754
  const add = async (image) => {
8755
8755
  const original = preflightConfig();
8756
8756
  if (!isFile(path(".env")))
8757
- throw new IspError(".env does not exist. Run scripts/gen-keys.sh first.");
8757
+ throw new IspError(".env does not exist. Run my-singbox gen-keys first.");
8758
8758
  if (!configHasIsp(original.config)) await service.portsFree();
8759
8759
  const envText = readFileSync6(path(".env"), "utf8");
8760
8760
  const isp = await collectInputs(envText, ask);
@@ -8780,7 +8780,7 @@ async function ispOutbound(io, opts) {
8780
8780
  candidate(clashCandidate);
8781
8781
  clashState = `clash.yaml updated (nodes ${NODE_SS_ISP} and ${NODE_VLESS_ISP} added and listed in the ${GROUP_MAIN} group).`;
8782
8782
  } else {
8783
- warn("clash.yaml does not exist, so only the server config is changed. After running scripts/conf-clash.sh, re-run this script with --add to add the client nodes.");
8783
+ warn("clash.yaml does not exist, so only the server config is changed. After running my-singbox conf-clash, re-run my-singbox isp-outbound --add to add the client nodes.");
8784
8784
  clashState = "clash.yaml not found (skipped).";
8785
8785
  }
8786
8786
  const changed = configText !== original.text;
@@ -8870,12 +8870,12 @@ Notes:
8870
8870
  if (docker === "permission-denied")
8871
8871
  throw new IspError(`permission denied while talking to the Docker daemon (the Docker socket is not accessible to this user). Nothing was changed.
8872
8872
  Do one of these, then re-run:
8873
- - run this script with sudo: sudo my-singbox isp-outbound ${action ? `--${action}` : ""}
8873
+ - run it with sudo: sudo my-singbox isp-outbound ${action ? `--${action}` : ""}
8874
8874
  - or add your user to the docker group and log in again: sudo usermod -aG docker "$USER" (then log out and back in)`);
8875
8875
  if (docker === "down")
8876
8876
  throw new IspError("Docker daemon is not running (or not reachable). Start it and re-run. Nothing was changed.");
8877
8877
  const image = await service.containerImage();
8878
- if (!image) throw new IspError("Container sing-box not found. Run scripts/start.sh first.");
8878
+ if (!image) throw new IspError("Container sing-box not found. Run my-singbox start first.");
8879
8879
  const sudoHint = `sudo my-singbox isp-outbound ${action ? `--${action}` : ""}`;
8880
8880
  try {
8881
8881
  accessSync(projectDir, constants.W_OK);
@@ -9221,7 +9221,7 @@ Options: --help, -h
9221
9221
  var ispUsage = `Usage: my-singbox isp-outbound [--add | --remove] [--yes]
9222
9222
 
9223
9223
  --add add or update the ISP outbound (ports 13839 and 18444)
9224
- --remove remove the ISP outbound and everything this script added
9224
+ --remove remove the ISP outbound and everything it added
9225
9225
  --yes, -y do not ask before restarting sing-box
9226
9226
  --help show this help
9227
9227
 
@@ -9265,8 +9265,7 @@ async function dispatch(argv, io) {
9265
9265
  }
9266
9266
  return ispOutbound(io, { action, yes });
9267
9267
  } else if (args.some((a) => ["--help", "-h"].includes(a))) {
9268
- const help = cmd === "doctor" ? "\nCheck server prerequisites without changing the system." : ` [args]
9269
- Equivalent shell script: scripts/${cmd}.sh`;
9268
+ const help = cmd === "doctor" ? "\nCheck server prerequisites without changing the system." : " [args]";
9270
9269
  io.stdout(`Usage: my-singbox ${cmd}${help}
9271
9270
  `);
9272
9271
  return 0;
package/dist/index.js CHANGED
@@ -8140,7 +8140,7 @@ function addIspToClash(text, realityPrivateKey) {
8140
8140
  const doc = (0, import_yaml2.parseDocument)(text);
8141
8141
  if (doc.errors.length) throw new IspError("clash.yaml is not valid YAML.");
8142
8142
  const proxies = doc.get("proxies", true);
8143
- const missing = `clash.yaml has no usable node named "${NODE_SS}" and "${NODE_VLESS}". It was probably generated by an older version (My-sing-box / My-VLESS-Reality). Delete clash.yaml, run scripts/conf-clash.sh to regenerate it, re-import it in your clients, then re-run this script.`;
8143
+ const missing = `clash.yaml has no usable node named "${NODE_SS}" and "${NODE_VLESS}". It was probably generated by an older version (My-sing-box / My-VLESS-Reality). Delete clash.yaml, run my-singbox conf-clash to regenerate it, re-import it in your clients, then re-run my-singbox isp-outbound --add.`;
8144
8144
  if (!(0, import_yaml2.isSeq)(proxies)) throw new IspError(missing);
8145
8145
  let changed = false;
8146
8146
  for (const [base, name, basePort, port] of [
@@ -8174,7 +8174,7 @@ function addIspToClash(text, realityPrivateKey) {
8174
8174
  const group = (0, import_yaml2.isSeq)(groups) ? groups.items.find((g) => (0, import_yaml2.isMap)(g) && g.get("name") === GROUP_MAIN) : void 0;
8175
8175
  const list = (0, import_yaml2.isMap)(group) ? group.get("proxies", true) : void 0;
8176
8176
  if (!(0, import_yaml2.isSeq)(list))
8177
- throw new IspError(`clash.yaml has no '${GROUP_MAIN}' proxy group with a 'proxies:' list in the expected format (generated by scripts/conf-clash.sh). Regenerate clash.yaml, re-import it in your clients, then re-run this script.`);
8177
+ throw new IspError(`clash.yaml has no '${GROUP_MAIN}' proxy group with a 'proxies:' list in the expected format (generated by my-singbox conf-clash). Regenerate clash.yaml, re-import it in your clients, then re-run my-singbox isp-outbound --add.`);
8178
8178
  for (const name of [NODE_SS_ISP, NODE_VLESS_ISP]) {
8179
8179
  if (!list.items.some((item) => (0, import_yaml2.isScalar)(item) && item.value === name)) {
8180
8180
  list.add(name);
package/install.sh CHANGED
@@ -57,8 +57,7 @@ node_dir=${MY_SINGBOX_NODE_DIR:-$HOME/.local/node}
57
57
 
58
58
  hints() {
59
59
  printf 'PATH hint: export PATH="%s/bin:$PATH"\n' "$node_dir"
60
- echo 'Next: npx my-singbox doctor (package is not published yet in P1).'
61
- echo 'From a checkout: node dist/cli.js doctor'
60
+ echo 'Next: npm i -g my-singbox && my-singbox doctor (or: npx my-singbox doctor).'
62
61
  }
63
62
 
64
63
  usable_node() {
@@ -70,7 +69,7 @@ usable_node() {
70
69
  if [[ ${MY_SINGBOX_FORCE_NODE_INSTALL:-0} != 1 ]]; then
71
70
  if command -v node >/dev/null 2>&1 && usable_node node; then
72
71
  echo "Using Node already on PATH: $(command -v node)"
73
- echo 'Next: npx my-singbox doctor (package is not published yet in P1). From a checkout: node dist/cli.js doctor'
72
+ echo 'Next: npm i -g my-singbox && my-singbox doctor (or: npx my-singbox doctor).'
74
73
  exit 0
75
74
  fi
76
75
  if [[ -x $node_dir/bin/node ]] && usable_node "$node_dir/bin/node"; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "my-singbox",
3
- "version": "2.0.0-next.0",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "engines": {