@react-native-oh/react-native-harmony-cli 0.0.40 → 0.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -11
- package/dist/assetResolver.js +43 -74
- package/dist/autolinking/Autolinking.js +178 -179
- package/dist/codegen/core/CodegenError.js +3 -23
- package/dist/codegen/core/EventUtils.js +3 -3
- package/dist/codegen/core/TypeAnnotationToTS.js +24 -28
- package/dist/codegen/core/UberSchema.js +57 -96
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +28 -41
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +27 -34
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +25 -33
- package/dist/codegen/generators/CppComponentCodeGenerator.js +23 -28
- package/dist/codegen/generators/LibGlueCodeGenerator.js +26 -29
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +25 -30
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
- package/dist/codegen/generators/UberGeneratorV1.js +24 -23
- package/dist/codegen/generators/UberGeneratorV2.js +34 -35
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +50 -24
- package/dist/codegen/templates/BasePackageHTemplate.js +120 -21
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +53 -8
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +75 -27
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +162 -29
- package/dist/codegen/templates/IndexTSTemplate.js +37 -17
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +119 -24
- package/dist/codegen/templates/TurboModuleCppTemplate.js +38 -15
- package/dist/codegen/templates/TurboModuleHTemplate.js +32 -11
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +52 -19
- package/dist/commands/bundle-harmony.js +53 -138
- package/dist/commands/codegen-harmony.js +105 -165
- package/dist/commands/codegen-lib-harmony.js +76 -116
- package/dist/commands/create-metro-host-constants.js +18 -47
- package/dist/commands/init.js +537 -961
- package/dist/commands/link-harmony.js +33 -71
- package/dist/commands/pack-harmony.js +47 -108
- package/dist/commands/run-harmony.js +372 -518
- package/dist/commands/unpack-harmony.js +105 -198
- package/dist/commands/verify-package-harmony.js +54 -108
- package/dist/core/AbsolutePath.js +31 -47
- package/dist/core/CodegenConfig.js +24 -22
- package/dist/core/DescriptiveError.js +18 -37
- package/dist/core/FileSystem.js +14 -18
- package/dist/core/OHPackageJSON5.js +17 -23
- package/dist/core/PackageJSON.js +26 -42
- package/dist/core/ProjectDependenciesManager.js +40 -92
- package/dist/core/ValidationError.js +2 -22
- package/dist/core/fs.js +9 -6
- package/dist/index.js +1 -1
- package/dist/io/CliExecutor.js +46 -98
- package/dist/io/Logger.js +40 -46
- package/dist/io/RealFS.js +35 -88
- package/dist/io/TarGz.js +11 -8
- package/dist/io/__fixtures__.js +79 -141
- package/dist/io/fsUtils.js +13 -12
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +19 -47
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +13 -41
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +8 -38
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +22 -54
- package/dist/package-verifier/verify-package.js +55 -132
- package/dist/simulator/LaunchSimulator.js +224 -301
- package/harmony/rnoh-hvigor-plugin-0.3.0.tgz +0 -0
- package/jest.config.js +12 -12
- package/package.json +78 -78
- package/react-native.config.js +17 -17
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
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
|
-
|
|
12
|
-
|
|
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: [
|
|
28
|
+
whatCanUserDo: [`Verify path: ${path.getValue()}`],
|
|
26
29
|
});
|
|
27
30
|
}
|
|
28
|
-
|
|
29
|
-
fileOrDirNames.forEach(
|
|
30
|
-
|
|
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
package/dist/io/CliExecutor.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,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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
22
|
-
var _this = this;
|
|
24
|
+
start(prepareMsg) {
|
|
23
25
|
this.loader.start(prepareMsg(chalk_1.default));
|
|
24
26
|
this.isLoaderActive = true;
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
+
return (options) => {
|
|
28
|
+
this.isLoaderActive = false;
|
|
27
29
|
if (options === null || options === void 0 ? void 0 : options.persist) {
|
|
28
|
-
console.log({ loader:
|
|
29
|
-
|
|
30
|
+
console.log({ loader: this.loader });
|
|
31
|
+
this.loader.stopAndPersist();
|
|
30
32
|
}
|
|
31
33
|
else {
|
|
32
|
-
|
|
34
|
+
this.loader.stop();
|
|
33
35
|
}
|
|
34
36
|
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
-
|
|
44
|
-
|
|
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
|
-
|
|
51
|
-
|
|
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
|
-
|
|
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
|
-
|
|
69
|
-
|
|
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(
|
|
68
|
+
error.stack.split('\n').forEach((line) => lines.push(chalk_1.default.gray(line)));
|
|
74
69
|
}
|
|
75
|
-
|
|
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(
|
|
74
|
+
details.split('\n').forEach((line) => lines.push(line));
|
|
80
75
|
}
|
|
81
76
|
lines.push('');
|
|
82
|
-
lines.push(
|
|
83
|
-
|
|
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(
|
|
87
|
-
suggestions.forEach(
|
|
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
|
-
|
|
99
|
-
}());
|
|
92
|
+
}
|
|
93
|
+
}
|
|
100
94
|
exports.Logger = Logger;
|
|
101
|
-
|
|
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
|
-
|
|
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
|
|
33
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
39
|
+
}
|
|
40
|
+
readTextSync(path) {
|
|
91
41
|
return node_fs_1.default.readFileSync(path.toString()).toString();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
95
|
-
return
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
55
|
+
}
|
|
56
|
+
writeTextSync(path, data) {
|
|
109
57
|
node_fs_1.default.writeFileSync(path.toString(), data);
|
|
110
|
-
}
|
|
111
|
-
|
|
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(
|
|
118
|
-
}
|
|
119
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
18
|
-
|
|
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(
|
|
23
|
-
writeStream.on('finish',
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
writeStream.on('finish', () => {
|
|
24
27
|
resolve(undefined);
|
|
25
28
|
});
|
|
26
|
-
writeStream.on('error',
|
|
29
|
+
writeStream.on('error', (err) => {
|
|
27
30
|
reject(err);
|
|
28
31
|
});
|
|
29
32
|
});
|