@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
|
@@ -14,18 +14,42 @@ 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
|
+
}
|
|
19
43
|
};
|
|
20
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
45
|
exports.commandUnpackHarmony = void 0;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
var io_1 = require("../io");
|
|
47
|
+
var path_1 = require("path");
|
|
48
|
+
var fs_1 = require("fs");
|
|
49
|
+
var zlib_1 = require("zlib");
|
|
50
|
+
var tar_1 = require("tar");
|
|
51
|
+
var json5_1 = require("json5");
|
|
52
|
+
var core_1 = require("../core");
|
|
29
53
|
exports.commandUnpackHarmony = {
|
|
30
54
|
name: 'unpack-harmony',
|
|
31
55
|
description: 'Unpacks native code.',
|
|
@@ -41,86 +65,153 @@ exports.commandUnpackHarmony = {
|
|
|
41
65
|
default: './harmony/rnoh_modules',
|
|
42
66
|
},
|
|
43
67
|
],
|
|
44
|
-
func: (argv, config, args)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
68
|
+
func: function (argv, config, args) { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
+
var err_1;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
switch (_a.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
_a.trys.push([0, 2, , 3]);
|
|
74
|
+
return [4 /*yield*/, unpack(new core_1.AbsolutePath(args.projectRootPath), new core_1.AbsolutePath(args.outputDir))];
|
|
75
|
+
case 1:
|
|
76
|
+
_a.sent();
|
|
77
|
+
return [3 /*break*/, 3];
|
|
78
|
+
case 2:
|
|
79
|
+
err_1 = _a.sent();
|
|
80
|
+
if (err_1 instanceof core_1.ValidationError) {
|
|
81
|
+
console.error('[ERROR]', err_1.message);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw err_1;
|
|
86
|
+
}
|
|
87
|
+
return [3 /*break*/, 3];
|
|
88
|
+
case 3: return [2 /*return*/];
|
|
55
89
|
}
|
|
56
|
-
}
|
|
57
|
-
}),
|
|
90
|
+
});
|
|
91
|
+
}); },
|
|
58
92
|
};
|
|
59
93
|
function unpack(projectRootPath, outputDirPath) {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function
|
|
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
|
-
|
|
94
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
+
var logger, fs, projectDependenciesManager, unpackedArchivesCount, skippedArchivesCount;
|
|
96
|
+
var _this = this;
|
|
97
|
+
return __generator(this, function (_a) {
|
|
98
|
+
switch (_a.label) {
|
|
99
|
+
case 0:
|
|
100
|
+
logger = new io_1.Logger();
|
|
101
|
+
fs = new io_1.RealFS();
|
|
102
|
+
projectDependenciesManager = new core_1.ProjectDependenciesManager(fs, projectRootPath);
|
|
103
|
+
logger.info(function (styles) { return styles.bold("Unpacking RNOH modules"); });
|
|
104
|
+
unpackedArchivesCount = 0;
|
|
105
|
+
skippedArchivesCount = 0;
|
|
106
|
+
return [4 /*yield*/, projectDependenciesManager.forEachAsync(function (dependency) { return __awaiter(_this, void 0, void 0, function () {
|
|
107
|
+
var packageJSON, harmonyArchivePath, pkgHarmonyDirPath, harmonyTarGzPathStr, ohModulesInfo, _loop_1, _i, ohModulesInfo_1, ohModuleInfo, ohModulesInfo, _loop_2, _a, ohModulesInfo_2, ohModuleInfo;
|
|
108
|
+
return __generator(this, function (_b) {
|
|
109
|
+
switch (_b.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
packageJSON = dependency.readPackageJSON();
|
|
112
|
+
harmonyArchivePath = dependency
|
|
113
|
+
.getRootPath()
|
|
114
|
+
.copyWithNewSegment('harmony.tar.gz');
|
|
115
|
+
pkgHarmonyDirPath = dependency
|
|
116
|
+
.getRootPath()
|
|
117
|
+
.copyWithNewSegment('harmony');
|
|
118
|
+
harmonyTarGzPathStr = dependency
|
|
119
|
+
.getRootPath()
|
|
120
|
+
.copyWithNewSegment('harmony.tar.gz')
|
|
121
|
+
.relativeTo(projectRootPath)
|
|
122
|
+
.getValue();
|
|
123
|
+
if (!(packageJSON.version &&
|
|
124
|
+
shouldUnpack(harmonyArchivePath, pkgHarmonyDirPath, outputDirPath, packageJSON.version))) return [3 /*break*/, 8];
|
|
125
|
+
if (!!fs.existsSync(pkgHarmonyDirPath)) return [3 /*break*/, 2];
|
|
126
|
+
/**
|
|
127
|
+
* After fresh install, harmony.tar.gz wasn't unpacked to harmony. Updating npm package should remove unpacked harmony dir.
|
|
128
|
+
*/
|
|
129
|
+
logger.info(function (styles) {
|
|
130
|
+
return "[".concat(styles.cyan('unpacking'), "] ").concat(styles.gray(harmonyTarGzPathStr));
|
|
131
|
+
});
|
|
132
|
+
return [4 /*yield*/, unpackTarGz(harmonyArchivePath, pkgHarmonyDirPath)];
|
|
133
|
+
case 1:
|
|
134
|
+
_b.sent();
|
|
135
|
+
unpackedArchivesCount++;
|
|
136
|
+
return [3 /*break*/, 3];
|
|
137
|
+
case 2:
|
|
138
|
+
skippedArchivesCount++;
|
|
139
|
+
logger.info(function (styles) {
|
|
140
|
+
return "[".concat(styles.yellow('skipped'), "] ").concat(styles.gray(harmonyTarGzPathStr));
|
|
141
|
+
});
|
|
142
|
+
_b.label = 3;
|
|
143
|
+
case 3:
|
|
144
|
+
ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
|
|
145
|
+
_loop_1 = function (ohModuleInfo) {
|
|
146
|
+
var moduleArchivePathStr;
|
|
147
|
+
return __generator(this, function (_c) {
|
|
148
|
+
switch (_c.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
moduleArchivePathStr = dependency
|
|
151
|
+
.getRootPath()
|
|
152
|
+
.copyWithNewSegment('harmony', ohModuleInfo.archiveFileName)
|
|
153
|
+
.relativeTo(projectRootPath)
|
|
154
|
+
.getValue();
|
|
155
|
+
logger.info(function (styles) {
|
|
156
|
+
return "[".concat(styles.cyan('unpacking'), "] ").concat(styles.gray(moduleArchivePathStr));
|
|
157
|
+
});
|
|
158
|
+
unpackedArchivesCount++;
|
|
159
|
+
return [4 /*yield*/, unpackTarGz(ohModuleInfo.archivePath, ohModuleInfo.computedModulePath)];
|
|
160
|
+
case 1:
|
|
161
|
+
_c.sent();
|
|
162
|
+
return [2 /*return*/];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
_i = 0, ohModulesInfo_1 = ohModulesInfo;
|
|
167
|
+
_b.label = 4;
|
|
168
|
+
case 4:
|
|
169
|
+
if (!(_i < ohModulesInfo_1.length)) return [3 /*break*/, 7];
|
|
170
|
+
ohModuleInfo = ohModulesInfo_1[_i];
|
|
171
|
+
return [5 /*yield**/, _loop_1(ohModuleInfo)];
|
|
172
|
+
case 5:
|
|
173
|
+
_b.sent();
|
|
174
|
+
_b.label = 6;
|
|
175
|
+
case 6:
|
|
176
|
+
_i++;
|
|
177
|
+
return [3 /*break*/, 4];
|
|
178
|
+
case 7: return [3 /*break*/, 9];
|
|
179
|
+
case 8:
|
|
180
|
+
if (fs.existsSync(harmonyArchivePath)) {
|
|
181
|
+
skippedArchivesCount++;
|
|
182
|
+
logger.info(function (styles) {
|
|
183
|
+
return "[".concat(styles.yellow('skipped'), "] ").concat(styles.gray(harmonyTarGzPathStr));
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
|
|
187
|
+
_loop_2 = function (ohModuleInfo) {
|
|
188
|
+
var moduleArchivePathStr = dependency
|
|
189
|
+
.getRootPath()
|
|
190
|
+
.copyWithNewSegment('harmony', ohModuleInfo.archiveFileName)
|
|
191
|
+
.relativeTo(projectRootPath)
|
|
192
|
+
.getValue();
|
|
193
|
+
skippedArchivesCount++;
|
|
194
|
+
logger.info(function (styles) {
|
|
195
|
+
return "[".concat(styles.yellow('skipped'), "] ").concat(styles.gray(moduleArchivePathStr));
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
for (_a = 0, ohModulesInfo_2 = ohModulesInfo; _a < ohModulesInfo_2.length; _a++) {
|
|
199
|
+
ohModuleInfo = ohModulesInfo_2[_a];
|
|
200
|
+
_loop_2(ohModuleInfo);
|
|
201
|
+
}
|
|
202
|
+
_b.label = 9;
|
|
203
|
+
case 9: return [2 /*return*/];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
}); })];
|
|
207
|
+
case 1:
|
|
208
|
+
_a.sent();
|
|
209
|
+
logger.info(function (styles) {
|
|
210
|
+
return "\nUnpacked: ".concat(styles.cyan(unpackedArchivesCount), ", Skipped: ").concat(styles.yellow(skippedArchivesCount));
|
|
211
|
+
});
|
|
212
|
+
return [2 /*return*/];
|
|
105
213
|
}
|
|
106
|
-
|
|
107
|
-
if (fs.existsSync(harmonyArchivePath)) {
|
|
108
|
-
skippedArchivesCount++;
|
|
109
|
-
logger.info((styles) => `[${styles.yellow('skipped')}] ${styles.gray(harmonyTarGzPathStr)}`);
|
|
110
|
-
}
|
|
111
|
-
const ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
|
|
112
|
-
for (const ohModuleInfo of ohModulesInfo) {
|
|
113
|
-
const moduleArchivePathStr = dependency
|
|
114
|
-
.getRootPath()
|
|
115
|
-
.copyWithNewSegment('harmony', ohModuleInfo.archiveFileName)
|
|
116
|
-
.relativeTo(projectRootPath)
|
|
117
|
-
.getValue();
|
|
118
|
-
skippedArchivesCount++;
|
|
119
|
-
logger.info((styles) => `[${styles.yellow('skipped')}] ${styles.gray(moduleArchivePathStr)}`);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}));
|
|
123
|
-
logger.info((styles) => `\nUnpacked: ${styles.cyan(unpackedArchivesCount)}, Skipped: ${styles.yellow(skippedArchivesCount)}`);
|
|
214
|
+
});
|
|
124
215
|
});
|
|
125
216
|
}
|
|
126
217
|
function shouldUnpack(harmonyArchivePath, pkgHarmonyDirPath, outputDirPath, nodePackageVersion) {
|
|
@@ -128,8 +219,9 @@ function shouldUnpack(harmonyArchivePath, pkgHarmonyDirPath, outputDirPath, node
|
|
|
128
219
|
return false;
|
|
129
220
|
if (!fs_1.default.existsSync(pkgHarmonyDirPath.getValue()))
|
|
130
221
|
return true;
|
|
131
|
-
|
|
132
|
-
for (
|
|
222
|
+
var ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
|
|
223
|
+
for (var _i = 0, ohModulesInfo_3 = ohModulesInfo; _i < ohModulesInfo_3.length; _i++) {
|
|
224
|
+
var ohModuleInfo = ohModulesInfo_3[_i];
|
|
133
225
|
if (!fs_1.default.existsSync(ohModuleInfo.computedModulePath.getValue()) ||
|
|
134
226
|
getOhPackageVersion(ohModuleInfo.computedModulePath) !==
|
|
135
227
|
nodePackageVersion) {
|
|
@@ -139,31 +231,32 @@ function shouldUnpack(harmonyArchivePath, pkgHarmonyDirPath, outputDirPath, node
|
|
|
139
231
|
return false;
|
|
140
232
|
}
|
|
141
233
|
function getOhPackageVersion(modulePath) {
|
|
142
|
-
|
|
234
|
+
var ohPackagePath = modulePath.copyWithNewSegment('oh-package.json5');
|
|
143
235
|
if (!fs_1.default.existsSync(ohPackagePath.getValue()))
|
|
144
236
|
return null;
|
|
145
|
-
|
|
237
|
+
var content = fs_1.default.readFileSync(ohPackagePath.getValue(), {
|
|
146
238
|
encoding: 'utf-8',
|
|
147
239
|
});
|
|
148
240
|
return json5_1.default.parse(content)['version'];
|
|
149
241
|
}
|
|
150
242
|
function getOhModulesInfo(pkgHarmonyDirPath, outputDirPath) {
|
|
151
|
-
|
|
243
|
+
var results = [];
|
|
152
244
|
if (!fs_1.default.existsSync(pkgHarmonyDirPath.getValue()))
|
|
153
245
|
return [];
|
|
154
|
-
|
|
155
|
-
for (
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
246
|
+
var names = fs_1.default.readdirSync(pkgHarmonyDirPath.getValue());
|
|
247
|
+
for (var _i = 0, names_1 = names; _i < names_1.length; _i++) {
|
|
248
|
+
var name_1 = names_1[_i];
|
|
249
|
+
if (name_1.endsWith('.tar.gz')) {
|
|
250
|
+
var archivePath = pkgHarmonyDirPath.copyWithNewSegment(name_1);
|
|
251
|
+
var computedModuleName = path_1.default
|
|
159
252
|
.parse(archivePath.getValue())
|
|
160
253
|
.name.split('.')[0];
|
|
161
|
-
|
|
254
|
+
var computedModulePath = outputDirPath.copyWithNewSegment(computedModuleName);
|
|
162
255
|
results.push({
|
|
163
|
-
archivePath,
|
|
164
|
-
archiveFileName:
|
|
165
|
-
computedModulePath,
|
|
166
|
-
computedModuleName,
|
|
256
|
+
archivePath: archivePath,
|
|
257
|
+
archiveFileName: name_1,
|
|
258
|
+
computedModulePath: computedModulePath,
|
|
259
|
+
computedModuleName: computedModuleName,
|
|
167
260
|
});
|
|
168
261
|
}
|
|
169
262
|
}
|
|
@@ -173,16 +266,16 @@ function unpackTarGz(archivePath, outputDirPath) {
|
|
|
173
266
|
if (!fs_1.default.existsSync(outputDirPath.getValue())) {
|
|
174
267
|
fs_1.default.mkdirSync(outputDirPath.getValue(), { recursive: true });
|
|
175
268
|
}
|
|
176
|
-
|
|
177
|
-
|
|
269
|
+
var readStream = fs_1.default.createReadStream(archivePath.getValue());
|
|
270
|
+
var writeStream = tar_1.default.extract({
|
|
178
271
|
cwd: outputDirPath.getValue(),
|
|
179
272
|
});
|
|
180
273
|
readStream.pipe(zlib_1.default.createGunzip()).pipe(writeStream);
|
|
181
|
-
return new Promise((resolve, reject)
|
|
182
|
-
writeStream.on('finish', ()
|
|
274
|
+
return new Promise(function (resolve, reject) {
|
|
275
|
+
writeStream.on('finish', function () {
|
|
183
276
|
resolve(undefined);
|
|
184
277
|
});
|
|
185
|
-
writeStream.on('error', (err)
|
|
278
|
+
writeStream.on('error', function (err) {
|
|
186
279
|
reject(err);
|
|
187
280
|
});
|
|
188
281
|
});
|
|
@@ -14,6 +14,33 @@ 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
|
+
};
|
|
17
44
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
18
45
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
19
46
|
var m = o[Symbol.asyncIterator], i;
|
|
@@ -21,16 +48,13 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
21
48
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
22
49
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
23
50
|
};
|
|
24
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
|
-
};
|
|
27
51
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
52
|
exports.commandVerifyPackageHarmony = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
53
|
+
var cli_tools_1 = require("@react-native-community/cli-tools");
|
|
54
|
+
var chalk_1 = require("chalk");
|
|
55
|
+
var core_1 = require("../core");
|
|
56
|
+
var io_1 = require("../io");
|
|
57
|
+
var package_verifier_1 = require("../package-verifier");
|
|
34
58
|
exports.commandVerifyPackageHarmony = {
|
|
35
59
|
name: 'verify-package-harmony',
|
|
36
60
|
description: 'Validates that a package is compliant with guidelines',
|
|
@@ -48,22 +72,34 @@ exports.commandVerifyPackageHarmony = {
|
|
|
48
72
|
description: 'Disable certain checks by their names separated by ";"',
|
|
49
73
|
},
|
|
50
74
|
],
|
|
51
|
-
func: (argv, config, rawArgs)
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
func: function (argv, config, rawArgs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
76
|
+
var loader, args, checkResults, _a, _b, _c, checkResult, e_1_1, err_1;
|
|
77
|
+
var _d, e_1, _e, _f;
|
|
78
|
+
return __generator(this, function (_g) {
|
|
79
|
+
switch (_g.label) {
|
|
80
|
+
case 0:
|
|
81
|
+
loader = (0, cli_tools_1.getLoader)();
|
|
82
|
+
_g.label = 1;
|
|
83
|
+
case 1:
|
|
84
|
+
_g.trys.push([1, 14, , 15]);
|
|
85
|
+
args = validateArgs(rawArgs);
|
|
86
|
+
loader.info("Verifying RNOH package: ".concat(args.packagePath.getValue()));
|
|
87
|
+
checkResults = [];
|
|
88
|
+
_g.label = 2;
|
|
89
|
+
case 2:
|
|
90
|
+
_g.trys.push([2, 7, 8, 13]);
|
|
91
|
+
_a = true, _b = __asyncValues((0, package_verifier_1.verifyRNOHPackage)({
|
|
92
|
+
npmPackagePath: args.packagePath,
|
|
93
|
+
hasHarmonyCode: args.hasHarmonyCode,
|
|
94
|
+
checkNamesToSkip: args.checkNamesToSkip,
|
|
95
|
+
}));
|
|
96
|
+
_g.label = 3;
|
|
97
|
+
case 3: return [4 /*yield*/, _b.next()];
|
|
98
|
+
case 4:
|
|
99
|
+
if (!(_c = _g.sent(), _d = _c.done, !_d)) return [3 /*break*/, 6];
|
|
100
|
+
_f = _c.value;
|
|
101
|
+
_a = false;
|
|
102
|
+
checkResult = _f;
|
|
67
103
|
if (checkResult.type === 'START_PROCESS') {
|
|
68
104
|
loader.start(chalk_1.default.gray(checkResult.name));
|
|
69
105
|
}
|
|
@@ -71,31 +107,49 @@ exports.commandVerifyPackageHarmony = {
|
|
|
71
107
|
checkResults.push(checkResult);
|
|
72
108
|
logCheckResult(loader, checkResult);
|
|
73
109
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
110
|
+
_g.label = 5;
|
|
111
|
+
case 5:
|
|
112
|
+
_a = true;
|
|
113
|
+
return [3 /*break*/, 3];
|
|
114
|
+
case 6: return [3 /*break*/, 13];
|
|
115
|
+
case 7:
|
|
116
|
+
e_1_1 = _g.sent();
|
|
117
|
+
e_1 = { error: e_1_1 };
|
|
118
|
+
return [3 /*break*/, 13];
|
|
119
|
+
case 8:
|
|
120
|
+
_g.trys.push([8, , 11, 12]);
|
|
121
|
+
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 10];
|
|
122
|
+
return [4 /*yield*/, _e.call(_b)];
|
|
123
|
+
case 9:
|
|
124
|
+
_g.sent();
|
|
125
|
+
_g.label = 10;
|
|
126
|
+
case 10: return [3 /*break*/, 12];
|
|
127
|
+
case 11:
|
|
128
|
+
if (e_1) throw e_1.error;
|
|
129
|
+
return [7 /*endfinally*/];
|
|
130
|
+
case 12: return [7 /*endfinally*/];
|
|
131
|
+
case 13:
|
|
132
|
+
if (checkResults.every(function (checkResult) {
|
|
133
|
+
return checkResult.status === 'pass' || checkResult.status === 'skip';
|
|
134
|
+
})) {
|
|
135
|
+
loader.info(chalk_1.default.bold('OK'));
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
loader.info(chalk_1.default.red('Package verification failed. Please fix those checks before publishing your package.'));
|
|
139
|
+
process.exit(1);
|
|
140
|
+
}
|
|
141
|
+
return [3 /*break*/, 15];
|
|
142
|
+
case 14:
|
|
143
|
+
err_1 = _g.sent();
|
|
144
|
+
if (err_1 instanceof core_1.DescriptiveError) {
|
|
145
|
+
new io_1.Logger().descriptiveError(err_1);
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
throw err_1;
|
|
149
|
+
case 15: return [2 /*return*/];
|
|
95
150
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}),
|
|
151
|
+
});
|
|
152
|
+
}); },
|
|
99
153
|
};
|
|
100
154
|
function validateArgs(args) {
|
|
101
155
|
var _a;
|
|
@@ -112,17 +166,17 @@ function validateArgs(args) {
|
|
|
112
166
|
};
|
|
113
167
|
}
|
|
114
168
|
function logCheckResult(loader, checkResult) {
|
|
115
|
-
|
|
169
|
+
var prefix = (function () {
|
|
116
170
|
switch (checkResult.status) {
|
|
117
171
|
case 'pass':
|
|
118
|
-
return
|
|
172
|
+
return "".concat(chalk_1.default.green('PASS'));
|
|
119
173
|
case 'fail':
|
|
120
|
-
return
|
|
174
|
+
return "".concat(chalk_1.default.red('FAIL'));
|
|
121
175
|
case 'skip':
|
|
122
|
-
return
|
|
176
|
+
return "".concat(chalk_1.default.yellow('SKIP'));
|
|
123
177
|
}
|
|
124
178
|
})();
|
|
125
179
|
loader.info(checkResult.message
|
|
126
|
-
?
|
|
127
|
-
:
|
|
180
|
+
? "[".concat(chalk_1.default.bold(prefix), "] ").concat(chalk_1.default.bold(checkResult.name), "\n").concat(checkResult.message)
|
|
181
|
+
: "[".concat(chalk_1.default.bold(prefix), "] ").concat(chalk_1.default.bold(checkResult.name)));
|
|
128
182
|
}
|