@react-native-oh/react-native-harmony-cli 0.77.50 → 0.77.64

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 (197) hide show
  1. package/dist/assetResolver.js +31 -3
  2. package/dist/autolinking/Autolinking.js +8 -1
  3. package/dist/autolinking/JSON5Writer.js +61 -0
  4. package/dist/autolinking/index.js +6 -0
  5. package/dist/commands/bundle-harmony.js +15 -0
  6. package/harmony/{rnoh-hvigor-plugin-0.77.50.tgz → rnoh-hvigor-plugin-0.77.64.tgz} +0 -0
  7. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/00a68392 +0 -0
  8. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0544a6cc +0 -0
  9. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0f36b2db +0 -0
  10. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12f23f1e +0 -0
  11. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/13d95d98 +0 -0
  12. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1629e86b +0 -0
  13. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/180c8379 +0 -0
  14. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1a697147 +0 -0
  15. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1a8271b1 +0 -0
  16. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1b7fa689 +0 -0
  17. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/255a9f13 +0 -0
  18. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/268d155b +0 -0
  19. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/27db9aa4 +0 -0
  20. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/28db79ed +0 -0
  21. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2dc2bbcb +0 -0
  22. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2df5f8c5 +0 -0
  23. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2f88aedb +0 -0
  24. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/31b3a7ea +0 -0
  25. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/36335b1c +0 -0
  26. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/38fca641 +0 -0
  27. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/397722eb +0 -0
  28. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/{d64bff57 → 397b6432} +0 -0
  29. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3b17421f +0 -0
  30. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/454f5e18 +0 -0
  31. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/45ec6cce +0 -0
  32. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/482d51b1 +0 -0
  33. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4ac5cd67 +0 -0
  34. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4d40499a +0 -0
  35. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4dcad919 +0 -0
  36. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/4fc31929 +0 -0
  37. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/54edc8f5 +0 -0
  38. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/558a5405 +0 -0
  39. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/58d2b670 +0 -0
  40. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5ec7feca +0 -0
  41. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62180f3e +0 -0
  42. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/63981360 +0 -0
  43. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/64096c89 +0 -0
  44. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/64af560b +0 -0
  45. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6585e783 +0 -0
  46. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/{8e83cbe1 → 6954304f} +0 -0
  47. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/{1184678c → 69fd6235} +0 -0
  48. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6d3a0478 +0 -0
  49. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6e131db7 +0 -0
  50. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/778cd8f1 +0 -0
  51. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/788206b6 +0 -0
  52. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7882dc26 +0 -0
  53. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7b3c14f7 +0 -0
  54. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7cdfe667 +0 -0
  55. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8048c487 +0 -0
  56. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8332d9a3 +0 -0
  57. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/84e5b603 +0 -0
  58. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/854d8127 +0 -0
  59. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/88c97376 +0 -0
  60. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/90d5f644 +0 -0
  61. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/967e25ac +0 -0
  62. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/969896c2 +0 -0
  63. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9790193e +0 -0
  64. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/{c342b18e → 97ae40c5} +0 -0
  65. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9a5bf482 +0 -0
  66. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a07adeb9 +0 -0
  67. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a427f355 +0 -0
  68. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/{cf039161 → a9dd7eb7} +0 -0
  69. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a9e9d79e +0 -0
  70. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ab920855 +0 -0
  71. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ab9e3038 +0 -0
  72. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/af054988 +0 -0
  73. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/afe03e51 +0 -0
  74. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b3b83913 +0 -0
  75. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b4db7b4d +0 -0
  76. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b5225355 +0 -0
  77. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b8c00f06 +0 -0
  78. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b917a081 +0 -0
  79. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b9e2f3bd +0 -0
  80. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/{5c2aafe7 → bd70db0e} +0 -0
  81. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bdbda648 +0 -0
  82. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/be1e5469 +0 -0
  83. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/{333648cc → c9462295} +0 -0
  84. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ca6e5efa +0 -0
  85. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/caf52beb +0 -0
  86. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cb268960 +0 -0
  87. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cca16b15 +0 -0
  88. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cfc1c937 +0 -0
  89. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d10e6e05 +0 -0
  90. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d172fc04 +0 -0
  91. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d4e94e50 +0 -0
  92. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d59f8d2c +0 -0
  93. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/da964053 +0 -0
  94. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e0bb712a +0 -0
  95. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e3e6ca34 +0 -0
  96. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e50f7385 +0 -0
  97. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f1a1d282 +0 -0
  98. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f2514c3c +0 -0
  99. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f66207cf +0 -0
  100. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f8d129ce +0 -0
  101. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fb1e9558 +0 -0
  102. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ff7e3608 +0 -0
  103. package/package.json +5 -4
  104. package/src/assetResolver.ts +37 -3
  105. package/src/autolinking/Autolinking.test.ts +70 -17
  106. package/src/autolinking/Autolinking.ts +14 -9
  107. package/src/autolinking/JSON5Writer.ts +70 -0
  108. package/src/autolinking/index.ts +7 -0
  109. package/src/commands/bundle-harmony.ts +17 -0
  110. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0271b9dd +0 -0
  111. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/07ba0208 +0 -0
  112. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/082dd09d +0 -0
  113. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0a9e1b0b +0 -0
  114. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0c3d528a +0 -0
  115. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1014d3ff +0 -0
  116. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12621366 +0 -0
  117. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/126d3e66 +0 -0
  118. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/19262852 +0 -0
  119. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/203fac53 +0 -0
  120. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/237b660a +0 -0
  121. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2528002d +0 -0
  122. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2587d041 +0 -0
  123. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2893bd11 +0 -0
  124. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2af6ff9d +0 -0
  125. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2bf31f33 +0 -0
  126. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/386f6df0 +0 -0
  127. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3b8c270e +0 -0
  128. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3bcc34ba +0 -0
  129. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/444808bd +0 -0
  130. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/44a775e2 +0 -0
  131. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/46da3ccd +0 -0
  132. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/51f80e35 +0 -0
  133. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5203a2ca +0 -0
  134. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/52795646 +0 -0
  135. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/577f8208 +0 -0
  136. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c69bcfe +0 -0
  137. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62695b92 +0 -0
  138. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62698102 +0 -0
  139. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6411ab00 +0 -0
  140. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6569ba92 +0 -0
  141. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/65e5133c +0 -0
  142. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/66029655 +0 -0
  143. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/69e85d0d +0 -0
  144. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6afcb99e +0 -0
  145. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6de07367 +0 -0
  146. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/72498307 +0 -0
  147. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7babd1de +0 -0
  148. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7fe56d21 +0 -0
  149. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/810cbd72 +0 -0
  150. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/812386d2 +0 -0
  151. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8448897d +0 -0
  152. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/84ab0a41 +0 -0
  153. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/853825e2 +0 -0
  154. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/862ad93a +0 -0
  155. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/86b14da6 +0 -0
  156. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/87f0fe62 +0 -0
  157. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/88ee8f74 +0 -0
  158. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c5237c9 +0 -0
  159. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c725800 +0 -0
  160. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8f4085b9 +0 -0
  161. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/931f0b2e +0 -0
  162. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/940c8f92 +0 -0
  163. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/968191a3 +0 -0
  164. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/970780c0 +0 -0
  165. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/98bc4394 +0 -0
  166. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/99a3b0b0 +0 -0
  167. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9c0ffa6b +0 -0
  168. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9d9b42c2 +0 -0
  169. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a04266ef +0 -0
  170. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a18f78c5 +0 -0
  171. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a642fb0e +0 -0
  172. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a97edf40 +0 -0
  173. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/aa672a20 +0 -0
  174. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ae25c61a +0 -0
  175. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b2bebae6 +0 -0
  176. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ba492422 +0 -0
  177. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bd3e6c21 +0 -0
  178. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/be9e564e +0 -0
  179. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c3993e7e +0 -0
  180. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c52ffd54 +0 -0
  181. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c7079ad4 +0 -0
  182. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c8eb01c1 +0 -0
  183. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/caee5d30 +0 -0
  184. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d0377c40 +0 -0
  185. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d262bc85 +0 -0
  186. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d287cb5c +0 -0
  187. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d716a608 +0 -0
  188. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d751012b +0 -0
  189. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e0873711 +0 -0
  190. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e1fcf77b +0 -0
  191. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e8548d8a +0 -0
  192. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eaedd71d +0 -0
  193. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eca0019e +0 -0
  194. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f7189953 +0 -0
  195. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f75cb201 +0 -0
  196. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f888164b +0 -0
  197. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fdb9eb5a +0 -0
@@ -1,8 +1,15 @@
1
+ /**
2
+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE-MIT file in the root directory of this source tree.
6
+ */
7
+
1
8
  import { Autolinking, AutolinkingConfig } from './Autolinking';
2
9
  import { NestedDirectoryJSON } from 'memfs';
3
10
  import { AbsolutePath, DescriptiveError } from '../core/';
4
11
  import { MockedLogger, MemFS } from '../io/__fixtures__';
5
- import pathUtils from "node:path"
12
+ import pathUtils from 'node:path';
6
13
 
7
14
  function createAutolinking({
8
15
  fsStructure,
@@ -91,16 +98,13 @@ it('should generate correct templates with scoped package default configuration'
91
98
 
92
99
  await runAutolinking();
93
100
 
94
- expect(
95
- memFS.readTextSync(new AbsolutePath('./harmony/oh-package.json5')).replace(/\\\\/g, '/')
96
- ).toBe(
97
- `
98
- {
99
- dependencies: {
100
- "@rnoh/rnoh--link-scoped": "file:../node_modules/@rnoh/link-scoped/harmony/link_scoped.har",
101
- },
102
- }
103
- `.trimStart()
101
+ const ohPackageContent = memFS.readTextSync(
102
+ new AbsolutePath('./harmony/oh-package.json5')
103
+ );
104
+ expect(ohPackageContent).toContain('dependencies');
105
+ expect(ohPackageContent).toContain('@rnoh/rnoh--link-scoped');
106
+ expect(ohPackageContent).toContain(
107
+ 'file:../node_modules/@rnoh/link-scoped/harmony/link_scoped.har'
104
108
  );
105
109
  expect(
106
110
  memFS.readTextSync(
@@ -323,14 +327,18 @@ it('should log updated files', async () => {
323
327
  const { logs } = await runAutolinking();
324
328
 
325
329
  const combinedLogs = logs.map((log) => log.msg).join('\n');
326
- expect(combinedLogs).toContain(pathUtils.normalize('harmony/entry/src/main/cpp/autolink.cmake'));
327
- expect(combinedLogs).toContain(pathUtils.normalize(
328
- 'harmony/entry/src/main/ets/RNOHPackageFactory.ets')
330
+ expect(combinedLogs).toContain(
331
+ pathUtils.normalize('harmony/entry/src/main/cpp/autolink.cmake')
332
+ );
333
+ expect(combinedLogs).toContain(
334
+ pathUtils.normalize('harmony/entry/src/main/ets/RNOHPackageFactory.ets')
329
335
  );
330
- expect(combinedLogs).toContain(pathUtils.normalize(
331
- 'harmony/entry/src/main/cpp/RNOHPackageFactory.h')
336
+ expect(combinedLogs).toContain(
337
+ pathUtils.normalize('harmony/entry/src/main/cpp/RNOHPackageFactory.h')
338
+ );
339
+ expect(combinedLogs).toContain(
340
+ pathUtils.normalize('harmony/oh-package.json5')
332
341
  );
333
- expect(combinedLogs).toContain(pathUtils.normalize('harmony/oh-package.json5'));
334
342
  });
335
343
 
336
344
  it('should log linked and skipped packages', async () => {
@@ -517,3 +525,48 @@ it('not delete packages with two hars', async () => {
517
525
  const ohPackageContent = memFS.readTextSync(output.ohPackagePath);
518
526
  expect(ohPackageContent).toContain('@rnoh/multiple-har');
519
527
  });
528
+
529
+ it('should preserve comments in oh-package.json5', async () => {
530
+ const { runAutolinking, memFS } = createAutolinking({
531
+ fsStructure: {
532
+ ...baseFileStructure,
533
+ node_modules: {
534
+ 'test-package': {
535
+ harmony: {
536
+ 'test_package.har': '',
537
+ },
538
+ 'package.json': JSON.stringify({
539
+ name: 'test-package',
540
+ harmony: {
541
+ autolinking: true,
542
+ },
543
+ }),
544
+ },
545
+ },
546
+ harmony: {
547
+ ...baseFileStructure.harmony,
548
+ 'oh-package.json5': `{
549
+ // This is a top-level comment
550
+ "modelVersion": "5.0.0",
551
+ "license": "ISC",
552
+ /* This is a multi-line
553
+ comment */
554
+ "dependencies": {
555
+ // Existing dependency comment
556
+ "@rnoh/react-native-openharmony/": "./react_native_openharmony",
557
+ },
558
+ }`,
559
+ },
560
+ },
561
+ });
562
+
563
+ const output = await runAutolinking();
564
+
565
+ const ohPackageContent = memFS.readTextSync(output.ohPackagePath);
566
+ // Verify comments are preserved
567
+ expect(ohPackageContent).toContain('// This is a top-level comment');
568
+ expect(ohPackageContent).toContain('/* This is a multi-line');
569
+ expect(ohPackageContent).toContain('// Existing dependency comment');
570
+ // Verify new dependency is added
571
+ expect(ohPackageContent).toContain('@rnoh/test-package');
572
+ });
@@ -1,3 +1,10 @@
1
+ /**
2
+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE-MIT file in the root directory of this source tree.
6
+ */
7
+
1
8
  import JSON5 from 'json5';
2
9
  import {
3
10
  AbsolutePath,
@@ -9,6 +16,7 @@ import Mustache from 'mustache';
9
16
  import Case from 'case';
10
17
  import { Logger } from '../io';
11
18
  import pathUtils from 'node:path';
19
+ import { JSON5Writer } from './JSON5Writer';
12
20
 
13
21
  type Version = string;
14
22
  type DependencySpecifier = `file:${string}` | Version;
@@ -299,16 +307,13 @@ export class Autolinking {
299
307
  ],
300
308
  ohPackagePathAndContent: [
301
309
  input.ohPackagePathAndContent[0],
302
- JSON5.stringify(
310
+ JSON5Writer.updateDependenciesWithFallback(
311
+ input.ohPackagePathAndContent[1],
303
312
  {
304
- ...ohPackage,
305
- dependencies: {
306
- ...unmanagedNativeDependencySpecifierByName,
307
- ...managedNativeDependencySpecifierByName,
308
- },
309
- },
310
- { space: 2, quote: '"' }
311
- ) + '\n',
313
+ ...unmanagedNativeDependencySpecifierByName,
314
+ ...managedNativeDependencySpecifierByName,
315
+ }
316
+ ),
312
317
  ],
313
318
  };
314
319
  }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE-MIT file in the root directory of this source tree.
6
+ */
7
+
8
+ import JSON5 from 'json5';
9
+
10
+ /**
11
+ * A utility class for modifying JSON5 content while preserving comments and formatting.
12
+ * Uses json5-writer's AST-based transformation to maintain the original structure.
13
+ */
14
+ export class JSON5Writer {
15
+ /**
16
+ * Updates the dependencies in a JSON5 string while preserving comments and formatting.
17
+ *
18
+ * @param content - The original JSON5 content
19
+ * @param newDependencies - The new dependencies object to set
20
+ * @returns The modified JSON5 content with preserved comments
21
+ */
22
+ static updateDependencies(content: string, newDependencies: Record<string, string>): string {
23
+ const json5Writer = require('json5-writer');
24
+
25
+ // Parse the original content to get all fields
26
+ const parsed = JSON5.parse(content);
27
+
28
+ // Create the new object with updated dependencies
29
+ const newObject = {
30
+ ...parsed,
31
+ dependencies: newDependencies,
32
+ };
33
+
34
+ // Load the original content into json5-writer to preserve comments
35
+ const writer = json5Writer.load(content);
36
+
37
+ // Write the new object, which will preserve comments
38
+ writer.write(newObject);
39
+
40
+ // Return the modified source with JSON5-style formatting
41
+ // Use double quotes for both keys and values, and trailing commas
42
+ // quoteKeys: true ensures keys with special characters (like @, /, -) are properly quoted
43
+ return writer.toSource({ quote: 'double', quoteKeys: true, trailingComma: true }) + '\n';
44
+ }
45
+
46
+ /**
47
+ * Updates dependencies with fallback to standard JSON5 stringify if preservation fails.
48
+ * This ensures backward compatibility.
49
+ *
50
+ * @param content - The original JSON5 content
51
+ * @param newDependencies - The new dependencies object to set
52
+ * @returns The modified JSON5 content
53
+ */
54
+ static updateDependenciesWithFallback(
55
+ content: string,
56
+ newDependencies: Record<string, string>
57
+ ): string {
58
+ try {
59
+ return this.updateDependencies(content, newDependencies);
60
+ } catch (error) {
61
+ // Fallback to JSON5 stringify if AST transformation fails
62
+ const parsed = JSON5.parse(content);
63
+ const result = {
64
+ ...parsed,
65
+ dependencies: newDependencies,
66
+ };
67
+ return JSON5.stringify(result, { space: 2, quote: '"' }) + '\n';
68
+ }
69
+ }
70
+ }
@@ -1 +1,8 @@
1
+ /**
2
+ * Copyright (c) 2026 Huawei Technologies Co., Ltd.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE-MIT file in the root directory of this source tree.
6
+ */
7
+
1
8
  export * from './Autolinking';
@@ -12,6 +12,15 @@ import { Logger } from '../io';
12
12
  import { DescriptiveError } from '../core';
13
13
  import { randomUUID } from 'node:crypto';
14
14
 
15
+ const ENABLE_DEBUG_LOG = process.env.RNOH_BUNDLE_DEBUG === 'true';
16
+
17
+ function debugLog(message: string) {
18
+ if (ENABLE_DEBUG_LOG) {
19
+ const timestamp = new Date().toISOString().replace('T', ' ').substring(0, 23);
20
+ console.log(`[${timestamp}] ${message}`);
21
+ }
22
+ }
23
+
15
24
  type MetroConfig = Awaited<ReturnType<typeof Metro.loadConfig>>;
16
25
 
17
26
  const HERMESC_BIN_PATH = {
@@ -144,6 +153,7 @@ export const commandBundleHarmony: Command = {
144
153
  const assets = await retrieveAssetsData(metroConfig, buildOptions);
145
154
 
146
155
  if (shouldGenerateHbcBundle) {
156
+ debugLog('Starting Hermes bytecode compilation...');
147
157
  await saveHbcBundle(
148
158
  logger,
149
159
  bundle.code,
@@ -151,11 +161,14 @@ export const commandBundleHarmony: Command = {
151
161
  args.hermescDir,
152
162
  args.hermescOptions
153
163
  );
164
+ debugLog('Hermes bytecode compilation finished');
154
165
  } else {
155
166
  await saveJSBundle(logger, bundle, bundleOutput);
156
167
  }
157
168
  maybeSaveSourceMap(logger, bundle, args.sourcemapOutput);
158
169
  await copyAssets(logger, assets, assetsDest);
170
+ debugLog('Assets copy completed, cleaning up...');
171
+ debugLog('Bundle process finished, exiting');
159
172
  } catch (err) {
160
173
  if (err instanceof DescriptiveError) {
161
174
  logger.descriptiveError(err);
@@ -215,19 +228,23 @@ async function saveHbcBundle(
215
228
  }
216
229
 
217
230
  const tmpBundlePath = `${os.tmpdir()}${pathUtils.sep}b-${randomUUID()}.harmony.js`;
231
+ debugLog('Writing temporary JS bundle...');
218
232
  await fse.writeFile(tmpBundlePath, bundleCode);
219
233
  const hbcFilePath = bundleOutput.endsWith('.hbc')
220
234
  ? bundleOutput
221
235
  : pathUtils.join(pathUtils.dirname(bundleOutput), 'hermes_bundle.hbc');
222
236
  const hermescOptionsString =
223
237
  hermescOptions?.map((e) => `-${e}`).join(' ') || '';
238
+ debugLog(`Executing hermesc compiler: ${resolvedHermescPath}`);
224
239
  execSync(
225
240
  `${resolvedHermescPath} ${hermescOptionsString} --emit-binary -out ${hbcFilePath} ${tmpBundlePath}`,
226
241
  {
227
242
  stdio: 'inherit',
228
243
  }
229
244
  );
245
+ debugLog('Hermesc execution completed, cleaning up temp file...');
230
246
  fs.unlinkSync(tmpBundlePath);
247
+ debugLog('Temp file deleted');
231
248
  logger.info((s) => `Created ${hbcFilePath}`);
232
249
  }
233
250