@weapp-tailwindcss/hbuilderx-runner 0.1.8 → 0.1.9
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.d.cts +202 -0
- package/dist/index.d.ts +1 -1
- package/package.json +9 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { ChildProcess } from "node:child_process";
|
|
2
|
+
import { Buffer } from "node:buffer";
|
|
3
|
+
export declare function fileExists(file: string): Promise<boolean>;
|
|
4
|
+
export declare function readUtf8(file: string): Promise<string>;
|
|
5
|
+
export declare function wait(ms: number): Promise<unknown>;
|
|
6
|
+
export type HBuilderXMiniProgramPlatform = 'mp-weixin' | 'mp-alipay' | 'mp-baidu' | 'mp-toutiao';
|
|
7
|
+
export type HBuilderXAppPlatform = 'app-android' | 'app-ios' | 'app-harmony';
|
|
8
|
+
export type HBuilderXPlatform = HBuilderXMiniProgramPlatform | HBuilderXAppPlatform;
|
|
9
|
+
export type HBuilderXChannel = 'auto' | 'stable' | 'alpha';
|
|
10
|
+
export type HBuilderXResolvedChannel = Exclude<HBuilderXChannel, 'auto'> | 'unknown';
|
|
11
|
+
export type HBuilderXIssueKind = 'cli-not-found' | 'cli-instance-mismatch' | 'cli-host-ambiguous' | 'project-not-uni-app' | 'project-type-unsupported' | 'config-load-failed' | 'android-toolchain-missing' | 'ios-toolchain-missing' | 'harmony-toolchain-missing' | 'harmony-build-failed' | 'timeout' | 'process-exit' | 'unknown';
|
|
12
|
+
export interface HBuilderXIssue {
|
|
13
|
+
kind: HBuilderXIssueKind;
|
|
14
|
+
message: string;
|
|
15
|
+
hint?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CommandExit {
|
|
18
|
+
code: number | null;
|
|
19
|
+
signal: NodeJS.Signals | null;
|
|
20
|
+
}
|
|
21
|
+
export interface HBuilderXCommandOptions {
|
|
22
|
+
command: string;
|
|
23
|
+
args: string[];
|
|
24
|
+
cwd: string;
|
|
25
|
+
/** 业务截止时间;超时后另有有界进程清理预算。 */
|
|
26
|
+
timeoutMs?: number;
|
|
27
|
+
env?: Record<string, string | undefined>;
|
|
28
|
+
allowFailure?: boolean;
|
|
29
|
+
detached?: boolean;
|
|
30
|
+
stdio?: 'pipe' | 'inherit';
|
|
31
|
+
}
|
|
32
|
+
export interface HBuilderXCommandResult {
|
|
33
|
+
command: string;
|
|
34
|
+
args: string[];
|
|
35
|
+
cwd: string;
|
|
36
|
+
exit: CommandExit;
|
|
37
|
+
logs: string[];
|
|
38
|
+
output: string;
|
|
39
|
+
issue: HBuilderXIssue;
|
|
40
|
+
}
|
|
41
|
+
export interface SpawnedHBuilderXCommand {
|
|
42
|
+
child: ChildProcess;
|
|
43
|
+
logs: string[];
|
|
44
|
+
command: string;
|
|
45
|
+
args: string[];
|
|
46
|
+
cwd: string;
|
|
47
|
+
/** 在 close 前启动有界清理并确认本轮进程树结束;失败抛出诊断,多次调用复用同一结果。 */
|
|
48
|
+
stop: (signal?: NodeJS.Signals) => Promise<void>;
|
|
49
|
+
closed: Promise<CommandExit>;
|
|
50
|
+
ensureRunning: () => void;
|
|
51
|
+
}
|
|
52
|
+
export interface HBuilderXProjectOptions {
|
|
53
|
+
cwd: string;
|
|
54
|
+
hbuilderxCliPath?: string;
|
|
55
|
+
channel?: HBuilderXChannel;
|
|
56
|
+
host?: string;
|
|
57
|
+
env?: Record<string, string | undefined>;
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
allowFailure?: boolean;
|
|
60
|
+
}
|
|
61
|
+
export interface HBuilderXLaunchOptions extends HBuilderXProjectOptions {
|
|
62
|
+
platform: HBuilderXPlatform;
|
|
63
|
+
args?: string[];
|
|
64
|
+
compile?: boolean;
|
|
65
|
+
runtimeLog?: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface ToolResult {
|
|
68
|
+
ok: boolean;
|
|
69
|
+
output: string;
|
|
70
|
+
status: number | null;
|
|
71
|
+
signal: NodeJS.Signals | null;
|
|
72
|
+
}
|
|
73
|
+
export interface AndroidToolchain {
|
|
74
|
+
command: string;
|
|
75
|
+
output: string;
|
|
76
|
+
env: Record<string, string> | undefined;
|
|
77
|
+
}
|
|
78
|
+
export type HBuilderXCliResolutionSource = 'running-process' | 'env' | 'default-path' | 'candidate';
|
|
79
|
+
export interface HBuilderXCliResolveOptions {
|
|
80
|
+
candidates?: string[];
|
|
81
|
+
channel?: HBuilderXChannel;
|
|
82
|
+
env?: NodeJS.ProcessEnv;
|
|
83
|
+
host?: string;
|
|
84
|
+
}
|
|
85
|
+
export interface HBuilderXCliResolution {
|
|
86
|
+
path: string;
|
|
87
|
+
isRunning: boolean;
|
|
88
|
+
source: HBuilderXCliResolutionSource;
|
|
89
|
+
channel: HBuilderXResolvedChannel;
|
|
90
|
+
host?: string;
|
|
91
|
+
version?: string;
|
|
92
|
+
}
|
|
93
|
+
export interface HBuilderXNativeCommandOptions {
|
|
94
|
+
args: string[];
|
|
95
|
+
cwd?: string;
|
|
96
|
+
timeoutMs?: number;
|
|
97
|
+
env?: Record<string, string | undefined>;
|
|
98
|
+
allowFailure?: boolean;
|
|
99
|
+
detached?: boolean;
|
|
100
|
+
stdio?: 'pipe' | 'inherit';
|
|
101
|
+
}
|
|
102
|
+
export interface HBuilderXRunnerOptions extends HBuilderXCliResolveOptions {
|
|
103
|
+
cwd?: string;
|
|
104
|
+
hbuilderxCliPath?: string;
|
|
105
|
+
timeoutMs?: number;
|
|
106
|
+
}
|
|
107
|
+
export interface HBuilderXRunner {
|
|
108
|
+
resolution: HBuilderXCliResolution;
|
|
109
|
+
run: (options: HBuilderXNativeCommandOptions) => Promise<HBuilderXCommandResult>;
|
|
110
|
+
spawn: (options: HBuilderXNativeCommandOptions) => SpawnedHBuilderXCommand;
|
|
111
|
+
closeProject: (options: HBuilderXProjectOptions) => Promise<HBuilderXCommandResult>;
|
|
112
|
+
openProject: (options: HBuilderXProjectOptions) => Promise<HBuilderXCommandResult>;
|
|
113
|
+
prepareProject: (options: HBuilderXProjectOptions) => Promise<HBuilderXCommandResult>;
|
|
114
|
+
launchProject: (options: HBuilderXLaunchOptions) => Promise<HBuilderXCommandResult>;
|
|
115
|
+
startLaunch: (options: HBuilderXLaunchOptions) => SpawnedHBuilderXCommand;
|
|
116
|
+
}
|
|
117
|
+
export declare const macOSStableCli = "/Applications/HBuilderX.app/Contents/MacOS/cli";
|
|
118
|
+
export declare const macOSAlphaCli = "/Applications/HBuilderX-Alpha.app/Contents/MacOS/cli";
|
|
119
|
+
export declare function resolveHBuilderXChannel(channel?: string): HBuilderXChannel;
|
|
120
|
+
export declare function inferHBuilderXChannel(file: string): HBuilderXResolvedChannel;
|
|
121
|
+
export declare function getDefaultHBuilderXCliCandidates(env?: NodeJS.ProcessEnv, channel?: HBuilderXChannel, platform?: NodeJS.Platform): string[];
|
|
122
|
+
export declare function extractHBuilderXMacOSExecutables(output: string): string[];
|
|
123
|
+
export declare function extractHBuilderXWindowsExecutables(output: string): string[];
|
|
124
|
+
export declare function extractHBuilderXExecutablesFromProcessOutput(output: string, platform?: NodeJS.Platform): string[];
|
|
125
|
+
export declare function extractHBuilderXMacOSExecutable(line: string): string | undefined;
|
|
126
|
+
export declare function extractHBuilderXWindowsExecutable(line: string): string | undefined;
|
|
127
|
+
export declare function extractHBuilderXExecutableFromProcessOutput(output: string, platform?: NodeJS.Platform): string | undefined;
|
|
128
|
+
export declare function findRunningHBuilderXCliCandidates(platform?: NodeJS.Platform): Promise<string[]>;
|
|
129
|
+
export declare function findRunningHBuilderXCli(platform?: NodeJS.Platform): Promise<string | undefined>;
|
|
130
|
+
export declare function selectHBuilderXCliCandidatesForChannel(items: string[], channel: HBuilderXChannel): string[];
|
|
131
|
+
export declare function resolveHBuilderXCliInfoFromOptions(options?: HBuilderXCliResolveOptions): Promise<HBuilderXCliResolution>;
|
|
132
|
+
export declare class HBuilderXCommandError extends Error {
|
|
133
|
+
readonly result: HBuilderXCommandResult;
|
|
134
|
+
readonly cleanupError?: Error;
|
|
135
|
+
constructor(message: string, result: HBuilderXCommandResult, cleanupError?: Error);
|
|
136
|
+
}
|
|
137
|
+
/** 保留同步请求终止的兼容入口;需要确认关闭时必须等待 spawned.stop()。 */
|
|
138
|
+
export declare function killProcessTree(child: ChildProcess, signal?: NodeJS.Signals): void;
|
|
139
|
+
export declare function spawnCommand(options: HBuilderXCommandOptions): SpawnedHBuilderXCommand;
|
|
140
|
+
export declare function runCommand(options: HBuilderXCommandOptions): Promise<HBuilderXCommandResult>;
|
|
141
|
+
export declare function createProcessExitTracker(child: ChildProcess): {
|
|
142
|
+
closed: Promise<CommandExit>;
|
|
143
|
+
ensureRunning(logs: string[]): void;
|
|
144
|
+
};
|
|
145
|
+
export declare function stripAnsi(value: string): string;
|
|
146
|
+
export declare function parseHBuilderXHosts(output: string): string[];
|
|
147
|
+
export declare function parseHBuilderXVersion(output: string): string | undefined;
|
|
148
|
+
export declare function inferHBuilderXChannelFromVersion(version: string): HBuilderXResolvedChannel;
|
|
149
|
+
export declare function createHBuilderXNativeLaunchArgs(options: HBuilderXLaunchOptions): string[];
|
|
150
|
+
export declare function createHBuilderXRunner(options?: HBuilderXRunnerOptions): Promise<HBuilderXRunner>;
|
|
151
|
+
export declare function resolveHBuilderXCliInfo(options?: HBuilderXCliResolveOptions): ReturnType<typeof resolveHBuilderXCliInfoFromOptions>;
|
|
152
|
+
export declare function resolveHBuilderXCliInfo(candidates?: string[], env?: NodeJS.ProcessEnv): ReturnType<typeof resolveHBuilderXCliInfoFromOptions>;
|
|
153
|
+
export declare function resolveHBuilderXCli(options?: HBuilderXCliResolveOptions): Promise<string>;
|
|
154
|
+
export declare function resolveHBuilderXCli(candidates?: string[]): Promise<string>;
|
|
155
|
+
export declare function createHBuilderXEnv(options?: {
|
|
156
|
+
hbuilderxCliPath?: string;
|
|
157
|
+
env?: Record<string, string | undefined>;
|
|
158
|
+
}): {
|
|
159
|
+
HBUILDERX_CLI_PATH: string | undefined;
|
|
160
|
+
NODE_OPTIONS: string;
|
|
161
|
+
};
|
|
162
|
+
export declare function hbuilderxPnpmArgs(args: string[]): string[];
|
|
163
|
+
export declare function runPnpmCommand(options: HBuilderXProjectOptions & {
|
|
164
|
+
args: string[];
|
|
165
|
+
}): Promise<HBuilderXCommandResult>;
|
|
166
|
+
export declare function spawnPnpmCommand(options: HBuilderXProjectOptions & {
|
|
167
|
+
args: string[];
|
|
168
|
+
}): SpawnedHBuilderXCommand;
|
|
169
|
+
export declare function closeProject(options: HBuilderXProjectOptions): Promise<HBuilderXCommandResult>;
|
|
170
|
+
export declare function openProject(options: HBuilderXProjectOptions): Promise<HBuilderXCommandResult>;
|
|
171
|
+
export declare function prepareProject(options: HBuilderXProjectOptions): Promise<HBuilderXCommandResult>;
|
|
172
|
+
export declare function createLaunchArgs(options: HBuilderXLaunchOptions): string[];
|
|
173
|
+
export declare function launchProject(options: HBuilderXLaunchOptions): Promise<HBuilderXCommandResult>;
|
|
174
|
+
/**
|
|
175
|
+
* @deprecated 需要固定 stable/alpha 与 host 时,请使用 `createHBuilderXRunner().startLaunch()`。
|
|
176
|
+
*/
|
|
177
|
+
export declare function startLaunch(options: HBuilderXLaunchOptions): SpawnedHBuilderXCommand;
|
|
178
|
+
export declare function createLogBuffer(maxChunks?: number): {
|
|
179
|
+
logs: string[];
|
|
180
|
+
push(chunk: Buffer | string): void;
|
|
181
|
+
text(): string;
|
|
182
|
+
};
|
|
183
|
+
export declare function collectProcessOutput(child: ChildProcess, maxChunks?: number): string[];
|
|
184
|
+
export declare function classifyHBuilderXOutput(output: string): HBuilderXIssue;
|
|
185
|
+
export declare function createTimeoutIssue(): HBuilderXIssue;
|
|
186
|
+
export declare function formatRecentLogs(logs: string[], maxLength?: number): string;
|
|
187
|
+
export declare function runTool(command: string, args: string[]): ToolResult;
|
|
188
|
+
export declare function resolveAdbCommand(env?: NodeJS.ProcessEnv): AndroidToolchain;
|
|
189
|
+
export declare function assertAndroidToolchain(env?: NodeJS.ProcessEnv): Record<string, string> | undefined;
|
|
190
|
+
export declare function assertIosSimulatorToolchain(env?: NodeJS.ProcessEnv): void;
|
|
191
|
+
export interface IosSimulatorDevice {
|
|
192
|
+
lastBootedAt?: string;
|
|
193
|
+
name: string;
|
|
194
|
+
state: string;
|
|
195
|
+
udid: string;
|
|
196
|
+
}
|
|
197
|
+
export declare function parseIosSimulatorDevices(output: string): IosSimulatorDevice[];
|
|
198
|
+
export declare function selectPreferredIosSimulatorDevice(devices: IosSimulatorDevice[]): IosSimulatorDevice | undefined;
|
|
199
|
+
export declare function resolveIosSimulatorDeviceId(env?: NodeJS.ProcessEnv): string;
|
|
200
|
+
export declare function resolveHdcCommand(env?: NodeJS.ProcessEnv): string;
|
|
201
|
+
export declare function parseHdcTargets(output: string): string[];
|
|
202
|
+
export declare function assertHarmonyToolchain(env?: NodeJS.ProcessEnv, deviceId?: string): string;
|
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
|
export declare function fileExists(file: string): Promise<boolean>;
|
|
4
4
|
export declare function readUtf8(file: string): Promise<string>;
|
|
5
5
|
export declare function wait(ms: number): Promise<unknown>;
|
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.
|
|
4
|
+
"version": "0.1.9",
|
|
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",
|
|
@@ -25,9 +25,14 @@
|
|
|
25
25
|
"sideEffects": false,
|
|
26
26
|
"exports": {
|
|
27
27
|
".": {
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.mjs"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/index.d.cts",
|
|
34
|
+
"default": "./dist/index.cjs"
|
|
35
|
+
}
|
|
31
36
|
}
|
|
32
37
|
},
|
|
33
38
|
"main": "./dist/index.cjs",
|