@weapp-tailwindcss/hbuilderx-runner 0.1.5 → 0.1.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/dist/index.cjs CHANGED
@@ -507,8 +507,12 @@ const ansiRE = new RegExp(`${String.fromCharCode(27)}\\[[\\d;]*m`, "g");
507
507
  function stripAnsi(value) {
508
508
  return value.replace(ansiRE, "");
509
509
  }
510
+ /** CLI 的未启动协议响应因界面语言不同而变化,不能作为 host 名称解析。 */
511
+ function isStoppedHostDiagnostic(line) {
512
+ return /^(?:HBuilderX is not detected running\. Please execute cli open.*|没有可用的命令[,,]尝试使用\s*cli open|未检测到已打开的\s*HBuilderX[,,]请先执行\s*cli open.*)$/i.test(line.trim());
513
+ }
510
514
  function parseHBuilderXHosts(output) {
511
- return [...new Set(stripAnsi(output).split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !/^-?\d+:cli:|命令.+(?:不存在|错误)|not detected running/i.test(line)))];
515
+ return [...new Set(stripAnsi(output).split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !isStoppedHostDiagnostic(line) && !/^-?\d+:cli:|命令.+(?:不存在|错误)|not detected running/i.test(line)))];
512
516
  }
513
517
  function parseHBuilderXVersion(output) {
514
518
  return stripAnsi(output).match(/\b(\d+\.\d+(?:\.\d+)+(?:-[0-9a-z.-]+)?)\b/i)?.[1];
@@ -578,7 +582,7 @@ async function connectHBuilderXHost(options) {
578
582
  };
579
583
  const probe = async () => {
580
584
  const listed = await command(["listhost"]);
581
- if (!(listed.issue.kind !== "timeout" && /HBuilderX is not detected running\. Please execute cli open/i.test(stripAnsi(listed.output)))) assertCommand(listed);
585
+ if (!(listed.issue.kind !== "timeout" && stripAnsi(listed.output).split(/\r?\n/).some(isStoppedHostDiagnostic))) assertCommand(listed);
582
586
  const hosts = parseHBuilderXHosts(listed.output);
583
587
  const compatible = [];
584
588
  for (const host of explicitHost ? [explicitHost] : hosts) {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { ChildProcess } from "node:child_process";
2
1
  import { Buffer } from "node:buffer";
2
+ import { ChildProcess } from "node:child_process";
3
3
  //#region src/fs.d.ts
4
4
  export declare function fileExists(file: string): Promise<boolean>;
5
5
  export declare function readUtf8(file: string): Promise<string>;
package/dist/index.mjs CHANGED
@@ -480,8 +480,12 @@ const ansiRE = new RegExp(`${String.fromCharCode(27)}\\[[\\d;]*m`, "g");
480
480
  function stripAnsi(value) {
481
481
  return value.replace(ansiRE, "");
482
482
  }
483
+ /** CLI 的未启动协议响应因界面语言不同而变化,不能作为 host 名称解析。 */
484
+ function isStoppedHostDiagnostic(line) {
485
+ return /^(?:HBuilderX is not detected running\. Please execute cli open.*|没有可用的命令[,,]尝试使用\s*cli open|未检测到已打开的\s*HBuilderX[,,]请先执行\s*cli open.*)$/i.test(line.trim());
486
+ }
483
487
  function parseHBuilderXHosts(output) {
484
- return [...new Set(stripAnsi(output).split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !/^-?\d+:cli:|命令.+(?:不存在|错误)|not detected running/i.test(line)))];
488
+ return [...new Set(stripAnsi(output).split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0 && !isStoppedHostDiagnostic(line) && !/^-?\d+:cli:|命令.+(?:不存在|错误)|not detected running/i.test(line)))];
485
489
  }
486
490
  function parseHBuilderXVersion(output) {
487
491
  return stripAnsi(output).match(/\b(\d+\.\d+(?:\.\d+)+(?:-[0-9a-z.-]+)?)\b/i)?.[1];
@@ -551,7 +555,7 @@ async function connectHBuilderXHost(options) {
551
555
  };
552
556
  const probe = async () => {
553
557
  const listed = await command(["listhost"]);
554
- if (!(listed.issue.kind !== "timeout" && /HBuilderX is not detected running\. Please execute cli open/i.test(stripAnsi(listed.output)))) assertCommand(listed);
558
+ if (!(listed.issue.kind !== "timeout" && stripAnsi(listed.output).split(/\r?\n/).some(isStoppedHostDiagnostic))) assertCommand(listed);
555
559
  const hosts = parseHBuilderXHosts(listed.output);
556
560
  const compatible = [];
557
561
  for (const host of explicitHost ? [explicitHost] : hosts) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@weapp-tailwindcss/hbuilderx-runner",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "description": "HBuilderX runner utilities for cross-platform uni-app Tailwind CSS workflows. 跨端 uni-app Tailwind CSS 工作流的 HBuilderX 运行器工具。",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",