@react-native-oh/react-native-harmony-cli 0.0.36 → 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 +42 -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 -109
- 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 -108
- 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 +520 -352
- 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 +395 -0
- package/dist/simulator/index.js +23 -0
- 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 -120
- 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 -147
- 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 -138
- 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 -478
- 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
|
@@ -14,23 +14,60 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
14
14
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
|
-
var
|
|
18
|
-
|
|
17
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
18
|
+
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);
|
|
19
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
20
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
21
|
+
function step(op) {
|
|
22
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
23
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
24
|
+
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;
|
|
25
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
26
|
+
switch (op[0]) {
|
|
27
|
+
case 0: case 1: t = op; break;
|
|
28
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
29
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
30
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
31
|
+
default:
|
|
32
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
33
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
34
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
35
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
36
|
+
if (t[2]) _.ops.pop();
|
|
37
|
+
_.trys.pop(); continue;
|
|
38
|
+
}
|
|
39
|
+
op = body.call(thisArg, _);
|
|
40
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
41
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
45
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
46
|
+
if (ar || !(i in from)) {
|
|
47
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
48
|
+
ar[i] = from[i];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
19
52
|
};
|
|
20
53
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
54
|
exports.commandCodegenHarmony = void 0;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
55
|
+
var node_path_1 = require("node:path");
|
|
56
|
+
var case_1 = require("case");
|
|
57
|
+
var core_1 = require("../core");
|
|
58
|
+
var codegen_1 = require("../codegen");
|
|
59
|
+
var io_1 = require("../io");
|
|
27
60
|
exports.commandCodegenHarmony = {
|
|
28
61
|
name: 'codegen-harmony',
|
|
29
62
|
description: 'Generates boilerplate, types, and utilities from Turbo Module and Fabric Component specifications. This command is meant to be executed during the application build process.',
|
|
30
63
|
options: [
|
|
31
64
|
{
|
|
32
65
|
name: '--rnoh-module-path <path>',
|
|
33
|
-
description: 'Specifies the relative path to the rnoh OHOS module',
|
|
66
|
+
description: '[deprecated] Specifies the relative path to the rnoh OHOS module',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: '--ets-output-path <path>',
|
|
70
|
+
description: 'Specifies the relative path to the output directory intended for storing generated ETS files.',
|
|
34
71
|
},
|
|
35
72
|
{
|
|
36
73
|
name: '--cpp-output-path <path>',
|
|
@@ -52,109 +89,141 @@ exports.commandCodegenHarmony = {
|
|
|
52
89
|
description: 'Skips the check that prevents file operations outside the current working directory. This command permanently deletes previously generated files. Files are generated in the path specified by cpp-output-path.',
|
|
53
90
|
},
|
|
54
91
|
],
|
|
55
|
-
func: (_argv, _config, args)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
92
|
+
func: function (_argv, _config, args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
93
|
+
var logger, fs, MAX_SUPPORTED_CODEGEN_VERSION_1, etsOutputPath, isEndWithGenerated, enableSafetyCheck, cppOutputPath, projectRootPath, uberSchemaFromArkTSLibraries, cApiLibrariesData, codegenNoticeLines, uberGeneratorV1, uberGeneratorV2, glueCodeGenerator, fileContentByPath_1, appendToFileContentByPath, uberSchema_1, err_1;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
switch (_a.label) {
|
|
96
|
+
case 0:
|
|
97
|
+
logger = new io_1.Logger();
|
|
98
|
+
fs = new io_1.RealFS();
|
|
99
|
+
_a.label = 1;
|
|
100
|
+
case 1:
|
|
101
|
+
_a.trys.push([1, 6, , 7]);
|
|
102
|
+
MAX_SUPPORTED_CODEGEN_VERSION_1 = 2;
|
|
103
|
+
// prepare the input data
|
|
104
|
+
validateArgs(args);
|
|
105
|
+
etsOutputPath = args.etsOutputPath || args.rnohModulePath;
|
|
106
|
+
isEndWithGenerated = /\/generated\/?$/.test(etsOutputPath);
|
|
107
|
+
etsOutputPath = new core_1.AbsolutePath(etsOutputPath);
|
|
108
|
+
if (!isEndWithGenerated) {
|
|
109
|
+
etsOutputPath = etsOutputPath.copyWithNewSegment('generated');
|
|
110
|
+
}
|
|
111
|
+
enableSafetyCheck = args.safetyCheck;
|
|
112
|
+
cppOutputPath = new core_1.AbsolutePath(args.cppOutputPath);
|
|
113
|
+
projectRootPath = new core_1.AbsolutePath(args.projectRootPath);
|
|
114
|
+
return [4 /*yield*/, codegen_1.UberSchema.fromProject(fs, projectRootPath, function (codegenVersion, packageName) {
|
|
115
|
+
throwErrorIfUnsupportedCodegenVersion(codegenVersion, MAX_SUPPORTED_CODEGEN_VERSION_1, packageName);
|
|
116
|
+
return codegenVersion === 1;
|
|
117
|
+
})];
|
|
118
|
+
case 2:
|
|
119
|
+
uberSchemaFromArkTSLibraries = _a.sent();
|
|
120
|
+
return [4 /*yield*/, collectLibrariesData(fs, projectRootPath, function (codegenVersion, packageName) {
|
|
121
|
+
throwErrorIfUnsupportedCodegenVersion(codegenVersion, MAX_SUPPORTED_CODEGEN_VERSION_1, packageName);
|
|
122
|
+
return codegenVersion === 2;
|
|
123
|
+
})];
|
|
124
|
+
case 3:
|
|
125
|
+
cApiLibrariesData = _a.sent();
|
|
126
|
+
codegenNoticeLines = [
|
|
127
|
+
'This code was generated by "react-native codegen-harmony"',
|
|
128
|
+
'',
|
|
129
|
+
'Do not edit this file as changes may cause incorrect behavior and will be',
|
|
130
|
+
'lost once the code is regenerated.',
|
|
131
|
+
];
|
|
132
|
+
uberGeneratorV1 = new codegen_1.UberGeneratorV1(cppOutputPath, etsOutputPath, __spreadArray(__spreadArray([], codegenNoticeLines, true), ['', '@generatorVersion: 1'], false));
|
|
133
|
+
uberGeneratorV2 = new codegen_1.UberGeneratorV2(cppOutputPath, etsOutputPath, __spreadArray(__spreadArray([], codegenNoticeLines, true), ['', '@generatorVersion: 2'], false));
|
|
134
|
+
glueCodeGenerator = new codegen_1.AppBuildTimeGlueCodeGenerator(cppOutputPath, etsOutputPath, codegenNoticeLines);
|
|
135
|
+
fileContentByPath_1 = new Map();
|
|
136
|
+
appendToFileContentByPath = function (fileContent, path) {
|
|
137
|
+
fileContentByPath_1.set(path, fileContent);
|
|
138
|
+
};
|
|
139
|
+
uberGeneratorV1
|
|
140
|
+
.generate(uberSchemaFromArkTSLibraries)
|
|
141
|
+
.forEach(appendToFileContentByPath);
|
|
142
|
+
uberGeneratorV2
|
|
143
|
+
.generate(cApiLibrariesData)
|
|
144
|
+
.forEach(appendToFileContentByPath);
|
|
145
|
+
glueCodeGenerator
|
|
146
|
+
.generate({
|
|
147
|
+
v1: uberGeneratorV1.getGlueCodeData(),
|
|
148
|
+
v2: uberGeneratorV2.getGlueCodeData(),
|
|
149
|
+
})
|
|
150
|
+
.forEach(appendToFileContentByPath);
|
|
151
|
+
if (!args.debug) return [3 /*break*/, 5];
|
|
152
|
+
return [4 /*yield*/, codegen_1.UberSchema.fromProject(fs, projectRootPath)];
|
|
153
|
+
case 4:
|
|
154
|
+
uberSchema_1 = _a.sent();
|
|
155
|
+
logger.debug(function (styles) {
|
|
156
|
+
return styles.gray(JSON.stringify(uberSchema_1.getValue(), null, 2));
|
|
157
|
+
});
|
|
158
|
+
_a.label = 5;
|
|
159
|
+
case 5:
|
|
160
|
+
saveCodegenResult(fs, fileContentByPath_1, cppOutputPath, etsOutputPath, enableSafetyCheck);
|
|
161
|
+
logCodegenResult(logger, fileContentByPath_1, projectRootPath);
|
|
162
|
+
return [3 /*break*/, 7];
|
|
163
|
+
case 6:
|
|
164
|
+
err_1 = _a.sent();
|
|
165
|
+
if (err_1 instanceof core_1.DescriptiveError) {
|
|
166
|
+
logger.descriptiveError(err_1);
|
|
167
|
+
process.exit(1);
|
|
168
|
+
}
|
|
169
|
+
throw err_1;
|
|
170
|
+
case 7: return [2 /*return*/];
|
|
113
171
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}),
|
|
172
|
+
});
|
|
173
|
+
}); },
|
|
117
174
|
};
|
|
118
175
|
function validateArgs(args) {
|
|
119
|
-
if (!args.rnohModulePath) {
|
|
176
|
+
if (!args.rnohModulePath && !args.etsOutputPath) {
|
|
120
177
|
throw new core_1.DescriptiveError({
|
|
121
|
-
whatHappened:
|
|
178
|
+
whatHappened: '--ets-output-path is required',
|
|
122
179
|
whatCanUserDo: [
|
|
123
|
-
'Please provide
|
|
180
|
+
'Please provide an output path for the ETS file.',
|
|
181
|
+
'It is recommended to place it in the same directory as the custom component or TurboModule.',
|
|
182
|
+
'Do not place it inside @rnoh/react-native-openharmony, otherwise a jscrash may occur when using react_native_openharmony_release2.har.'
|
|
124
183
|
],
|
|
125
184
|
});
|
|
126
185
|
}
|
|
127
186
|
}
|
|
128
187
|
function collectLibrariesData(fs, projectRootPath, onShouldAcceptCodegenConfig) {
|
|
129
|
-
return __awaiter(this, void 0, void 0, function
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
results
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
188
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
189
|
+
var packageJSONs, results, _i, packageJSONs_1, packageJSON, codegenConfigs, _a, codegenConfigs_1, codegenConfig;
|
|
190
|
+
return __generator(this, function (_b) {
|
|
191
|
+
switch (_b.label) {
|
|
192
|
+
case 0:
|
|
193
|
+
packageJSONs = [
|
|
194
|
+
core_1.PackageJSON.fromProjectRootPath(fs, projectRootPath, projectRootPath),
|
|
195
|
+
];
|
|
196
|
+
return [4 /*yield*/, new core_1.ProjectDependenciesManager(fs, projectRootPath).forEachAsync(function (dependency) {
|
|
197
|
+
packageJSONs.push(dependency.readPackageJSON());
|
|
198
|
+
})];
|
|
199
|
+
case 1:
|
|
200
|
+
_b.sent();
|
|
201
|
+
results = [];
|
|
202
|
+
for (_i = 0, packageJSONs_1 = packageJSONs; _i < packageJSONs_1.length; _i++) {
|
|
203
|
+
packageJSON = packageJSONs_1[_i];
|
|
204
|
+
codegenConfigs = packageJSON.getCodegenConfigs();
|
|
205
|
+
for (_a = 0, codegenConfigs_1 = codegenConfigs; _a < codegenConfigs_1.length; _a++) {
|
|
206
|
+
codegenConfig = codegenConfigs_1[_a];
|
|
207
|
+
if (codegenConfig &&
|
|
208
|
+
onShouldAcceptCodegenConfig(codegenConfig.getVersion(), packageJSON.name)) {
|
|
209
|
+
results.push({
|
|
210
|
+
libraryCppName: deriveCppDirectoryNameFromNpmPackageName(packageJSON.name),
|
|
211
|
+
uberSchema: codegen_1.UberSchema.fromCodegenConfig(codegenConfig),
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return [2 /*return*/, results];
|
|
147
217
|
}
|
|
148
|
-
}
|
|
149
|
-
return results;
|
|
218
|
+
});
|
|
150
219
|
});
|
|
151
220
|
}
|
|
152
221
|
function throwErrorIfUnsupportedCodegenVersion(codegenVersion, maxSupportedCodegenVersion, packageName) {
|
|
153
222
|
if (codegenVersion > maxSupportedCodegenVersion) {
|
|
154
223
|
throw new codegen_1.CodegenError({
|
|
155
|
-
whatHappened:
|
|
224
|
+
whatHappened: "Package \"".concat(packageName, "\" requires codegenVersion: ").concat(codegenVersion, ", which is not supported (maxSupportedCodegenVersion=").concat(maxSupportedCodegenVersion, ")."),
|
|
156
225
|
whatCanUserDo: [
|
|
157
|
-
|
|
226
|
+
"Try downgrading \"".concat(packageName, "\"."),
|
|
158
227
|
'Update the "@react-native-oh/react-native-harmony-cli" package.',
|
|
159
228
|
],
|
|
160
229
|
});
|
|
@@ -165,10 +234,10 @@ function saveCodegenResult(fs, fileContentByPath, cppOutputPath, etsOutputPath,
|
|
|
165
234
|
prepareDirectory(etsOutputPath, enableSafetyCheck);
|
|
166
235
|
prepareDirectory(etsOutputPath.copyWithNewSegment('components'), enableSafetyCheck);
|
|
167
236
|
prepareDirectory(etsOutputPath.copyWithNewSegment('turboModules'), enableSafetyCheck);
|
|
168
|
-
fileContentByPath.forEach((_fileContent, path)
|
|
237
|
+
fileContentByPath.forEach(function (_fileContent, path) {
|
|
169
238
|
prepareDirectory(path.getDirectoryPath(), enableSafetyCheck);
|
|
170
239
|
});
|
|
171
|
-
fileContentByPath.forEach((fileContent, path)
|
|
240
|
+
fileContentByPath.forEach(function (fileContent, path) {
|
|
172
241
|
fs.writeTextSync(path, fileContent);
|
|
173
242
|
});
|
|
174
243
|
}
|
|
@@ -176,24 +245,26 @@ function prepareDirectory(path, enableSafetyCheck) {
|
|
|
176
245
|
(0, core_1.maybeMakeDirectories)(path);
|
|
177
246
|
if (enableSafetyCheck && !path.getValue().startsWith(process.cwd())) {
|
|
178
247
|
throw new core_1.DescriptiveError({
|
|
179
|
-
whatHappened:
|
|
248
|
+
whatHappened: "Tried to remove files in ".concat(path.getValue(), "\nand that path is outside current working directory"),
|
|
180
249
|
whatCanUserDo: ['Run codegen from different location'],
|
|
181
250
|
});
|
|
182
251
|
}
|
|
183
252
|
(0, core_1.maybeRemoveFilesInDirectory)(path);
|
|
184
253
|
}
|
|
185
254
|
function logCodegenResult(logger, fileContentByPath, projectRootPath) {
|
|
186
|
-
|
|
255
|
+
var sortedRelativePathStrings = Array.from(fileContentByPath.keys()).map(function (path) { return node_path_1.default.relative(projectRootPath.getValue(), path.getValue()); });
|
|
187
256
|
sortedRelativePathStrings.sort();
|
|
188
|
-
sortedRelativePathStrings.forEach((pathStr)
|
|
189
|
-
logger.debug((styles)
|
|
257
|
+
sortedRelativePathStrings.forEach(function (pathStr) {
|
|
258
|
+
logger.debug(function (styles) { return styles.gray("\u2022 ".concat(pathStr)); });
|
|
259
|
+
});
|
|
260
|
+
logger.debug(function () { return ''; });
|
|
261
|
+
logger.info(function (styles) {
|
|
262
|
+
return "Generated ".concat(styles.green(styles.bold(fileContentByPath.size)), " file(s)");
|
|
190
263
|
});
|
|
191
|
-
logger.debug(()
|
|
192
|
-
logger.info((styles) => `Generated ${styles.green(styles.bold(fileContentByPath.size))} file(s)`);
|
|
193
|
-
logger.debug(() => '');
|
|
264
|
+
logger.debug(function () { return ''; });
|
|
194
265
|
}
|
|
195
266
|
function deriveCppDirectoryNameFromNpmPackageName(npmPackageName) {
|
|
196
|
-
|
|
267
|
+
var result = npmPackageName;
|
|
197
268
|
if (npmPackageName.includes('/')) {
|
|
198
269
|
result.replace('@', '');
|
|
199
270
|
result = npmPackageName.replace('/', '__');
|