@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.
Files changed (65) hide show
  1. package/README.md +11 -11
  2. package/dist/assetResolver.js +74 -77
  3. package/dist/autolinking/Autolinking.js +179 -179
  4. package/dist/autolinking/JSON5Writer.js +61 -0
  5. package/dist/codegen/core/CodegenError.js +3 -23
  6. package/dist/codegen/core/EventUtils.js +3 -3
  7. package/dist/codegen/core/TypeAnnotationToTS.js +24 -28
  8. package/dist/codegen/core/UberSchema.js +57 -96
  9. package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +28 -41
  10. package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +27 -34
  11. package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +25 -33
  12. package/dist/codegen/generators/CppComponentCodeGenerator.js +23 -28
  13. package/dist/codegen/generators/LibGlueCodeGenerator.js +26 -29
  14. package/dist/codegen/generators/NativeModuleCodeGenerator.js +25 -30
  15. package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
  16. package/dist/codegen/generators/UberGeneratorV1.js +24 -23
  17. package/dist/codegen/generators/UberGeneratorV2.js +34 -35
  18. package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +50 -24
  19. package/dist/codegen/templates/BasePackageHTemplate.js +120 -21
  20. package/dist/codegen/templates/ComponentDescriptorHTemplate.js +53 -8
  21. package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +75 -27
  22. package/dist/codegen/templates/ComponentUtilsTSTemplate.js +162 -29
  23. package/dist/codegen/templates/IndexTSTemplate.js +37 -17
  24. package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +119 -24
  25. package/dist/codegen/templates/TurboModuleCppTemplate.js +38 -15
  26. package/dist/codegen/templates/TurboModuleHTemplate.js +32 -11
  27. package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +52 -19
  28. package/dist/commands/bundle-harmony.js +65 -138
  29. package/dist/commands/codegen-harmony.js +105 -165
  30. package/dist/commands/codegen-lib-harmony.js +76 -116
  31. package/dist/commands/create-metro-host-constants.js +18 -47
  32. package/dist/commands/init.js +537 -961
  33. package/dist/commands/link-harmony.js +33 -71
  34. package/dist/commands/pack-harmony.js +47 -108
  35. package/dist/commands/run-harmony.js +372 -518
  36. package/dist/commands/unpack-harmony.js +105 -198
  37. package/dist/commands/verify-package-harmony.js +54 -108
  38. package/dist/core/AbsolutePath.js +31 -47
  39. package/dist/core/CodegenConfig.js +24 -22
  40. package/dist/core/DescriptiveError.js +18 -37
  41. package/dist/core/FileSystem.js +14 -18
  42. package/dist/core/OHPackageJSON5.js +17 -23
  43. package/dist/core/PackageJSON.js +26 -42
  44. package/dist/core/ProjectDependenciesManager.js +40 -92
  45. package/dist/core/ValidationError.js +2 -22
  46. package/dist/core/fs.js +9 -6
  47. package/dist/index.js +1 -1
  48. package/dist/io/CliExecutor.js +46 -98
  49. package/dist/io/Logger.js +40 -46
  50. package/dist/io/RealFS.js +35 -88
  51. package/dist/io/TarGz.js +11 -8
  52. package/dist/io/__fixtures__.js +79 -141
  53. package/dist/io/fsUtils.js +13 -12
  54. package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +19 -47
  55. package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +13 -41
  56. package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +8 -38
  57. package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +22 -54
  58. package/dist/package-verifier/verify-package.js +55 -132
  59. package/dist/simulator/LaunchSimulator.js +224 -301
  60. package/harmony/rnoh-hvigor-plugin-0.3.0.tgz +0 -0
  61. package/jest.config.js +12 -12
  62. package/package.json +79 -78
  63. package/react-native.config.js +17 -17
  64. package/tsconfig.build.json +6 -6
  65. package/tsconfig.json +2 -2
@@ -5,71 +5,55 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
9
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
10
- if (ar || !(i in from)) {
11
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
12
- ar[i] = from[i];
13
- }
14
- }
15
- return to.concat(ar || Array.prototype.slice.call(from));
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
16
10
  };
17
11
  Object.defineProperty(exports, "__esModule", { value: true });
18
12
  exports.AbsolutePath = void 0;
19
- var node_path_1 = require("node:path");
20
- var AbsolutePath = /** @class */ (function () {
21
- function AbsolutePath(path) {
13
+ const node_path_1 = __importDefault(require("node:path"));
14
+ class AbsolutePath {
15
+ static fromSegments(...segments) {
16
+ return new AbsolutePath(node_path_1.default.join(...segments));
17
+ }
18
+ constructor(path) {
22
19
  this.value = '';
23
20
  this.value = node_path_1.default.resolve(path);
24
21
  }
25
- AbsolutePath.fromSegments = function () {
26
- var segments = [];
27
- for (var _i = 0; _i < arguments.length; _i++) {
28
- segments[_i] = arguments[_i];
29
- }
30
- return new AbsolutePath(node_path_1.default.join.apply(node_path_1.default, segments));
31
- };
32
- AbsolutePath.prototype.getValue = function () {
22
+ getValue() {
33
23
  return this.value;
34
- };
35
- AbsolutePath.prototype.toString = function () {
24
+ }
25
+ toString() {
36
26
  return this.value;
37
- };
38
- AbsolutePath.prototype.copyWithNewSegment = function () {
39
- var relativePath = [];
40
- for (var _i = 0; _i < arguments.length; _i++) {
41
- relativePath[_i] = arguments[_i];
42
- }
43
- return new AbsolutePath(node_path_1.default.join.apply(node_path_1.default, __spreadArray([this.getValue()], relativePath, false)));
44
- };
45
- AbsolutePath.prototype.getExtension = function () {
46
- var maybeExtWithDot = node_path_1.default.extname(this.value);
27
+ }
28
+ copyWithNewSegment(...relativePath) {
29
+ return new AbsolutePath(node_path_1.default.join(this.getValue(), ...relativePath));
30
+ }
31
+ getExtension() {
32
+ const maybeExtWithDot = node_path_1.default.extname(this.value);
47
33
  if (maybeExtWithDot) {
48
34
  return maybeExtWithDot.substring(1);
49
35
  }
50
36
  return null;
51
- };
52
- AbsolutePath.prototype.getDirectoryPath = function () {
53
- var dirPath = node_path_1.default.extname(this.value)
37
+ }
38
+ getDirectoryPath() {
39
+ const dirPath = node_path_1.default.extname(this.value)
54
40
  ? node_path_1.default.dirname(this.value)
55
41
  : this.value;
56
42
  return new AbsolutePath(dirPath);
57
- };
58
- AbsolutePath.prototype.relativeTo = function (absolutePath) {
43
+ }
44
+ relativeTo(absolutePath) {
59
45
  return new RelativePath(node_path_1.default.relative(absolutePath.getValue(), this.value));
60
- };
61
- return AbsolutePath;
62
- }());
46
+ }
47
+ }
63
48
  exports.AbsolutePath = AbsolutePath;
64
- var RelativePath = /** @class */ (function () {
65
- function RelativePath(value) {
49
+ class RelativePath {
50
+ constructor(value) {
66
51
  this.value = value;
67
52
  }
68
- RelativePath.prototype.getValue = function () {
53
+ getValue() {
69
54
  return this.value;
70
- };
71
- RelativePath.prototype.toString = function () {
55
+ }
56
+ toString() {
72
57
  return this.value;
73
- };
74
- return RelativePath;
75
- }());
58
+ }
59
+ }
@@ -5,20 +5,19 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.CodegenConfig = void 0;
10
- var node_fs_1 = require("node:fs");
11
- var io_1 = require("../io");
12
- var DescriptiveError_1 = require("./DescriptiveError");
13
- var CodegenConfig = /** @class */ (function () {
14
- function CodegenConfig(specFilePaths, version) {
15
- this.specFilePaths = specFilePaths;
16
- this.version = version;
17
- }
18
- CodegenConfig.fromRawCodegenConfig = function (rawCodegenConfig, packageRootPath, projectRootPath, packageName) {
13
+ const node_fs_1 = __importDefault(require("node:fs"));
14
+ const io_1 = require("../io");
15
+ const DescriptiveError_1 = require("./DescriptiveError");
16
+ class CodegenConfig {
17
+ static fromRawCodegenConfig(rawCodegenConfig, packageRootPath, projectRootPath, packageName) {
19
18
  var _a, _b;
20
- var SUPPORTED_SPEC_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'];
21
- var specPaths = ((_a = rawCodegenConfig.specPaths) !== null && _a !== void 0 ? _a : []).map(function (rawSpecPath) {
19
+ const SUPPORTED_SPEC_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'];
20
+ const specPaths = ((_a = rawCodegenConfig.specPaths) !== null && _a !== void 0 ? _a : []).map((rawSpecPath) => {
22
21
  if (rawSpecPath.startsWith('~')) {
23
22
  return projectRootPath.copyWithNewSegment(rawSpecPath.replace('~', ''));
24
23
  }
@@ -26,12 +25,12 @@ var CodegenConfig = /** @class */ (function () {
26
25
  return packageRootPath.copyWithNewSegment(rawSpecPath);
27
26
  }
28
27
  });
29
- var specFilePaths = specPaths.flatMap(function (specPath) {
28
+ const specFilePaths = specPaths.flatMap((specPath) => {
30
29
  if (!node_fs_1.default.existsSync(specPath.getValue())) {
31
30
  throw new DescriptiveError_1.DescriptiveError({
32
- whatHappened: "No such file or directory: ".concat(specPath.getValue()),
31
+ whatHappened: `No such file or directory: ${specPath.getValue()}`,
33
32
  whatCanUserDo: [
34
- "Please verify \"".concat(packageName, "/package.json::harmony::codegenConfig\". If you are not the maintainer of this package, please report this problem to the package maintainer."),
33
+ `Please verify "${packageName}/package.json::harmony::codegenConfig". If you are not the maintainer of this package, please report this problem to the package maintainer.`,
35
34
  ],
36
35
  });
37
36
  }
@@ -39,7 +38,7 @@ var CodegenConfig = /** @class */ (function () {
39
38
  return (0, io_1.findFilePathsWithExtensions)(specPath, SUPPORTED_SPEC_EXTENSIONS);
40
39
  }
41
40
  else {
42
- var ext = specPath.getExtension();
41
+ const ext = specPath.getExtension();
43
42
  if (ext && SUPPORTED_SPEC_EXTENSIONS.includes(ext)) {
44
43
  return [specPath];
45
44
  }
@@ -47,13 +46,16 @@ var CodegenConfig = /** @class */ (function () {
47
46
  }
48
47
  });
49
48
  return new CodegenConfig(specFilePaths, (_b = rawCodegenConfig.version) !== null && _b !== void 0 ? _b : 1);
50
- };
51
- CodegenConfig.prototype.getSpecFilePaths = function () {
49
+ }
50
+ constructor(specFilePaths, version) {
51
+ this.specFilePaths = specFilePaths;
52
+ this.version = version;
53
+ }
54
+ getSpecFilePaths() {
52
55
  return this.specFilePaths;
53
- };
54
- CodegenConfig.prototype.getVersion = function () {
56
+ }
57
+ getVersion() {
55
58
  return this.version;
56
- };
57
- return CodegenConfig;
58
- }());
59
+ }
60
+ }
59
61
  exports.CodegenConfig = CodegenConfig;
@@ -5,37 +5,20 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
- var __extends = (this && this.__extends) || (function () {
9
- var extendStatics = function (d, b) {
10
- extendStatics = Object.setPrototypeOf ||
11
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
13
- return extendStatics(d, b);
14
- };
15
- return function (d, b) {
16
- if (typeof b !== "function" && b !== null)
17
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
18
- extendStatics(d, b);
19
- function __() { this.constructor = d; }
20
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21
- };
22
- })();
23
8
  Object.defineProperty(exports, "__esModule", { value: true });
24
9
  exports.DescriptiveError = void 0;
25
- var DescriptiveError = /** @class */ (function (_super) {
26
- __extends(DescriptiveError, _super);
27
- function DescriptiveError(data) {
28
- var _this = _super.call(this, data.whatHappened) || this;
29
- _this.data = data;
30
- return _this;
10
+ class DescriptiveError extends Error {
11
+ constructor(data) {
12
+ super(data.whatHappened);
13
+ this.data = data;
31
14
  }
32
- DescriptiveError.prototype.isUnexpected = function () {
15
+ isUnexpected() {
33
16
  return 'unexpected' in this.data;
34
- };
35
- DescriptiveError.prototype.getMessage = function () {
17
+ }
18
+ getMessage() {
36
19
  return this.data.whatHappened;
37
- };
38
- DescriptiveError.prototype.getSuggestions = function () {
20
+ }
21
+ getSuggestions() {
39
22
  var _a;
40
23
  if ('whatCanUserDo' in this.data) {
41
24
  return (_a = this.data.whatCanUserDo) !== null && _a !== void 0 ? _a : [];
@@ -43,11 +26,11 @@ var DescriptiveError = /** @class */ (function (_super) {
43
26
  else {
44
27
  return [];
45
28
  }
46
- };
47
- DescriptiveError.prototype.getRawData = function () {
29
+ }
30
+ getRawData() {
48
31
  return this.data;
49
- };
50
- DescriptiveError.prototype.getDetails = function () {
32
+ }
33
+ getDetails() {
51
34
  var _a;
52
35
  if (!this.data.extraData) {
53
36
  return '';
@@ -56,11 +39,10 @@ var DescriptiveError = /** @class */ (function (_super) {
56
39
  return this.data.extraData.trim();
57
40
  }
58
41
  if (this.data.extraData instanceof Error) {
59
- var lines = [
60
- "".concat(this.data.extraData.name, ": ").concat(this.data.extraData.message),
42
+ let lines = [
43
+ `${this.data.extraData.name}: ${this.data.extraData.message}`,
61
44
  ];
62
- for (var _i = 0, _b = ((_a = this.data.extraData.stack) !== null && _a !== void 0 ? _a : '').split('\n'); _i < _b.length; _i++) {
63
- var stackEntry = _b[_i];
45
+ for (let stackEntry of ((_a = this.data.extraData.stack) !== null && _a !== void 0 ? _a : '').split('\n')) {
64
46
  lines.push('');
65
47
  lines.push(stackEntry);
66
48
  }
@@ -72,7 +54,6 @@ var DescriptiveError = /** @class */ (function (_super) {
72
54
  catch (err) {
73
55
  return '';
74
56
  }
75
- };
76
- return DescriptiveError;
77
- }(Error));
57
+ }
58
+ }
78
59
  exports.DescriptiveError = DescriptiveError;
@@ -5,24 +5,21 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.FS = exports.Dirent = void 0;
10
- var node_path_1 = require("node:path");
11
- var Dirent = /** @class */ (function () {
12
- function Dirent() {
13
- }
14
- return Dirent;
15
- }());
13
+ const node_path_1 = __importDefault(require("node:path"));
14
+ class Dirent {
15
+ }
16
16
  exports.Dirent = Dirent;
17
- var FS = /** @class */ (function () {
18
- function FS() {
19
- }
20
- FS.prototype.findFilePathsWithExtensions = function (dirPath, fileExtensions) {
21
- var results = [];
22
- var dirents = this.readDirentsSync(dirPath);
23
- for (var _i = 0, dirents_1 = dirents; _i < dirents_1.length; _i++) {
24
- var dirent = dirents_1[_i];
25
- var path = dirPath.copyWithNewSegment(dirent.name.toString());
17
+ class FS {
18
+ findFilePathsWithExtensions(dirPath, fileExtensions) {
19
+ let results = [];
20
+ const dirents = this.readDirentsSync(dirPath);
21
+ for (const dirent of dirents) {
22
+ const path = dirPath.copyWithNewSegment(dirent.name.toString());
26
23
  if (dirent.isDirectory()) {
27
24
  results = results.concat(this.findFilePathsWithExtensions(path, fileExtensions));
28
25
  }
@@ -31,7 +28,6 @@ var FS = /** @class */ (function () {
31
28
  }
32
29
  }
33
30
  return results;
34
- };
35
- return FS;
36
- }());
31
+ }
32
+ }
37
33
  exports.FS = FS;
@@ -5,31 +5,25 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
+ var __importDefault = (this && this.__importDefault) || function (mod) {
9
+ return (mod && mod.__esModule) ? mod : { "default": mod };
10
+ };
8
11
  Object.defineProperty(exports, "__esModule", { value: true });
9
12
  exports.OHPackageJSON5 = void 0;
10
- var json5_1 = require("json5");
11
- var node_fs_1 = require("node:fs");
12
- var OHPackageJSON5 = /** @class */ (function () {
13
- function OHPackageJSON5(rawData) {
13
+ const json5_1 = __importDefault(require("json5"));
14
+ const node_fs_1 = __importDefault(require("node:fs"));
15
+ class OHPackageJSON5 {
16
+ static fromPath(ohPackageJson5Path) {
17
+ return new OHPackageJSON5(json5_1.default.parse(node_fs_1.default.readFileSync(ohPackageJson5Path.getValue(), { encoding: 'utf-8' })));
18
+ }
19
+ constructor(rawData) {
14
20
  this.rawData = rawData;
15
21
  }
16
- OHPackageJSON5.fromPath = function (ohPackageJson5Path) {
17
- return new OHPackageJSON5(json5_1.default.parse(node_fs_1.default.readFileSync(ohPackageJson5Path.getValue(), { encoding: 'utf-8' })));
18
- };
19
- Object.defineProperty(OHPackageJSON5.prototype, "name", {
20
- get: function () {
21
- return this.rawData['name'];
22
- },
23
- enumerable: false,
24
- configurable: true
25
- });
26
- Object.defineProperty(OHPackageJSON5.prototype, "version", {
27
- get: function () {
28
- return this.rawData['version'];
29
- },
30
- enumerable: false,
31
- configurable: true
32
- });
33
- return OHPackageJSON5;
34
- }());
22
+ get name() {
23
+ return this.rawData['name'];
24
+ }
25
+ get version() {
26
+ return this.rawData['version'];
27
+ }
28
+ }
35
29
  exports.OHPackageJSON5 = OHPackageJSON5;
@@ -1,16 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PackageJSON = void 0;
4
- var CodegenConfig_1 = require("./CodegenConfig");
5
- var DescriptiveError_1 = require("./DescriptiveError");
6
- var PackageJSON = /** @class */ (function () {
7
- function PackageJSON(rawPackageJSON, packageRootPath, projectRootPath) {
8
- this.rawPackageJSON = rawPackageJSON;
9
- this.packageRootPath = packageRootPath;
10
- this.projectRootPath = projectRootPath;
11
- }
12
- PackageJSON.fromProjectRootPath = function (fs, packageRootPath, projectRootPath) {
13
- var packageJSONPath = packageRootPath.copyWithNewSegment('package.json');
4
+ const CodegenConfig_1 = require("./CodegenConfig");
5
+ const DescriptiveError_1 = require("./DescriptiveError");
6
+ class PackageJSON {
7
+ static fromProjectRootPath(fs, packageRootPath, projectRootPath) {
8
+ const packageJSONPath = packageRootPath.copyWithNewSegment('package.json');
14
9
  if (!fs.existsSync(packageJSONPath)) {
15
10
  throw new DescriptiveError_1.DescriptiveError({
16
11
  whatHappened: "Couldn't find 'package.json'",
@@ -27,33 +22,25 @@ var PackageJSON = /** @class */ (function () {
27
22
  catch (err) {
28
23
  throw new DescriptiveError_1.DescriptiveError({
29
24
  whatHappened: "Couldn't parse package.json",
30
- extraData: { packageJSONPath: packageJSONPath, err: err },
25
+ extraData: { packageJSONPath, err },
31
26
  });
32
27
  }
33
- };
34
- Object.defineProperty(PackageJSON.prototype, "name", {
35
- get: function () {
36
- return this.rawPackageJSON.name;
37
- },
38
- enumerable: false,
39
- configurable: true
40
- });
41
- Object.defineProperty(PackageJSON.prototype, "version", {
42
- get: function () {
43
- return this.rawPackageJSON.version;
44
- },
45
- enumerable: false,
46
- configurable: true
47
- });
48
- Object.defineProperty(PackageJSON.prototype, "harmony", {
49
- get: function () {
50
- return this.rawPackageJSON.harmony;
51
- },
52
- enumerable: false,
53
- configurable: true
54
- });
55
- PackageJSON.prototype.getCodegenConfigs = function () {
56
- var _this = this;
28
+ }
29
+ constructor(rawPackageJSON, packageRootPath, projectRootPath) {
30
+ this.rawPackageJSON = rawPackageJSON;
31
+ this.packageRootPath = packageRootPath;
32
+ this.projectRootPath = projectRootPath;
33
+ }
34
+ get name() {
35
+ return this.rawPackageJSON.name;
36
+ }
37
+ get version() {
38
+ return this.rawPackageJSON.version;
39
+ }
40
+ get harmony() {
41
+ return this.rawPackageJSON.harmony;
42
+ }
43
+ getCodegenConfigs() {
57
44
  var _a;
58
45
  /**
59
46
  * Shared codegenConfig is not used on purpose. Android, iOS and other platforms shouldn't
@@ -61,19 +48,16 @@ var PackageJSON = /** @class */ (function () {
61
48
  * that the shape of the shared config, to allow specifying which specific turbo modules or
62
49
  * fabric components should be code generated.
63
50
  */
64
- var rawCodegenConfig = (_a = this.rawPackageJSON.harmony) === null || _a === void 0 ? void 0 : _a.codegenConfig;
51
+ const rawCodegenConfig = (_a = this.rawPackageJSON.harmony) === null || _a === void 0 ? void 0 : _a.codegenConfig;
65
52
  if (!rawCodegenConfig) {
66
53
  return [];
67
54
  }
68
55
  if (Array.isArray(rawCodegenConfig)) {
69
- return rawCodegenConfig.map(function (config) {
70
- return CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(config, _this.packageRootPath, _this.projectRootPath, _this.name);
71
- });
56
+ return rawCodegenConfig.map((config) => CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(config, this.packageRootPath, this.projectRootPath, this.name));
72
57
  }
73
58
  return [
74
59
  CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(rawCodegenConfig, this.packageRootPath, this.projectRootPath, this.name),
75
60
  ];
76
- };
77
- return PackageJSON;
78
- }());
61
+ }
62
+ }
79
63
  exports.PackageJSON = PackageJSON;
@@ -14,120 +14,68 @@ 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.ProjectDependenciesManager = exports.ProjectDependency = void 0;
46
- var PackageJSON_1 = require("./PackageJSON");
47
- var ProjectDependency = /** @class */ (function () {
48
- function ProjectDependency(fs, packageRootPath, projectRootPath) {
19
+ const PackageJSON_1 = require("./PackageJSON");
20
+ class ProjectDependency {
21
+ constructor(fs, packageRootPath, projectRootPath) {
49
22
  this.fs = fs;
50
23
  this.packageRootPath = packageRootPath;
51
24
  this.projectRootPath = projectRootPath;
52
25
  }
53
- ProjectDependency.prototype.getRootPath = function () {
26
+ getRootPath() {
54
27
  return this.packageRootPath;
55
- };
56
- ProjectDependency.prototype.getCodegenConfigs = function () {
28
+ }
29
+ getCodegenConfigs() {
57
30
  return this.readPackageJSON().getCodegenConfigs();
58
- };
59
- ProjectDependency.prototype.getHarFilePaths = function () {
60
- var packageHarmonyPath = this.packageRootPath.copyWithNewSegment('harmony');
31
+ }
32
+ getHarFilePaths() {
33
+ const packageHarmonyPath = this.packageRootPath.copyWithNewSegment('harmony');
61
34
  if (this.fs.existsSync(packageHarmonyPath)) {
62
35
  return this.fs.findFilePathsWithExtensions(packageHarmonyPath, ['har']);
63
36
  }
64
37
  else {
65
38
  return this.fs.findFilePathsWithExtensions(this.packageRootPath, ['har']);
66
39
  }
67
- };
68
- ProjectDependency.prototype.readPackageJSON = function () {
40
+ }
41
+ readPackageJSON() {
69
42
  return PackageJSON_1.PackageJSON.fromProjectRootPath(this.fs, this.packageRootPath, this.projectRootPath);
70
- };
71
- return ProjectDependency;
72
- }());
43
+ }
44
+ }
73
45
  exports.ProjectDependency = ProjectDependency;
74
- var ProjectDependenciesManager = /** @class */ (function () {
75
- function ProjectDependenciesManager(fs, projectRootPath) {
46
+ class ProjectDependenciesManager {
47
+ constructor(fs, projectRootPath) {
76
48
  this.fs = fs;
77
49
  this.projectRootPath = projectRootPath;
78
50
  }
79
- ProjectDependenciesManager.prototype.forEachAsync = function (cb) {
80
- return __awaiter(this, void 0, void 0, function () {
81
- return __generator(this, function (_a) {
82
- switch (_a.label) {
83
- case 0: return [4 /*yield*/, this.forEachDependencyInDirectory(cb, this.projectRootPath.copyWithNewSegment('node_modules'))];
84
- case 1:
85
- _a.sent();
86
- return [2 /*return*/];
87
- }
88
- });
51
+ forEachAsync(cb) {
52
+ return __awaiter(this, void 0, void 0, function* () {
53
+ yield this.forEachDependencyInDirectory(cb, this.projectRootPath.copyWithNewSegment('node_modules'));
89
54
  });
90
- };
91
- ProjectDependenciesManager.prototype.forEachDependencyInDirectory = function (cb, directoryPath) {
92
- return __awaiter(this, void 0, void 0, function () {
93
- var _i, _a, dirent, potentialDependencyRootPath;
94
- return __generator(this, function (_b) {
95
- switch (_b.label) {
96
- case 0:
97
- if (!this.fs.existsSync(directoryPath)) {
98
- return [2 /*return*/];
99
- }
100
- _i = 0, _a = this.fs.readDirentsSync(directoryPath);
101
- _b.label = 1;
102
- case 1:
103
- if (!(_i < _a.length)) return [3 /*break*/, 7];
104
- dirent = _a[_i];
105
- if (!dirent.isDirectory()) return [3 /*break*/, 6];
106
- if (!dirent.name.startsWith('.')) return [3 /*break*/, 2];
107
- return [3 /*break*/, 6];
108
- case 2:
109
- if (!dirent.name.startsWith('@')) return [3 /*break*/, 4];
110
- return [4 /*yield*/, this.forEachDependencyInDirectory(cb, directoryPath.copyWithNewSegment(dirent.name))];
111
- case 3:
112
- _b.sent();
113
- return [3 /*break*/, 6];
114
- case 4:
115
- potentialDependencyRootPath = directoryPath.copyWithNewSegment(dirent.name);
55
+ }
56
+ forEachDependencyInDirectory(cb, directoryPath) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ if (!this.fs.existsSync(directoryPath)) {
59
+ return;
60
+ }
61
+ for (let dirent of this.fs.readDirentsSync(directoryPath)) {
62
+ if (dirent.isDirectory()) {
63
+ if (dirent.name.startsWith('.')) {
64
+ continue;
65
+ }
66
+ else if (dirent.name.startsWith('@')) {
67
+ yield this.forEachDependencyInDirectory(cb, directoryPath.copyWithNewSegment(dirent.name));
68
+ }
69
+ else {
70
+ const potentialDependencyRootPath = directoryPath.copyWithNewSegment(dirent.name);
116
71
  if (!this.fs.existsSync(potentialDependencyRootPath.copyWithNewSegment('package.json'))) {
117
- return [3 /*break*/, 6];
72
+ continue;
118
73
  }
119
- return [4 /*yield*/, cb(new ProjectDependency(this.fs, potentialDependencyRootPath, this.projectRootPath))];
120
- case 5:
121
- _b.sent();
122
- _b.label = 6;
123
- case 6:
124
- _i++;
125
- return [3 /*break*/, 1];
126
- case 7: return [2 /*return*/];
74
+ yield cb(new ProjectDependency(this.fs, potentialDependencyRootPath, this.projectRootPath));
75
+ }
127
76
  }
128
- });
77
+ }
129
78
  });
130
- };
131
- return ProjectDependenciesManager;
132
- }());
79
+ }
80
+ }
133
81
  exports.ProjectDependenciesManager = ProjectDependenciesManager;
@@ -5,28 +5,8 @@
5
5
  * This source code is licensed under the MIT license found in the
6
6
  * LICENSE-MIT file in the root directory of this source tree.
7
7
  */
8
- var __extends = (this && this.__extends) || (function () {
9
- var extendStatics = function (d, b) {
10
- extendStatics = Object.setPrototypeOf ||
11
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
12
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
13
- return extendStatics(d, b);
14
- };
15
- return function (d, b) {
16
- if (typeof b !== "function" && b !== null)
17
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
18
- extendStatics(d, b);
19
- function __() { this.constructor = d; }
20
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21
- };
22
- })();
23
8
  Object.defineProperty(exports, "__esModule", { value: true });
24
9
  exports.ValidationError = void 0;
25
- var ValidationError = /** @class */ (function (_super) {
26
- __extends(ValidationError, _super);
27
- function ValidationError() {
28
- return _super !== null && _super.apply(this, arguments) || this;
29
- }
30
- return ValidationError;
31
- }(Error));
10
+ class ValidationError extends Error {
11
+ }
32
12
  exports.ValidationError = ValidationError;