@react-native-oh/react-native-harmony-cli 0.0.30 → 0.77.18

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 (234) 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/jest.config.js +0 -7
  113. package/package.json +20 -16
  114. package/react-native.config.js +0 -7
  115. package/scripts/copy-template.js +18 -0
  116. package/src/assetResolver.ts +117 -11
  117. package/src/autolinking/Autolinking.test.ts +54 -18
  118. package/src/autolinking/Autolinking.ts +32 -31
  119. package/src/autolinking/index.ts +1 -8
  120. package/src/codegen/core/CodeGenerator.ts +0 -7
  121. package/src/codegen/core/CodegenError.ts +0 -7
  122. package/src/codegen/core/EventUtils.ts +3 -12
  123. package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -7
  124. package/src/codegen/core/TypeAnnotationToTS.ts +3 -8
  125. package/src/codegen/core/UberSchema.ts +9 -22
  126. package/src/codegen/core/index.ts +0 -7
  127. package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +5 -8
  128. package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +3 -7
  129. package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +3 -7
  130. package/src/codegen/generators/CppComponentCodeGenerator.ts +3 -7
  131. package/src/codegen/generators/LibGlueCodeGenerator.ts +2 -9
  132. package/src/codegen/generators/NativeModuleCodeGenerator.ts +1 -8
  133. package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -7
  134. package/src/codegen/generators/UberGeneratorV1.ts +0 -7
  135. package/src/codegen/generators/UberGeneratorV2.ts +0 -7
  136. package/src/codegen/generators/index.ts +0 -7
  137. package/src/codegen/index.ts +0 -7
  138. package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -7
  139. package/src/codegen/templates/BasePackageHTemplate.ts +13 -8
  140. package/src/codegen/templates/ComponentDescriptorHTemplate.ts +1 -7
  141. package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +24 -8
  142. package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -7
  143. package/src/codegen/templates/IndexTSTemplate.ts +0 -7
  144. package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +13 -8
  145. package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -7
  146. package/src/codegen/templates/TurboModuleHTemplate.ts +0 -7
  147. package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -7
  148. package/src/codegen/templates/index.ts +0 -7
  149. package/src/commands/bundle-harmony.ts +178 -118
  150. package/src/commands/clean-harmony.ts +54 -0
  151. package/src/commands/codegen-harmony.ts +13 -25
  152. package/src/commands/codegen-lib-harmony.ts +16 -28
  153. package/src/commands/index.ts +3 -10
  154. package/src/commands/init-harmony.ts +299 -0
  155. package/src/commands/init.ts +755 -0
  156. package/src/commands/link-harmony.ts +14 -19
  157. package/src/commands/run-harmony.ts +478 -0
  158. package/src/commands/types.ts +14 -0
  159. package/src/commands/verify-package-harmony.ts +9 -12
  160. package/src/core/AbsolutePath.ts +4 -7
  161. package/src/core/CodegenConfig.ts +3 -12
  162. package/src/core/DescriptiveError.ts +8 -15
  163. package/src/core/FileSystem.ts +5 -8
  164. package/src/core/OHPackageJSON5.ts +0 -7
  165. package/src/core/PackageJSON.ts +4 -13
  166. package/src/core/ProjectDependenciesManager.ts +14 -22
  167. package/src/core/ValidationError.ts +0 -7
  168. package/src/core/ValueObject.ts +0 -7
  169. package/src/core/fs.ts +14 -8
  170. package/src/core/index.ts +0 -7
  171. package/src/index.ts +8 -15
  172. package/src/init/templates/AppScopeAppJSON5Template.ts +24 -0
  173. package/src/init/templates/AppScopeStringVarTemplate.ts +22 -0
  174. package/src/init/templates/EntryIndexTemplate.ts +59 -0
  175. package/src/init/templates/EntryStringVarTemplate.ts +31 -0
  176. package/src/init/templates/HvigorConfigJson5Template.ts +40 -0
  177. package/src/init/templates/MetroConfigTemplate.ts +41 -0
  178. package/src/init/templates/OhPackageJson5Template.ts +31 -0
  179. package/src/init/templates/harmony/AppScope/app.json5 +10 -0
  180. package/src/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
  181. package/src/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
  182. package/src/init/templates/harmony/build-profile.json5 +36 -0
  183. package/src/init/templates/harmony/codelinter.json +32 -0
  184. package/src/init/templates/harmony/entry/build-profile.json5 +18 -0
  185. package/src/init/templates/harmony/entry/gitignore +7 -0
  186. package/src/init/templates/harmony/entry/hvigorfile.ts +13 -0
  187. package/src/init/templates/harmony/entry/oh-package.json5 +9 -0
  188. package/src/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
  189. package/src/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
  190. package/src/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
  191. package/src/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
  192. package/src/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
  193. package/src/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
  194. package/src/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
  195. package/src/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
  196. package/src/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
  197. package/src/init/templates/harmony/entry/src/main/module.json5 +58 -0
  198. package/src/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
  199. package/src/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
  200. package/src/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
  201. package/src/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
  202. package/src/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
  203. package/src/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
  204. package/src/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
  205. package/src/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
  206. package/src/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
  207. package/src/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
  208. package/src/init/templates/harmony/gitignore +16 -0
  209. package/src/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
  210. package/src/init/templates/harmony/hvigorfile.ts +7 -0
  211. package/src/init/templates/index.ts +5 -0
  212. package/src/io/CliExecutor.ts +55 -40
  213. package/src/io/Logger.ts +77 -51
  214. package/src/io/RealFS.ts +15 -8
  215. package/src/io/TarGz.ts +1 -8
  216. package/src/io/__fixtures__.ts +15 -18
  217. package/src/io/fsUtils.ts +1 -7
  218. package/src/io/index.ts +1 -7
  219. package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -7
  220. package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -7
  221. package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -7
  222. package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -7
  223. package/src/package-verifier/checks/index.ts +0 -7
  224. package/src/package-verifier/index.ts +0 -7
  225. package/src/package-verifier/types.ts +0 -7
  226. package/src/package-verifier/verify-package.ts +4 -13
  227. package/tsconfig.build.json +2 -5
  228. package/tsconfig.json +4 -0
  229. package/dist/commands/create-metro-host-constants.js +0 -67
  230. package/dist/commands/pack-harmony.js +0 -106
  231. package/dist/commands/unpack-harmony.js +0 -191
  232. package/src/commands/create-metro-host-constants.ts +0 -55
  233. package/src/commands/pack-harmony.ts +0 -128
  234. package/src/commands/unpack-harmony.ts +0 -240
@@ -0,0 +1,27 @@
1
+ cmake_minimum_required(VERSION 3.11)
2
+ project(rnapp)
3
+
4
+ set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
5
+ set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
6
+ set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../oh_modules/@rnoh/react-native-openharmony/src/main/cpp")
7
+ set(RNOH_GENERATED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/generated")
8
+ set(LOG_VERBOSITY_LEVEL 1)
9
+ set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
10
+ set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
11
+ set(WITH_HITRACE_SYSTRACE ON)
12
+ set(WITH_HITRACE_REACT_MARKER ON)
13
+ set(OH_MODULES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../oh_modules") # required by 'autolink_libraries'
14
+
15
+ add_subdirectory("${RNOH_CPP_DIR}" ./rn)
16
+
17
+ include("${CMAKE_CURRENT_SOURCE_DIR}/autolinking.cmake")
18
+
19
+ file(GLOB GENERATED_CPP_FILES "${CMAKE_CURRENT_SOURCE_DIR}/generated/*.cpp") # this line is needed by codegen v1
20
+ add_library(rnoh_app SHARED
21
+ ${GENERATED_CPP_FILES}
22
+ "./PackageProvider.cpp"
23
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
24
+ )
25
+ target_link_libraries(rnoh_app PUBLIC rnoh)
26
+
27
+ autolink_libraries(rnoh_app)
@@ -0,0 +1,13 @@
1
+ #include "RNOH/PackageProvider.h"
2
+ #include "RNOHPackagesFactory.h"
3
+ #include "generated/RNOHGeneratedPackage.h"
4
+
5
+ using namespace rnoh;
6
+
7
+ std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(
8
+ Package::Context ctx) {
9
+ auto packages = createRNOHPackages(ctx); // <= autolinking
10
+ packages.push_back(std::make_shared<RNOHGeneratedPackage>(
11
+ ctx)); // generated by codegen-harmony v1 on app preBuilt stage)
12
+ return packages;
13
+ }
@@ -0,0 +1,4 @@
1
+ generated/
2
+ /RNOHPackagesFactory.h
3
+ autolinking.cmake
4
+
@@ -0,0 +1,8 @@
1
+ import type { RNPackageContext, RNOHPackage } from '@rnoh/react-native-openharmony';
2
+ import { createRNOHPackages as createRNOHPackagesAutolinking } from "./RNOHPackagesFactory"
3
+
4
+ export function getRNOHPackages(ctx: RNPackageContext): RNOHPackage[] {
5
+ return [
6
+ ...createRNOHPackagesAutolinking(ctx)
7
+ ]
8
+ }
@@ -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,5 @@
1
+ export * from './MetroConfigTemplate';
2
+ export * from './EntryStringVarTemplate';
3
+ export * from './EntryIndexTemplate';
4
+ export * from './OhPackageJson5Template';
5
+ export * from './HvigorConfigJson5Template';
@@ -1,47 +1,62 @@
1
- /**
2
- * Copyright (c) 2024 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
1
  import { AbsolutePath } from '../core';
2
+ import { spawn } from 'node:child_process';
3
+
4
+ export type CliOptions = {
5
+ args: string[];
6
+ cwd?: AbsolutePath;
7
+ onArgsStringified?: (commandWithArgs: string) => void;
8
+ onStdout?: (data: string) => void;
9
+ onStderr?: (data: string) => void;
10
+ shell?: boolean;
11
+ };
9
12
 
10
13
  export abstract class CliExecutor {
11
- abstract run(
12
- command: string,
13
- options?: {
14
- args?: Record<string, string | number | boolean>;
15
- cwd?: AbsolutePath;
16
- }
17
- ): string;
18
-
19
- protected stringifyCliArgs(
20
- args: Record<string, string | number | boolean>
21
- ): string {
22
- return Object.entries(args)
23
- .filter(([_, value]) => {
24
- if (typeof value === 'boolean') {
25
- return value;
26
- }
27
- return value !== undefined && value !== null;
28
- })
29
- .map(([key, value]) => {
30
- const formattedKey = toKebabCase(key);
14
+ abstract run(command: string, options?: CliOptions): Promise<string>;
15
+ }
31
16
 
32
- if (typeof value === 'boolean') {
33
- return `--${formattedKey}`;
34
- }
17
+ export class RealCliExecutor extends CliExecutor {
18
+ async run(command: string, options?: CliOptions): Promise<string> {
19
+ return new Promise((resolve, reject) => {
20
+ let commandWithArgs = command;
21
+ let argStrings: string[] = [];
22
+ if (options?.args) {
23
+ argStrings = options.args;
24
+ commandWithArgs += ' ' + argStrings.join(' ');
25
+ }
26
+ options?.onArgsStringified?.(commandWithArgs);
27
+ const process = spawn(command, argStrings, {
28
+ cwd: options?.cwd?.toString(),
29
+ shell: options?.shell ? true : false,
30
+ });
31
+
32
+ let stdout = '';
33
+ let stderr = '';
35
34
 
36
- return `--${formattedKey} ${value}`;
37
- })
38
- .join(' ');
35
+ process.stdout.on('data', (data) => {
36
+ const output = data.toString();
37
+ stdout += output;
38
+ options?.onStdout?.(output);
39
+ });
40
+
41
+ process.stderr.on('data', (data) => {
42
+ const output = data.toString();
43
+ stderr += output;
44
+ options?.onStderr?.(output);
45
+ });
46
+
47
+ process.on('error', (error) => {
48
+ reject(error);
49
+ });
50
+
51
+ process.on('close', (code) => {
52
+ if (code === 0) {
53
+ resolve(stdout);
54
+ } else {
55
+ reject(
56
+ new Error(`Command failed with code ${code}\nStderr: ${stderr}`)
57
+ );
58
+ }
59
+ });
60
+ });
39
61
  }
40
62
  }
41
-
42
- function toKebabCase(str: string): string {
43
- return str
44
- .replace(/([a-z])([A-Z])/g, '$1-$2')
45
- .replace(/[\s_]+/g, '-')
46
- .toLowerCase();
47
- }
package/src/io/Logger.ts CHANGED
@@ -1,32 +1,56 @@
1
- /**
2
- * Copyright (c) 2024 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
1
  import chalk from 'chalk';
9
2
  import { DescriptiveError } from '../core';
10
-
3
+ import { getLoader, logger as LOGGER } from '@react-native-community/cli-tools';
4
+ import process from 'node:process';
11
5
  export class Logger {
12
- info(
13
- prepareMsg: (styles: typeof chalk) => string,
14
- options?: { prefix?: boolean }
15
- ) {
16
- const prefix = options?.prefix ? `[${chalk.bold(chalk.cyan('INFO'))}]` : '';
17
- if (prefix) {
18
- console.info(prefix, prepareMsg(chalk));
19
- } else {
20
- console.info(prepareMsg(chalk));
21
- }
6
+ private loader = getLoader({
7
+ interval: process.stdout.isTTY ? undefined : 0,
8
+ });
9
+ private logger = LOGGER;
10
+ private isLoaderActive = false;
11
+
12
+ start(prepareMsg: (styles: typeof chalk) => string) {
13
+ this.loader.start(prepareMsg(chalk));
14
+ this.isLoaderActive = true;
15
+ return (options?: { persist?: boolean }) => {
16
+ this.isLoaderActive = false;
17
+ if (options?.persist) {
18
+ console.log({ loader: this.loader });
19
+ this.loader.stopAndPersist();
20
+ } else {
21
+ this.loader.stop();
22
+ }
23
+ };
22
24
  }
23
-
25
+
26
+ info(prepareMsg: (styles: typeof chalk) => string) {
27
+ const info = (msg: string) => {
28
+ this.isLoaderActive ? this.loader.info(msg) : this.logger.info(msg);
29
+ };
30
+ info(prepareMsg(chalk));
31
+ }
32
+
33
+ succeed(prepareMsg: (styles: typeof chalk) => string) {
34
+ const succeed = (msg: string) =>
35
+ this.isLoaderActive ? this.loader.succeed(msg) : this.logger.success(msg);
36
+ succeed(prepareMsg(chalk));
37
+ }
38
+
24
39
  warn(prepareMsg: (styles: typeof chalk) => string) {
25
- console.warn(prepareMsg(chalk));
40
+ const warn = (msg: string) =>
41
+ this.isLoaderActive ? this.loader.warn(msg) : this.logger.warn(msg);
42
+ warn(prepareMsg(chalk));
26
43
  }
27
44
 
28
45
  debug(prepareMsg: (styles: typeof chalk) => string) {
29
- console.debug(prepareMsg(chalk));
46
+ if (this.isLoaderActive) {
47
+ clearLine(process.stdout);
48
+ moveCursor(process.stdout, 0);
49
+ console.debug(prepareMsg(chalk));
50
+ this.loader.render();
51
+ } else {
52
+ console.debug(prepareMsg(chalk));
53
+ }
30
54
  }
31
55
 
32
56
  descriptiveError(error: DescriptiveError) {
@@ -43,37 +67,39 @@ export class Logger {
43
67
  details.split('\n').forEach((line) => lines.push(line));
44
68
  }
45
69
  lines.push('');
46
- let prefix = '';
47
- if (error.isUnexpected()) {
48
- prefix = '[' + chalk.red(chalk.bold('UNEXPECTED_ERROR')) + ']';
49
- } else {
50
- prefix = '[' + chalk.red(chalk.bold('ERROR')) + ']';
70
+ lines.push(`${error.getMessage()}`);
71
+ const suggestions = error.getSuggestions();
72
+
73
+ if (suggestions.length > 0) {
74
+ lines.push('');
75
+ lines.push(chalk.bold(`Suggestions`));
76
+ suggestions.forEach((suggestion) => {
77
+ lines.push('• ' + suggestion);
78
+ });
51
79
  }
52
- lines.push(`${prefix} ${error.getMessage()}`);
53
- const suggestionsByRole = error.getSuggestionsByRole();
54
- if (suggestionsByRole) {
55
- if ((suggestionsByRole.default?.length ?? 0) > 0) {
56
- lines.push('');
57
- lines.push(chalk.bold(`Suggestions`));
58
- suggestionsByRole.default?.forEach((suggestion) => {
59
- lines.push(suggestion);
60
- });
61
- }
62
- if ((suggestionsByRole.rnAppDeveloper?.length ?? 0) > 0) {
63
- lines.push('');
64
- lines.push(chalk.bold(`Suggestions for RN App developers`));
65
- suggestionsByRole.rnAppDeveloper?.forEach((suggestion) => {
66
- lines.push(suggestion);
67
- });
68
- }
69
- if (suggestionsByRole.rnPackageDeveloper?.length ?? 0) {
70
- lines.push('');
71
- lines.push(chalk.bold(`Suggestions for RN package developers`));
72
- suggestionsByRole.rnPackageDeveloper?.forEach((suggestion) => {
73
- lines.push(suggestion);
74
- });
75
- }
80
+
81
+ if (this.isLoaderActive) {
82
+ this.loader.fail(lines.join('\n').trim());
83
+ } else {
84
+ this.logger.error(lines.join('\n').trim());
76
85
  }
77
- console.error(lines.join('\n'));
78
86
  }
79
87
  }
88
+
89
+ const clearLine = (stream: NodeJS.WriteStream): void => {
90
+ if (stream.clearLine) {
91
+ stream.clearLine(0);
92
+ } else {
93
+ process.stdout.write(
94
+ '\r' + ' '.repeat(process.stdout.columns || 80) + '\r'
95
+ );
96
+ }
97
+ };
98
+
99
+ const moveCursor = (stream: NodeJS.WriteStream, x: number): void => {
100
+ if (stream.cursorTo) {
101
+ stream.cursorTo(x);
102
+ } else {
103
+ process.stdout.write('\r');
104
+ }
105
+ };
package/src/io/RealFS.ts CHANGED
@@ -1,10 +1,3 @@
1
- /**
2
- * Copyright (c) 2024 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
1
  import { AbsolutePath } from '../core';
9
2
  import { Dirent, FS } from '../core/FileSystem';
10
3
  import fs, { Dirent as NodeFSDirent } from 'node:fs';
@@ -18,9 +11,19 @@ class RealFSDirent extends Dirent {
18
11
  return this.nodeFSDirent.isDirectory();
19
12
  }
20
13
 
14
+ isSymbolicLink(): boolean {
15
+ return this.nodeFSDirent.isSymbolicLink();
16
+ }
17
+
21
18
  get name(): string {
22
19
  return this.nodeFSDirent.name;
23
20
  }
21
+
22
+ get path(): AbsolutePath {
23
+ return new AbsolutePath(this.nodeFSDirent.path).copyWithNewSegment(
24
+ this.nodeFSDirent.name
25
+ );
26
+ }
24
27
  }
25
28
 
26
29
  export class RealFS extends FS {
@@ -59,4 +62,8 @@ export class RealFS extends FS {
59
62
  })
60
63
  .map((rawDirent) => new RealFSDirent(rawDirent));
61
64
  }
62
- }
65
+
66
+ renameSync(oldPath: AbsolutePath, newPath: AbsolutePath) {
67
+ fs.renameSync(oldPath.toString(), newPath.toString());
68
+ }
69
+ }
package/src/io/TarGz.ts CHANGED
@@ -1,12 +1,5 @@
1
- /**
2
- * Copyright (c) 2024 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
1
  import fs from 'node:fs';
9
- import zlib from 'zlib';
2
+ import zlib from 'node:zlib';
10
3
  import tar from 'tar';
11
4
  import { AbsolutePath } from '../core';
12
5
 
@@ -1,12 +1,5 @@
1
- /**
2
- * Copyright (c) 2024 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
1
  import { AbsolutePath, DescriptiveError, Dirent, FS } from '../core';
9
- import { CliExecutor } from './CliExecutor';
2
+ import { CliExecutor, CliOptions } from './CliExecutor';
10
3
  import { IFs, memfs, NestedDirectoryJSON } from 'memfs';
11
4
  import RawMemDirent from 'memfs/lib/Dirent';
12
5
  import { Logger } from './Logger';
@@ -15,20 +8,14 @@ import chalk from 'chalk';
15
8
  export class FakeCliExecutor extends CliExecutor {
16
9
  private commands: string[] = [];
17
10
 
18
- constructor(private onRun: (command: string) => string) {
11
+ constructor(private onRun: (command: string) => Promise<string>) {
19
12
  super();
20
13
  }
21
14
 
22
- run(
23
- command: string,
24
- options: {
25
- args?: Record<string, string | number | boolean>;
26
- cwd?: AbsolutePath;
27
- } = {}
28
- ): string {
15
+ run(command: string, options: CliOptions): Promise<string> {
29
16
  let commandWithArgs = command;
30
17
  if (options.args) {
31
- commandWithArgs += ' ' + this.stringifyCliArgs(options.args);
18
+ commandWithArgs += options.args.join(' ');
32
19
  }
33
20
  this.commands.push(commandWithArgs);
34
21
  return this.onRun(commandWithArgs);
@@ -48,9 +35,19 @@ class MemFSDirent extends Dirent {
48
35
  return this.rawDirent.isDirectory();
49
36
  }
50
37
 
38
+ isSymbolicLink(): boolean {
39
+ return false;
40
+ }
41
+
51
42
  get name(): string {
52
43
  return this.rawDirent.name.toString();
53
44
  }
45
+
46
+ get path(): AbsolutePath {
47
+ return new AbsolutePath(this.rawDirent.path).copyWithNewSegment(
48
+ this.rawDirent.name.toString()
49
+ );
50
+ }
54
51
  }
55
52
  export class MemFS extends FS {
56
53
  private fs: IFs;
@@ -132,4 +129,4 @@ export class MockedLogger extends Logger {
132
129
  getLogs() {
133
130
  return this.logs;
134
131
  }
135
- }
132
+ }
package/src/io/fsUtils.ts CHANGED
@@ -1,11 +1,5 @@
1
- /**
2
- * Copyright (c) 2024 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
1
  import pathUtils from 'node:path';
2
+
9
3
  import { AbsolutePath } from '../core';
10
4
  import { IFs } from 'memfs';
11
5
  import MemDirent from 'memfs/lib/Dirent';