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