@harmonyos-arkts/droid2hmos 0.0.8 → 0.0.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.
Files changed (42) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +249 -249
  3. package/config/preflight-checklist.json +65 -65
  4. package/dist/cli.js +23 -8
  5. package/dist/cli.js.map +1 -1
  6. package/package.json +36 -36
  7. package/templates/ohos/AppScope/app.json5 +10 -10
  8. package/templates/ohos/AppScope/resources/base/element/string.json +8 -8
  9. package/templates/ohos/AppScope/resources/base/media/layered_image.json +6 -6
  10. package/templates/ohos/build-profile.json5 +41 -41
  11. package/templates/ohos/code-linter.json5 +31 -31
  12. package/templates/ohos/entry/build-profile.json5 +32 -32
  13. package/templates/ohos/entry/hvigorfile.ts +5 -5
  14. package/templates/ohos/entry/obfuscation-rules.txt +22 -22
  15. package/templates/ohos/entry/oh-package.json5 +10 -10
  16. package/templates/ohos/entry/src/main/ets/entryability/EntryAbility.ets +47 -47
  17. package/templates/ohos/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +15 -15
  18. package/templates/ohos/entry/src/main/ets/pages/Index.ets +22 -22
  19. package/templates/ohos/entry/src/main/module.json5 +49 -49
  20. package/templates/ohos/entry/src/main/resources/base/element/color.json +7 -7
  21. package/templates/ohos/entry/src/main/resources/base/element/float.json +8 -8
  22. package/templates/ohos/entry/src/main/resources/base/element/string.json +15 -15
  23. package/templates/ohos/entry/src/main/resources/base/media/layered_image.json +6 -6
  24. package/templates/ohos/entry/src/main/resources/base/profile/backup_config.json +2 -2
  25. package/templates/ohos/entry/src/main/resources/base/profile/main_pages.json +5 -5
  26. package/templates/ohos/entry/src/main/resources/dark/element/color.json +7 -7
  27. package/templates/ohos/entry/src/mock/mock-config.json5 +1 -1
  28. package/templates/ohos/entry/src/ohosTest/ets/test/Ability.test.ets +34 -34
  29. package/templates/ohos/entry/src/ohosTest/ets/test/List.test.ets +4 -4
  30. package/templates/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets +48 -48
  31. package/templates/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets +14 -14
  32. package/templates/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets +41 -41
  33. package/templates/ohos/entry/src/ohosTest/module.json5 +25 -25
  34. package/templates/ohos/entry/src/ohosTest/resources/base/element/color.json +7 -7
  35. package/templates/ohos/entry/src/ohosTest/resources/base/element/string.json +12 -12
  36. package/templates/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json +5 -5
  37. package/templates/ohos/entry/src/test/List.test.ets +4 -4
  38. package/templates/ohos/entry/src/test/LocalUnit.test.ets +32 -32
  39. package/templates/ohos/hvigor/hvigor-config.json5 +23 -23
  40. package/templates/ohos/hvigorfile.ts +5 -5
  41. package/templates/ohos/oh-package-lock.json5 +27 -27
  42. package/templates/ohos/oh-package.json5 +10 -10
@@ -1,65 +1,65 @@
1
- {
2
- "version": 1,
3
- "checks": {
4
- "android-ui-stack": {
5
- "name": "Android UI 技术栈",
6
- "required": true,
7
- "enabled": true
8
- },
9
- "git": {
10
- "name": "Git 仓库和工作区",
11
- "required": true,
12
- "enabled": true
13
- },
14
- "toolchain": {
15
- "name": "主机综合工具链",
16
- "required": true,
17
- "enabled": true
18
- },
19
- "devecocli-auth": {
20
- "name": "DevEco CLI 登录状态",
21
- "required": true,
22
- "enabled": true
23
- },
24
- "appgraph": {
25
- "name": "AppGraph 兼容性和健康状态",
26
- "required": true,
27
- "enabled": true
28
- },
29
- "config": {
30
- "name": ".migration/config.json",
31
- "required": true,
32
- "enabled": true
33
- },
34
- "android-build": {
35
- "name": "Android 基线构建",
36
- "required": false,
37
- "enabled": false
38
- },
39
- "android-emulator": {
40
- "name": "Android 模拟器",
41
- "required": false,
42
- "enabled": true
43
- },
44
- "harmony-project": {
45
- "name": "HarmonyOS 工程存在或初始化",
46
- "required": true,
47
- "enabled": true
48
- },
49
- "harmony-sdk": {
50
- "name": "HarmonyOS SDK 声明根目录",
51
- "required": false,
52
- "enabled": true
53
- },
54
- "harmony-build": {
55
- "name": "HarmonyOS 应用 HAP 构建",
56
- "required": true,
57
- "enabled": true
58
- },
59
- "harmony-device": {
60
- "name": "HarmonyOS 设备和 Shell",
61
- "required": true,
62
- "enabled": true
63
- }
64
- }
65
- }
1
+ {
2
+ "version": 1,
3
+ "checks": {
4
+ "android-ui-stack": {
5
+ "name": "Android UI 技术栈",
6
+ "required": true,
7
+ "enabled": true
8
+ },
9
+ "git": {
10
+ "name": "Git 仓库和工作区",
11
+ "required": true,
12
+ "enabled": true
13
+ },
14
+ "toolchain": {
15
+ "name": "主机综合工具链",
16
+ "required": true,
17
+ "enabled": true
18
+ },
19
+ "devecocli-auth": {
20
+ "name": "DevEco CLI 登录状态",
21
+ "required": true,
22
+ "enabled": true
23
+ },
24
+ "appgraph": {
25
+ "name": "AppGraph 兼容性和健康状态",
26
+ "required": true,
27
+ "enabled": true
28
+ },
29
+ "config": {
30
+ "name": ".migration/config.json",
31
+ "required": true,
32
+ "enabled": true
33
+ },
34
+ "android-build": {
35
+ "name": "Android 基线构建",
36
+ "required": false,
37
+ "enabled": false
38
+ },
39
+ "android-emulator": {
40
+ "name": "Android 模拟器",
41
+ "required": false,
42
+ "enabled": true
43
+ },
44
+ "harmony-project": {
45
+ "name": "HarmonyOS 工程存在或初始化",
46
+ "required": true,
47
+ "enabled": true
48
+ },
49
+ "harmony-sdk": {
50
+ "name": "HarmonyOS SDK 声明根目录",
51
+ "required": false,
52
+ "enabled": true
53
+ },
54
+ "harmony-build": {
55
+ "name": "HarmonyOS 应用 HAP 构建",
56
+ "required": true,
57
+ "enabled": true
58
+ },
59
+ "harmony-device": {
60
+ "name": "HarmonyOS 设备和 Shell",
61
+ "required": true,
62
+ "enabled": true
63
+ }
64
+ }
65
+ }
package/dist/cli.js CHANGED
@@ -2395,6 +2395,14 @@ import { existsSync as existsSync3, readdirSync, statSync } from "fs";
2395
2395
  import path13 from "path";
2396
2396
  var DEVECO_CLI_PACKAGE = "@deveco/deveco-cli@latest";
2397
2397
  var DEVECO_CLI_INSTALL_COMMAND = `npm install -g ${DEVECO_CLI_PACKAGE}`;
2398
+ var NODE_INSPECTOR_OPTION = /(?:^|\s)--inspect(?:-brk|-port|-wait)?(?:=(?:"[^"]*"|'[^']*'|\S+))?(?=\s|$)/gu;
2399
+ function devEcoCliEnvironment(environment = process.env) {
2400
+ const result = { ...environment, DEVECO_CLI_SKIP_VERSION_CHECK: "1" };
2401
+ const nodeOptions = String(environment.NODE_OPTIONS ?? "").replace(NODE_INSPECTOR_OPTION, "").trim();
2402
+ if (nodeOptions) result.NODE_OPTIONS = nodeOptions;
2403
+ else delete result.NODE_OPTIONS;
2404
+ return result;
2405
+ }
2398
2406
  function executableName() {
2399
2407
  return process.env.DEVECO_CLI_BINARY || "devecocli";
2400
2408
  }
@@ -2402,14 +2410,14 @@ function devEcoCliSpawn(executable, args) {
2402
2410
  const scriptWrapper = /\.m?js$/i.test(executable);
2403
2411
  return scriptWrapper ? [process.execPath, executable, ...args] : [executable, ...args];
2404
2412
  }
2405
- function runDevEcoCli(args, { executable = executableName(), runner = spawnCommandSync, timeoutMs = 15e3 } = {}, cwd) {
2413
+ function runDevEcoCli(args, { executable = executableName(), runner = spawnCommandSync, timeoutMs = 15e3, environment = process.env } = {}, cwd) {
2406
2414
  const [command2, ...commandArgs] = devEcoCliSpawn(executable, args);
2407
2415
  const result = runner(command2, commandArgs, {
2408
2416
  cwd,
2409
2417
  encoding: "utf8",
2410
2418
  timeout: timeoutMs,
2411
2419
  windowsHide: true,
2412
- env: { ...process.env, DEVECO_CLI_SKIP_VERSION_CHECK: "1" }
2420
+ env: devEcoCliEnvironment(environment)
2413
2421
  });
2414
2422
  return {
2415
2423
  executable,
@@ -2421,13 +2429,13 @@ function runDevEcoCli(args, { executable = executableName(), runner = spawnComma
2421
2429
  errorCode: result.error && "code" in result.error ? result.error.code : null
2422
2430
  };
2423
2431
  }
2424
- async function runDevEcoCliAsync(args, { executable = executableName(), timeoutMs = 15e3 } = {}, cwd) {
2432
+ async function runDevEcoCliAsync(args, { executable = executableName(), timeoutMs = 15e3, environment = process.env } = {}, cwd) {
2425
2433
  const [command2, ...commandArgs] = devEcoCliSpawn(executable, args);
2426
2434
  const child = spawnCommand(command2, commandArgs, {
2427
2435
  cwd,
2428
2436
  windowsHide: true,
2429
2437
  detached: process.platform !== "win32",
2430
- env: { ...process.env, DEVECO_CLI_SKIP_VERSION_CHECK: "1" },
2438
+ env: devEcoCliEnvironment(environment),
2431
2439
  stdio: ["ignore", "pipe", "pipe"]
2432
2440
  });
2433
2441
  let stdout = "";
@@ -2508,7 +2516,7 @@ function checkDevEcoCliAuth(cli = {}) {
2508
2516
  const result = runDevEcoCli(["auth", "status"], cli);
2509
2517
  const output = [result.stdout, result.stderr].map((value) => value.trim()).filter(Boolean).join("\n");
2510
2518
  const loggedOut = /(?:^|\n)Not logged in(?:\n|$)/i.test(output);
2511
- const currentUser = output.match(/(?:^|\n)Current user:\s*(.+?)(?:\n|$)/i)?.[1]?.trim();
2519
+ const currentUser = output.match(/Current user:\s*([^\r\n]+)/i)?.[1]?.trim();
2512
2520
  if (result.status !== "passed" || loggedOut || !currentUser) {
2513
2521
  return {
2514
2522
  status: "failed",
@@ -4074,7 +4082,7 @@ async function runPreflight(options) {
4074
4082
  }
4075
4083
 
4076
4084
  // src/commands/deveco-auth-login.ts
4077
- import { spawn as spawn3, spawnSync as spawnSync6 } from "child_process";
4085
+ import { spawnSync as spawnSync6 } from "child_process";
4078
4086
  import { closeSync as closeSync3, existsSync as existsSync6, mkdirSync as mkdirSync3, openSync as openSync3, readFileSync as readFileSync5, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
4079
4087
  import path24 from "path";
4080
4088
  import { setTimeout as delay2 } from "timers/promises";
@@ -4212,7 +4220,7 @@ function runDetachedDevEcoAuthHost(requestPath) {
4212
4220
  const stdout = openSync3(request.stdout, "a");
4213
4221
  const stderr = openSync3(request.stderr, "a");
4214
4222
  try {
4215
- const child = spawn3(request.command[0], request.command.slice(1), {
4223
+ const child = spawnCommand(request.command[0], request.command.slice(1), {
4216
4224
  cwd: request.cwd,
4217
4225
  detached: true,
4218
4226
  env: { ...process.env, ...request.env ?? {} },
@@ -4220,6 +4228,13 @@ function runDetachedDevEcoAuthHost(requestPath) {
4220
4228
  windowsHide: true
4221
4229
  });
4222
4230
  const stdin = child.stdin;
4231
+ if (!stdin) {
4232
+ try {
4233
+ child.kill();
4234
+ } catch {
4235
+ }
4236
+ throw new Error("DevEco CLI \u767B\u5F55\u8FDB\u7A0B\u7684 stdin \u4E0D\u53EF\u7528");
4237
+ }
4223
4238
  stdin.on("error", () => {
4224
4239
  });
4225
4240
  stdin.write("\n");
@@ -4310,7 +4325,7 @@ async function managedDevEcoCliLogin(options) {
4310
4325
  stdout: state.stdoutLog,
4311
4326
  stderr: state.stderrLog,
4312
4327
  command: devEcoCliSpawn(executable, ["auth", "login"]),
4313
- env: { DEVECO_CLI_SKIP_VERSION_CHECK: "1" }
4328
+ env: devEcoCliEnvironment()
4314
4329
  }, null, 2), "utf8");
4315
4330
  launchHostOutsideRunner(requestPath, options.hostCommand);
4316
4331
  progress(`\u5DF2\u6301\u4E45\u62C9\u8D77\u767B\u5F55\u8FDB\u7A0B\uFF08\u56DE\u8C03\u670D\u52A1\u5668\u968F\u8FDB\u7A0B\u5B58\u6D3B\uFF09\uFF0C\u65E5\u5FD7: ${state.stdoutLog}`);