@oniroproject/core 0.6.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.
@@ -0,0 +1,593 @@
1
+ import { ChildProcessWithoutNullStreams } from 'node:child_process';
2
+
3
+ interface Logger {
4
+ debug(message: string): void;
5
+ info(message: string): void;
6
+ warn(message: string): void;
7
+ error(message: string): void;
8
+ }
9
+ declare const noopLogger: Logger;
10
+ declare const consoleLogger: Logger;
11
+
12
+ interface ProgressUpdate {
13
+ message?: string;
14
+ increment?: number;
15
+ }
16
+ interface ProgressReporter {
17
+ report(update: ProgressUpdate): void;
18
+ }
19
+ declare const noopProgress: ProgressReporter;
20
+
21
+ /**
22
+ * Keys read from the ConfigProvider by core. Frontends (CLI, VS Code extension)
23
+ * implement the provider however they like (env vars, settings.json, etc.).
24
+ */
25
+ type ConfigKey = 'sdkRootDir' | 'cmdToolsPath' | 'emulatorDir' | 'hapPath' | 'cmdToolsUrlLinux' | 'cmdToolsUrlWindows' | 'cmdToolsUrlMac' | 'emulatorUrl';
26
+ interface ConfigProvider {
27
+ /**
28
+ * Get the configured value for `key`, or `fallback` if unset/empty.
29
+ * Implementations should expand the literal `${userHome}` to the user's home dir.
30
+ */
31
+ get<T extends string | number | boolean>(key: ConfigKey, fallback: T): T;
32
+ }
33
+ /**
34
+ * Default config values used when a ConfigProvider returns the fallback.
35
+ * These match the historical paths used by the bash CLI and the extension.
36
+ */
37
+ declare const defaultPaths: {
38
+ readonly sdkRootDir: () => string;
39
+ readonly cmdToolsPath: () => string;
40
+ readonly emulatorDir: () => string;
41
+ readonly hapPath: "entry/build/default/outputs/default/entry-default-signed.hap";
42
+ readonly emulatorUrl: "https://github.com/eclipse-oniro4openharmony/device_board_oniro/releases/latest/download/oniro_emulator.zip";
43
+ readonly cmdToolsUrlLinux: "https://repo.huaweicloud.com/harmonyos/ohpm/5.1.0/commandline-tools-linux-x64-5.1.0.840.zip";
44
+ };
45
+ /**
46
+ * A simple in-memory ConfigProvider, useful for tests and as a base for CLI/extension impls.
47
+ */
48
+ declare function staticConfig(values?: Partial<Record<ConfigKey, string>>): ConfigProvider;
49
+
50
+ /**
51
+ * Interactive prompts. Frontends implement these — CLI uses @inquirer/prompts,
52
+ * the extension uses `vscode.window.show*`. Core never assumes a TTY.
53
+ */
54
+ interface Prompter {
55
+ /** Ask the user to confirm an action. */
56
+ confirm(message: string, defaultValue?: boolean): Promise<boolean>;
57
+ /** Ask the user for a single line of text. */
58
+ input(message: string, defaultValue?: string): Promise<string>;
59
+ /** Ask the user to pick a directory on disk; resolves to an absolute path or null if cancelled. */
60
+ selectDirectory(message: string, defaultPath?: string): Promise<string | null>;
61
+ /** Ask the user to pick a file on disk; resolves to an absolute path or null if cancelled. */
62
+ selectFile(message: string, filters?: {
63
+ extensions?: string[];
64
+ }): Promise<string | null>;
65
+ }
66
+ /**
67
+ * Throws on any prompt — used in non-interactive contexts where all answers must come from flags.
68
+ */
69
+ declare const nonInteractivePrompter: Prompter;
70
+
71
+ declare class OniroError extends Error {
72
+ readonly cause?: unknown | undefined;
73
+ constructor(message: string, cause?: unknown | undefined);
74
+ }
75
+ declare class SdkNotInstalledError extends OniroError {
76
+ readonly api: string;
77
+ readonly expectedPath: string;
78
+ constructor(api: string, expectedPath: string);
79
+ }
80
+ declare class CmdToolsNotInstalledError extends OniroError {
81
+ readonly expectedPath: string;
82
+ constructor(expectedPath: string);
83
+ }
84
+ declare class UnsupportedPlatformError extends OniroError {
85
+ readonly platform: string;
86
+ constructor(platform: string);
87
+ }
88
+ declare class ChecksumMismatchError extends OniroError {
89
+ readonly expected: string;
90
+ readonly actual: string;
91
+ constructor(expected: string, actual: string);
92
+ }
93
+ declare class CancelledError extends OniroError {
94
+ constructor(message?: string);
95
+ }
96
+
97
+ /**
98
+ * Carries the cross-cutting dependencies most core functions need: a Logger and a ConfigProvider.
99
+ * Functions that report progress or prompt the user take those as additional parameters.
100
+ */
101
+ interface OniroContext {
102
+ logger: Logger;
103
+ config: ConfigProvider;
104
+ }
105
+ declare function defaultContext(overrides?: Partial<OniroContext>): OniroContext;
106
+
107
+ interface SdkRelease {
108
+ version: string;
109
+ api: string;
110
+ }
111
+ /**
112
+ * Known OpenHarmony SDK releases. Kept in sync with the bash CLI / extension.
113
+ * Update when a new SDK ships.
114
+ */
115
+ declare const ALL_SDKS: readonly SdkRelease[];
116
+ declare const OHOS_URL_BASE = "https://repo.huaweicloud.com/openharmony/os";
117
+
118
+ type OsFolder = 'linux' | 'darwin' | 'windows';
119
+ /**
120
+ * Map Node's `os.platform()` to the OS folder name used in the SDK install layout
121
+ * and the SDK release tarballs.
122
+ */
123
+ declare function getOsFolder(): OsFolder;
124
+ interface SdkArchiveInfo {
125
+ filename: string;
126
+ osFolder: OsFolder;
127
+ /** Number of leading path components to strip when extracting the tarball. */
128
+ strip: number;
129
+ }
130
+ /**
131
+ * Resolve the SDK archive filename, OS folder, and tar strip count for the current platform.
132
+ *
133
+ * The Huawei mirror packages Linux and Windows together in one tarball with `linux/` and
134
+ * `windows/` subfolders. For 5.0.0/5.0.1/6.0 the tarball has no extra top-level wrapper
135
+ * (strip=0); newer/older releases wrap the OS folders in a single top-level directory (strip=1).
136
+ * macOS tarballs have a deeper layout (strip=3).
137
+ */
138
+ declare function getSdkFilename(version?: string): SdkArchiveInfo;
139
+
140
+ declare function getSdkRootDir(config: ConfigProvider): string;
141
+ /**
142
+ * Base SDK home for the current OS: `<sdkRootDir>/<linux|darwin|windows>`.
143
+ * SDK API folders (e.g. `12`, `18`, `20`) live inside this directory.
144
+ */
145
+ declare function getOhosBaseSdkHome(config: ConfigProvider): string;
146
+ declare function getCmdToolsPath(config: ConfigProvider): string;
147
+ declare function getEmulatorDir(config: ConfigProvider): string;
148
+ /**
149
+ * Resolve the OHPM binary path inside the command-line tools install.
150
+ * On Windows tries common executable suffixes (.exe, .cmd, .bat) before the POSIX name.
151
+ */
152
+ declare function getCmdToolsBin(config: ConfigProvider): string;
153
+ /**
154
+ * Resolve the hdc binary path inside the SDK toolchains tree.
155
+ */
156
+ declare function getHdcPath(config: ConfigProvider): string;
157
+ /**
158
+ * Resolve the hvigorw wrapper for a project, preferring the project-local copy
159
+ * (which carries the project's pinned hvigor version) and falling back to the
160
+ * one shipped with the command-line tools.
161
+ */
162
+ declare function getHvigorwPath(config: ConfigProvider, projectDir: string): string;
163
+
164
+ /**
165
+ * Detect the SDK API a project targets by reading `build-profile.json5`.
166
+ * Returns the `compileSdkVersion` of the first declared product, or undefined
167
+ * if the file is missing/malformed or no product declares one.
168
+ */
169
+ declare function detectProjectSdkVersion(projectRoot: string, logger?: Logger): number | undefined;
170
+
171
+ interface DownloadOptions {
172
+ url: string;
173
+ dest: string;
174
+ progress?: ProgressReporter;
175
+ abortSignal?: AbortSignal;
176
+ /** Overall progress start offset (0..100). Default 0. */
177
+ start?: number;
178
+ /** Overall progress range to consume (0..100). Default 100. */
179
+ range?: number;
180
+ }
181
+ /**
182
+ * Stream a remote file to disk with optional progress reporting and cancellation.
183
+ * Follows redirects via the `follow-redirects` library.
184
+ */
185
+ declare function downloadFile(opts: DownloadOptions): Promise<void>;
186
+ /**
187
+ * Verify the SHA-256 checksum of a file against an on-disk .sha256 file.
188
+ * The .sha256 file is expected to contain the hex digest as its first whitespace-delimited token.
189
+ */
190
+ declare function verifySha256(filePath: string, sha256Path: string): Promise<void>;
191
+
192
+ interface ExtractZipOptions {
193
+ zipPath: string;
194
+ dest: string;
195
+ progress?: ProgressReporter;
196
+ /** Overall progress start offset (0..100). Default 0. */
197
+ start?: number;
198
+ /** Overall progress range to consume (0..100). Default 100. */
199
+ range?: number;
200
+ logger?: Logger;
201
+ }
202
+ /**
203
+ * Extract a ZIP to a destination directory, preserving file permissions and following
204
+ * symlinks defensively. Protects against Zip Slip (entries whose paths escape `dest`).
205
+ */
206
+ declare function extractZipWithProgress(opts: ExtractZipOptions): Promise<void>;
207
+ /**
208
+ * Extract a tar/tar.gz/tar.bz2 archive. Wraps `tar.x`.
209
+ */
210
+ declare function extractTarball(tarPath: string, dest: string, strip?: number): Promise<void>;
211
+
212
+ interface SdkInfo {
213
+ version: string;
214
+ api: string;
215
+ installed: boolean;
216
+ }
217
+ /**
218
+ * List supported SDKs annotated with whether they are installed for the current OS.
219
+ * Sorted by API descending (newest first).
220
+ */
221
+ declare function getSupportedSdksForUi(config: ConfigProvider): SdkInfo[];
222
+ /**
223
+ * Return the SDK versions that have at least one OS-folder install in `sdkRootDir`.
224
+ * Scans `linux`, `darwin`, `windows` so the list is consistent across machines that
225
+ * share an SDK root over a network mount.
226
+ */
227
+ declare function getInstalledSdks(config: ConfigProvider): string[];
228
+
229
+ /**
230
+ * Remove an installed SDK for a given API level, across all OS folders.
231
+ * Returns true if at least one folder was deleted.
232
+ */
233
+ declare function removeSdk(config: ConfigProvider, api: string): boolean;
234
+
235
+ interface InstallSdkOptions {
236
+ config: ConfigProvider;
237
+ version: string;
238
+ api: string;
239
+ progress?: ProgressReporter;
240
+ abortSignal?: AbortSignal;
241
+ logger?: Logger;
242
+ }
243
+ /**
244
+ * Download and install an OpenHarmony SDK release into `<sdkRootDir>/<osFolder>/<api>`.
245
+ *
246
+ * Progress budget (overall 0..100):
247
+ * 0..35 SDK archive download
248
+ * 35..45 Checksum download
249
+ * 45..50 Checksum verify
250
+ * 50..60 Tarball extract
251
+ * 60..95 Component ZIP extracts
252
+ * 95..100 Finalize + cleanup
253
+ */
254
+ declare function downloadAndInstallSdk(opts: InstallSdkOptions): Promise<void>;
255
+
256
+ /**
257
+ * Resolve the per-platform download URL for the OpenHarmony command-line tools.
258
+ *
259
+ * Only Linux has a public download URL on the Huawei mirror. Windows and macOS
260
+ * builds are gated behind the Huawei developer portal: users must download the
261
+ * ZIP manually and pass it via `--from-zip`, or self-host the archive and point
262
+ * `cmdToolsUrlWindows` / `cmdToolsUrlMac` at it.
263
+ *
264
+ * @param platform Defaults to the current host. Override for testing.
265
+ */
266
+ declare function getCmdToolsDownloadUrl(config: ConfigProvider, platform?: NodeJS.Platform): string;
267
+ /**
268
+ * Locate the extracted command-line tools' source root within a temp extraction folder.
269
+ * Tries known top-level names, then any subdirectory containing a `bin/` folder.
270
+ */
271
+ declare function findCmdToolsSourceDir(extractPath: string): string;
272
+ interface InstallCmdToolsOptions {
273
+ config: ConfigProvider;
274
+ progress?: ProgressReporter;
275
+ abortSignal?: AbortSignal;
276
+ logger?: Logger;
277
+ /** Skip download and install from a local zip the caller already has. */
278
+ localZipPath?: string;
279
+ }
280
+ /**
281
+ * Install the OpenHarmony command-line tools into `<cmdToolsPath>`.
282
+ * Either downloads from the platform-specific URL or installs from a caller-supplied ZIP.
283
+ */
284
+ declare function installCmdTools(opts: InstallCmdToolsOptions): Promise<void>;
285
+ interface CmdToolsStatus {
286
+ installed: boolean;
287
+ status: string;
288
+ }
289
+ /**
290
+ * Reports whether ohpm is present at the configured path, and if so its version.
291
+ * Prefers reading `version.txt` (`# Version: x.y.z`) before falling back to executing
292
+ * the binary with `-v`.
293
+ */
294
+ declare function getCmdToolsStatus(config: ConfigProvider): CmdToolsStatus;
295
+ declare function isCmdToolsInstalled(config: ConfigProvider): boolean;
296
+ declare function removeCmdTools(config: ConfigProvider): void;
297
+
298
+ /**
299
+ * Generates the signing-material directory tree: fd/{0,1,2}, ac, ce.
300
+ * Each subfolder contains a randomly-named keyfile derived as described in
301
+ * the OpenHarmony hap-sign-tool reference implementation.
302
+ */
303
+ declare function createMaterial(materialPath: string): void;
304
+ /**
305
+ * Re-derives the work key from an existing material directory.
306
+ */
307
+ declare function getKey(materialPath: string): Buffer;
308
+ /**
309
+ * Encrypts a password using the work key derived from `materialPath`.
310
+ * Returns the encrypted blob as a hex string (the format expected in build-profile.json5).
311
+ */
312
+ declare function encryptPwd(password: string, materialPath: string): string;
313
+ /**
314
+ * Inverse of `encryptPwd`. Exposed for parity with the original CLI.
315
+ */
316
+ declare function decryptPwd(encryptedHex: string, materialPath: string): string;
317
+
318
+ /** Ability Privilege Level written into the profile's `bundle-info.apl`. */
319
+ type Apl = 'normal' | 'system_basic' | 'system_core';
320
+ /** App feature written into the profile's `bundle-info.app-feature`. */
321
+ type AppFeature = 'hos_normal_app' | 'hos_system_app';
322
+ declare const APL_VALUES: readonly Apl[];
323
+ declare const APP_FEATURE_VALUES: readonly AppFeature[];
324
+ interface GenerateSigningConfigsOptions {
325
+ /** Absolute path to the OpenHarmony project (the folder containing build-profile.json5). */
326
+ projectDir: string;
327
+ /** Absolute path to the OS-specific SDK home (the folder containing API-version subfolders). */
328
+ sdkHome: string;
329
+ /**
330
+ * APL level to write into the profile's `bundle-info.apl`. Defaults to `'normal'`.
331
+ * Apps requesting permissions above `normal` (e.g. `ohos.permission.GET_WIFI_INFO_INTERNAL`)
332
+ * need `system_basic` or `system_core` — otherwise `bm install` fails with
333
+ * `grant request permissions failed`.
334
+ */
335
+ apl?: Apl;
336
+ /**
337
+ * App feature to write into `bundle-info.app-feature`. Defaults to `'hos_normal_app'`
338
+ * when `apl='normal'`, otherwise `'hos_system_app'`.
339
+ */
340
+ appFeature?: AppFeature;
341
+ /** Optional logger; defaults to no-op. */
342
+ logger?: Logger;
343
+ }
344
+ /**
345
+ * Generate signing configs for an OpenHarmony project: copies certs, signs the profile,
346
+ * generates the signing material, and writes the resulting `signingConfigs` entry into
347
+ * `build-profile.json5`.
348
+ *
349
+ * Requires `java` on PATH (the OpenHarmony hap-sign-tool ships as a .jar).
350
+ */
351
+ declare function generateSigningConfigs(options: GenerateSigningConfigsOptions): void;
352
+
353
+ interface InstallEmulatorOptions {
354
+ config: ConfigProvider;
355
+ progress?: ProgressReporter;
356
+ abortSignal?: AbortSignal;
357
+ logger?: Logger;
358
+ }
359
+ /**
360
+ * Download and extract the Oniro emulator into the configured `emulatorDir`.
361
+ */
362
+ declare function installEmulator(opts: InstallEmulatorOptions): Promise<void>;
363
+ /**
364
+ * Heuristic: emulator is considered installed if `images/run.sh` is present.
365
+ * On Windows-only emulator builds (when they exist) this may not apply.
366
+ */
367
+ declare function isEmulatorInstalled(config: ConfigProvider): boolean;
368
+ declare function removeEmulator(config: ConfigProvider): void;
369
+
370
+ /**
371
+ * Try to connect hdc to the emulator. Resolves true on success, false otherwise.
372
+ */
373
+ declare function attemptHdcConnection(config: ConfigProvider, address?: string, logger?: Logger): Promise<boolean>;
374
+ interface StartEmulatorOptions {
375
+ config: ConfigProvider;
376
+ logger?: Logger;
377
+ /** Pass --headless to the bundled launcher (VNC + telnet serial, no local window). */
378
+ headless?: boolean;
379
+ /**
380
+ * Override the launcher's host:port for hdc port forwarding. Defaults to the
381
+ * launcher's own default (typically `127.0.0.1:55555`). Use `0.0.0.0:55555`
382
+ * on hosts where QEMU refuses to bind the hostfwd to 127.0.0.1 (e.g. some
383
+ * CI runners with restricted loopback bindings).
384
+ */
385
+ connect?: string;
386
+ /**
387
+ * Redirect launcher stdout/stderr to this file. Default: discard
388
+ * (/dev/null on POSIX, NUL on Windows). Use a real path in CI so you can
389
+ * surface qemu output on failure.
390
+ */
391
+ logFile?: string;
392
+ /**
393
+ * If > 0, block until hdc connects to the running emulator, up to this many
394
+ * seconds. 0 (default) returns as soon as the launcher process is spawned.
395
+ */
396
+ waitForHdcSeconds?: number;
397
+ /** Poll interval for the hdc wait, ms. Default 5000. */
398
+ hdcPollIntervalMs?: number;
399
+ abortSignal?: AbortSignal;
400
+ }
401
+ /**
402
+ * Launch the Oniro emulator in the background via the bundled run.sh/run.bat.
403
+ *
404
+ * The launcher process is detached + unref'd so callers can exit while the
405
+ * emulator keeps running. A PID file is written to the OS temp dir so
406
+ * `stopEmulator` and rerun-detection logic can find the process later.
407
+ */
408
+ declare function startEmulator(opts: StartEmulatorOptions): Promise<void>;
409
+ declare function stopEmulator(logger?: Logger): Promise<void>;
410
+
411
+ /**
412
+ * Read the project's bundle name from `AppScope/app.json5`.
413
+ */
414
+ declare function getBundleName(projectDir: string): string;
415
+ /**
416
+ * Read the main ability from `<module>/src/main/module.json5`. Defaults to `entry`
417
+ * for the module folder name if not provided — projects with custom module names
418
+ * should pass it explicitly.
419
+ */
420
+ declare function getMainAbility(projectDir: string, moduleName?: string): string;
421
+
422
+ interface InstallAppOptions {
423
+ config: ConfigProvider;
424
+ projectDir: string;
425
+ /**
426
+ * Explicit path (absolute, or relative to projectDir) to the signed `.hap`.
427
+ * Falls back to the `hapPath` config key, then to the well-known default.
428
+ */
429
+ hapPath?: string;
430
+ logger?: Logger;
431
+ }
432
+ declare function installApp(opts: InstallAppOptions): Promise<void>;
433
+ interface LaunchAppOptions {
434
+ config: ConfigProvider;
435
+ projectDir: string;
436
+ /** Override the module name if it isn't the default `entry`. */
437
+ moduleName?: string;
438
+ logger?: Logger;
439
+ }
440
+ declare function launchApp(opts: LaunchAppOptions): Promise<void>;
441
+ interface RunningProcess {
442
+ pid: string;
443
+ name: string;
444
+ }
445
+ /**
446
+ * List running processes via `hdc track-jpid`. Times out after `timeoutMs`.
447
+ * When `targetProcessName` is set, resolves to that process's PID early; otherwise
448
+ * resolves to the full list collected within the timeout window.
449
+ */
450
+ declare function listRunningProcesses(config: ConfigProvider, options?: {
451
+ targetProcessName?: string;
452
+ timeoutMs?: number;
453
+ logger?: Logger;
454
+ }): Promise<RunningProcess[] | string>;
455
+ declare function findAppProcessId(config: ConfigProvider, projectDir: string, logger?: Logger): Promise<string>;
456
+
457
+ type HilogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL';
458
+ /** A parsed line of `hdc shell hilog` output. */
459
+ interface HilogEntry {
460
+ /** "MM-DD HH:MM:SS.mmm". The device timestamp; no year. */
461
+ time: string;
462
+ pid: string;
463
+ tid: string;
464
+ /** Short level letter as printed by hilog: D, I, W, E (F is rare). */
465
+ level: 'D' | 'I' | 'W' | 'E' | 'F';
466
+ tag: string;
467
+ message: string;
468
+ }
469
+ interface SetHilogLevelOptions {
470
+ config: ConfigProvider;
471
+ level: HilogLevel;
472
+ logger?: Logger;
473
+ }
474
+ /**
475
+ * Set the hilog buffer level on the connected device. Resolves when the
476
+ * underlying `hdc shell hilog -b <LEVEL>` exits successfully; rejects with
477
+ * the stderr text if the command fails.
478
+ */
479
+ declare function setHilogLevel(opts: SetHilogLevelOptions): Promise<void>;
480
+ interface StreamHilogOptions {
481
+ config: ConfigProvider;
482
+ /** Restrict the stream to a single process id (passed as `-P <pid>`). */
483
+ processId?: string;
484
+ }
485
+ /**
486
+ * Spawn `hdc shell hilog [-P <pid>]` and return the child process. The caller
487
+ * owns the stdout/stderr streams (typically wired through `parseHilogLine`) and
488
+ * is responsible for killing the process when streaming should stop.
489
+ */
490
+ declare function streamHilog(opts: StreamHilogOptions): ChildProcessWithoutNullStreams;
491
+ /**
492
+ * Parse a single line of `hdc shell hilog` output into structured fields.
493
+ * Returns null when the line doesn't match the expected hilog format (e.g.
494
+ * banners, blank lines, or partial chunks).
495
+ */
496
+ declare function parseHilogLine(line: string): HilogEntry | null;
497
+
498
+ interface RunHvigorwOptions {
499
+ config: ConfigProvider;
500
+ projectDir: string;
501
+ /** Forwarded as `-p product=<product>`. Default `default`. */
502
+ product?: string;
503
+ /** Forwarded as `-p module=<module>` when set. */
504
+ module?: string;
505
+ /** Forwarded as `-p buildMode=<mode>` when set. */
506
+ buildMode?: string;
507
+ /** hvigor task to run. Default `assembleHap`. */
508
+ task?: string;
509
+ /** Extra raw args appended after the standard ones. */
510
+ extraArgs?: readonly string[];
511
+ logger?: Logger;
512
+ /**
513
+ * Optional callback for each stdout/stderr chunk, lets callers stream output
514
+ * to a terminal or webview without buffering. Lines also flow through `logger`.
515
+ */
516
+ onOutput?: (chunk: string, stream: 'stdout' | 'stderr') => void;
517
+ }
518
+ interface RunHvigorwResult {
519
+ exitCode: number;
520
+ }
521
+ /**
522
+ * Run the project's `hvigorw` wrapper. Replaces the extension's vscode-tasks indirection
523
+ * and the bash CLI's chained `clean` + `assembleHap` calls with a single direct spawn.
524
+ */
525
+ declare function runHvigorw(opts: RunHvigorwOptions): Promise<RunHvigorwResult>;
526
+
527
+ /**
528
+ * Conservative project-folder-name validator (no path separators, conservative charset).
529
+ */
530
+ declare function isValidProjectName(name: string): boolean;
531
+ /**
532
+ * Bundle-name validator. Allows reverse-DNS style identifiers like `com.example.myapp`.
533
+ */
534
+ declare function isValidBundleName(bundleName: string): boolean;
535
+
536
+ interface TemplateOption {
537
+ id: string;
538
+ label: string;
539
+ description: string;
540
+ defaultModuleName: string;
541
+ }
542
+ /**
543
+ * Enumerate templates inside `templateRoot`. Each direct subfolder is a template;
544
+ * per-template metadata (label/description/defaultModuleName) may live in a
545
+ * `template.json` file alongside the template content.
546
+ *
547
+ * Callers own the template root — the CLI ships its own under
548
+ * `<cli-package>/templates/`, the VS Code extension uses `extensionPath/template`.
549
+ */
550
+ declare function listTemplates(templateRoot: string): TemplateOption[];
551
+ /**
552
+ * Verify that a template directory contains the files required by the scaffold pipeline.
553
+ * Returns the list of missing relative paths, or [] if the template is complete.
554
+ */
555
+ declare function validateTemplateLayout(templateDir: string, defaultModuleName: string): string[];
556
+
557
+ interface CreateScaffoldOptions {
558
+ config: ConfigProvider;
559
+ templateId: string;
560
+ projectName: string;
561
+ bundleName: string;
562
+ /** Parent directory that will contain the new project folder. */
563
+ location: string;
564
+ sdkApi: number;
565
+ /** Module folder name. Defaults to the template's `defaultModuleName`. */
566
+ moduleName?: string;
567
+ /** Absolute path to the directory containing template subfolders. */
568
+ templateRoot: string;
569
+ /** If the destination exists, remove it before scaffolding instead of throwing. */
570
+ overwrite?: boolean;
571
+ logger?: Logger;
572
+ }
573
+ interface CreateScaffoldResult {
574
+ projectDir: string;
575
+ }
576
+ /**
577
+ * Scaffold a new Oniro/OpenHarmony project from a template. Returns the absolute path
578
+ * to the created project directory.
579
+ */
580
+ declare function createScaffold(opts: CreateScaffoldOptions): Promise<CreateScaffoldResult>;
581
+
582
+ declare function readJson5File<T>(filePath: string): T;
583
+ /**
584
+ * Write strict JSON content (quoted keys) to a `.json5` file. Keeps the file
585
+ * compatible with VS Code's JSON parser while remaining valid JSON5.
586
+ */
587
+ declare function writeJson5File(filePath: string, value: unknown): void;
588
+ declare function readJsonFile<T>(filePath: string): T;
589
+ declare function writeJsonFile(filePath: string, value: unknown): void;
590
+
591
+ declare const VERSION: string;
592
+
593
+ export { ALL_SDKS, APL_VALUES, APP_FEATURE_VALUES, type Apl, type AppFeature, CancelledError, ChecksumMismatchError, CmdToolsNotInstalledError, type CmdToolsStatus, type ConfigKey, type ConfigProvider, type CreateScaffoldOptions, type CreateScaffoldResult, type DownloadOptions, type ExtractZipOptions, type GenerateSigningConfigsOptions, type HilogEntry, type HilogLevel, type InstallAppOptions, type InstallCmdToolsOptions, type InstallEmulatorOptions, type InstallSdkOptions, type LaunchAppOptions, type Logger, OHOS_URL_BASE, type OniroContext, OniroError, type OsFolder, type ProgressReporter, type ProgressUpdate, type Prompter, type RunHvigorwOptions, type RunHvigorwResult, type RunningProcess, type SdkArchiveInfo, type SdkInfo, SdkNotInstalledError, type SdkRelease, type SetHilogLevelOptions, type StartEmulatorOptions, type StreamHilogOptions, type TemplateOption, UnsupportedPlatformError, VERSION, attemptHdcConnection, consoleLogger, createMaterial, createScaffold, decryptPwd, defaultContext, defaultPaths, detectProjectSdkVersion, downloadAndInstallSdk, downloadFile, encryptPwd, extractTarball, extractZipWithProgress, findAppProcessId, findCmdToolsSourceDir, generateSigningConfigs, getBundleName, getCmdToolsBin, getCmdToolsDownloadUrl, getCmdToolsPath, getCmdToolsStatus, getEmulatorDir, getHdcPath, getHvigorwPath, getInstalledSdks, getKey, getMainAbility, getOhosBaseSdkHome, getOsFolder, getSdkFilename, getSdkRootDir, getSupportedSdksForUi, installApp, installCmdTools, installEmulator, isCmdToolsInstalled, isEmulatorInstalled, isValidBundleName, isValidProjectName, launchApp, listRunningProcesses, listTemplates, nonInteractivePrompter, noopLogger, noopProgress, parseHilogLine, readJson5File, readJsonFile, removeCmdTools, removeEmulator, removeSdk, runHvigorw, setHilogLevel, startEmulator, staticConfig, stopEmulator, streamHilog, validateTemplateLayout, verifySha256, writeJson5File, writeJsonFile };