@weapp-tailwindcss/hbuilderx-runner 0.0.3 → 0.1.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/dist/index.d.ts CHANGED
@@ -9,7 +9,9 @@ declare function wait(ms: number): Promise<unknown>;
9
9
  type HBuilderXMiniProgramPlatform = 'mp-weixin' | 'mp-alipay' | 'mp-baidu' | 'mp-toutiao';
10
10
  type HBuilderXAppPlatform = 'app-android' | 'app-ios' | 'app-harmony';
11
11
  type HBuilderXPlatform = HBuilderXMiniProgramPlatform | HBuilderXAppPlatform;
12
- type HBuilderXIssueKind = 'cli-not-found' | 'project-not-uni-app' | 'project-type-unsupported' | 'config-load-failed' | 'android-toolchain-missing' | 'ios-toolchain-missing' | 'harmony-toolchain-missing' | 'timeout' | 'process-exit' | 'unknown';
12
+ type HBuilderXChannel = 'auto' | 'stable' | 'alpha';
13
+ type HBuilderXResolvedChannel = Exclude<HBuilderXChannel, 'auto'> | 'unknown';
14
+ 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' | 'timeout' | 'process-exit' | 'unknown';
13
15
  interface HBuilderXIssue {
14
16
  kind: HBuilderXIssueKind;
15
17
  message: string;
@@ -51,6 +53,8 @@ interface SpawnedHBuilderXCommand {
51
53
  interface HBuilderXProjectOptions {
52
54
  cwd: string;
53
55
  hbuilderxCliPath?: string;
56
+ channel?: HBuilderXChannel;
57
+ host?: string;
54
58
  env?: Record<string, string | undefined>;
55
59
  timeoutMs?: number;
56
60
  allowFailure?: boolean;
@@ -73,19 +77,74 @@ interface AndroidToolchain {
73
77
  env: Record<string, string> | undefined;
74
78
  }
75
79
  type HBuilderXCliResolutionSource = 'running-process' | 'env' | 'default-path' | 'candidate';
80
+ interface HBuilderXCliResolveOptions {
81
+ candidates?: string[];
82
+ channel?: HBuilderXChannel;
83
+ env?: NodeJS.ProcessEnv;
84
+ host?: string;
85
+ }
76
86
  interface HBuilderXCliResolution {
77
87
  path: string;
78
88
  isRunning: boolean;
79
89
  source: HBuilderXCliResolutionSource;
90
+ channel: HBuilderXResolvedChannel;
91
+ host?: string;
92
+ version?: string;
93
+ }
94
+ interface HBuilderXNativeCommandOptions {
95
+ args: string[];
96
+ cwd?: string;
97
+ timeoutMs?: number;
98
+ env?: Record<string, string | undefined>;
99
+ allowFailure?: boolean;
100
+ detached?: boolean;
101
+ stdio?: 'pipe' | 'inherit';
102
+ }
103
+ interface HBuilderXRunnerOptions extends HBuilderXCliResolveOptions {
104
+ cwd?: string;
105
+ hbuilderxCliPath?: string;
106
+ timeoutMs?: number;
107
+ }
108
+ interface HBuilderXRunner {
109
+ resolution: HBuilderXCliResolution;
110
+ run: (options: HBuilderXNativeCommandOptions) => Promise<HBuilderXCommandResult>;
111
+ spawn: (options: HBuilderXNativeCommandOptions) => SpawnedHBuilderXCommand;
112
+ closeProject: (options: HBuilderXProjectOptions) => Promise<HBuilderXCommandResult>;
113
+ openProject: (options: HBuilderXProjectOptions) => Promise<HBuilderXCommandResult>;
114
+ prepareProject: (options: HBuilderXProjectOptions) => Promise<HBuilderXCommandResult>;
115
+ launchProject: (options: HBuilderXLaunchOptions) => Promise<HBuilderXCommandResult>;
116
+ startLaunch: (options: HBuilderXLaunchOptions) => SpawnedHBuilderXCommand;
80
117
  }
81
118
  //#endregion
82
- //#region src/hbuilderx.d.ts
83
- declare function getDefaultHBuilderXCliCandidates(env?: NodeJS.ProcessEnv): string[];
119
+ //#region src/hbuilderx/discovery.d.ts
120
+ declare const macOSStableCli = "/Applications/HBuilderX.app/Contents/MacOS/cli";
121
+ declare const macOSAlphaCli = "/Applications/HBuilderX-Alpha.app/Contents/MacOS/cli";
122
+ declare function resolveHBuilderXChannel(channel?: string): HBuilderXChannel;
123
+ declare function inferHBuilderXChannel(file: string): HBuilderXResolvedChannel;
124
+ declare function getDefaultHBuilderXCliCandidates(env?: NodeJS.ProcessEnv, channel?: HBuilderXChannel, platform?: NodeJS.Platform): string[];
125
+ declare function extractHBuilderXMacOSExecutables(output: string): string[];
126
+ declare function extractHBuilderXWindowsExecutables(output: string): string[];
127
+ declare function extractHBuilderXExecutablesFromProcessOutput(output: string, platform?: NodeJS.Platform): string[];
84
128
  declare function extractHBuilderXMacOSExecutable(line: string): string | undefined;
85
129
  declare function extractHBuilderXWindowsExecutable(line: string): string | undefined;
86
130
  declare function extractHBuilderXExecutableFromProcessOutput(output: string, platform?: NodeJS.Platform): string | undefined;
131
+ declare function findRunningHBuilderXCliCandidates(platform?: NodeJS.Platform): Promise<string[]>;
87
132
  declare function findRunningHBuilderXCli(platform?: NodeJS.Platform): Promise<string | undefined>;
88
- declare function resolveHBuilderXCliInfo(candidates?: string[], env?: NodeJS.ProcessEnv): Promise<HBuilderXCliResolution>;
133
+ declare function selectHBuilderXCliCandidatesForChannel(items: string[], channel: HBuilderXChannel): string[];
134
+ declare function resolveHBuilderXCliInfoFromOptions(options?: HBuilderXCliResolveOptions): Promise<HBuilderXCliResolution>;
135
+ //#endregion
136
+ //#region src/hbuilderx/runner.d.ts
137
+ declare function stripAnsi(value: string): string;
138
+ declare function parseHBuilderXHosts(output: string): string[];
139
+ declare function parseHBuilderXVersion(output: string): string | undefined;
140
+ declare function inferHBuilderXChannelFromVersion(version: string): HBuilderXResolvedChannel;
141
+ declare function createHBuilderXNativeLaunchArgs(options: HBuilderXLaunchOptions): string[];
142
+ declare function createHBuilderXRunner(options?: HBuilderXRunnerOptions): Promise<HBuilderXRunner>;
143
+ //#endregion
144
+ //#region src/hbuilderx.d.ts
145
+ declare function resolveHBuilderXCliInfo(options?: HBuilderXCliResolveOptions): ReturnType<typeof resolveHBuilderXCliInfoFromOptions>;
146
+ declare function resolveHBuilderXCliInfo(candidates?: string[], env?: NodeJS.ProcessEnv): ReturnType<typeof resolveHBuilderXCliInfoFromOptions>;
147
+ declare function resolveHBuilderXCli(options?: HBuilderXCliResolveOptions): Promise<string>;
89
148
  declare function resolveHBuilderXCli(candidates?: string[]): Promise<string>;
90
149
  declare function createHBuilderXEnv(options?: {
91
150
  hbuilderxCliPath?: string;
@@ -106,6 +165,9 @@ declare function openProject(options: HBuilderXProjectOptions): Promise<HBuilder
106
165
  declare function prepareProject(options: HBuilderXProjectOptions): Promise<HBuilderXCommandResult>;
107
166
  declare function createLaunchArgs(options: HBuilderXLaunchOptions): string[];
108
167
  declare function launchProject(options: HBuilderXLaunchOptions): Promise<HBuilderXCommandResult>;
168
+ /**
169
+ * @deprecated 需要固定 stable/alpha 与 host 时,请使用 `createHBuilderXRunner().startLaunch()`。
170
+ */
109
171
  declare function startLaunch(options: HBuilderXLaunchOptions): SpawnedHBuilderXCommand;
110
172
  //#endregion
111
173
  //#region src/logs.d.ts
@@ -137,8 +199,17 @@ declare function runTool(command: string, args: string[]): ToolResult;
137
199
  declare function resolveAdbCommand(env?: NodeJS.ProcessEnv): AndroidToolchain;
138
200
  declare function assertAndroidToolchain(env?: NodeJS.ProcessEnv): Record<string, string> | undefined;
139
201
  declare function assertIosSimulatorToolchain(env?: NodeJS.ProcessEnv): void;
202
+ interface IosSimulatorDevice {
203
+ lastBootedAt?: string;
204
+ name: string;
205
+ state: string;
206
+ udid: string;
207
+ }
208
+ declare function parseIosSimulatorDevices(output: string): IosSimulatorDevice[];
209
+ declare function selectPreferredIosSimulatorDevice(devices: IosSimulatorDevice[]): IosSimulatorDevice | undefined;
210
+ declare function resolveIosSimulatorDeviceId(env?: NodeJS.ProcessEnv): string;
140
211
  declare function resolveHdcCommand(env?: NodeJS.ProcessEnv): string;
141
212
  declare function parseHdcTargets(output: string): string[];
142
213
  declare function assertHarmonyToolchain(env?: NodeJS.ProcessEnv, deviceId?: string): string;
143
214
  //#endregion
144
- export { AndroidToolchain, CommandExit, HBuilderXAppPlatform, HBuilderXCliResolution, HBuilderXCliResolutionSource, HBuilderXCommandError, HBuilderXCommandOptions, HBuilderXCommandResult, HBuilderXIssue, HBuilderXIssueKind, HBuilderXLaunchOptions, HBuilderXMiniProgramPlatform, HBuilderXPlatform, HBuilderXProjectOptions, SpawnedHBuilderXCommand, ToolResult, assertAndroidToolchain, assertHarmonyToolchain, assertIosSimulatorToolchain, classifyHBuilderXOutput, closeProject, collectProcessOutput, createHBuilderXEnv, createLaunchArgs, createLogBuffer, createProcessExitTracker, createTimeoutIssue, extractHBuilderXExecutableFromProcessOutput, extractHBuilderXMacOSExecutable, extractHBuilderXWindowsExecutable, fileExists, findRunningHBuilderXCli, formatRecentLogs, getDefaultHBuilderXCliCandidates, hbuilderxPnpmArgs, killProcessTree, launchProject, openProject, parseHdcTargets, prepareProject, readUtf8, resolveAdbCommand, resolveHBuilderXCli, resolveHBuilderXCliInfo, resolveHdcCommand, runCommand, runPnpmCommand, runTool, spawnCommand, spawnPnpmCommand, startLaunch, wait };
215
+ export { AndroidToolchain, CommandExit, HBuilderXAppPlatform, HBuilderXChannel, HBuilderXCliResolution, HBuilderXCliResolutionSource, HBuilderXCliResolveOptions, HBuilderXCommandError, HBuilderXCommandOptions, HBuilderXCommandResult, HBuilderXIssue, HBuilderXIssueKind, HBuilderXLaunchOptions, HBuilderXMiniProgramPlatform, HBuilderXNativeCommandOptions, HBuilderXPlatform, HBuilderXProjectOptions, HBuilderXResolvedChannel, HBuilderXRunner, HBuilderXRunnerOptions, IosSimulatorDevice, SpawnedHBuilderXCommand, ToolResult, assertAndroidToolchain, assertHarmonyToolchain, assertIosSimulatorToolchain, classifyHBuilderXOutput, closeProject, collectProcessOutput, createHBuilderXEnv, createHBuilderXNativeLaunchArgs, createHBuilderXRunner, createLaunchArgs, createLogBuffer, createProcessExitTracker, createTimeoutIssue, extractHBuilderXExecutableFromProcessOutput, extractHBuilderXExecutablesFromProcessOutput, extractHBuilderXMacOSExecutable, extractHBuilderXMacOSExecutables, extractHBuilderXWindowsExecutable, extractHBuilderXWindowsExecutables, fileExists, findRunningHBuilderXCli, findRunningHBuilderXCliCandidates, formatRecentLogs, getDefaultHBuilderXCliCandidates, hbuilderxPnpmArgs, inferHBuilderXChannel, inferHBuilderXChannelFromVersion, killProcessTree, launchProject, macOSAlphaCli, macOSStableCli, openProject, parseHBuilderXHosts, parseHBuilderXVersion, parseHdcTargets, parseIosSimulatorDevices, prepareProject, readUtf8, resolveAdbCommand, resolveHBuilderXChannel, resolveHBuilderXCli, resolveHBuilderXCliInfo, resolveHBuilderXCliInfoFromOptions, resolveHdcCommand, resolveIosSimulatorDeviceId, runCommand, runPnpmCommand, runTool, selectHBuilderXCliCandidatesForChannel, selectPreferredIosSimulatorDevice, spawnCommand, spawnPnpmCommand, startLaunch, stripAnsi, wait };