@react-native-oh/react-native-harmony-cli 0.77.33 → 0.77.44
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/dist/assetResolver.js +43 -74
- package/dist/autolinking/Autolinking.js +178 -179
- package/dist/codegen/core/CodegenError.js +3 -23
- package/dist/codegen/core/EventUtils.js +3 -3
- package/dist/codegen/core/TypeAnnotationToTS.js +24 -28
- package/dist/codegen/core/UberSchema.js +55 -97
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +28 -41
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +27 -34
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +25 -33
- package/dist/codegen/generators/CppComponentCodeGenerator.js +23 -28
- package/dist/codegen/generators/LibGlueCodeGenerator.js +26 -29
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +25 -30
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
- package/dist/codegen/generators/UberGeneratorV1.js +24 -23
- package/dist/codegen/generators/UberGeneratorV2.js +34 -35
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +50 -24
- package/dist/codegen/templates/BasePackageHTemplate.js +120 -21
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +54 -8
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +75 -27
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +162 -29
- package/dist/codegen/templates/IndexTSTemplate.js +37 -17
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +119 -24
- package/dist/codegen/templates/TurboModuleCppTemplate.js +38 -15
- package/dist/codegen/templates/TurboModuleHTemplate.js +32 -11
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +52 -19
- package/dist/commands/bundle-harmony.js +118 -221
- package/dist/commands/clean-harmony.js +58 -63
- package/dist/commands/codegen-harmony.js +105 -165
- package/dist/commands/codegen-lib-harmony.js +76 -116
- package/dist/commands/init-harmony.js +151 -196
- package/dist/commands/init.js +537 -961
- package/dist/commands/link-harmony.js +35 -82
- package/dist/commands/run-harmony.js +372 -518
- package/dist/commands/verify-package-harmony.js +54 -117
- package/dist/core/AbsolutePath.js +33 -49
- package/dist/core/CodegenConfig.js +24 -22
- package/dist/core/DescriptiveError.js +18 -37
- package/dist/core/FileSystem.js +14 -18
- package/dist/core/OHPackageJSON5.js +17 -23
- package/dist/core/PackageJSON.js +26 -42
- package/dist/core/ProjectDependenciesManager.js +40 -92
- package/dist/core/ValidationError.js +2 -22
- package/dist/core/fs.js +10 -7
- package/dist/index.js +1 -1
- package/dist/init/templates/AppScopeAppJSON5Template.js +21 -8
- package/dist/init/templates/AppScopeStringVarTemplate.js +19 -8
- package/dist/init/templates/EntryIndexTemplate.js +56 -8
- package/dist/init/templates/EntryStringVarTemplate.js +27 -8
- package/dist/init/templates/HvigorConfigJson5Template.js +33 -8
- package/dist/init/templates/MetroConfigTemplate.js +38 -8
- package/dist/init/templates/OhPackageJson5Template.js +28 -8
- 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 +65 -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/io/CliExecutor.js +46 -98
- package/dist/io/Logger.js +40 -46
- package/dist/io/RealFS.js +43 -100
- package/dist/io/TarGz.js +11 -8
- package/dist/io/__fixtures__.js +79 -141
- package/dist/io/fsUtils.js +13 -12
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +19 -47
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +13 -41
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +8 -38
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +22 -54
- package/dist/package-verifier/verify-package.js +56 -133
- package/dist/simulator/LaunchSimulator.js +224 -301
- package/harmony/rnoh-hvigor-plugin-0.77.44.tgz +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0271b9dd +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/07ba0208 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/082dd09d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0a9e1b0b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/0c3d528a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1014d3ff +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/1184678c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/12621366 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/126d3e66 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/19262852 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/203fac53 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/237b660a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2528002d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2587d041 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2893bd11 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2af6ff9d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/2bf31f33 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/333648cc +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/386f6df0 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3b8c270e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/3bcc34ba +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/444808bd +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/44a775e2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/46da3ccd +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/51f80e35 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5203a2ca +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/52795646 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/577f8208 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c2aafe7 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/5c69bcfe +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62695b92 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/62698102 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6411ab00 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6569ba92 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/65e5133c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/66029655 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/69e85d0d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6afcb99e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/6de07367 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/72498307 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7babd1de +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/7fe56d21 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/810cbd72 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/812386d2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8448897d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/84ab0a41 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/853825e2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/862ad93a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/86b14da6 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/87f0fe62 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/88ee8f74 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c5237c9 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8c725800 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8e83cbe1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/8f4085b9 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/931f0b2e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/940c8f92 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/968191a3 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/970780c0 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/98bc4394 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/99a3b0b0 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9c0ffa6b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/9d9b42c2 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a04266ef +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a18f78c5 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a642fb0e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/a97edf40 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/aa672a20 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ae25c61a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/b2bebae6 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/ba492422 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/bd3e6c21 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/be9e564e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c342b18e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c3993e7e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c52ffd54 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c7079ad4 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/c8eb01c1 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/caee5d30 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/cf039161 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d0377c40 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d262bc85 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d287cb5c +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d64bff57 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d716a608 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/d751012b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e0873711 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e1fcf77b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/e8548d8a +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eaedd71d +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/eca0019e +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f7189953 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f75cb201 +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/f888164b +0 -0
- package/node-compile-cache/v22.14.0-x64-efe9a9df-0/fdb9eb5a +0 -0
- package/package.json +5 -1
package/dist/assetResolver.js
CHANGED
|
@@ -8,32 +8,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
13
|
};
|
|
38
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
15
|
exports.copyAssets = copyAssets;
|
|
@@ -43,18 +19,17 @@ exports.copyAssets = copyAssets;
|
|
|
43
19
|
* This source code is licensed under the MIT license found in the
|
|
44
20
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
45
21
|
*/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
22
|
+
const fs_1 = __importDefault(require("fs"));
|
|
23
|
+
const path_1 = __importDefault(require("path"));
|
|
24
|
+
const ALLOWED_SCALES = [1, 2, 3, 4];
|
|
49
25
|
function filterAssetScales(scales) {
|
|
50
|
-
|
|
26
|
+
const result = scales.filter(scale => ALLOWED_SCALES.includes(scale));
|
|
51
27
|
if (result.length === 0 && scales.length > 0) {
|
|
52
28
|
// No matching scale found, but there are some available. Ideally we don't
|
|
53
29
|
// want to be in this situation and should throw, but for now as a fallback
|
|
54
30
|
// let's just use the closest larger image
|
|
55
|
-
|
|
56
|
-
for (
|
|
57
|
-
var scale = scales_1[_i];
|
|
31
|
+
const maxScale = ALLOWED_SCALES[ALLOWED_SCALES.length - 1];
|
|
32
|
+
for (const scale of scales) {
|
|
58
33
|
if (scale > maxScale) {
|
|
59
34
|
result.push(scale);
|
|
60
35
|
break;
|
|
@@ -68,69 +43,63 @@ function filterAssetScales(scales) {
|
|
|
68
43
|
return result;
|
|
69
44
|
}
|
|
70
45
|
function copyAssets(logger, assetsData, assetsDest) {
|
|
71
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
assetsData.forEach(addAssetToCopy);
|
|
91
|
-
return [2 /*return*/, copyFiles(logger, filesToCopy)];
|
|
92
|
-
});
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
if (assetsDest == null) {
|
|
48
|
+
logger.warn((s) => 'Assets destination folder is not set, skipping...');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
const filesToCopy = {};
|
|
52
|
+
const addAssetToCopy = (asset) => {
|
|
53
|
+
const validScales = filterAssetScales(asset.scales);
|
|
54
|
+
asset.scales.forEach((scale, idx) => {
|
|
55
|
+
if (!validScales.includes(scale)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const src = asset.files[idx];
|
|
59
|
+
const dest = path_1.default.join(assetsDest, getAssetDestRelativePath(asset, scale));
|
|
60
|
+
filesToCopy[src] = dest;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
assetsData.forEach(addAssetToCopy);
|
|
64
|
+
return copyFiles(logger, filesToCopy);
|
|
93
65
|
});
|
|
94
66
|
}
|
|
95
|
-
function getAssetDestRelativePath(asset, scale) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var fileName = getResourceIdentifier(asset);
|
|
67
|
+
function getAssetDestRelativePath(asset, scale = 1) {
|
|
68
|
+
const suffix = scale === 1 ? '' : `@${scale}x`;
|
|
69
|
+
const fileName = getResourceIdentifier(asset);
|
|
99
70
|
// Assets can have relative paths outside of the project root.
|
|
100
71
|
// Replace `../` with `_` to make sure they don't end up outside of
|
|
101
72
|
// the expected assets directory.
|
|
102
|
-
return
|
|
73
|
+
return `${fileName + suffix}.${asset.type}`.replace(/\.\.\//g, '_');
|
|
103
74
|
}
|
|
104
75
|
function getResourceIdentifier(asset) {
|
|
105
|
-
|
|
106
|
-
return
|
|
76
|
+
const folderPath = getBasePath(asset);
|
|
77
|
+
return `${folderPath}/${asset.name}`.replace(/^assets\//, '');
|
|
107
78
|
}
|
|
108
79
|
function getBasePath(asset) {
|
|
109
|
-
|
|
80
|
+
const basePath = asset.httpServerLocation;
|
|
110
81
|
return basePath.startsWith('/') ? basePath.slice(1) : basePath;
|
|
111
82
|
}
|
|
112
83
|
function copyFiles(logger, fileDestBySrc) {
|
|
113
|
-
|
|
84
|
+
const fileSources = Object.keys(fileDestBySrc);
|
|
114
85
|
if (fileSources.length === 0) {
|
|
115
86
|
return Promise.resolve();
|
|
116
87
|
}
|
|
117
|
-
|
|
118
|
-
return new Promise(
|
|
119
|
-
|
|
88
|
+
const assetFilesCount = fileSources.length;
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
const copyNext = (error) => {
|
|
120
91
|
if (error) {
|
|
121
92
|
reject(error);
|
|
122
93
|
return;
|
|
123
94
|
}
|
|
124
95
|
if (fileSources.length === 0) {
|
|
125
|
-
logger.info(
|
|
126
|
-
return "Copied ".concat(assetFilesCount, " ").concat(assetFilesCount === 1 ? 'asset' : 'assets');
|
|
127
|
-
});
|
|
96
|
+
logger.info(() => `Copied ${assetFilesCount} ${assetFilesCount === 1 ? 'asset' : 'assets'}`);
|
|
128
97
|
resolve();
|
|
129
98
|
}
|
|
130
99
|
else {
|
|
131
100
|
// fileSources.length === 0 is checked in previous branch, so this is string
|
|
132
|
-
|
|
133
|
-
|
|
101
|
+
const src = fileSources.shift();
|
|
102
|
+
const dest = fileDestBySrc[src];
|
|
134
103
|
copyFile(src, dest, copyNext);
|
|
135
104
|
}
|
|
136
105
|
};
|
|
@@ -138,8 +107,8 @@ function copyFiles(logger, fileDestBySrc) {
|
|
|
138
107
|
});
|
|
139
108
|
}
|
|
140
109
|
function copyFile(src, dest, onFinished) {
|
|
141
|
-
|
|
142
|
-
fs_1.default.mkdir(destDir, { recursive: true },
|
|
110
|
+
const destDir = path_1.default.dirname(dest);
|
|
111
|
+
fs_1.default.mkdir(destDir, { recursive: true }, (err) => {
|
|
143
112
|
if (err) {
|
|
144
113
|
onFinished(err);
|
|
145
114
|
return;
|
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,152 +8,171 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
|
-
var
|
|
23
|
-
|
|
24
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
13
|
};
|
|
49
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
15
|
exports.Autolinking = void 0;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
16
|
+
const json5_1 = __importDefault(require("json5"));
|
|
17
|
+
const core_1 = require("../core");
|
|
18
|
+
const mustache_1 = __importDefault(require("mustache"));
|
|
19
|
+
const case_1 = __importDefault(require("case"));
|
|
20
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
21
|
+
const ETS_RNOH_PACKAGES_FACTORY_TEMPLATE = `
|
|
22
|
+
/*
|
|
23
|
+
* This file was generated by RNOH autolinking.
|
|
24
|
+
* DO NOT modify it manually, your changes WILL be overwritten.
|
|
25
|
+
*/
|
|
26
|
+
import type { RNPackageContext, RNOHPackage } from '@rnoh/react-native-openharmony';
|
|
27
|
+
{{#libraries}}
|
|
28
|
+
import {{etsRNOHPackageClassName}} from '{{{ohPackageName}}}';
|
|
29
|
+
{{/libraries}}
|
|
30
|
+
|
|
31
|
+
export function createRNOHPackages(ctx: RNPackageContext): RNOHPackage[] {
|
|
32
|
+
return [
|
|
33
|
+
{{#libraries}}
|
|
34
|
+
new {{etsRNOHPackageClassName}}(ctx),
|
|
35
|
+
{{/libraries}}
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
`.trimStart();
|
|
39
|
+
const CPP_RNOH_PACKAGES_FACTORY_TEMPLATE = `
|
|
40
|
+
/*
|
|
41
|
+
* This file was generated by RNOH autolinking.
|
|
42
|
+
* DO NOT modify it manually, your changes WILL be overwritten.
|
|
43
|
+
*/
|
|
44
|
+
// clang-format off
|
|
45
|
+
#pragma once
|
|
46
|
+
#include "RNOH/Package.h"
|
|
47
|
+
{{#libraries}}
|
|
48
|
+
#include "{{cppRNOHPackageClassName}}.h"
|
|
49
|
+
{{/libraries}}
|
|
50
|
+
|
|
51
|
+
std::vector<rnoh::Package::Shared> createRNOHPackages(const rnoh::Package::Context &ctx) {
|
|
52
|
+
return {
|
|
53
|
+
{{#libraries}}
|
|
54
|
+
std::make_shared<rnoh::{{cppRNOHPackageClassName}}>(ctx),
|
|
55
|
+
{{/libraries}}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
`.trimStart();
|
|
59
|
+
const CMAKE_AUTOLINKING_TEMPLATE = `
|
|
60
|
+
# This file was generated by RNOH autolinking.
|
|
61
|
+
# DO NOT modify it manually, your changes WILL be overwritten.
|
|
62
|
+
cmake_minimum_required(VERSION 3.5)
|
|
63
|
+
|
|
64
|
+
# @actor RNOH_APP
|
|
65
|
+
function(autolink_libraries target)
|
|
66
|
+
{{#libraries}}
|
|
67
|
+
add_subdirectory("\${OH_MODULES_DIR}/{{{ohPackageName}}}/src/main/cpp" ./{{cmakeLibraryTargetName}})
|
|
68
|
+
{{/libraries}}
|
|
69
|
+
|
|
70
|
+
set(AUTOLINKED_LIBRARIES
|
|
71
|
+
{{#libraries}}
|
|
72
|
+
{{cmakeLibraryTargetName}}
|
|
73
|
+
{{/libraries}}
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
foreach(lib \${AUTOLINKED_LIBRARIES})
|
|
77
|
+
target_link_libraries(\${target} PUBLIC \${lib})
|
|
78
|
+
endforeach()
|
|
79
|
+
endfunction()
|
|
80
|
+
`.trimStart();
|
|
81
|
+
class Autolinking {
|
|
82
|
+
constructor(fs, logger) {
|
|
61
83
|
this.fs = fs;
|
|
62
84
|
this.logger = logger;
|
|
63
85
|
}
|
|
64
|
-
|
|
65
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
-
var harmonyProjectPath, nodeModuleHarPaths, autolinkableLibraries, projectRootPath, skippedLibraryNpmPackageNames, ohPackagePath, ohPackageContent, cppRNOHPackagesFactoryPath, cmakeAutolinkingPath;
|
|
86
|
+
prepareInput(config) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
88
|
var _a;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
harFilePaths.length !== 1) {
|
|
105
|
-
skippedLibraryNpmPackageNames.push(packageJson.name);
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
var autolinkingConfig = providedAutolinkingConfig === true ? {} : providedAutolinkingConfig;
|
|
109
|
-
autolinkableLibraries.push({
|
|
110
|
-
npmPackageName: packageJson.name,
|
|
111
|
-
etsRNOHPackageClassName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.etsPackageClassName,
|
|
112
|
-
cppRNOHPackageClassName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.cppPackageClassName,
|
|
113
|
-
cmakeLibraryTargetName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.cmakeLibraryTargetName,
|
|
114
|
-
ohPackageName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.ohPackageName,
|
|
115
|
-
harFilePathRelativeToHarmony: harFilePaths[0]
|
|
116
|
-
.relativeTo(harmonyProjectPath)
|
|
117
|
-
.toString(),
|
|
118
|
-
});
|
|
119
|
-
})];
|
|
120
|
-
case 1:
|
|
121
|
-
_b.sent();
|
|
122
|
-
ohPackagePath = harmonyProjectPath.copyWithNewSegment(config.ohPackagePathRelativeToHarmony);
|
|
123
|
-
return [4 /*yield*/, this.fs.readText(ohPackagePath)];
|
|
124
|
-
case 2:
|
|
125
|
-
ohPackageContent = _b.sent();
|
|
126
|
-
cppRNOHPackagesFactoryPath = harmonyProjectPath.copyWithNewSegment(config.cppRNOHPackagesFactoryPathRelativeToHarmony);
|
|
127
|
-
cmakeAutolinkingPath = harmonyProjectPath.copyWithNewSegment(config.cmakeAutolinkPathRelativeToHarmony);
|
|
128
|
-
return [2 /*return*/, {
|
|
129
|
-
projectRootPath: projectRootPath,
|
|
130
|
-
skippedLibraryNpmPackageNames: skippedLibraryNpmPackageNames,
|
|
131
|
-
etsRNOHPackagesFactoryPath: harmonyProjectPath.copyWithNewSegment(config.etsRNOHPackagesFactoryPathRelativeToHarmony),
|
|
132
|
-
cppRNOHPackagesFactoryPath: cppRNOHPackagesFactoryPath,
|
|
133
|
-
cmakeAutolinkingPath: cmakeAutolinkingPath,
|
|
134
|
-
ohPackagePathAndContent: [ohPackagePath, ohPackageContent],
|
|
135
|
-
autolinkableLibraries: autolinkableLibraries,
|
|
136
|
-
nodeModuleHarFilePathsRelativeToHarmony: nodeModuleHarPaths.map(function (p) {
|
|
137
|
-
return p.relativeTo(harmonyProjectPath).toString();
|
|
138
|
-
}),
|
|
139
|
-
}];
|
|
89
|
+
if (config.includedNpmPackageNames.size > 0 &&
|
|
90
|
+
config.excludedNpmPackageNames.size > 0) {
|
|
91
|
+
throw new core_1.DescriptiveError({
|
|
92
|
+
whatHappened: 'Tried to exclude and include npm packages.',
|
|
93
|
+
whatCanUserDo: ['Include or exclude npm packages, but not both.'],
|
|
94
|
+
extraData: {
|
|
95
|
+
includedNpmPackageNamesCount: config.includedNpmPackageNames.size,
|
|
96
|
+
excludedNpmPackageNamesCount: config.excludedNpmPackageNames.size,
|
|
97
|
+
includedNpmPackageNames: config.includedNpmPackageNames,
|
|
98
|
+
excludedNpmPackageNames: config.excludedNpmPackageNames,
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const harmonyProjectPath = (_a = config.harmonyProjectPath) !== null && _a !== void 0 ? _a : new core_1.AbsolutePath('./');
|
|
103
|
+
const nodeModuleHarPaths = [];
|
|
104
|
+
const autolinkableLibraries = [];
|
|
105
|
+
const projectRootPath = config.nodeModulesPath.copyWithNewSegment('..');
|
|
106
|
+
const skippedLibraryNpmPackageNames = [];
|
|
107
|
+
yield new core_1.ProjectDependenciesManager(this.fs, projectRootPath).forEachAsync((dependency) => {
|
|
108
|
+
var _a;
|
|
109
|
+
const harFilePaths = dependency.getHarFilePaths();
|
|
110
|
+
if (harFilePaths.length === 0) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
nodeModuleHarPaths.push(...harFilePaths);
|
|
114
|
+
const packageJson = dependency.readPackageJSON();
|
|
115
|
+
const providedAutolinkingConfig = (_a = packageJson.harmony) === null || _a === void 0 ? void 0 : _a.autolinking;
|
|
116
|
+
if (providedAutolinkingConfig === undefined ||
|
|
117
|
+
providedAutolinkingConfig === null ||
|
|
118
|
+
(config.excludedNpmPackageNames.has(packageJson.name) &&
|
|
119
|
+
config.excludedNpmPackageNames.size > 0) ||
|
|
120
|
+
(!config.includedNpmPackageNames.has(packageJson.name) &&
|
|
121
|
+
config.includedNpmPackageNames.size > 0) ||
|
|
122
|
+
harFilePaths.length !== 1) {
|
|
123
|
+
skippedLibraryNpmPackageNames.push(packageJson.name);
|
|
124
|
+
return;
|
|
140
125
|
}
|
|
126
|
+
const autolinkingConfig = providedAutolinkingConfig === true ? {} : providedAutolinkingConfig;
|
|
127
|
+
autolinkableLibraries.push({
|
|
128
|
+
npmPackageName: packageJson.name,
|
|
129
|
+
etsRNOHPackageClassName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.etsPackageClassName,
|
|
130
|
+
cppRNOHPackageClassName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.cppPackageClassName,
|
|
131
|
+
cmakeLibraryTargetName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.cmakeLibraryTargetName,
|
|
132
|
+
ohPackageName: autolinkingConfig === null || autolinkingConfig === void 0 ? void 0 : autolinkingConfig.ohPackageName,
|
|
133
|
+
harFilePathRelativeToHarmony: harFilePaths[0]
|
|
134
|
+
.relativeTo(harmonyProjectPath)
|
|
135
|
+
.toString(),
|
|
136
|
+
});
|
|
141
137
|
});
|
|
138
|
+
const ohPackagePath = harmonyProjectPath.copyWithNewSegment(config.ohPackagePathRelativeToHarmony);
|
|
139
|
+
const ohPackageContent = yield this.fs.readText(ohPackagePath);
|
|
140
|
+
const cppRNOHPackagesFactoryPath = harmonyProjectPath.copyWithNewSegment(config.cppRNOHPackagesFactoryPathRelativeToHarmony);
|
|
141
|
+
const cmakeAutolinkingPath = harmonyProjectPath.copyWithNewSegment(config.cmakeAutolinkPathRelativeToHarmony);
|
|
142
|
+
return {
|
|
143
|
+
projectRootPath,
|
|
144
|
+
skippedLibraryNpmPackageNames,
|
|
145
|
+
etsRNOHPackagesFactoryPath: harmonyProjectPath.copyWithNewSegment(config.etsRNOHPackagesFactoryPathRelativeToHarmony),
|
|
146
|
+
cppRNOHPackagesFactoryPath,
|
|
147
|
+
cmakeAutolinkingPath: cmakeAutolinkingPath,
|
|
148
|
+
ohPackagePathAndContent: [ohPackagePath, ohPackageContent],
|
|
149
|
+
autolinkableLibraries,
|
|
150
|
+
nodeModuleHarFilePathsRelativeToHarmony: nodeModuleHarPaths.map((p) => p.relativeTo(harmonyProjectPath).toString()),
|
|
151
|
+
};
|
|
142
152
|
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
var autolinkableLibraries = input.autolinkableLibraries.map(function (lib) {
|
|
153
|
+
}
|
|
154
|
+
evaluate(input) {
|
|
155
|
+
const autolinkableLibraries = input.autolinkableLibraries.map((lib) => {
|
|
147
156
|
var _a, _b, _c, _d;
|
|
148
|
-
return
|
|
157
|
+
return Object.assign(Object.assign({}, lib), { etsRNOHPackageClassName: (_a = lib.etsRNOHPackageClassName) !== null && _a !== void 0 ? _a : this.npmPackageNameToRNOHPackageClassName(lib.npmPackageName), cppRNOHPackageClassName: (_b = lib.cppRNOHPackageClassName) !== null && _b !== void 0 ? _b : this.npmPackageNameToRNOHPackageClassName(lib.npmPackageName), cmakeLibraryTargetName: (_c = lib.cmakeLibraryTargetName) !== null && _c !== void 0 ? _c : this.npmPackageNameToCMakeLibraryTargetName(lib.npmPackageName), ohPackageName: (_d = lib.ohPackageName) !== null && _d !== void 0 ? _d : this.npmPackageNameToOHPackageName(lib.npmPackageName) });
|
|
149
158
|
});
|
|
150
|
-
autolinkableLibraries.sort(
|
|
159
|
+
autolinkableLibraries.sort((a, b) => {
|
|
151
160
|
if (a.npmPackageName < b.npmPackageName)
|
|
152
161
|
return -1;
|
|
153
162
|
if (a.npmPackageName > b.npmPackageName)
|
|
154
163
|
return 1;
|
|
155
164
|
return 0;
|
|
156
165
|
});
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
Object.entries(ohPackage.dependencies).forEach(
|
|
161
|
-
var name = _a[0], dependencySpecifier = _a[1];
|
|
166
|
+
const ohPackage = json5_1.default.parse(input.ohPackagePathAndContent[1]);
|
|
167
|
+
const autolinkableHarFilePathsRelativeToHarmony = autolinkableLibraries.map((lib) => lib.harFilePathRelativeToHarmony);
|
|
168
|
+
const unmanagedNativeDependencySpecifierByName = {};
|
|
169
|
+
Object.entries(ohPackage.dependencies).forEach(([name, dependencySpecifier]) => {
|
|
162
170
|
if (!(dependencySpecifier.includes('file:') &&
|
|
163
171
|
dependencySpecifier.includes('node_modules'))) {
|
|
164
172
|
unmanagedNativeDependencySpecifierByName[name] = dependencySpecifier;
|
|
165
173
|
}
|
|
166
174
|
else {
|
|
167
|
-
|
|
175
|
+
const harFilePathRelativeToHarmony = dependencySpecifier.replace('file:', '');
|
|
168
176
|
if (!autolinkableHarFilePathsRelativeToHarmony.includes(node_path_1.default.normalize(harFilePathRelativeToHarmony)) &&
|
|
169
177
|
input.nodeModuleHarFilePathsRelativeToHarmony.includes(node_path_1.default.normalize(harFilePathRelativeToHarmony))) {
|
|
170
178
|
unmanagedNativeDependencySpecifierByName[name] =
|
|
@@ -172,15 +180,14 @@ var Autolinking = /** @class */ (function () {
|
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
182
|
});
|
|
175
|
-
|
|
176
|
-
for (
|
|
177
|
-
var library = autolinkableLibraries_1[_i];
|
|
183
|
+
const managedNativeDependencySpecifierByName = {};
|
|
184
|
+
for (const library of autolinkableLibraries) {
|
|
178
185
|
managedNativeDependencySpecifierByName[library.ohPackageName] =
|
|
179
|
-
|
|
186
|
+
`file:${library.harFilePathRelativeToHarmony}`.split(node_path_1.default.sep).join('/');
|
|
180
187
|
}
|
|
181
188
|
return {
|
|
182
189
|
skippedLibraryNpmPackageNames: input.skippedLibraryNpmPackageNames,
|
|
183
|
-
linkedLibraryNpmPackageNames: autolinkableLibraries.map(
|
|
190
|
+
linkedLibraryNpmPackageNames: autolinkableLibraries.map((lib) => lib.npmPackageName),
|
|
184
191
|
projectRootPath: input.projectRootPath,
|
|
185
192
|
cppRNOHPackagesFactoryPathAndContent: [
|
|
186
193
|
input.cppRNOHPackagesFactoryPath,
|
|
@@ -202,70 +209,62 @@ var Autolinking = /** @class */ (function () {
|
|
|
202
209
|
],
|
|
203
210
|
ohPackagePathAndContent: [
|
|
204
211
|
input.ohPackagePathAndContent[0],
|
|
205
|
-
json5_1.default.stringify(
|
|
212
|
+
json5_1.default.stringify(Object.assign(Object.assign({}, ohPackage), { dependencies: Object.assign(Object.assign({}, unmanagedNativeDependencySpecifierByName), managedNativeDependencySpecifierByName) }), { space: 2, quote: '"' }) + '\n',
|
|
206
213
|
],
|
|
207
214
|
};
|
|
208
|
-
}
|
|
209
|
-
|
|
215
|
+
}
|
|
216
|
+
npmPackageNameToRNOHPackageClassName(fullNpmPackageName) {
|
|
210
217
|
if (fullNpmPackageName.startsWith('@')) {
|
|
211
|
-
|
|
218
|
+
const [scopeName, packageName] = fullNpmPackageName
|
|
212
219
|
.replace('@', '')
|
|
213
|
-
.split('/')
|
|
220
|
+
.split('/');
|
|
214
221
|
return case_1.default.pascal(scopeName) + case_1.default.pascal(packageName) + 'Package';
|
|
215
222
|
}
|
|
216
223
|
return case_1.default.pascal(fullNpmPackageName) + 'Package';
|
|
217
|
-
}
|
|
218
|
-
|
|
224
|
+
}
|
|
225
|
+
npmPackageNameToCMakeLibraryTargetName(fullNpmPackageName) {
|
|
219
226
|
if (fullNpmPackageName.startsWith('@')) {
|
|
220
|
-
|
|
227
|
+
const [scopeName, packageName] = fullNpmPackageName
|
|
221
228
|
.replace('@', '')
|
|
222
|
-
.split('/')
|
|
229
|
+
.split('/');
|
|
223
230
|
return 'rnoh__' + case_1.default.snake(scopeName) + '__' + case_1.default.snake(packageName);
|
|
224
231
|
}
|
|
225
232
|
return 'rnoh__' + case_1.default.snake(fullNpmPackageName);
|
|
226
|
-
}
|
|
227
|
-
|
|
233
|
+
}
|
|
234
|
+
npmPackageNameToOHPackageName(fullNpmPackageName) {
|
|
228
235
|
if (fullNpmPackageName.startsWith('@')) {
|
|
229
|
-
|
|
236
|
+
const [scopeName, packageName] = fullNpmPackageName
|
|
230
237
|
.replace('@', '')
|
|
231
|
-
.split('/')
|
|
238
|
+
.split('/');
|
|
232
239
|
return '@rnoh/' + case_1.default.kebab(scopeName) + '--' + case_1.default.kebab(packageName);
|
|
233
240
|
}
|
|
234
241
|
return '@rnoh/' + case_1.default.kebab(fullNpmPackageName);
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
var pathAndContentPairs = [];
|
|
242
|
+
}
|
|
243
|
+
saveAndLogOutput(output) {
|
|
244
|
+
const pathAndContentPairs = [];
|
|
239
245
|
pathAndContentPairs.push(output.etsRNOHPackagesFactoryPathAndContent);
|
|
240
246
|
pathAndContentPairs.push(output.cppRNOHPackagesFactoryPathAndContent);
|
|
241
247
|
pathAndContentPairs.push(output.cmakeAutolinkingPathAndContent);
|
|
242
248
|
pathAndContentPairs.push(output.ohPackagePathAndContent);
|
|
243
|
-
pathAndContentPairs.forEach(
|
|
244
|
-
|
|
245
|
-
_this.fs.writeTextSync(path, content);
|
|
249
|
+
pathAndContentPairs.forEach(([path, content]) => {
|
|
250
|
+
this.fs.writeTextSync(path, content);
|
|
246
251
|
});
|
|
247
|
-
output.linkedLibraryNpmPackageNames.forEach(
|
|
248
|
-
|
|
252
|
+
output.linkedLibraryNpmPackageNames.forEach((npmPackageName) => {
|
|
253
|
+
this.logger.debug((styles) => `[${styles.green(styles.bold('link'))}] ${npmPackageName}`);
|
|
249
254
|
});
|
|
250
|
-
output.skippedLibraryNpmPackageNames.forEach(
|
|
251
|
-
|
|
255
|
+
output.skippedLibraryNpmPackageNames.forEach((npmPackageName) => {
|
|
256
|
+
this.logger.debug((styles) => `[${styles.yellow(styles.bold('skip'))}] ${npmPackageName}`);
|
|
252
257
|
});
|
|
253
|
-
this.logger.debug(
|
|
254
|
-
|
|
255
|
-
.map(
|
|
256
|
-
var path = _a[0];
|
|
257
|
-
return path.relativeTo(output.projectRootPath).toString();
|
|
258
|
-
})
|
|
258
|
+
this.logger.debug(() => '');
|
|
259
|
+
const sortedPathsRelativeToRoot = pathAndContentPairs
|
|
260
|
+
.map(([path]) => path.relativeTo(output.projectRootPath).toString())
|
|
259
261
|
.sort();
|
|
260
|
-
sortedPathsRelativeToRoot.forEach(
|
|
261
|
-
|
|
262
|
-
});
|
|
263
|
-
this.logger.debug(function () { return ''; });
|
|
264
|
-
this.logger.info(function (styles) {
|
|
265
|
-
return "updated ".concat(styles.green(styles.bold(sortedPathsRelativeToRoot.length)), " file(s), linked ").concat(styles.green(styles.bold(output.linkedLibraryNpmPackageNames.length)), " libraries, skipped ").concat(styles.yellow(styles.bold(output.skippedLibraryNpmPackageNames.length)), " libraries");
|
|
262
|
+
sortedPathsRelativeToRoot.forEach((pathStr) => {
|
|
263
|
+
this.logger.debug((styles) => styles.gray(`• ${pathStr}`));
|
|
266
264
|
});
|
|
267
|
-
this.logger.debug(
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
265
|
+
this.logger.debug(() => '');
|
|
266
|
+
this.logger.info((styles) => `updated ${styles.green(styles.bold(sortedPathsRelativeToRoot.length))} file(s), linked ${styles.green(styles.bold(output.linkedLibraryNpmPackageNames.length))} libraries, skipped ${styles.yellow(styles.bold(output.skippedLibraryNpmPackageNames.length))} libraries`);
|
|
267
|
+
this.logger.debug(() => '');
|
|
268
|
+
}
|
|
269
|
+
}
|
|
271
270
|
exports.Autolinking = Autolinking;
|