@hmharness/domain-harmony 0.11.0 → 0.13.2

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.
Files changed (2) hide show
  1. package/dist/emulator.js +35 -2
  2. package/package.json +1 -1
package/dist/emulator.js CHANGED
@@ -26,7 +26,21 @@ export function imageRoot() {
26
26
  return join(localAppData(), 'Huawei', 'Sdk');
27
27
  }
28
28
  function emulatorExe() {
29
- return join(process.env.HM_DEVECO_HOME ?? 'C:\\DevEco-Studio', 'tools', 'emulator', 'Emulator.exe');
29
+ // same discoverability contract as findHdc: honor HM_DEVECO_HOME, then
30
+ // probe the standard install locations. The bare-drive default missed the
31
+ // common "Program Files" install and broke every emulator tool on stock
32
+ // DevEco setups (day-18 SELFFEED: the agent had to fake a junction).
33
+ if (process.env.HM_DEVECO_HOME)
34
+ return join(process.env.HM_DEVECO_HOME, 'tools', 'emulator', 'Emulator.exe');
35
+ for (const home of ['C:\\Program Files\\Huawei\\DevEco Studio', 'D:\\Program Files\\Huawei\\DevEco Studio', 'C:\\DevEco-Studio']) {
36
+ const cand = join(home, 'tools', 'emulator', 'Emulator.exe');
37
+ try {
38
+ accessSync(cand);
39
+ return cand;
40
+ }
41
+ catch { /* next */ }
42
+ }
43
+ return join('C:\\DevEco-Studio', 'tools', 'emulator', 'Emulator.exe');
30
44
  }
31
45
  async function readLists() {
32
46
  try {
@@ -178,7 +192,26 @@ export const harmonyEmulatorStop = {
178
192
  /* already gone */
179
193
  }
180
194
  }
181
- return { output: `stopped: ${targets.map((t) => `${t.hvd} (pid ${t.pid})`).join(', ')}` };
195
+ // verify, never trust the kill report (day-19 SELFFEED: taskkill returned
196
+ // success while Emulator.exe was still alive for seconds) - poll until the
197
+ // CIM query no longer sees the target pids, bounded at ~15s
198
+ const wantGone = new Set(targets.map((t) => t.pid));
199
+ let stillAlive = [];
200
+ for (let waited = 0; waited <= 15_000; waited += 2000) {
201
+ await new Promise((res) => setTimeout(res, waited === 0 ? 1000 : 2000));
202
+ const now = await runningEmulators();
203
+ stillAlive = now.map((r) => r.pid).filter((pid) => wantGone.has(pid));
204
+ if (stillAlive.length === 0)
205
+ break;
206
+ }
207
+ const stopped = targets.filter((t) => !stillAlive.includes(t.pid));
208
+ const stuck = targets.filter((t) => stillAlive.includes(t.pid));
209
+ const lines = [];
210
+ if (stopped.length > 0)
211
+ lines.push(`stopped: ${stopped.map((t) => `${t.hvd} (pid ${t.pid})`).join(', ')} (verified gone)`);
212
+ if (stuck.length > 0)
213
+ lines.push(`NOT stopped (process still alive after taskkill - kill it manually or retry): ${stuck.map((t) => `${t.hvd} (pid ${t.pid})`).join(', ')}`);
214
+ return { output: lines.join('\n'), ...(stuck.length > 0 ? { isError: true } : {}) };
182
215
  },
183
216
  };
184
217
  export const harmonyEmulatorCatalog = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/domain-harmony",
3
- "version": "0.11.0",
3
+ "version": "0.13.2",
4
4
  "description": "hmharness HarmonyOS domain core: device, toolchain, build, and project lifecycle capabilities. HarmonyOS is the framework's native domain, not an add-on.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",