@react-native-oh/react-native-harmony-cli 0.0.37 → 0.0.40
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 +11 -11
- package/dist/assetResolver.js +74 -43
- package/dist/autolinking/Autolinking.js +183 -179
- 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 +96 -57
- 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 -53
- 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 +138 -53
- package/dist/commands/codegen-harmony.js +175 -104
- package/dist/commands/codegen-lib-harmony.js +116 -76
- package/dist/commands/create-metro-host-constants.js +47 -18
- package/dist/commands/init.js +961 -537
- package/dist/commands/link-harmony.js +71 -33
- package/dist/commands/pack-harmony.js +108 -47
- package/dist/commands/run-harmony.js +518 -374
- package/dist/commands/unpack-harmony.js +198 -105
- package/dist/commands/verify-package-harmony.js +108 -54
- package/dist/core/AbsolutePath.js +47 -31
- 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 +96 -46
- package/dist/core/ValidationError.js +22 -2
- package/dist/core/fs.js +6 -9
- package/dist/index.js +1 -1
- package/dist/io/CliExecutor.js +98 -46
- package/dist/io/Logger.js +46 -40
- package/dist/io/RealFS.js +88 -35
- 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 +132 -55
- package/dist/simulator/LaunchSimulator.js +301 -217
- package/jest.config.js +12 -12
- package/package.json +78 -70
- package/react-native.config.js +17 -17
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
- package/.prettierrc +0 -6
- package/src/assetResolver.ts +0 -134
- package/src/autolinking/Autolinking.test.ts +0 -483
- package/src/autolinking/Autolinking.ts +0 -382
- package/src/autolinking/index.ts +0 -8
- package/src/codegen/core/CodeGenerator.ts +0 -16
- package/src/codegen/core/CodegenError.ts +0 -10
- package/src/codegen/core/EventUtils.ts +0 -23
- package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
- package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
- package/src/codegen/core/UberSchema.ts +0 -152
- package/src/codegen/core/index.ts +0 -12
- package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -124
- package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
- package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
- package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
- package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
- package/src/codegen/generators/UberGeneratorV1.ts +0 -75
- package/src/codegen/generators/UberGeneratorV2.ts +0 -114
- package/src/codegen/generators/index.ts +0 -15
- package/src/codegen/index.ts +0 -9
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
- package/src/codegen/templates/BasePackageHTemplate.ts +0 -159
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
- package/src/codegen/templates/IndexTSTemplate.ts +0 -62
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -150
- package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
- package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
- package/src/codegen/templates/index.ts +0 -16
- package/src/commands/bundle-harmony.ts +0 -134
- package/src/commands/codegen-harmony.ts +0 -297
- package/src/commands/codegen-lib-harmony.ts +0 -389
- package/src/commands/create-metro-host-constants.ts +0 -55
- package/src/commands/index.ts +0 -16
- package/src/commands/init.ts +0 -755
- package/src/commands/link-harmony.ts +0 -102
- package/src/commands/pack-harmony.ts +0 -128
- package/src/commands/run-harmony.ts +0 -506
- package/src/commands/types.ts +0 -21
- package/src/commands/unpack-harmony.ts +0 -238
- package/src/commands/verify-package-harmony.ts +0 -113
- package/src/core/AbsolutePath.ts +0 -66
- package/src/core/CodegenConfig.ts +0 -67
- package/src/core/DescriptiveError.ts +0 -68
- package/src/core/FileSystem.ts +0 -57
- package/src/core/OHPackageJSON5.ts +0 -30
- package/src/core/PackageJSON.ts +0 -104
- package/src/core/ProjectDependenciesManager.ts +0 -103
- package/src/core/ValidationError.ts +0 -8
- package/src/core/ValueObject.ts +0 -9
- package/src/core/fs.ts +0 -38
- package/src/core/index.ts +0 -17
- package/src/index.ts +0 -33
- package/src/io/CliExecutor.ts +0 -69
- package/src/io/Logger.ts +0 -112
- package/src/io/RealFS.ts +0 -62
- package/src/io/TarGz.ts +0 -33
- package/src/io/__fixtures__.ts +0 -139
- package/src/io/fsUtils.ts +0 -44
- package/src/io/index.ts +0 -11
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
- package/src/package-verifier/checks/index.ts +0 -11
- package/src/package-verifier/index.ts +0 -9
- package/src/package-verifier/types.ts +0 -19
- package/src/package-verifier/verify-package.ts +0 -123
- package/src/simulator/LaunchSimulator.ts +0 -352
- package/src/simulator/index.ts +0 -8
|
@@ -5,6 +5,33 @@
|
|
|
5
5
|
* This source code is licensed under the MIT license found in the
|
|
6
6
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
9
|
+
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);
|
|
10
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
11
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
12
|
+
function step(op) {
|
|
13
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
14
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
15
|
+
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;
|
|
16
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
17
|
+
switch (op[0]) {
|
|
18
|
+
case 0: case 1: t = op; break;
|
|
19
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
20
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
21
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
22
|
+
default:
|
|
23
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
24
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
25
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
26
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
27
|
+
if (t[2]) _.ops.pop();
|
|
28
|
+
_.trys.pop(); continue;
|
|
29
|
+
}
|
|
30
|
+
op = body.call(thisArg, _);
|
|
31
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
32
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
33
|
+
}
|
|
34
|
+
};
|
|
8
35
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
9
36
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
10
37
|
var m = o[Symbol.asyncIterator], i;
|
|
@@ -30,73 +57,123 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
|
|
|
30
57
|
function reject(value) { resume("throw", value); }
|
|
31
58
|
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
32
59
|
};
|
|
33
|
-
var
|
|
34
|
-
|
|
60
|
+
var __values = (this && this.__values) || function(o) {
|
|
61
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
62
|
+
if (m) return m.call(o);
|
|
63
|
+
if (o && typeof o.length === "number") return {
|
|
64
|
+
next: function () {
|
|
65
|
+
if (o && i >= o.length) o = void 0;
|
|
66
|
+
return { value: o && o[i++], done: !o };
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
35
70
|
};
|
|
36
71
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
72
|
exports.verifyRNOHPackage = verifyRNOHPackage;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
73
|
+
var node_fs_1 = require("node:fs");
|
|
74
|
+
var tmp_1 = require("tmp");
|
|
75
|
+
var core_1 = require("../core");
|
|
76
|
+
var checks_1 = require("./checks");
|
|
77
|
+
var io_1 = require("../io");
|
|
43
78
|
function verifyRNOHPackage(_a) {
|
|
44
|
-
return __asyncGenerator(this, arguments, function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
]
|
|
60
|
-
|
|
79
|
+
return __asyncGenerator(this, arguments, function verifyRNOHPackage_1(_b) {
|
|
80
|
+
var npmPackageJson, initialChecks, harPath, tmpDirPath, ohPackageJson5, harChecks;
|
|
81
|
+
var npmPackagePath = _b.npmPackagePath, hasHarmonyCode = _b.hasHarmonyCode, checkNamesToSkip = _b.checkNamesToSkip;
|
|
82
|
+
return __generator(this, function (_c) {
|
|
83
|
+
switch (_c.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
npmPackageJson = core_1.PackageJSON.fromProjectRootPath(new io_1.RealFS(), npmPackagePath, npmPackagePath);
|
|
86
|
+
initialChecks = [
|
|
87
|
+
(0, checks_1.createHarmonyDirExistsCheck)(npmPackagePath, hasHarmonyCode),
|
|
88
|
+
(0, checks_1.createHarmonyDirContainsOnlyHarsCheck)(npmPackagePath, hasHarmonyCode),
|
|
89
|
+
];
|
|
90
|
+
return [5 /*yield**/, __values(__asyncDelegator(__asyncValues(runChecks(initialChecks, checkNamesToSkip))))];
|
|
91
|
+
case 1: return [4 /*yield*/, __await.apply(void 0, [_c.sent()])];
|
|
92
|
+
case 2:
|
|
93
|
+
_c.sent();
|
|
94
|
+
if (!hasHarmonyCode) return [3 /*break*/, 8];
|
|
95
|
+
harPath = findHarPath(npmPackagePath);
|
|
96
|
+
if (!harPath) {
|
|
97
|
+
throw new core_1.DescriptiveError({
|
|
98
|
+
whatHappened: 'Attempted to verify har but no har was found',
|
|
99
|
+
whatCanUserDo: [
|
|
100
|
+
'Run this command without --no-harmony-code flag.',
|
|
101
|
+
'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.',
|
|
102
|
+
],
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
tmpDirPath = new core_1.AbsolutePath(tmp_1.default.dirSync().name);
|
|
106
|
+
return [4 /*yield*/, __await({
|
|
107
|
+
type: 'START_PROCESS',
|
|
108
|
+
name: "Unpacking the har file to the tmpdir",
|
|
109
|
+
})];
|
|
110
|
+
case 3: return [4 /*yield*/, _c.sent()];
|
|
111
|
+
case 4:
|
|
112
|
+
_c.sent();
|
|
113
|
+
return [4 /*yield*/, __await((0, io_1.unpackTarGz)(harPath, tmpDirPath))];
|
|
114
|
+
case 5:
|
|
115
|
+
_c.sent();
|
|
116
|
+
ohPackageJson5 = core_1.OHPackageJSON5.fromPath(tmpDirPath.copyWithNewSegment('package', 'oh-package.json5'));
|
|
117
|
+
harChecks = [
|
|
118
|
+
(0, checks_1.createOhPackageNameFollowsNamingConventionCheck)(npmPackageJson.name, ohPackageJson5.name),
|
|
119
|
+
(0, checks_1.createNpmAndOhPackageVersionsAreEqualCheck)(npmPackageJson.version, ohPackageJson5.version),
|
|
120
|
+
];
|
|
121
|
+
return [5 /*yield**/, __values(__asyncDelegator(__asyncValues(runChecks(harChecks, checkNamesToSkip))))];
|
|
122
|
+
case 6: return [4 /*yield*/, __await.apply(void 0, [_c.sent()])];
|
|
123
|
+
case 7:
|
|
124
|
+
_c.sent();
|
|
125
|
+
_c.label = 8;
|
|
126
|
+
case 8: return [2 /*return*/];
|
|
61
127
|
}
|
|
62
|
-
|
|
63
|
-
yield yield __await({
|
|
64
|
-
type: 'START_PROCESS',
|
|
65
|
-
name: `Unpacking the har file to the tmpdir`,
|
|
66
|
-
});
|
|
67
|
-
yield __await((0, io_1.unpackTarGz)(harPath, tmpDirPath));
|
|
68
|
-
const ohPackageJson5 = core_1.OHPackageJSON5.fromPath(tmpDirPath.copyWithNewSegment('package', 'oh-package.json5'));
|
|
69
|
-
const harChecks = [
|
|
70
|
-
(0, checks_1.createOhPackageNameFollowsNamingConventionCheck)(npmPackageJson.name, ohPackageJson5.name),
|
|
71
|
-
(0, checks_1.createNpmAndOhPackageVersionsAreEqualCheck)(npmPackageJson.version, ohPackageJson5.version),
|
|
72
|
-
];
|
|
73
|
-
yield __await(yield* __asyncDelegator(__asyncValues(runChecks(harChecks, checkNamesToSkip))));
|
|
74
|
-
}
|
|
128
|
+
});
|
|
75
129
|
});
|
|
76
130
|
}
|
|
77
131
|
function runChecks(checks, checkNamesToSkip) {
|
|
78
|
-
return __asyncGenerator(this, arguments, function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
132
|
+
return __asyncGenerator(this, arguments, function runChecks_1() {
|
|
133
|
+
var _i, checks_2, _a, checkIf, run, result, status_1, message;
|
|
134
|
+
return __generator(this, function (_b) {
|
|
135
|
+
switch (_b.label) {
|
|
136
|
+
case 0:
|
|
137
|
+
_i = 0, checks_2 = checks;
|
|
138
|
+
_b.label = 1;
|
|
139
|
+
case 1:
|
|
140
|
+
if (!(_i < checks_2.length)) return [3 /*break*/, 9];
|
|
141
|
+
_a = checks_2[_i], checkIf = _a.checkIf, run = _a.run;
|
|
142
|
+
if (!checkNamesToSkip.includes(checkIf)) return [3 /*break*/, 4];
|
|
143
|
+
return [4 /*yield*/, __await({
|
|
144
|
+
type: 'FINISHED_CHECKING',
|
|
145
|
+
name: checkIf,
|
|
146
|
+
status: 'skip',
|
|
147
|
+
message: '',
|
|
148
|
+
})];
|
|
149
|
+
case 2: return [4 /*yield*/, _b.sent()];
|
|
150
|
+
case 3:
|
|
151
|
+
_b.sent();
|
|
152
|
+
return [3 /*break*/, 8];
|
|
153
|
+
case 4: return [4 /*yield*/, __await(run())];
|
|
154
|
+
case 5:
|
|
155
|
+
result = _b.sent();
|
|
156
|
+
status_1 = typeof result === 'string' ? result : result.status;
|
|
157
|
+
message = typeof result === 'string' ? '' : result.message;
|
|
158
|
+
return [4 /*yield*/, __await({ type: 'FINISHED_CHECKING', name: checkIf, status: status_1, message: message })];
|
|
159
|
+
case 6: return [4 /*yield*/, _b.sent()];
|
|
160
|
+
case 7:
|
|
161
|
+
_b.sent();
|
|
162
|
+
_b.label = 8;
|
|
163
|
+
case 8:
|
|
164
|
+
_i++;
|
|
165
|
+
return [3 /*break*/, 1];
|
|
166
|
+
case 9: return [2 /*return*/];
|
|
88
167
|
}
|
|
89
|
-
|
|
90
|
-
const status = typeof result === 'string' ? result : result.status;
|
|
91
|
-
const message = typeof result === 'string' ? '' : result.message;
|
|
92
|
-
yield yield __await({ type: 'FINISHED_CHECKING', name: checkIf, status, message });
|
|
93
|
-
}
|
|
168
|
+
});
|
|
94
169
|
});
|
|
95
170
|
}
|
|
96
171
|
function findHarPath(packagePath) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
172
|
+
var packageHarmonyPath = packagePath.copyWithNewSegment('harmony');
|
|
173
|
+
var fileOrDirNames = node_fs_1.default.readdirSync(packageHarmonyPath.getValue());
|
|
174
|
+
var harFilenames = fileOrDirNames.filter(function (fileOrDirName) {
|
|
175
|
+
return fileOrDirName.endsWith('.har');
|
|
176
|
+
});
|
|
100
177
|
if (harFilenames.length != 1) {
|
|
101
178
|
return null;
|
|
102
179
|
}
|