@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,23 +8,50 @@ 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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
39
|
exports.commandInitHarmony = void 0;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
40
|
+
var io_1 = require("../io");
|
|
41
|
+
var templates_1 = require("../init/templates");
|
|
42
|
+
var core_1 = require("../core");
|
|
43
|
+
var fs_extra_1 = require("fs-extra");
|
|
44
|
+
var AppScopeStringVarTemplate_1 = require("../init/templates/AppScopeStringVarTemplate");
|
|
45
|
+
var AppScopeAppJSON5Template_1 = require("../init/templates/AppScopeAppJSON5Template");
|
|
46
|
+
var COMMAND_NAME = 'init-harmony';
|
|
47
|
+
var BUNDLE_NAME_PATTERN = /^[a-zA-Z][0-9a-zA-Z_.]+$/;
|
|
21
48
|
exports.commandInitHarmony = {
|
|
22
49
|
name: COMMAND_NAME,
|
|
23
50
|
description: 'Initializes a new RNOH project.',
|
|
24
51
|
options: [
|
|
25
52
|
{
|
|
26
53
|
name: '--bundle-name <string>',
|
|
27
|
-
description:
|
|
54
|
+
description: "Required. The native app bundle name. It must match ".concat(BUNDLE_NAME_PATTERN, " pattern and include three segments separated by a dot (.)."),
|
|
28
55
|
},
|
|
29
56
|
{
|
|
30
57
|
name: '--project-root-path [path]',
|
|
@@ -47,150 +74,167 @@ exports.commandInitHarmony = {
|
|
|
47
74
|
default: '@react-native-oh/react-native-harmony-cli',
|
|
48
75
|
},
|
|
49
76
|
],
|
|
50
|
-
func: (_argv, _config, rawArgs)
|
|
77
|
+
func: function (_argv, _config, rawArgs) { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
+
var fs, logger, projectRootPath, harmonyDirPath, rnohNpmPackageName, rnohNpmPackagePath, rnohCliNpmPackageName, rnohCliNpmPackagePath, rnohHvigorPluginPath, packageJSON, appName, bundleName, harmonyTemplateDirPath, metroConfigPath, metroConfigContent, dynamicTemplateContentByPath, buildProfileTemplateComment, buildProfilePath, buildProfileContent, contentLines, buildProfileTemplateContent, err_1;
|
|
51
79
|
var _a;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
-
|
|
80
|
+
return __generator(this, function (_b) {
|
|
81
|
+
switch (_b.label) {
|
|
82
|
+
case 0:
|
|
83
|
+
fs = new io_1.RealFS();
|
|
84
|
+
logger = new io_1.Logger();
|
|
85
|
+
_b.label = 1;
|
|
86
|
+
case 1:
|
|
87
|
+
_b.trys.push([1, 4, , 5]);
|
|
88
|
+
// input preparation and validation
|
|
89
|
+
if (!rawArgs.bundleName) {
|
|
90
|
+
throw new core_1.DescriptiveError({
|
|
91
|
+
whatHappened: "--bundle-name argument wasn't provided",
|
|
92
|
+
whatCanUserDo: ['Please provide --bundle-name argument'],
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
projectRootPath = new core_1.AbsolutePath(rawArgs.projectRootPath);
|
|
96
|
+
harmonyDirPath = projectRootPath.copyWithNewSegment('harmony');
|
|
97
|
+
if (fs.existsSync(harmonyDirPath)) {
|
|
98
|
+
throw new core_1.DescriptiveError({
|
|
99
|
+
whatHappened: 'The "harmony" directory is already initialized',
|
|
100
|
+
whatCanUserDo: ["Remove the 'harmony' directory."],
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
rnohNpmPackageName = rawArgs.rnohNpmPackageName;
|
|
104
|
+
rnohNpmPackagePath = projectRootPath.copyWithNewSegment('node_modules', rnohNpmPackageName);
|
|
105
|
+
if (!fs.existsSync(rnohNpmPackagePath)) {
|
|
106
|
+
throw new core_1.DescriptiveError({
|
|
107
|
+
whatHappened: "".concat(rnohNpmPackagePath
|
|
108
|
+
.relativeTo(projectRootPath)
|
|
109
|
+
.toString(), " does not exist. This command requires that 'react-native-harmony' NPM package is already installed."),
|
|
110
|
+
whatCanUserDo: [
|
|
111
|
+
'Install react-native-harmony and try again.',
|
|
112
|
+
'Provide --rnoh-npm-package-name if the default value is incorrect.',
|
|
113
|
+
],
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
rnohCliNpmPackageName = rawArgs.rnohCliNpmPackageName;
|
|
117
|
+
rnohCliNpmPackagePath = projectRootPath.copyWithNewSegment('node_modules', rnohCliNpmPackageName);
|
|
118
|
+
if (!fs.existsSync(rnohCliNpmPackagePath)) {
|
|
119
|
+
throw new core_1.DescriptiveError({
|
|
120
|
+
whatHappened: "".concat(rnohCliNpmPackagePath
|
|
121
|
+
.relativeTo(projectRootPath)
|
|
122
|
+
.toString(), " does not exist. This command requires that 'react-native-cli-harmony' NPM package is already installed."),
|
|
123
|
+
whatCanUserDo: [
|
|
124
|
+
'Install react-native-harmony-cli and try again.',
|
|
125
|
+
'Provide --rnoh-cli-npm-package-name if the default value is incorrect.',
|
|
126
|
+
],
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
rnohHvigorPluginPath = findRNOHHvigorPluginPath(fs, rnohCliNpmPackagePath.copyWithNewSegment('harmony'));
|
|
130
|
+
if (rnohHvigorPluginPath === null) {
|
|
131
|
+
throw new core_1.DescriptiveError({
|
|
132
|
+
whatHappened: "Couldn't find RNOH hvigor plugin in ".concat(rnohHvigorPluginPath, ". This CLI package seems to be incompatible with RNOH."),
|
|
133
|
+
whatCanUserDo: ['Try using different RNOH or CLI version.'],
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
packageJSON = core_1.PackageJSON.fromProjectRootPath(fs, projectRootPath, projectRootPath);
|
|
137
|
+
appName = (_a = rawArgs.appName) !== null && _a !== void 0 ? _a : packageJSON.name;
|
|
138
|
+
bundleName = rawArgs.bundleName;
|
|
139
|
+
if (!isBundleNameValid(bundleName)) {
|
|
140
|
+
throw new core_1.DescriptiveError({
|
|
141
|
+
whatHappened: 'Bundle name validation failed',
|
|
142
|
+
whatCanUserDo: [
|
|
143
|
+
"Provide a different project name or provide a bundle name explicitly. Bundle name should have three parts separated by dot e.g. com.org.project and it should match the following regex pattern: ".concat(BUNDLE_NAME_PATTERN),
|
|
144
|
+
],
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
harmonyTemplateDirPath = new core_1.AbsolutePath(__dirname).copyWithNewSegment('..', 'init', 'templates', 'harmony');
|
|
148
|
+
return [4 /*yield*/, (0, fs_extra_1.ensureDir)(harmonyDirPath.toString())];
|
|
149
|
+
case 2:
|
|
150
|
+
_b.sent();
|
|
151
|
+
metroConfigPath = projectRootPath.copyWithNewSegment('metro.config.js');
|
|
152
|
+
metroConfigContent = new templates_1.MetroConfigTemplate(rnohNpmPackageName).build();
|
|
153
|
+
dynamicTemplateContentByPath = new Map([
|
|
154
|
+
[
|
|
155
|
+
harmonyDirPath.copyWithNewSegment('oh-package.json5'),
|
|
156
|
+
new templates_1.OhPackageJson5Template(rnohNpmPackageName).build(),
|
|
157
|
+
],
|
|
158
|
+
[
|
|
159
|
+
harmonyDirPath.copyWithNewSegment('hvigor', 'hvigor-config.json5'),
|
|
160
|
+
new templates_1.HvigorConfigJson5Template(rnohCliNpmPackageName, rnohHvigorPluginPath.getBasename()).build(),
|
|
161
|
+
],
|
|
162
|
+
[
|
|
163
|
+
harmonyDirPath.copyWithNewSegment('entry', 'src', 'main', 'resources', 'base', 'element', 'string.json'),
|
|
164
|
+
new templates_1.EntryStringVarTemplate(appName, '').build(),
|
|
165
|
+
],
|
|
166
|
+
[
|
|
167
|
+
harmonyDirPath.copyWithNewSegment('entry', 'src', 'main', 'ets', 'pages', 'Index.ets'),
|
|
168
|
+
new templates_1.EntryIndexTemplate(appName).build(),
|
|
169
|
+
],
|
|
170
|
+
[
|
|
171
|
+
harmonyDirPath.copyWithNewSegment('AppScope', 'resources', 'base', 'element', 'string.json'),
|
|
172
|
+
new AppScopeStringVarTemplate_1.AppScopeStringVarTemplate(appName).build(),
|
|
173
|
+
],
|
|
174
|
+
[
|
|
175
|
+
harmonyDirPath.copyWithNewSegment('AppScope', 'app.json5'),
|
|
176
|
+
new AppScopeAppJSON5Template_1.AppScopeAppJSON5Template(bundleName).build(),
|
|
177
|
+
],
|
|
178
|
+
]);
|
|
179
|
+
// output
|
|
180
|
+
if (fs.existsSync(metroConfigPath)) {
|
|
181
|
+
if (fs.existsSync(projectRootPath.copyWithNewSegment('.git'))) {
|
|
182
|
+
logger.warn(function (s) { return "Overwritten \"".concat(s.bold('./metro.config.js'), "\""); });
|
|
183
|
+
fs.writeTextSync(metroConfigPath, metroConfigContent);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
logger.warn(function (s) {
|
|
187
|
+
return "Skipped overriding \"".concat(s.bold('./metro.config.js'), "\" due to lack of .git. Override \"").concat(s.bold('./metro.config.js'), "\" manually.");
|
|
188
|
+
});
|
|
189
|
+
console.log(metroConfigContent);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else {
|
|
193
|
+
fs.writeTextSync(metroConfigPath, metroConfigContent);
|
|
194
|
+
}
|
|
195
|
+
return [4 /*yield*/, (0, fs_extra_1.copy)(harmonyTemplateDirPath.toString(), harmonyDirPath.toString())];
|
|
196
|
+
case 3:
|
|
197
|
+
_b.sent();
|
|
198
|
+
renameGitignoreFiles(fs, harmonyDirPath);
|
|
199
|
+
logger.succeed(function (s) { return "Created \"".concat(s.bold('./harmony'), "\" directory"); });
|
|
200
|
+
dynamicTemplateContentByPath.forEach(function (content, path) {
|
|
201
|
+
fs.writeTextSync(path, content);
|
|
202
|
+
});
|
|
203
|
+
buildProfileTemplateComment = "build-profile.json5 can contain signingConfigs which are unique for each developer, therefore that file is ignored by Git. Create a build-profile.json5 based on this template after cloning this repository to be able to open this project in DevEco Studio.";
|
|
204
|
+
buildProfilePath = harmonyDirPath.copyWithNewSegment('build-profile.json5');
|
|
205
|
+
buildProfileContent = fs.readTextSync(buildProfilePath);
|
|
206
|
+
contentLines = buildProfileContent.split('\n');
|
|
207
|
+
contentLines.splice(1, 0, " // " + buildProfileTemplateComment);
|
|
208
|
+
buildProfileTemplateContent = contentLines.join('\n');
|
|
209
|
+
fs.writeTextSync(harmonyDirPath.copyWithNewSegment('build-profile.template.json5'), buildProfileTemplateContent);
|
|
210
|
+
logger.info(function (s) {
|
|
211
|
+
return [
|
|
212
|
+
s.bold('Run on a physical device:'),
|
|
213
|
+
s.gray('1. Run `npm start` to start the Metro server.'),
|
|
214
|
+
s.gray('2. Open `./harmony` project in DevEco Studio and wait for background jobs to finish.'),
|
|
215
|
+
s.gray('3. Press the user icon in top right corner, and then press "Sign in" button.'),
|
|
216
|
+
s.gray('4. Connect the device.'),
|
|
217
|
+
s.gray('5. Go to File > Project Structure > Signing Configs and mark "Automatically generate signature", and then press OK.'),
|
|
218
|
+
s.gray("6. Select 'entry' run configuration (top right corner)."),
|
|
219
|
+
s.gray("7. Press the `Debug 'entry'` button (top right corner)."),
|
|
220
|
+
].join('\n');
|
|
221
|
+
});
|
|
222
|
+
return [3 /*break*/, 5];
|
|
223
|
+
case 4:
|
|
224
|
+
err_1 = _b.sent();
|
|
225
|
+
if (err_1 instanceof core_1.DescriptiveError && !err_1.isUnexpected()) {
|
|
226
|
+
logger.descriptiveError(err_1);
|
|
227
|
+
return [2 /*return*/];
|
|
228
|
+
}
|
|
229
|
+
throw err_1;
|
|
230
|
+
case 5: return [2 /*return*/];
|
|
102
231
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const bundleName = rawArgs.bundleName;
|
|
106
|
-
if (!isBundleNameValid(bundleName)) {
|
|
107
|
-
throw new core_1.DescriptiveError({
|
|
108
|
-
whatHappened: 'Bundle name validation failed',
|
|
109
|
-
whatCanUserDo: [
|
|
110
|
-
`Provide a different project name or provide a bundle name explicitly. Bundle name should have three parts separated by dot e.g. com.org.project and it should match the following regex pattern: ${BUNDLE_NAME_PATTERN}`,
|
|
111
|
-
],
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
const harmonyTemplateDirPath = new core_1.AbsolutePath(__dirname).copyWithNewSegment('..', 'init', 'templates', 'harmony');
|
|
115
|
-
yield (0, fs_extra_1.ensureDir)(harmonyDirPath.toString());
|
|
116
|
-
// processing
|
|
117
|
-
const metroConfigPath = projectRootPath.copyWithNewSegment('metro.config.js');
|
|
118
|
-
const metroConfigContent = new templates_1.MetroConfigTemplate(rnohNpmPackageName).build();
|
|
119
|
-
const dynamicTemplateContentByPath = new Map([
|
|
120
|
-
[
|
|
121
|
-
harmonyDirPath.copyWithNewSegment('oh-package.json5'),
|
|
122
|
-
new templates_1.OhPackageJson5Template(rnohNpmPackageName).build(),
|
|
123
|
-
],
|
|
124
|
-
[
|
|
125
|
-
harmonyDirPath.copyWithNewSegment('hvigor', 'hvigor-config.json5'),
|
|
126
|
-
new templates_1.HvigorConfigJson5Template(rnohCliNpmPackageName, rnohHvigorPluginPath.getBasename()).build(),
|
|
127
|
-
],
|
|
128
|
-
[
|
|
129
|
-
harmonyDirPath.copyWithNewSegment('entry', 'src', 'main', 'resources', 'base', 'element', 'string.json'),
|
|
130
|
-
new templates_1.EntryStringVarTemplate(appName, '').build(),
|
|
131
|
-
],
|
|
132
|
-
[
|
|
133
|
-
harmonyDirPath.copyWithNewSegment('entry', 'src', 'main', 'ets', 'pages', 'Index.ets'),
|
|
134
|
-
new templates_1.EntryIndexTemplate(appName).build(),
|
|
135
|
-
],
|
|
136
|
-
[
|
|
137
|
-
harmonyDirPath.copyWithNewSegment('AppScope', 'resources', 'base', 'element', 'string.json'),
|
|
138
|
-
new AppScopeStringVarTemplate_1.AppScopeStringVarTemplate(appName).build(),
|
|
139
|
-
],
|
|
140
|
-
[
|
|
141
|
-
harmonyDirPath.copyWithNewSegment('AppScope', 'app.json5'),
|
|
142
|
-
new AppScopeAppJSON5Template_1.AppScopeAppJSON5Template(bundleName).build(),
|
|
143
|
-
],
|
|
144
|
-
]);
|
|
145
|
-
// output
|
|
146
|
-
if (fs.existsSync(metroConfigPath)) {
|
|
147
|
-
if (fs.existsSync(projectRootPath.copyWithNewSegment('.git'))) {
|
|
148
|
-
logger.warn((s) => `Overwritten "${s.bold('./metro.config.js')}"`);
|
|
149
|
-
fs.writeTextSync(metroConfigPath, metroConfigContent);
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
logger.warn((s) => `Skipped overriding "${s.bold('./metro.config.js')}" due to lack of .git. Override "${s.bold('./metro.config.js')}" manually.`);
|
|
153
|
-
console.log(metroConfigContent);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
fs.writeTextSync(metroConfigPath, metroConfigContent);
|
|
158
|
-
}
|
|
159
|
-
yield (0, fs_extra_1.copy)(harmonyTemplateDirPath.toString(), harmonyDirPath.toString());
|
|
160
|
-
renameGitignoreFiles(fs, harmonyDirPath);
|
|
161
|
-
logger.succeed((s) => `Created "${s.bold('./harmony')}" directory`);
|
|
162
|
-
dynamicTemplateContentByPath.forEach((content, path) => {
|
|
163
|
-
fs.writeTextSync(path, content);
|
|
164
|
-
});
|
|
165
|
-
const buildProfileTemplateComment = "build-profile.json5 can contain signingConfigs which are unique for each developer, therefore that file is ignored by Git. Create a build-profile.json5 based on this template after cloning this repository to be able to open this project in DevEco Studio.";
|
|
166
|
-
const buildProfilePath = harmonyDirPath.copyWithNewSegment('build-profile.json5');
|
|
167
|
-
const buildProfileContent = fs.readTextSync(buildProfilePath);
|
|
168
|
-
const contentLines = buildProfileContent.split('\n');
|
|
169
|
-
contentLines.splice(1, 0, " // " + buildProfileTemplateComment);
|
|
170
|
-
const buildProfileTemplateContent = contentLines.join('\n');
|
|
171
|
-
fs.writeTextSync(harmonyDirPath.copyWithNewSegment('build-profile.template.json5'), buildProfileTemplateContent);
|
|
172
|
-
logger.info((s) => [
|
|
173
|
-
s.bold('Run on a physical device:'),
|
|
174
|
-
s.gray('1. Run `npm start` to start the Metro server.'),
|
|
175
|
-
s.gray('2. Open `./harmony` project in DevEco Studio and wait for background jobs to finish.'),
|
|
176
|
-
s.gray('3. Press the user icon in top right corner, and then press "Sign in" button.'),
|
|
177
|
-
s.gray('4. Connect the device.'),
|
|
178
|
-
s.gray('5. Go to File > Project Structure > Signing Configs and mark "Automatically generate signature", and then press OK.'),
|
|
179
|
-
s.gray("6. Select 'entry' run configuration (top right corner)."),
|
|
180
|
-
s.gray("7. Press the `Debug 'entry'` button (top right corner)."),
|
|
181
|
-
].join('\n'));
|
|
182
|
-
}
|
|
183
|
-
catch (err) {
|
|
184
|
-
if (err instanceof core_1.DescriptiveError && !err.isUnexpected()) {
|
|
185
|
-
logger.descriptiveError(err);
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
throw err;
|
|
189
|
-
}
|
|
190
|
-
}),
|
|
232
|
+
});
|
|
233
|
+
}); },
|
|
191
234
|
};
|
|
192
235
|
function findRNOHHvigorPluginPath(fs, dirPath) {
|
|
193
|
-
for (
|
|
236
|
+
for (var _i = 0, _a = fs.readDirentsSync(dirPath); _i < _a.length; _i++) {
|
|
237
|
+
var dirent = _a[_i];
|
|
194
238
|
if (dirent.isDirectory() || !dirent.name.startsWith('rnoh-hvigor-plugin')) {
|
|
195
239
|
continue;
|
|
196
240
|
}
|
|
@@ -204,12 +248,13 @@ function findRNOHHvigorPluginPath(fs, dirPath) {
|
|
|
204
248
|
*/
|
|
205
249
|
function renameGitignoreFiles(fs, dirPath) {
|
|
206
250
|
try {
|
|
207
|
-
for (
|
|
251
|
+
for (var _i = 0, _a = fs.readDirentsSync(dirPath); _i < _a.length; _i++) {
|
|
252
|
+
var dirent = _a[_i];
|
|
208
253
|
if (dirent.isDirectory()) {
|
|
209
254
|
renameGitignoreFiles(fs, dirent.path);
|
|
210
255
|
}
|
|
211
256
|
else if (!dirent.isDirectory() && dirent.name === 'gitignore') {
|
|
212
|
-
|
|
257
|
+
var newFilePath = dirPath.copyWithNewSegment('.gitignore');
|
|
213
258
|
fs.renameSync(dirent.path, newFilePath);
|
|
214
259
|
}
|
|
215
260
|
}
|