@react-native-oh/react-native-harmony-cli 0.0.26 → 0.0.28
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/README.md +12 -0
- package/dist/assetResolver.js +25 -0
- package/dist/autolinking/Autolinking.js +275 -0
- package/dist/autolinking/index.js +23 -0
- package/dist/codegen/core/CodeGenerator.js +8 -0
- package/dist/codegen/core/CodegenError.js +13 -0
- package/dist/codegen/core/EventUtils.js +25 -0
- package/dist/codegen/core/TypeAnnotationToTS.js +138 -0
- package/dist/codegen/core/UberSchema.js +109 -0
- package/dist/codegen/core/index.js +27 -0
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +67 -0
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +82 -0
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +80 -0
- package/dist/codegen/generators/CppComponentCodeGenerator.js +62 -0
- package/dist/codegen/generators/LibGlueCodeGenerator.js +56 -0
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +79 -0
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +40 -0
- package/dist/codegen/generators/UberGeneratorV1.js +56 -0
- package/dist/codegen/generators/UberGeneratorV2.js +77 -0
- package/dist/codegen/generators/index.js +30 -0
- package/dist/codegen/index.js +24 -0
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +111 -0
- package/dist/codegen/templates/BasePackageHTemplate.js +136 -0
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +68 -0
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +91 -0
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +198 -0
- package/dist/codegen/templates/IndexTSTemplate.js +58 -0
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +130 -0
- package/dist/codegen/templates/TurboModuleCppTemplate.js +59 -0
- package/dist/codegen/templates/TurboModuleHTemplate.js +48 -0
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +81 -0
- package/dist/codegen/templates/index.js +31 -0
- package/dist/commands/bundle-harmony.js +185 -0
- package/dist/commands/codegen-harmony.js +207 -0
- package/dist/commands/codegen-lib-harmony.js +259 -0
- package/dist/commands/create-metro-host-constants.js +67 -0
- package/dist/commands/index.js +30 -0
- package/dist/commands/link-harmony.js +97 -0
- package/dist/commands/pack-harmony.js +106 -0
- package/dist/commands/unpack-harmony.js +191 -0
- package/dist/commands/verify-package-harmony.js +128 -0
- package/dist/core/AbsolutePath.js +59 -0
- package/dist/core/CodegenConfig.js +63 -0
- package/dist/core/DescriptiveError.js +55 -0
- package/dist/core/FileSystem.js +33 -0
- package/dist/core/OHPackageJSON5.js +29 -0
- package/dist/core/PackageJSON.js +66 -0
- package/dist/core/ProjectDependenciesManager.js +83 -0
- package/dist/core/ValidationError.js +12 -0
- package/dist/core/ValueObject.js +8 -0
- package/dist/core/fs.js +42 -0
- package/dist/core/index.js +32 -0
- package/dist/index.js +22 -0
- package/dist/io/CliExecutor.js +35 -0
- package/dist/io/Logger.js +80 -0
- package/dist/io/RealFS.js +68 -0
- package/dist/io/TarGz.js +34 -0
- package/dist/io/__fixtures__.js +127 -0
- package/dist/io/fsUtils.js +37 -0
- package/dist/io/index.js +26 -0
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +44 -0
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +38 -0
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +32 -0
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +57 -0
- package/dist/package-verifier/checks/index.js +26 -0
- package/dist/package-verifier/index.js +24 -0
- package/dist/package-verifier/types.js +8 -0
- package/dist/package-verifier/verify-package.js +107 -0
- package/jest.config.js +7 -0
- package/package.json +8 -2
- package/react-native.config.js +7 -0
- package/src/assetResolver.ts +7 -0
- package/src/autolinking/Autolinking.test.ts +483 -0
- package/src/autolinking/Autolinking.ts +384 -0
- package/src/autolinking/index.ts +8 -0
- package/src/codegen/core/CodeGenerator.ts +7 -0
- package/src/codegen/core/CodegenError.ts +7 -0
- package/src/codegen/core/EventUtils.ts +7 -0
- package/src/codegen/core/TypeAnnotationToTS.test.ts +7 -0
- package/src/codegen/core/TypeAnnotationToTS.ts +7 -0
- package/src/codegen/core/UberSchema.ts +15 -1
- package/src/codegen/core/index.ts +7 -0
- package/src/codegen/generators/{GlueCodeGenerator.ts → AppBuildTimeGlueCodeGenerator.ts} +20 -9
- package/src/codegen/generators/{ComponentCodeGeneratorArkTS.ts → ArkTSComponentCodeGeneratorArkTS.ts} +18 -5
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +119 -0
- package/src/codegen/generators/{ComponentCodeGeneratorCAPI.ts → CppComponentCodeGenerator.ts} +21 -43
- package/src/codegen/generators/LibGlueCodeGenerator.ts +98 -0
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +14 -5
- package/src/codegen/generators/SharedComponentCodeGenerator.ts +57 -0
- package/src/codegen/generators/UberGeneratorV1.ts +19 -8
- package/src/codegen/generators/UberGeneratorV2.ts +39 -16
- package/src/codegen/generators/index.ts +12 -3
- package/src/codegen/index.ts +7 -0
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +19 -7
- package/src/codegen/templates/{GeneratedPackageHTemplate.ts → BasePackageHTemplate.ts} +52 -12
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +9 -1
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +15 -10
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +20 -8
- package/src/codegen/templates/IndexTSTemplate.ts +18 -9
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +8 -0
- package/src/codegen/templates/TurboModuleCppTemplate.ts +16 -9
- package/src/codegen/templates/TurboModuleHTemplate.ts +16 -9
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +20 -9
- package/src/codegen/templates/index.ts +7 -0
- package/src/commands/bundle-harmony.ts +8 -1
- package/src/commands/codegen-harmony.ts +43 -13
- package/src/commands/codegen-lib-harmony.ts +394 -0
- package/src/commands/create-metro-host-constants.ts +7 -0
- package/src/commands/index.ts +9 -0
- package/src/commands/link-harmony.ts +102 -0
- package/src/commands/pack-harmony.ts +7 -0
- package/src/commands/unpack-harmony.ts +12 -3
- package/src/commands/verify-package-harmony.ts +7 -0
- package/src/core/AbsolutePath.ts +16 -0
- package/src/core/CodegenConfig.ts +7 -0
- package/src/core/DescriptiveError.ts +7 -0
- package/src/core/FileSystem.ts +57 -0
- package/src/core/OHPackageJSON5.ts +7 -0
- package/src/core/PackageJSON.ts +40 -8
- package/src/core/ProjectDependenciesManager.ts +40 -14
- package/src/core/ValidationError.ts +7 -0
- package/src/core/ValueObject.ts +7 -0
- package/src/core/fs.ts +7 -0
- package/src/core/index.ts +8 -0
- package/src/index.ts +11 -0
- package/src/io/CliExecutor.ts +47 -0
- package/src/io/Logger.ts +11 -0
- package/src/io/RealFS.ts +62 -0
- package/src/io/TarGz.ts +7 -0
- package/src/io/__fixtures__.ts +135 -0
- package/src/io/fsUtils.ts +26 -6
- package/src/io/index.ts +8 -0
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +7 -0
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +7 -0
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +7 -0
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +7 -0
- package/src/package-verifier/checks/index.ts +7 -0
- package/src/package-verifier/index.ts +7 -0
- package/src/package-verifier/types.ts +7 -0
- package/src/package-verifier/verify-package.ts +9 -1
package/dist/io/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./Logger"), exports);
|
|
24
|
+
__exportStar(require("./fsUtils"), exports);
|
|
25
|
+
__exportStar(require("./TarGz"), exports);
|
|
26
|
+
__exportStar(require("./RealFS"), exports);
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.createHarmonyDirContainsOnlyHarsCheck = void 0;
|
|
22
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
23
|
+
function createHarmonyDirContainsOnlyHarsCheck(npmPackagePath, hasNpmPackageNativeCode) {
|
|
24
|
+
return {
|
|
25
|
+
checkIf: 'harmony_directory_contains_only_one_har_file',
|
|
26
|
+
run: () => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
if (!hasNpmPackageNativeCode) {
|
|
28
|
+
return 'skip';
|
|
29
|
+
}
|
|
30
|
+
const harmonyPath = npmPackagePath
|
|
31
|
+
.copyWithNewSegment('harmony')
|
|
32
|
+
.getValue();
|
|
33
|
+
const fileOrDirNames = node_fs_1.default.readdirSync(harmonyPath);
|
|
34
|
+
if (fileOrDirNames.length !== 1) {
|
|
35
|
+
return { status: 'fail', message: JSON.stringify(fileOrDirNames) };
|
|
36
|
+
}
|
|
37
|
+
if (!fileOrDirNames[0].endsWith('.har')) {
|
|
38
|
+
return 'fail';
|
|
39
|
+
}
|
|
40
|
+
return 'pass';
|
|
41
|
+
}),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
exports.createHarmonyDirContainsOnlyHarsCheck = createHarmonyDirContainsOnlyHarsCheck;
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.createHarmonyDirExistsCheck = void 0;
|
|
22
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
23
|
+
function createHarmonyDirExistsCheck(packagePath, hasNativeCode) {
|
|
24
|
+
return {
|
|
25
|
+
checkIf: 'package_has_harmony_dir',
|
|
26
|
+
run: () => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const harmonyDirExist = node_fs_1.default.existsSync(packagePath.copyWithNewSegment('harmony').getValue());
|
|
28
|
+
if (!hasNativeCode) {
|
|
29
|
+
return 'skip';
|
|
30
|
+
}
|
|
31
|
+
if (!harmonyDirExist) {
|
|
32
|
+
return 'fail';
|
|
33
|
+
}
|
|
34
|
+
return 'pass';
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.createHarmonyDirExistsCheck = createHarmonyDirExistsCheck;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.createNpmAndOhPackageVersionsAreEqualCheck = void 0;
|
|
19
|
+
function createNpmAndOhPackageVersionsAreEqualCheck(npmPackageVersion, ohPackageVersion) {
|
|
20
|
+
return {
|
|
21
|
+
checkIf: 'npm_and_oh_package_versions_are_equal',
|
|
22
|
+
run: () => __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
return npmPackageVersion === ohPackageVersion
|
|
24
|
+
? 'pass'
|
|
25
|
+
: {
|
|
26
|
+
status: 'fail',
|
|
27
|
+
message: `expected OH package version (${ohPackageVersion}) to match NPM version (${npmPackageVersion})`,
|
|
28
|
+
};
|
|
29
|
+
}),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.createNpmAndOhPackageVersionsAreEqualCheck = createNpmAndOhPackageVersionsAreEqualCheck;
|
|
@@ -0,0 +1,57 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.createOhPackageNameFollowsNamingConventionCheck = void 0;
|
|
19
|
+
function createOhPackageNameFollowsNamingConventionCheck(npmPackageName, ohPackageName) {
|
|
20
|
+
const npmPackageNameInfo = getPackageNameInfo(npmPackageName);
|
|
21
|
+
return {
|
|
22
|
+
checkIf: 'oh_package_name_is_derived_from_npm_package_name',
|
|
23
|
+
run: () => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
if (npmPackageNameInfo.organizationName) {
|
|
25
|
+
const expectedOHPackageName = `@rnoh/${npmPackageNameInfo.organizationName}--${npmPackageNameInfo.unscopedName}`;
|
|
26
|
+
return expectedOHPackageName === ohPackageName
|
|
27
|
+
? 'pass'
|
|
28
|
+
: {
|
|
29
|
+
status: 'fail',
|
|
30
|
+
message: `expected '${expectedOHPackageName}', got: ${ohPackageName}`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const expectedOHPackageName = `@rnoh/${npmPackageNameInfo.unscopedName}`;
|
|
35
|
+
return expectedOHPackageName === ohPackageName
|
|
36
|
+
? 'pass'
|
|
37
|
+
: {
|
|
38
|
+
status: 'fail',
|
|
39
|
+
message: `expected '${expectedOHPackageName}', got: ${ohPackageName}`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
exports.createOhPackageNameFollowsNamingConventionCheck = createOhPackageNameFollowsNamingConventionCheck;
|
|
46
|
+
function getPackageNameInfo(packageName) {
|
|
47
|
+
if (packageName.startsWith('@') && packageName.includes('/')) {
|
|
48
|
+
const [part1, part2] = packageName.split('/');
|
|
49
|
+
return {
|
|
50
|
+
organizationName: part1.replace('@', ''),
|
|
51
|
+
unscopedName: part2,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return { organizationName: null, unscopedName: packageName };
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./HarmonyDirExistsCheck"), exports);
|
|
24
|
+
__exportStar(require("./HarmonyDirContainsOnlyHarsCheck"), exports);
|
|
25
|
+
__exportStar(require("./NpmAnAndOhPackageVersionsAreEqual"), exports);
|
|
26
|
+
__exportStar(require("./OhPackageNameFollowsNamingConventionCheck"), exports);
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
__exportStar(require("./types"), exports);
|
|
24
|
+
__exportStar(require("./verify-package"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
9
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
10
|
+
var m = o[Symbol.asyncIterator], i;
|
|
11
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
12
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
13
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
14
|
+
};
|
|
15
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
16
|
+
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {
|
|
17
|
+
var i, p;
|
|
18
|
+
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
19
|
+
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
|
|
20
|
+
};
|
|
21
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
22
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
23
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
24
|
+
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
25
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
26
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
27
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
28
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
29
|
+
function fulfill(value) { resume("next", value); }
|
|
30
|
+
function reject(value) { resume("throw", value); }
|
|
31
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
32
|
+
};
|
|
33
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.verifyRNOHPackage = void 0;
|
|
38
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
39
|
+
const tmp_1 = __importDefault(require("tmp"));
|
|
40
|
+
const core_1 = require("../core");
|
|
41
|
+
const checks_1 = require("./checks");
|
|
42
|
+
const io_1 = require("../io");
|
|
43
|
+
function verifyRNOHPackage(_a) {
|
|
44
|
+
return __asyncGenerator(this, arguments, function* verifyRNOHPackage_1({ npmPackagePath, hasHarmonyCode, checkNamesToSkip, }) {
|
|
45
|
+
const npmPackageJson = core_1.PackageJSON.fromProjectRootPath(new io_1.RealFS(), npmPackagePath, npmPackagePath);
|
|
46
|
+
const initialChecks = [
|
|
47
|
+
(0, checks_1.createHarmonyDirExistsCheck)(npmPackagePath, hasHarmonyCode),
|
|
48
|
+
(0, checks_1.createHarmonyDirContainsOnlyHarsCheck)(npmPackagePath, hasHarmonyCode),
|
|
49
|
+
];
|
|
50
|
+
yield __await(yield* __asyncDelegator(__asyncValues(runChecks(initialChecks, checkNamesToSkip))));
|
|
51
|
+
if (hasHarmonyCode) {
|
|
52
|
+
const harPath = findHarPath(npmPackagePath);
|
|
53
|
+
if (!harPath) {
|
|
54
|
+
throw new core_1.DescriptiveError({
|
|
55
|
+
whatHappened: 'Attempted to verify har but no har was found',
|
|
56
|
+
whatCanUserDo: {
|
|
57
|
+
default: [
|
|
58
|
+
'Run this command without --no-harmony-code flag.',
|
|
59
|
+
'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.',
|
|
60
|
+
],
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const tmpDirPath = new core_1.AbsolutePath(tmp_1.default.dirSync().name);
|
|
65
|
+
yield yield __await({
|
|
66
|
+
type: 'START_PROCESS',
|
|
67
|
+
name: `Unpacking the har file to the tmpdir`,
|
|
68
|
+
});
|
|
69
|
+
yield __await((0, io_1.unpackTarGz)(harPath, tmpDirPath));
|
|
70
|
+
const ohPackageJson5 = core_1.OHPackageJSON5.fromPath(tmpDirPath.copyWithNewSegment('package', 'oh-package.json5'));
|
|
71
|
+
const harChecks = [
|
|
72
|
+
(0, checks_1.createOhPackageNameFollowsNamingConventionCheck)(npmPackageJson.name, ohPackageJson5.name),
|
|
73
|
+
(0, checks_1.createNpmAndOhPackageVersionsAreEqualCheck)(npmPackageJson.version, ohPackageJson5.version),
|
|
74
|
+
];
|
|
75
|
+
yield __await(yield* __asyncDelegator(__asyncValues(runChecks(harChecks, checkNamesToSkip))));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
exports.verifyRNOHPackage = verifyRNOHPackage;
|
|
80
|
+
function runChecks(checks, checkNamesToSkip) {
|
|
81
|
+
return __asyncGenerator(this, arguments, function* runChecks_1() {
|
|
82
|
+
for (const { checkIf, run } of checks) {
|
|
83
|
+
if (checkNamesToSkip.includes(checkIf)) {
|
|
84
|
+
yield yield __await({
|
|
85
|
+
type: 'FINISHED_CHECKING',
|
|
86
|
+
name: checkIf,
|
|
87
|
+
status: 'skip',
|
|
88
|
+
message: '',
|
|
89
|
+
});
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const result = yield __await(run());
|
|
93
|
+
const status = typeof result === 'string' ? result : result.status;
|
|
94
|
+
const message = typeof result === 'string' ? '' : result.message;
|
|
95
|
+
yield yield __await({ type: 'FINISHED_CHECKING', name: checkIf, status, message });
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
function findHarPath(packagePath) {
|
|
100
|
+
const packageHarmonyPath = packagePath.copyWithNewSegment('harmony');
|
|
101
|
+
const fileOrDirNames = node_fs_1.default.readdirSync(packageHarmonyPath.getValue());
|
|
102
|
+
const harFilenames = fileOrDirNames.filter((fileOrDirName) => fileOrDirName.endsWith('.har'));
|
|
103
|
+
if (harFilenames.length != 1) {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
return packageHarmonyPath.copyWithNewSegment(harFilenames[0]);
|
|
107
|
+
}
|
package/jest.config.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
|
2
9
|
module.exports = {
|
|
3
10
|
preset: 'ts-jest',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-oh/react-native-harmony-cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.28",
|
|
4
4
|
"description": "",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"keywords": [],
|
|
19
19
|
"author": "",
|
|
20
|
-
"license": "
|
|
20
|
+
"license": "MIT",
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"metro": "*"
|
|
23
23
|
},
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"typescript": "^5.0.4"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"memfs": "^4.12.0",
|
|
43
44
|
"@react-native-community/cli-tools": "^13.6.5",
|
|
44
45
|
"@react-native/codegen": "0.74.0",
|
|
45
46
|
"@tsconfig/recommended": "^1.0.2",
|
|
@@ -53,5 +54,10 @@
|
|
|
53
54
|
"mustache": "^4.2.0",
|
|
54
55
|
"tar": "^6.1.15",
|
|
55
56
|
"tmp": "^0.2.1"
|
|
57
|
+
},
|
|
58
|
+
"homepage": "https://gitee.com/openharmony-sig/ohos_react_native",
|
|
59
|
+
"repository": {
|
|
60
|
+
"type": "gitee",
|
|
61
|
+
"url": "https://gitee.com/openharmony-sig/ohos_react_native"
|
|
56
62
|
}
|
|
57
63
|
}
|
package/react-native.config.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
const { config: harmonyConfig } = require('./dist');
|
|
2
9
|
|
|
3
10
|
/**
|
package/src/assetResolver.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
|
|
1
8
|
import type { AssetData } from 'metro';
|
|
2
9
|
|
|
3
10
|
export type Asset = AssetData;
|