@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.
- package/README.md +11 -11
- package/dist/assetResolver.js +74 -77
- package/dist/autolinking/Autolinking.js +179 -179
- package/dist/autolinking/JSON5Writer.js +61 -0
- 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 +65 -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 +79 -78
- package/react-native.config.js +17 -17
- package/tsconfig.build.json +6 -6
- package/tsconfig.json +2 -2
package/dist/commands/init.js
CHANGED
|
@@ -6,17 +6,6 @@
|
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
var __assign = (this && this.__assign) || function () {
|
|
10
|
-
__assign = Object.assign || function(t) {
|
|
11
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
12
|
-
s = arguments[i];
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
}
|
|
16
|
-
return t;
|
|
17
|
-
};
|
|
18
|
-
return __assign.apply(this, arguments);
|
|
19
|
-
};
|
|
20
9
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
21
10
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
22
11
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -26,167 +15,101 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
26
15
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
27
16
|
});
|
|
28
17
|
};
|
|
29
|
-
var
|
|
30
|
-
|
|
31
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
32
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
33
|
-
function step(op) {
|
|
34
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
35
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
36
|
-
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;
|
|
37
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
38
|
-
switch (op[0]) {
|
|
39
|
-
case 0: case 1: t = op; break;
|
|
40
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
41
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
42
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
43
|
-
default:
|
|
44
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
45
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
46
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
47
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
48
|
-
if (t[2]) _.ops.pop();
|
|
49
|
-
_.trys.pop(); continue;
|
|
50
|
-
}
|
|
51
|
-
op = body.call(thisArg, _);
|
|
52
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
53
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
57
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
58
|
-
if (ar || !(i in from)) {
|
|
59
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
60
|
-
ar[i] = from[i];
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
18
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
19
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
64
20
|
};
|
|
65
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
22
|
exports.rnohInit = rnohInit;
|
|
67
|
-
|
|
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
|
-
|
|
23
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
24
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
25
|
+
const commander_1 = require("commander");
|
|
26
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
27
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
28
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
29
|
+
const json5_1 = __importDefault(require("json5"));
|
|
30
|
+
const cli_tools_1 = require("@react-native-community/cli-tools");
|
|
31
|
+
const CliExecutor_1 = require("../io/CliExecutor");
|
|
32
|
+
const AbsolutePath_1 = require("../core/AbsolutePath");
|
|
33
|
+
const DescriptiveError_1 = require("../core/DescriptiveError");
|
|
34
|
+
const VALID_APP_NAME_REG = /^[A-Za-z][A-Za-z0-9_]*[A-Za-z0-9]$/;
|
|
35
|
+
const DEFAULT_PACKAGE_PREFIX = 'com.example.';
|
|
36
|
+
const HARMONY_DIR = 'harmony';
|
|
37
|
+
const JSON5_EXT = '.json5';
|
|
38
|
+
const DEFAULT_ENCODING = 'utf8';
|
|
39
|
+
const MODULE_DESC = 'module_desc';
|
|
40
|
+
const ENTRY_ABILITY_DESC = 'EntryAbility_desc';
|
|
41
|
+
const ENTRY_ABILITY_LABEL = 'EntryAbility_label';
|
|
42
|
+
const REACT_NATIVE = 'react-native';
|
|
43
|
+
const NODE_MODULES = 'node_modules';
|
|
44
|
+
const STRING_TYPE = 'string';
|
|
45
|
+
const PROJECT_NAME_INDEX = 0;
|
|
46
|
+
const JSON_INDENTATION_LENGTH = 2;
|
|
47
|
+
const GIT_EXE = 'git';
|
|
48
|
+
const NODE_EXE = 'node';
|
|
49
|
+
const NPM_EXE = 'npm';
|
|
50
|
+
const APP_JSON = 'app.json';
|
|
51
|
+
const APP_JSON5 = 'app.json5';
|
|
52
|
+
const STRING_JSON = 'string.json';
|
|
53
|
+
const PACKAGE_JSON = 'package.json';
|
|
54
|
+
const TEMPLATE_CONFIG_JS = 'template.config.js';
|
|
55
|
+
const METRO_CONFIG_JS = 'metro.config.js';
|
|
56
|
+
const DEFAULT_TEMPLATE_PKG = '@react-native-oh/template';
|
|
57
|
+
const REACT_NATIVE_OH_REACT_NATIVE_HARMONY = '@react-native-oh/react-native-harmony';
|
|
58
|
+
const REACT_NATIVE_OH_REACT_NATIVE_HARMONY_CLI = '@react-native-oh/react-native-harmony-cli';
|
|
103
59
|
/**
|
|
104
60
|
* Helper class for file operations (JSON and text file updates).
|
|
105
61
|
*/
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
? json5_1.default.stringify(updatedData, null, JSON_INDENTATION_LENGTH)
|
|
129
|
-
: JSON.stringify(updatedData, null, JSON_INDENTATION_LENGTH);
|
|
130
|
-
return [4 /*yield*/, fs_extra_1.default.writeFile(filePath, outputContent)];
|
|
131
|
-
case 4:
|
|
132
|
-
_a.sent();
|
|
133
|
-
return [3 /*break*/, 6];
|
|
134
|
-
case 5:
|
|
135
|
-
e_1 = _a.sent();
|
|
136
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
137
|
-
whatHappened: errorMessage,
|
|
138
|
-
whatCanUserDo: ['Please check if the file format is correct.'],
|
|
139
|
-
extraData: e_1,
|
|
140
|
-
});
|
|
141
|
-
case 6: return [2 /*return*/];
|
|
142
|
-
}
|
|
143
|
-
});
|
|
62
|
+
class FileOperationHelper {
|
|
63
|
+
static updateJsonFile(filePath, updateFn, errorMessage) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
if (!(yield fs_extra_1.default.pathExists(filePath))) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
const content = yield fs_extra_1.default.readFile(filePath, DEFAULT_ENCODING);
|
|
70
|
+
const data = json5_1.default.parse(content);
|
|
71
|
+
const updatedData = updateFn(data);
|
|
72
|
+
const outputContent = filePath.endsWith(JSON5_EXT)
|
|
73
|
+
? json5_1.default.stringify(updatedData, null, JSON_INDENTATION_LENGTH)
|
|
74
|
+
: JSON.stringify(updatedData, null, JSON_INDENTATION_LENGTH);
|
|
75
|
+
yield fs_extra_1.default.writeFile(filePath, outputContent);
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
79
|
+
whatHappened: errorMessage,
|
|
80
|
+
whatCanUserDo: ['Please check if the file format is correct.'],
|
|
81
|
+
extraData: e,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
144
84
|
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
_a.label = 2;
|
|
157
|
-
case 2:
|
|
158
|
-
_a.trys.push([2, 6, , 7]);
|
|
159
|
-
return [4 /*yield*/, fs_extra_1.default.readFile(filePath, DEFAULT_ENCODING)];
|
|
160
|
-
case 3:
|
|
161
|
-
content = _a.sent();
|
|
162
|
-
if (!content.includes(placeholder)) return [3 /*break*/, 5];
|
|
163
|
-
content = content.replace(new RegExp(placeholder, 'g'), replacement);
|
|
164
|
-
return [4 /*yield*/, fs_extra_1.default.writeFile(filePath, content, DEFAULT_ENCODING)];
|
|
165
|
-
case 4:
|
|
166
|
-
_a.sent();
|
|
167
|
-
_a.label = 5;
|
|
168
|
-
case 5: return [3 /*break*/, 7];
|
|
169
|
-
case 6:
|
|
170
|
-
e_2 = _a.sent();
|
|
171
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
172
|
-
whatHappened: "Failed to update ".concat(node_path_1.default.basename(filePath), "."),
|
|
173
|
-
whatCanUserDo: ['Please check if the file is readable and writable.'],
|
|
174
|
-
extraData: e_2,
|
|
175
|
-
});
|
|
176
|
-
case 7: return [2 /*return*/];
|
|
85
|
+
}
|
|
86
|
+
static updateTextFile(filePath, placeholder, replacement) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
if (!(yield fs_extra_1.default.pathExists(filePath))) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
let content = yield fs_extra_1.default.readFile(filePath, DEFAULT_ENCODING);
|
|
93
|
+
if (content.includes(placeholder)) {
|
|
94
|
+
content = content.replace(new RegExp(placeholder, 'g'), replacement);
|
|
95
|
+
yield fs_extra_1.default.writeFile(filePath, content, DEFAULT_ENCODING);
|
|
177
96
|
}
|
|
178
|
-
}
|
|
97
|
+
}
|
|
98
|
+
catch (e) {
|
|
99
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
100
|
+
whatHappened: `Failed to update ${node_path_1.default.basename(filePath)}.`,
|
|
101
|
+
whatCanUserDo: ['Please check if the file is readable and writable.'],
|
|
102
|
+
extraData: e,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
179
105
|
});
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
}());
|
|
106
|
+
}
|
|
107
|
+
}
|
|
183
108
|
/**
|
|
184
109
|
* Helper class for validation operations.
|
|
185
110
|
*/
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
189
|
-
ValidationHelper.validateProjectName = function (projectName) {
|
|
111
|
+
class ValidationHelper {
|
|
112
|
+
static validateProjectName(projectName) {
|
|
190
113
|
if (!projectName.trim()) {
|
|
191
114
|
return 'Project name cannot be empty.';
|
|
192
115
|
}
|
|
@@ -194,91 +117,60 @@ var ValidationHelper = /** @class */ (function () {
|
|
|
194
117
|
return 'Project name must start with a letter and can only contain letters, numbers, _.';
|
|
195
118
|
}
|
|
196
119
|
return true;
|
|
197
|
-
}
|
|
198
|
-
|
|
120
|
+
}
|
|
121
|
+
static validateOptions(options) {
|
|
199
122
|
if (options.version && options.template) {
|
|
200
123
|
throw new DescriptiveError_1.DescriptiveError({
|
|
201
124
|
whatHappened: 'Cannot specify both --version and --template.',
|
|
202
125
|
whatCanUserDo: ['Please specify only one of --version or --template.'],
|
|
203
126
|
});
|
|
204
127
|
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
-
var
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return [4 /*yield*/, fs_extra_1.default.readFile(packageJsonPath, DEFAULT_ENCODING)];
|
|
219
|
-
case 2:
|
|
220
|
-
packageJson = _b.apply(_a, [_d.sent()]);
|
|
221
|
-
reactNativeVersion = (_c = packageJson.dependencies) === null || _c === void 0 ? void 0 : _c[REACT_NATIVE];
|
|
222
|
-
if (!reactNativeVersion || !/^\^?0\.(72)|(77)\./.test(reactNativeVersion)) {
|
|
223
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
224
|
-
whatHappened: "Unsupported RN community template. Please ensure react-native version starts with \"0.77.\".",
|
|
225
|
-
whatCanUserDo: ['Please use a template with react-native version 0.77.x.'],
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
return [2 /*return*/, reactNativeVersion];
|
|
229
|
-
case 3: return [2 /*return*/, "0.77"];
|
|
128
|
+
}
|
|
129
|
+
static validateReactNativeVersion(destDir) {
|
|
130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
131
|
+
var _a;
|
|
132
|
+
const packageJsonPath = node_path_1.default.join(destDir, PACKAGE_JSON);
|
|
133
|
+
if (yield fs_extra_1.default.pathExists(packageJsonPath)) {
|
|
134
|
+
const packageJson = JSON.parse(yield fs_extra_1.default.readFile(packageJsonPath, DEFAULT_ENCODING));
|
|
135
|
+
const reactNativeVersion = (_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a[REACT_NATIVE];
|
|
136
|
+
if (!reactNativeVersion || !/^\^?0\.(72)|(77)\./.test(reactNativeVersion)) {
|
|
137
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
138
|
+
whatHappened: `Unsupported RN community template. Please ensure react-native version starts with "0.77.".`,
|
|
139
|
+
whatCanUserDo: ['Please use a template with react-native version 0.77.x.'],
|
|
140
|
+
});
|
|
230
141
|
}
|
|
231
|
-
|
|
142
|
+
return reactNativeVersion;
|
|
143
|
+
}
|
|
144
|
+
return "0.77";
|
|
232
145
|
});
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
}());
|
|
146
|
+
}
|
|
147
|
+
}
|
|
236
148
|
/**
|
|
237
149
|
* Main entry point for the RNOH init command.
|
|
238
150
|
* Initializes a new RNOH project with proper template and configuration.
|
|
239
151
|
*/
|
|
240
152
|
function rnohInit() {
|
|
241
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
.option('-v, --version <version>', 'Harmonized RN version')
|
|
252
|
-
.option('-t, --template <template>', 'Template npm package')
|
|
253
|
-
.action(function (projectName, options) { return __awaiter(_this, void 0, void 0, function () {
|
|
254
|
-
var err_1;
|
|
255
|
-
return __generator(this, function (_a) {
|
|
256
|
-
switch (_a.label) {
|
|
257
|
-
case 0:
|
|
258
|
-
_a.trys.push([0, 2, , 3]);
|
|
259
|
-
return [4 /*yield*/, runInit(projectName, options)];
|
|
260
|
-
case 1:
|
|
261
|
-
_a.sent();
|
|
262
|
-
return [3 /*break*/, 3];
|
|
263
|
-
case 2:
|
|
264
|
-
err_1 = _a.sent();
|
|
265
|
-
handleError(err_1);
|
|
266
|
-
process.exit(1);
|
|
267
|
-
return [3 /*break*/, 3];
|
|
268
|
-
case 3: return [2 /*return*/];
|
|
269
|
-
}
|
|
270
|
-
});
|
|
271
|
-
}); });
|
|
272
|
-
return [4 /*yield*/, program.parseAsync(process.argv)];
|
|
273
|
-
case 1:
|
|
274
|
-
_a.sent();
|
|
275
|
-
return [2 /*return*/];
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
const program = new commander_1.Command();
|
|
155
|
+
program
|
|
156
|
+
.command('init [projectName]')
|
|
157
|
+
.description('Initialize a new RNOH project')
|
|
158
|
+
.option('-v, --version <version>', 'Harmonized RN version')
|
|
159
|
+
.option('-t, --template <template>', 'Template npm package')
|
|
160
|
+
.action((projectName, options) => __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
try {
|
|
162
|
+
yield runInit(projectName, options);
|
|
276
163
|
}
|
|
277
|
-
|
|
164
|
+
catch (err) {
|
|
165
|
+
handleError(err);
|
|
166
|
+
process.exit(1);
|
|
167
|
+
}
|
|
168
|
+
}));
|
|
169
|
+
yield program.parseAsync(process.argv);
|
|
278
170
|
});
|
|
279
171
|
}
|
|
280
172
|
function showWelcomeMessage(version) {
|
|
281
|
-
|
|
173
|
+
const rnohLogoArray = [
|
|
282
174
|
' ',
|
|
283
175
|
' ____ _ ______ __ __ ',
|
|
284
176
|
' / __ \\/ | / / __ \\/ / / / ',
|
|
@@ -287,549 +179,348 @@ function showWelcomeMessage(version) {
|
|
|
287
179
|
' /_/ |_/_/ |_/\\____/_/ /_/ ',
|
|
288
180
|
' ',
|
|
289
181
|
];
|
|
290
|
-
|
|
291
|
-
?
|
|
182
|
+
const versionInfo = version && version !== 'undefined'
|
|
183
|
+
? ` Welcome to RNOH ${version}!`
|
|
292
184
|
: ' Welcome to RNOH!';
|
|
293
|
-
cli_tools_1.logger.log(
|
|
185
|
+
cli_tools_1.logger.log(`${chalk_1.default.cyan(rnohLogoArray.join('\n'))}\n${chalk_1.default.cyanBright.bold(versionInfo)}\n`);
|
|
294
186
|
}
|
|
295
187
|
function runInit(projectName, options) {
|
|
296
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
case 4:
|
|
315
|
-
_a.trys.push([4, 6, 8, 10]);
|
|
316
|
-
return [4 /*yield*/, executeInitializationSteps(tempDir, destDir, projectName, packageName, options)];
|
|
317
|
-
case 5:
|
|
318
|
-
_a.sent();
|
|
319
|
-
return [3 /*break*/, 10];
|
|
320
|
-
case 6:
|
|
321
|
-
error_1 = _a.sent();
|
|
322
|
-
return [4 /*yield*/, cleanupOnError(destDir)];
|
|
323
|
-
case 7:
|
|
324
|
-
_a.sent();
|
|
325
|
-
throw error_1;
|
|
326
|
-
case 8: return [4 /*yield*/, cleanupTempDir(tempDir)];
|
|
327
|
-
case 9:
|
|
328
|
-
_a.sent();
|
|
329
|
-
return [7 /*endfinally*/];
|
|
330
|
-
case 10: return [2 /*return*/];
|
|
331
|
-
}
|
|
332
|
-
});
|
|
188
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
+
projectName = yield getValidatedProjectName(projectName);
|
|
190
|
+
ValidationHelper.validateOptions(options);
|
|
191
|
+
const packageName = `${DEFAULT_PACKAGE_PREFIX}${projectName}`;
|
|
192
|
+
const destDir = node_path_1.default.resolve(process.cwd(), projectName);
|
|
193
|
+
yield checkDestinationDirectory(destDir, projectName);
|
|
194
|
+
showWelcomeMessage(options.version);
|
|
195
|
+
const tempDir = yield createTempDir();
|
|
196
|
+
try {
|
|
197
|
+
yield executeInitializationSteps(tempDir, destDir, projectName, packageName, options);
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
yield cleanupOnError(destDir);
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
finally {
|
|
204
|
+
yield cleanupTempDir(tempDir);
|
|
205
|
+
}
|
|
333
206
|
});
|
|
334
207
|
}
|
|
335
208
|
function getValidatedProjectName(projectName) {
|
|
336
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
357
|
-
whatHappened: 'Invalid project name.',
|
|
358
|
-
whatCanUserDo: [validationResult],
|
|
359
|
-
});
|
|
360
|
-
}
|
|
361
|
-
return [2 /*return*/, projectName];
|
|
362
|
-
}
|
|
363
|
-
});
|
|
209
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
if (!projectName) {
|
|
211
|
+
const { name } = yield inquirer_1.default.prompt([
|
|
212
|
+
{
|
|
213
|
+
type: 'input',
|
|
214
|
+
name: 'name',
|
|
215
|
+
message: 'Please input your project name:',
|
|
216
|
+
validate: ValidationHelper.validateProjectName,
|
|
217
|
+
},
|
|
218
|
+
]);
|
|
219
|
+
return name.trim();
|
|
220
|
+
}
|
|
221
|
+
const validationResult = ValidationHelper.validateProjectName(projectName);
|
|
222
|
+
if (validationResult !== true) {
|
|
223
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
224
|
+
whatHappened: 'Invalid project name.',
|
|
225
|
+
whatCanUserDo: [validationResult],
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return projectName;
|
|
364
229
|
});
|
|
365
230
|
}
|
|
366
231
|
function checkDestinationDirectory(destDir, projectName) {
|
|
367
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
default: false,
|
|
380
|
-
},
|
|
381
|
-
])];
|
|
382
|
-
case 2:
|
|
383
|
-
overwrite = (_a.sent()).overwrite;
|
|
384
|
-
if (!overwrite) {
|
|
385
|
-
process.exit(0);
|
|
386
|
-
}
|
|
387
|
-
_a.label = 3;
|
|
388
|
-
case 3:
|
|
389
|
-
_a.trys.push([3, 5, , 6]);
|
|
390
|
-
return [4 /*yield*/, fs_extra_1.default.remove(destDir)];
|
|
391
|
-
case 4:
|
|
392
|
-
_a.sent();
|
|
393
|
-
return [3 /*break*/, 6];
|
|
394
|
-
case 5:
|
|
395
|
-
err_2 = _a.sent();
|
|
396
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
397
|
-
whatHappened: "Failed to remove existing directory ".concat(destDir),
|
|
398
|
-
whatCanUserDo: ['Check permissions for the directory.', 'Ensure the directory is not in use.'],
|
|
399
|
-
});
|
|
400
|
-
case 6: return [2 /*return*/];
|
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
233
|
+
if (yield fs_extra_1.default.pathExists(destDir)) {
|
|
234
|
+
const { overwrite } = yield inquirer_1.default.prompt([
|
|
235
|
+
{
|
|
236
|
+
type: 'confirm',
|
|
237
|
+
name: 'overwrite',
|
|
238
|
+
message: `Directory '${projectName}' already exists. Do you want to overwrite it?`,
|
|
239
|
+
default: false,
|
|
240
|
+
},
|
|
241
|
+
]);
|
|
242
|
+
if (!overwrite) {
|
|
243
|
+
process.exit(0);
|
|
401
244
|
}
|
|
402
|
-
|
|
245
|
+
try {
|
|
246
|
+
yield fs_extra_1.default.remove(destDir);
|
|
247
|
+
}
|
|
248
|
+
catch (err) {
|
|
249
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
250
|
+
whatHappened: `Failed to remove existing directory ${destDir}`,
|
|
251
|
+
whatCanUserDo: ['Check permissions for the directory.', 'Ensure the directory is not in use.'],
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
}
|
|
403
255
|
});
|
|
404
256
|
}
|
|
405
257
|
function executeInitializationSteps(tempDir, destDir, projectName, packageName, options) {
|
|
406
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return [4 /*yield*/, npmInitAndInstall(tempDir, options.template, options.version)];
|
|
418
|
-
case 2:
|
|
419
|
-
_c.sent();
|
|
420
|
-
loader.succeed('Template downloaded successfully!');
|
|
421
|
-
return [3 /*break*/, 4];
|
|
422
|
-
case 3:
|
|
423
|
-
err_3 = _c.sent();
|
|
424
|
-
loader.fail('Failed to download template');
|
|
425
|
-
if (err_3 instanceof DescriptiveError_1.DescriptiveError) {
|
|
426
|
-
throw err_3;
|
|
427
|
-
}
|
|
428
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
429
|
-
whatHappened: 'Template download failed',
|
|
430
|
-
whatCanUserDo: ['Check your internet connection.', 'Ensure the template package exists.'],
|
|
431
|
-
});
|
|
432
|
-
case 4:
|
|
433
|
-
loader.start("".concat(chalk_1.default.bold('Copying template...')));
|
|
434
|
-
return [4 /*yield*/, getTemplateConfigFromPkg(tempDir)];
|
|
435
|
-
case 5:
|
|
436
|
-
_a = _c.sent(), templateConfig = _a.templateConfig, templateRoot = _a.templateRoot;
|
|
437
|
-
isHarmonyTemplate = true;
|
|
438
|
-
rnohTemplateConfig = undefined;
|
|
439
|
-
rnohVersion = undefined;
|
|
440
|
-
rnohCliVersion = undefined;
|
|
441
|
-
_c.label = 6;
|
|
442
|
-
case 6:
|
|
443
|
-
_c.trys.push([6, 12, , 13]);
|
|
444
|
-
return [4 /*yield*/, copyAndReplaceTemplate(templateConfig, templateRoot, destDir)];
|
|
445
|
-
case 7:
|
|
446
|
-
_c.sent();
|
|
447
|
-
return [4 /*yield*/, ValidationHelper.validateReactNativeVersion(destDir)];
|
|
448
|
-
case 8:
|
|
449
|
-
rnVersion = _c.sent();
|
|
450
|
-
return [4 /*yield*/, fs_extra_1.default.pathExists(node_path_1.default.join(destDir, HARMONY_DIR))];
|
|
451
|
-
case 9:
|
|
452
|
-
if (!!(_c.sent())) return [3 /*break*/, 11];
|
|
453
|
-
isHarmonyTemplate = false;
|
|
454
|
-
return [4 /*yield*/, handleMissingHarmonyDir(destDir, rnVersion)];
|
|
455
|
-
case 10:
|
|
456
|
-
(_b = _c.sent(), rnohTemplateConfig = _b.rnohTemplateConfig, rnohVersion = _b.rnohVersion, rnohCliVersion = _b.rnohCliVersion);
|
|
457
|
-
_c.label = 11;
|
|
458
|
-
case 11:
|
|
459
|
-
loader.succeed('Template copied successfully!');
|
|
460
|
-
return [3 /*break*/, 13];
|
|
461
|
-
case 12:
|
|
462
|
-
err_4 = _c.sent();
|
|
463
|
-
loader.fail('Failed to copy template');
|
|
464
|
-
if (err_4 instanceof DescriptiveError_1.DescriptiveError) {
|
|
465
|
-
throw err_4;
|
|
466
|
-
}
|
|
467
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
468
|
-
whatHappened: 'Template copy failed',
|
|
469
|
-
whatCanUserDo: ['Ensure you have write permissions for the destination directory.'],
|
|
470
|
-
});
|
|
471
|
-
case 13:
|
|
472
|
-
loader.start("".concat(chalk_1.default.bold('Processing template...')));
|
|
473
|
-
_c.label = 14;
|
|
474
|
-
case 14:
|
|
475
|
-
_c.trys.push([14, 16, , 17]);
|
|
476
|
-
updateConfig = {
|
|
477
|
-
destDir: destDir,
|
|
478
|
-
templateRoot: templateRoot,
|
|
479
|
-
templateConfig: templateConfig,
|
|
480
|
-
projectName: projectName,
|
|
481
|
-
packageName: packageName,
|
|
482
|
-
isHarmonyTemplate: isHarmonyTemplate,
|
|
483
|
-
rnohVersion: rnohVersion,
|
|
484
|
-
rnohCliVersion: rnohCliVersion,
|
|
485
|
-
rnohTemplateConfig: rnohTemplateConfig,
|
|
486
|
-
};
|
|
487
|
-
return [4 /*yield*/, processTemplate(updateConfig)];
|
|
488
|
-
case 15:
|
|
489
|
-
_c.sent();
|
|
490
|
-
loader.succeed('Template processed successfully!');
|
|
491
|
-
return [3 /*break*/, 17];
|
|
492
|
-
case 16:
|
|
493
|
-
err_5 = _c.sent();
|
|
494
|
-
loader.fail('Failed to process template');
|
|
495
|
-
if (err_5 instanceof DescriptiveError_1.DescriptiveError) {
|
|
496
|
-
throw err_5;
|
|
497
|
-
}
|
|
498
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
499
|
-
whatHappened: 'Template processing failed',
|
|
500
|
-
whatCanUserDo: ['Check if the template files are corrupted.'],
|
|
501
|
-
});
|
|
502
|
-
case 17:
|
|
503
|
-
loader.start("".concat(chalk_1.default.bold('Installing dependencies...')));
|
|
504
|
-
_c.label = 18;
|
|
505
|
-
case 18:
|
|
506
|
-
_c.trys.push([18, 20, , 21]);
|
|
507
|
-
return [4 /*yield*/, runCliCommand(NPM_EXE, ['install', '--legacy-peer-deps'], destDir)];
|
|
508
|
-
case 19:
|
|
509
|
-
_c.sent();
|
|
510
|
-
loader.succeed('Dependencies installed successfully!');
|
|
511
|
-
return [3 /*break*/, 21];
|
|
512
|
-
case 20:
|
|
513
|
-
err_6 = _c.sent();
|
|
514
|
-
loader.fail('Failed to install dependencies');
|
|
515
|
-
if (err_6 instanceof DescriptiveError_1.DescriptiveError) {
|
|
516
|
-
throw err_6;
|
|
517
|
-
}
|
|
518
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
519
|
-
whatHappened: 'Dependency installation failed',
|
|
520
|
-
whatCanUserDo: ['Check your internet connection.'],
|
|
521
|
-
});
|
|
522
|
-
case 21:
|
|
523
|
-
loader.start("".concat(chalk_1.default.bold('Initializing git repository...')));
|
|
524
|
-
return [4 /*yield*/, initGitRepo(destDir)];
|
|
525
|
-
case 22:
|
|
526
|
-
isSuccess = _c.sent();
|
|
527
|
-
if (isSuccess) {
|
|
528
|
-
loader.succeed('Git repository initialized successfully!');
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
loader.fail('Failed to initialize git repository.');
|
|
532
|
-
}
|
|
533
|
-
return [2 /*return*/];
|
|
258
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
259
|
+
const loader = (0, cli_tools_1.getLoader)();
|
|
260
|
+
loader.start(`${chalk_1.default.bold('Downloading template...')}`);
|
|
261
|
+
try {
|
|
262
|
+
yield npmInitAndInstall(tempDir, options.template, options.version);
|
|
263
|
+
loader.succeed('Template downloaded successfully!');
|
|
264
|
+
}
|
|
265
|
+
catch (err) {
|
|
266
|
+
loader.fail('Failed to download template');
|
|
267
|
+
if (err instanceof DescriptiveError_1.DescriptiveError) {
|
|
268
|
+
throw err;
|
|
534
269
|
}
|
|
535
|
-
|
|
270
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
271
|
+
whatHappened: 'Template download failed',
|
|
272
|
+
whatCanUserDo: ['Check your internet connection.', 'Ensure the template package exists.'],
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
loader.start(`${chalk_1.default.bold('Copying template...')}`);
|
|
276
|
+
const { templateConfig, templateRoot } = yield getTemplateConfigFromPkg(tempDir);
|
|
277
|
+
let isHarmonyTemplate = true;
|
|
278
|
+
let rnohTemplateConfig = undefined;
|
|
279
|
+
let rnohVersion = undefined;
|
|
280
|
+
let rnohCliVersion = undefined;
|
|
281
|
+
try {
|
|
282
|
+
yield copyAndReplaceTemplate(templateConfig, templateRoot, destDir);
|
|
283
|
+
const rnVersion = yield ValidationHelper.validateReactNativeVersion(destDir);
|
|
284
|
+
if (!(yield fs_extra_1.default.pathExists(node_path_1.default.join(destDir, HARMONY_DIR)))) {
|
|
285
|
+
isHarmonyTemplate = false;
|
|
286
|
+
({ rnohTemplateConfig, rnohVersion, rnohCliVersion } = yield handleMissingHarmonyDir(destDir, rnVersion));
|
|
287
|
+
}
|
|
288
|
+
loader.succeed('Template copied successfully!');
|
|
289
|
+
}
|
|
290
|
+
catch (err) {
|
|
291
|
+
loader.fail('Failed to copy template');
|
|
292
|
+
if (err instanceof DescriptiveError_1.DescriptiveError) {
|
|
293
|
+
throw err;
|
|
294
|
+
}
|
|
295
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
296
|
+
whatHappened: 'Template copy failed',
|
|
297
|
+
whatCanUserDo: ['Ensure you have write permissions for the destination directory.'],
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
loader.start(`${chalk_1.default.bold('Processing template...')}`);
|
|
301
|
+
try {
|
|
302
|
+
const updateConfig = {
|
|
303
|
+
destDir,
|
|
304
|
+
templateRoot,
|
|
305
|
+
templateConfig,
|
|
306
|
+
projectName,
|
|
307
|
+
packageName,
|
|
308
|
+
isHarmonyTemplate,
|
|
309
|
+
rnohVersion,
|
|
310
|
+
rnohCliVersion,
|
|
311
|
+
rnohTemplateConfig,
|
|
312
|
+
};
|
|
313
|
+
yield processTemplate(updateConfig);
|
|
314
|
+
loader.succeed('Template processed successfully!');
|
|
315
|
+
}
|
|
316
|
+
catch (err) {
|
|
317
|
+
loader.fail('Failed to process template');
|
|
318
|
+
if (err instanceof DescriptiveError_1.DescriptiveError) {
|
|
319
|
+
throw err;
|
|
320
|
+
}
|
|
321
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
322
|
+
whatHappened: 'Template processing failed',
|
|
323
|
+
whatCanUserDo: ['Check if the template files are corrupted.'],
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
loader.start(`${chalk_1.default.bold('Installing dependencies...')}`);
|
|
327
|
+
try {
|
|
328
|
+
yield runCliCommand(NPM_EXE, ['install', '--legacy-peer-deps'], destDir);
|
|
329
|
+
loader.succeed('Dependencies installed successfully!');
|
|
330
|
+
}
|
|
331
|
+
catch (err) {
|
|
332
|
+
loader.fail('Failed to install dependencies');
|
|
333
|
+
if (err instanceof DescriptiveError_1.DescriptiveError) {
|
|
334
|
+
throw err;
|
|
335
|
+
}
|
|
336
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
337
|
+
whatHappened: 'Dependency installation failed',
|
|
338
|
+
whatCanUserDo: ['Check your internet connection.'],
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
loader.start(`${chalk_1.default.bold('Initializing git repository...')}`);
|
|
342
|
+
const isSuccess = yield initGitRepo(destDir);
|
|
343
|
+
if (isSuccess) {
|
|
344
|
+
loader.succeed('Git repository initialized successfully!');
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
loader.fail('Failed to initialize git repository.');
|
|
348
|
+
}
|
|
536
349
|
});
|
|
537
350
|
}
|
|
538
351
|
function createTempDir() {
|
|
539
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
case 0:
|
|
544
|
-
tempDir = node_path_1.default.join(node_os_1.default.tmpdir(), "rnoh-init-".concat(Date.now(), "-").concat(Math.random().toString(36).slice(2)));
|
|
545
|
-
return [4 /*yield*/, fs_extra_1.default.ensureDir(tempDir)];
|
|
546
|
-
case 1:
|
|
547
|
-
_a.sent();
|
|
548
|
-
return [2 /*return*/, tempDir];
|
|
549
|
-
}
|
|
550
|
-
});
|
|
352
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
353
|
+
const tempDir = node_path_1.default.join(node_os_1.default.tmpdir(), `rnoh-init-${Date.now()}-${Math.random().toString(36).slice(2)}`);
|
|
354
|
+
yield fs_extra_1.default.ensureDir(tempDir);
|
|
355
|
+
return tempDir;
|
|
551
356
|
});
|
|
552
357
|
}
|
|
553
358
|
function npmInitAndInstall(tempDir, customTemplate, version) {
|
|
554
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
case 0: return [4 /*yield*/, runCliCommand(NPM_EXE, ['init', '-y'], tempDir)];
|
|
559
|
-
case 1:
|
|
560
|
-
_a.sent();
|
|
561
|
-
installTarget = customTemplate ? customTemplate : version ? "".concat(DEFAULT_TEMPLATE_PKG, "@").concat(version) : DEFAULT_TEMPLATE_PKG;
|
|
562
|
-
return [4 /*yield*/, runCliCommand(NPM_EXE, ['install', installTarget], tempDir)];
|
|
563
|
-
case 2:
|
|
564
|
-
_a.sent();
|
|
565
|
-
return [2 /*return*/];
|
|
566
|
-
}
|
|
567
|
-
});
|
|
359
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
360
|
+
yield runCliCommand(NPM_EXE, ['init', '-y'], tempDir);
|
|
361
|
+
const installTarget = customTemplate ? customTemplate : version ? `${DEFAULT_TEMPLATE_PKG}@${version}` : DEFAULT_TEMPLATE_PKG;
|
|
362
|
+
yield runCliCommand(NPM_EXE, ['install', installTarget], tempDir);
|
|
568
363
|
});
|
|
569
364
|
}
|
|
570
365
|
function getTemplateConfigFromPkg(tempDir) {
|
|
571
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
return [4 /*yield*/, fs_extra_1.default.pathExists(configPath)];
|
|
594
|
-
case 3:
|
|
595
|
-
if (!(_c.sent())) {
|
|
596
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
597
|
-
whatHappened: "".concat(TEMPLATE_CONFIG_JS, " not found in template package."),
|
|
598
|
-
whatCanUserDo: ['Check the template package.'],
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
templateConfig = require(configPath);
|
|
602
|
-
validateTemplateConfig(templateConfig);
|
|
603
|
-
return [2 /*return*/, { templateConfig: templateConfig, templateRoot: templateRoot }];
|
|
604
|
-
}
|
|
605
|
-
});
|
|
366
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
367
|
+
const pkgJsonPath = node_path_1.default.join(tempDir, PACKAGE_JSON);
|
|
368
|
+
const packageJson = JSON.parse(yield fs_extra_1.default.readFile(pkgJsonPath, DEFAULT_ENCODING));
|
|
369
|
+
const dependencies = packageJson.dependencies;
|
|
370
|
+
const templateName = Object.keys(dependencies)[0];
|
|
371
|
+
const templateRoot = node_path_1.default.join(tempDir, NODE_MODULES, ...templateName.split('/'));
|
|
372
|
+
if (!(yield fs_extra_1.default.pathExists(templateRoot))) {
|
|
373
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
374
|
+
whatHappened: 'Cannot find installed template package.',
|
|
375
|
+
whatCanUserDo: ['Check npm install output.'],
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
const configPath = node_path_1.default.join(templateRoot, TEMPLATE_CONFIG_JS);
|
|
379
|
+
if (!(yield fs_extra_1.default.pathExists(configPath))) {
|
|
380
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
381
|
+
whatHappened: `${TEMPLATE_CONFIG_JS} not found in template package.`,
|
|
382
|
+
whatCanUserDo: ['Check the template package.'],
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
const templateConfig = require(configPath);
|
|
386
|
+
validateTemplateConfig(templateConfig);
|
|
387
|
+
return { templateConfig, templateRoot };
|
|
606
388
|
});
|
|
607
389
|
}
|
|
608
390
|
function validateTemplateConfig(templateConfig) {
|
|
609
391
|
if (!templateConfig.placeholderName || !templateConfig.templateDir) {
|
|
610
392
|
throw new DescriptiveError_1.DescriptiveError({
|
|
611
|
-
whatHappened:
|
|
612
|
-
whatCanUserDo: [
|
|
393
|
+
whatHappened: `${TEMPLATE_CONFIG_JS} missing required fields (placeholderName, templateDir).`,
|
|
394
|
+
whatCanUserDo: [`Check ${TEMPLATE_CONFIG_JS} format.`],
|
|
613
395
|
});
|
|
614
396
|
}
|
|
615
397
|
if (typeof templateConfig.placeholderName !== STRING_TYPE || typeof templateConfig.templateDir !== STRING_TYPE) {
|
|
616
398
|
throw new DescriptiveError_1.DescriptiveError({
|
|
617
|
-
whatHappened:
|
|
618
|
-
whatCanUserDo: [
|
|
399
|
+
whatHappened: `${TEMPLATE_CONFIG_JS} fields must be strings.`,
|
|
400
|
+
whatCanUserDo: [`Check ${TEMPLATE_CONFIG_JS} format.`],
|
|
619
401
|
});
|
|
620
402
|
}
|
|
621
403
|
}
|
|
622
404
|
function copyAndReplaceTemplate(templateConfig, templateRoot, destDir) {
|
|
623
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
633
|
-
whatHappened: 'Template directory not found.',
|
|
634
|
-
whatCanUserDo: ["Check templateDir in ".concat(TEMPLATE_CONFIG_JS, ".")],
|
|
635
|
-
});
|
|
636
|
-
}
|
|
637
|
-
return [4 /*yield*/, fs_extra_1.default.copy(srcDir, destDir)];
|
|
638
|
-
case 2:
|
|
639
|
-
_a.sent();
|
|
640
|
-
return [2 /*return*/];
|
|
641
|
-
}
|
|
642
|
-
});
|
|
405
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
406
|
+
const srcDir = node_path_1.default.join(templateRoot, templateConfig.templateDir);
|
|
407
|
+
if (!(yield fs_extra_1.default.pathExists(srcDir))) {
|
|
408
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
409
|
+
whatHappened: 'Template directory not found.',
|
|
410
|
+
whatCanUserDo: [`Check templateDir in ${TEMPLATE_CONFIG_JS}.`],
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
yield fs_extra_1.default.copy(srcDir, destDir);
|
|
643
414
|
});
|
|
644
415
|
}
|
|
645
416
|
function updateRNConfigFiles(updateConfig) {
|
|
646
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
}
|
|
659
|
-
return __assign(__assign({}, data), { name: updateConfig.packageName });
|
|
660
|
-
}, "Failed to update ".concat(PACKAGE_JSON, ".")),
|
|
661
|
-
];
|
|
662
|
-
return [4 /*yield*/, Promise.all(updates)];
|
|
663
|
-
case 1:
|
|
664
|
-
_a.sent();
|
|
665
|
-
return [2 /*return*/];
|
|
666
|
-
}
|
|
667
|
-
});
|
|
417
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
418
|
+
const updates = [
|
|
419
|
+
FileOperationHelper.updateJsonFile(node_path_1.default.join(updateConfig.destDir, APP_JSON), (data) => (Object.assign(Object.assign({}, data), { name: updateConfig.projectName, displayName: updateConfig.projectName })), `Failed to update ${APP_JSON}.`),
|
|
420
|
+
FileOperationHelper.updateJsonFile(node_path_1.default.join(updateConfig.destDir, PACKAGE_JSON), (data) => {
|
|
421
|
+
if (!updateConfig.isHarmonyTemplate) {
|
|
422
|
+
data.dependencies = Object.assign(Object.assign({}, data.dependencies), { [REACT_NATIVE_OH_REACT_NATIVE_HARMONY]: updateConfig.rnohVersion });
|
|
423
|
+
data.devDependencies = Object.assign(Object.assign({}, data.devDependencies), { [REACT_NATIVE_OH_REACT_NATIVE_HARMONY_CLI]: updateConfig.rnohCliVersion });
|
|
424
|
+
}
|
|
425
|
+
return Object.assign(Object.assign({}, data), { name: updateConfig.packageName });
|
|
426
|
+
}, `Failed to update ${PACKAGE_JSON}.`),
|
|
427
|
+
];
|
|
428
|
+
yield Promise.all(updates);
|
|
668
429
|
});
|
|
669
430
|
}
|
|
670
431
|
function renameDotFiles(destDir) {
|
|
671
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
};
|
|
691
|
-
renameOperations = Object.entries(dotMap).map(function (_a) { return __awaiter(_this, [_a], void 0, function (_b) {
|
|
692
|
-
var srcPath;
|
|
693
|
-
var src = _b[0], dest = _b[1];
|
|
694
|
-
return __generator(this, function (_c) {
|
|
695
|
-
switch (_c.label) {
|
|
696
|
-
case 0:
|
|
697
|
-
srcPath = node_path_1.default.join(destDir, src);
|
|
698
|
-
return [4 /*yield*/, fs_extra_1.default.pathExists(srcPath)];
|
|
699
|
-
case 1:
|
|
700
|
-
if (!_c.sent()) return [3 /*break*/, 3];
|
|
701
|
-
return [4 /*yield*/, fs_extra_1.default.move(srcPath, node_path_1.default.join(destDir, dest), { overwrite: true })];
|
|
702
|
-
case 2:
|
|
703
|
-
_c.sent();
|
|
704
|
-
_c.label = 3;
|
|
705
|
-
case 3: return [2 /*return*/];
|
|
706
|
-
}
|
|
707
|
-
});
|
|
708
|
-
}); });
|
|
709
|
-
return [4 /*yield*/, Promise.all(renameOperations)];
|
|
710
|
-
case 1:
|
|
711
|
-
_a.sent();
|
|
712
|
-
return [2 /*return*/];
|
|
432
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
433
|
+
const dotMap = {
|
|
434
|
+
'_bundle': '.bundle',
|
|
435
|
+
'_eslintrc.js': '.eslintrc.js',
|
|
436
|
+
'_gitignore': '.gitignore',
|
|
437
|
+
'_prettierrc.js': '.prettierrc.js',
|
|
438
|
+
'_watchmanconfig': '.watchmanconfig',
|
|
439
|
+
'_buckconfig': '.buckconfig',
|
|
440
|
+
'_flowconfig': '.flowconfig',
|
|
441
|
+
'_gitattributes': '.gitattributes',
|
|
442
|
+
'_editorconfig': '.editorconfig',
|
|
443
|
+
'_ruby-version': '.ruby-version',
|
|
444
|
+
'_node-version': '.node-version',
|
|
445
|
+
'_xcode.env': '.xcode.env',
|
|
446
|
+
};
|
|
447
|
+
const renameOperations = Object.entries(dotMap).map((_a) => __awaiter(this, [_a], void 0, function* ([src, dest]) {
|
|
448
|
+
const srcPath = node_path_1.default.join(destDir, src);
|
|
449
|
+
if (yield fs_extra_1.default.pathExists(srcPath)) {
|
|
450
|
+
yield fs_extra_1.default.move(srcPath, node_path_1.default.join(destDir, dest), { overwrite: true });
|
|
713
451
|
}
|
|
714
|
-
});
|
|
452
|
+
}));
|
|
453
|
+
yield Promise.all(renameOperations);
|
|
715
454
|
});
|
|
716
455
|
}
|
|
717
456
|
function runPostInitScript(scriptPath, templateRoot, cwd, isHarmonyTemplate) {
|
|
718
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
whatCanUserDo: ["Check postInitScript path in ".concat(TEMPLATE_CONFIG_JS, ".")],
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
if (!!isHarmonyTemplate) return [3 /*break*/, 6];
|
|
733
|
-
_a.label = 2;
|
|
734
|
-
case 2:
|
|
735
|
-
_a.trys.push([2, 4, , 5]);
|
|
736
|
-
return [4 /*yield*/, runCliCommand(NODE_EXE, [absScriptPath], cwd)];
|
|
737
|
-
case 3:
|
|
738
|
-
_a.sent();
|
|
739
|
-
return [3 /*break*/, 5];
|
|
740
|
-
case 4:
|
|
741
|
-
err_7 = _a.sent();
|
|
742
|
-
cli_tools_1.logger.error("Failed to execute postInitScript in RN community template, please execute manually.");
|
|
743
|
-
return [3 /*break*/, 5];
|
|
744
|
-
case 5: return [3 /*break*/, 8];
|
|
745
|
-
case 6: return [4 /*yield*/, runCliCommand(NODE_EXE, [absScriptPath], cwd)];
|
|
746
|
-
case 7:
|
|
747
|
-
_a.sent();
|
|
748
|
-
_a.label = 8;
|
|
749
|
-
case 8: return [2 /*return*/];
|
|
457
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
458
|
+
const absScriptPath = node_path_1.default.join(templateRoot, scriptPath);
|
|
459
|
+
if (!(yield fs_extra_1.default.pathExists(absScriptPath))) {
|
|
460
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
461
|
+
whatHappened: 'postInitScript not found.',
|
|
462
|
+
whatCanUserDo: [`Check postInitScript path in ${TEMPLATE_CONFIG_JS}.`],
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
if (!isHarmonyTemplate) {
|
|
466
|
+
try {
|
|
467
|
+
yield runCliCommand(NODE_EXE, [absScriptPath], cwd);
|
|
750
468
|
}
|
|
751
|
-
|
|
469
|
+
catch (err) {
|
|
470
|
+
cli_tools_1.logger.error(`Failed to execute postInitScript in RN community template, please execute manually.`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
yield runCliCommand(NODE_EXE, [absScriptPath], cwd);
|
|
475
|
+
}
|
|
752
476
|
});
|
|
753
477
|
}
|
|
754
478
|
function runCliCommand(cmd_1, args_1, cwd_1) {
|
|
755
|
-
return __awaiter(this, arguments, void 0, function (cmd, args, cwd, silent, stdOutFunc) {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
case 2:
|
|
773
|
-
_a.sent();
|
|
774
|
-
return [3 /*break*/, 4];
|
|
775
|
-
case 3:
|
|
776
|
-
err_8 = _a.sent();
|
|
777
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
778
|
-
whatHappened: "Failed to run command: ".concat(cmd, " ").concat(args.join(' ')),
|
|
779
|
-
extraData: err_8,
|
|
780
|
-
});
|
|
781
|
-
case 4: return [2 /*return*/];
|
|
782
|
-
}
|
|
783
|
-
});
|
|
479
|
+
return __awaiter(this, arguments, void 0, function* (cmd, args, cwd, silent = true, stdOutFunc) {
|
|
480
|
+
const cli = new CliExecutor_1.RealCliExecutor();
|
|
481
|
+
try {
|
|
482
|
+
yield cli.run(cmd, {
|
|
483
|
+
args,
|
|
484
|
+
cwd: new AbsolutePath_1.AbsolutePath(cwd),
|
|
485
|
+
shell: true,
|
|
486
|
+
onStdout: silent ? undefined : stdOutFunc ? (data) => stdOutFunc(data) : (data) => cli_tools_1.logger.info(data),
|
|
487
|
+
onStderr: silent ? undefined : (data) => cli_tools_1.logger.error(data),
|
|
488
|
+
});
|
|
489
|
+
}
|
|
490
|
+
catch (err) {
|
|
491
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
492
|
+
whatHappened: `Failed to run command: ${cmd} ${args.join(' ')}`,
|
|
493
|
+
extraData: err,
|
|
494
|
+
});
|
|
495
|
+
}
|
|
784
496
|
});
|
|
785
497
|
}
|
|
786
498
|
function initGitRepo(destDir) {
|
|
787
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
return [4 /*yield*/, runCliCommand(GIT_EXE, ['init'], destDir)];
|
|
803
|
-
case 3:
|
|
804
|
-
_a.sent();
|
|
805
|
-
return [4 /*yield*/, runCliCommand(GIT_EXE, ['add', '.'], destDir)];
|
|
806
|
-
case 4:
|
|
807
|
-
_a.sent();
|
|
808
|
-
return [4 /*yield*/, runCliCommand(GIT_EXE, ['commit', '-m', "\"Initial RNOH by ".concat(REACT_NATIVE_OH_REACT_NATIVE_HARMONY_CLI, "\"")], destDir)];
|
|
809
|
-
case 5:
|
|
810
|
-
_a.sent();
|
|
811
|
-
return [3 /*break*/, 10];
|
|
812
|
-
case 6:
|
|
813
|
-
error_2 = _a.sent();
|
|
814
|
-
cli_tools_1.logger.warn('Failed to initialize git repository. You can initialize it manually later.');
|
|
815
|
-
return [4 /*yield*/, fs_extra_1.default.pathExists(gitDir)];
|
|
816
|
-
case 7:
|
|
817
|
-
if (!_a.sent()) return [3 /*break*/, 9];
|
|
818
|
-
return [4 /*yield*/, fs_extra_1.default.remove(gitDir)];
|
|
819
|
-
case 8:
|
|
820
|
-
_a.sent();
|
|
821
|
-
_a.label = 9;
|
|
822
|
-
case 9: return [2 /*return*/, false];
|
|
823
|
-
case 10: return [2 /*return*/, true];
|
|
499
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
500
|
+
const gitDir = node_path_1.default.join(destDir, '.git');
|
|
501
|
+
if (yield fs_extra_1.default.pathExists(gitDir)) {
|
|
502
|
+
cli_tools_1.logger.warn('Git repository already exists, skipping git init.');
|
|
503
|
+
return false;
|
|
504
|
+
}
|
|
505
|
+
try {
|
|
506
|
+
yield runCliCommand(GIT_EXE, ['init'], destDir);
|
|
507
|
+
yield runCliCommand(GIT_EXE, ['add', '.'], destDir);
|
|
508
|
+
yield runCliCommand(GIT_EXE, ['commit', '-m', `"Initial RNOH by ${REACT_NATIVE_OH_REACT_NATIVE_HARMONY_CLI}"`], destDir);
|
|
509
|
+
}
|
|
510
|
+
catch (error) {
|
|
511
|
+
cli_tools_1.logger.warn('Failed to initialize git repository. You can initialize it manually later.');
|
|
512
|
+
if (yield fs_extra_1.default.pathExists(gitDir)) {
|
|
513
|
+
yield fs_extra_1.default.remove(gitDir);
|
|
824
514
|
}
|
|
825
|
-
|
|
515
|
+
return false;
|
|
516
|
+
}
|
|
517
|
+
return true;
|
|
826
518
|
});
|
|
827
519
|
}
|
|
828
520
|
function handleError(err) {
|
|
829
521
|
if (err instanceof DescriptiveError_1.DescriptiveError) {
|
|
830
522
|
cli_tools_1.logger.error(chalk_1.default.red(err.getMessage()));
|
|
831
|
-
for (
|
|
832
|
-
var suggestion = _a[_i];
|
|
523
|
+
for (const suggestion of err.getSuggestions()) {
|
|
833
524
|
cli_tools_1.logger.info(chalk_1.default.yellow('Tip: ' + suggestion));
|
|
834
525
|
}
|
|
835
526
|
if (err.getDetails()) {
|
|
@@ -837,291 +528,176 @@ function handleError(err) {
|
|
|
837
528
|
}
|
|
838
529
|
}
|
|
839
530
|
else {
|
|
840
|
-
|
|
531
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
841
532
|
cli_tools_1.logger.error(chalk_1.default.red('Unexpected error: ' + message));
|
|
842
533
|
}
|
|
843
534
|
}
|
|
844
535
|
function cleanupOnError(destDir) {
|
|
845
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
case 1:
|
|
850
|
-
if (!_a.sent()) return [3 /*break*/, 3];
|
|
851
|
-
return [4 /*yield*/, fs_extra_1.default.remove(destDir)];
|
|
852
|
-
case 2:
|
|
853
|
-
_a.sent();
|
|
854
|
-
_a.label = 3;
|
|
855
|
-
case 3: return [2 /*return*/];
|
|
856
|
-
}
|
|
857
|
-
});
|
|
536
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
537
|
+
if (yield fs_extra_1.default.pathExists(destDir)) {
|
|
538
|
+
yield fs_extra_1.default.remove(destDir);
|
|
539
|
+
}
|
|
858
540
|
});
|
|
859
541
|
}
|
|
860
542
|
function cleanupTempDir(tempDir) {
|
|
861
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
case 1:
|
|
869
|
-
_a.sent();
|
|
870
|
-
return [3 /*break*/, 3];
|
|
871
|
-
case 2:
|
|
872
|
-
cleanupError_1 = _a.sent();
|
|
873
|
-
cli_tools_1.logger.warn('Failed to clean up temporary directory:', tempDir);
|
|
874
|
-
return [3 /*break*/, 3];
|
|
875
|
-
case 3: return [2 /*return*/];
|
|
876
|
-
}
|
|
877
|
-
});
|
|
543
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
544
|
+
try {
|
|
545
|
+
yield fs_extra_1.default.remove(tempDir);
|
|
546
|
+
}
|
|
547
|
+
catch (cleanupError) {
|
|
548
|
+
cli_tools_1.logger.warn('Failed to clean up temporary directory:', tempDir);
|
|
549
|
+
}
|
|
878
550
|
});
|
|
879
551
|
}
|
|
880
552
|
function getRNOHVersion(rnVersion) {
|
|
881
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
majorMinorVersion = "".concat(versionParts[0], ".").concat(versionParts[1]);
|
|
888
|
-
versionInfos = "";
|
|
889
|
-
return [4 /*yield*/, runCliCommand(NPM_EXE, ['view', DEFAULT_TEMPLATE_PKG, 'versions', '--json'], process.cwd(), false, function (data) {
|
|
890
|
-
versionInfos += data.toString();
|
|
891
|
-
})];
|
|
892
|
-
case 1:
|
|
893
|
-
_a.sent();
|
|
894
|
-
versions = JSON.parse(versionInfos);
|
|
895
|
-
matchingVersions = versions.filter(function (v) { return v.startsWith(majorMinorVersion); });
|
|
896
|
-
if (matchingVersions.length === 0) {
|
|
897
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
898
|
-
whatHappened: "No matching versions found for ".concat(DEFAULT_TEMPLATE_PKG, " with major version ").concat(majorMinorVersion, "."),
|
|
899
|
-
whatCanUserDo: ['Please check the available versions of the template package.'],
|
|
900
|
-
});
|
|
901
|
-
}
|
|
902
|
-
return [2 /*return*/, matchingVersions.pop()];
|
|
903
|
-
}
|
|
553
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
554
|
+
const versionParts = rnVersion.split('.');
|
|
555
|
+
const majorMinorVersion = `${versionParts[0]}.${versionParts[1]}`;
|
|
556
|
+
let versionInfos = "";
|
|
557
|
+
yield runCliCommand(NPM_EXE, ['view', DEFAULT_TEMPLATE_PKG, 'versions', '--json'], process.cwd(), false, (data) => {
|
|
558
|
+
versionInfos += data.toString();
|
|
904
559
|
});
|
|
560
|
+
const versions = JSON.parse(versionInfos);
|
|
561
|
+
const matchingVersions = versions.filter((v) => v.startsWith(majorMinorVersion));
|
|
562
|
+
if (matchingVersions.length === 0) {
|
|
563
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
564
|
+
whatHappened: `No matching versions found for ${DEFAULT_TEMPLATE_PKG} with major version ${majorMinorVersion}.`,
|
|
565
|
+
whatCanUserDo: ['Please check the available versions of the template package.'],
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
return matchingVersions.pop();
|
|
905
569
|
});
|
|
906
570
|
}
|
|
907
571
|
function handleMissingHarmonyDir(destDir, rnVersion) {
|
|
908
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
909
|
-
var
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
_e.trys.push([3, 19, 20, 22]);
|
|
922
|
-
return [4 /*yield*/, npmInitAndInstall(defaultTempDir, "".concat(DEFAULT_TEMPLATE_PKG, "@").concat(lastestVersion))];
|
|
923
|
-
case 4:
|
|
924
|
-
_e.sent();
|
|
925
|
-
return [4 /*yield*/, getTemplateConfigFromPkg(defaultTempDir)];
|
|
926
|
-
case 5:
|
|
927
|
-
defaultTemplateConfig = _e.sent();
|
|
928
|
-
sourceHarmonyDir = node_path_1.default.join(defaultTemplateConfig.templateRoot, defaultTemplateConfig.templateConfig.templateDir, HARMONY_DIR);
|
|
929
|
-
targetHarmonyDir = node_path_1.default.join(destDir, HARMONY_DIR);
|
|
930
|
-
return [4 /*yield*/, fs_extra_1.default.pathExists(sourceHarmonyDir)];
|
|
931
|
-
case 6:
|
|
932
|
-
if (!(_e.sent())) {
|
|
933
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
934
|
-
whatHappened: "Default template does not contain harmony directory at ".concat(sourceHarmonyDir),
|
|
935
|
-
whatCanUserDo: ['Please use a template that contains harmony directory.', 'Check if the default template package is correct.'],
|
|
936
|
-
});
|
|
937
|
-
}
|
|
938
|
-
return [4 /*yield*/, fs_extra_1.default.copy(sourceHarmonyDir, targetHarmonyDir)];
|
|
939
|
-
case 7:
|
|
940
|
-
_e.sent();
|
|
941
|
-
sourceMetroConfigPath = node_path_1.default.join(defaultTemplateConfig.templateRoot, defaultTemplateConfig.templateConfig.templateDir, METRO_CONFIG_JS);
|
|
942
|
-
targetMetroConfigPath = node_path_1.default.join(destDir, METRO_CONFIG_JS);
|
|
943
|
-
return [4 /*yield*/, fs_extra_1.default.pathExists(sourceMetroConfigPath)];
|
|
944
|
-
case 8:
|
|
945
|
-
if (!_e.sent()) return [3 /*break*/, 10];
|
|
946
|
-
return [4 /*yield*/, fs_extra_1.default.copyFile(sourceMetroConfigPath, targetMetroConfigPath)];
|
|
947
|
-
case 9:
|
|
948
|
-
_e.sent();
|
|
949
|
-
return [3 /*break*/, 11];
|
|
950
|
-
case 10: throw new DescriptiveError_1.DescriptiveError({
|
|
951
|
-
whatHappened: "Default template does not contain ".concat(METRO_CONFIG_JS, " at ").concat(sourceMetroConfigPath),
|
|
952
|
-
whatCanUserDo: ["Please use a template that contains ".concat(METRO_CONFIG_JS, "."), 'Check if the default template package is correct.'],
|
|
572
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
573
|
+
var _a, _b;
|
|
574
|
+
const lastestVersion = yield getRNOHVersion(rnVersion);
|
|
575
|
+
const defaultTempDir = yield createTempDir();
|
|
576
|
+
try {
|
|
577
|
+
yield npmInitAndInstall(defaultTempDir, `${DEFAULT_TEMPLATE_PKG}@${lastestVersion}`);
|
|
578
|
+
const defaultTemplateConfig = yield getTemplateConfigFromPkg(defaultTempDir);
|
|
579
|
+
const sourceHarmonyDir = node_path_1.default.join(defaultTemplateConfig.templateRoot, defaultTemplateConfig.templateConfig.templateDir, HARMONY_DIR);
|
|
580
|
+
const targetHarmonyDir = node_path_1.default.join(destDir, HARMONY_DIR);
|
|
581
|
+
if (!(yield fs_extra_1.default.pathExists(sourceHarmonyDir))) {
|
|
582
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
583
|
+
whatHappened: `Default template does not contain harmony directory at ${sourceHarmonyDir}`,
|
|
584
|
+
whatCanUserDo: ['Please use a template that contains harmony directory.', 'Check if the default template package is correct.'],
|
|
953
585
|
});
|
|
954
|
-
case 11:
|
|
955
|
-
pkgJsonPath = node_path_1.default.join(defaultTemplateConfig.templateRoot, defaultTemplateConfig.templateConfig.templateDir, PACKAGE_JSON);
|
|
956
|
-
_b = (_a = JSON).parse;
|
|
957
|
-
return [4 /*yield*/, fs_extra_1.default.readFile(pkgJsonPath, DEFAULT_ENCODING)];
|
|
958
|
-
case 12:
|
|
959
|
-
pkgContent = _b.apply(_a, [_e.sent()]);
|
|
960
|
-
rnohVersion = (_c = pkgContent.dependencies) === null || _c === void 0 ? void 0 : _c[REACT_NATIVE_OH_REACT_NATIVE_HARMONY];
|
|
961
|
-
rnohCliVersion = (_d = pkgContent.devDependencies) === null || _d === void 0 ? void 0 : _d[REACT_NATIVE_OH_REACT_NATIVE_HARMONY_CLI];
|
|
962
|
-
androidDir = node_path_1.default.join(destDir, 'android');
|
|
963
|
-
iosDir = node_path_1.default.join(destDir, 'ios');
|
|
964
|
-
return [4 /*yield*/, fs_extra_1.default.pathExists(androidDir)];
|
|
965
|
-
case 13:
|
|
966
|
-
if (!_e.sent()) return [3 /*break*/, 15];
|
|
967
|
-
return [4 /*yield*/, fs_extra_1.default.remove(androidDir)];
|
|
968
|
-
case 14:
|
|
969
|
-
_e.sent();
|
|
970
|
-
_e.label = 15;
|
|
971
|
-
case 15: return [4 /*yield*/, fs_extra_1.default.pathExists(iosDir)];
|
|
972
|
-
case 16:
|
|
973
|
-
if (!_e.sent()) return [3 /*break*/, 18];
|
|
974
|
-
return [4 /*yield*/, fs_extra_1.default.remove(iosDir)];
|
|
975
|
-
case 17:
|
|
976
|
-
_e.sent();
|
|
977
|
-
_e.label = 18;
|
|
978
|
-
case 18: return [2 /*return*/, { rnohTemplateConfig: defaultTemplateConfig.templateConfig, rnohVersion: rnohVersion, rnohCliVersion: rnohCliVersion }];
|
|
979
|
-
case 19:
|
|
980
|
-
error_3 = _e.sent();
|
|
981
|
-
if (error_3 instanceof DescriptiveError_1.DescriptiveError) {
|
|
982
|
-
throw error_3;
|
|
983
|
-
}
|
|
984
|
-
throw new DescriptiveError_1.DescriptiveError({
|
|
985
|
-
whatHappened: 'Failed to handle missing harmony directory from default template.',
|
|
986
|
-
whatCanUserDo: [
|
|
987
|
-
'Check your internet connection.',
|
|
988
|
-
'Ensure you have write permissions for the destination directory.',
|
|
989
|
-
'Verify that the default template package exists and is accessible.',
|
|
990
|
-
],
|
|
991
|
-
extraData: error_3,
|
|
992
|
-
});
|
|
993
|
-
case 20: return [4 /*yield*/, cleanupTempDir(defaultTempDir)];
|
|
994
|
-
case 21:
|
|
995
|
-
_e.sent();
|
|
996
|
-
return [7 /*endfinally*/];
|
|
997
|
-
case 22: return [2 /*return*/];
|
|
998
586
|
}
|
|
999
|
-
|
|
587
|
+
yield fs_extra_1.default.copy(sourceHarmonyDir, targetHarmonyDir);
|
|
588
|
+
const sourceMetroConfigPath = node_path_1.default.join(defaultTemplateConfig.templateRoot, defaultTemplateConfig.templateConfig.templateDir, METRO_CONFIG_JS);
|
|
589
|
+
const targetMetroConfigPath = node_path_1.default.join(destDir, METRO_CONFIG_JS);
|
|
590
|
+
if (yield fs_extra_1.default.pathExists(sourceMetroConfigPath)) {
|
|
591
|
+
yield fs_extra_1.default.copyFile(sourceMetroConfigPath, targetMetroConfigPath);
|
|
592
|
+
}
|
|
593
|
+
else {
|
|
594
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
595
|
+
whatHappened: `Default template does not contain ${METRO_CONFIG_JS} at ${sourceMetroConfigPath}`,
|
|
596
|
+
whatCanUserDo: [`Please use a template that contains ${METRO_CONFIG_JS}.`, 'Check if the default template package is correct.'],
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
const pkgJsonPath = node_path_1.default.join(defaultTemplateConfig.templateRoot, defaultTemplateConfig.templateConfig.templateDir, PACKAGE_JSON);
|
|
600
|
+
const pkgContent = JSON.parse(yield fs_extra_1.default.readFile(pkgJsonPath, DEFAULT_ENCODING));
|
|
601
|
+
const rnohVersion = (_a = pkgContent.dependencies) === null || _a === void 0 ? void 0 : _a[REACT_NATIVE_OH_REACT_NATIVE_HARMONY];
|
|
602
|
+
const rnohCliVersion = (_b = pkgContent.devDependencies) === null || _b === void 0 ? void 0 : _b[REACT_NATIVE_OH_REACT_NATIVE_HARMONY_CLI];
|
|
603
|
+
const androidDir = node_path_1.default.join(destDir, 'android');
|
|
604
|
+
const iosDir = node_path_1.default.join(destDir, 'ios');
|
|
605
|
+
if (yield fs_extra_1.default.pathExists(androidDir)) {
|
|
606
|
+
yield fs_extra_1.default.remove(androidDir);
|
|
607
|
+
}
|
|
608
|
+
if (yield fs_extra_1.default.pathExists(iosDir)) {
|
|
609
|
+
yield fs_extra_1.default.remove(iosDir);
|
|
610
|
+
}
|
|
611
|
+
return { rnohTemplateConfig: defaultTemplateConfig.templateConfig, rnohVersion, rnohCliVersion };
|
|
612
|
+
}
|
|
613
|
+
catch (error) {
|
|
614
|
+
if (error instanceof DescriptiveError_1.DescriptiveError) {
|
|
615
|
+
throw error;
|
|
616
|
+
}
|
|
617
|
+
throw new DescriptiveError_1.DescriptiveError({
|
|
618
|
+
whatHappened: 'Failed to handle missing harmony directory from default template.',
|
|
619
|
+
whatCanUserDo: [
|
|
620
|
+
'Check your internet connection.',
|
|
621
|
+
'Ensure you have write permissions for the destination directory.',
|
|
622
|
+
'Verify that the default template package exists and is accessible.',
|
|
623
|
+
],
|
|
624
|
+
extraData: error,
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
finally {
|
|
628
|
+
yield cleanupTempDir(defaultTempDir);
|
|
629
|
+
}
|
|
1000
630
|
});
|
|
1001
631
|
}
|
|
1002
632
|
function updateHarmonyFiles(updateConfig) {
|
|
1003
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
updateAppScopeAppJson5(appScopeDir, updateConfig.packageName),
|
|
1015
|
-
updateEntryStringJson(entryDir, updateConfig.projectName),
|
|
1016
|
-
];
|
|
1017
|
-
return [4 /*yield*/, Promise.all(updateOperations)];
|
|
1018
|
-
case 1:
|
|
1019
|
-
_a.sent();
|
|
1020
|
-
return [2 /*return*/];
|
|
1021
|
-
}
|
|
1022
|
-
});
|
|
633
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
634
|
+
const harmonyDir = node_path_1.default.join(updateConfig.destDir, HARMONY_DIR);
|
|
635
|
+
const appScopeDir = node_path_1.default.join(harmonyDir, 'AppScope');
|
|
636
|
+
const entryDir = node_path_1.default.join(harmonyDir, 'entry');
|
|
637
|
+
const updateOperations = [
|
|
638
|
+
updateAppScopeStringJson(appScopeDir, updateConfig.projectName),
|
|
639
|
+
updateEntryIndexEts(entryDir, updateConfig),
|
|
640
|
+
updateAppScopeAppJson5(appScopeDir, updateConfig.packageName),
|
|
641
|
+
updateEntryStringJson(entryDir, updateConfig.projectName),
|
|
642
|
+
];
|
|
643
|
+
yield Promise.all(updateOperations);
|
|
1023
644
|
});
|
|
1024
645
|
}
|
|
1025
646
|
function updateAppScopeStringJson(appScopeDir, projectName) {
|
|
1026
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
appScopeStringJson = node_path_1.default.join(appScopeDir, 'resources', 'base', 'element', STRING_JSON);
|
|
1032
|
-
return [4 /*yield*/, FileOperationHelper.updateJsonFile(appScopeStringJson, function (data) {
|
|
1033
|
-
if (Array.isArray(data.string) && data.string.length > 0) {
|
|
1034
|
-
data.string[PROJECT_NAME_INDEX].value = projectName;
|
|
1035
|
-
}
|
|
1036
|
-
return data;
|
|
1037
|
-
}, "Failed to update AppScope ".concat(STRING_JSON, "."))];
|
|
1038
|
-
case 1:
|
|
1039
|
-
_a.sent();
|
|
1040
|
-
return [2 /*return*/];
|
|
647
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
648
|
+
const appScopeStringJson = node_path_1.default.join(appScopeDir, 'resources', 'base', 'element', STRING_JSON);
|
|
649
|
+
yield FileOperationHelper.updateJsonFile(appScopeStringJson, (data) => {
|
|
650
|
+
if (Array.isArray(data.string) && data.string.length > 0) {
|
|
651
|
+
data.string[PROJECT_NAME_INDEX].value = projectName;
|
|
1041
652
|
}
|
|
1042
|
-
|
|
653
|
+
return data;
|
|
654
|
+
}, `Failed to update AppScope ${STRING_JSON}.`);
|
|
1043
655
|
});
|
|
1044
656
|
}
|
|
1045
657
|
function updateEntryIndexEts(entryDir, updateConfig) {
|
|
1046
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
if (!updateConfig.isHarmonyTemplate && updateConfig.rnohTemplateConfig) {
|
|
1054
|
-
replacedText = updateConfig.rnohTemplateConfig.placeholderName;
|
|
1055
|
-
}
|
|
1056
|
-
return [4 /*yield*/, FileOperationHelper.updateTextFile(entryIndexEts, replacedText, updateConfig.projectName)];
|
|
1057
|
-
case 1:
|
|
1058
|
-
_a.sent();
|
|
1059
|
-
return [2 /*return*/];
|
|
1060
|
-
}
|
|
1061
|
-
});
|
|
658
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
659
|
+
const entryIndexEts = node_path_1.default.join(entryDir, 'src', 'main', 'ets', 'pages', 'Index.ets');
|
|
660
|
+
let replacedText = updateConfig.templateConfig.placeholderName;
|
|
661
|
+
if (!updateConfig.isHarmonyTemplate && updateConfig.rnohTemplateConfig) {
|
|
662
|
+
replacedText = updateConfig.rnohTemplateConfig.placeholderName;
|
|
663
|
+
}
|
|
664
|
+
yield FileOperationHelper.updateTextFile(entryIndexEts, replacedText, updateConfig.projectName);
|
|
1062
665
|
});
|
|
1063
666
|
}
|
|
1064
667
|
function updateAppScopeAppJson5(appScopeDir, packageName) {
|
|
1065
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
switch (_a.label) {
|
|
1069
|
-
case 0:
|
|
1070
|
-
appScopeAppJson5 = node_path_1.default.join(appScopeDir, APP_JSON5);
|
|
1071
|
-
return [4 /*yield*/, FileOperationHelper.updateJsonFile(appScopeAppJson5, function (data) { return (__assign(__assign({}, data), { app: __assign(__assign({}, data.app), { bundleName: packageName }) })); }, "Failed to update AppScope ".concat(APP_JSON5, "."))];
|
|
1072
|
-
case 1:
|
|
1073
|
-
_a.sent();
|
|
1074
|
-
return [2 /*return*/];
|
|
1075
|
-
}
|
|
1076
|
-
});
|
|
668
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
669
|
+
const appScopeAppJson5 = node_path_1.default.join(appScopeDir, APP_JSON5);
|
|
670
|
+
yield FileOperationHelper.updateJsonFile(appScopeAppJson5, (data) => (Object.assign(Object.assign({}, data), { app: Object.assign(Object.assign({}, data.app), { bundleName: packageName }) })), `Failed to update AppScope ${APP_JSON5}.`);
|
|
1077
671
|
});
|
|
1078
672
|
}
|
|
1079
673
|
function updateEntryStringJson(entryDir, projectName) {
|
|
1080
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
if (item.name === ENTRY_ABILITY_LABEL) {
|
|
1093
|
-
item.value = projectName;
|
|
1094
|
-
}
|
|
1095
|
-
});
|
|
1096
|
-
}
|
|
1097
|
-
return data;
|
|
1098
|
-
}, "Failed to update entry ".concat(STRING_JSON, "."))];
|
|
1099
|
-
case 1:
|
|
1100
|
-
_a.sent();
|
|
1101
|
-
return [2 /*return*/];
|
|
674
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
675
|
+
const entryStringJson = node_path_1.default.join(entryDir, 'src', 'main', 'resources', 'base', 'element', STRING_JSON);
|
|
676
|
+
yield FileOperationHelper.updateJsonFile(entryStringJson, (data) => {
|
|
677
|
+
if (Array.isArray(data.string)) {
|
|
678
|
+
data.string.forEach((item) => {
|
|
679
|
+
if (item.name === MODULE_DESC || item.name === ENTRY_ABILITY_DESC) {
|
|
680
|
+
item.value = '';
|
|
681
|
+
}
|
|
682
|
+
if (item.name === ENTRY_ABILITY_LABEL) {
|
|
683
|
+
item.value = projectName;
|
|
684
|
+
}
|
|
685
|
+
});
|
|
1102
686
|
}
|
|
1103
|
-
|
|
687
|
+
return data;
|
|
688
|
+
}, `Failed to update entry ${STRING_JSON}.`);
|
|
1104
689
|
});
|
|
1105
690
|
}
|
|
1106
691
|
function processTemplate(updateConfig) {
|
|
1107
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
_a.sent();
|
|
1117
|
-
if (!updateConfig.templateConfig.postInitScript) return [3 /*break*/, 3];
|
|
1118
|
-
return [4 /*yield*/, runPostInitScript(updateConfig.templateConfig.postInitScript, updateConfig.templateRoot, updateConfig.destDir, updateConfig.isHarmonyTemplate)];
|
|
1119
|
-
case 2:
|
|
1120
|
-
_a.sent();
|
|
1121
|
-
_a.label = 3;
|
|
1122
|
-
case 3: return [2 /*return*/];
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
692
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
693
|
+
yield Promise.all([
|
|
694
|
+
updateRNConfigFiles(updateConfig),
|
|
695
|
+
updateHarmonyFiles(updateConfig),
|
|
696
|
+
renameDotFiles(updateConfig.destDir),
|
|
697
|
+
]);
|
|
698
|
+
if (updateConfig.templateConfig.postInitScript) {
|
|
699
|
+
yield runPostInitScript(updateConfig.templateConfig.postInitScript, updateConfig.templateRoot, updateConfig.destDir, updateConfig.isHarmonyTemplate);
|
|
700
|
+
}
|
|
1125
701
|
});
|
|
1126
702
|
}
|
|
1127
703
|
rnohInit();
|