@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.
Files changed (138) hide show
  1. package/README.md +11 -11
  2. package/dist/assetResolver.js +74 -43
  3. package/dist/autolinking/Autolinking.js +183 -179
  4. package/dist/codegen/core/CodegenError.js +23 -3
  5. package/dist/codegen/core/EventUtils.js +3 -3
  6. package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
  7. package/dist/codegen/core/UberSchema.js +96 -57
  8. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +41 -28
  9. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
  10. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
  11. package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
  12. package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
  13. package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
  14. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  15. package/dist/codegen/generators/UberGeneratorV1.js +24 -18
  16. package/dist/codegen/generators/UberGeneratorV2.js +36 -28
  17. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
  18. package/dist/codegen/templates/BasePackageHTemplate.js +21 -120
  19. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -53
  20. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
  21. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
  22. package/dist/codegen/templates/IndexTSTemplate.js +17 -37
  23. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -119
  24. package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
  25. package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
  26. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
  27. package/dist/commands/bundle-harmony.js +138 -53
  28. package/dist/commands/codegen-harmony.js +175 -104
  29. package/dist/commands/codegen-lib-harmony.js +116 -76
  30. package/dist/commands/create-metro-host-constants.js +47 -18
  31. package/dist/commands/init.js +961 -537
  32. package/dist/commands/link-harmony.js +71 -33
  33. package/dist/commands/pack-harmony.js +108 -47
  34. package/dist/commands/run-harmony.js +518 -374
  35. package/dist/commands/unpack-harmony.js +198 -105
  36. package/dist/commands/verify-package-harmony.js +108 -54
  37. package/dist/core/AbsolutePath.js +47 -31
  38. package/dist/core/CodegenConfig.js +22 -24
  39. package/dist/core/DescriptiveError.js +37 -18
  40. package/dist/core/FileSystem.js +18 -14
  41. package/dist/core/OHPackageJSON5.js +23 -17
  42. package/dist/core/PackageJSON.js +42 -26
  43. package/dist/core/ProjectDependenciesManager.js +96 -46
  44. package/dist/core/ValidationError.js +22 -2
  45. package/dist/core/fs.js +6 -9
  46. package/dist/index.js +1 -1
  47. package/dist/io/CliExecutor.js +98 -46
  48. package/dist/io/Logger.js +46 -40
  49. package/dist/io/RealFS.js +88 -35
  50. package/dist/io/TarGz.js +8 -11
  51. package/dist/io/__fixtures__.js +141 -79
  52. package/dist/io/fsUtils.js +12 -13
  53. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
  54. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
  55. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
  56. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
  57. package/dist/package-verifier/verify-package.js +132 -55
  58. package/dist/simulator/LaunchSimulator.js +301 -217
  59. package/jest.config.js +12 -12
  60. package/package.json +78 -70
  61. package/react-native.config.js +17 -17
  62. package/tsconfig.build.json +6 -6
  63. package/tsconfig.json +2 -2
  64. package/.prettierrc +0 -6
  65. package/src/assetResolver.ts +0 -134
  66. package/src/autolinking/Autolinking.test.ts +0 -483
  67. package/src/autolinking/Autolinking.ts +0 -382
  68. package/src/autolinking/index.ts +0 -8
  69. package/src/codegen/core/CodeGenerator.ts +0 -16
  70. package/src/codegen/core/CodegenError.ts +0 -10
  71. package/src/codegen/core/EventUtils.ts +0 -23
  72. package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
  73. package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
  74. package/src/codegen/core/UberSchema.ts +0 -152
  75. package/src/codegen/core/index.ts +0 -12
  76. package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -124
  77. package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
  78. package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
  79. package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
  80. package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
  81. package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
  82. package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
  83. package/src/codegen/generators/UberGeneratorV1.ts +0 -75
  84. package/src/codegen/generators/UberGeneratorV2.ts +0 -114
  85. package/src/codegen/generators/index.ts +0 -15
  86. package/src/codegen/index.ts +0 -9
  87. package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
  88. package/src/codegen/templates/BasePackageHTemplate.ts +0 -159
  89. package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
  90. package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
  91. package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
  92. package/src/codegen/templates/IndexTSTemplate.ts +0 -62
  93. package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -150
  94. package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
  95. package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
  96. package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
  97. package/src/codegen/templates/index.ts +0 -16
  98. package/src/commands/bundle-harmony.ts +0 -134
  99. package/src/commands/codegen-harmony.ts +0 -297
  100. package/src/commands/codegen-lib-harmony.ts +0 -389
  101. package/src/commands/create-metro-host-constants.ts +0 -55
  102. package/src/commands/index.ts +0 -16
  103. package/src/commands/init.ts +0 -755
  104. package/src/commands/link-harmony.ts +0 -102
  105. package/src/commands/pack-harmony.ts +0 -128
  106. package/src/commands/run-harmony.ts +0 -506
  107. package/src/commands/types.ts +0 -21
  108. package/src/commands/unpack-harmony.ts +0 -238
  109. package/src/commands/verify-package-harmony.ts +0 -113
  110. package/src/core/AbsolutePath.ts +0 -66
  111. package/src/core/CodegenConfig.ts +0 -67
  112. package/src/core/DescriptiveError.ts +0 -68
  113. package/src/core/FileSystem.ts +0 -57
  114. package/src/core/OHPackageJSON5.ts +0 -30
  115. package/src/core/PackageJSON.ts +0 -104
  116. package/src/core/ProjectDependenciesManager.ts +0 -103
  117. package/src/core/ValidationError.ts +0 -8
  118. package/src/core/ValueObject.ts +0 -9
  119. package/src/core/fs.ts +0 -38
  120. package/src/core/index.ts +0 -17
  121. package/src/index.ts +0 -33
  122. package/src/io/CliExecutor.ts +0 -69
  123. package/src/io/Logger.ts +0 -112
  124. package/src/io/RealFS.ts +0 -62
  125. package/src/io/TarGz.ts +0 -33
  126. package/src/io/__fixtures__.ts +0 -139
  127. package/src/io/fsUtils.ts +0 -44
  128. package/src/io/index.ts +0 -11
  129. package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
  130. package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
  131. package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
  132. package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
  133. package/src/package-verifier/checks/index.ts +0 -11
  134. package/src/package-verifier/index.ts +0 -9
  135. package/src/package-verifier/types.ts +0 -19
  136. package/src/package-verifier/verify-package.ts +0 -123
  137. package/src/simulator/LaunchSimulator.ts +0 -352
  138. 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 __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
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
- 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");
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) => __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);
52
- }
53
- else {
54
- throw err;
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
- 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
- }
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
- 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)}`);
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
- const ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
132
- for (const ohModuleInfo of ohModulesInfo) {
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
- const ohPackagePath = modulePath.copyWithNewSegment('oh-package.json5');
234
+ var ohPackagePath = modulePath.copyWithNewSegment('oh-package.json5');
143
235
  if (!fs_1.default.existsSync(ohPackagePath.getValue()))
144
236
  return null;
145
- const content = fs_1.default.readFileSync(ohPackagePath.getValue(), {
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
- const results = [];
243
+ var results = [];
152
244
  if (!fs_1.default.existsSync(pkgHarmonyDirPath.getValue()))
153
245
  return [];
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
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
- const computedModulePath = outputDirPath.copyWithNewSegment(computedModuleName);
254
+ var computedModulePath = outputDirPath.copyWithNewSegment(computedModuleName);
162
255
  results.push({
163
- archivePath,
164
- archiveFileName: name,
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
- const readStream = fs_1.default.createReadStream(archivePath.getValue());
177
- const writeStream = tar_1.default.extract({
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
- 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");
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) => __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;
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
- 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);
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
- throw err;
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
- const prefix = (() => {
169
+ var prefix = (function () {
116
170
  switch (checkResult.status) {
117
171
  case 'pass':
118
- return `${chalk_1.default.green('PASS')}`;
172
+ return "".concat(chalk_1.default.green('PASS'));
119
173
  case 'fail':
120
- return `${chalk_1.default.red('FAIL')}`;
174
+ return "".concat(chalk_1.default.red('FAIL'));
121
175
  case 'skip':
122
- return `${chalk_1.default.yellow('SKIP')}`;
176
+ return "".concat(chalk_1.default.yellow('SKIP'));
123
177
  }
124
178
  })();
125
179
  loader.info(checkResult.message
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)}`);
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
  }