@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
|
@@ -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.createHarmonyDirExistsCheck =
|
|
15
|
+
exports.createHarmonyDirExistsCheck = createHarmonyDirExistsCheck;
|
|
22
16
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
23
17
|
function createHarmonyDirExistsCheck(packagePath, hasNativeCode) {
|
|
24
18
|
return {
|
|
@@ -35,4 +29,3 @@ function createHarmonyDirExistsCheck(packagePath, hasNativeCode) {
|
|
|
35
29
|
}),
|
|
36
30
|
};
|
|
37
31
|
}
|
|
38
|
-
exports.createHarmonyDirExistsCheck = createHarmonyDirExistsCheck;
|
|
@@ -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) {
|
|
@@ -15,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
15
9
|
});
|
|
16
10
|
};
|
|
17
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.createNpmAndOhPackageVersionsAreEqualCheck =
|
|
12
|
+
exports.createNpmAndOhPackageVersionsAreEqualCheck = createNpmAndOhPackageVersionsAreEqualCheck;
|
|
19
13
|
function createNpmAndOhPackageVersionsAreEqualCheck(npmPackageVersion, ohPackageVersion) {
|
|
20
14
|
return {
|
|
21
15
|
checkIf: 'npm_and_oh_package_versions_are_equal',
|
|
@@ -29,4 +23,3 @@ function createNpmAndOhPackageVersionsAreEqualCheck(npmPackageVersion, ohPackage
|
|
|
29
23
|
}),
|
|
30
24
|
};
|
|
31
25
|
}
|
|
32
|
-
exports.createNpmAndOhPackageVersionsAreEqualCheck = createNpmAndOhPackageVersionsAreEqualCheck;
|
|
@@ -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) {
|
|
@@ -15,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
15
9
|
});
|
|
16
10
|
};
|
|
17
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.createOhPackageNameFollowsNamingConventionCheck =
|
|
12
|
+
exports.createOhPackageNameFollowsNamingConventionCheck = createOhPackageNameFollowsNamingConventionCheck;
|
|
19
13
|
function createOhPackageNameFollowsNamingConventionCheck(npmPackageName, ohPackageName) {
|
|
20
14
|
const npmPackageNameInfo = getPackageNameInfo(npmPackageName);
|
|
21
15
|
return {
|
|
@@ -42,7 +36,6 @@ function createOhPackageNameFollowsNamingConventionCheck(npmPackageName, ohPacka
|
|
|
42
36
|
}),
|
|
43
37
|
};
|
|
44
38
|
}
|
|
45
|
-
exports.createOhPackageNameFollowsNamingConventionCheck = createOhPackageNameFollowsNamingConventionCheck;
|
|
46
39
|
function getPackageNameInfo(packageName) {
|
|
47
40
|
if (packageName.startsWith('@') && packageName.includes('/')) {
|
|
48
41
|
const [part1, part2] = packageName.split('/');
|
|
@@ -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);
|
|
@@ -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);
|
|
@@ -1,8 +1,2 @@
|
|
|
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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -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 __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
9
3
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
10
4
|
var m = o[Symbol.asyncIterator], i;
|
|
@@ -34,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
34
28
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
29
|
};
|
|
36
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
-
exports.verifyRNOHPackage =
|
|
31
|
+
exports.verifyRNOHPackage = verifyRNOHPackage;
|
|
38
32
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
39
33
|
const tmp_1 = __importDefault(require("tmp"));
|
|
40
34
|
const core_1 = require("../core");
|
|
@@ -53,12 +47,10 @@ function verifyRNOHPackage(_a) {
|
|
|
53
47
|
if (!harPath) {
|
|
54
48
|
throw new core_1.DescriptiveError({
|
|
55
49
|
whatHappened: 'Attempted to verify har but no har was found',
|
|
56
|
-
whatCanUserDo:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
],
|
|
61
|
-
},
|
|
50
|
+
whatCanUserDo: [
|
|
51
|
+
'Run this command without --no-harmony-code flag.',
|
|
52
|
+
'Create har files by running DevEco Studio > Build > Make Module (MODULE_NAME). The har file can be later found in MODULE_NAME/build/default/outputs/default/MODULE_NAME.har. Copy that file to the PACKAGE_ROOT/harmony directory.',
|
|
53
|
+
],
|
|
62
54
|
});
|
|
63
55
|
}
|
|
64
56
|
const tmpDirPath = new core_1.AbsolutePath(tmp_1.default.dirSync().name);
|
|
@@ -76,7 +68,6 @@ function verifyRNOHPackage(_a) {
|
|
|
76
68
|
}
|
|
77
69
|
});
|
|
78
70
|
}
|
|
79
|
-
exports.verifyRNOHPackage = verifyRNOHPackage;
|
|
80
71
|
function runChecks(checks, checkNamesToSkip) {
|
|
81
72
|
return __asyncGenerator(this, arguments, function* runChecks_1() {
|
|
82
73
|
for (const { checkIf, run } of checks) {
|
package/jest.config.js
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
|
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
9
2
|
module.exports = {
|
|
10
3
|
preset: 'ts-jest',
|
package/package.json
CHANGED
|
@@ -1,63 +1,67 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-oh/react-native-harmony-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.18",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "tsc --outDir dist -p tsconfig.build.json",
|
|
11
|
-
"prepack": "npm run build",
|
|
10
|
+
"build": "tsc --outDir dist -p tsconfig.build.json && node ./scripts/copy-template.js",
|
|
11
|
+
"prepack": "npm run build && npm run _recreate-hvigor-plugin",
|
|
12
|
+
"_recreate-hvigor-plugin": "cd ../react-native-harmony-hvigor-plugin && npm i && npm run deploy && cd ../react-native-harmony-cli",
|
|
12
13
|
"verify": "tsc --noEmit && npm run test",
|
|
13
14
|
"test": "npm run build && jest",
|
|
14
15
|
"test:codegen": "jest ./src/codegen/.* && npm run build && jest tests/codegen.*",
|
|
15
16
|
"rn": "npm run build && react-native",
|
|
16
|
-
"
|
|
17
|
+
"dev": "tsc --outDir dist -p tsconfig.build.json --watch",
|
|
18
|
+
"prepublishOnly": "npm run build",
|
|
19
|
+
"deploy": "npm run verify && npm publish"
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"rnoh-cli": "dist/commands/init.js"
|
|
17
23
|
},
|
|
18
24
|
"keywords": [],
|
|
19
25
|
"author": "",
|
|
20
26
|
"license": "MIT",
|
|
21
27
|
"peerDependencies": {
|
|
22
|
-
"metro": "
|
|
28
|
+
"metro": "^0.81.0"
|
|
23
29
|
},
|
|
24
30
|
"main": "dist/index.js",
|
|
25
31
|
"devDependencies": {
|
|
32
|
+
"@react-native-community/cli": "^15.0.0",
|
|
26
33
|
"@react-native-community/cli-types": "^11.3.0",
|
|
27
34
|
"@types/adm-zip": "^0.5.5",
|
|
28
35
|
"@types/fs-extra": "^11.0.1",
|
|
29
36
|
"@types/jest": "^29.5.1",
|
|
30
|
-
"@types/jszip": "^3.4.1",
|
|
31
37
|
"@types/mustache": "^4.2.5",
|
|
32
38
|
"@types/tar": "^6.1.5",
|
|
33
39
|
"@types/tmp": "^0.2.3",
|
|
34
40
|
"directory-tree": "^3.5.1",
|
|
35
41
|
"execa": "npm:@esm2cjs/execa@^6.1.1-cjs.1",
|
|
36
42
|
"jest": "^29.5.0",
|
|
37
|
-
"react-native": "^0.
|
|
43
|
+
"react-native": "^0.77.1",
|
|
38
44
|
"ts-jest": "^29.1.0",
|
|
39
|
-
"ts-node": "^10.9.1",
|
|
40
45
|
"typescript": "^5.0.4"
|
|
41
46
|
},
|
|
42
47
|
"dependencies": {
|
|
43
|
-
"memfs": "^4.12.0",
|
|
44
48
|
"@react-native-community/cli-tools": "^13.6.5",
|
|
45
|
-
"@react-native/codegen": "0.
|
|
49
|
+
"@react-native/codegen": "0.77.1",
|
|
46
50
|
"@tsconfig/recommended": "^1.0.2",
|
|
47
|
-
"adm-zip": "^0.5.12",
|
|
48
51
|
"case": "^1.6.3",
|
|
49
52
|
"chalk": "^4",
|
|
53
|
+
"commander": "^14.0.0",
|
|
50
54
|
"fs-extra": "^11.1.1",
|
|
51
|
-
"
|
|
52
|
-
"ignore": "^5.2.4",
|
|
55
|
+
"inquirer": "^12.6.3",
|
|
53
56
|
"json5": "^2.2.3",
|
|
57
|
+
"memfs": "4.12.0",
|
|
54
58
|
"mustache": "^4.2.0",
|
|
55
59
|
"tar": "^6.1.15",
|
|
56
60
|
"tmp": "^0.2.1"
|
|
57
61
|
},
|
|
58
|
-
"homepage": "https://
|
|
62
|
+
"homepage": "https://gitcode.com/openharmony-sig/ohos_react_native",
|
|
59
63
|
"repository": {
|
|
60
|
-
"type": "
|
|
61
|
-
"url": "https://
|
|
64
|
+
"type": "gitcode",
|
|
65
|
+
"url": "https://gitcode.com/openharmony-sig/ohos_react_native"
|
|
62
66
|
}
|
|
63
67
|
}
|
package/react-native.config.js
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
|
const { config: harmonyConfig } = require('./dist');
|
|
9
2
|
|
|
10
3
|
/**
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const fs = require('fs-extra');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
const templatesSrc = path.join(__dirname, '../src/init/templates/harmony');
|
|
5
|
+
const templatesDest = path.join(__dirname, '../dist/init/templates/harmony');
|
|
6
|
+
async function copyTemplate() {
|
|
7
|
+
try {
|
|
8
|
+
if (await fs.pathExists(templatesDest)) {
|
|
9
|
+
await fs.remove(templatesDest);
|
|
10
|
+
}
|
|
11
|
+
await fs.copy(templatesSrc, templatesDest);
|
|
12
|
+
console.log('Templates folder copied successfully!');
|
|
13
|
+
} catch (err) {
|
|
14
|
+
console.error('Error copying templates folder:', err);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
copyTemplate();
|
package/src/assetResolver.ts
CHANGED
|
@@ -4,25 +4,131 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import pathUtils from 'path';
|
|
8
9
|
import type { AssetData } from 'metro';
|
|
10
|
+
import { Logger } from './io';
|
|
11
|
+
|
|
12
|
+
type Path = string;
|
|
13
|
+
type CopiedFiles = Record<Path, Path>;
|
|
14
|
+
|
|
15
|
+
const ALLOWED_SCALES: number[] = [1, 2, 3, 4];
|
|
16
|
+
|
|
17
|
+
function filterAssetScales(
|
|
18
|
+
scales: readonly number[],
|
|
19
|
+
): readonly number[] {
|
|
20
|
+
const result = scales.filter(scale => ALLOWED_SCALES.includes(scale));
|
|
21
|
+
if (result.length === 0 && scales.length > 0) {
|
|
22
|
+
// No matching scale found, but there are some available. Ideally we don't
|
|
23
|
+
// want to be in this situation and should throw, but for now as a fallback
|
|
24
|
+
// let's just use the closest larger image
|
|
25
|
+
const maxScale = ALLOWED_SCALES[ALLOWED_SCALES.length - 1];
|
|
26
|
+
for (const scale of scales) {
|
|
27
|
+
if (scale > maxScale) {
|
|
28
|
+
result.push(scale);
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// There is no larger scales available, use the largest we have
|
|
33
|
+
if (result.length === 0) {
|
|
34
|
+
result.push(scales[scales.length - 1]);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function copyAssets(
|
|
41
|
+
logger: Logger,
|
|
42
|
+
assetsData: readonly AssetData[],
|
|
43
|
+
assetsDest: Path
|
|
44
|
+
): Promise<void> {
|
|
45
|
+
if (assetsDest == null) {
|
|
46
|
+
logger.warn((s) => 'Assets destination folder is not set, skipping...');
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const filesToCopy: CopiedFiles = {};
|
|
51
|
+
const addAssetToCopy = (asset: AssetData) => {
|
|
52
|
+
const validScales = filterAssetScales(asset.scales);
|
|
53
|
+
asset.scales.forEach((scale, idx) => {
|
|
54
|
+
if (!validScales.includes(scale)) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const src = asset.files[idx];
|
|
58
|
+
const dest = pathUtils.join(assetsDest, getAssetDestRelativePath(asset, scale));
|
|
59
|
+
filesToCopy[src] = dest;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
assetsData.forEach(addAssetToCopy);
|
|
9
64
|
|
|
10
|
-
|
|
65
|
+
return copyFiles(logger, filesToCopy);
|
|
66
|
+
}
|
|
11
67
|
|
|
12
|
-
|
|
68
|
+
function getAssetDestRelativePath(asset: AssetData, scale: number = 1): string {
|
|
69
|
+
const suffix = scale === 1 ? '' : `@${scale}x`;
|
|
13
70
|
const fileName = getResourceIdentifier(asset);
|
|
14
|
-
|
|
71
|
+
// Assets can have relative paths outside of the project root.
|
|
72
|
+
// Replace `../` with `_` to make sure they don't end up outside of
|
|
73
|
+
// the expected assets directory.
|
|
74
|
+
return `${fileName + suffix}.${asset.type}`.replace(/\.\.\//g, '_');
|
|
15
75
|
}
|
|
16
76
|
|
|
17
|
-
function getResourceIdentifier(asset:
|
|
77
|
+
function getResourceIdentifier(asset: AssetData): string {
|
|
18
78
|
const folderPath = getBasePath(asset);
|
|
19
|
-
return `${folderPath}/${asset.name}`.
|
|
79
|
+
return `${folderPath}/${asset.name}`.replace(/^assets\//, '');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function getBasePath(asset: AssetData): string {
|
|
83
|
+
const basePath = asset.httpServerLocation;
|
|
84
|
+
return basePath.startsWith('/') ? basePath.slice(1) : basePath;
|
|
20
85
|
}
|
|
21
86
|
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
if (
|
|
25
|
-
|
|
87
|
+
function copyFiles(logger: Logger, fileDestBySrc: CopiedFiles) {
|
|
88
|
+
const fileSources = Object.keys(fileDestBySrc);
|
|
89
|
+
if (fileSources.length === 0) {
|
|
90
|
+
return Promise.resolve();
|
|
26
91
|
}
|
|
27
|
-
|
|
92
|
+
|
|
93
|
+
const assetFilesCount = fileSources.length;
|
|
94
|
+
return new Promise<void>((resolve, reject) => {
|
|
95
|
+
const copyNext = (error?: Error) => {
|
|
96
|
+
if (error) {
|
|
97
|
+
reject(error);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
if (fileSources.length === 0) {
|
|
101
|
+
logger.info(
|
|
102
|
+
() =>
|
|
103
|
+
`Copied ${assetFilesCount} ${
|
|
104
|
+
assetFilesCount === 1 ? 'asset' : 'assets'
|
|
105
|
+
}`
|
|
106
|
+
);
|
|
107
|
+
resolve();
|
|
108
|
+
} else {
|
|
109
|
+
// fileSources.length === 0 is checked in previous branch, so this is string
|
|
110
|
+
const src = fileSources.shift()!;
|
|
111
|
+
const dest = fileDestBySrc[src];
|
|
112
|
+
copyFile(src, dest, copyNext);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
copyNext();
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function copyFile(
|
|
120
|
+
src: string,
|
|
121
|
+
dest: string,
|
|
122
|
+
onFinished: (error?: Error) => void
|
|
123
|
+
): void {
|
|
124
|
+
const destDir = pathUtils.dirname(dest);
|
|
125
|
+
fs.mkdir(destDir, { recursive: true }, (err?) => {
|
|
126
|
+
if (err) {
|
|
127
|
+
onFinished(err);
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
fs.createReadStream(src)
|
|
131
|
+
.pipe(fs.createWriteStream(dest))
|
|
132
|
+
.on('finish', onFinished);
|
|
133
|
+
});
|
|
28
134
|
}
|
|
@@ -1,14 +1,8 @@
|
|
|
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 { Autolinking, AutolinkingConfig } from './Autolinking';
|
|
9
2
|
import { NestedDirectoryJSON } from 'memfs';
|
|
10
|
-
import { AbsolutePath, DescriptiveError } from '../core';
|
|
3
|
+
import { AbsolutePath, DescriptiveError } from '../core/';
|
|
11
4
|
import { MockedLogger, MemFS } from '../io/__fixtures__';
|
|
5
|
+
import pathUtils from "node:path"
|
|
12
6
|
|
|
13
7
|
function createAutolinking({
|
|
14
8
|
fsStructure,
|
|
@@ -98,7 +92,7 @@ it('should generate correct templates with scoped package default configuration'
|
|
|
98
92
|
await runAutolinking();
|
|
99
93
|
|
|
100
94
|
expect(
|
|
101
|
-
memFS.readTextSync(new AbsolutePath('./harmony/oh-package.json5'))
|
|
95
|
+
memFS.readTextSync(new AbsolutePath('./harmony/oh-package.json5')).replace(/\\\\/g, '/')
|
|
102
96
|
).toBe(
|
|
103
97
|
`
|
|
104
98
|
{
|
|
@@ -162,7 +156,7 @@ std::vector<rnoh::Package::Shared> createRNOHPackages(const rnoh::Package::Conte
|
|
|
162
156
|
# DO NOT modify it manually, your changes WILL be overwritten.
|
|
163
157
|
cmake_minimum_required(VERSION 3.5)
|
|
164
158
|
|
|
165
|
-
# @
|
|
159
|
+
# @actor RNOH_APP
|
|
166
160
|
function(autolink_libraries target)
|
|
167
161
|
add_subdirectory("\${OH_MODULES_DIR}/@rnoh/rnoh--link-scoped/src/main/cpp" ./rnoh__rnoh__link_scoped)
|
|
168
162
|
|
|
@@ -210,9 +204,15 @@ it('should handle custom autolinking configuration', async () => {
|
|
|
210
204
|
expect(memFS.readTextSync(output.etsRNOHPackagesFactoryPath)).toContain(
|
|
211
205
|
'CustomEtsClass'
|
|
212
206
|
);
|
|
207
|
+
expect(memFS.readTextSync(output.etsRNOHPackagesFactoryPath)).not.toContain(
|
|
208
|
+
'CustomCppClass'
|
|
209
|
+
);
|
|
213
210
|
expect(memFS.readTextSync(output.cppRNOHPackagesFactoryPath)).toContain(
|
|
214
211
|
'CustomCppClass'
|
|
215
212
|
);
|
|
213
|
+
expect(memFS.readTextSync(output.cppRNOHPackagesFactoryPath)).not.toContain(
|
|
214
|
+
'CustomEtsClass'
|
|
215
|
+
);
|
|
216
216
|
expect(memFS.readTextSync(output.cmakeAutolinkingPath)).toContain(
|
|
217
217
|
'custom_cmake_target'
|
|
218
218
|
);
|
|
@@ -323,14 +323,14 @@ it('should log updated files', async () => {
|
|
|
323
323
|
const { logs } = await runAutolinking();
|
|
324
324
|
|
|
325
325
|
const combinedLogs = logs.map((log) => log.msg).join('\n');
|
|
326
|
-
expect(combinedLogs).toContain('harmony/entry/src/main/cpp/autolink.cmake');
|
|
327
|
-
expect(combinedLogs).toContain(
|
|
328
|
-
'harmony/entry/src/main/ets/RNOHPackageFactory.ets'
|
|
326
|
+
expect(combinedLogs).toContain(pathUtils.normalize('harmony/entry/src/main/cpp/autolink.cmake'));
|
|
327
|
+
expect(combinedLogs).toContain(pathUtils.normalize(
|
|
328
|
+
'harmony/entry/src/main/ets/RNOHPackageFactory.ets')
|
|
329
329
|
);
|
|
330
|
-
expect(combinedLogs).toContain(
|
|
331
|
-
'harmony/entry/src/main/cpp/RNOHPackageFactory.h'
|
|
330
|
+
expect(combinedLogs).toContain(pathUtils.normalize(
|
|
331
|
+
'harmony/entry/src/main/cpp/RNOHPackageFactory.h')
|
|
332
332
|
);
|
|
333
|
-
expect(combinedLogs).toContain('harmony/oh-package.json5');
|
|
333
|
+
expect(combinedLogs).toContain(pathUtils.normalize('harmony/oh-package.json5'));
|
|
334
334
|
});
|
|
335
335
|
|
|
336
336
|
it('should log linked and skipped packages', async () => {
|
|
@@ -446,7 +446,6 @@ it('should link only specified packages', async () => {
|
|
|
446
446
|
expect(combinedLogs).toContain('[skip] ignored-package');
|
|
447
447
|
});
|
|
448
448
|
|
|
449
|
-
|
|
450
449
|
it('should link by default only those packages that support autolinking', async () => {
|
|
451
450
|
const { runAutolinking } = createAutolinking({
|
|
452
451
|
fsStructure: {
|
|
@@ -480,4 +479,41 @@ it('should link by default only those packages that support autolinking', async
|
|
|
480
479
|
const combinedLogs = logs.map((log) => log.msg).join('\n');
|
|
481
480
|
expect(combinedLogs).toContain('[link] autolinkable-package');
|
|
482
481
|
expect(combinedLogs).toContain('[skip] not-autolinkable-package');
|
|
483
|
-
});
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it('not delete packages with two hars', async () => {
|
|
485
|
+
const { runAutolinking, memFS } = createAutolinking({
|
|
486
|
+
fsStructure: {
|
|
487
|
+
...baseFileStructure,
|
|
488
|
+
node_modules: {
|
|
489
|
+
'@rnoh': {
|
|
490
|
+
'multiple-har': {
|
|
491
|
+
harmony: {
|
|
492
|
+
'multiple_har.har': '',
|
|
493
|
+
'some_other_har.har': '',
|
|
494
|
+
},
|
|
495
|
+
'package.json': JSON.stringify({
|
|
496
|
+
name: '@rnoh/multiple-har',
|
|
497
|
+
harmony: {
|
|
498
|
+
autolinking: null,
|
|
499
|
+
},
|
|
500
|
+
}),
|
|
501
|
+
},
|
|
502
|
+
},
|
|
503
|
+
},
|
|
504
|
+
harmony: {
|
|
505
|
+
...baseFileStructure.harmony,
|
|
506
|
+
'oh-package.json5': `{
|
|
507
|
+
"dependencies": {
|
|
508
|
+
"@rnoh/multiple-har": "file:../node_modules/@rnoh/multiple-har/harmony/multiple_har.har",
|
|
509
|
+
}
|
|
510
|
+
}`,
|
|
511
|
+
},
|
|
512
|
+
},
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
const output = await runAutolinking();
|
|
516
|
+
|
|
517
|
+
const ohPackageContent = memFS.readTextSync(output.ohPackagePath);
|
|
518
|
+
expect(ohPackageContent).toContain('@rnoh/multiple-har');
|
|
519
|
+
});
|