@react-native-oh/react-native-harmony-cli 0.0.40 → 0.0.42
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 -77
- package/dist/autolinking/Autolinking.js +179 -179
- package/dist/autolinking/JSON5Writer.js +61 -0
- 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 +57 -96
- 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 +53 -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 +65 -138
- package/dist/commands/codegen-harmony.js +105 -165
- package/dist/commands/codegen-lib-harmony.js +76 -116
- package/dist/commands/create-metro-host-constants.js +18 -47
- package/dist/commands/init.js +537 -961
- package/dist/commands/link-harmony.js +33 -71
- package/dist/commands/pack-harmony.js +47 -108
- package/dist/commands/run-harmony.js +372 -518
- package/dist/commands/unpack-harmony.js +105 -198
- package/dist/commands/verify-package-harmony.js +54 -108
- package/dist/core/AbsolutePath.js +31 -47
- 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 +9 -6
- package/dist/index.js +1 -1
- package/dist/io/CliExecutor.js +46 -98
- package/dist/io/Logger.js +40 -46
- package/dist/io/RealFS.js +35 -88
- 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 +55 -132
- package/dist/simulator/LaunchSimulator.js +224 -301
- package/harmony/rnoh-hvigor-plugin-0.3.0.tgz +0 -0
- package/jest.config.js +12 -12
- package/package.json +79 -78
- package/react-native.config.js +17 -17
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
|
@@ -14,39 +14,12 @@ 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 __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
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
18
|
exports.commandLinkHarmony = void 0;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
const core_1 = require("../core");
|
|
20
|
+
const io_1 = require("../io");
|
|
21
|
+
const autolinking_1 = require("../autolinking");
|
|
22
|
+
const COMMAND_NAME = 'link-harmony';
|
|
50
23
|
exports.commandLinkHarmony = {
|
|
51
24
|
name: COMMAND_NAME,
|
|
52
25
|
description: 'Handles the automatic linking of RNOH libraries. This command is meant to be used by the RNOH HvigorPlugin.',
|
|
@@ -90,46 +63,35 @@ exports.commandLinkHarmony = {
|
|
|
90
63
|
description: "Lists npm package names to be included from the autolinking process, separated by semicolons. By default every library is included. Can't be used with --excluded-npm-packages.",
|
|
91
64
|
},
|
|
92
65
|
],
|
|
93
|
-
func:
|
|
94
|
-
var logger, fs, autolinking, config, result, err_1;
|
|
66
|
+
func: (_argv, _config, rawArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
95
67
|
var _a, _b;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
result = autolinking.evaluate(config);
|
|
122
|
-
autolinking.saveAndLogOutput(result);
|
|
123
|
-
return [3 /*break*/, 4];
|
|
124
|
-
case 3:
|
|
125
|
-
err_1 = _c.sent();
|
|
126
|
-
if (err_1 instanceof core_1.DescriptiveError && !err_1.isUnexpected()) {
|
|
127
|
-
logger.descriptiveError(err_1);
|
|
128
|
-
return [2 /*return*/];
|
|
129
|
-
}
|
|
130
|
-
throw err_1;
|
|
131
|
-
case 4: return [2 /*return*/];
|
|
68
|
+
const logger = new io_1.Logger();
|
|
69
|
+
const fs = new io_1.RealFS();
|
|
70
|
+
const autolinking = new autolinking_1.Autolinking(fs, logger);
|
|
71
|
+
try {
|
|
72
|
+
const config = yield autolinking.prepareInput({
|
|
73
|
+
harmonyProjectPath: new core_1.AbsolutePath(rawArgs.harmonyProjectPath),
|
|
74
|
+
nodeModulesPath: new core_1.AbsolutePath(rawArgs.nodeModulesPath),
|
|
75
|
+
cmakeAutolinkPathRelativeToHarmony: rawArgs.cmakeAutolinkPathRelativeToHarmony,
|
|
76
|
+
cppRNOHPackagesFactoryPathRelativeToHarmony: rawArgs.cppRnohPackagesFactoryPathRelativeToHarmony,
|
|
77
|
+
etsRNOHPackagesFactoryPathRelativeToHarmony: rawArgs.etsRnohPackagesFactoryPathRelativeToHarmony,
|
|
78
|
+
ohPackagePathRelativeToHarmony: rawArgs.ohPackagePathRelativeToHarmony,
|
|
79
|
+
excludedNpmPackageNames: new Set(rawArgs.excludeNpmPackages
|
|
80
|
+
? ((_a = rawArgs.excludeNpmPackages) !== null && _a !== void 0 ? _a : '').split(';')
|
|
81
|
+
: undefined),
|
|
82
|
+
includedNpmPackageNames: new Set(rawArgs.includeNpmPackages
|
|
83
|
+
? ((_b = rawArgs.includeNpmPackages) !== null && _b !== void 0 ? _b : '').split(';')
|
|
84
|
+
: undefined),
|
|
85
|
+
});
|
|
86
|
+
const result = autolinking.evaluate(config);
|
|
87
|
+
autolinking.saveAndLogOutput(result);
|
|
88
|
+
}
|
|
89
|
+
catch (err) {
|
|
90
|
+
if (err instanceof core_1.DescriptiveError && !err.isUnexpected()) {
|
|
91
|
+
logger.descriptiveError(err);
|
|
92
|
+
return;
|
|
132
93
|
}
|
|
133
|
-
|
|
134
|
-
|
|
94
|
+
throw err;
|
|
95
|
+
}
|
|
96
|
+
}),
|
|
135
97
|
};
|
|
@@ -14,42 +14,18 @@ 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
|
-
|
|
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
|
-
}
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
43
19
|
};
|
|
44
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
21
|
exports.commandPackHarmony = void 0;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
22
|
+
const glob_1 = require("glob");
|
|
23
|
+
const path_1 = __importDefault(require("path"));
|
|
24
|
+
const tar_1 = __importDefault(require("tar"));
|
|
25
|
+
const fs_1 = __importDefault(require("fs"));
|
|
26
|
+
const core_1 = require("../core");
|
|
27
|
+
const ignore_1 = __importDefault(require("ignore"));
|
|
28
|
+
const json5_1 = __importDefault(require("json5"));
|
|
53
29
|
exports.commandPackHarmony = {
|
|
54
30
|
name: 'pack-harmony',
|
|
55
31
|
description: 'Pack native code. Used for package development.',
|
|
@@ -67,76 +43,47 @@ exports.commandPackHarmony = {
|
|
|
67
43
|
description: 'Path to the package.json',
|
|
68
44
|
},
|
|
69
45
|
],
|
|
70
|
-
func:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
err_1 = _a.sent();
|
|
82
|
-
if (err_1 instanceof core_1.ValidationError) {
|
|
83
|
-
console.error('[ERROR]', err_1.message);
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
throw err_1;
|
|
88
|
-
}
|
|
89
|
-
return [3 /*break*/, 3];
|
|
90
|
-
case 3: return [2 /*return*/];
|
|
46
|
+
func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
try {
|
|
48
|
+
yield pack(path_1.default.resolve(args.harmonyDirPath), path_1.default.resolve(args.ohModulePath), path_1.default.resolve(args.packageJsonPath));
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
if (err instanceof core_1.ValidationError) {
|
|
52
|
+
console.error('[ERROR]', err.message);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
throw err;
|
|
91
57
|
}
|
|
92
|
-
}
|
|
93
|
-
})
|
|
58
|
+
}
|
|
59
|
+
}),
|
|
94
60
|
};
|
|
95
61
|
function pack(harmonyDirPath, ohModuleDirPath, packageJSONPath) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
return [4 /*yield*/, createTGZFromDir(ohModuleDirPath, path_1.default.join(harmonyDirPath, "".concat(path_1.default.parse(ohModuleDirPath).name, ".tar.gz")))];
|
|
105
|
-
case 1:
|
|
106
|
-
_a.sent();
|
|
107
|
-
return [4 /*yield*/, createTGZFromDir(harmonyDirPath, path_1.default.join(path_1.default.dirname(harmonyDirPath), 'harmony.tar.gz'))];
|
|
108
|
-
case 2:
|
|
109
|
-
_a.sent();
|
|
110
|
-
return [2 /*return*/];
|
|
111
|
-
}
|
|
112
|
-
});
|
|
62
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
+
syncVersions(packageJSONPath, path_1.default.join(ohModuleDirPath, 'oh-package.json5'));
|
|
64
|
+
if (!fs_1.default.existsSync(harmonyDirPath)) {
|
|
65
|
+
fs_1.default.mkdirSync(harmonyDirPath, { recursive: true });
|
|
66
|
+
}
|
|
67
|
+
yield createTGZFromDir(ohModuleDirPath, path_1.default.join(harmonyDirPath, `${path_1.default.parse(ohModuleDirPath).name}.tar.gz`));
|
|
68
|
+
yield createTGZFromDir(harmonyDirPath, path_1.default.join(path_1.default.dirname(harmonyDirPath), 'harmony.tar.gz'));
|
|
113
69
|
});
|
|
114
70
|
}
|
|
115
71
|
function syncVersions(packageJSONFilePath, ohPackageJSONFilePath) {
|
|
116
|
-
|
|
72
|
+
const packageJSONFileContent = JSON.parse(fs_1.default.readFileSync(packageJSONFilePath, { encoding: 'utf-8' }));
|
|
117
73
|
if (fs_1.default.existsSync(ohPackageJSONFilePath)) {
|
|
118
|
-
|
|
74
|
+
const ohPackageJSONFileContent = json5_1.default.parse(fs_1.default.readFileSync(ohPackageJSONFilePath, { encoding: 'utf-8' }));
|
|
119
75
|
ohPackageJSONFileContent['version'] = packageJSONFileContent['version'];
|
|
120
76
|
fs_1.default.writeFileSync(ohPackageJSONFilePath, json5_1.default.stringify(ohPackageJSONFileContent, null, 2));
|
|
121
77
|
}
|
|
122
78
|
}
|
|
123
79
|
function createTGZFromDir(dirPath, outputFilePath) {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
cwd: dirPath,
|
|
132
|
-
nodir: true,
|
|
133
|
-
}).filter(function (path) { return !ig.ignores(path); });
|
|
134
|
-
return [4 /*yield*/, createArchive(outputFilePath, dirPath, filesToInclude)];
|
|
135
|
-
case 1:
|
|
136
|
-
_a.sent();
|
|
137
|
-
return [2 /*return*/];
|
|
138
|
-
}
|
|
139
|
-
});
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
const ig = getIgnoreUtil(path_1.default.join(dirPath, '.tarignore'));
|
|
82
|
+
const filesToInclude = (0, glob_1.globSync)('**', {
|
|
83
|
+
cwd: dirPath,
|
|
84
|
+
nodir: true,
|
|
85
|
+
}).filter((path) => !ig.ignores(path));
|
|
86
|
+
yield createArchive(outputFilePath, dirPath, filesToInclude);
|
|
140
87
|
});
|
|
141
88
|
}
|
|
142
89
|
function getIgnoreUtil(tarignorePath) {
|
|
@@ -146,22 +93,14 @@ function getIgnoreUtil(tarignorePath) {
|
|
|
146
93
|
return (0, ignore_1.default)().add(fs_1.default.readFileSync(tarignorePath).toString());
|
|
147
94
|
}
|
|
148
95
|
function createArchive(outputFilePath, packageDirPath, filesToInclude) {
|
|
149
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
file: outputFilePath,
|
|
159
|
-
cwd: packageDirPath,
|
|
160
|
-
}, filesToInclude)];
|
|
161
|
-
case 1:
|
|
162
|
-
_a.sent();
|
|
163
|
-
return [2 /*return*/];
|
|
164
|
-
}
|
|
165
|
-
});
|
|
96
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
+
if (filesToInclude.length === 0) {
|
|
98
|
+
throw new core_1.ValidationError('Nothing to pack');
|
|
99
|
+
}
|
|
100
|
+
yield tar_1.default.c({
|
|
101
|
+
gzip: true,
|
|
102
|
+
file: outputFilePath,
|
|
103
|
+
cwd: packageDirPath,
|
|
104
|
+
}, filesToInclude);
|
|
166
105
|
});
|
|
167
106
|
}
|