@react-native-oh/react-native-harmony-cli 0.77.18 → 0.77.33-1

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 (118) hide show
  1. package/dist/autolinking/Autolinking.js +1 -1
  2. package/dist/codegen/generators/UberGeneratorV1.js +9 -2
  3. package/dist/codegen/generators/UberGeneratorV2.js +8 -1
  4. package/dist/commands/clean-harmony.js +17 -7
  5. package/dist/commands/codegen-harmony.js +16 -5
  6. package/dist/commands/init.js +0 -0
  7. package/dist/commands/run-harmony.js +49 -27
  8. package/dist/init/templates/harmony/entry/src/main/module.json5 +7 -0
  9. package/dist/package-verifier/verify-package.js +1 -1
  10. package/dist/simulator/LaunchSimulator.js +318 -0
  11. package/dist/simulator/index.js +23 -0
  12. package/harmony/rnoh-hvigor-plugin-0.77.33.tgz +0 -0
  13. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/02febc14 +0 -0
  14. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0429e5b7 +0 -0
  15. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/05339e68 +0 -0
  16. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/070be2fe +0 -0
  17. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/07851ff1 +0 -0
  18. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12e10c06 +0 -0
  19. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12e1d696 +0 -0
  20. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/14950087 +0 -0
  21. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/15e87372 +0 -0
  22. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/19e6ecbe +0 -0
  23. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1aac0ac4 +0 -0
  24. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1b8db102 +0 -0
  25. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1c181646 +0 -0
  26. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/203e747c +0 -0
  27. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/21ba4c08 +0 -0
  28. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/259939e5 +0 -0
  29. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/288ba98c +0 -0
  30. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2a45461c +0 -0
  31. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2d773091 +0 -0
  32. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2eda89fc +0 -0
  33. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2f584eca +0 -0
  34. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/35b495ca +0 -0
  35. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/36478aed +0 -0
  36. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3844e772 +0 -0
  37. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3ee777f4 +0 -0
  38. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/471ac436 +0 -0
  39. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4a91abcc +0 -0
  40. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d1a5094 +0 -0
  41. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d3ef38f +0 -0
  42. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4daf5855 +0 -0
  43. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4ef0389f +0 -0
  44. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4f72da28 +0 -0
  45. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/59d3e924 +0 -0
  46. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5a8edfaa +0 -0
  47. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5d28a510 +0 -0
  48. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/61a6391d +0 -0
  49. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/65921a14 +0 -0
  50. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6624e7fc +0 -0
  51. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/66d28144 +0 -0
  52. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6aceb8d2 +0 -0
  53. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/702393d3 +0 -0
  54. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/714f932b +0 -0
  55. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/73f9d4a6 +0 -0
  56. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/78d3adae +0 -0
  57. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7b6564b8 +0 -0
  58. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7c7c3e6e +0 -0
  59. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7cbc9b6a +0 -0
  60. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7dd579e0 +0 -0
  61. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7e0b7d06 +0 -0
  62. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7e153eef +0 -0
  63. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7ee84fd7 +0 -0
  64. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7f5146a4 +0 -0
  65. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/844e633a +0 -0
  66. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8a1af22c +0 -0
  67. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/90a1680d +0 -0
  68. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a15fb79a +0 -0
  69. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ac288a8a +0 -0
  70. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ad7a66b4 +0 -0
  71. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/aee8805e +0 -0
  72. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b0487ec8 +0 -0
  73. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b10e16d2 +0 -0
  74. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b32d42ac +0 -0
  75. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b7d8f35c +0 -0
  76. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b96748af +0 -0
  77. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bedb2fea +0 -0
  78. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c01ad640 +0 -0
  79. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c0472cf5 +0 -0
  80. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c102ed0f +0 -0
  81. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c1a91819 +0 -0
  82. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c243857a +0 -0
  83. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c407792f +0 -0
  84. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c4459bee +0 -0
  85. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c72a4dcd +0 -0
  86. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c83537a9 +0 -0
  87. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c88f7498 +0 -0
  88. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c8d04070 +0 -0
  89. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cc44d6f1 +0 -0
  90. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d4d913f6 +0 -0
  91. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/da97f202 +0 -0
  92. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/dc965522 +0 -0
  93. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/dff6f700 +0 -0
  94. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e507c001 +0 -0
  95. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e52f3f2d +0 -0
  96. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e5c3890d +0 -0
  97. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e720074d +0 -0
  98. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e7656fa7 +0 -0
  99. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e80bcaac +0 -0
  100. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e8e7900e +0 -0
  101. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ee8993f9 +0 -0
  102. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ef8cf362 +0 -0
  103. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f1405b1d +0 -0
  104. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f20f0e0d +0 -0
  105. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f2586978 +0 -0
  106. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f53cd716 +0 -0
  107. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fe71f6bb +0 -0
  108. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/febfc20b +0 -0
  109. package/package.json +2 -7
  110. package/scripts/sync-hvigor.js +27 -0
  111. package/src/autolinking/Autolinking.ts +1 -1
  112. package/src/codegen/generators/UberGeneratorV1.ts +7 -2
  113. package/src/codegen/generators/UberGeneratorV2.ts +6 -1
  114. package/src/commands/codegen-harmony.ts +17 -7
  115. package/src/commands/run-harmony.ts +67 -41
  116. package/src/init/templates/harmony/entry/src/main/module.json5 +7 -0
  117. package/src/simulator/LaunchSimulator.ts +359 -0
  118. package/src/simulator/index.ts +8 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native-oh/react-native-harmony-cli",
3
- "version": "0.77.18",
3
+ "version": "0.77.33-1",
4
4
  "description": "",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -9,7 +9,7 @@
9
9
  "scripts": {
10
10
  "build": "tsc --outDir dist -p tsconfig.build.json && node ./scripts/copy-template.js",
11
11
  "prepack": "npm run build && npm run _recreate-hvigor-plugin",
12
- "_recreate-hvigor-plugin": "cd ../react-native-harmony-hvigor-plugin && npm i && npm run deploy && cd ../react-native-harmony-cli",
12
+ "_recreate-hvigor-plugin": "cd ../react-native-harmony-hvigor-plugin && npm i && npm run deploy && cd ../react-native-harmony-cli && node ./scripts/sync-hvigor.js",
13
13
  "verify": "tsc --noEmit && npm run test",
14
14
  "test": "npm run build && jest",
15
15
  "test:codegen": "jest ./src/codegen/.* && npm run build && jest tests/codegen.*",
@@ -58,10 +58,5 @@
58
58
  "mustache": "^4.2.0",
59
59
  "tar": "^6.1.15",
60
60
  "tmp": "^0.2.1"
61
- },
62
- "homepage": "https://gitcode.com/openharmony-sig/ohos_react_native",
63
- "repository": {
64
- "type": "gitcode",
65
- "url": "https://gitcode.com/openharmony-sig/ohos_react_native"
66
61
  }
67
62
  }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ const fs = require('fs').promises;
8
+
9
+ async function sync(configFilePaths = []) {
10
+ const dir = './harmony';
11
+ const files = await fs.readdir(dir);
12
+ const file = files.find(f => /^rnoh-hvigor-plugin-\d+(\.\d+){2}\.tgz$/.test(f));
13
+ if (!file) {
14
+ return;
15
+ }
16
+ configFilePaths.forEach(async (configFilePath) => {
17
+ const fileContent = await fs.readFile(configFilePath, 'utf8');
18
+ const updatedContent = fileContent.replace(/rnoh-hvigor-plugin-\d+(\.\d+){2}\.tgz/g, file);
19
+ fs.writeFile(configFilePath, updatedContent, 'utf8');
20
+ });
21
+ }
22
+
23
+ sync([
24
+ '../tester/harmony/hvigor/hvigor-config.json5',
25
+ '../tester-ecosystem/harmony/hvigor/hvigor-config.json5',
26
+ '../react-native-harmony-61-interop-tester/rnoh-entry/harmony/hvigor/hvigor-config.json5'
27
+ ]).catch(console.error);
@@ -271,7 +271,7 @@ export class Autolinking {
271
271
  const managedNativeDependencySpecifierByName: Record<string, string> = {};
272
272
  for (const library of autolinkableLibraries) {
273
273
  managedNativeDependencySpecifierByName[library.ohPackageName] =
274
- 'file:' + library.harFilePathRelativeToHarmony;
274
+ `file:${library.harFilePathRelativeToHarmony}`.split(pathUtils.sep).join('/');
275
275
  }
276
276
  return {
277
277
  skippedLibraryNpmPackageNames: input.skippedLibraryNpmPackageNames,
@@ -1,3 +1,4 @@
1
+ import pathUtils from 'path';
1
2
  import { AbsolutePath } from '../../core';
2
3
  import {
3
4
  CodeGenerator,
@@ -10,6 +11,9 @@ import { GlueCodeDataV1 } from './AppBuildTimeGlueCodeGenerator';
10
11
  import { NativeModuleCodeGenerator } from './NativeModuleCodeGenerator';
11
12
  import { ArkTSComponentCodeGeneratorArkTS } from './ArkTSComponentCodeGeneratorArkTS';
12
13
 
14
+ // The name of rnoh OHOS module
15
+ const RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
16
+
13
17
  /**
14
18
  * Generates code for libraries built on top of RNOH's ArkTS architecture.
15
19
  */
@@ -28,17 +32,18 @@ export class UberGeneratorV1 implements CodeGenerator<UberSchema> {
28
32
 
29
33
  generate(uberSchema: UberSchema) {
30
34
  const fileContentByPath = new Map<AbsolutePath, string>();
35
+ const isRNOHModulePath = this.etsOutputPath.getValue().endsWith(`${RNOH_OHOS_NAME}/generated`.replace(/\//g, pathUtils.sep));
31
36
  const componentCodeGenerator = new ArkTSComponentCodeGeneratorArkTS(
32
37
  this.cppOutputPath,
33
38
  this.etsOutputPath.copyWithNewSegment('components'),
34
39
  this.codegenNoticeLines,
35
- '../../ts'
40
+ isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`
36
41
  );
37
42
  const nativeModuleCodeGenerator = new NativeModuleCodeGenerator(
38
43
  this.cppOutputPath,
39
44
  this.etsOutputPath.copyWithNewSegment('turboModules'),
40
45
  this.codegenNoticeLines,
41
- '../../ts'
46
+ isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`
42
47
  );
43
48
  const generatorBySpecType = {
44
49
  Component: componentCodeGenerator,
@@ -1,3 +1,4 @@
1
+ import pathUtils from 'path';
1
2
  import { AbsolutePath } from '../../core';
2
3
  import { CodeGenerator } from '../core';
3
4
  import {
@@ -8,6 +9,9 @@ import { NativeModuleCodeGenerator } from './NativeModuleCodeGenerator';
8
9
  import { GlueCodeDataV2 } from './AppBuildTimeGlueCodeGenerator';
9
10
  import { SharedComponentCodeGenerator } from './SharedComponentCodeGenerator';
10
11
 
12
+ // The name of rnoh OHOS module
13
+ const RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
14
+
11
15
  /**
12
16
  * Generates code for libraries built on top of RNOH's C-API architecture.
13
17
  */
@@ -78,6 +82,7 @@ export class UberGeneratorV2 implements CodeGenerator<LibraryData[]> {
78
82
  .getSpecSchemaByFilenameMap()
79
83
  .entries()) {
80
84
  if (specSchema.type === 'NativeModule') {
85
+ const isRNOHModulePath = this.etsOutputPath.getValue().endsWith(`${RNOH_OHOS_NAME}/generated`.replace(/\//g, pathUtils.sep));
81
86
  const nativeModuleCodeGenerator = new NativeModuleCodeGenerator(
82
87
  libraryCppOutput.copyWithNewSegment(
83
88
  'RNOH',
@@ -86,7 +91,7 @@ export class UberGeneratorV2 implements CodeGenerator<LibraryData[]> {
86
91
  ),
87
92
  this.etsOutputPath.copyWithNewSegment('turboModules'),
88
93
  this.codegenNoticeLines,
89
- '../../ts'
94
+ isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`
90
95
  );
91
96
  nativeModuleCodeGenerator
92
97
  .generate(specSchema)
@@ -27,7 +27,12 @@ export const commandCodegenHarmony: Command = {
27
27
  options: [
28
28
  {
29
29
  name: '--rnoh-module-path <path>',
30
- description: 'Specifies the relative path to the rnoh OHOS module',
30
+ description: '[deprecated] Specifies the relative path to the rnoh OHOS module',
31
+ },
32
+ {
33
+ name: '--ets-output-path <path>',
34
+ description:
35
+ 'Specifies the relative path to the output directory intended for storing generated ETS files.',
31
36
  },
32
37
  {
33
38
  name: '--cpp-output-path <path>',
@@ -58,9 +63,12 @@ export const commandCodegenHarmony: Command = {
58
63
  const MAX_SUPPORTED_CODEGEN_VERSION = 2;
59
64
  // prepare the input data
60
65
  validateArgs(args);
61
- const etsOutputPath = new AbsolutePath(
62
- args.rnohModulePath
63
- ).copyWithNewSegment('generated');
66
+ let etsOutputPath = args.etsOutputPath || args.rnohModulePath;
67
+ const isEndWithGenerated = /\/generated\/?$/.test(etsOutputPath);
68
+ etsOutputPath = new AbsolutePath(etsOutputPath);
69
+ if (!isEndWithGenerated) {
70
+ etsOutputPath = etsOutputPath.copyWithNewSegment('generated');
71
+ }
64
72
  const enableSafetyCheck: boolean = args.safetyCheck;
65
73
  const cppOutputPath = new AbsolutePath(args.cppOutputPath);
66
74
  const projectRootPath = new AbsolutePath(args.projectRootPath);
@@ -159,11 +167,13 @@ export const commandCodegenHarmony: Command = {
159
167
  };
160
168
 
161
169
  function validateArgs(args: any) {
162
- if (!args.rnohModulePath) {
170
+ if (!args.rnohModulePath && !args.etsOutputPath) {
163
171
  throw new DescriptiveError({
164
- whatHappened: "--rnoh-module-path argument wasn't provided",
172
+ whatHappened: '--ets-output-path is required',
165
173
  whatCanUserDo: [
166
- 'Please provide a path to the native React Native for Open Harmony module (rnoh) which is probably located somewhere in "<PROJECT_ROOT>/harmony" directory',
174
+ 'Please provide an output path for the ETS file.',
175
+ 'It is recommended to place it in the same directory as the custom component or TurboModule.',
176
+ 'Do not place it inside @rnoh/react-native-openharmony, otherwise a jscrash may occur when using react_native_openharmony_release2.har.'
167
177
  ],
168
178
  });
169
179
  }
@@ -19,8 +19,11 @@ import {
19
19
  startServerInNewWindow,
20
20
  findDevServerPort,
21
21
  } from '@react-native-community/cli-tools';
22
+ import { launchHarmonySimulator } from '../simulator';
22
23
 
23
24
  const COMMAND_NAME = 'run-harmony';
25
+ const LOOPBACK_IP = '127.0.0.1';
26
+ const DEFAULT_SIMULATOR_NAME = `${LOOPBACK_IP}:5555`;
24
27
 
25
28
  export const commandRunHarmony: Command = {
26
29
  name: COMMAND_NAME,
@@ -108,7 +111,7 @@ export const commandRunHarmony: Command = {
108
111
  const buildMode: string = rawArgs.buildMode;
109
112
  const moduleName: string = rawArgs.module;
110
113
  const abilityName: string = rawArgs.ability;
111
- const simulatorName: string = rawArgs.simulator;
114
+ let simulatorName: string = rawArgs.simulator;
112
115
  const defaultPort: number = rawArgs.port;
113
116
  const packager: boolean = rawArgs.packager;
114
117
  const devEcoStudioToolsPath = new AbsolutePath(
@@ -125,6 +128,32 @@ export const commandRunHarmony: Command = {
125
128
  )
126
129
  ).app.bundleName;
127
130
 
131
+ let currentPort: number = defaultPort;
132
+ if (packager) {
133
+ const root: string = _config.root || '.';
134
+ const reactNativePath: string = _config.reactNativePath || path.dirname(
135
+ require.resolve('react-native', { paths: [root] }),
136
+ );
137
+ const { port: newPort, startPackager } = await findDevServerPort(
138
+ defaultPort,
139
+ root,
140
+ );
141
+
142
+ if (newPort !== 8081) {
143
+ await trySetMetroPort(harmonyProjectPath.copyWithNewSegment(
144
+ 'entry', 'src', 'main', 'ets', 'pages', 'Index.ets').toString(), newPort);
145
+ }
146
+ if (startPackager) {
147
+ startServerInNewWindow(
148
+ newPort,
149
+ root,
150
+ reactNativePath,
151
+ getDefaultUserTerminal(),
152
+ );
153
+ }
154
+ currentPort = newPort;
155
+ }
156
+
128
157
  const selectDevice = async (deviceAndSimulatorInfos: string) => {
129
158
  const lines = deviceAndSimulatorInfos.trim().split('\n');
130
159
  const availableDevices = lines.map((line) => {
@@ -150,6 +179,11 @@ export const commandRunHarmony: Command = {
150
179
  return simulatorName;
151
180
  }
152
181
  const connectedDevices = availableDevices.filter((deviceOrSimulator) => deviceOrSimulator.state === 'Connected');
182
+
183
+ if (connectedDevices.length === 1) {
184
+ return connectedDevices[0].name;
185
+ }
186
+
153
187
  if (connectedDevices.length > 1) {
154
188
  const answers = await inquirer.prompt([
155
189
  {
@@ -160,14 +194,33 @@ export const commandRunHarmony: Command = {
160
194
  }
161
195
  ])
162
196
  return connectedDevices[parseInt(answers.selectedDeviceIndex) - 1].name;
163
- } else if (connectedDevices.length === 1) {
164
- return connectedDevices[0].name;
165
- } else {
197
+ }
198
+
199
+ try {
200
+ await launchHarmonySimulator({
201
+ devEcoStudioToolsPath,
202
+ sdkToolchainsPath,
203
+ cli,
204
+ logger,
205
+ env: process.env,
206
+ });
207
+ simulatorName = DEFAULT_SIMULATOR_NAME;
208
+ return simulatorName;
209
+ } catch (e) {
210
+ if (e instanceof DescriptiveError) {
211
+ throw new DescriptiveError({
212
+ whatHappened: `${e.getMessage()} \n No devices are connected. Failed to auto-launch simulator.`,
213
+ whatCanUserDo: [...e.getSuggestions()],
214
+ extraData: e.getRawData().extraData,
215
+ });
216
+ }
166
217
  throw new DescriptiveError({
167
- whatHappened: `No devices are connected in the current environment.`,
218
+ whatHappened: `No devices are connected in the current environment (auto-launch attempt failed).`,
168
219
  whatCanUserDo: [
169
- 'Please connect your HarmonyOS device or open the simulator.',
170
- ]
220
+ 'Connect a HarmonyOS device via USB or start the simulator manually.',
221
+ 'Re-run the command after a device is listed by: hdc list targets -v',
222
+ ],
223
+ extraData: e,
171
224
  });
172
225
  }
173
226
  };
@@ -180,32 +233,9 @@ export const commandRunHarmony: Command = {
180
233
  }
181
234
  );
182
235
 
183
- const deviceOrSimulatorName = await selectDevice(deviceAndSimulatorInfo)
184
-
185
- let currentPort: number = defaultPort;
186
- if (packager) {
187
- const root: string = _config.root || '.';
188
- const reactNativePath: string = _config.reactNativePath || path.dirname(
189
- require.resolve('react-native', { paths: [root] }),
190
- );
191
- const { port: newPort, startPackager } = await findDevServerPort(
192
- defaultPort,
193
- root,
194
- );
195
-
196
- if (newPort !== 8081) {
197
- await trySetMetroPort(harmonyProjectPath.copyWithNewSegment(
198
- 'entry', 'src', 'main', 'ets', 'pages', 'Index.ets').toString(), newPort);
199
- }
200
- if (startPackager) {
201
- startServerInNewWindow(
202
- newPort,
203
- root,
204
- reactNativePath,
205
- getDefaultUserTerminal(),
206
- );
207
- }
208
- currentPort = newPort;
236
+ const deviceOrSimulatorName = await selectDevice(deviceAndSimulatorInfo);
237
+ if (deviceOrSimulatorName.includes(`${LOOPBACK_IP}:`)) {
238
+ simulatorName = deviceOrSimulatorName;
209
239
  }
210
240
 
211
241
  const runJob = async (name: string, job: () => Promise<void>) => {
@@ -235,14 +265,11 @@ export const commandRunHarmony: Command = {
235
265
  .copyWithNewSegment('ohpm', 'bin', 'ohpm.bat');
236
266
  }
237
267
  await cli.run(
238
- process.platform === 'win32' ? `"${ohpmPath.toString()}"` :
239
- ohpmPath.toString(),
268
+ `"${ohpmPath.toString()}"`,
240
269
  {
241
270
  args: [
242
271
  'install',
243
272
  '--all',
244
- '--strict_ssl',
245
- 'true',
246
273
  ],
247
274
  cwd: harmonyProjectPath,
248
275
  shell: true,
@@ -265,10 +292,9 @@ export const commandRunHarmony: Command = {
265
292
  nodePath = devEcoStudioToolsPath.copyWithNewSegment('node', 'node');
266
293
  }
267
294
  let hvigorPathRaw = devEcoStudioToolsPath.copyWithNewSegment('hvigor', 'bin', 'hvigorw.js').toString();
268
- const hvigorPath = process.platform === 'win32' ? `"${hvigorPathRaw}"` : hvigorPathRaw;
295
+ const hvigorPath = `"${hvigorPathRaw}"`;
269
296
  await cli.run(
270
- process.platform === 'win32' ? `"${nodePath.toString()}"` :
271
- nodePath.toString(),
297
+ `"${nodePath.toString()}"`,
272
298
  {
273
299
  args: [
274
300
  hvigorPath,
@@ -321,7 +347,7 @@ export const commandRunHarmony: Command = {
321
347
  const hdcPathStrRaw = sdkToolchainsPath
322
348
  .copyWithNewSegment('hdc')
323
349
  .toString();
324
- const hdcPathStr = process.platform === 'win32' ? `"${hdcPathStrRaw.toString()}"` : hdcPathStrRaw;
350
+ const hdcPathStr = `"${hdcPathStrRaw.toString()}"`;
325
351
 
326
352
  const tryRemoveForwardPorting = async () => {
327
353
  let fportInfo: string = '';
@@ -10,6 +10,13 @@
10
10
  "deliveryWithInstall": true,
11
11
  "installationFree": false,
12
12
  "pages": "$profile:main_pages",
13
+ // This is needed by bundleManager.canOpenLink to check if the app can open some url
14
+ "querySchemes": [
15
+ "maps",
16
+ "http",
17
+ "https",
18
+ "customDomain"
19
+ ],
13
20
  "requestPermissions": [
14
21
  {
15
22
  "name": "ohos.permission.INTERNET"