@react-native-oh/react-native-harmony-cli 0.77.33 → 0.77.44

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 (192) hide show
  1. package/dist/assetResolver.js +43 -74
  2. package/dist/autolinking/Autolinking.js +178 -179
  3. package/dist/codegen/core/CodegenError.js +3 -23
  4. package/dist/codegen/core/EventUtils.js +3 -3
  5. package/dist/codegen/core/TypeAnnotationToTS.js +24 -28
  6. package/dist/codegen/core/UberSchema.js +55 -97
  7. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +28 -41
  8. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +27 -34
  9. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +25 -33
  10. package/dist/codegen/generators/CppComponentCodeGenerator.js +23 -28
  11. package/dist/codegen/generators/LibGlueCodeGenerator.js +26 -29
  12. package/dist/codegen/generators/NativeModuleCodeGenerator.js +25 -30
  13. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  14. package/dist/codegen/generators/UberGeneratorV1.js +24 -23
  15. package/dist/codegen/generators/UberGeneratorV2.js +34 -35
  16. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +50 -24
  17. package/dist/codegen/templates/BasePackageHTemplate.js +120 -21
  18. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +54 -8
  19. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +75 -27
  20. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +162 -29
  21. package/dist/codegen/templates/IndexTSTemplate.js +37 -17
  22. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +119 -24
  23. package/dist/codegen/templates/TurboModuleCppTemplate.js +38 -15
  24. package/dist/codegen/templates/TurboModuleHTemplate.js +32 -11
  25. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +52 -19
  26. package/dist/commands/bundle-harmony.js +118 -221
  27. package/dist/commands/clean-harmony.js +58 -63
  28. package/dist/commands/codegen-harmony.js +105 -165
  29. package/dist/commands/codegen-lib-harmony.js +76 -116
  30. package/dist/commands/init-harmony.js +151 -196
  31. package/dist/commands/init.js +537 -961
  32. package/dist/commands/link-harmony.js +35 -82
  33. package/dist/commands/run-harmony.js +372 -518
  34. package/dist/commands/verify-package-harmony.js +54 -117
  35. package/dist/core/AbsolutePath.js +33 -49
  36. package/dist/core/CodegenConfig.js +24 -22
  37. package/dist/core/DescriptiveError.js +18 -37
  38. package/dist/core/FileSystem.js +14 -18
  39. package/dist/core/OHPackageJSON5.js +17 -23
  40. package/dist/core/PackageJSON.js +26 -42
  41. package/dist/core/ProjectDependenciesManager.js +40 -92
  42. package/dist/core/ValidationError.js +2 -22
  43. package/dist/core/fs.js +10 -7
  44. package/dist/index.js +1 -1
  45. package/dist/init/templates/AppScopeAppJSON5Template.js +21 -8
  46. package/dist/init/templates/AppScopeStringVarTemplate.js +19 -8
  47. package/dist/init/templates/EntryIndexTemplate.js +56 -8
  48. package/dist/init/templates/EntryStringVarTemplate.js +27 -8
  49. package/dist/init/templates/HvigorConfigJson5Template.js +33 -8
  50. package/dist/init/templates/MetroConfigTemplate.js +38 -8
  51. package/dist/init/templates/OhPackageJson5Template.js +28 -8
  52. package/dist/init/templates/harmony/AppScope/app.json5 +10 -0
  53. package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
  54. package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  55. package/dist/init/templates/harmony/build-profile.json5 +36 -0
  56. package/dist/init/templates/harmony/codelinter.json +32 -0
  57. package/dist/init/templates/harmony/entry/build-profile.json5 +18 -0
  58. package/dist/init/templates/harmony/entry/gitignore +7 -0
  59. package/dist/init/templates/harmony/entry/hvigorfile.ts +13 -0
  60. package/dist/init/templates/harmony/entry/oh-package.json5 +9 -0
  61. package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
  62. package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
  63. package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
  64. package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
  65. package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
  66. package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
  67. package/dist/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
  68. package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  69. package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
  70. package/dist/init/templates/harmony/entry/src/main/module.json5 +65 -0
  71. package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
  72. package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
  73. package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  74. package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  75. package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  76. package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  77. package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  78. package/dist/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
  79. package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
  80. package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
  81. package/dist/init/templates/harmony/gitignore +16 -0
  82. package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
  83. package/dist/init/templates/harmony/hvigorfile.ts +7 -0
  84. package/dist/io/CliExecutor.js +46 -98
  85. package/dist/io/Logger.js +40 -46
  86. package/dist/io/RealFS.js +43 -100
  87. package/dist/io/TarGz.js +11 -8
  88. package/dist/io/__fixtures__.js +79 -141
  89. package/dist/io/fsUtils.js +13 -12
  90. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +19 -47
  91. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +13 -41
  92. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +8 -38
  93. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +22 -54
  94. package/dist/package-verifier/verify-package.js +56 -133
  95. package/dist/simulator/LaunchSimulator.js +224 -301
  96. package/harmony/rnoh-hvigor-plugin-0.77.44.tgz +0 -0
  97. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0271b9dd +0 -0
  98. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/07ba0208 +0 -0
  99. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/082dd09d +0 -0
  100. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0a9e1b0b +0 -0
  101. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0c3d528a +0 -0
  102. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1014d3ff +0 -0
  103. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1184678c +0 -0
  104. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12621366 +0 -0
  105. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/126d3e66 +0 -0
  106. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/19262852 +0 -0
  107. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/203fac53 +0 -0
  108. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/237b660a +0 -0
  109. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2528002d +0 -0
  110. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2587d041 +0 -0
  111. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2893bd11 +0 -0
  112. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2af6ff9d +0 -0
  113. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2bf31f33 +0 -0
  114. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/333648cc +0 -0
  115. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/386f6df0 +0 -0
  116. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3b8c270e +0 -0
  117. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3bcc34ba +0 -0
  118. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/444808bd +0 -0
  119. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/44a775e2 +0 -0
  120. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/46da3ccd +0 -0
  121. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/51f80e35 +0 -0
  122. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5203a2ca +0 -0
  123. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/52795646 +0 -0
  124. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/577f8208 +0 -0
  125. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c2aafe7 +0 -0
  126. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c69bcfe +0 -0
  127. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62695b92 +0 -0
  128. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62698102 +0 -0
  129. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6411ab00 +0 -0
  130. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6569ba92 +0 -0
  131. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/65e5133c +0 -0
  132. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/66029655 +0 -0
  133. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/69e85d0d +0 -0
  134. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6afcb99e +0 -0
  135. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6de07367 +0 -0
  136. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/72498307 +0 -0
  137. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7babd1de +0 -0
  138. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7fe56d21 +0 -0
  139. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/810cbd72 +0 -0
  140. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/812386d2 +0 -0
  141. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8448897d +0 -0
  142. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/84ab0a41 +0 -0
  143. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/853825e2 +0 -0
  144. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/862ad93a +0 -0
  145. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/86b14da6 +0 -0
  146. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/87f0fe62 +0 -0
  147. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/88ee8f74 +0 -0
  148. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c5237c9 +0 -0
  149. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c725800 +0 -0
  150. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8e83cbe1 +0 -0
  151. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8f4085b9 +0 -0
  152. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/931f0b2e +0 -0
  153. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/940c8f92 +0 -0
  154. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/968191a3 +0 -0
  155. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/970780c0 +0 -0
  156. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/98bc4394 +0 -0
  157. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/99a3b0b0 +0 -0
  158. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9c0ffa6b +0 -0
  159. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9d9b42c2 +0 -0
  160. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a04266ef +0 -0
  161. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a18f78c5 +0 -0
  162. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a642fb0e +0 -0
  163. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a97edf40 +0 -0
  164. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/aa672a20 +0 -0
  165. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ae25c61a +0 -0
  166. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b2bebae6 +0 -0
  167. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ba492422 +0 -0
  168. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bd3e6c21 +0 -0
  169. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/be9e564e +0 -0
  170. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c342b18e +0 -0
  171. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c3993e7e +0 -0
  172. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c52ffd54 +0 -0
  173. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c7079ad4 +0 -0
  174. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c8eb01c1 +0 -0
  175. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/caee5d30 +0 -0
  176. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cf039161 +0 -0
  177. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d0377c40 +0 -0
  178. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d262bc85 +0 -0
  179. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d287cb5c +0 -0
  180. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d64bff57 +0 -0
  181. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d716a608 +0 -0
  182. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d751012b +0 -0
  183. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e0873711 +0 -0
  184. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e1fcf77b +0 -0
  185. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e8548d8a +0 -0
  186. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eaedd71d +0 -0
  187. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eca0019e +0 -0
  188. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f7189953 +0 -0
  189. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f75cb201 +0 -0
  190. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f888164b +0 -0
  191. package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fdb9eb5a +0 -0
  192. package/package.json +5 -1
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,42 +31,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
32
  });
10
33
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
36
  };
38
37
  Object.defineProperty(exports, "__esModule", { value: true });
39
38
  exports.commandCleanHarmony = void 0;
40
- var core_1 = require("../core");
41
- var json5_1 = require("json5");
42
- var node_fs_1 = require("node:fs");
43
- var node_path_1 = require("node:path");
44
- var node_os_1 = require("node:os");
45
- var crypto = require("node:crypto");
46
- var COMMAND_NAME = 'clean-harmony';
39
+ const core_1 = require("../core");
40
+ const json5_1 = __importDefault(require("json5"));
41
+ const node_fs_1 = __importDefault(require("node:fs"));
42
+ const node_path_1 = __importDefault(require("node:path"));
43
+ const node_os_1 = __importDefault(require("node:os"));
44
+ const crypto = __importStar(require("node:crypto"));
45
+ const COMMAND_NAME = 'clean-harmony';
47
46
  exports.commandCleanHarmony = {
48
47
  name: COMMAND_NAME,
49
48
  description: 'Remove cached files in the OpenHarmony project.',
@@ -54,36 +53,32 @@ exports.commandCleanHarmony = {
54
53
  default: "./harmony"
55
54
  }
56
55
  ],
57
- func: function (_argv, _config, rawArgs) { return __awaiter(void 0, void 0, void 0, function () {
58
- var harmonyProjectPath, md5Path, hvigorCachePath, buildProfilePath, buildProfileContent, buildProfile;
59
- return __generator(this, function (_a) {
60
- harmonyProjectPath = new core_1.AbsolutePath(rawArgs.harmonyProjectPath);
61
- md5Path = crypto.createHash("md5").update(harmonyProjectPath.getValue()).digest("hex");
62
- hvigorCachePath = new core_1.AbsolutePath(node_path_1.default.join(node_os_1.default.homedir(), ".hvigor", "project_caches", md5Path));
63
- if (node_fs_1.default.existsSync(hvigorCachePath.getValue())) {
64
- node_fs_1.default.rmSync(hvigorCachePath.getValue(), { recursive: true, force: true });
65
- }
66
- buildProfilePath = harmonyProjectPath.copyWithNewSegment('build-profile.json5');
67
- buildProfileContent = (0, core_1.maybeReadFile)(buildProfilePath);
68
- if (buildProfileContent) {
69
- buildProfile = json5_1.default.parse(buildProfileContent);
70
- if (Array.isArray(buildProfile.modules)) {
71
- buildProfile.modules.forEach(function (module) {
72
- if (module && module.srcPath) {
73
- var modulePath = harmonyProjectPath.copyWithNewSegment(module.srcPath);
74
- var cxxPath = modulePath.copyWithNewSegment('.cxx');
75
- var buildPath = modulePath.copyWithNewSegment('build');
76
- if (node_fs_1.default.existsSync(cxxPath.getValue())) {
77
- node_fs_1.default.rmSync(cxxPath.getValue(), { recursive: true, force: true });
78
- }
79
- if (node_fs_1.default.existsSync(buildPath.getValue())) {
80
- node_fs_1.default.rmSync(buildPath.getValue(), { recursive: true, force: true });
81
- }
56
+ func: (_argv, _config, rawArgs) => __awaiter(void 0, void 0, void 0, function* () {
57
+ const harmonyProjectPath = new core_1.AbsolutePath(rawArgs.harmonyProjectPath);
58
+ const md5Path = crypto.createHash("md5").update(harmonyProjectPath.getValue()).digest("hex");
59
+ const hvigorCachePath = new core_1.AbsolutePath(node_path_1.default.join(node_os_1.default.homedir(), ".hvigor", "project_caches", md5Path));
60
+ if (node_fs_1.default.existsSync(hvigorCachePath.getValue())) {
61
+ node_fs_1.default.rmSync(hvigorCachePath.getValue(), { recursive: true, force: true });
62
+ }
63
+ const buildProfilePath = harmonyProjectPath.copyWithNewSegment('build-profile.json5');
64
+ const buildProfileContent = (0, core_1.maybeReadFile)(buildProfilePath);
65
+ if (buildProfileContent) {
66
+ const buildProfile = json5_1.default.parse(buildProfileContent);
67
+ if (Array.isArray(buildProfile.modules)) {
68
+ buildProfile.modules.forEach((module) => {
69
+ if (module && module.srcPath) {
70
+ const modulePath = harmonyProjectPath.copyWithNewSegment(module.srcPath);
71
+ const cxxPath = modulePath.copyWithNewSegment('.cxx');
72
+ const buildPath = modulePath.copyWithNewSegment('build');
73
+ if (node_fs_1.default.existsSync(cxxPath.getValue())) {
74
+ node_fs_1.default.rmSync(cxxPath.getValue(), { recursive: true, force: true });
82
75
  }
83
- });
84
- }
76
+ if (node_fs_1.default.existsSync(buildPath.getValue())) {
77
+ node_fs_1.default.rmSync(buildPath.getValue(), { recursive: true, force: true });
78
+ }
79
+ }
80
+ });
85
81
  }
86
- return [2 /*return*/];
87
- });
88
- }); }
82
+ }
83
+ })
89
84
  };
@@ -8,49 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
39
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
40
- if (ar || !(i in from)) {
41
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
42
- ar[i] = from[i];
43
- }
44
- }
45
- return to.concat(ar || Array.prototype.slice.call(from));
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
13
  };
47
14
  Object.defineProperty(exports, "__esModule", { value: true });
48
15
  exports.commandCodegenHarmony = void 0;
49
- var node_path_1 = require("node:path");
50
- var case_1 = require("case");
51
- var core_1 = require("../core");
52
- var codegen_1 = require("../codegen");
53
- var io_1 = require("../io");
16
+ const node_path_1 = __importDefault(require("node:path"));
17
+ const case_1 = __importDefault(require("case"));
18
+ const core_1 = require("../core");
19
+ const codegen_1 = require("../codegen");
20
+ const io_1 = require("../io");
54
21
  exports.commandCodegenHarmony = {
55
22
  name: 'codegen-harmony',
56
23
  description: 'Generates boilerplate, types, and utilities from Turbo Module and Fabric Component specifications. This command is meant to be executed during the application build process.',
@@ -83,88 +50,73 @@ exports.commandCodegenHarmony = {
83
50
  description: 'Skips the check that prevents file operations outside the current working directory. This command permanently deletes previously generated files. Files are generated in the path specified by cpp-output-path.',
84
51
  },
85
52
  ],
86
- func: function (_argv, _config, args) { return __awaiter(void 0, void 0, void 0, function () {
87
- var logger, fs, MAX_SUPPORTED_CODEGEN_VERSION_1, etsOutputPath, isEndWithGenerated, enableSafetyCheck, cppOutputPath, projectRootPath, uberSchemaFromArkTSLibraries, cApiLibrariesData, codegenNoticeLines, uberGeneratorV1, uberGeneratorV2, glueCodeGenerator, fileContentByPath_1, appendToFileContentByPath, uberSchema_1, err_1;
88
- return __generator(this, function (_a) {
89
- switch (_a.label) {
90
- case 0:
91
- logger = new io_1.Logger();
92
- fs = new io_1.RealFS();
93
- _a.label = 1;
94
- case 1:
95
- _a.trys.push([1, 6, , 7]);
96
- MAX_SUPPORTED_CODEGEN_VERSION_1 = 2;
97
- // prepare the input data
98
- validateArgs(args);
99
- etsOutputPath = args.etsOutputPath || args.rnohModulePath;
100
- isEndWithGenerated = /\/generated\/?$/.test(etsOutputPath);
101
- etsOutputPath = new core_1.AbsolutePath(etsOutputPath);
102
- if (!isEndWithGenerated) {
103
- etsOutputPath = etsOutputPath.copyWithNewSegment('generated');
104
- }
105
- enableSafetyCheck = args.safetyCheck;
106
- cppOutputPath = new core_1.AbsolutePath(args.cppOutputPath);
107
- projectRootPath = new core_1.AbsolutePath(args.projectRootPath);
108
- return [4 /*yield*/, codegen_1.UberSchema.fromProject(fs, projectRootPath, function (codegenVersion, packageName) {
109
- throwErrorIfUnsupportedCodegenVersion(codegenVersion, MAX_SUPPORTED_CODEGEN_VERSION_1, packageName);
110
- return codegenVersion === 1;
111
- })];
112
- case 2:
113
- uberSchemaFromArkTSLibraries = _a.sent();
114
- return [4 /*yield*/, collectLibrariesData(fs, projectRootPath, function (codegenVersion, packageName) {
115
- throwErrorIfUnsupportedCodegenVersion(codegenVersion, MAX_SUPPORTED_CODEGEN_VERSION_1, packageName);
116
- return codegenVersion === 2;
117
- })];
118
- case 3:
119
- cApiLibrariesData = _a.sent();
120
- codegenNoticeLines = [
121
- 'This code was generated by "react-native codegen-harmony"',
122
- '',
123
- 'Do not edit this file as changes may cause incorrect behavior and will be',
124
- 'lost once the code is regenerated.',
125
- ];
126
- uberGeneratorV1 = new codegen_1.UberGeneratorV1(cppOutputPath, etsOutputPath, __spreadArray(__spreadArray([], codegenNoticeLines, true), ['', '@generatorVersion: 1'], false));
127
- uberGeneratorV2 = new codegen_1.UberGeneratorV2(cppOutputPath, etsOutputPath, __spreadArray(__spreadArray([], codegenNoticeLines, true), ['', '@generatorVersion: 2'], false));
128
- glueCodeGenerator = new codegen_1.AppBuildTimeGlueCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines);
129
- fileContentByPath_1 = new Map();
130
- appendToFileContentByPath = function (fileContent, path) {
131
- fileContentByPath_1.set(path, fileContent);
132
- };
133
- uberGeneratorV1
134
- .generate(uberSchemaFromArkTSLibraries)
135
- .forEach(appendToFileContentByPath);
136
- uberGeneratorV2
137
- .generate(cApiLibrariesData)
138
- .forEach(appendToFileContentByPath);
139
- glueCodeGenerator
140
- .generate({
141
- v1: uberGeneratorV1.getGlueCodeData(),
142
- v2: uberGeneratorV2.getGlueCodeData(),
143
- })
144
- .forEach(appendToFileContentByPath);
145
- if (!args.debug) return [3 /*break*/, 5];
146
- return [4 /*yield*/, codegen_1.UberSchema.fromProject(fs, projectRootPath)];
147
- case 4:
148
- uberSchema_1 = _a.sent();
149
- logger.debug(function (styles) {
150
- return styles.gray(JSON.stringify(uberSchema_1.getValue(), null, 2));
151
- });
152
- _a.label = 5;
153
- case 5:
154
- saveCodegenResult(fs, fileContentByPath_1, cppOutputPath, etsOutputPath, enableSafetyCheck);
155
- logCodegenResult(logger, fileContentByPath_1, projectRootPath);
156
- return [3 /*break*/, 7];
157
- case 6:
158
- err_1 = _a.sent();
159
- if (err_1 instanceof core_1.DescriptiveError) {
160
- logger.descriptiveError(err_1);
161
- process.exit(1);
162
- }
163
- throw err_1;
164
- case 7: return [2 /*return*/];
53
+ func: (_argv, _config, args) => __awaiter(void 0, void 0, void 0, function* () {
54
+ const logger = new io_1.Logger();
55
+ const fs = new io_1.RealFS();
56
+ try {
57
+ const MAX_SUPPORTED_CODEGEN_VERSION = 2;
58
+ // prepare the input data
59
+ validateArgs(args);
60
+ let etsOutputPath = args.etsOutputPath || args.rnohModulePath;
61
+ const isEndWithGenerated = /\/generated\/?$/.test(etsOutputPath);
62
+ etsOutputPath = new core_1.AbsolutePath(etsOutputPath);
63
+ if (!isEndWithGenerated) {
64
+ etsOutputPath = etsOutputPath.copyWithNewSegment('generated');
165
65
  }
166
- });
167
- }); },
66
+ const enableSafetyCheck = args.safetyCheck;
67
+ const cppOutputPath = new core_1.AbsolutePath(args.cppOutputPath);
68
+ const projectRootPath = new core_1.AbsolutePath(args.projectRootPath);
69
+ const uberSchemaFromArkTSLibraries = yield codegen_1.UberSchema.fromProject(fs, projectRootPath, (codegenVersion, packageName) => {
70
+ throwErrorIfUnsupportedCodegenVersion(codegenVersion, MAX_SUPPORTED_CODEGEN_VERSION, packageName);
71
+ return codegenVersion === 1;
72
+ });
73
+ const cApiLibrariesData = yield collectLibrariesData(fs, projectRootPath, (codegenVersion, packageName) => {
74
+ throwErrorIfUnsupportedCodegenVersion(codegenVersion, MAX_SUPPORTED_CODEGEN_VERSION, packageName);
75
+ return codegenVersion === 2;
76
+ });
77
+ // instantiate objects
78
+ const codegenNoticeLines = [
79
+ 'This code was generated by "react-native codegen-harmony"',
80
+ '',
81
+ 'Do not edit this file as changes may cause incorrect behavior and will be',
82
+ 'lost once the code is regenerated.',
83
+ ];
84
+ const uberGeneratorV1 = new codegen_1.UberGeneratorV1(cppOutputPath, etsOutputPath, [...codegenNoticeLines, '', '@generatorVersion: 1']);
85
+ const uberGeneratorV2 = new codegen_1.UberGeneratorV2(cppOutputPath, etsOutputPath, [...codegenNoticeLines, '', '@generatorVersion: 2']);
86
+ const glueCodeGenerator = new codegen_1.AppBuildTimeGlueCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines);
87
+ // generate the code
88
+ const fileContentByPath = new Map();
89
+ const appendToFileContentByPath = (fileContent, path) => {
90
+ fileContentByPath.set(path, fileContent);
91
+ };
92
+ uberGeneratorV1
93
+ .generate(uberSchemaFromArkTSLibraries)
94
+ .forEach(appendToFileContentByPath);
95
+ uberGeneratorV2
96
+ .generate(cApiLibrariesData)
97
+ .forEach(appendToFileContentByPath);
98
+ glueCodeGenerator
99
+ .generate({
100
+ v1: uberGeneratorV1.getGlueCodeData(),
101
+ v2: uberGeneratorV2.getGlueCodeData(),
102
+ })
103
+ .forEach(appendToFileContentByPath);
104
+ // output the results
105
+ if (args.debug) {
106
+ const uberSchema = yield codegen_1.UberSchema.fromProject(fs, projectRootPath);
107
+ logger.debug((styles) => styles.gray(JSON.stringify(uberSchema.getValue(), null, 2)));
108
+ }
109
+ saveCodegenResult(fs, fileContentByPath, cppOutputPath, etsOutputPath, enableSafetyCheck);
110
+ logCodegenResult(logger, fileContentByPath, projectRootPath);
111
+ }
112
+ catch (err) {
113
+ if (err instanceof core_1.DescriptiveError) {
114
+ logger.descriptiveError(err);
115
+ process.exit(1);
116
+ }
117
+ throw err;
118
+ }
119
+ }),
168
120
  };
169
121
  function validateArgs(args) {
170
122
  if (!args.rnohModulePath && !args.etsOutputPath) {
@@ -179,45 +131,35 @@ function validateArgs(args) {
179
131
  }
180
132
  }
181
133
  function collectLibrariesData(fs, projectRootPath, onShouldAcceptCodegenConfig) {
182
- return __awaiter(this, void 0, void 0, function () {
183
- var packageJSONs, results, _i, packageJSONs_1, packageJSON, codegenConfigs, _a, codegenConfigs_1, codegenConfig;
184
- return __generator(this, function (_b) {
185
- switch (_b.label) {
186
- case 0:
187
- packageJSONs = [
188
- core_1.PackageJSON.fromProjectRootPath(fs, projectRootPath, projectRootPath),
189
- ];
190
- return [4 /*yield*/, new core_1.ProjectDependenciesManager(fs, projectRootPath).forEachAsync(function (dependency) {
191
- packageJSONs.push(dependency.readPackageJSON());
192
- })];
193
- case 1:
194
- _b.sent();
195
- results = [];
196
- for (_i = 0, packageJSONs_1 = packageJSONs; _i < packageJSONs_1.length; _i++) {
197
- packageJSON = packageJSONs_1[_i];
198
- codegenConfigs = packageJSON.getCodegenConfigs();
199
- for (_a = 0, codegenConfigs_1 = codegenConfigs; _a < codegenConfigs_1.length; _a++) {
200
- codegenConfig = codegenConfigs_1[_a];
201
- if (codegenConfig &&
202
- onShouldAcceptCodegenConfig(codegenConfig.getVersion(), packageJSON.name)) {
203
- results.push({
204
- libraryCppName: deriveCppDirectoryNameFromNpmPackageName(packageJSON.name),
205
- uberSchema: codegen_1.UberSchema.fromCodegenConfig(codegenConfig),
206
- });
207
- }
208
- }
209
- }
210
- return [2 /*return*/, results];
211
- }
134
+ return __awaiter(this, void 0, void 0, function* () {
135
+ const packageJSONs = [
136
+ core_1.PackageJSON.fromProjectRootPath(fs, projectRootPath, projectRootPath),
137
+ ];
138
+ yield new core_1.ProjectDependenciesManager(fs, projectRootPath).forEachAsync((dependency) => {
139
+ packageJSONs.push(dependency.readPackageJSON());
212
140
  });
141
+ const results = [];
142
+ for (const packageJSON of packageJSONs) {
143
+ const codegenConfigs = packageJSON.getCodegenConfigs();
144
+ for (const codegenConfig of codegenConfigs) {
145
+ if (codegenConfig &&
146
+ onShouldAcceptCodegenConfig(codegenConfig.getVersion(), packageJSON.name)) {
147
+ results.push({
148
+ libraryCppName: deriveCppDirectoryNameFromNpmPackageName(packageJSON.name),
149
+ uberSchema: codegen_1.UberSchema.fromCodegenConfig(codegenConfig),
150
+ });
151
+ }
152
+ }
153
+ }
154
+ return results;
213
155
  });
214
156
  }
215
157
  function throwErrorIfUnsupportedCodegenVersion(codegenVersion, maxSupportedCodegenVersion, packageName) {
216
158
  if (codegenVersion > maxSupportedCodegenVersion) {
217
159
  throw new codegen_1.CodegenError({
218
- whatHappened: "Package \"".concat(packageName, "\" requires codegenVersion: ").concat(codegenVersion, ", which is not supported (maxSupportedCodegenVersion=").concat(maxSupportedCodegenVersion, ")."),
160
+ whatHappened: `Package "${packageName}" requires codegenVersion: ${codegenVersion}, which is not supported (maxSupportedCodegenVersion=${maxSupportedCodegenVersion}).`,
219
161
  whatCanUserDo: [
220
- "Try downgrading \"".concat(packageName, "\"."),
162
+ `Try downgrading "${packageName}".`,
221
163
  'Update the "@react-native-oh/react-native-harmony-cli" package.',
222
164
  ],
223
165
  });
@@ -228,10 +170,10 @@ function saveCodegenResult(fs, fileContentByPath, cppOutputPath, etsOutputPath,
228
170
  prepareDirectory(etsOutputPath, enableSafetyCheck);
229
171
  prepareDirectory(etsOutputPath.copyWithNewSegment('components'), enableSafetyCheck);
230
172
  prepareDirectory(etsOutputPath.copyWithNewSegment('turboModules'), enableSafetyCheck);
231
- fileContentByPath.forEach(function (_fileContent, path) {
173
+ fileContentByPath.forEach((_fileContent, path) => {
232
174
  prepareDirectory(path.getDirectoryPath(), enableSafetyCheck);
233
175
  });
234
- fileContentByPath.forEach(function (fileContent, path) {
176
+ fileContentByPath.forEach((fileContent, path) => {
235
177
  fs.writeTextSync(path, fileContent);
236
178
  });
237
179
  }
@@ -239,26 +181,24 @@ function prepareDirectory(path, enableSafetyCheck) {
239
181
  (0, core_1.maybeMakeDirectories)(path);
240
182
  if (enableSafetyCheck && !path.getValue().startsWith(process.cwd())) {
241
183
  throw new core_1.DescriptiveError({
242
- whatHappened: "Tried to remove files in ".concat(path.getValue(), "\nand that path is outside current working directory"),
184
+ whatHappened: `Tried to remove files in ${path.getValue()}\nand that path is outside current working directory`,
243
185
  whatCanUserDo: ['Run codegen from different location'],
244
186
  });
245
187
  }
246
188
  (0, core_1.maybeRemoveFilesInDirectory)(path);
247
189
  }
248
190
  function logCodegenResult(logger, fileContentByPath, projectRootPath) {
249
- var sortedRelativePathStrings = Array.from(fileContentByPath.keys()).map(function (path) { return node_path_1.default.relative(projectRootPath.getValue(), path.getValue()); });
191
+ const sortedRelativePathStrings = Array.from(fileContentByPath.keys()).map((path) => node_path_1.default.relative(projectRootPath.getValue(), path.getValue()));
250
192
  sortedRelativePathStrings.sort();
251
- sortedRelativePathStrings.forEach(function (pathStr) {
252
- logger.debug(function (styles) { return styles.gray("\u2022 ".concat(pathStr)); });
253
- });
254
- logger.debug(function () { return ''; });
255
- logger.info(function (styles) {
256
- return "Generated ".concat(styles.green(styles.bold(fileContentByPath.size)), " file(s)");
193
+ sortedRelativePathStrings.forEach((pathStr) => {
194
+ logger.debug((styles) => styles.gray(`• ${pathStr}`));
257
195
  });
258
- logger.debug(function () { return ''; });
196
+ logger.debug(() => '');
197
+ logger.info((styles) => `Generated ${styles.green(styles.bold(fileContentByPath.size))} file(s)`);
198
+ logger.debug(() => '');
259
199
  }
260
200
  function deriveCppDirectoryNameFromNpmPackageName(npmPackageName) {
261
- var result = npmPackageName;
201
+ let result = npmPackageName;
262
202
  if (npmPackageName.includes('/')) {
263
203
  result.replace('@', '');
264
204
  result = npmPackageName.replace('/', '__');