@react-native-oh/react-native-harmony-cli 0.77.18 → 0.77.33
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/dist/assetResolver.js +74 -43
- package/dist/autolinking/Autolinking.js +179 -178
- package/dist/codegen/core/CodegenError.js +23 -3
- package/dist/codegen/core/EventUtils.js +3 -3
- package/dist/codegen/core/TypeAnnotationToTS.js +28 -24
- package/dist/codegen/core/UberSchema.js +97 -55
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +41 -28
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +34 -27
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +33 -25
- package/dist/codegen/generators/CppComponentCodeGenerator.js +28 -23
- package/dist/codegen/generators/LibGlueCodeGenerator.js +29 -26
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +30 -25
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +15 -15
- package/dist/codegen/generators/UberGeneratorV1.js +24 -18
- package/dist/codegen/generators/UberGeneratorV2.js +36 -28
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +24 -50
- package/dist/codegen/templates/BasePackageHTemplate.js +21 -120
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +8 -54
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +27 -75
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +29 -162
- package/dist/codegen/templates/IndexTSTemplate.js +17 -37
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +24 -119
- package/dist/codegen/templates/TurboModuleCppTemplate.js +15 -38
- package/dist/codegen/templates/TurboModuleHTemplate.js +11 -32
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +19 -52
- package/dist/commands/bundle-harmony.js +221 -118
- package/dist/commands/clean-harmony.js +63 -58
- package/dist/commands/codegen-harmony.js +175 -104
- package/dist/commands/codegen-lib-harmony.js +116 -76
- package/dist/commands/init-harmony.js +196 -151
- package/dist/commands/init.js +961 -537
- package/dist/commands/link-harmony.js +82 -35
- package/dist/commands/run-harmony.js +520 -352
- package/dist/commands/verify-package-harmony.js +117 -54
- package/dist/core/AbsolutePath.js +49 -33
- package/dist/core/CodegenConfig.js +22 -24
- package/dist/core/DescriptiveError.js +37 -18
- package/dist/core/FileSystem.js +18 -14
- package/dist/core/OHPackageJSON5.js +23 -17
- package/dist/core/PackageJSON.js +42 -26
- package/dist/core/ProjectDependenciesManager.js +92 -40
- package/dist/core/ValidationError.js +22 -2
- package/dist/core/fs.js +7 -10
- package/dist/index.js +1 -1
- package/dist/init/templates/AppScopeAppJSON5Template.js +8 -21
- package/dist/init/templates/AppScopeStringVarTemplate.js +8 -19
- package/dist/init/templates/EntryIndexTemplate.js +8 -56
- package/dist/init/templates/EntryStringVarTemplate.js +8 -27
- package/dist/init/templates/HvigorConfigJson5Template.js +8 -33
- package/dist/init/templates/MetroConfigTemplate.js +8 -38
- package/dist/init/templates/OhPackageJson5Template.js +8 -28
- package/dist/io/CliExecutor.js +98 -46
- package/dist/io/Logger.js +46 -40
- package/dist/io/RealFS.js +100 -43
- package/dist/io/TarGz.js +8 -11
- package/dist/io/__fixtures__.js +141 -79
- package/dist/io/fsUtils.js +12 -13
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +47 -19
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +41 -13
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +38 -8
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +54 -22
- package/dist/package-verifier/verify-package.js +133 -56
- package/dist/simulator/LaunchSimulator.js +395 -0
- package/dist/simulator/index.js +23 -0
- package/package.json +2 -11
- package/scripts/sync-hvigor.js +27 -0
- package/src/autolinking/Autolinking.ts +1 -1
- package/src/codegen/generators/UberGeneratorV1.ts +7 -2
- package/src/codegen/generators/UberGeneratorV2.ts +6 -1
- package/src/commands/codegen-harmony.ts +17 -7
- package/src/commands/run-harmony.ts +67 -41
- package/src/init/templates/harmony/entry/src/main/module.json5 +7 -0
- package/src/simulator/LaunchSimulator.ts +359 -0
- package/src/simulator/index.ts +8 -0
- package/dist/init/templates/harmony/AppScope/app.json5 +0 -10
- package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +0 -8
- package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/dist/init/templates/harmony/build-profile.json5 +0 -36
- package/dist/init/templates/harmony/codelinter.json +0 -32
- package/dist/init/templates/harmony/entry/build-profile.json5 +0 -18
- package/dist/init/templates/harmony/entry/gitignore +0 -7
- package/dist/init/templates/harmony/entry/hvigorfile.ts +0 -13
- package/dist/init/templates/harmony/entry/oh-package.json5 +0 -9
- package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +0 -27
- package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +0 -13
- package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +0 -4
- package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +0 -8
- package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +0 -2
- package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +0 -11
- package/dist/init/templates/harmony/entry/src/main/ets/gitignore +0 -1
- package/dist/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
- package/dist/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +0 -16
- package/dist/init/templates/harmony/entry/src/main/module.json5 +0 -58
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +0 -8
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +0 -16
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +0 -7
- package/dist/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +0 -5
- package/dist/init/templates/harmony/entry/src/main/resources/gitignore +0 -1
- package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +0 -2
- package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +0 -13
- package/dist/init/templates/harmony/gitignore +0 -16
- package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +0 -22
- package/dist/init/templates/harmony/hvigorfile.ts +0 -7
|
@@ -8,6 +8,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
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);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
11
38
|
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
39
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
40
|
var m = o[Symbol.asyncIterator], i;
|
|
@@ -15,16 +42,22 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
15
42
|
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
43
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
44
|
};
|
|
18
|
-
var
|
|
19
|
-
|
|
45
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
46
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
47
|
+
if (ar || !(i in from)) {
|
|
48
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
49
|
+
ar[i] = from[i];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
53
|
};
|
|
21
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
55
|
exports.commandVerifyPackageHarmony = void 0;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
56
|
+
var cli_tools_1 = require("@react-native-community/cli-tools");
|
|
57
|
+
var chalk_1 = require("chalk");
|
|
58
|
+
var core_1 = require("../core");
|
|
59
|
+
var io_1 = require("../io");
|
|
60
|
+
var package_verifier_1 = require("../package-verifier");
|
|
28
61
|
exports.commandVerifyPackageHarmony = {
|
|
29
62
|
name: 'verify-package-harmony',
|
|
30
63
|
description: 'Validates that a package is compliant with guidelines',
|
|
@@ -40,25 +73,37 @@ exports.commandVerifyPackageHarmony = {
|
|
|
40
73
|
{
|
|
41
74
|
name: '--skip-checks <string...>',
|
|
42
75
|
description: 'Disable certain checks by their names',
|
|
43
|
-
parse: (val, prev)
|
|
76
|
+
parse: function (val, prev) { return (prev ? __spreadArray(__spreadArray([], prev, true), [val], false) : [val]); },
|
|
44
77
|
},
|
|
45
78
|
],
|
|
46
|
-
func: (argv, config, rawArgs)
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
79
|
+
func: function (argv, config, rawArgs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
80
|
+
var loader, args, checkResults, _a, _b, _c, checkResult, e_1_1, err_1;
|
|
81
|
+
var _d, e_1, _e, _f;
|
|
82
|
+
return __generator(this, function (_g) {
|
|
83
|
+
switch (_g.label) {
|
|
84
|
+
case 0:
|
|
85
|
+
loader = (0, cli_tools_1.getLoader)();
|
|
86
|
+
_g.label = 1;
|
|
87
|
+
case 1:
|
|
88
|
+
_g.trys.push([1, 14, , 15]);
|
|
89
|
+
args = validateArgs(rawArgs);
|
|
90
|
+
loader.info("Verifying RNOH package: ".concat(args.packagePath.getValue()));
|
|
91
|
+
checkResults = [];
|
|
92
|
+
_g.label = 2;
|
|
93
|
+
case 2:
|
|
94
|
+
_g.trys.push([2, 7, 8, 13]);
|
|
95
|
+
_a = true, _b = __asyncValues((0, package_verifier_1.verifyRNOHPackage)({
|
|
96
|
+
npmPackagePath: args.packagePath,
|
|
97
|
+
hasHarmonyCode: args.hasHarmonyCode,
|
|
98
|
+
checkNamesToSkip: args.checkNamesToSkip,
|
|
99
|
+
}));
|
|
100
|
+
_g.label = 3;
|
|
101
|
+
case 3: return [4 /*yield*/, _b.next()];
|
|
102
|
+
case 4:
|
|
103
|
+
if (!(_c = _g.sent(), _d = _c.done, !_d)) return [3 /*break*/, 6];
|
|
104
|
+
_f = _c.value;
|
|
105
|
+
_a = false;
|
|
106
|
+
checkResult = _f;
|
|
62
107
|
if (checkResult.type === 'START_PROCESS') {
|
|
63
108
|
loader.start(chalk_1.default.gray(checkResult.name));
|
|
64
109
|
}
|
|
@@ -66,31 +111,49 @@ exports.commandVerifyPackageHarmony = {
|
|
|
66
111
|
checkResults.push(checkResult);
|
|
67
112
|
logCheckResult(loader, checkResult);
|
|
68
113
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
114
|
+
_g.label = 5;
|
|
115
|
+
case 5:
|
|
116
|
+
_a = true;
|
|
117
|
+
return [3 /*break*/, 3];
|
|
118
|
+
case 6: return [3 /*break*/, 13];
|
|
119
|
+
case 7:
|
|
120
|
+
e_1_1 = _g.sent();
|
|
121
|
+
e_1 = { error: e_1_1 };
|
|
122
|
+
return [3 /*break*/, 13];
|
|
123
|
+
case 8:
|
|
124
|
+
_g.trys.push([8, , 11, 12]);
|
|
125
|
+
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 10];
|
|
126
|
+
return [4 /*yield*/, _e.call(_b)];
|
|
127
|
+
case 9:
|
|
128
|
+
_g.sent();
|
|
129
|
+
_g.label = 10;
|
|
130
|
+
case 10: return [3 /*break*/, 12];
|
|
131
|
+
case 11:
|
|
132
|
+
if (e_1) throw e_1.error;
|
|
133
|
+
return [7 /*endfinally*/];
|
|
134
|
+
case 12: return [7 /*endfinally*/];
|
|
135
|
+
case 13:
|
|
136
|
+
if (checkResults.every(function (checkResult) {
|
|
137
|
+
return checkResult.status === 'pass' || checkResult.status === 'skip';
|
|
138
|
+
})) {
|
|
139
|
+
loader.info(chalk_1.default.bold('OK'));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
loader.info(chalk_1.default.red('Package verification failed. Please fix those checks before publishing your package.'));
|
|
143
|
+
process.exit(1);
|
|
144
|
+
}
|
|
145
|
+
return [3 /*break*/, 15];
|
|
146
|
+
case 14:
|
|
147
|
+
err_1 = _g.sent();
|
|
148
|
+
if (err_1 instanceof core_1.DescriptiveError) {
|
|
149
|
+
new io_1.Logger().descriptiveError(err_1);
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
throw err_1;
|
|
153
|
+
case 15: return [2 /*return*/];
|
|
90
154
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}),
|
|
155
|
+
});
|
|
156
|
+
}); },
|
|
94
157
|
};
|
|
95
158
|
function validateArgs(args) {
|
|
96
159
|
if (!args.packagePath) {
|
|
@@ -108,17 +171,17 @@ function validateArgs(args) {
|
|
|
108
171
|
};
|
|
109
172
|
}
|
|
110
173
|
function logCheckResult(loader, checkResult) {
|
|
111
|
-
|
|
174
|
+
var prefix = (function () {
|
|
112
175
|
switch (checkResult.status) {
|
|
113
176
|
case 'pass':
|
|
114
|
-
return
|
|
177
|
+
return "".concat(chalk_1.default.green('PASS'));
|
|
115
178
|
case 'fail':
|
|
116
|
-
return
|
|
179
|
+
return "".concat(chalk_1.default.red('FAIL'));
|
|
117
180
|
case 'skip':
|
|
118
|
-
return
|
|
181
|
+
return "".concat(chalk_1.default.yellow('SKIP'));
|
|
119
182
|
}
|
|
120
183
|
})();
|
|
121
184
|
loader.info(checkResult.message
|
|
122
|
-
?
|
|
123
|
-
:
|
|
185
|
+
? "[".concat(chalk_1.default.bold(prefix), "] ").concat(chalk_1.default.bold(checkResult.name), "\n").concat(checkResult.message)
|
|
186
|
+
: "[".concat(chalk_1.default.bold(prefix), "] ").concat(chalk_1.default.bold(checkResult.name)));
|
|
124
187
|
}
|
|
@@ -1,56 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
4
10
|
};
|
|
5
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
12
|
exports.AbsolutePath = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return new AbsolutePath(node_path_1.default.join(...segments));
|
|
11
|
-
}
|
|
12
|
-
constructor(path) {
|
|
13
|
+
var node_path_1 = require("node:path");
|
|
14
|
+
var AbsolutePath = /** @class */ (function () {
|
|
15
|
+
function AbsolutePath(path) {
|
|
13
16
|
this.value = '';
|
|
14
17
|
this.value = node_path_1.default.resolve(path);
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
AbsolutePath.fromSegments = function () {
|
|
20
|
+
var segments = [];
|
|
21
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
22
|
+
segments[_i] = arguments[_i];
|
|
23
|
+
}
|
|
24
|
+
return new AbsolutePath(node_path_1.default.join.apply(node_path_1.default, segments));
|
|
25
|
+
};
|
|
26
|
+
AbsolutePath.prototype.getValue = function () {
|
|
17
27
|
return this.value;
|
|
18
|
-
}
|
|
19
|
-
toString() {
|
|
28
|
+
};
|
|
29
|
+
AbsolutePath.prototype.toString = function () {
|
|
20
30
|
return this.value;
|
|
21
|
-
}
|
|
22
|
-
copyWithNewSegment(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
};
|
|
32
|
+
AbsolutePath.prototype.copyWithNewSegment = function () {
|
|
33
|
+
var relativePath = [];
|
|
34
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
35
|
+
relativePath[_i] = arguments[_i];
|
|
36
|
+
}
|
|
37
|
+
return new AbsolutePath(node_path_1.default.join.apply(node_path_1.default, __spreadArray([this.getValue()], relativePath, false)));
|
|
38
|
+
};
|
|
39
|
+
AbsolutePath.prototype.getExtension = function () {
|
|
40
|
+
var maybeExtWithDot = node_path_1.default.extname(this.value);
|
|
27
41
|
if (maybeExtWithDot) {
|
|
28
42
|
return maybeExtWithDot.substring(1);
|
|
29
43
|
}
|
|
30
44
|
return null;
|
|
31
|
-
}
|
|
32
|
-
getBasename() {
|
|
45
|
+
};
|
|
46
|
+
AbsolutePath.prototype.getBasename = function () {
|
|
33
47
|
return node_path_1.default.basename(this.value);
|
|
34
|
-
}
|
|
35
|
-
getDirectoryPath() {
|
|
36
|
-
|
|
48
|
+
};
|
|
49
|
+
AbsolutePath.prototype.getDirectoryPath = function () {
|
|
50
|
+
var dirPath = node_path_1.default.extname(this.value)
|
|
37
51
|
? node_path_1.default.dirname(this.value)
|
|
38
52
|
: this.value;
|
|
39
53
|
return new AbsolutePath(dirPath);
|
|
40
|
-
}
|
|
41
|
-
relativeTo(absolutePath) {
|
|
54
|
+
};
|
|
55
|
+
AbsolutePath.prototype.relativeTo = function (absolutePath) {
|
|
42
56
|
return new RelativePath(node_path_1.default.relative(absolutePath.getValue(), this.value));
|
|
43
|
-
}
|
|
44
|
-
|
|
57
|
+
};
|
|
58
|
+
return AbsolutePath;
|
|
59
|
+
}());
|
|
45
60
|
exports.AbsolutePath = AbsolutePath;
|
|
46
|
-
|
|
47
|
-
|
|
61
|
+
var RelativePath = /** @class */ (function () {
|
|
62
|
+
function RelativePath(value) {
|
|
48
63
|
this.value = value;
|
|
49
64
|
}
|
|
50
|
-
getValue() {
|
|
65
|
+
RelativePath.prototype.getValue = function () {
|
|
51
66
|
return this.value;
|
|
52
|
-
}
|
|
53
|
-
toString() {
|
|
67
|
+
};
|
|
68
|
+
RelativePath.prototype.toString = function () {
|
|
54
69
|
return this.value;
|
|
55
|
-
}
|
|
56
|
-
|
|
70
|
+
};
|
|
71
|
+
return RelativePath;
|
|
72
|
+
}());
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.CodegenConfig = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
var node_fs_1 = require("node:fs");
|
|
5
|
+
var io_1 = require("../io");
|
|
6
|
+
var DescriptiveError_1 = require("./DescriptiveError");
|
|
7
|
+
var CodegenConfig = /** @class */ (function () {
|
|
8
|
+
function CodegenConfig(specFilePaths, version) {
|
|
9
|
+
this.specFilePaths = specFilePaths;
|
|
10
|
+
this.version = version;
|
|
11
|
+
}
|
|
12
|
+
CodegenConfig.fromRawCodegenConfig = function (rawCodegenConfig, packageRootPath, projectRootPath, packageName) {
|
|
12
13
|
var _a, _b;
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
var SUPPORTED_SPEC_EXTENSIONS = ['js', 'jsx', 'ts', 'tsx'];
|
|
15
|
+
var specPaths = ((_a = rawCodegenConfig.specPaths) !== null && _a !== void 0 ? _a : []).map(function (rawSpecPath) {
|
|
15
16
|
if (rawSpecPath.startsWith('~')) {
|
|
16
17
|
return projectRootPath.copyWithNewSegment(rawSpecPath.replace('~', ''));
|
|
17
18
|
}
|
|
@@ -19,12 +20,12 @@ class CodegenConfig {
|
|
|
19
20
|
return packageRootPath.copyWithNewSegment(rawSpecPath);
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
|
-
|
|
23
|
+
var specFilePaths = specPaths.flatMap(function (specPath) {
|
|
23
24
|
if (!node_fs_1.default.existsSync(specPath.getValue())) {
|
|
24
25
|
throw new DescriptiveError_1.DescriptiveError({
|
|
25
|
-
whatHappened:
|
|
26
|
+
whatHappened: "No such file or directory: ".concat(specPath.getValue()),
|
|
26
27
|
whatCanUserDo: [
|
|
27
|
-
|
|
28
|
+
"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."),
|
|
28
29
|
],
|
|
29
30
|
});
|
|
30
31
|
}
|
|
@@ -32,7 +33,7 @@ class CodegenConfig {
|
|
|
32
33
|
return (0, io_1.findFilePathsWithExtensions)(specPath, SUPPORTED_SPEC_EXTENSIONS);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
|
-
|
|
36
|
+
var ext = specPath.getExtension();
|
|
36
37
|
if (ext && SUPPORTED_SPEC_EXTENSIONS.includes(ext)) {
|
|
37
38
|
return [specPath];
|
|
38
39
|
}
|
|
@@ -40,16 +41,13 @@ class CodegenConfig {
|
|
|
40
41
|
}
|
|
41
42
|
});
|
|
42
43
|
return new CodegenConfig(specFilePaths, (_b = rawCodegenConfig.version) !== null && _b !== void 0 ? _b : 1);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this.specFilePaths = specFilePaths;
|
|
46
|
-
this.version = version;
|
|
47
|
-
}
|
|
48
|
-
getSpecFilePaths() {
|
|
44
|
+
};
|
|
45
|
+
CodegenConfig.prototype.getSpecFilePaths = function () {
|
|
49
46
|
return this.specFilePaths;
|
|
50
|
-
}
|
|
51
|
-
getVersion() {
|
|
47
|
+
};
|
|
48
|
+
CodegenConfig.prototype.getVersion = function () {
|
|
52
49
|
return this.version;
|
|
53
|
-
}
|
|
54
|
-
|
|
50
|
+
};
|
|
51
|
+
return CodegenConfig;
|
|
52
|
+
}());
|
|
55
53
|
exports.CodegenConfig = CodegenConfig;
|
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
2
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
18
|
exports.DescriptiveError = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.
|
|
19
|
+
var DescriptiveError = /** @class */ (function (_super) {
|
|
20
|
+
__extends(DescriptiveError, _super);
|
|
21
|
+
function DescriptiveError(data) {
|
|
22
|
+
var _this = _super.call(this, data.whatHappened) || this;
|
|
23
|
+
_this.data = data;
|
|
24
|
+
return _this;
|
|
8
25
|
}
|
|
9
|
-
isUnexpected() {
|
|
26
|
+
DescriptiveError.prototype.isUnexpected = function () {
|
|
10
27
|
return 'unexpected' in this.data;
|
|
11
|
-
}
|
|
12
|
-
getMessage() {
|
|
28
|
+
};
|
|
29
|
+
DescriptiveError.prototype.getMessage = function () {
|
|
13
30
|
return this.data.whatHappened;
|
|
14
|
-
}
|
|
15
|
-
getSuggestions() {
|
|
31
|
+
};
|
|
32
|
+
DescriptiveError.prototype.getSuggestions = function () {
|
|
16
33
|
var _a;
|
|
17
34
|
if ('whatCanUserDo' in this.data) {
|
|
18
35
|
return (_a = this.data.whatCanUserDo) !== null && _a !== void 0 ? _a : [];
|
|
@@ -20,11 +37,11 @@ class DescriptiveError extends Error {
|
|
|
20
37
|
else {
|
|
21
38
|
return [];
|
|
22
39
|
}
|
|
23
|
-
}
|
|
24
|
-
getRawData() {
|
|
40
|
+
};
|
|
41
|
+
DescriptiveError.prototype.getRawData = function () {
|
|
25
42
|
return this.data;
|
|
26
|
-
}
|
|
27
|
-
getDetails() {
|
|
43
|
+
};
|
|
44
|
+
DescriptiveError.prototype.getDetails = function () {
|
|
28
45
|
var _a;
|
|
29
46
|
if (!this.data.extraData) {
|
|
30
47
|
return '';
|
|
@@ -33,10 +50,11 @@ class DescriptiveError extends Error {
|
|
|
33
50
|
return this.data.extraData.trim();
|
|
34
51
|
}
|
|
35
52
|
if (this.data.extraData instanceof Error) {
|
|
36
|
-
|
|
37
|
-
|
|
53
|
+
var lines = [
|
|
54
|
+
"".concat(this.data.extraData.name, ": ").concat(this.data.extraData.message),
|
|
38
55
|
];
|
|
39
|
-
for (
|
|
56
|
+
for (var _i = 0, _b = ((_a = this.data.extraData.stack) !== null && _a !== void 0 ? _a : '').split('\n'); _i < _b.length; _i++) {
|
|
57
|
+
var stackEntry = _b[_i];
|
|
40
58
|
lines.push('');
|
|
41
59
|
lines.push(stackEntry);
|
|
42
60
|
}
|
|
@@ -48,6 +66,7 @@ class DescriptiveError extends Error {
|
|
|
48
66
|
catch (err) {
|
|
49
67
|
return '';
|
|
50
68
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
69
|
+
};
|
|
70
|
+
return DescriptiveError;
|
|
71
|
+
}(Error));
|
|
53
72
|
exports.DescriptiveError = DescriptiveError;
|
package/dist/core/FileSystem.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.FS = exports.Dirent = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
var node_path_1 = require("node:path");
|
|
5
|
+
var Dirent = /** @class */ (function () {
|
|
6
|
+
function Dirent() {
|
|
7
|
+
}
|
|
8
|
+
return Dirent;
|
|
9
|
+
}());
|
|
10
10
|
exports.Dirent = Dirent;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
var FS = /** @class */ (function () {
|
|
12
|
+
function FS() {
|
|
13
|
+
}
|
|
14
|
+
FS.prototype.findFilePathsWithExtensions = function (dirPath, fileExtensions) {
|
|
15
|
+
var results = [];
|
|
16
|
+
var dirents = this.readDirentsSync(dirPath);
|
|
17
|
+
for (var _i = 0, dirents_1 = dirents; _i < dirents_1.length; _i++) {
|
|
18
|
+
var dirent = dirents_1[_i];
|
|
19
|
+
var path = dirPath.copyWithNewSegment(dirent.name.toString());
|
|
17
20
|
if (dirent.isDirectory()) {
|
|
18
21
|
results = results.concat(this.findFilePathsWithExtensions(path, fileExtensions));
|
|
19
22
|
}
|
|
@@ -22,6 +25,7 @@ class FS {
|
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
return results;
|
|
25
|
-
}
|
|
26
|
-
|
|
28
|
+
};
|
|
29
|
+
return FS;
|
|
30
|
+
}());
|
|
27
31
|
exports.FS = FS;
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.OHPackageJSON5 = void 0;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return new OHPackageJSON5(json5_1.default.parse(node_fs_1.default.readFileSync(ohPackageJson5Path.getValue(), { encoding: 'utf-8' })));
|
|
12
|
-
}
|
|
13
|
-
constructor(rawData) {
|
|
4
|
+
var json5_1 = require("json5");
|
|
5
|
+
var node_fs_1 = require("node:fs");
|
|
6
|
+
var OHPackageJSON5 = /** @class */ (function () {
|
|
7
|
+
function OHPackageJSON5(rawData) {
|
|
14
8
|
this.rawData = rawData;
|
|
15
9
|
}
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
10
|
+
OHPackageJSON5.fromPath = function (ohPackageJson5Path) {
|
|
11
|
+
return new OHPackageJSON5(json5_1.default.parse(node_fs_1.default.readFileSync(ohPackageJson5Path.getValue(), { encoding: 'utf-8' })));
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(OHPackageJSON5.prototype, "name", {
|
|
14
|
+
get: function () {
|
|
15
|
+
return this.rawData['name'];
|
|
16
|
+
},
|
|
17
|
+
enumerable: false,
|
|
18
|
+
configurable: true
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(OHPackageJSON5.prototype, "version", {
|
|
21
|
+
get: function () {
|
|
22
|
+
return this.rawData['version'];
|
|
23
|
+
},
|
|
24
|
+
enumerable: false,
|
|
25
|
+
configurable: true
|
|
26
|
+
});
|
|
27
|
+
return OHPackageJSON5;
|
|
28
|
+
}());
|
|
23
29
|
exports.OHPackageJSON5 = OHPackageJSON5;
|