@oniroproject/core 0.8.0 → 0.10.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.cjs +375 -244
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -3
- package/dist/index.d.ts +92 -3
- package/dist/index.js +369 -245
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
1
|
+
import { ChildProcess, SpawnOptions, ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
2
|
|
|
3
3
|
interface Logger {
|
|
4
4
|
debug(message: string): void;
|
|
@@ -182,6 +182,26 @@ declare function getSdkRootDir(config: ConfigProvider): string;
|
|
|
182
182
|
declare function getOhosBaseSdkHome(config: ConfigProvider): string;
|
|
183
183
|
declare function getCmdToolsPath(config: ConfigProvider): string;
|
|
184
184
|
declare function getEmulatorDir(config: ConfigProvider): string;
|
|
185
|
+
/**
|
|
186
|
+
* Expand a Windows 8.3 short path (`C:\Users\FRANCE~1\...`) to its long form.
|
|
187
|
+
*
|
|
188
|
+
* Short names reach us whenever a caller passes `%TEMP%` or a path built in a
|
|
189
|
+
* `cmd` context, and hvigor cannot resolve a module directory underneath one:
|
|
190
|
+
* it aborts with `00303149 Configuration Error / Path not found` naming a
|
|
191
|
+
* `srcPath` that plainly exists. Node and the Win32 API resolve short names
|
|
192
|
+
* fine, so the mismatch only surfaces once hvigor is running.
|
|
193
|
+
*
|
|
194
|
+
* No-op off Windows, where short names do not exist and resolving would only
|
|
195
|
+
* dereference symlinks the caller chose deliberately. On Windows it does also
|
|
196
|
+
* canonicalise case and follow junctions — the same path the OS resolves to
|
|
197
|
+
* anyway.
|
|
198
|
+
*
|
|
199
|
+
* Returns `p` unchanged when it does not exist, so a caller's "not found"
|
|
200
|
+
* error still quotes the path the user actually typed.
|
|
201
|
+
*
|
|
202
|
+
* `platform` is injectable so the behaviour is unit-testable off Windows.
|
|
203
|
+
*/
|
|
204
|
+
declare function toLongPath(p: string, platform?: NodeJS.Platform): string;
|
|
185
205
|
/**
|
|
186
206
|
* Resolve a binary inside the command-line tools `bin/` directory by name
|
|
187
207
|
* (e.g. `'ohpm'`, `'hvigorw'`, `'codelinter'`). On Windows tries common
|
|
@@ -204,8 +224,13 @@ declare function getHdcPath(config: ConfigProvider): string;
|
|
|
204
224
|
* ship a project-local `hvigorw` whose `hvigor/` install is absent, so the
|
|
205
225
|
* wrapper crashes on startup; in that case we fall back to the hvigorw bundled
|
|
206
226
|
* with the command-line tools, which is always installed.
|
|
227
|
+
*
|
|
228
|
+
* DevEco projects ship both wrappers side by side: an extensionless POSIX shell
|
|
229
|
+
* script and a `.bat` for Windows. The candidate order is therefore
|
|
230
|
+
* platform-dependent — picking the shell script on Windows would hand `spawn` a
|
|
231
|
+
* file the OS cannot execute.
|
|
207
232
|
*/
|
|
208
|
-
declare function getHvigorwPath(config: ConfigProvider, projectDir: string): string;
|
|
233
|
+
declare function getHvigorwPath(config: ConfigProvider, projectDir: string, platform?: NodeJS.Platform): string;
|
|
209
234
|
|
|
210
235
|
/**
|
|
211
236
|
* Detect the SDK API a project targets by reading `build-profile.json5`.
|
|
@@ -605,6 +630,63 @@ interface StartEmulatorOptions {
|
|
|
605
630
|
declare function startEmulator(opts: StartEmulatorOptions): Promise<void>;
|
|
606
631
|
declare function stopEmulator(logger?: Logger): Promise<void>;
|
|
607
632
|
|
|
633
|
+
/**
|
|
634
|
+
* True when `command` must be routed through `cmd.exe` to run at all —
|
|
635
|
+
* i.e. we are on Windows and the target is a batch wrapper.
|
|
636
|
+
*
|
|
637
|
+
* `platform` is injectable so the behaviour is unit-testable off Windows.
|
|
638
|
+
*/
|
|
639
|
+
declare function needsCmdWrapper(command: string, platform?: NodeJS.Platform): boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Escape one argument for a `cmd.exe` command line: quote it, double the
|
|
642
|
+
* backslashes that would otherwise escape the closing quote, then caret-escape
|
|
643
|
+
* every metacharacter.
|
|
644
|
+
*
|
|
645
|
+
* `doubleEscapeMetaChars` adds the second caret layer needed by `%*`-forwarding
|
|
646
|
+
* shims — see {@link CMD_SHIM_RE}.
|
|
647
|
+
*/
|
|
648
|
+
declare function escapeCmdArgument(arg: string, doubleEscapeMetaChars?: boolean): string;
|
|
649
|
+
/**
|
|
650
|
+
* Escape the executable path. It is caret-escaped but deliberately NOT quoted:
|
|
651
|
+
* `cmd.exe /s /c "..."` strips the outer quotes of the whole line, and a quoted
|
|
652
|
+
* first token confuses that parse. Caret-escaping the spaces is what makes
|
|
653
|
+
* `C:\Program Files\...` work.
|
|
654
|
+
*/
|
|
655
|
+
declare function escapeCmdCommand(command: string): string;
|
|
656
|
+
interface CmdWrapper {
|
|
657
|
+
command: string;
|
|
658
|
+
args: string[];
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Build the `cmd.exe /d /s /c "<command> <args...>"` invocation for a batch
|
|
662
|
+
* wrapper. Pure (no I/O, no spawning) so the escaping is unit-testable on every
|
|
663
|
+
* platform.
|
|
664
|
+
*
|
|
665
|
+
* `/d` skips AutoRun registry commands, `/s` keeps the outer quotes intact,
|
|
666
|
+
* `/c` runs the command and exits.
|
|
667
|
+
*
|
|
668
|
+
* @throws OniroError if the command or any argument contains a character that
|
|
669
|
+
* cannot survive `cmd.exe` unambiguously (see {@link UNSAFE_CMD_CHARS_RE}).
|
|
670
|
+
*/
|
|
671
|
+
declare function buildCmdWrapper(command: string, args: readonly string[]): CmdWrapper;
|
|
672
|
+
/**
|
|
673
|
+
* `child_process.spawn`, but able to run Windows batch wrappers.
|
|
674
|
+
*
|
|
675
|
+
* Identical to `spawn` everywhere else — on POSIX, and on Windows for real
|
|
676
|
+
* executables, the command and args are passed straight through with
|
|
677
|
+
* `shell: false`.
|
|
678
|
+
*/
|
|
679
|
+
declare function spawnCompat(command: string, args: readonly string[], options?: SpawnOptions): ChildProcess;
|
|
680
|
+
/**
|
|
681
|
+
* Kill a child and everything it started.
|
|
682
|
+
*
|
|
683
|
+
* On Windows a signal only reaches the process we spawned — killing the
|
|
684
|
+
* `cmd.exe` wrapper leaves the Node/hvigor process it launched running, so an
|
|
685
|
+
* aborted or timed-out build would keep holding the project's output files.
|
|
686
|
+
* `taskkill /T /F` tears down the whole tree instead.
|
|
687
|
+
*/
|
|
688
|
+
declare function killProcessTree(child: ChildProcess): void;
|
|
689
|
+
|
|
608
690
|
/** Result of a spawned command. `code` is the process exit code (-1 if it was killed). */
|
|
609
691
|
interface HdcExecResult {
|
|
610
692
|
code: number;
|
|
@@ -635,6 +717,12 @@ interface RunProcessOptions {
|
|
|
635
717
|
* because args are passed as an array and never interpolated into a shell
|
|
636
718
|
* string, command construction is injection-safe by construction.
|
|
637
719
|
*
|
|
720
|
+
* The one exception is a Windows batch wrapper (`.bat`/`.cmd`, how the
|
|
721
|
+
* OpenHarmony command-line tools ship there), which the OS cannot execute
|
|
722
|
+
* directly: those go through `cmd.exe` with every argument individually
|
|
723
|
+
* escaped — see {@link spawnCompat}. The array-in, no-word-splitting contract
|
|
724
|
+
* is preserved.
|
|
725
|
+
*
|
|
638
726
|
* Resolves with `{ code, stdout, stderr }` for ANY exit code (callers opt into
|
|
639
727
|
* throw-on-non-zero via {@link ensureOk}). Rejects only on spawn failure
|
|
640
728
|
* (e.g. missing binary), timeout, or abort.
|
|
@@ -1093,6 +1181,7 @@ interface InstallAppOptions {
|
|
|
1093
1181
|
* Falls back to the `hapPath` config key, then to the well-known default.
|
|
1094
1182
|
*/
|
|
1095
1183
|
hapPath?: string;
|
|
1184
|
+
deviceSerial?: string;
|
|
1096
1185
|
logger?: Logger;
|
|
1097
1186
|
}
|
|
1098
1187
|
interface InstallAppResult {
|
|
@@ -1671,4 +1760,4 @@ declare function applyChanges(opts: ApplyChangesOptions): Promise<ApplyChangesRe
|
|
|
1671
1760
|
|
|
1672
1761
|
declare const VERSION: string;
|
|
1673
1762
|
|
|
1674
|
-
export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type AbilityInfo, type Apl, type AppFeature, type ApplyChangesOptions, type ApplyChangesResult, type BuildHapOptions, type BuildHapResult, type BundleOptions, CancelledError, type CaptureBurstOptions, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type CodelinterFinding, type CodelinterResult, CommandFailedError, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DeviceFullInfo, type DeviceInfo, type DiscoverHapsOptions, type DisplaySize, type DisplaySizeOptions, type DownloadOptions, type DumpLayoutOptions, type DumpLayoutResult, type DumpLogOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type GestureUitestOptions, type GetDeviceInfoOptions, type HapAssetDiff, type HdcExecOptions, type HdcExecResult, type HdcShellOptions, type HidumperOptions, type HilogEntry, type HilogLevel, INSTALL_TMP_DIRNAME, type InputType, type InstallAppOptions, type InstallAppResult, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallMethod, type InstallSdkOptions, type InstallTempDir, type InstallTempDirOptions, InsufficientSpaceError, type LaunchAppOptions, type LayoutNode, type Logger, type ModuleHaps, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type OutputSink, type ParamOptions, type PrepareSigningOptions, type PrepareSigningResult, type ProgressReporter, type ProgressUpdate, type ProjectModule, type Prompter, type RawLayoutNode, type RawTouchEvent, type RebootDecision, type RebootOptions, type RecvFileOptions, type RunCodelinterOptions, type RunHvigorwOptions, type RunHvigorwResult, type RunOhpmOptions, type RunProcessOptions, type RunningProcess, type ScreenDump, type Screenshot, type ScreenshotOptions, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SendFileOptions, type SendGestureOptions, type SendInputOptions, type SendRawTouchOptions, type SetHilogLevelOptions, type SigningKind, type SigningPasswords, type StartEmulatorOptions, type StreamHilogOptions, TMP_DIR_HINT, type TemplateOption, UnsupportedPlatformError, VERSION, type WaitForBootOptions, type WaitForBundleOptions, type WaitForConditionOptions, type WaitForLogOptions, type WatchLogOptions, type Waypoint, applyChanges, attemptHdcConnection, buildGestureCommands, buildGestureUitestCommand, buildHap, buildHvigorwArgs, buildInputCommand, buildRawTouchCommand, captureBurst, consoleLogger, createInstallTempDir, createMaterial, createScaffold, createTempWorkDir, decideInstallMethod, decideReboot, decryptPwd, dedupEntries, defaultContext, defaultPaths, detectAaStartFailure, detectProjectSdkVersion, detectSigningConfigNames, diffEntryNames, diffHapAssets, discoverHaps, downloadAndInstallSdk, downloadFile, dumpLayout, dumpLog, dumpRenderService, dumpScreen, dumpWindow, encryptPwd, ensureFreeSpace, ensureOhModules, ensureOk, ensureRemoteOk, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, findRunningProcess, forceStop, formatBytes, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getDeviceInfo, getDisplaySize, getEmulatorDir, getFreeSpaceBytes, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOhpmPath, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, hdcExec, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isOutOfSpaceError, isRamBackedPath, isValidBundleName, isValidProjectName, launchApp, listAbilities, listDevices, listModules, listRunningProcesses, listTemplates, nonInteractivePrompter, noopLogger, noopProgress, paramGet, paramSet, parseBounds, parseCodelinterFindings, parseDeviceList, parseHilogLine, parseMainAbilityFromBmDump, parseRemoteExit, pickSigningKind, prepareSigning, pruneLayout, readJson5File, readJsonFile, reboot, recvFile, removeCmdTools, removeEmulator, removeSdk, removeTempWorkDir, resolveTmpRoot, runCodelinter, runHvigorw, runOhpm, runProcess, scopedLogger, selectDevice, sendFile, sendGesture, sendInput, sendRawTouch, setHilogLevel, shell, shellChecked, startEmulator, staticConfig, stopEmulator, streamHilog, takeScreenshot, toSpaceError, uninstallApp, validateTemplateLayout, verifySha256, waitForBoot, waitForBundle, waitForCondition, waitForLog, watchLog, waypointsToRawEvents, writeJson5File, writeJsonFile };
|
|
1763
|
+
export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type AbilityInfo, type Apl, type AppFeature, type ApplyChangesOptions, type ApplyChangesResult, type BuildHapOptions, type BuildHapResult, type BundleOptions, CancelledError, type CaptureBurstOptions, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type CmdWrapper, type CodelinterFinding, type CodelinterResult, CommandFailedError, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DeviceFullInfo, type DeviceInfo, type DiscoverHapsOptions, type DisplaySize, type DisplaySizeOptions, type DownloadOptions, type DumpLayoutOptions, type DumpLayoutResult, type DumpLogOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type GestureUitestOptions, type GetDeviceInfoOptions, type HapAssetDiff, type HdcExecOptions, type HdcExecResult, type HdcShellOptions, type HidumperOptions, type HilogEntry, type HilogLevel, INSTALL_TMP_DIRNAME, type InputType, type InstallAppOptions, type InstallAppResult, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallMethod, type InstallSdkOptions, type InstallTempDir, type InstallTempDirOptions, InsufficientSpaceError, type LaunchAppOptions, type LayoutNode, type Logger, type ModuleHaps, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type OutputSink, type ParamOptions, type PrepareSigningOptions, type PrepareSigningResult, type ProgressReporter, type ProgressUpdate, type ProjectModule, type Prompter, type RawLayoutNode, type RawTouchEvent, type RebootDecision, type RebootOptions, type RecvFileOptions, type RunCodelinterOptions, type RunHvigorwOptions, type RunHvigorwResult, type RunOhpmOptions, type RunProcessOptions, type RunningProcess, type ScreenDump, type Screenshot, type ScreenshotOptions, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SendFileOptions, type SendGestureOptions, type SendInputOptions, type SendRawTouchOptions, type SetHilogLevelOptions, type SigningKind, type SigningPasswords, type StartEmulatorOptions, type StreamHilogOptions, TMP_DIR_HINT, type TemplateOption, UnsupportedPlatformError, VERSION, type WaitForBootOptions, type WaitForBundleOptions, type WaitForConditionOptions, type WaitForLogOptions, type WatchLogOptions, type Waypoint, applyChanges, attemptHdcConnection, buildCmdWrapper, buildGestureCommands, buildGestureUitestCommand, buildHap, buildHvigorwArgs, buildInputCommand, buildRawTouchCommand, captureBurst, consoleLogger, createInstallTempDir, createMaterial, createScaffold, createTempWorkDir, decideInstallMethod, decideReboot, decryptPwd, dedupEntries, defaultContext, defaultPaths, detectAaStartFailure, detectProjectSdkVersion, detectSigningConfigNames, diffEntryNames, diffHapAssets, discoverHaps, downloadAndInstallSdk, downloadFile, dumpLayout, dumpLog, dumpRenderService, dumpScreen, dumpWindow, encryptPwd, ensureFreeSpace, ensureOhModules, ensureOk, ensureRemoteOk, escapeCmdArgument, escapeCmdCommand, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, findRunningProcess, forceStop, formatBytes, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getDeviceInfo, getDisplaySize, getEmulatorDir, getFreeSpaceBytes, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOhpmPath, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, hdcExec, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isOutOfSpaceError, isRamBackedPath, isValidBundleName, isValidProjectName, killProcessTree, launchApp, listAbilities, listDevices, listModules, listRunningProcesses, listTemplates, needsCmdWrapper, nonInteractivePrompter, noopLogger, noopProgress, paramGet, paramSet, parseBounds, parseCodelinterFindings, parseDeviceList, parseHilogLine, parseMainAbilityFromBmDump, parseRemoteExit, pickSigningKind, prepareSigning, pruneLayout, readJson5File, readJsonFile, reboot, recvFile, removeCmdTools, removeEmulator, removeSdk, removeTempWorkDir, resolveTmpRoot, runCodelinter, runHvigorw, runOhpm, runProcess, scopedLogger, selectDevice, sendFile, sendGesture, sendInput, sendRawTouch, setHilogLevel, shell, shellChecked, spawnCompat, startEmulator, staticConfig, stopEmulator, streamHilog, takeScreenshot, toLongPath, toSpaceError, uninstallApp, validateTemplateLayout, verifySha256, waitForBoot, waitForBundle, waitForCondition, waitForLog, watchLog, waypointsToRawEvents, writeJson5File, writeJsonFile };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
1
|
+
import { ChildProcess, SpawnOptions, ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
2
|
|
|
3
3
|
interface Logger {
|
|
4
4
|
debug(message: string): void;
|
|
@@ -182,6 +182,26 @@ declare function getSdkRootDir(config: ConfigProvider): string;
|
|
|
182
182
|
declare function getOhosBaseSdkHome(config: ConfigProvider): string;
|
|
183
183
|
declare function getCmdToolsPath(config: ConfigProvider): string;
|
|
184
184
|
declare function getEmulatorDir(config: ConfigProvider): string;
|
|
185
|
+
/**
|
|
186
|
+
* Expand a Windows 8.3 short path (`C:\Users\FRANCE~1\...`) to its long form.
|
|
187
|
+
*
|
|
188
|
+
* Short names reach us whenever a caller passes `%TEMP%` or a path built in a
|
|
189
|
+
* `cmd` context, and hvigor cannot resolve a module directory underneath one:
|
|
190
|
+
* it aborts with `00303149 Configuration Error / Path not found` naming a
|
|
191
|
+
* `srcPath` that plainly exists. Node and the Win32 API resolve short names
|
|
192
|
+
* fine, so the mismatch only surfaces once hvigor is running.
|
|
193
|
+
*
|
|
194
|
+
* No-op off Windows, where short names do not exist and resolving would only
|
|
195
|
+
* dereference symlinks the caller chose deliberately. On Windows it does also
|
|
196
|
+
* canonicalise case and follow junctions — the same path the OS resolves to
|
|
197
|
+
* anyway.
|
|
198
|
+
*
|
|
199
|
+
* Returns `p` unchanged when it does not exist, so a caller's "not found"
|
|
200
|
+
* error still quotes the path the user actually typed.
|
|
201
|
+
*
|
|
202
|
+
* `platform` is injectable so the behaviour is unit-testable off Windows.
|
|
203
|
+
*/
|
|
204
|
+
declare function toLongPath(p: string, platform?: NodeJS.Platform): string;
|
|
185
205
|
/**
|
|
186
206
|
* Resolve a binary inside the command-line tools `bin/` directory by name
|
|
187
207
|
* (e.g. `'ohpm'`, `'hvigorw'`, `'codelinter'`). On Windows tries common
|
|
@@ -204,8 +224,13 @@ declare function getHdcPath(config: ConfigProvider): string;
|
|
|
204
224
|
* ship a project-local `hvigorw` whose `hvigor/` install is absent, so the
|
|
205
225
|
* wrapper crashes on startup; in that case we fall back to the hvigorw bundled
|
|
206
226
|
* with the command-line tools, which is always installed.
|
|
227
|
+
*
|
|
228
|
+
* DevEco projects ship both wrappers side by side: an extensionless POSIX shell
|
|
229
|
+
* script and a `.bat` for Windows. The candidate order is therefore
|
|
230
|
+
* platform-dependent — picking the shell script on Windows would hand `spawn` a
|
|
231
|
+
* file the OS cannot execute.
|
|
207
232
|
*/
|
|
208
|
-
declare function getHvigorwPath(config: ConfigProvider, projectDir: string): string;
|
|
233
|
+
declare function getHvigorwPath(config: ConfigProvider, projectDir: string, platform?: NodeJS.Platform): string;
|
|
209
234
|
|
|
210
235
|
/**
|
|
211
236
|
* Detect the SDK API a project targets by reading `build-profile.json5`.
|
|
@@ -605,6 +630,63 @@ interface StartEmulatorOptions {
|
|
|
605
630
|
declare function startEmulator(opts: StartEmulatorOptions): Promise<void>;
|
|
606
631
|
declare function stopEmulator(logger?: Logger): Promise<void>;
|
|
607
632
|
|
|
633
|
+
/**
|
|
634
|
+
* True when `command` must be routed through `cmd.exe` to run at all —
|
|
635
|
+
* i.e. we are on Windows and the target is a batch wrapper.
|
|
636
|
+
*
|
|
637
|
+
* `platform` is injectable so the behaviour is unit-testable off Windows.
|
|
638
|
+
*/
|
|
639
|
+
declare function needsCmdWrapper(command: string, platform?: NodeJS.Platform): boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Escape one argument for a `cmd.exe` command line: quote it, double the
|
|
642
|
+
* backslashes that would otherwise escape the closing quote, then caret-escape
|
|
643
|
+
* every metacharacter.
|
|
644
|
+
*
|
|
645
|
+
* `doubleEscapeMetaChars` adds the second caret layer needed by `%*`-forwarding
|
|
646
|
+
* shims — see {@link CMD_SHIM_RE}.
|
|
647
|
+
*/
|
|
648
|
+
declare function escapeCmdArgument(arg: string, doubleEscapeMetaChars?: boolean): string;
|
|
649
|
+
/**
|
|
650
|
+
* Escape the executable path. It is caret-escaped but deliberately NOT quoted:
|
|
651
|
+
* `cmd.exe /s /c "..."` strips the outer quotes of the whole line, and a quoted
|
|
652
|
+
* first token confuses that parse. Caret-escaping the spaces is what makes
|
|
653
|
+
* `C:\Program Files\...` work.
|
|
654
|
+
*/
|
|
655
|
+
declare function escapeCmdCommand(command: string): string;
|
|
656
|
+
interface CmdWrapper {
|
|
657
|
+
command: string;
|
|
658
|
+
args: string[];
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Build the `cmd.exe /d /s /c "<command> <args...>"` invocation for a batch
|
|
662
|
+
* wrapper. Pure (no I/O, no spawning) so the escaping is unit-testable on every
|
|
663
|
+
* platform.
|
|
664
|
+
*
|
|
665
|
+
* `/d` skips AutoRun registry commands, `/s` keeps the outer quotes intact,
|
|
666
|
+
* `/c` runs the command and exits.
|
|
667
|
+
*
|
|
668
|
+
* @throws OniroError if the command or any argument contains a character that
|
|
669
|
+
* cannot survive `cmd.exe` unambiguously (see {@link UNSAFE_CMD_CHARS_RE}).
|
|
670
|
+
*/
|
|
671
|
+
declare function buildCmdWrapper(command: string, args: readonly string[]): CmdWrapper;
|
|
672
|
+
/**
|
|
673
|
+
* `child_process.spawn`, but able to run Windows batch wrappers.
|
|
674
|
+
*
|
|
675
|
+
* Identical to `spawn` everywhere else — on POSIX, and on Windows for real
|
|
676
|
+
* executables, the command and args are passed straight through with
|
|
677
|
+
* `shell: false`.
|
|
678
|
+
*/
|
|
679
|
+
declare function spawnCompat(command: string, args: readonly string[], options?: SpawnOptions): ChildProcess;
|
|
680
|
+
/**
|
|
681
|
+
* Kill a child and everything it started.
|
|
682
|
+
*
|
|
683
|
+
* On Windows a signal only reaches the process we spawned — killing the
|
|
684
|
+
* `cmd.exe` wrapper leaves the Node/hvigor process it launched running, so an
|
|
685
|
+
* aborted or timed-out build would keep holding the project's output files.
|
|
686
|
+
* `taskkill /T /F` tears down the whole tree instead.
|
|
687
|
+
*/
|
|
688
|
+
declare function killProcessTree(child: ChildProcess): void;
|
|
689
|
+
|
|
608
690
|
/** Result of a spawned command. `code` is the process exit code (-1 if it was killed). */
|
|
609
691
|
interface HdcExecResult {
|
|
610
692
|
code: number;
|
|
@@ -635,6 +717,12 @@ interface RunProcessOptions {
|
|
|
635
717
|
* because args are passed as an array and never interpolated into a shell
|
|
636
718
|
* string, command construction is injection-safe by construction.
|
|
637
719
|
*
|
|
720
|
+
* The one exception is a Windows batch wrapper (`.bat`/`.cmd`, how the
|
|
721
|
+
* OpenHarmony command-line tools ship there), which the OS cannot execute
|
|
722
|
+
* directly: those go through `cmd.exe` with every argument individually
|
|
723
|
+
* escaped — see {@link spawnCompat}. The array-in, no-word-splitting contract
|
|
724
|
+
* is preserved.
|
|
725
|
+
*
|
|
638
726
|
* Resolves with `{ code, stdout, stderr }` for ANY exit code (callers opt into
|
|
639
727
|
* throw-on-non-zero via {@link ensureOk}). Rejects only on spawn failure
|
|
640
728
|
* (e.g. missing binary), timeout, or abort.
|
|
@@ -1093,6 +1181,7 @@ interface InstallAppOptions {
|
|
|
1093
1181
|
* Falls back to the `hapPath` config key, then to the well-known default.
|
|
1094
1182
|
*/
|
|
1095
1183
|
hapPath?: string;
|
|
1184
|
+
deviceSerial?: string;
|
|
1096
1185
|
logger?: Logger;
|
|
1097
1186
|
}
|
|
1098
1187
|
interface InstallAppResult {
|
|
@@ -1671,4 +1760,4 @@ declare function applyChanges(opts: ApplyChangesOptions): Promise<ApplyChangesRe
|
|
|
1671
1760
|
|
|
1672
1761
|
declare const VERSION: string;
|
|
1673
1762
|
|
|
1674
|
-
export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type AbilityInfo, type Apl, type AppFeature, type ApplyChangesOptions, type ApplyChangesResult, type BuildHapOptions, type BuildHapResult, type BundleOptions, CancelledError, type CaptureBurstOptions, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type CodelinterFinding, type CodelinterResult, CommandFailedError, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DeviceFullInfo, type DeviceInfo, type DiscoverHapsOptions, type DisplaySize, type DisplaySizeOptions, type DownloadOptions, type DumpLayoutOptions, type DumpLayoutResult, type DumpLogOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type GestureUitestOptions, type GetDeviceInfoOptions, type HapAssetDiff, type HdcExecOptions, type HdcExecResult, type HdcShellOptions, type HidumperOptions, type HilogEntry, type HilogLevel, INSTALL_TMP_DIRNAME, type InputType, type InstallAppOptions, type InstallAppResult, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallMethod, type InstallSdkOptions, type InstallTempDir, type InstallTempDirOptions, InsufficientSpaceError, type LaunchAppOptions, type LayoutNode, type Logger, type ModuleHaps, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type OutputSink, type ParamOptions, type PrepareSigningOptions, type PrepareSigningResult, type ProgressReporter, type ProgressUpdate, type ProjectModule, type Prompter, type RawLayoutNode, type RawTouchEvent, type RebootDecision, type RebootOptions, type RecvFileOptions, type RunCodelinterOptions, type RunHvigorwOptions, type RunHvigorwResult, type RunOhpmOptions, type RunProcessOptions, type RunningProcess, type ScreenDump, type Screenshot, type ScreenshotOptions, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SendFileOptions, type SendGestureOptions, type SendInputOptions, type SendRawTouchOptions, type SetHilogLevelOptions, type SigningKind, type SigningPasswords, type StartEmulatorOptions, type StreamHilogOptions, TMP_DIR_HINT, type TemplateOption, UnsupportedPlatformError, VERSION, type WaitForBootOptions, type WaitForBundleOptions, type WaitForConditionOptions, type WaitForLogOptions, type WatchLogOptions, type Waypoint, applyChanges, attemptHdcConnection, buildGestureCommands, buildGestureUitestCommand, buildHap, buildHvigorwArgs, buildInputCommand, buildRawTouchCommand, captureBurst, consoleLogger, createInstallTempDir, createMaterial, createScaffold, createTempWorkDir, decideInstallMethod, decideReboot, decryptPwd, dedupEntries, defaultContext, defaultPaths, detectAaStartFailure, detectProjectSdkVersion, detectSigningConfigNames, diffEntryNames, diffHapAssets, discoverHaps, downloadAndInstallSdk, downloadFile, dumpLayout, dumpLog, dumpRenderService, dumpScreen, dumpWindow, encryptPwd, ensureFreeSpace, ensureOhModules, ensureOk, ensureRemoteOk, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, findRunningProcess, forceStop, formatBytes, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getDeviceInfo, getDisplaySize, getEmulatorDir, getFreeSpaceBytes, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOhpmPath, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, hdcExec, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isOutOfSpaceError, isRamBackedPath, isValidBundleName, isValidProjectName, launchApp, listAbilities, listDevices, listModules, listRunningProcesses, listTemplates, nonInteractivePrompter, noopLogger, noopProgress, paramGet, paramSet, parseBounds, parseCodelinterFindings, parseDeviceList, parseHilogLine, parseMainAbilityFromBmDump, parseRemoteExit, pickSigningKind, prepareSigning, pruneLayout, readJson5File, readJsonFile, reboot, recvFile, removeCmdTools, removeEmulator, removeSdk, removeTempWorkDir, resolveTmpRoot, runCodelinter, runHvigorw, runOhpm, runProcess, scopedLogger, selectDevice, sendFile, sendGesture, sendInput, sendRawTouch, setHilogLevel, shell, shellChecked, startEmulator, staticConfig, stopEmulator, streamHilog, takeScreenshot, toSpaceError, uninstallApp, validateTemplateLayout, verifySha256, waitForBoot, waitForBundle, waitForCondition, waitForLog, watchLog, waypointsToRawEvents, writeJson5File, writeJsonFile };
|
|
1763
|
+
export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type AbilityInfo, type Apl, type AppFeature, type ApplyChangesOptions, type ApplyChangesResult, type BuildHapOptions, type BuildHapResult, type BundleOptions, CancelledError, type CaptureBurstOptions, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type CmdWrapper, type CodelinterFinding, type CodelinterResult, CommandFailedError, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DeviceFullInfo, type DeviceInfo, type DiscoverHapsOptions, type DisplaySize, type DisplaySizeOptions, type DownloadOptions, type DumpLayoutOptions, type DumpLayoutResult, type DumpLogOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type GestureUitestOptions, type GetDeviceInfoOptions, type HapAssetDiff, type HdcExecOptions, type HdcExecResult, type HdcShellOptions, type HidumperOptions, type HilogEntry, type HilogLevel, INSTALL_TMP_DIRNAME, type InputType, type InstallAppOptions, type InstallAppResult, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallMethod, type InstallSdkOptions, type InstallTempDir, type InstallTempDirOptions, InsufficientSpaceError, type LaunchAppOptions, type LayoutNode, type Logger, type ModuleHaps, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type OutputSink, type ParamOptions, type PrepareSigningOptions, type PrepareSigningResult, type ProgressReporter, type ProgressUpdate, type ProjectModule, type Prompter, type RawLayoutNode, type RawTouchEvent, type RebootDecision, type RebootOptions, type RecvFileOptions, type RunCodelinterOptions, type RunHvigorwOptions, type RunHvigorwResult, type RunOhpmOptions, type RunProcessOptions, type RunningProcess, type ScreenDump, type Screenshot, type ScreenshotOptions, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SendFileOptions, type SendGestureOptions, type SendInputOptions, type SendRawTouchOptions, type SetHilogLevelOptions, type SigningKind, type SigningPasswords, type StartEmulatorOptions, type StreamHilogOptions, TMP_DIR_HINT, type TemplateOption, UnsupportedPlatformError, VERSION, type WaitForBootOptions, type WaitForBundleOptions, type WaitForConditionOptions, type WaitForLogOptions, type WatchLogOptions, type Waypoint, applyChanges, attemptHdcConnection, buildCmdWrapper, buildGestureCommands, buildGestureUitestCommand, buildHap, buildHvigorwArgs, buildInputCommand, buildRawTouchCommand, captureBurst, consoleLogger, createInstallTempDir, createMaterial, createScaffold, createTempWorkDir, decideInstallMethod, decideReboot, decryptPwd, dedupEntries, defaultContext, defaultPaths, detectAaStartFailure, detectProjectSdkVersion, detectSigningConfigNames, diffEntryNames, diffHapAssets, discoverHaps, downloadAndInstallSdk, downloadFile, dumpLayout, dumpLog, dumpRenderService, dumpScreen, dumpWindow, encryptPwd, ensureFreeSpace, ensureOhModules, ensureOk, ensureRemoteOk, escapeCmdArgument, escapeCmdCommand, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, findRunningProcess, forceStop, formatBytes, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getDeviceInfo, getDisplaySize, getEmulatorDir, getFreeSpaceBytes, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOhpmPath, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, hdcExec, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isOutOfSpaceError, isRamBackedPath, isValidBundleName, isValidProjectName, killProcessTree, launchApp, listAbilities, listDevices, listModules, listRunningProcesses, listTemplates, needsCmdWrapper, nonInteractivePrompter, noopLogger, noopProgress, paramGet, paramSet, parseBounds, parseCodelinterFindings, parseDeviceList, parseHilogLine, parseMainAbilityFromBmDump, parseRemoteExit, pickSigningKind, prepareSigning, pruneLayout, readJson5File, readJsonFile, reboot, recvFile, removeCmdTools, removeEmulator, removeSdk, removeTempWorkDir, resolveTmpRoot, runCodelinter, runHvigorw, runOhpm, runProcess, scopedLogger, selectDevice, sendFile, sendGesture, sendInput, sendRawTouch, setHilogLevel, shell, shellChecked, spawnCompat, startEmulator, staticConfig, stopEmulator, streamHilog, takeScreenshot, toLongPath, toSpaceError, uninstallApp, validateTemplateLayout, verifySha256, waitForBoot, waitForBundle, waitForCondition, waitForLog, watchLog, waypointsToRawEvents, writeJson5File, writeJsonFile };
|