@react-native-oh/react-native-harmony-cli 0.0.30 → 0.77.18-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 (235) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -4
  3. package/dist/assetResolver.js +105 -10
  4. package/dist/autolinking/Autolinking.js +21 -26
  5. package/dist/autolinking/index.js +0 -6
  6. package/dist/codegen/core/CodeGenerator.js +0 -6
  7. package/dist/codegen/core/CodegenError.js +0 -6
  8. package/dist/codegen/core/EventUtils.js +4 -13
  9. package/dist/codegen/core/TypeAnnotationToTS.js +3 -9
  10. package/dist/codegen/core/UberSchema.js +8 -21
  11. package/dist/codegen/core/index.js +0 -6
  12. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +2 -7
  13. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +3 -6
  14. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +3 -6
  15. package/dist/codegen/generators/CppComponentCodeGenerator.js +3 -6
  16. package/dist/codegen/generators/LibGlueCodeGenerator.js +2 -8
  17. package/dist/codegen/generators/NativeModuleCodeGenerator.js +1 -7
  18. package/dist/codegen/generators/SharedComponentCodeGenerator.js +0 -6
  19. package/dist/codegen/generators/UberGeneratorV1.js +0 -6
  20. package/dist/codegen/generators/UberGeneratorV2.js +0 -6
  21. package/dist/codegen/generators/index.js +0 -6
  22. package/dist/codegen/index.js +0 -6
  23. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +0 -6
  24. package/dist/codegen/templates/BasePackageHTemplate.js +12 -7
  25. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +1 -6
  26. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +15 -6
  27. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +0 -6
  28. package/dist/codegen/templates/IndexTSTemplate.js +0 -6
  29. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +12 -7
  30. package/dist/codegen/templates/TurboModuleCppTemplate.js +0 -6
  31. package/dist/codegen/templates/TurboModuleHTemplate.js +0 -6
  32. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +0 -6
  33. package/dist/codegen/templates/index.js +0 -6
  34. package/dist/commands/bundle-harmony.js +133 -101
  35. package/dist/commands/clean-harmony.js +84 -0
  36. package/dist/commands/codegen-harmony.js +12 -22
  37. package/dist/commands/codegen-lib-harmony.js +15 -25
  38. package/dist/commands/index.js +3 -9
  39. package/dist/commands/init-harmony.js +226 -0
  40. package/dist/commands/init.js +703 -0
  41. package/dist/commands/link-harmony.js +12 -16
  42. package/dist/commands/run-harmony.js +438 -0
  43. package/dist/commands/types.js +2 -0
  44. package/dist/commands/verify-package-harmony.js +7 -11
  45. package/dist/core/AbsolutePath.js +3 -6
  46. package/dist/core/CodegenConfig.js +3 -11
  47. package/dist/core/DescriptiveError.js +7 -9
  48. package/dist/core/FileSystem.js +0 -6
  49. package/dist/core/OHPackageJSON5.js +0 -6
  50. package/dist/core/PackageJSON.js +4 -7
  51. package/dist/core/ProjectDependenciesManager.js +6 -14
  52. package/dist/core/ValidationError.js +0 -6
  53. package/dist/core/ValueObject.js +0 -6
  54. package/dist/core/fs.js +16 -10
  55. package/dist/core/index.js +0 -6
  56. package/dist/index.js +3 -9
  57. package/dist/init/templates/AppScopeAppJSON5Template.js +30 -0
  58. package/dist/init/templates/AppScopeStringVarTemplate.js +28 -0
  59. package/dist/init/templates/EntryIndexTemplate.js +65 -0
  60. package/dist/init/templates/EntryStringVarTemplate.js +38 -0
  61. package/dist/init/templates/HvigorConfigJson5Template.js +44 -0
  62. package/dist/init/templates/MetroConfigTemplate.js +47 -0
  63. package/dist/init/templates/OhPackageJson5Template.js +37 -0
  64. package/dist/init/templates/harmony/AppScope/app.json5 +10 -0
  65. package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
  66. package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  67. package/dist/init/templates/harmony/build-profile.json5 +36 -0
  68. package/dist/init/templates/harmony/codelinter.json +32 -0
  69. package/dist/init/templates/harmony/entry/build-profile.json5 +18 -0
  70. package/dist/init/templates/harmony/entry/gitignore +7 -0
  71. package/dist/init/templates/harmony/entry/hvigorfile.ts +13 -0
  72. package/dist/init/templates/harmony/entry/oh-package.json5 +9 -0
  73. package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
  74. package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
  75. package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
  76. package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
  77. package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
  78. package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
  79. package/dist/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
  80. package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  81. package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
  82. package/dist/init/templates/harmony/entry/src/main/module.json5 +58 -0
  83. package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
  84. package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
  85. package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  86. package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  87. package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  88. package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  89. package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  90. package/dist/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
  91. package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
  92. package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
  93. package/dist/init/templates/harmony/gitignore +16 -0
  94. package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
  95. package/dist/init/templates/harmony/hvigorfile.ts +7 -0
  96. package/dist/init/templates/index.js +21 -0
  97. package/dist/io/CliExecutor.js +56 -29
  98. package/dist/io/Logger.js +71 -47
  99. package/dist/io/RealFS.js +10 -6
  100. package/dist/io/TarGz.js +3 -10
  101. package/dist/io/__fixtures__.js +8 -8
  102. package/dist/io/fsUtils.js +1 -8
  103. package/dist/io/index.js +1 -6
  104. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +1 -8
  105. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +1 -8
  106. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +1 -8
  107. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +1 -8
  108. package/dist/package-verifier/checks/index.js +0 -6
  109. package/dist/package-verifier/index.js +0 -6
  110. package/dist/package-verifier/types.js +0 -6
  111. package/dist/package-verifier/verify-package.js +5 -14
  112. package/harmony/rnoh-hvigor-plugin-0.77.18.tgz +0 -0
  113. package/jest.config.js +0 -7
  114. package/package.json +20 -16
  115. package/react-native.config.js +0 -7
  116. package/scripts/copy-template.js +18 -0
  117. package/src/assetResolver.ts +117 -11
  118. package/src/autolinking/Autolinking.test.ts +54 -18
  119. package/src/autolinking/Autolinking.ts +32 -31
  120. package/src/autolinking/index.ts +1 -8
  121. package/src/codegen/core/CodeGenerator.ts +0 -7
  122. package/src/codegen/core/CodegenError.ts +0 -7
  123. package/src/codegen/core/EventUtils.ts +3 -12
  124. package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -7
  125. package/src/codegen/core/TypeAnnotationToTS.ts +3 -8
  126. package/src/codegen/core/UberSchema.ts +9 -22
  127. package/src/codegen/core/index.ts +0 -7
  128. package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +5 -8
  129. package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +3 -7
  130. package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +3 -7
  131. package/src/codegen/generators/CppComponentCodeGenerator.ts +3 -7
  132. package/src/codegen/generators/LibGlueCodeGenerator.ts +2 -9
  133. package/src/codegen/generators/NativeModuleCodeGenerator.ts +1 -8
  134. package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -7
  135. package/src/codegen/generators/UberGeneratorV1.ts +0 -7
  136. package/src/codegen/generators/UberGeneratorV2.ts +0 -7
  137. package/src/codegen/generators/index.ts +0 -7
  138. package/src/codegen/index.ts +0 -7
  139. package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -7
  140. package/src/codegen/templates/BasePackageHTemplate.ts +13 -8
  141. package/src/codegen/templates/ComponentDescriptorHTemplate.ts +1 -7
  142. package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +24 -8
  143. package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -7
  144. package/src/codegen/templates/IndexTSTemplate.ts +0 -7
  145. package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +13 -8
  146. package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -7
  147. package/src/codegen/templates/TurboModuleHTemplate.ts +0 -7
  148. package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -7
  149. package/src/codegen/templates/index.ts +0 -7
  150. package/src/commands/bundle-harmony.ts +178 -118
  151. package/src/commands/clean-harmony.ts +54 -0
  152. package/src/commands/codegen-harmony.ts +13 -25
  153. package/src/commands/codegen-lib-harmony.ts +16 -28
  154. package/src/commands/index.ts +3 -10
  155. package/src/commands/init-harmony.ts +299 -0
  156. package/src/commands/init.ts +755 -0
  157. package/src/commands/link-harmony.ts +14 -19
  158. package/src/commands/run-harmony.ts +478 -0
  159. package/src/commands/types.ts +14 -0
  160. package/src/commands/verify-package-harmony.ts +9 -12
  161. package/src/core/AbsolutePath.ts +4 -7
  162. package/src/core/CodegenConfig.ts +3 -12
  163. package/src/core/DescriptiveError.ts +8 -15
  164. package/src/core/FileSystem.ts +5 -8
  165. package/src/core/OHPackageJSON5.ts +0 -7
  166. package/src/core/PackageJSON.ts +4 -13
  167. package/src/core/ProjectDependenciesManager.ts +14 -22
  168. package/src/core/ValidationError.ts +0 -7
  169. package/src/core/ValueObject.ts +0 -7
  170. package/src/core/fs.ts +14 -8
  171. package/src/core/index.ts +0 -7
  172. package/src/index.ts +8 -15
  173. package/src/init/templates/AppScopeAppJSON5Template.ts +24 -0
  174. package/src/init/templates/AppScopeStringVarTemplate.ts +22 -0
  175. package/src/init/templates/EntryIndexTemplate.ts +59 -0
  176. package/src/init/templates/EntryStringVarTemplate.ts +31 -0
  177. package/src/init/templates/HvigorConfigJson5Template.ts +40 -0
  178. package/src/init/templates/MetroConfigTemplate.ts +41 -0
  179. package/src/init/templates/OhPackageJson5Template.ts +31 -0
  180. package/src/init/templates/harmony/AppScope/app.json5 +10 -0
  181. package/src/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
  182. package/src/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  183. package/src/init/templates/harmony/build-profile.json5 +36 -0
  184. package/src/init/templates/harmony/codelinter.json +32 -0
  185. package/src/init/templates/harmony/entry/build-profile.json5 +18 -0
  186. package/src/init/templates/harmony/entry/gitignore +7 -0
  187. package/src/init/templates/harmony/entry/hvigorfile.ts +13 -0
  188. package/src/init/templates/harmony/entry/oh-package.json5 +9 -0
  189. package/src/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
  190. package/src/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
  191. package/src/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
  192. package/src/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
  193. package/src/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
  194. package/src/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
  195. package/src/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
  196. package/src/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  197. package/src/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
  198. package/src/init/templates/harmony/entry/src/main/module.json5 +58 -0
  199. package/src/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
  200. package/src/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
  201. package/src/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  202. package/src/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  203. package/src/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  204. package/src/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  205. package/src/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  206. package/src/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
  207. package/src/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
  208. package/src/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
  209. package/src/init/templates/harmony/gitignore +16 -0
  210. package/src/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
  211. package/src/init/templates/harmony/hvigorfile.ts +7 -0
  212. package/src/init/templates/index.ts +5 -0
  213. package/src/io/CliExecutor.ts +55 -40
  214. package/src/io/Logger.ts +77 -51
  215. package/src/io/RealFS.ts +15 -8
  216. package/src/io/TarGz.ts +1 -8
  217. package/src/io/__fixtures__.ts +15 -18
  218. package/src/io/fsUtils.ts +1 -7
  219. package/src/io/index.ts +1 -7
  220. package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -7
  221. package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -7
  222. package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -7
  223. package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -7
  224. package/src/package-verifier/checks/index.ts +0 -7
  225. package/src/package-verifier/index.ts +0 -7
  226. package/src/package-verifier/types.ts +0 -7
  227. package/src/package-verifier/verify-package.ts +4 -13
  228. package/tsconfig.build.json +2 -5
  229. package/tsconfig.json +4 -0
  230. package/dist/commands/create-metro-host-constants.js +0 -67
  231. package/dist/commands/pack-harmony.js +0 -106
  232. package/dist/commands/unpack-harmony.js +0 -191
  233. package/src/commands/create-metro-host-constants.ts +0 -55
  234. package/src/commands/pack-harmony.ts +0 -128
  235. package/src/commands/unpack-harmony.ts +0 -240
@@ -0,0 +1,11 @@
1
+ import {RNAbility} from '@rnoh/react-native-openharmony';
2
+
3
+ export default class EntryAbility extends RNAbility {
4
+ override getPagePath() {
5
+ return 'pages/Index';
6
+ }
7
+
8
+ override getRNOHWorkerScriptUrl() {
9
+ return "entry/ets/workers/RNOHWorker.ets"
10
+ }
11
+ }
@@ -0,0 +1 @@
1
+ /RNOHPackagesFactory.ets
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Importing some ets files in the following way results in runtime errors e.g.
3
+ * import { setupRNOHWorker } from "@rnoh/react-native-openharmony"
4
+ *
5
+ * It looks like this is ArkTS problem and it may be fixed in the future.
6
+ * For the time being, use direct imports.
7
+ */
8
+ import { setupRNOHWorker } from "@rnoh/react-native-openharmony/src/main/ets/setupRNOHWorker"
9
+ import { getRNOHPackages } from "../PackageProvider"
10
+
11
+ setupRNOHWorker({
12
+ createWorkerRNInstanceConfig: (_rnInstanceName) => {
13
+ return { thirdPartyPackagesFactory: getRNOHPackages }
14
+ }
15
+ })
16
+
@@ -0,0 +1,58 @@
1
+ {
2
+ "module": {
3
+ "name": "entry",
4
+ "type": "entry",
5
+ "description": "$string:module_desc",
6
+ "mainElement": "EntryAbility",
7
+ "deviceTypes": [
8
+ "default"
9
+ ],
10
+ "deliveryWithInstall": true,
11
+ "installationFree": false,
12
+ "pages": "$profile:main_pages",
13
+ "requestPermissions": [
14
+ {
15
+ "name": "ohos.permission.INTERNET"
16
+ },
17
+ {
18
+ "name": "ohos.permission.VIBRATE"
19
+ }
20
+ ],
21
+ "metadata": [
22
+ {
23
+ "name": "OPTLazyForEach",
24
+ "value": "true",
25
+ },
26
+ {
27
+ "name": "can_preview_text",
28
+ "value": "true",
29
+ },
30
+ {
31
+ "name": "halfLeading",
32
+ "value": "true",
33
+ },
34
+ ],
35
+ "abilities": [
36
+ {
37
+ "name": "EntryAbility",
38
+ "srcEntry": "./ets/entryability/EntryAbility.ets",
39
+ "description": "$string:EntryAbility_desc",
40
+ "icon": "$media:layered_image",
41
+ "label": "$string:EntryAbility_label",
42
+ "startWindowIcon": "$media:startIcon",
43
+ "startWindowBackground": "$color:start_window_background",
44
+ "visible": true,
45
+ "skills": [
46
+ {
47
+ "entities": [
48
+ "entity.system.home"
49
+ ],
50
+ "actions": [
51
+ "action.system.home"
52
+ ],
53
+ }
54
+ ]
55
+ }
56
+ ]
57
+ }
58
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "color": [
3
+ {
4
+ "name": "start_window_background",
5
+ "value": "#FFFFFF"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "module_desc",
5
+ "value": "module description"
6
+ },
7
+ {
8
+ "name": "EntryAbility_desc",
9
+ "value": "description"
10
+ },
11
+ {
12
+ "name": "EntryAbility_label",
13
+ "value": "template app"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "layered-image":
3
+ {
4
+ "background" : "$media:background",
5
+ "foreground" : "$media:foreground"
6
+ }
7
+ }
@@ -0,0 +1,2 @@
1
+ export default function testsuite() {
2
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "module": {
3
+ "name": "entry_test",
4
+ "type": "feature",
5
+ "deviceTypes": [
6
+ "phone",
7
+ "tablet",
8
+ "2in1"
9
+ ],
10
+ "deliveryWithInstall": true,
11
+ "installationFree": false
12
+ }
13
+ }
@@ -0,0 +1,16 @@
1
+ /build-profile.json5
2
+
3
+ # ---
4
+
5
+ /local.properties
6
+ /.idea
7
+ **/build
8
+ /.hvigor
9
+ .cxx
10
+ /.clangd
11
+ /.clang-format
12
+ /.clang-tidy
13
+ /oh_modules
14
+ hvigorw
15
+ hvigorw.bat
16
+ hvigor/hvigor-wrapper.js
@@ -0,0 +1,22 @@
1
+ {
2
+ modelVersion: '5.0.0',
3
+ dependencies: {
4
+ // "@rnoh/hvigor-plugin": "../../node_modules/<RNOH_CLI>/harmony/rnoh-hvigor-plugin-X.X.X.tgz",
5
+ },
6
+ execution: {
7
+ // "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */
8
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
9
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
10
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
11
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
12
+ },
13
+ logging: {
14
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
15
+ },
16
+ debugging: {
17
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
18
+ },
19
+ nodeOptions: {
20
+ // "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */
21
+ },
22
+ }
@@ -0,0 +1,7 @@
1
+ import { appTasks } from '@ohos/hvigor-ohos-plugin';
2
+ import { createRNOHProjectPlugin } from '@rnoh/hvigor-plugin';
3
+
4
+ export default {
5
+ system: appTasks,
6
+ plugins: [createRNOHProjectPlugin()],
7
+ };
@@ -0,0 +1,21 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./MetroConfigTemplate"), exports);
18
+ __exportStar(require("./EntryStringVarTemplate"), exports);
19
+ __exportStar(require("./EntryIndexTemplate"), exports);
20
+ __exportStar(require("./OhPackageJson5Template"), exports);
21
+ __exportStar(require("./HvigorConfigJson5Template"), exports);
@@ -1,35 +1,62 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE-MIT file in the root directory of this source tree.
7
- */
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.CliExecutor = void 0;
12
+ exports.RealCliExecutor = exports.CliExecutor = void 0;
13
+ const node_child_process_1 = require("node:child_process");
10
14
  class CliExecutor {
11
- stringifyCliArgs(args) {
12
- return Object.entries(args)
13
- .filter(([_, value]) => {
14
- if (typeof value === 'boolean') {
15
- return value;
16
- }
17
- return value !== undefined && value !== null;
18
- })
19
- .map(([key, value]) => {
20
- const formattedKey = toKebabCase(key);
21
- if (typeof value === 'boolean') {
22
- return `--${formattedKey}`;
23
- }
24
- return `--${formattedKey} ${value}`;
25
- })
26
- .join(' ');
27
- }
28
15
  }
29
16
  exports.CliExecutor = CliExecutor;
30
- function toKebabCase(str) {
31
- return str
32
- .replace(/([a-z])([A-Z])/g, '$1-$2')
33
- .replace(/[\s_]+/g, '-')
34
- .toLowerCase();
17
+ class RealCliExecutor extends CliExecutor {
18
+ run(command, options) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ return new Promise((resolve, reject) => {
21
+ var _a, _b;
22
+ let commandWithArgs = command;
23
+ let argStrings = [];
24
+ if (options === null || options === void 0 ? void 0 : options.args) {
25
+ argStrings = options.args;
26
+ commandWithArgs += ' ' + argStrings.join(' ');
27
+ }
28
+ (_a = options === null || options === void 0 ? void 0 : options.onArgsStringified) === null || _a === void 0 ? void 0 : _a.call(options, commandWithArgs);
29
+ const process = (0, node_child_process_1.spawn)(command, argStrings, {
30
+ cwd: (_b = options === null || options === void 0 ? void 0 : options.cwd) === null || _b === void 0 ? void 0 : _b.toString(),
31
+ shell: (options === null || options === void 0 ? void 0 : options.shell) ? true : false,
32
+ });
33
+ let stdout = '';
34
+ let stderr = '';
35
+ process.stdout.on('data', (data) => {
36
+ var _a;
37
+ const output = data.toString();
38
+ stdout += output;
39
+ (_a = options === null || options === void 0 ? void 0 : options.onStdout) === null || _a === void 0 ? void 0 : _a.call(options, output);
40
+ });
41
+ process.stderr.on('data', (data) => {
42
+ var _a;
43
+ const output = data.toString();
44
+ stderr += output;
45
+ (_a = options === null || options === void 0 ? void 0 : options.onStderr) === null || _a === void 0 ? void 0 : _a.call(options, output);
46
+ });
47
+ process.on('error', (error) => {
48
+ reject(error);
49
+ });
50
+ process.on('close', (code) => {
51
+ if (code === 0) {
52
+ resolve(stdout);
53
+ }
54
+ else {
55
+ reject(new Error(`Command failed with code ${code}\nStderr: ${stderr}`));
56
+ }
57
+ });
58
+ });
59
+ });
60
+ }
35
61
  }
62
+ exports.RealCliExecutor = RealCliExecutor;
package/dist/io/Logger.js CHANGED
@@ -1,34 +1,60 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE-MIT file in the root directory of this source tree.
7
- */
8
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
4
  };
11
5
  Object.defineProperty(exports, "__esModule", { value: true });
12
6
  exports.Logger = void 0;
13
7
  const chalk_1 = __importDefault(require("chalk"));
8
+ const cli_tools_1 = require("@react-native-community/cli-tools");
9
+ const node_process_1 = __importDefault(require("node:process"));
14
10
  class Logger {
15
- info(prepareMsg, options) {
16
- const prefix = (options === null || options === void 0 ? void 0 : options.prefix) ? `[${chalk_1.default.bold(chalk_1.default.cyan('INFO'))}]` : '';
17
- if (prefix) {
18
- console.info(prefix, prepareMsg(chalk_1.default));
19
- }
20
- else {
21
- console.info(prepareMsg(chalk_1.default));
22
- }
11
+ constructor() {
12
+ this.loader = (0, cli_tools_1.getLoader)({
13
+ interval: node_process_1.default.stdout.isTTY ? undefined : 0,
14
+ });
15
+ this.logger = cli_tools_1.logger;
16
+ this.isLoaderActive = false;
17
+ }
18
+ start(prepareMsg) {
19
+ this.loader.start(prepareMsg(chalk_1.default));
20
+ this.isLoaderActive = true;
21
+ return (options) => {
22
+ this.isLoaderActive = false;
23
+ if (options === null || options === void 0 ? void 0 : options.persist) {
24
+ console.log({ loader: this.loader });
25
+ this.loader.stopAndPersist();
26
+ }
27
+ else {
28
+ this.loader.stop();
29
+ }
30
+ };
31
+ }
32
+ info(prepareMsg) {
33
+ const info = (msg) => {
34
+ this.isLoaderActive ? this.loader.info(msg) : this.logger.info(msg);
35
+ };
36
+ info(prepareMsg(chalk_1.default));
37
+ }
38
+ succeed(prepareMsg) {
39
+ const succeed = (msg) => this.isLoaderActive ? this.loader.succeed(msg) : this.logger.success(msg);
40
+ succeed(prepareMsg(chalk_1.default));
23
41
  }
24
42
  warn(prepareMsg) {
25
- console.warn(prepareMsg(chalk_1.default));
43
+ const warn = (msg) => this.isLoaderActive ? this.loader.warn(msg) : this.logger.warn(msg);
44
+ warn(prepareMsg(chalk_1.default));
26
45
  }
27
46
  debug(prepareMsg) {
28
- console.debug(prepareMsg(chalk_1.default));
47
+ if (this.isLoaderActive) {
48
+ clearLine(node_process_1.default.stdout);
49
+ moveCursor(node_process_1.default.stdout, 0);
50
+ console.debug(prepareMsg(chalk_1.default));
51
+ this.loader.render();
52
+ }
53
+ else {
54
+ console.debug(prepareMsg(chalk_1.default));
55
+ }
29
56
  }
30
57
  descriptiveError(error) {
31
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
32
58
  const lines = [];
33
59
  if (error.isUnexpected() && error.stack) {
34
60
  lines.push('');
@@ -42,39 +68,37 @@ class Logger {
42
68
  details.split('\n').forEach((line) => lines.push(line));
43
69
  }
44
70
  lines.push('');
45
- let prefix = '';
46
- if (error.isUnexpected()) {
47
- prefix = '[' + chalk_1.default.red(chalk_1.default.bold('UNEXPECTED_ERROR')) + ']';
71
+ lines.push(`${error.getMessage()}`);
72
+ const suggestions = error.getSuggestions();
73
+ if (suggestions.length > 0) {
74
+ lines.push('');
75
+ lines.push(chalk_1.default.bold(`Suggestions`));
76
+ suggestions.forEach((suggestion) => {
77
+ lines.push('• ' + suggestion);
78
+ });
48
79
  }
49
- else {
50
- prefix = '[' + chalk_1.default.red(chalk_1.default.bold('ERROR')) + ']';
80
+ if (this.isLoaderActive) {
81
+ this.loader.fail(lines.join('\n').trim());
51
82
  }
52
- lines.push(`${prefix} ${error.getMessage()}`);
53
- const suggestionsByRole = error.getSuggestionsByRole();
54
- if (suggestionsByRole) {
55
- if (((_b = (_a = suggestionsByRole.default) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) > 0) {
56
- lines.push('');
57
- lines.push(chalk_1.default.bold(`Suggestions`));
58
- (_c = suggestionsByRole.default) === null || _c === void 0 ? void 0 : _c.forEach((suggestion) => {
59
- lines.push(suggestion);
60
- });
61
- }
62
- if (((_e = (_d = suggestionsByRole.rnAppDeveloper) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0) > 0) {
63
- lines.push('');
64
- lines.push(chalk_1.default.bold(`Suggestions for RN App developers`));
65
- (_f = suggestionsByRole.rnAppDeveloper) === null || _f === void 0 ? void 0 : _f.forEach((suggestion) => {
66
- lines.push(suggestion);
67
- });
68
- }
69
- if ((_h = (_g = suggestionsByRole.rnPackageDeveloper) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) {
70
- lines.push('');
71
- lines.push(chalk_1.default.bold(`Suggestions for RN package developers`));
72
- (_j = suggestionsByRole.rnPackageDeveloper) === null || _j === void 0 ? void 0 : _j.forEach((suggestion) => {
73
- lines.push(suggestion);
74
- });
75
- }
83
+ else {
84
+ this.logger.error(lines.join('\n').trim());
76
85
  }
77
- console.error(lines.join('\n'));
78
86
  }
79
87
  }
80
88
  exports.Logger = Logger;
89
+ const clearLine = (stream) => {
90
+ if (stream.clearLine) {
91
+ stream.clearLine(0);
92
+ }
93
+ else {
94
+ node_process_1.default.stdout.write('\r' + ' '.repeat(node_process_1.default.stdout.columns || 80) + '\r');
95
+ }
96
+ };
97
+ const moveCursor = (stream, x) => {
98
+ if (stream.cursorTo) {
99
+ stream.cursorTo(x);
100
+ }
101
+ else {
102
+ node_process_1.default.stdout.write('\r');
103
+ }
104
+ };
package/dist/io/RealFS.js CHANGED
@@ -1,10 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE-MIT file in the root directory of this source tree.
7
- */
8
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
13
  };
20
14
  Object.defineProperty(exports, "__esModule", { value: true });
21
15
  exports.RealFS = void 0;
16
+ const core_1 = require("../core");
22
17
  const FileSystem_1 = require("../core/FileSystem");
23
18
  const node_fs_1 = __importDefault(require("node:fs"));
24
19
  class RealFSDirent extends FileSystem_1.Dirent {
@@ -29,9 +24,15 @@ class RealFSDirent extends FileSystem_1.Dirent {
29
24
  isDirectory() {
30
25
  return this.nodeFSDirent.isDirectory();
31
26
  }
27
+ isSymbolicLink() {
28
+ return this.nodeFSDirent.isSymbolicLink();
29
+ }
32
30
  get name() {
33
31
  return this.nodeFSDirent.name;
34
32
  }
33
+ get path() {
34
+ return new core_1.AbsolutePath(this.nodeFSDirent.path).copyWithNewSegment(this.nodeFSDirent.name);
35
+ }
35
36
  }
36
37
  class RealFS extends FileSystem_1.FS {
37
38
  existsSync(path) {
@@ -64,5 +65,8 @@ class RealFS extends FileSystem_1.FS {
64
65
  })
65
66
  .map((rawDirent) => new RealFSDirent(rawDirent));
66
67
  }
68
+ renameSync(oldPath, newPath) {
69
+ node_fs_1.default.renameSync(oldPath.toString(), newPath.toString());
70
+ }
67
71
  }
68
72
  exports.RealFS = RealFS;
package/dist/io/TarGz.js CHANGED
@@ -1,17 +1,11 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE-MIT file in the root directory of this source tree.
7
- */
8
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
4
  };
11
5
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.unpackTarGz = void 0;
6
+ exports.unpackTarGz = unpackTarGz;
13
7
  const node_fs_1 = __importDefault(require("node:fs"));
14
- const zlib_1 = __importDefault(require("zlib"));
8
+ const node_zlib_1 = __importDefault(require("node:zlib"));
15
9
  const tar_1 = __importDefault(require("tar"));
16
10
  function unpackTarGz(archivePath, outputDirPath) {
17
11
  if (!node_fs_1.default.existsSync(outputDirPath.getValue())) {
@@ -21,7 +15,7 @@ function unpackTarGz(archivePath, outputDirPath) {
21
15
  const writeStream = tar_1.default.extract({
22
16
  cwd: outputDirPath.getValue(),
23
17
  });
24
- readStream.pipe(zlib_1.default.createGunzip()).pipe(writeStream);
18
+ readStream.pipe(node_zlib_1.default.createGunzip()).pipe(writeStream);
25
19
  return new Promise((resolve, reject) => {
26
20
  writeStream.on('finish', () => {
27
21
  resolve(undefined);
@@ -31,4 +25,3 @@ function unpackTarGz(archivePath, outputDirPath) {
31
25
  });
32
26
  });
33
27
  }
34
- exports.unpackTarGz = unpackTarGz;
@@ -1,10 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE-MIT file in the root directory of this source tree.
7
- */
8
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -31,10 +25,10 @@ class FakeCliExecutor extends CliExecutor_1.CliExecutor {
31
25
  this.onRun = onRun;
32
26
  this.commands = [];
33
27
  }
34
- run(command, options = {}) {
28
+ run(command, options) {
35
29
  let commandWithArgs = command;
36
30
  if (options.args) {
37
- commandWithArgs += ' ' + this.stringifyCliArgs(options.args);
31
+ commandWithArgs += options.args.join(' ');
38
32
  }
39
33
  this.commands.push(commandWithArgs);
40
34
  return this.onRun(commandWithArgs);
@@ -52,9 +46,15 @@ class MemFSDirent extends core_1.Dirent {
52
46
  isDirectory() {
53
47
  return this.rawDirent.isDirectory();
54
48
  }
49
+ isSymbolicLink() {
50
+ return false;
51
+ }
55
52
  get name() {
56
53
  return this.rawDirent.name.toString();
57
54
  }
55
+ get path() {
56
+ return new core_1.AbsolutePath(this.rawDirent.path).copyWithNewSegment(this.rawDirent.name.toString());
57
+ }
58
58
  }
59
59
  class MemFS extends core_1.FS {
60
60
  constructor(initialFileStructure) {
@@ -1,15 +1,9 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE-MIT file in the root directory of this source tree.
7
- */
8
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
9
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
10
4
  };
11
5
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.findFilePathsWithExtensions = void 0;
6
+ exports.findFilePathsWithExtensions = findFilePathsWithExtensions;
13
7
  const node_path_1 = __importDefault(require("node:path"));
14
8
  const Dirent_1 = __importDefault(require("memfs/lib/Dirent"));
15
9
  const node_fs_1 = __importDefault(require("node:fs"));
@@ -34,4 +28,3 @@ function findFilePathsWithExtensions(dirPath, fileExtensions, options = {}) {
34
28
  }
35
29
  return results;
36
30
  }
37
- exports.findFilePathsWithExtensions = findFilePathsWithExtensions;
package/dist/io/index.js CHANGED
@@ -1,10 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE-MIT file in the root directory of this source tree.
7
- */
8
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
3
  if (k2 === undefined) k2 = k;
10
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -24,3 +18,4 @@ __exportStar(require("./Logger"), exports);
24
18
  __exportStar(require("./fsUtils"), exports);
25
19
  __exportStar(require("./TarGz"), exports);
26
20
  __exportStar(require("./RealFS"), exports);
21
+ __exportStar(require("./CliExecutor"), exports);
@@ -1,10 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Copyright (c) 2024 Huawei Technologies Co., Ltd.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE-MIT file in the root directory of this source tree.
7
- */
8
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
9
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
10
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -18,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
19
13
  };
20
14
  Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.createHarmonyDirContainsOnlyHarsCheck = void 0;
15
+ exports.createHarmonyDirContainsOnlyHarsCheck = createHarmonyDirContainsOnlyHarsCheck;
22
16
  const node_fs_1 = __importDefault(require("node:fs"));
23
17
  function createHarmonyDirContainsOnlyHarsCheck(npmPackagePath, hasNpmPackageNativeCode) {
24
18
  return {
@@ -41,4 +35,3 @@ function createHarmonyDirContainsOnlyHarsCheck(npmPackagePath, hasNpmPackageNati
41
35
  }),
42
36
  };
43
37
  }
44
- exports.createHarmonyDirContainsOnlyHarsCheck = createHarmonyDirContainsOnlyHarsCheck;