@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.
- package/LICENSE +21 -0
- package/README.md +4 -4
- package/dist/assetResolver.js +105 -10
- package/dist/autolinking/Autolinking.js +21 -26
- package/dist/autolinking/index.js +0 -6
- package/dist/codegen/core/CodeGenerator.js +0 -6
- package/dist/codegen/core/CodegenError.js +0 -6
- package/dist/codegen/core/EventUtils.js +4 -13
- package/dist/codegen/core/TypeAnnotationToTS.js +3 -9
- package/dist/codegen/core/UberSchema.js +8 -21
- package/dist/codegen/core/index.js +0 -6
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +2 -7
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +3 -6
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +3 -6
- package/dist/codegen/generators/CppComponentCodeGenerator.js +3 -6
- package/dist/codegen/generators/LibGlueCodeGenerator.js +2 -8
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +1 -7
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +0 -6
- package/dist/codegen/generators/UberGeneratorV1.js +0 -6
- package/dist/codegen/generators/UberGeneratorV2.js +0 -6
- package/dist/codegen/generators/index.js +0 -6
- package/dist/codegen/index.js +0 -6
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +0 -6
- package/dist/codegen/templates/BasePackageHTemplate.js +12 -7
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +1 -6
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +15 -6
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +0 -6
- package/dist/codegen/templates/IndexTSTemplate.js +0 -6
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +12 -7
- package/dist/codegen/templates/TurboModuleCppTemplate.js +0 -6
- package/dist/codegen/templates/TurboModuleHTemplate.js +0 -6
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +0 -6
- package/dist/codegen/templates/index.js +0 -6
- package/dist/commands/bundle-harmony.js +133 -101
- package/dist/commands/clean-harmony.js +84 -0
- package/dist/commands/codegen-harmony.js +12 -22
- package/dist/commands/codegen-lib-harmony.js +15 -25
- package/dist/commands/index.js +3 -9
- package/dist/commands/init-harmony.js +226 -0
- package/dist/commands/init.js +703 -0
- package/dist/commands/link-harmony.js +12 -16
- package/dist/commands/run-harmony.js +438 -0
- package/dist/commands/types.js +2 -0
- package/dist/commands/verify-package-harmony.js +7 -11
- package/dist/core/AbsolutePath.js +3 -6
- package/dist/core/CodegenConfig.js +3 -11
- package/dist/core/DescriptiveError.js +7 -9
- package/dist/core/FileSystem.js +0 -6
- package/dist/core/OHPackageJSON5.js +0 -6
- package/dist/core/PackageJSON.js +4 -7
- package/dist/core/ProjectDependenciesManager.js +6 -14
- package/dist/core/ValidationError.js +0 -6
- package/dist/core/ValueObject.js +0 -6
- package/dist/core/fs.js +16 -10
- package/dist/core/index.js +0 -6
- package/dist/index.js +3 -9
- package/dist/init/templates/AppScopeAppJSON5Template.js +30 -0
- package/dist/init/templates/AppScopeStringVarTemplate.js +28 -0
- package/dist/init/templates/EntryIndexTemplate.js +65 -0
- package/dist/init/templates/EntryStringVarTemplate.js +38 -0
- package/dist/init/templates/HvigorConfigJson5Template.js +44 -0
- package/dist/init/templates/MetroConfigTemplate.js +47 -0
- package/dist/init/templates/OhPackageJson5Template.js +37 -0
- package/dist/init/templates/harmony/AppScope/app.json5 +10 -0
- package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
- package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/dist/init/templates/harmony/build-profile.json5 +36 -0
- package/dist/init/templates/harmony/codelinter.json +32 -0
- package/dist/init/templates/harmony/entry/build-profile.json5 +18 -0
- package/dist/init/templates/harmony/entry/gitignore +7 -0
- package/dist/init/templates/harmony/entry/hvigorfile.ts +13 -0
- package/dist/init/templates/harmony/entry/oh-package.json5 +9 -0
- package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
- package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
- package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
- package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
- package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
- package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
- package/dist/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
- package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
- package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
- package/dist/init/templates/harmony/entry/src/main/module.json5 +58 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/dist/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
- package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
- package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
- package/dist/init/templates/harmony/gitignore +16 -0
- package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
- package/dist/init/templates/harmony/hvigorfile.ts +7 -0
- package/dist/init/templates/index.js +21 -0
- package/dist/io/CliExecutor.js +56 -29
- package/dist/io/Logger.js +71 -47
- package/dist/io/RealFS.js +10 -6
- package/dist/io/TarGz.js +3 -10
- package/dist/io/__fixtures__.js +8 -8
- package/dist/io/fsUtils.js +1 -8
- package/dist/io/index.js +1 -6
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +1 -8
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +1 -8
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +1 -8
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +1 -8
- package/dist/package-verifier/checks/index.js +0 -6
- package/dist/package-verifier/index.js +0 -6
- package/dist/package-verifier/types.js +0 -6
- package/dist/package-verifier/verify-package.js +5 -14
- package/jest.config.js +0 -7
- package/package.json +20 -16
- package/react-native.config.js +0 -7
- package/scripts/copy-template.js +18 -0
- package/src/assetResolver.ts +117 -11
- package/src/autolinking/Autolinking.test.ts +54 -18
- package/src/autolinking/Autolinking.ts +32 -31
- package/src/autolinking/index.ts +1 -8
- package/src/codegen/core/CodeGenerator.ts +0 -7
- package/src/codegen/core/CodegenError.ts +0 -7
- package/src/codegen/core/EventUtils.ts +3 -12
- package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -7
- package/src/codegen/core/TypeAnnotationToTS.ts +3 -8
- package/src/codegen/core/UberSchema.ts +9 -22
- package/src/codegen/core/index.ts +0 -7
- package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +5 -8
- package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +3 -7
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +3 -7
- package/src/codegen/generators/CppComponentCodeGenerator.ts +3 -7
- package/src/codegen/generators/LibGlueCodeGenerator.ts +2 -9
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +1 -8
- package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -7
- package/src/codegen/generators/UberGeneratorV1.ts +0 -7
- package/src/codegen/generators/UberGeneratorV2.ts +0 -7
- package/src/codegen/generators/index.ts +0 -7
- package/src/codegen/index.ts +0 -7
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -7
- package/src/codegen/templates/BasePackageHTemplate.ts +13 -8
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +1 -7
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +24 -8
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -7
- package/src/codegen/templates/IndexTSTemplate.ts +0 -7
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +13 -8
- package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -7
- package/src/codegen/templates/TurboModuleHTemplate.ts +0 -7
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -7
- package/src/codegen/templates/index.ts +0 -7
- package/src/commands/bundle-harmony.ts +178 -118
- package/src/commands/clean-harmony.ts +54 -0
- package/src/commands/codegen-harmony.ts +13 -25
- package/src/commands/codegen-lib-harmony.ts +16 -28
- package/src/commands/index.ts +3 -10
- package/src/commands/init-harmony.ts +299 -0
- package/src/commands/init.ts +755 -0
- package/src/commands/link-harmony.ts +14 -19
- package/src/commands/run-harmony.ts +478 -0
- package/src/commands/types.ts +14 -0
- package/src/commands/verify-package-harmony.ts +9 -12
- package/src/core/AbsolutePath.ts +4 -7
- package/src/core/CodegenConfig.ts +3 -12
- package/src/core/DescriptiveError.ts +8 -15
- package/src/core/FileSystem.ts +5 -8
- package/src/core/OHPackageJSON5.ts +0 -7
- package/src/core/PackageJSON.ts +4 -13
- package/src/core/ProjectDependenciesManager.ts +14 -22
- package/src/core/ValidationError.ts +0 -7
- package/src/core/ValueObject.ts +0 -7
- package/src/core/fs.ts +14 -8
- package/src/core/index.ts +0 -7
- package/src/index.ts +8 -15
- package/src/init/templates/AppScopeAppJSON5Template.ts +24 -0
- package/src/init/templates/AppScopeStringVarTemplate.ts +22 -0
- package/src/init/templates/EntryIndexTemplate.ts +59 -0
- package/src/init/templates/EntryStringVarTemplate.ts +31 -0
- package/src/init/templates/HvigorConfigJson5Template.ts +40 -0
- package/src/init/templates/MetroConfigTemplate.ts +41 -0
- package/src/init/templates/OhPackageJson5Template.ts +31 -0
- package/src/init/templates/harmony/AppScope/app.json5 +10 -0
- package/src/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
- package/src/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/src/init/templates/harmony/build-profile.json5 +36 -0
- package/src/init/templates/harmony/codelinter.json +32 -0
- package/src/init/templates/harmony/entry/build-profile.json5 +18 -0
- package/src/init/templates/harmony/entry/gitignore +7 -0
- package/src/init/templates/harmony/entry/hvigorfile.ts +13 -0
- package/src/init/templates/harmony/entry/oh-package.json5 +9 -0
- package/src/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
- package/src/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
- package/src/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
- package/src/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
- package/src/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
- package/src/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
- package/src/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
- package/src/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
- package/src/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
- package/src/init/templates/harmony/entry/src/main/module.json5 +58 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/src/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
- package/src/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
- package/src/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
- package/src/init/templates/harmony/gitignore +16 -0
- package/src/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
- package/src/init/templates/harmony/hvigorfile.ts +7 -0
- package/src/init/templates/index.ts +5 -0
- package/src/io/CliExecutor.ts +55 -40
- package/src/io/Logger.ts +77 -51
- package/src/io/RealFS.ts +15 -8
- package/src/io/TarGz.ts +1 -8
- package/src/io/__fixtures__.ts +15 -18
- package/src/io/fsUtils.ts +1 -7
- package/src/io/index.ts +1 -7
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -7
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -7
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -7
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -7
- package/src/package-verifier/checks/index.ts +0 -7
- package/src/package-verifier/index.ts +0 -7
- package/src/package-verifier/types.ts +0 -7
- package/src/package-verifier/verify-package.ts +4 -13
- package/tsconfig.build.json +2 -5
- package/tsconfig.json +4 -0
- package/dist/commands/create-metro-host-constants.js +0 -67
- package/dist/commands/pack-harmony.js +0 -106
- package/dist/commands/unpack-harmony.js +0 -191
- package/src/commands/create-metro-host-constants.ts +0 -55
- package/src/commands/pack-harmony.ts +0 -128
- 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,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
|
|
File without changes
|
|
@@ -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
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rawfile/assets
|
|
@@ -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
|
+
}
|
package/src/io/CliExecutor.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
33
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
|
package/src/io/__fixtures__.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 { 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 += ' '
|
|
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';
|