@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
package/dist/core/fs.js CHANGED
@@ -5,11 +5,14 @@
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.maybeMakeDirectories = maybeMakeDirectories;
10
13
  exports.maybeRemoveFilesInDirectory = maybeRemoveFilesInDirectory;
11
- var node_fs_1 = require("node:fs");
12
- var DescriptiveError_1 = require("./DescriptiveError");
14
+ const node_fs_1 = __importDefault(require("node:fs"));
15
+ const DescriptiveError_1 = require("./DescriptiveError");
13
16
  function maybeMakeDirectories(path) {
14
17
  if (!node_fs_1.default.existsSync(path.getValue())) {
15
18
  node_fs_1.default.mkdirSync(path.getValue(), { recursive: true });
@@ -22,12 +25,12 @@ function maybeRemoveFilesInDirectory(path) {
22
25
  if (!node_fs_1.default.lstatSync(path.getValue()).isDirectory()) {
23
26
  throw new DescriptiveError_1.DescriptiveError({
24
27
  whatHappened: "Tried to remove all files from a path that doesn't point to a directory",
25
- whatCanUserDo: ["Verify path: ".concat(path.getValue())],
28
+ whatCanUserDo: [`Verify path: ${path.getValue()}`],
26
29
  });
27
30
  }
28
- var fileOrDirNames = node_fs_1.default.readdirSync(path.getValue());
29
- fileOrDirNames.forEach(function (fileOrDirName) {
30
- var maybeFilePath = path.copyWithNewSegment(fileOrDirName);
31
+ const fileOrDirNames = node_fs_1.default.readdirSync(path.getValue());
32
+ fileOrDirNames.forEach((fileOrDirName) => {
33
+ const maybeFilePath = path.copyWithNewSegment(fileOrDirName);
31
34
  if (node_fs_1.default.statSync(maybeFilePath.getValue()).isDirectory()) {
32
35
  return;
33
36
  }
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.config = void 0;
10
- var commands_1 = require("./commands");
10
+ const commands_1 = require("./commands");
11
11
  exports.config = {
12
12
  commands: [
13
13
  commands_1.commandBundleHarmony,
@@ -5,21 +5,6 @@
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
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
24
9
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25
10
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -29,92 +14,55 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
29
14
  step((generator = generator.apply(thisArg, _arguments || [])).next());
30
15
  });
31
16
  };
32
- var __generator = (this && this.__generator) || function (thisArg, body) {
33
- 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);
34
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
35
- function verb(n) { return function (v) { return step([n, v]); }; }
36
- function step(op) {
37
- if (f) throw new TypeError("Generator is already executing.");
38
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
39
- 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;
40
- if (y = 0, t) op = [op[0] & 2, t.value];
41
- switch (op[0]) {
42
- case 0: case 1: t = op; break;
43
- case 4: _.label++; return { value: op[1], done: false };
44
- case 5: _.label++; y = op[1]; op = [0]; continue;
45
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
46
- default:
47
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
48
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
49
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
50
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
51
- if (t[2]) _.ops.pop();
52
- _.trys.pop(); continue;
53
- }
54
- op = body.call(thisArg, _);
55
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
56
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
57
- }
58
- };
59
17
  Object.defineProperty(exports, "__esModule", { value: true });
60
18
  exports.RealCliExecutor = exports.CliExecutor = void 0;
61
- var node_child_process_1 = require("node:child_process");
62
- var CliExecutor = /** @class */ (function () {
63
- function CliExecutor() {
64
- }
65
- return CliExecutor;
66
- }());
19
+ const node_child_process_1 = require("node:child_process");
20
+ class CliExecutor {
21
+ }
67
22
  exports.CliExecutor = CliExecutor;
68
- var RealCliExecutor = /** @class */ (function (_super) {
69
- __extends(RealCliExecutor, _super);
70
- function RealCliExecutor() {
71
- return _super !== null && _super.apply(this, arguments) || this;
72
- }
73
- RealCliExecutor.prototype.run = function (command, options) {
74
- return __awaiter(this, void 0, void 0, function () {
75
- return __generator(this, function (_a) {
76
- return [2 /*return*/, new Promise(function (resolve, reject) {
77
- var _a, _b;
78
- var commandWithArgs = command;
79
- var argStrings = [];
80
- if (options === null || options === void 0 ? void 0 : options.args) {
81
- argStrings = options.args;
82
- commandWithArgs += ' ' + argStrings.join(' ');
83
- }
84
- (_a = options === null || options === void 0 ? void 0 : options.onArgsStringified) === null || _a === void 0 ? void 0 : _a.call(options, commandWithArgs);
85
- var process = (0, node_child_process_1.spawn)(command, argStrings, {
86
- cwd: (_b = options === null || options === void 0 ? void 0 : options.cwd) === null || _b === void 0 ? void 0 : _b.toString(),
87
- shell: (options === null || options === void 0 ? void 0 : options.shell) ? true : false,
88
- });
89
- var stdout = '';
90
- var stderr = '';
91
- process.stdout.on('data', function (data) {
92
- var _a;
93
- var output = data.toString();
94
- stdout += output;
95
- (_a = options === null || options === void 0 ? void 0 : options.onStdout) === null || _a === void 0 ? void 0 : _a.call(options, output);
96
- });
97
- process.stderr.on('data', function (data) {
98
- var _a;
99
- var output = data.toString();
100
- stderr += output;
101
- (_a = options === null || options === void 0 ? void 0 : options.onStderr) === null || _a === void 0 ? void 0 : _a.call(options, output);
102
- });
103
- process.on('error', function (error) {
104
- reject(error);
105
- });
106
- process.on('close', function (code) {
107
- if (code === 0) {
108
- resolve(stdout);
109
- }
110
- else {
111
- reject(new Error("Command failed with code ".concat(code, "\nStderr: ").concat(stderr)));
112
- }
113
- });
114
- })];
23
+ class RealCliExecutor extends CliExecutor {
24
+ run(command, options) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ return new Promise((resolve, reject) => {
27
+ var _a, _b;
28
+ let commandWithArgs = command;
29
+ let argStrings = [];
30
+ if (options === null || options === void 0 ? void 0 : options.args) {
31
+ argStrings = options.args;
32
+ commandWithArgs += ' ' + argStrings.join(' ');
33
+ }
34
+ (_a = options === null || options === void 0 ? void 0 : options.onArgsStringified) === null || _a === void 0 ? void 0 : _a.call(options, commandWithArgs);
35
+ const process = (0, node_child_process_1.spawn)(command, argStrings, {
36
+ cwd: (_b = options === null || options === void 0 ? void 0 : options.cwd) === null || _b === void 0 ? void 0 : _b.toString(),
37
+ shell: (options === null || options === void 0 ? void 0 : options.shell) ? true : false,
38
+ });
39
+ let stdout = '';
40
+ let stderr = '';
41
+ process.stdout.on('data', (data) => {
42
+ var _a;
43
+ const output = data.toString();
44
+ stdout += output;
45
+ (_a = options === null || options === void 0 ? void 0 : options.onStdout) === null || _a === void 0 ? void 0 : _a.call(options, output);
46
+ });
47
+ process.stderr.on('data', (data) => {
48
+ var _a;
49
+ const output = data.toString();
50
+ stderr += output;
51
+ (_a = options === null || options === void 0 ? void 0 : options.onStderr) === null || _a === void 0 ? void 0 : _a.call(options, output);
52
+ });
53
+ process.on('error', (error) => {
54
+ reject(error);
55
+ });
56
+ process.on('close', (code) => {
57
+ if (code === 0) {
58
+ resolve(stdout);
59
+ }
60
+ else {
61
+ reject(new Error(`Command failed with code ${code}\nStderr: ${stderr}`));
62
+ }
63
+ });
115
64
  });
116
65
  });
117
- };
118
- return RealCliExecutor;
119
- }(CliExecutor));
66
+ }
67
+ }
120
68
  exports.RealCliExecutor = RealCliExecutor;
package/dist/io/Logger.js CHANGED
@@ -5,56 +5,51 @@
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.Logger = void 0;
10
- var chalk_1 = require("chalk");
11
- var cli_tools_1 = require("@react-native-community/cli-tools");
12
- var node_process_1 = require("node:process");
13
- var Logger = /** @class */ (function () {
14
- function Logger() {
13
+ const chalk_1 = __importDefault(require("chalk"));
14
+ const cli_tools_1 = require("@react-native-community/cli-tools");
15
+ const node_process_1 = __importDefault(require("node:process"));
16
+ class Logger {
17
+ constructor() {
15
18
  this.loader = (0, cli_tools_1.getLoader)({
16
19
  interval: node_process_1.default.stdout.isTTY ? undefined : 0,
17
20
  });
18
21
  this.logger = cli_tools_1.logger;
19
22
  this.isLoaderActive = false;
20
23
  }
21
- Logger.prototype.start = function (prepareMsg) {
22
- var _this = this;
24
+ start(prepareMsg) {
23
25
  this.loader.start(prepareMsg(chalk_1.default));
24
26
  this.isLoaderActive = true;
25
- return function (options) {
26
- _this.isLoaderActive = false;
27
+ return (options) => {
28
+ this.isLoaderActive = false;
27
29
  if (options === null || options === void 0 ? void 0 : options.persist) {
28
- console.log({ loader: _this.loader });
29
- _this.loader.stopAndPersist();
30
+ console.log({ loader: this.loader });
31
+ this.loader.stopAndPersist();
30
32
  }
31
33
  else {
32
- _this.loader.stop();
34
+ this.loader.stop();
33
35
  }
34
36
  };
35
- };
36
- Logger.prototype.info = function (prepareMsg) {
37
- var _this = this;
38
- var info = function (msg) {
39
- _this.isLoaderActive ? _this.loader.info(msg) : _this.logger.info(msg);
37
+ }
38
+ info(prepareMsg) {
39
+ const info = (msg) => {
40
+ this.isLoaderActive ? this.loader.info(msg) : this.logger.info(msg);
40
41
  };
41
42
  info(prepareMsg(chalk_1.default));
42
- };
43
- Logger.prototype.succeed = function (prepareMsg) {
44
- var _this = this;
45
- var succeed = function (msg) {
46
- return _this.isLoaderActive ? _this.loader.succeed(msg) : _this.logger.success(msg);
47
- };
43
+ }
44
+ succeed(prepareMsg) {
45
+ const succeed = (msg) => this.isLoaderActive ? this.loader.succeed(msg) : this.logger.success(msg);
48
46
  succeed(prepareMsg(chalk_1.default));
49
- };
50
- Logger.prototype.warn = function (prepareMsg) {
51
- var _this = this;
52
- var warn = function (msg) {
53
- return _this.isLoaderActive ? _this.loader.warn(msg) : _this.logger.warn(msg);
54
- };
47
+ }
48
+ warn(prepareMsg) {
49
+ const warn = (msg) => this.isLoaderActive ? this.loader.warn(msg) : this.logger.warn(msg);
55
50
  warn(prepareMsg(chalk_1.default));
56
- };
57
- Logger.prototype.debug = function (prepareMsg) {
51
+ }
52
+ debug(prepareMsg) {
58
53
  if (this.isLoaderActive) {
59
54
  clearLine(node_process_1.default.stdout);
60
55
  moveCursor(node_process_1.default.stdout, 0);
@@ -64,27 +59,27 @@ var Logger = /** @class */ (function () {
64
59
  else {
65
60
  console.debug(prepareMsg(chalk_1.default));
66
61
  }
67
- };
68
- Logger.prototype.descriptiveError = function (error) {
69
- var lines = [];
62
+ }
63
+ descriptiveError(error) {
64
+ const lines = [];
70
65
  if (error.isUnexpected() && error.stack) {
71
66
  lines.push('');
72
67
  lines.push(chalk_1.default.bold('Stack'));
73
- error.stack.split('\n').forEach(function (line) { return lines.push(chalk_1.default.gray(line)); });
68
+ error.stack.split('\n').forEach((line) => lines.push(chalk_1.default.gray(line)));
74
69
  }
75
- var details = error.getDetails();
70
+ const details = error.getDetails();
76
71
  if (details) {
77
72
  lines.push('');
78
73
  lines.push(chalk_1.default.bold('Details'));
79
- details.split('\n').forEach(function (line) { return lines.push(line); });
74
+ details.split('\n').forEach((line) => lines.push(line));
80
75
  }
81
76
  lines.push('');
82
- lines.push("".concat(error.getMessage()));
83
- var suggestions = error.getSuggestions();
77
+ lines.push(`${error.getMessage()}`);
78
+ const suggestions = error.getSuggestions();
84
79
  if (suggestions.length > 0) {
85
80
  lines.push('');
86
- lines.push(chalk_1.default.bold("Suggestions"));
87
- suggestions.forEach(function (suggestion) {
81
+ lines.push(chalk_1.default.bold(`Suggestions`));
82
+ suggestions.forEach((suggestion) => {
88
83
  lines.push('• ' + suggestion);
89
84
  });
90
85
  }
@@ -94,11 +89,10 @@ var Logger = /** @class */ (function () {
94
89
  else {
95
90
  this.logger.error(lines.join('\n').trim());
96
91
  }
97
- };
98
- return Logger;
99
- }());
92
+ }
93
+ }
100
94
  exports.Logger = Logger;
101
- var clearLine = function (stream) {
95
+ const clearLine = (stream) => {
102
96
  if (stream.clearLine) {
103
97
  stream.clearLine(0);
104
98
  }
@@ -106,7 +100,7 @@ var clearLine = function (stream) {
106
100
  node_process_1.default.stdout.write('\r' + ' '.repeat(node_process_1.default.stdout.columns || 80) + '\r');
107
101
  }
108
102
  };
109
- var moveCursor = function (stream, x) {
103
+ const moveCursor = (stream, x) => {
110
104
  if (stream.cursorTo) {
111
105
  stream.cursorTo(x);
112
106
  }
package/dist/io/RealFS.js CHANGED
@@ -5,21 +5,6 @@
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
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
24
9
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25
10
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -29,93 +14,55 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
29
14
  step((generator = generator.apply(thisArg, _arguments || [])).next());
30
15
  });
31
16
  };
32
- var __generator = (this && this.__generator) || function (thisArg, body) {
33
- 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);
34
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
35
- function verb(n) { return function (v) { return step([n, v]); }; }
36
- function step(op) {
37
- if (f) throw new TypeError("Generator is already executing.");
38
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
39
- 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;
40
- if (y = 0, t) op = [op[0] & 2, t.value];
41
- switch (op[0]) {
42
- case 0: case 1: t = op; break;
43
- case 4: _.label++; return { value: op[1], done: false };
44
- case 5: _.label++; y = op[1]; op = [0]; continue;
45
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
46
- default:
47
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
48
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
49
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
50
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
51
- if (t[2]) _.ops.pop();
52
- _.trys.pop(); continue;
53
- }
54
- op = body.call(thisArg, _);
55
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
56
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
57
- }
17
+ var __importDefault = (this && this.__importDefault) || function (mod) {
18
+ return (mod && mod.__esModule) ? mod : { "default": mod };
58
19
  };
59
20
  Object.defineProperty(exports, "__esModule", { value: true });
60
21
  exports.RealFS = void 0;
61
- var FileSystem_1 = require("../core/FileSystem");
62
- var node_fs_1 = require("node:fs");
63
- var RealFSDirent = /** @class */ (function (_super) {
64
- __extends(RealFSDirent, _super);
65
- function RealFSDirent(nodeFSDirent) {
66
- var _this = _super.call(this) || this;
67
- _this.nodeFSDirent = nodeFSDirent;
68
- return _this;
22
+ const FileSystem_1 = require("../core/FileSystem");
23
+ const node_fs_1 = __importDefault(require("node:fs"));
24
+ class RealFSDirent extends FileSystem_1.Dirent {
25
+ constructor(nodeFSDirent) {
26
+ super();
27
+ this.nodeFSDirent = nodeFSDirent;
69
28
  }
70
- RealFSDirent.prototype.isDirectory = function () {
29
+ isDirectory() {
71
30
  return this.nodeFSDirent.isDirectory();
72
- };
73
- Object.defineProperty(RealFSDirent.prototype, "name", {
74
- get: function () {
75
- return this.nodeFSDirent.name;
76
- },
77
- enumerable: false,
78
- configurable: true
79
- });
80
- return RealFSDirent;
81
- }(FileSystem_1.Dirent));
82
- var RealFS = /** @class */ (function (_super) {
83
- __extends(RealFS, _super);
84
- function RealFS() {
85
- return _super !== null && _super.apply(this, arguments) || this;
86
31
  }
87
- RealFS.prototype.existsSync = function (path) {
32
+ get name() {
33
+ return this.nodeFSDirent.name;
34
+ }
35
+ }
36
+ class RealFS extends FileSystem_1.FS {
37
+ existsSync(path) {
88
38
  return node_fs_1.default.existsSync(path.toString());
89
- };
90
- RealFS.prototype.readTextSync = function (path) {
39
+ }
40
+ readTextSync(path) {
91
41
  return node_fs_1.default.readFileSync(path.toString()).toString();
92
- };
93
- RealFS.prototype.readText = function (path) {
94
- return __awaiter(this, void 0, void 0, function () {
95
- return __generator(this, function (_a) {
96
- return [2 /*return*/, new Promise(function (resolve, reject) {
97
- node_fs_1.default.readFile(path.toString(), undefined, function (err, data) {
98
- if (err) {
99
- reject(err);
100
- return;
101
- }
102
- resolve(data.toString());
103
- });
104
- })];
42
+ }
43
+ readText(path) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ return new Promise((resolve, reject) => {
46
+ node_fs_1.default.readFile(path.toString(), undefined, (err, data) => {
47
+ if (err) {
48
+ reject(err);
49
+ return;
50
+ }
51
+ resolve(data.toString());
52
+ });
105
53
  });
106
54
  });
107
- };
108
- RealFS.prototype.writeTextSync = function (path, data) {
55
+ }
56
+ writeTextSync(path, data) {
109
57
  node_fs_1.default.writeFileSync(path.toString(), data);
110
- };
111
- RealFS.prototype.readDirentsSync = function (path, options) {
58
+ }
59
+ readDirentsSync(path, options) {
112
60
  return node_fs_1.default
113
61
  .readdirSync(path.toString(), {
114
62
  withFileTypes: true,
115
63
  recursive: options === null || options === void 0 ? void 0 : options.recursive,
116
64
  })
117
- .map(function (rawDirent) { return new RealFSDirent(rawDirent); });
118
- };
119
- return RealFS;
120
- }(FileSystem_1.FS));
65
+ .map((rawDirent) => new RealFSDirent(rawDirent));
66
+ }
67
+ }
121
68
  exports.RealFS = RealFS;
package/dist/io/TarGz.js CHANGED
@@ -5,25 +5,28 @@
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.unpackTarGz = unpackTarGz;
10
- var node_fs_1 = require("node:fs");
11
- var zlib_1 = require("zlib");
12
- var tar_1 = require("tar");
13
+ const node_fs_1 = __importDefault(require("node:fs"));
14
+ const zlib_1 = __importDefault(require("zlib"));
15
+ const tar_1 = __importDefault(require("tar"));
13
16
  function unpackTarGz(archivePath, outputDirPath) {
14
17
  if (!node_fs_1.default.existsSync(outputDirPath.getValue())) {
15
18
  node_fs_1.default.mkdirSync(outputDirPath.getValue(), { recursive: true });
16
19
  }
17
- var readStream = node_fs_1.default.createReadStream(archivePath.getValue());
18
- var writeStream = tar_1.default.extract({
20
+ const readStream = node_fs_1.default.createReadStream(archivePath.getValue());
21
+ const writeStream = tar_1.default.extract({
19
22
  cwd: outputDirPath.getValue(),
20
23
  });
21
24
  readStream.pipe(zlib_1.default.createGunzip()).pipe(writeStream);
22
- return new Promise(function (resolve, reject) {
23
- writeStream.on('finish', function () {
25
+ return new Promise((resolve, reject) => {
26
+ writeStream.on('finish', () => {
24
27
  resolve(undefined);
25
28
  });
26
- writeStream.on('error', function (err) {
29
+ writeStream.on('error', (err) => {
27
30
  reject(err);
28
31
  });
29
32
  });