@react-native-oh/react-native-harmony-cli 0.0.28 → 0.0.36

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 (66) hide show
  1. package/dist/assetResolver.js +105 -10
  2. package/dist/autolinking/Autolinking.js +9 -11
  3. package/dist/codegen/core/EventUtils.js +5 -8
  4. package/dist/codegen/core/TypeAnnotationToTS.js +3 -3
  5. package/dist/codegen/core/UberSchema.js +7 -11
  6. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +3 -0
  7. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +3 -0
  8. package/dist/codegen/generators/CppComponentCodeGenerator.js +3 -0
  9. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +15 -0
  10. package/dist/commands/bundle-harmony.js +5 -68
  11. package/dist/commands/codegen-harmony.js +13 -17
  12. package/dist/commands/codegen-lib-harmony.js +10 -14
  13. package/dist/commands/create-metro-host-constants.js +1 -1
  14. package/dist/commands/index.js +2 -1
  15. package/dist/commands/init.js +703 -0
  16. package/dist/commands/link-harmony.js +1 -1
  17. package/dist/commands/pack-harmony.js +1 -1
  18. package/dist/commands/run-harmony.js +438 -0
  19. package/dist/commands/types.js +8 -0
  20. package/dist/commands/unpack-harmony.js +2 -4
  21. package/dist/commands/verify-package-harmony.js +2 -2
  22. package/dist/core/CodegenConfig.js +4 -6
  23. package/dist/core/DescriptiveError.js +8 -4
  24. package/dist/core/PackageJSON.js +4 -7
  25. package/dist/core/fs.js +4 -5
  26. package/dist/index.js +2 -1
  27. package/dist/io/CliExecutor.js +57 -24
  28. package/dist/io/Logger.js +72 -42
  29. package/dist/io/TarGz.js +1 -2
  30. package/dist/io/__fixtures__.js +9 -3
  31. package/dist/io/fsUtils.js +1 -2
  32. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +1 -2
  33. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +1 -2
  34. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +1 -2
  35. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +1 -2
  36. package/dist/package-verifier/verify-package.js +7 -10
  37. package/package.json +10 -3
  38. package/src/assetResolver.ts +117 -11
  39. package/src/autolinking/Autolinking.ts +10 -12
  40. package/src/codegen/core/EventUtils.ts +4 -6
  41. package/src/codegen/core/UberSchema.ts +7 -11
  42. package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +3 -0
  43. package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +3 -0
  44. package/src/codegen/generators/CppComponentCodeGenerator.ts +3 -0
  45. package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +24 -1
  46. package/src/commands/bundle-harmony.ts +6 -82
  47. package/src/commands/codegen-harmony.ts +14 -19
  48. package/src/commands/codegen-lib-harmony.ts +11 -16
  49. package/src/commands/create-metro-host-constants.ts +2 -2
  50. package/src/commands/index.ts +2 -1
  51. package/src/commands/init.ts +755 -0
  52. package/src/commands/link-harmony.ts +2 -2
  53. package/src/commands/pack-harmony.ts +2 -2
  54. package/src/commands/run-harmony.ts +478 -0
  55. package/src/commands/types.ts +21 -0
  56. package/src/commands/unpack-harmony.ts +3 -5
  57. package/src/commands/verify-package-harmony.ts +3 -3
  58. package/src/core/CodegenConfig.ts +4 -6
  59. package/src/core/DescriptiveError.ts +9 -9
  60. package/src/core/PackageJSON.ts +5 -8
  61. package/src/core/fs.ts +2 -2
  62. package/src/index.ts +5 -3
  63. package/src/io/CliExecutor.ts +56 -34
  64. package/src/io/Logger.ts +78 -45
  65. package/src/io/__fixtures__.ts +15 -11
  66. package/src/package-verifier/verify-package.ts +5 -7
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
+ * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
+ * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
@@ -0,0 +1,438 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
+ return new (P || (P = Promise))(function (resolve, reject) {
11
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
12
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
13
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
14
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
15
+ });
16
+ };
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
19
+ };
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.commandRunHarmony = void 0;
22
+ const core_1 = require("../core");
23
+ const io_1 = require("../io");
24
+ const CliExecutor_1 = require("../io/CliExecutor");
25
+ const fs_extra_1 = __importDefault(require("fs-extra"));
26
+ const node_crypto_1 = __importDefault(require("node:crypto"));
27
+ const json5_1 = __importDefault(require("json5"));
28
+ const inquirer_1 = __importDefault(require("inquirer"));
29
+ const path_1 = __importDefault(require("path"));
30
+ const cli_tools_1 = require("@react-native-community/cli-tools");
31
+ const COMMAND_NAME = 'run-harmony';
32
+ exports.commandRunHarmony = {
33
+ name: COMMAND_NAME,
34
+ description: 'Builds your app and starts it on your phone.',
35
+ options: [
36
+ {
37
+ name: '--harmony-project-path <path>',
38
+ description: 'Specifies the root of your OpenHarmony project.',
39
+ default: './harmony',
40
+ },
41
+ {
42
+ name: '--module <string>',
43
+ description: 'Name of the OH module to run.',
44
+ default: 'entry',
45
+ },
46
+ {
47
+ name: '--build-mode <string>',
48
+ description: 'Debug or Release.',
49
+ default: 'debug',
50
+ },
51
+ {
52
+ name: '--product <string>',
53
+ description: 'OpenHarmony product defined in build-profile.json5.',
54
+ default: 'default',
55
+ },
56
+ {
57
+ name: '--ability <string>',
58
+ description: 'Name of the ability to start.',
59
+ default: 'EntryAbility',
60
+ },
61
+ {
62
+ name: '--simulator <string>',
63
+ description: 'The name of the simulator that are currently connected.',
64
+ default: 'undefined',
65
+ },
66
+ {
67
+ name: '--port <number>',
68
+ description: 'The port to use for the device.',
69
+ default: process.env.RCT_METRO_PORT || 8081,
70
+ },
71
+ {
72
+ name: '--no-packager',
73
+ description: 'Do not launch packager while running the app.',
74
+ },
75
+ ],
76
+ func: (_argv, _config, rawArgs) => __awaiter(void 0, void 0, void 0, function* () {
77
+ const logger = new io_1.Logger();
78
+ try {
79
+ const DEVECO_SDK_HOME = process.env.DEVECO_SDK_HOME;
80
+ if (!DEVECO_SDK_HOME) {
81
+ throw new core_1.DescriptiveError({
82
+ whatHappened: 'DEVECO_SDK_HOME environment variable is not set',
83
+ whatCanUserDo: [
84
+ process.platform === 'darwin'
85
+ ? 'On MacOS, the contents directory is typically located at: /Applications/DevEco-Studio.app/Contents/sdk. Set this path as the value of DEVECO_SDK_HOME'
86
+ : "Locate the installation directory of DevEco Studio, and set its 'sdk' subdirectory as the value of DEVECO_SDK_HOME environment variable.",
87
+ ],
88
+ });
89
+ }
90
+ const fs = new io_1.RealFS();
91
+ const sdkPath = new core_1.AbsolutePath(DEVECO_SDK_HOME);
92
+ const sdkDirectoryNames = fs
93
+ .readDirentsSync(sdkPath)
94
+ .flatMap((dirent) => {
95
+ if (dirent.isDirectory()) {
96
+ return [dirent.name];
97
+ }
98
+ else {
99
+ return [];
100
+ }
101
+ });
102
+ if (sdkDirectoryNames.length === 0) {
103
+ throw new core_1.DescriptiveError({
104
+ whatHappened: `${sdkPath.toString()} has no directories`,
105
+ unexpected: true,
106
+ });
107
+ }
108
+ const sdkToolchainsPath = sdkPath.copyWithNewSegment(sdkDirectoryNames[0], 'openharmony', 'toolchains');
109
+ const cli = new CliExecutor_1.RealCliExecutor();
110
+ const harmonyProjectPath = new core_1.AbsolutePath(rawArgs.harmonyProjectPath);
111
+ const productName = rawArgs.product;
112
+ const buildMode = rawArgs.buildMode;
113
+ const moduleName = rawArgs.module;
114
+ const abilityName = rawArgs.ability;
115
+ const simulatorName = rawArgs.simulator;
116
+ const defaultPort = rawArgs.port;
117
+ const packager = rawArgs.packager;
118
+ const devEcoStudioToolsPath = new core_1.AbsolutePath(DEVECO_SDK_HOME).copyWithNewSegment('..', 'tools');
119
+ if (!fs.existsSync(devEcoStudioToolsPath)) {
120
+ throw new core_1.DescriptiveError({
121
+ whatHappened: `${devEcoStudioToolsPath.toString()} doesn't exist`,
122
+ });
123
+ }
124
+ const bundleName = json5_1.default.parse(fs.readTextSync(harmonyProjectPath.copyWithNewSegment('AppScope', 'app.json5'))).app.bundleName;
125
+ const selectDevice = (deviceAndSimulatorInfos) => __awaiter(void 0, void 0, void 0, function* () {
126
+ const lines = deviceAndSimulatorInfos.trim().split('\n');
127
+ const availableDevices = lines.map((line) => {
128
+ const parts = line.split(/\s+/);
129
+ return {
130
+ name: parts[0],
131
+ method: parts[1],
132
+ state: parts[2],
133
+ locate: parts[3],
134
+ connectTool: parts[4]
135
+ };
136
+ });
137
+ if (simulatorName !== 'undefined') {
138
+ const isRequestedDeviceAvailable = availableDevices.some((deviceOrSimulator) => deviceOrSimulator.name === simulatorName);
139
+ if (!isRequestedDeviceAvailable) {
140
+ throw new core_1.DescriptiveError({
141
+ whatHappened: `Simulator with name "${simulatorName}" not found.`,
142
+ whatCanUserDo: [
143
+ 'Please confirm whether the entered simulator name has been activated.',
144
+ ]
145
+ });
146
+ }
147
+ return simulatorName;
148
+ }
149
+ const connectedDevices = availableDevices.filter((deviceOrSimulator) => deviceOrSimulator.state === 'Connected');
150
+ if (connectedDevices.length > 1) {
151
+ const answers = yield inquirer_1.default.prompt([
152
+ {
153
+ type: 'list',
154
+ name: 'selectedDeviceIndex',
155
+ message: 'Please select a device:',
156
+ choices: connectedDevices.map((deviceOrSimulator, index) => `${index + 1}. ${deviceOrSimulator.name}`)
157
+ }
158
+ ]);
159
+ return connectedDevices[parseInt(answers.selectedDeviceIndex) - 1].name;
160
+ }
161
+ else if (connectedDevices.length === 1) {
162
+ return connectedDevices[0].name;
163
+ }
164
+ else {
165
+ throw new core_1.DescriptiveError({
166
+ whatHappened: `No devices are connected in the current environment.`,
167
+ whatCanUserDo: [
168
+ 'Please connect your HarmonyOS device or open the simulator.',
169
+ ]
170
+ });
171
+ }
172
+ });
173
+ const deviceAndSimulatorInfo = yield cli.run(sdkToolchainsPath.copyWithNewSegment('hdc').toString(), {
174
+ args: ['list', 'targets', '-v'],
175
+ cwd: harmonyProjectPath,
176
+ });
177
+ const deviceOrSimulatorName = yield selectDevice(deviceAndSimulatorInfo);
178
+ let currentPort = defaultPort;
179
+ if (packager) {
180
+ const root = _config.root || '.';
181
+ const reactNativePath = _config.reactNativePath || path_1.default.dirname(require.resolve('react-native', { paths: [root] }));
182
+ const { port: newPort, startPackager } = yield (0, cli_tools_1.findDevServerPort)(defaultPort, root);
183
+ if (newPort !== 8081) {
184
+ yield trySetMetroPort(harmonyProjectPath.copyWithNewSegment('entry', 'src', 'main', 'ets', 'pages', 'Index.ets').toString(), newPort);
185
+ }
186
+ if (startPackager) {
187
+ (0, cli_tools_1.startServerInNewWindow)(newPort, root, reactNativePath, (0, cli_tools_1.getDefaultUserTerminal)());
188
+ }
189
+ currentPort = newPort;
190
+ }
191
+ const runJob = (name, job) => __awaiter(void 0, void 0, void 0, function* () {
192
+ const stop = logger.start((s) => s.bold(name));
193
+ logger.info((s) => s.bold(`${name} started`));
194
+ try {
195
+ yield job();
196
+ logger.succeed((s) => s.bold(`${name} finished`));
197
+ }
198
+ catch (err) {
199
+ if (err instanceof core_1.DescriptiveError) {
200
+ throw err;
201
+ }
202
+ throw new core_1.DescriptiveError({
203
+ whatHappened: `${name} failed`,
204
+ extraData: err,
205
+ });
206
+ }
207
+ finally {
208
+ stop();
209
+ }
210
+ });
211
+ yield runJob('[1/3] installing dependencies', () => __awaiter(void 0, void 0, void 0, function* () {
212
+ let ohpmPath = devEcoStudioToolsPath
213
+ .copyWithNewSegment('ohpm', 'bin', 'ohpm');
214
+ if (process.platform === 'win32') {
215
+ ohpmPath = devEcoStudioToolsPath
216
+ .copyWithNewSegment('ohpm', 'bin', 'ohpm.bat');
217
+ }
218
+ yield cli.run(process.platform === 'win32' ? `"${ohpmPath.toString()}"` :
219
+ ohpmPath.toString(), {
220
+ args: [
221
+ 'install',
222
+ '--all',
223
+ '--strict_ssl',
224
+ 'true',
225
+ ],
226
+ cwd: harmonyProjectPath,
227
+ shell: true,
228
+ onArgsStringified: (commandWithArgs) => {
229
+ logger.debug((s) => s.bold(s.gray(commandWithArgs)));
230
+ },
231
+ onStdout: (msg) => {
232
+ logger.debug((s) => s.gray(msg.trimEnd()));
233
+ },
234
+ onStderr(msg) {
235
+ logger.debug(() => msg.trimEnd());
236
+ },
237
+ });
238
+ }));
239
+ yield runJob('[2/3] building app', () => __awaiter(void 0, void 0, void 0, function* () {
240
+ let nodePath = devEcoStudioToolsPath
241
+ .copyWithNewSegment('node', 'bin', 'node');
242
+ if (!fs.existsSync(nodePath)) {
243
+ nodePath = devEcoStudioToolsPath.copyWithNewSegment('node', 'node');
244
+ }
245
+ let hvigorPathRaw = devEcoStudioToolsPath.copyWithNewSegment('hvigor', 'bin', 'hvigorw.js').toString();
246
+ const hvigorPath = process.platform === 'win32' ? `"${hvigorPathRaw}"` : hvigorPathRaw;
247
+ yield cli.run(process.platform === 'win32' ? `"${nodePath.toString()}"` :
248
+ nodePath.toString(), {
249
+ args: [
250
+ hvigorPath,
251
+ `-p`,
252
+ `module=${moduleName}@default`,
253
+ `-p`,
254
+ `product=${productName}`,
255
+ `-p`,
256
+ `buildMode=${buildMode}`,
257
+ `-p`,
258
+ `requiredDeviceType=phone`,
259
+ `assembleHap`,
260
+ ],
261
+ cwd: harmonyProjectPath,
262
+ shell: true,
263
+ onArgsStringified: (commandWithArgs) => {
264
+ logger.debug((s) => s.bold(s.gray(commandWithArgs)));
265
+ },
266
+ onStdout: (msg) => {
267
+ logger.debug((s) => s.gray(msg.trimEnd()));
268
+ },
269
+ onStderr(msg) {
270
+ logger.debug(() => msg.trimEnd());
271
+ },
272
+ });
273
+ }));
274
+ yield runJob('[3/3] installing and opening app', () => __awaiter(void 0, void 0, void 0, function* () {
275
+ const tmpDirName = generateRandomString();
276
+ const ohosTmpDirPath = `data/local/tmp/${tmpDirName}`;
277
+ const exec = (command, args) => __awaiter(void 0, void 0, void 0, function* () {
278
+ const result = yield cli.run(command, {
279
+ args: args,
280
+ shell: true,
281
+ onArgsStringified: (commandWithArgs) => logger.debug((s) => s.bold(s.gray(commandWithArgs))),
282
+ });
283
+ if (result.startsWith('[Fail]')) {
284
+ throw new core_1.DescriptiveError({ whatHappened: result });
285
+ }
286
+ if (result) {
287
+ logger.debug((s) => s.gray(result.trimEnd() + '\n'));
288
+ }
289
+ else {
290
+ logger.debug(() => '');
291
+ }
292
+ return result;
293
+ });
294
+ const hdcPathStrRaw = sdkToolchainsPath
295
+ .copyWithNewSegment('hdc')
296
+ .toString();
297
+ const hdcPathStr = process.platform === 'win32' ? `"${hdcPathStrRaw.toString()}"` : hdcPathStrRaw;
298
+ const tryRemoveForwardPorting = () => __awaiter(void 0, void 0, void 0, function* () {
299
+ let fportInfo = '';
300
+ yield cli.run(hdcPathStrRaw, {
301
+ args: ['fport', 'ls'],
302
+ cwd: harmonyProjectPath,
303
+ onStdout: (msg) => {
304
+ fportInfo += msg;
305
+ },
306
+ onStderr: (msg) => {
307
+ logger.debug((s) => s.gray(msg.trimEnd()));
308
+ },
309
+ });
310
+ if (fportInfo.includes(`tcp:${currentPort} tcp:${currentPort}`)) {
311
+ yield exec(hdcPathStr, [
312
+ 'fport',
313
+ 'rm',
314
+ `tcp:${currentPort}`,
315
+ `tcp:${currentPort}`
316
+ ]);
317
+ }
318
+ });
319
+ yield exec(hdcPathStr, ['-t', deviceOrSimulatorName, 'shell', 'aa', 'force-stop', bundleName]);
320
+ try {
321
+ yield exec(hdcPathStr, ['-t', deviceOrSimulatorName, 'shell', 'mkdir', ohosTmpDirPath]);
322
+ let hapName = `${moduleName}-default-signed.hap`;
323
+ if (simulatorName !== 'undefined') {
324
+ hapName = `${moduleName}-default-unsigned.hap`;
325
+ }
326
+ yield exec(hdcPathStr, [
327
+ '-t',
328
+ deviceOrSimulatorName,
329
+ 'file',
330
+ 'send',
331
+ harmonyProjectPath
332
+ .copyWithNewSegment(moduleName, 'build', 'default', 'outputs', 'default', hapName)
333
+ .toString(),
334
+ ohosTmpDirPath,
335
+ ]);
336
+ const installationResult = yield exec(hdcPathStr, [
337
+ '-t',
338
+ deviceOrSimulatorName,
339
+ 'shell',
340
+ 'bm',
341
+ 'install',
342
+ '-p',
343
+ ohosTmpDirPath,
344
+ ]);
345
+ if (installationResult.includes('failed to install')) {
346
+ throw new core_1.DescriptiveError({
347
+ whatHappened: 'Installation failed.',
348
+ whatCanUserDo: [
349
+ `If an application with the same bundle name is already installed, try uninstalling it:\n${hdcPathStr} shell bm uninstall -n ${bundleName}`,
350
+ ],
351
+ });
352
+ }
353
+ }
354
+ finally {
355
+ yield exec(hdcPathStr, ['-t', deviceOrSimulatorName, 'shell', 'rm', '-rf', ohosTmpDirPath]);
356
+ }
357
+ yield exec(hdcPathStr, [
358
+ '-t',
359
+ deviceOrSimulatorName,
360
+ 'shell',
361
+ 'aa',
362
+ 'start',
363
+ '-a',
364
+ abilityName,
365
+ '-b',
366
+ bundleName,
367
+ ]);
368
+ yield tryRemoveForwardPorting();
369
+ yield exec(hdcPathStr, [
370
+ '-t',
371
+ deviceOrSimulatorName,
372
+ 'rport',
373
+ `tcp:${currentPort}`,
374
+ `tcp:${currentPort}`
375
+ ]);
376
+ }));
377
+ }
378
+ catch (err) {
379
+ if (err instanceof core_1.DescriptiveError) {
380
+ logger.descriptiveError(new core_1.DescriptiveError({
381
+ whatHappened: err.getMessage(),
382
+ whatCanUserDo: [
383
+ ...err.getSuggestions(),
384
+ 'Try building and running the app from DevEco studio.',
385
+ ],
386
+ extraData: err.getRawData().extraData,
387
+ }));
388
+ }
389
+ else {
390
+ throw err;
391
+ }
392
+ }
393
+ }),
394
+ };
395
+ function generateRandomString(length = 32) {
396
+ const chars = '0123456789abcdefghijklmnopqrstuvwxyz';
397
+ let result = '';
398
+ const randomValues = new Uint8Array(length);
399
+ node_crypto_1.default.getRandomValues(randomValues);
400
+ for (let i = 0; i < length; i++) {
401
+ const randomIndex = randomValues[i] % chars.length;
402
+ result += chars[randomIndex];
403
+ }
404
+ return result;
405
+ }
406
+ function trySetMetroPort(filePath, port) {
407
+ return __awaiter(this, void 0, void 0, function* () {
408
+ let content = yield fs_extra_1.default.readFile(filePath, 'utf-8');
409
+ const reFromServerIp = /MetroJSBundleProvider\.fromServerIp\(\s*"([^"]+)"\s*,\s*(\d+)\s*\)/;
410
+ if (reFromServerIp.test(content)) {
411
+ content = content.replace(reFromServerIp, (_match, host) => {
412
+ return `MetroJSBundleProvider.fromServerIp("${host}", ${port})`;
413
+ });
414
+ yield fs_extra_1.default.writeFile(filePath, content, 'utf-8');
415
+ return;
416
+ }
417
+ const reNewProvider = /new\s+MetroJSBundleProvider\s*\(\s*\)/;
418
+ if (reNewProvider.test(content)) {
419
+ content = content.replace(reNewProvider, () => {
420
+ return `MetroJSBundleProvider.fromServerIp("localhost", ${port}),\n new MetroJSBundleProvider()`;
421
+ });
422
+ yield fs_extra_1.default.writeFile(filePath, content, 'utf-8');
423
+ return;
424
+ }
425
+ throw new core_1.DescriptiveError({
426
+ whatHappened: `Unable to set the specified port [${port}] for the Metro server automatically.`,
427
+ whatCanUserDo: [
428
+ `Please manually add "MetroJSBundleProvider.fromServerIp("localhost", ${port})" in the "new AnyJSBundleProvider" section of your ${filePath} file.
429
+ e.g:
430
+ new AnyJSBundleProvider([
431
+ MetroJSBundleProvider.fromServerIp("localhost", ${port}),
432
+ new MetroJSBundleProvider(),
433
+ new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
434
+ ])`
435
+ ],
436
+ });
437
+ });
438
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ /**
3
+ * Copyright (c) 2025 Huawei Technologies Co., Ltd.
4
+ *
5
+ * This source code is licensed under the MIT license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
+ * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
@@ -61,9 +61,7 @@ function unpack(projectRootPath, outputDirPath) {
61
61
  const logger = new io_1.Logger();
62
62
  const fs = new io_1.RealFS();
63
63
  const projectDependenciesManager = new core_1.ProjectDependenciesManager(fs, projectRootPath);
64
- logger.info((styles) => styles.bold(`Unpacking RNOH modules`), {
65
- prefix: true,
66
- });
64
+ logger.info((styles) => styles.bold(`Unpacking RNOH modules`));
67
65
  let unpackedArchivesCount = 0;
68
66
  let skippedArchivesCount = 0;
69
67
  yield projectDependenciesManager.forEachAsync((dependency) => __awaiter(this, void 0, void 0, function* () {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
+ * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
@@ -102,7 +102,7 @@ function validateArgs(args) {
102
102
  if (!args.packagePath) {
103
103
  throw new core_1.DescriptiveError({
104
104
  whatHappened: 'package-path is undefined',
105
- whatCanUserDo: { default: ['Please provide --package-path'] },
105
+ whatCanUserDo: ['Please provide --package-path'],
106
106
  });
107
107
  }
108
108
  return {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
+ * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
@@ -29,11 +29,9 @@ class CodegenConfig {
29
29
  if (!node_fs_1.default.existsSync(specPath.getValue())) {
30
30
  throw new DescriptiveError_1.DescriptiveError({
31
31
  whatHappened: `No such file or directory: ${specPath.getValue()}`,
32
- whatCanUserDo: {
33
- default: [
34
- `Please verify "${packageName}/package.json::harmony::codegenConfig". If you are not the maintainer of this package, please report this problem to the package maintainer.`,
35
- ],
36
- },
32
+ whatCanUserDo: [
33
+ `Please verify "${packageName}/package.json::harmony::codegenConfig". If you are not the maintainer of this package, please report this problem to the package maintainer.`,
34
+ ],
37
35
  });
38
36
  }
39
37
  if (node_fs_1.default.lstatSync(specPath.getValue()).isDirectory()) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
+ * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
@@ -18,14 +18,18 @@ class DescriptiveError extends Error {
18
18
  getMessage() {
19
19
  return this.data.whatHappened;
20
20
  }
21
- getSuggestionsByRole() {
21
+ getSuggestions() {
22
+ var _a;
22
23
  if ('whatCanUserDo' in this.data) {
23
- return this.data.whatCanUserDo;
24
+ return (_a = this.data.whatCanUserDo) !== null && _a !== void 0 ? _a : [];
24
25
  }
25
26
  else {
26
- return null;
27
+ return [];
27
28
  }
28
29
  }
30
+ getRawData() {
31
+ return this.data;
32
+ }
29
33
  getDetails() {
30
34
  var _a;
31
35
  if (!this.data.extraData) {
@@ -9,12 +9,10 @@ class PackageJSON {
9
9
  if (!fs.existsSync(packageJSONPath)) {
10
10
  throw new DescriptiveError_1.DescriptiveError({
11
11
  whatHappened: "Couldn't find 'package.json'",
12
- whatCanUserDo: {
13
- default: [
14
- 'Check if the path to project root is correct',
15
- 'Try changing working directory to project root',
16
- ],
17
- },
12
+ whatCanUserDo: [
13
+ 'Check if the path to project root is correct',
14
+ 'Try changing working directory to project root',
15
+ ],
18
16
  extraData: packageJSONPath.getValue(),
19
17
  });
20
18
  }
@@ -24,7 +22,6 @@ class PackageJSON {
24
22
  catch (err) {
25
23
  throw new DescriptiveError_1.DescriptiveError({
26
24
  whatHappened: "Couldn't parse package.json",
27
- whatCanUserDo: {},
28
25
  extraData: { packageJSONPath, err },
29
26
  });
30
27
  }
package/dist/core/fs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
+ * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
@@ -9,7 +9,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
9
9
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.maybeRemoveFilesInDirectory = exports.maybeMakeDirectories = void 0;
12
+ exports.maybeMakeDirectories = maybeMakeDirectories;
13
+ exports.maybeRemoveFilesInDirectory = maybeRemoveFilesInDirectory;
13
14
  const node_fs_1 = __importDefault(require("node:fs"));
14
15
  const DescriptiveError_1 = require("./DescriptiveError");
15
16
  function maybeMakeDirectories(path) {
@@ -17,7 +18,6 @@ function maybeMakeDirectories(path) {
17
18
  node_fs_1.default.mkdirSync(path.getValue(), { recursive: true });
18
19
  }
19
20
  }
20
- exports.maybeMakeDirectories = maybeMakeDirectories;
21
21
  function maybeRemoveFilesInDirectory(path) {
22
22
  if (!node_fs_1.default.existsSync(path.getValue())) {
23
23
  return;
@@ -25,7 +25,7 @@ function maybeRemoveFilesInDirectory(path) {
25
25
  if (!node_fs_1.default.lstatSync(path.getValue()).isDirectory()) {
26
26
  throw new DescriptiveError_1.DescriptiveError({
27
27
  whatHappened: "Tried to remove all files from a path that doesn't point to a directory",
28
- whatCanUserDo: { default: [`Verify path: ${path.getValue()}`] },
28
+ whatCanUserDo: [`Verify path: ${path.getValue()}`],
29
29
  });
30
30
  }
31
31
  const fileOrDirNames = node_fs_1.default.readdirSync(path.getValue());
@@ -39,4 +39,3 @@ function maybeRemoveFilesInDirectory(path) {
39
39
  }
40
40
  });
41
41
  }
42
- exports.maybeRemoveFilesInDirectory = maybeRemoveFilesInDirectory;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
3
+ * Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
4
4
  *
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
@@ -18,5 +18,6 @@ exports.config = {
18
18
  commands_1.commandVerifyPackageHarmony,
19
19
  commands_1.commandCodegenLibHarmony,
20
20
  commands_1.commandLinkHarmony,
21
+ commands_1.commandRunHarmony,
21
22
  ],
22
23
  };