@react-native-oh/react-native-harmony-cli 0.0.36 → 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 (137) 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 +42 -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 -109
  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 -108
  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 +520 -352
  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 +395 -0
  59. package/dist/simulator/index.js +23 -0
  60. package/jest.config.js +12 -12
  61. package/package.json +78 -70
  62. package/react-native.config.js +17 -17
  63. package/tsconfig.build.json +6 -6
  64. package/tsconfig.json +2 -2
  65. package/.prettierrc +0 -6
  66. package/src/assetResolver.ts +0 -134
  67. package/src/autolinking/Autolinking.test.ts +0 -483
  68. package/src/autolinking/Autolinking.ts +0 -382
  69. package/src/autolinking/index.ts +0 -8
  70. package/src/codegen/core/CodeGenerator.ts +0 -16
  71. package/src/codegen/core/CodegenError.ts +0 -10
  72. package/src/codegen/core/EventUtils.ts +0 -23
  73. package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
  74. package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
  75. package/src/codegen/core/UberSchema.ts +0 -152
  76. package/src/codegen/core/index.ts +0 -12
  77. package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -120
  78. package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
  79. package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
  80. package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
  81. package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
  82. package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
  83. package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
  84. package/src/codegen/generators/UberGeneratorV1.ts +0 -75
  85. package/src/codegen/generators/UberGeneratorV2.ts +0 -114
  86. package/src/codegen/generators/index.ts +0 -15
  87. package/src/codegen/index.ts +0 -9
  88. package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
  89. package/src/codegen/templates/BasePackageHTemplate.ts +0 -147
  90. package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
  91. package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
  92. package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
  93. package/src/codegen/templates/IndexTSTemplate.ts +0 -62
  94. package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -138
  95. package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
  96. package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
  97. package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
  98. package/src/codegen/templates/index.ts +0 -16
  99. package/src/commands/bundle-harmony.ts +0 -134
  100. package/src/commands/codegen-harmony.ts +0 -297
  101. package/src/commands/codegen-lib-harmony.ts +0 -389
  102. package/src/commands/create-metro-host-constants.ts +0 -55
  103. package/src/commands/index.ts +0 -16
  104. package/src/commands/init.ts +0 -755
  105. package/src/commands/link-harmony.ts +0 -102
  106. package/src/commands/pack-harmony.ts +0 -128
  107. package/src/commands/run-harmony.ts +0 -478
  108. package/src/commands/types.ts +0 -21
  109. package/src/commands/unpack-harmony.ts +0 -238
  110. package/src/commands/verify-package-harmony.ts +0 -113
  111. package/src/core/AbsolutePath.ts +0 -66
  112. package/src/core/CodegenConfig.ts +0 -67
  113. package/src/core/DescriptiveError.ts +0 -68
  114. package/src/core/FileSystem.ts +0 -57
  115. package/src/core/OHPackageJSON5.ts +0 -30
  116. package/src/core/PackageJSON.ts +0 -104
  117. package/src/core/ProjectDependenciesManager.ts +0 -103
  118. package/src/core/ValidationError.ts +0 -8
  119. package/src/core/ValueObject.ts +0 -9
  120. package/src/core/fs.ts +0 -38
  121. package/src/core/index.ts +0 -17
  122. package/src/index.ts +0 -33
  123. package/src/io/CliExecutor.ts +0 -69
  124. package/src/io/Logger.ts +0 -112
  125. package/src/io/RealFS.ts +0 -62
  126. package/src/io/TarGz.ts +0 -33
  127. package/src/io/__fixtures__.ts +0 -139
  128. package/src/io/fsUtils.ts +0 -44
  129. package/src/io/index.ts +0 -11
  130. package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
  131. package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
  132. package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
  133. package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
  134. package/src/package-verifier/checks/index.ts +0 -11
  135. package/src/package-verifier/index.ts +0 -9
  136. package/src/package-verifier/types.ts +0 -19
  137. package/src/package-verifier/verify-package.ts +0 -123
@@ -5,55 +5,71 @@
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 };
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));
10
16
  };
11
17
  Object.defineProperty(exports, "__esModule", { value: true });
12
18
  exports.AbsolutePath = void 0;
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) {
19
+ var node_path_1 = require("node:path");
20
+ var AbsolutePath = /** @class */ (function () {
21
+ function AbsolutePath(path) {
19
22
  this.value = '';
20
23
  this.value = node_path_1.default.resolve(path);
21
24
  }
22
- getValue() {
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 () {
23
33
  return this.value;
24
- }
25
- toString() {
34
+ };
35
+ AbsolutePath.prototype.toString = function () {
26
36
  return 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);
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);
33
47
  if (maybeExtWithDot) {
34
48
  return maybeExtWithDot.substring(1);
35
49
  }
36
50
  return null;
37
- }
38
- getDirectoryPath() {
39
- const dirPath = node_path_1.default.extname(this.value)
51
+ };
52
+ AbsolutePath.prototype.getDirectoryPath = function () {
53
+ var dirPath = node_path_1.default.extname(this.value)
40
54
  ? node_path_1.default.dirname(this.value)
41
55
  : this.value;
42
56
  return new AbsolutePath(dirPath);
43
- }
44
- relativeTo(absolutePath) {
57
+ };
58
+ AbsolutePath.prototype.relativeTo = function (absolutePath) {
45
59
  return new RelativePath(node_path_1.default.relative(absolutePath.getValue(), this.value));
46
- }
47
- }
60
+ };
61
+ return AbsolutePath;
62
+ }());
48
63
  exports.AbsolutePath = AbsolutePath;
49
- class RelativePath {
50
- constructor(value) {
64
+ var RelativePath = /** @class */ (function () {
65
+ function RelativePath(value) {
51
66
  this.value = value;
52
67
  }
53
- getValue() {
68
+ RelativePath.prototype.getValue = function () {
54
69
  return this.value;
55
- }
56
- toString() {
70
+ };
71
+ RelativePath.prototype.toString = function () {
57
72
  return this.value;
58
- }
59
- }
73
+ };
74
+ return RelativePath;
75
+ }());
@@ -5,19 +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 __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
8
  Object.defineProperty(exports, "__esModule", { value: true });
12
9
  exports.CodegenConfig = void 0;
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) {
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) {
18
19
  var _a, _b;
19
- const SUPPORTED_SPEC_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'];
20
- const specPaths = ((_a = rawCodegenConfig.specPaths) !== null && _a !== void 0 ? _a : []).map((rawSpecPath) => {
20
+ var SUPPORTED_SPEC_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'];
21
+ var specPaths = ((_a = rawCodegenConfig.specPaths) !== null && _a !== void 0 ? _a : []).map(function (rawSpecPath) {
21
22
  if (rawSpecPath.startsWith('~')) {
22
23
  return projectRootPath.copyWithNewSegment(rawSpecPath.replace('~', ''));
23
24
  }
@@ -25,12 +26,12 @@ class CodegenConfig {
25
26
  return packageRootPath.copyWithNewSegment(rawSpecPath);
26
27
  }
27
28
  });
28
- const specFilePaths = specPaths.flatMap((specPath) => {
29
+ var specFilePaths = specPaths.flatMap(function (specPath) {
29
30
  if (!node_fs_1.default.existsSync(specPath.getValue())) {
30
31
  throw new DescriptiveError_1.DescriptiveError({
31
- whatHappened: `No such file or directory: ${specPath.getValue()}`,
32
+ whatHappened: "No such file or directory: ".concat(specPath.getValue()),
32
33
  whatCanUserDo: [
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.`,
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."),
34
35
  ],
35
36
  });
36
37
  }
@@ -38,7 +39,7 @@ class CodegenConfig {
38
39
  return (0, io_1.findFilePathsWithExtensions)(specPath, SUPPORTED_SPEC_EXTENSIONS);
39
40
  }
40
41
  else {
41
- const ext = specPath.getExtension();
42
+ var ext = specPath.getExtension();
42
43
  if (ext && SUPPORTED_SPEC_EXTENSIONS.includes(ext)) {
43
44
  return [specPath];
44
45
  }
@@ -46,16 +47,13 @@ class CodegenConfig {
46
47
  }
47
48
  });
48
49
  return new CodegenConfig(specFilePaths, (_b = rawCodegenConfig.version) !== null && _b !== void 0 ? _b : 1);
49
- }
50
- constructor(specFilePaths, version) {
51
- this.specFilePaths = specFilePaths;
52
- this.version = version;
53
- }
54
- getSpecFilePaths() {
50
+ };
51
+ CodegenConfig.prototype.getSpecFilePaths = function () {
55
52
  return this.specFilePaths;
56
- }
57
- getVersion() {
53
+ };
54
+ CodegenConfig.prototype.getVersion = function () {
58
55
  return this.version;
59
- }
60
- }
56
+ };
57
+ return CodegenConfig;
58
+ }());
61
59
  exports.CodegenConfig = CodegenConfig;
@@ -5,20 +5,37 @@
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
+ })();
8
23
  Object.defineProperty(exports, "__esModule", { value: true });
9
24
  exports.DescriptiveError = void 0;
10
- class DescriptiveError extends Error {
11
- constructor(data) {
12
- super(data.whatHappened);
13
- this.data = data;
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;
14
31
  }
15
- isUnexpected() {
32
+ DescriptiveError.prototype.isUnexpected = function () {
16
33
  return 'unexpected' in this.data;
17
- }
18
- getMessage() {
34
+ };
35
+ DescriptiveError.prototype.getMessage = function () {
19
36
  return this.data.whatHappened;
20
- }
21
- getSuggestions() {
37
+ };
38
+ DescriptiveError.prototype.getSuggestions = function () {
22
39
  var _a;
23
40
  if ('whatCanUserDo' in this.data) {
24
41
  return (_a = this.data.whatCanUserDo) !== null && _a !== void 0 ? _a : [];
@@ -26,11 +43,11 @@ class DescriptiveError extends Error {
26
43
  else {
27
44
  return [];
28
45
  }
29
- }
30
- getRawData() {
46
+ };
47
+ DescriptiveError.prototype.getRawData = function () {
31
48
  return this.data;
32
- }
33
- getDetails() {
49
+ };
50
+ DescriptiveError.prototype.getDetails = function () {
34
51
  var _a;
35
52
  if (!this.data.extraData) {
36
53
  return '';
@@ -39,10 +56,11 @@ class DescriptiveError extends Error {
39
56
  return this.data.extraData.trim();
40
57
  }
41
58
  if (this.data.extraData instanceof Error) {
42
- let lines = [
43
- `${this.data.extraData.name}: ${this.data.extraData.message}`,
59
+ var lines = [
60
+ "".concat(this.data.extraData.name, ": ").concat(this.data.extraData.message),
44
61
  ];
45
- for (let stackEntry of ((_a = this.data.extraData.stack) !== null && _a !== void 0 ? _a : '').split('\n')) {
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];
46
64
  lines.push('');
47
65
  lines.push(stackEntry);
48
66
  }
@@ -54,6 +72,7 @@ class DescriptiveError extends Error {
54
72
  catch (err) {
55
73
  return '';
56
74
  }
57
- }
58
- }
75
+ };
76
+ return DescriptiveError;
77
+ }(Error));
59
78
  exports.DescriptiveError = DescriptiveError;
@@ -5,21 +5,24 @@
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
- };
11
8
  Object.defineProperty(exports, "__esModule", { value: true });
12
9
  exports.FS = exports.Dirent = void 0;
13
- const node_path_1 = __importDefault(require("node:path"));
14
- class Dirent {
15
- }
10
+ var node_path_1 = require("node:path");
11
+ var Dirent = /** @class */ (function () {
12
+ function Dirent() {
13
+ }
14
+ return Dirent;
15
+ }());
16
16
  exports.Dirent = Dirent;
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());
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());
23
26
  if (dirent.isDirectory()) {
24
27
  results = results.concat(this.findFilePathsWithExtensions(path, fileExtensions));
25
28
  }
@@ -28,6 +31,7 @@ class FS {
28
31
  }
29
32
  }
30
33
  return results;
31
- }
32
- }
34
+ };
35
+ return FS;
36
+ }());
33
37
  exports.FS = FS;
@@ -5,25 +5,31 @@
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
- };
11
8
  Object.defineProperty(exports, "__esModule", { value: true });
12
9
  exports.OHPackageJSON5 = void 0;
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) {
10
+ var json5_1 = require("json5");
11
+ var node_fs_1 = require("node:fs");
12
+ var OHPackageJSON5 = /** @class */ (function () {
13
+ function OHPackageJSON5(rawData) {
20
14
  this.rawData = rawData;
21
15
  }
22
- get name() {
23
- return this.rawData['name'];
24
- }
25
- get version() {
26
- return this.rawData['version'];
27
- }
28
- }
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
+ }());
29
35
  exports.OHPackageJSON5 = OHPackageJSON5;
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PackageJSON = void 0;
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');
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');
9
14
  if (!fs.existsSync(packageJSONPath)) {
10
15
  throw new DescriptiveError_1.DescriptiveError({
11
16
  whatHappened: "Couldn't find 'package.json'",
@@ -22,25 +27,33 @@ class PackageJSON {
22
27
  catch (err) {
23
28
  throw new DescriptiveError_1.DescriptiveError({
24
29
  whatHappened: "Couldn't parse package.json",
25
- extraData: { packageJSONPath, err },
30
+ extraData: { packageJSONPath: packageJSONPath, err: err },
26
31
  });
27
32
  }
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() {
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;
44
57
  var _a;
45
58
  /**
46
59
  * Shared codegenConfig is not used on purpose. Android, iOS and other platforms shouldn't
@@ -48,16 +61,19 @@ class PackageJSON {
48
61
  * that the shape of the shared config, to allow specifying which specific turbo modules or
49
62
  * fabric components should be code generated.
50
63
  */
51
- const rawCodegenConfig = (_a = this.rawPackageJSON.harmony) === null || _a === void 0 ? void 0 : _a.codegenConfig;
64
+ var rawCodegenConfig = (_a = this.rawPackageJSON.harmony) === null || _a === void 0 ? void 0 : _a.codegenConfig;
52
65
  if (!rawCodegenConfig) {
53
66
  return [];
54
67
  }
55
68
  if (Array.isArray(rawCodegenConfig)) {
56
- return rawCodegenConfig.map((config) => CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(config, this.packageRootPath, this.projectRootPath, this.name));
69
+ return rawCodegenConfig.map(function (config) {
70
+ return CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(config, _this.packageRootPath, _this.projectRootPath, _this.name);
71
+ });
57
72
  }
58
73
  return [
59
74
  CodegenConfig_1.CodegenConfig.fromRawCodegenConfig(rawCodegenConfig, this.packageRootPath, this.projectRootPath, this.name),
60
75
  ];
61
- }
62
- }
76
+ };
77
+ return PackageJSON;
78
+ }());
63
79
  exports.PackageJSON = PackageJSON;
@@ -14,70 +14,120 @@ 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
  Object.defineProperty(exports, "__esModule", { value: true });
18
45
  exports.ProjectDependenciesManager = exports.ProjectDependency = void 0;
19
- const PackageJSON_1 = require("./PackageJSON");
20
- class ProjectDependency {
21
- constructor(fs, packageRootPath, projectRootPath) {
46
+ var PackageJSON_1 = require("./PackageJSON");
47
+ var ProjectDependency = /** @class */ (function () {
48
+ function ProjectDependency(fs, packageRootPath, projectRootPath) {
22
49
  this.fs = fs;
23
50
  this.packageRootPath = packageRootPath;
24
51
  this.projectRootPath = projectRootPath;
25
52
  }
26
- getRootPath() {
53
+ ProjectDependency.prototype.getRootPath = function () {
27
54
  return this.packageRootPath;
28
- }
29
- getCodegenConfigs() {
55
+ };
56
+ ProjectDependency.prototype.getCodegenConfigs = function () {
30
57
  return this.readPackageJSON().getCodegenConfigs();
31
- }
32
- getHarFilePath() {
33
- const packageHarmonyPath = this.packageRootPath.copyWithNewSegment('harmony');
34
- if (!this.fs.existsSync(packageHarmonyPath)) {
35
- return null;
58
+ };
59
+ ProjectDependency.prototype.getHarFilePaths = function () {
60
+ var packageHarmonyPath = this.packageRootPath.copyWithNewSegment('harmony');
61
+ if (this.fs.existsSync(packageHarmonyPath)) {
62
+ return this.fs.findFilePathsWithExtensions(packageHarmonyPath, ['har']);
36
63
  }
37
- const harFilePaths = this.fs.findFilePathsWithExtensions(packageHarmonyPath, ['har']);
38
- if (harFilePaths.length !== 1) {
39
- return null;
64
+ else {
65
+ return this.fs.findFilePathsWithExtensions(this.packageRootPath, ['har']);
40
66
  }
41
- return harFilePaths[0];
42
- }
43
- readPackageJSON() {
67
+ };
68
+ ProjectDependency.prototype.readPackageJSON = function () {
44
69
  return PackageJSON_1.PackageJSON.fromProjectRootPath(this.fs, this.packageRootPath, this.projectRootPath);
45
- }
46
- }
70
+ };
71
+ return ProjectDependency;
72
+ }());
47
73
  exports.ProjectDependency = ProjectDependency;
48
- class ProjectDependenciesManager {
49
- constructor(fs, projectRootPath) {
74
+ var ProjectDependenciesManager = /** @class */ (function () {
75
+ function ProjectDependenciesManager(fs, projectRootPath) {
50
76
  this.fs = fs;
51
77
  this.projectRootPath = projectRootPath;
52
78
  }
53
- forEachAsync(cb) {
54
- return __awaiter(this, void 0, void 0, function* () {
55
- yield this.forEachDependencyInDirectory(cb, this.projectRootPath.copyWithNewSegment('node_modules'));
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
+ });
56
89
  });
57
- }
58
- forEachDependencyInDirectory(cb, directoryPath) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- if (!this.fs.existsSync(directoryPath)) {
61
- return;
62
- }
63
- for (let dirent of this.fs.readDirentsSync(directoryPath)) {
64
- if (dirent.isDirectory()) {
65
- if (dirent.name.startsWith('.')) {
66
- continue;
67
- }
68
- else if (dirent.name.startsWith('@')) {
69
- yield this.forEachDependencyInDirectory(cb, directoryPath.copyWithNewSegment(dirent.name));
70
- }
71
- else {
72
- const potentialDependencyRootPath = directoryPath.copyWithNewSegment(dirent.name);
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);
73
116
  if (!this.fs.existsSync(potentialDependencyRootPath.copyWithNewSegment('package.json'))) {
74
- continue;
117
+ return [3 /*break*/, 6];
75
118
  }
76
- yield cb(new ProjectDependency(this.fs, potentialDependencyRootPath, this.projectRootPath));
77
- }
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*/];
78
127
  }
79
- }
128
+ });
80
129
  });
81
- }
82
- }
130
+ };
131
+ return ProjectDependenciesManager;
132
+ }());
83
133
  exports.ProjectDependenciesManager = ProjectDependenciesManager;