@react-native-oh/react-native-harmony-cli 0.77.18 → 0.77.33
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 +74 -43
- package/dist/autolinking/Autolinking.js +179 -178
- package/dist/codegen/core/CodegenError.js +23 -3
- package/dist/codegen/core/EventUtils.js +3 -3
- package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
- package/dist/codegen/core/UberSchema.js +97 -55
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +41 -28
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
- package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
- package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
- package/dist/codegen/generators/UberGeneratorV1.js +24 -18
- package/dist/codegen/generators/UberGeneratorV2.js +36 -28
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
- package/dist/codegen/templates/BasePackageHTemplate.js +21 -120
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -54
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
- package/dist/codegen/templates/IndexTSTemplate.js +17 -37
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -119
- package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
- package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
- package/dist/commands/bundle-harmony.js +221 -118
- package/dist/commands/clean-harmony.js +63 -58
- package/dist/commands/codegen-harmony.js +175 -104
- package/dist/commands/codegen-lib-harmony.js +116 -76
- package/dist/commands/init-harmony.js +196 -151
- package/dist/commands/init.js +961 -537
- package/dist/commands/link-harmony.js +82 -35
- package/dist/commands/run-harmony.js +520 -352
- package/dist/commands/verify-package-harmony.js +117 -54
- package/dist/core/AbsolutePath.js +49 -33
- package/dist/core/CodegenConfig.js +22 -24
- package/dist/core/DescriptiveError.js +37 -18
- package/dist/core/FileSystem.js +18 -14
- package/dist/core/OHPackageJSON5.js +23 -17
- package/dist/core/PackageJSON.js +42 -26
- package/dist/core/ProjectDependenciesManager.js +92 -40
- package/dist/core/ValidationError.js +22 -2
- package/dist/core/fs.js +7 -10
- package/dist/index.js +1 -1
- package/dist/init/templates/AppScopeAppJSON5Template.js +8 -21
- package/dist/init/templates/AppScopeStringVarTemplate.js +8 -19
- package/dist/init/templates/EntryIndexTemplate.js +8 -56
- package/dist/init/templates/EntryStringVarTemplate.js +8 -27
- package/dist/init/templates/HvigorConfigJson5Template.js +8 -33
- package/dist/init/templates/MetroConfigTemplate.js +8 -38
- package/dist/init/templates/OhPackageJson5Template.js +8 -28
- package/dist/io/CliExecutor.js +98 -46
- package/dist/io/Logger.js +46 -40
- package/dist/io/RealFS.js +100 -43
- package/dist/io/TarGz.js +8 -11
- package/dist/io/__fixtures__.js +141 -79
- package/dist/io/fsUtils.js +12 -13
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
- package/dist/package-verifier/verify-package.js +133 -56
- package/dist/simulator/LaunchSimulator.js +395 -0
- package/dist/simulator/index.js +23 -0
- package/package.json +2 -11
- package/scripts/sync-hvigor.js +27 -0
- package/src/autolinking/Autolinking.ts +1 -1
- package/src/codegen/generators/UberGeneratorV1.ts +7 -2
- package/src/codegen/generators/UberGeneratorV2.ts +6 -1
- package/src/commands/codegen-harmony.ts +17 -7
- package/src/commands/run-harmony.ts +67 -41
- package/src/init/templates/harmony/entry/src/main/module.json5 +7 -0
- package/src/simulator/LaunchSimulator.ts +359 -0
- package/src/simulator/index.ts +8 -0
- package/dist/init/templates/harmony/AppScope/app.json5 +0 -10
- package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +0 -8
- package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/dist/init/templates/harmony/build-profile.json5 +0 -36
- package/dist/init/templates/harmony/codelinter.json +0 -32
- package/dist/init/templates/harmony/entry/build-profile.json5 +0 -18
- package/dist/init/templates/harmony/entry/gitignore +0 -7
- package/dist/init/templates/harmony/entry/hvigorfile.ts +0 -13
- package/dist/init/templates/harmony/entry/oh-package.json5 +0 -9
- package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +0 -27
- package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +0 -13
- package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +0 -4
- package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +0 -8
- package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +0 -2
- package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +0 -11
- package/dist/init/templates/harmony/entry/src/main/ets/gitignore +0 -1
- 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 +0 -16
- package/dist/init/templates/harmony/entry/src/main/module.json5 +0 -58
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +0 -8
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +0 -16
- 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 +0 -7
- 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 +0 -5
- package/dist/init/templates/harmony/entry/src/main/resources/gitignore +0 -1
- package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +0 -2
- package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +0 -13
- package/dist/init/templates/harmony/gitignore +0 -16
- package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +0 -22
- package/dist/init/templates/harmony/hvigorfile.ts +0 -7
package/dist/core/PackageJSON.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PackageJSON = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
var CodegenConfig_1 = require("./CodegenConfig");
|
|
5
|
+
var DescriptiveError_1 = require("./DescriptiveError");
|
|
6
|
+
var PackageJSON = /** @class */ (function () {
|
|
7
|
+
function PackageJSON(rawPackageJSON, packageRootPath, projectRootPath) {
|
|
8
|
+
this.rawPackageJSON = rawPackageJSON;
|
|
9
|
+
this.packageRootPath = packageRootPath;
|
|
10
|
+
this.projectRootPath = projectRootPath;
|
|
11
|
+
}
|
|
12
|
+
PackageJSON.fromProjectRootPath = function (fs, packageRootPath, projectRootPath) {
|
|
13
|
+
var packageJSONPath = packageRootPath.copyWithNewSegment('package.json');
|
|
9
14
|
if (!fs.existsSync(packageJSONPath)) {
|
|
10
15
|
throw new DescriptiveError_1.DescriptiveError({
|
|
11
16
|
whatHappened: "Couldn't find 'package.json'",
|
|
@@ -22,25 +27,33 @@ class PackageJSON {
|
|
|
22
27
|
catch (err) {
|
|
23
28
|
throw new DescriptiveError_1.DescriptiveError({
|
|
24
29
|
whatHappened: "Couldn't parse package.json",
|
|
25
|
-
extraData: { packageJSONPath, err },
|
|
30
|
+
extraData: { packageJSONPath: packageJSONPath, err: err },
|
|
26
31
|
});
|
|
27
32
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(PackageJSON.prototype, "name", {
|
|
35
|
+
get: function () {
|
|
36
|
+
return this.rawPackageJSON.name;
|
|
37
|
+
},
|
|
38
|
+
enumerable: false,
|
|
39
|
+
configurable: true
|
|
40
|
+
});
|
|
41
|
+
Object.defineProperty(PackageJSON.prototype, "version", {
|
|
42
|
+
get: function () {
|
|
43
|
+
return this.rawPackageJSON.version;
|
|
44
|
+
},
|
|
45
|
+
enumerable: false,
|
|
46
|
+
configurable: true
|
|
47
|
+
});
|
|
48
|
+
Object.defineProperty(PackageJSON.prototype, "harmony", {
|
|
49
|
+
get: function () {
|
|
50
|
+
return this.rawPackageJSON.harmony;
|
|
51
|
+
},
|
|
52
|
+
enumerable: false,
|
|
53
|
+
configurable: true
|
|
54
|
+
});
|
|
55
|
+
PackageJSON.prototype.getCodegenConfigs = function () {
|
|
56
|
+
var _this = this;
|
|
44
57
|
var _a;
|
|
45
58
|
/**
|
|
46
59
|
* Shared codegenConfig is not used on purpose. Android, iOS and other platforms shouldn't
|
|
@@ -48,16 +61,19 @@ class PackageJSON {
|
|
|
48
61
|
* that the shape of the shared config, to allow specifying which specific turbo modules or
|
|
49
62
|
* fabric components should be code generated.
|
|
50
63
|
*/
|
|
51
|
-
|
|
64
|
+
var rawCodegenConfig = (_a = this.rawPackageJSON.harmony) === null || _a === void 0 ? void 0 : _a.codegenConfig;
|
|
52
65
|
if (!rawCodegenConfig) {
|
|
53
66
|
return [];
|
|
54
67
|
}
|
|
55
68
|
if (Array.isArray(rawCodegenConfig)) {
|
|
56
|
-
return rawCodegenConfig.map((config)
|
|
69
|
+
return rawCodegenConfig.map(function (config) {
|
|
70
|
+
return CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(config, _this.packageRootPath, _this.projectRootPath, _this.name);
|
|
71
|
+
});
|
|
57
72
|
}
|
|
58
73
|
return [
|
|
59
74
|
CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(rawCodegenConfig, this.packageRootPath, this.projectRootPath, this.name),
|
|
60
75
|
];
|
|
61
|
-
}
|
|
62
|
-
|
|
76
|
+
};
|
|
77
|
+
return PackageJSON;
|
|
78
|
+
}());
|
|
63
79
|
exports.PackageJSON = PackageJSON;
|
|
@@ -8,68 +8,120 @@ 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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
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
|
+
}
|
|
37
|
+
};
|
|
11
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
39
|
exports.ProjectDependenciesManager = exports.ProjectDependency = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
40
|
+
var PackageJSON_1 = require("./PackageJSON");
|
|
41
|
+
var ProjectDependency = /** @class */ (function () {
|
|
42
|
+
function ProjectDependency(fs, packageRootPath, projectRootPath) {
|
|
16
43
|
this.fs = fs;
|
|
17
44
|
this.packageRootPath = packageRootPath;
|
|
18
45
|
this.projectRootPath = projectRootPath;
|
|
19
46
|
}
|
|
20
|
-
getRootPath() {
|
|
47
|
+
ProjectDependency.prototype.getRootPath = function () {
|
|
21
48
|
return this.packageRootPath;
|
|
22
|
-
}
|
|
23
|
-
getCodegenConfigs() {
|
|
49
|
+
};
|
|
50
|
+
ProjectDependency.prototype.getCodegenConfigs = function () {
|
|
24
51
|
return this.readPackageJSON().getCodegenConfigs();
|
|
25
|
-
}
|
|
26
|
-
getHarFilePaths() {
|
|
27
|
-
|
|
52
|
+
};
|
|
53
|
+
ProjectDependency.prototype.getHarFilePaths = function () {
|
|
54
|
+
var packageHarmonyPath = this.packageRootPath.copyWithNewSegment('harmony');
|
|
28
55
|
if (this.fs.existsSync(packageHarmonyPath)) {
|
|
29
56
|
return this.fs.findFilePathsWithExtensions(packageHarmonyPath, ['har']);
|
|
30
57
|
}
|
|
31
58
|
else {
|
|
32
59
|
return this.fs.findFilePathsWithExtensions(this.packageRootPath, ['har']);
|
|
33
60
|
}
|
|
34
|
-
}
|
|
35
|
-
readPackageJSON() {
|
|
61
|
+
};
|
|
62
|
+
ProjectDependency.prototype.readPackageJSON = function () {
|
|
36
63
|
return PackageJSON_1.PackageJSON.fromProjectRootPath(this.fs, this.packageRootPath, this.projectRootPath);
|
|
37
|
-
}
|
|
38
|
-
|
|
64
|
+
};
|
|
65
|
+
return ProjectDependency;
|
|
66
|
+
}());
|
|
39
67
|
exports.ProjectDependency = ProjectDependency;
|
|
40
|
-
|
|
41
|
-
|
|
68
|
+
var ProjectDependenciesManager = /** @class */ (function () {
|
|
69
|
+
function ProjectDependenciesManager(fs, projectRootPath) {
|
|
42
70
|
this.fs = fs;
|
|
43
71
|
this.projectRootPath = projectRootPath;
|
|
44
72
|
}
|
|
45
|
-
forEachAsync(cb) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function
|
|
47
|
-
|
|
73
|
+
ProjectDependenciesManager.prototype.forEachAsync = function (cb) {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0: return [4 /*yield*/, this.forEachDependencyInDirectory(cb, this.projectRootPath.copyWithNewSegment('node_modules'))];
|
|
78
|
+
case 1:
|
|
79
|
+
_a.sent();
|
|
80
|
+
return [2 /*return*/];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
48
83
|
});
|
|
49
|
-
}
|
|
50
|
-
forEachDependencyInDirectory(cb, directoryPath) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
84
|
+
};
|
|
85
|
+
ProjectDependenciesManager.prototype.forEachDependencyInDirectory = function (cb, directoryPath) {
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var _i, _a, dirent, potentialDependencyRootPath;
|
|
88
|
+
return __generator(this, function (_b) {
|
|
89
|
+
switch (_b.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
if (!this.fs.existsSync(directoryPath)) {
|
|
92
|
+
return [2 /*return*/];
|
|
93
|
+
}
|
|
94
|
+
_i = 0, _a = this.fs.readDirentsSync(directoryPath);
|
|
95
|
+
_b.label = 1;
|
|
96
|
+
case 1:
|
|
97
|
+
if (!(_i < _a.length)) return [3 /*break*/, 7];
|
|
98
|
+
dirent = _a[_i];
|
|
99
|
+
if (!(dirent.isDirectory() || dirent.isSymbolicLink())) return [3 /*break*/, 6];
|
|
100
|
+
if (!dirent.name.startsWith('.')) return [3 /*break*/, 2];
|
|
101
|
+
return [3 /*break*/, 6];
|
|
102
|
+
case 2:
|
|
103
|
+
if (!dirent.name.startsWith('@')) return [3 /*break*/, 4];
|
|
104
|
+
return [4 /*yield*/, this.forEachDependencyInDirectory(cb, directoryPath.copyWithNewSegment(dirent.name))];
|
|
105
|
+
case 3:
|
|
106
|
+
_b.sent();
|
|
107
|
+
return [3 /*break*/, 6];
|
|
108
|
+
case 4:
|
|
109
|
+
potentialDependencyRootPath = directoryPath.copyWithNewSegment(dirent.name);
|
|
65
110
|
if (!this.fs.existsSync(potentialDependencyRootPath.copyWithNewSegment('package.json'))) {
|
|
66
|
-
|
|
111
|
+
return [3 /*break*/, 6];
|
|
67
112
|
}
|
|
68
|
-
yield cb(new ProjectDependency(this.fs, potentialDependencyRootPath, this.projectRootPath));
|
|
69
|
-
|
|
113
|
+
return [4 /*yield*/, cb(new ProjectDependency(this.fs, potentialDependencyRootPath, this.projectRootPath))];
|
|
114
|
+
case 5:
|
|
115
|
+
_b.sent();
|
|
116
|
+
_b.label = 6;
|
|
117
|
+
case 6:
|
|
118
|
+
_i++;
|
|
119
|
+
return [3 /*break*/, 1];
|
|
120
|
+
case 7: return [2 /*return*/];
|
|
70
121
|
}
|
|
71
|
-
}
|
|
122
|
+
});
|
|
72
123
|
});
|
|
73
|
-
}
|
|
74
|
-
|
|
124
|
+
};
|
|
125
|
+
return ProjectDependenciesManager;
|
|
126
|
+
}());
|
|
75
127
|
exports.ProjectDependenciesManager = ProjectDependenciesManager;
|
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.ValidationError = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
19
|
+
var ValidationError = /** @class */ (function (_super) {
|
|
20
|
+
__extends(ValidationError, _super);
|
|
21
|
+
function ValidationError() {
|
|
22
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
23
|
+
}
|
|
24
|
+
return ValidationError;
|
|
25
|
+
}(Error));
|
|
6
26
|
exports.ValidationError = ValidationError;
|
package/dist/core/fs.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.maybeMakeDirectories = maybeMakeDirectories;
|
|
7
4
|
exports.maybeRemoveFilesInDirectory = maybeRemoveFilesInDirectory;
|
|
8
5
|
exports.maybeReadFile = maybeReadFile;
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
var node_fs_1 = require("node:fs");
|
|
7
|
+
var DescriptiveError_1 = require("./DescriptiveError");
|
|
11
8
|
function maybeMakeDirectories(path) {
|
|
12
9
|
if (!node_fs_1.default.existsSync(path.getValue())) {
|
|
13
10
|
node_fs_1.default.mkdirSync(path.getValue(), { recursive: true });
|
|
@@ -20,12 +17,12 @@ function maybeRemoveFilesInDirectory(path) {
|
|
|
20
17
|
if (!node_fs_1.default.lstatSync(path.getValue()).isDirectory()) {
|
|
21
18
|
throw new DescriptiveError_1.DescriptiveError({
|
|
22
19
|
whatHappened: "Tried to remove all files from a path that doesn't point to a directory",
|
|
23
|
-
whatCanUserDo: [
|
|
20
|
+
whatCanUserDo: ["Verify path: ".concat(path.getValue())],
|
|
24
21
|
});
|
|
25
22
|
}
|
|
26
|
-
|
|
27
|
-
fileOrDirNames.forEach((fileOrDirName)
|
|
28
|
-
|
|
23
|
+
var fileOrDirNames = node_fs_1.default.readdirSync(path.getValue());
|
|
24
|
+
fileOrDirNames.forEach(function (fileOrDirName) {
|
|
25
|
+
var maybeFilePath = path.copyWithNewSegment(fileOrDirName);
|
|
29
26
|
if (node_fs_1.default.statSync(maybeFilePath.getValue()).isDirectory()) {
|
|
30
27
|
return;
|
|
31
28
|
}
|
|
@@ -41,7 +38,7 @@ function maybeReadFile(path) {
|
|
|
41
38
|
if (!node_fs_1.default.lstatSync(path.getValue()).isFile()) {
|
|
42
39
|
throw new DescriptiveError_1.DescriptiveError({
|
|
43
40
|
whatHappened: "Tried to read a path that doesn't point to a file",
|
|
44
|
-
whatCanUserDo: [
|
|
41
|
+
whatCanUserDo: ["Verify path: ".concat(path.getValue())],
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
44
|
return node_fs_1.default.readFileSync(path.getValue(), 'utf-8');
|
package/dist/index.js
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.AppScopeAppJSON5Template = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
"bundleName": "{{bundleName}}",
|
|
12
|
-
"vendor": "example",
|
|
13
|
-
"versionCode": 1000000,
|
|
14
|
-
"versionName": "1.0.0",
|
|
15
|
-
"icon": "$media:app_icon",
|
|
16
|
-
"label": "$string:app_name",
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
`;
|
|
20
|
-
class AppScopeAppJSON5Template {
|
|
21
|
-
constructor(bundleName) {
|
|
4
|
+
var mustache_1 = require("mustache");
|
|
5
|
+
var TEMPLATE = "\n{\n \"app\": {\n \"bundleName\": \"{{bundleName}}\",\n \"vendor\": \"example\",\n \"versionCode\": 1000000,\n \"versionName\": \"1.0.0\",\n \"icon\": \"$media:app_icon\",\n \"label\": \"$string:app_name\",\n }\n}\n";
|
|
6
|
+
var AppScopeAppJSON5Template = /** @class */ (function () {
|
|
7
|
+
function AppScopeAppJSON5Template(bundleName) {
|
|
22
8
|
this.bundleName = bundleName;
|
|
23
9
|
}
|
|
24
|
-
build() {
|
|
10
|
+
AppScopeAppJSON5Template.prototype.build = function () {
|
|
25
11
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
26
12
|
bundleName: this.bundleName,
|
|
27
13
|
});
|
|
28
|
-
}
|
|
29
|
-
|
|
14
|
+
};
|
|
15
|
+
return AppScopeAppJSON5Template;
|
|
16
|
+
}());
|
|
30
17
|
exports.AppScopeAppJSON5Template = AppScopeAppJSON5Template;
|
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.AppScopeStringVarTemplate = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
"name": "app_name",
|
|
13
|
-
"value": "{{name}}"
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
}
|
|
17
|
-
`;
|
|
18
|
-
class AppScopeStringVarTemplate {
|
|
19
|
-
constructor(name) {
|
|
4
|
+
var mustache_1 = require("mustache");
|
|
5
|
+
var TEMPLATE = "\n{\n \"string\": [\n {\n \"name\": \"app_name\",\n \"value\": \"{{name}}\"\n }\n ]\n}\n";
|
|
6
|
+
var AppScopeStringVarTemplate = /** @class */ (function () {
|
|
7
|
+
function AppScopeStringVarTemplate(name) {
|
|
20
8
|
this.name = name;
|
|
21
9
|
}
|
|
22
|
-
build() {
|
|
10
|
+
AppScopeStringVarTemplate.prototype.build = function () {
|
|
23
11
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
24
12
|
name: this.name,
|
|
25
13
|
});
|
|
26
|
-
}
|
|
27
|
-
|
|
14
|
+
};
|
|
15
|
+
return AppScopeStringVarTemplate;
|
|
16
|
+
}());
|
|
28
17
|
exports.AppScopeStringVarTemplate = AppScopeStringVarTemplate;
|
|
@@ -1,65 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.EntryIndexTemplate = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
MetroJSBundleProvider,
|
|
12
|
-
RNApp,
|
|
13
|
-
RNOHErrorDialog,
|
|
14
|
-
ResourceJSBundleProvider,
|
|
15
|
-
RNOHCoreContext
|
|
16
|
-
} from '@rnoh/react-native-openharmony';
|
|
17
|
-
import { getRNOHPackages } from '../PackageProvider';
|
|
18
|
-
|
|
19
|
-
@Entry
|
|
20
|
-
@Component
|
|
21
|
-
struct Index {
|
|
22
|
-
@StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined
|
|
23
|
-
|
|
24
|
-
build() {
|
|
25
|
-
Column() {
|
|
26
|
-
if (this.rnohCoreContext) {
|
|
27
|
-
if (this.rnohCoreContext?.isDebugModeEnabled) {
|
|
28
|
-
RNOHErrorDialog({ ctx: this.rnohCoreContext })
|
|
29
|
-
}
|
|
30
|
-
RNApp({
|
|
31
|
-
rnInstanceConfig: {
|
|
32
|
-
name: "{{name}}",
|
|
33
|
-
createRNPackages: getRNOHPackages,
|
|
34
|
-
fontResourceByFontFamily: {},
|
|
35
|
-
enableDebugger: this.rnohCoreContext?.isDebugModeEnabled,
|
|
36
|
-
},
|
|
37
|
-
appKey: "{{name}}",
|
|
38
|
-
jsBundleProvider: this.rnohCoreContext?.isDebugModeEnabled ?
|
|
39
|
-
new AnyJSBundleProvider([
|
|
40
|
-
new MetroJSBundleProvider(),
|
|
41
|
-
new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
|
|
42
|
-
]) :
|
|
43
|
-
/**
|
|
44
|
-
* NOTE: The HBC format is recommended for Hermes in a production environment. HBC provides better performance and loading times.
|
|
45
|
-
*/
|
|
46
|
-
new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
.height('100%')
|
|
51
|
-
.width('100%')
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`;
|
|
55
|
-
class EntryIndexTemplate {
|
|
56
|
-
constructor(name) {
|
|
4
|
+
var mustache_1 = require("mustache");
|
|
5
|
+
var TEMPLATE = "\nimport {\n AnyJSBundleProvider,\n MetroJSBundleProvider,\n RNApp,\n RNOHErrorDialog,\n ResourceJSBundleProvider,\n RNOHCoreContext\n} from '@rnoh/react-native-openharmony';\nimport { getRNOHPackages } from '../PackageProvider';\n\n@Entry\n@Component\nstruct Index {\n @StorageLink('RNOHCoreContext') private rnohCoreContext: RNOHCoreContext | undefined = undefined\n\n build() {\n Column() {\n if (this.rnohCoreContext) {\n if (this.rnohCoreContext?.isDebugModeEnabled) {\n RNOHErrorDialog({ ctx: this.rnohCoreContext })\n }\n RNApp({\n rnInstanceConfig: {\n name: \"{{name}}\",\n createRNPackages: getRNOHPackages,\n fontResourceByFontFamily: {},\n enableDebugger: this.rnohCoreContext?.isDebugModeEnabled,\n },\n appKey: \"{{name}}\",\n jsBundleProvider: this.rnohCoreContext?.isDebugModeEnabled ?\n new AnyJSBundleProvider([\n new MetroJSBundleProvider(),\n new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),\n ]) :\n /**\n * NOTE: The HBC format is recommended for Hermes in a production environment. HBC provides better performance and loading times.\n */\n new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),\n })\n }\n }\n .height('100%')\n .width('100%')\n }\n}\n";
|
|
6
|
+
var EntryIndexTemplate = /** @class */ (function () {
|
|
7
|
+
function EntryIndexTemplate(name) {
|
|
57
8
|
this.name = name;
|
|
58
9
|
}
|
|
59
|
-
build() {
|
|
10
|
+
EntryIndexTemplate.prototype.build = function () {
|
|
60
11
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
61
12
|
name: this.name,
|
|
62
13
|
});
|
|
63
|
-
}
|
|
64
|
-
|
|
14
|
+
};
|
|
15
|
+
return EntryIndexTemplate;
|
|
16
|
+
}());
|
|
65
17
|
exports.EntryIndexTemplate = EntryIndexTemplate;
|
|
@@ -1,38 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.EntryStringVarTemplate = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
"name": "module_desc",
|
|
13
|
-
"value": "{{description}}"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"name": "EntryAbility_desc",
|
|
17
|
-
"value": "{{description}}"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"name": "EntryAbility_label",
|
|
21
|
-
"value": "{{name}}"
|
|
22
|
-
}
|
|
23
|
-
]
|
|
24
|
-
}
|
|
25
|
-
`;
|
|
26
|
-
class EntryStringVarTemplate {
|
|
27
|
-
constructor(name, description) {
|
|
4
|
+
var mustache_1 = require("mustache");
|
|
5
|
+
var TEMPLATE = "\n{\n \"string\": [\n {\n \"name\": \"module_desc\",\n \"value\": \"{{description}}\"\n },\n {\n \"name\": \"EntryAbility_desc\",\n \"value\": \"{{description}}\"\n },\n {\n \"name\": \"EntryAbility_label\",\n \"value\": \"{{name}}\"\n }\n ]\n}\n";
|
|
6
|
+
var EntryStringVarTemplate = /** @class */ (function () {
|
|
7
|
+
function EntryStringVarTemplate(name, description) {
|
|
28
8
|
this.name = name;
|
|
29
9
|
this.description = description;
|
|
30
10
|
}
|
|
31
|
-
build() {
|
|
11
|
+
EntryStringVarTemplate.prototype.build = function () {
|
|
32
12
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
33
13
|
name: this.name,
|
|
34
14
|
description: this.description,
|
|
35
15
|
});
|
|
36
|
-
}
|
|
37
|
-
|
|
16
|
+
};
|
|
17
|
+
return EntryStringVarTemplate;
|
|
18
|
+
}());
|
|
38
19
|
exports.EntryStringVarTemplate = EntryStringVarTemplate;
|
|
@@ -1,44 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.HvigorConfigJson5Template = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"@rnoh/hvigor-plugin": "../../node_modules/{{{rnohCliNpmPackageName}}}/harmony/{{{rnohHvigorPluginFilename}}}", // <PROJECT_ROOT>/node_modules/<RNOH_CLI>/harmony/rnoh-hvigor-plugin-X.X.X.tgz
|
|
13
|
-
},
|
|
14
|
-
"execution": {
|
|
15
|
-
// "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */
|
|
16
|
-
// "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
|
|
17
|
-
// "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
|
|
18
|
-
// "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
|
|
19
|
-
// "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
|
|
20
|
-
},
|
|
21
|
-
"logging": {
|
|
22
|
-
// "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
|
|
23
|
-
},
|
|
24
|
-
"debugging": {
|
|
25
|
-
// "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
|
|
26
|
-
},
|
|
27
|
-
"nodeOptions": {
|
|
28
|
-
// "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
`;
|
|
32
|
-
class HvigorConfigJson5Template {
|
|
33
|
-
constructor(rnohCliNpmPackageName, rnohHvigorPluginFilename) {
|
|
4
|
+
var mustache_1 = require("mustache");
|
|
5
|
+
var TEMPLATE = "\n{\n \"modelVersion\": \"5.0.0\",\n \"dependencies\": {\n \"@rnoh/hvigor-plugin\": \"../../node_modules/{{{rnohCliNpmPackageName}}}/harmony/{{{rnohHvigorPluginFilename}}}\", // <PROJECT_ROOT>/node_modules/<RNOH_CLI>/harmony/rnoh-hvigor-plugin-X.X.X.tgz\n },\n \"execution\": {\n // \"analyze\": \"default\", /* Define the build analyze mode. Value: [ \"default\" | \"verbose\" | false ]. Default: \"default\" */\n // \"daemon\": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */\n // \"incremental\": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */\n // \"parallel\": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */\n // \"typeCheck\": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */\n },\n \"logging\": {\n // \"level\": \"info\" /* Define the log level. Value: [ \"debug\" | \"info\" | \"warn\" | \"error\" ]. Default: \"info\" */\n },\n \"debugging\": {\n // \"stacktrace\": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */\n },\n \"nodeOptions\": {\n // \"maxOldSpaceSize\": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */\n }\n}\n";
|
|
6
|
+
var HvigorConfigJson5Template = /** @class */ (function () {
|
|
7
|
+
function HvigorConfigJson5Template(rnohCliNpmPackageName, rnohHvigorPluginFilename) {
|
|
34
8
|
this.rnohCliNpmPackageName = rnohCliNpmPackageName;
|
|
35
9
|
this.rnohHvigorPluginFilename = rnohHvigorPluginFilename;
|
|
36
10
|
}
|
|
37
|
-
build() {
|
|
11
|
+
HvigorConfigJson5Template.prototype.build = function () {
|
|
38
12
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
39
13
|
rnohCliNpmPackageName: this.rnohCliNpmPackageName,
|
|
40
14
|
rnohHvigorPluginFilename: this.rnohHvigorPluginFilename,
|
|
41
15
|
});
|
|
42
|
-
}
|
|
43
|
-
|
|
16
|
+
};
|
|
17
|
+
return HvigorConfigJson5Template;
|
|
18
|
+
}());
|
|
44
19
|
exports.HvigorConfigJson5Template = HvigorConfigJson5Template;
|
|
@@ -1,47 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.MetroConfigTemplate = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
createHarmonyMetroConfig,
|
|
12
|
-
} = require('{{{reactNativeHarmonyPackageName}}}/metro.config');
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @type {import("metro-config").MetroConfig}
|
|
16
|
-
*/
|
|
17
|
-
const config = {
|
|
18
|
-
transformer: {
|
|
19
|
-
getTransformOptions: async () => ({
|
|
20
|
-
transform: {
|
|
21
|
-
experimentalImportSupport: false,
|
|
22
|
-
inlineRequires: true,
|
|
23
|
-
},
|
|
24
|
-
}),
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
module.exports = mergeConfig(
|
|
29
|
-
getDefaultConfig(__dirname),
|
|
30
|
-
createHarmonyMetroConfig({
|
|
31
|
-
reactNativeHarmonyPackageName: '{{{reactNativeHarmonyPackageName}}}',
|
|
32
|
-
}),
|
|
33
|
-
config,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
`;
|
|
37
|
-
class MetroConfigTemplate {
|
|
38
|
-
constructor(reactNativeHarmonyPackageName) {
|
|
4
|
+
var mustache_1 = require("mustache");
|
|
5
|
+
var TEMPLATE = "\nconst {mergeConfig, getDefaultConfig} = require('@react-native/metro-config');\nconst {\n createHarmonyMetroConfig,\n} = require('{{{reactNativeHarmonyPackageName}}}/metro.config');\n\n/**\n * @type {import(\"metro-config\").MetroConfig}\n */\nconst config = {\n transformer: {\n getTransformOptions: async () => ({\n transform: {\n experimentalImportSupport: false,\n inlineRequires: true,\n },\n }),\n },\n};\n\nmodule.exports = mergeConfig(\n getDefaultConfig(__dirname),\n createHarmonyMetroConfig({\n reactNativeHarmonyPackageName: '{{{reactNativeHarmonyPackageName}}}',\n }),\n config,\n);\n\n";
|
|
6
|
+
var MetroConfigTemplate = /** @class */ (function () {
|
|
7
|
+
function MetroConfigTemplate(reactNativeHarmonyPackageName) {
|
|
39
8
|
this.reactNativeHarmonyPackageName = reactNativeHarmonyPackageName;
|
|
40
9
|
}
|
|
41
|
-
build() {
|
|
10
|
+
MetroConfigTemplate.prototype.build = function () {
|
|
42
11
|
return mustache_1.default.render(TEMPLATE.trimStart(), {
|
|
43
12
|
reactNativeHarmonyPackageName: this.reactNativeHarmonyPackageName,
|
|
44
13
|
});
|
|
45
|
-
}
|
|
46
|
-
|
|
14
|
+
};
|
|
15
|
+
return MetroConfigTemplate;
|
|
16
|
+
}());
|
|
47
17
|
exports.MetroConfigTemplate = MetroConfigTemplate;
|