@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
package/package.json
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-oh/react-native-harmony-cli",
|
|
3
|
-
"version": "0.77.
|
|
3
|
+
"version": "0.77.33",
|
|
4
4
|
"description": "",
|
|
5
|
-
"publishConfig": {
|
|
6
|
-
"registry": "https://registry.npmjs.org/",
|
|
7
|
-
"access": "public"
|
|
8
|
-
},
|
|
9
5
|
"scripts": {
|
|
10
6
|
"build": "tsc --outDir dist -p tsconfig.build.json && node ./scripts/copy-template.js",
|
|
11
7
|
"prepack": "npm run build && npm run _recreate-hvigor-plugin",
|
|
12
|
-
"_recreate-hvigor-plugin": "cd ../react-native-harmony-hvigor-plugin && npm i && npm run deploy && cd ../react-native-harmony-cli",
|
|
8
|
+
"_recreate-hvigor-plugin": "cd ../react-native-harmony-hvigor-plugin && npm i && npm run deploy && cd ../react-native-harmony-cli && node ./scripts/sync-hvigor.js",
|
|
13
9
|
"verify": "tsc --noEmit && npm run test",
|
|
14
10
|
"test": "npm run build && jest",
|
|
15
11
|
"test:codegen": "jest ./src/codegen/.* && npm run build && jest tests/codegen.*",
|
|
@@ -58,10 +54,5 @@
|
|
|
58
54
|
"mustache": "^4.2.0",
|
|
59
55
|
"tar": "^6.1.15",
|
|
60
56
|
"tmp": "^0.2.1"
|
|
61
|
-
},
|
|
62
|
-
"homepage": "https://gitcode.com/openharmony-sig/ohos_react_native",
|
|
63
|
-
"repository": {
|
|
64
|
-
"type": "gitcode",
|
|
65
|
-
"url": "https://gitcode.com/openharmony-sig/ohos_react_native"
|
|
66
57
|
}
|
|
67
58
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
const fs = require('fs').promises;
|
|
8
|
+
|
|
9
|
+
async function sync(configFilePaths = []) {
|
|
10
|
+
const dir = './harmony';
|
|
11
|
+
const files = await fs.readdir(dir);
|
|
12
|
+
const file = files.find(f => /^rnoh-hvigor-plugin-\d+(\.\d+){2}\.tgz$/.test(f));
|
|
13
|
+
if (!file) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
configFilePaths.forEach(async (configFilePath) => {
|
|
17
|
+
const fileContent = await fs.readFile(configFilePath, 'utf8');
|
|
18
|
+
const updatedContent = fileContent.replace(/rnoh-hvigor-plugin-\d+(\.\d+){2}\.tgz/g, file);
|
|
19
|
+
fs.writeFile(configFilePath, updatedContent, 'utf8');
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
sync([
|
|
24
|
+
'../tester/harmony/hvigor/hvigor-config.json5',
|
|
25
|
+
'../tester-ecosystem/harmony/hvigor/hvigor-config.json5',
|
|
26
|
+
'../react-native-harmony-61-interop-tester/rnoh-entry/harmony/hvigor/hvigor-config.json5'
|
|
27
|
+
]).catch(console.error);
|
|
@@ -271,7 +271,7 @@ export class Autolinking {
|
|
|
271
271
|
const managedNativeDependencySpecifierByName: Record<string, string> = {};
|
|
272
272
|
for (const library of autolinkableLibraries) {
|
|
273
273
|
managedNativeDependencySpecifierByName[library.ohPackageName] =
|
|
274
|
-
|
|
274
|
+
`file:${library.harFilePathRelativeToHarmony}`.split(pathUtils.sep).join('/');
|
|
275
275
|
}
|
|
276
276
|
return {
|
|
277
277
|
skippedLibraryNpmPackageNames: input.skippedLibraryNpmPackageNames,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import pathUtils from 'path';
|
|
1
2
|
import { AbsolutePath } from '../../core';
|
|
2
3
|
import {
|
|
3
4
|
CodeGenerator,
|
|
@@ -10,6 +11,9 @@ import { GlueCodeDataV1 } from './AppBuildTimeGlueCodeGenerator';
|
|
|
10
11
|
import { NativeModuleCodeGenerator } from './NativeModuleCodeGenerator';
|
|
11
12
|
import { ArkTSComponentCodeGeneratorArkTS } from './ArkTSComponentCodeGeneratorArkTS';
|
|
12
13
|
|
|
14
|
+
// The name of rnoh OHOS module
|
|
15
|
+
const RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
|
|
16
|
+
|
|
13
17
|
/**
|
|
14
18
|
* Generates code for libraries built on top of RNOH's ArkTS architecture.
|
|
15
19
|
*/
|
|
@@ -28,17 +32,18 @@ export class UberGeneratorV1 implements CodeGenerator<UberSchema> {
|
|
|
28
32
|
|
|
29
33
|
generate(uberSchema: UberSchema) {
|
|
30
34
|
const fileContentByPath = new Map<AbsolutePath, string>();
|
|
35
|
+
const isRNOHModulePath = this.etsOutputPath.getValue().endsWith(`${RNOH_OHOS_NAME}/generated`.replace(/\//g, pathUtils.sep));
|
|
31
36
|
const componentCodeGenerator = new ArkTSComponentCodeGeneratorArkTS(
|
|
32
37
|
this.cppOutputPath,
|
|
33
38
|
this.etsOutputPath.copyWithNewSegment('components'),
|
|
34
39
|
this.codegenNoticeLines,
|
|
35
|
-
'../../ts'
|
|
40
|
+
isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`
|
|
36
41
|
);
|
|
37
42
|
const nativeModuleCodeGenerator = new NativeModuleCodeGenerator(
|
|
38
43
|
this.cppOutputPath,
|
|
39
44
|
this.etsOutputPath.copyWithNewSegment('turboModules'),
|
|
40
45
|
this.codegenNoticeLines,
|
|
41
|
-
'../../ts'
|
|
46
|
+
isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`
|
|
42
47
|
);
|
|
43
48
|
const generatorBySpecType = {
|
|
44
49
|
Component: componentCodeGenerator,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import pathUtils from 'path';
|
|
1
2
|
import { AbsolutePath } from '../../core';
|
|
2
3
|
import { CodeGenerator } from '../core';
|
|
3
4
|
import {
|
|
@@ -8,6 +9,9 @@ import { NativeModuleCodeGenerator } from './NativeModuleCodeGenerator';
|
|
|
8
9
|
import { GlueCodeDataV2 } from './AppBuildTimeGlueCodeGenerator';
|
|
9
10
|
import { SharedComponentCodeGenerator } from './SharedComponentCodeGenerator';
|
|
10
11
|
|
|
12
|
+
// The name of rnoh OHOS module
|
|
13
|
+
const RNOH_OHOS_NAME = '@rnoh/react-native-openharmony';
|
|
14
|
+
|
|
11
15
|
/**
|
|
12
16
|
* Generates code for libraries built on top of RNOH's C-API architecture.
|
|
13
17
|
*/
|
|
@@ -78,6 +82,7 @@ export class UberGeneratorV2 implements CodeGenerator<LibraryData[]> {
|
|
|
78
82
|
.getSpecSchemaByFilenameMap()
|
|
79
83
|
.entries()) {
|
|
80
84
|
if (specSchema.type === 'NativeModule') {
|
|
85
|
+
const isRNOHModulePath = this.etsOutputPath.getValue().endsWith(`${RNOH_OHOS_NAME}/generated`.replace(/\//g, pathUtils.sep));
|
|
81
86
|
const nativeModuleCodeGenerator = new NativeModuleCodeGenerator(
|
|
82
87
|
libraryCppOutput.copyWithNewSegment(
|
|
83
88
|
'RNOH',
|
|
@@ -86,7 +91,7 @@ export class UberGeneratorV2 implements CodeGenerator<LibraryData[]> {
|
|
|
86
91
|
),
|
|
87
92
|
this.etsOutputPath.copyWithNewSegment('turboModules'),
|
|
88
93
|
this.codegenNoticeLines,
|
|
89
|
-
'../../ts'
|
|
94
|
+
isRNOHModulePath ? '../../ts' : `${RNOH_OHOS_NAME}/ts`
|
|
90
95
|
);
|
|
91
96
|
nativeModuleCodeGenerator
|
|
92
97
|
.generate(specSchema)
|
|
@@ -27,7 +27,12 @@ export const commandCodegenHarmony: Command = {
|
|
|
27
27
|
options: [
|
|
28
28
|
{
|
|
29
29
|
name: '--rnoh-module-path <path>',
|
|
30
|
-
description: 'Specifies the relative path to the rnoh OHOS module',
|
|
30
|
+
description: '[deprecated] Specifies the relative path to the rnoh OHOS module',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: '--ets-output-path <path>',
|
|
34
|
+
description:
|
|
35
|
+
'Specifies the relative path to the output directory intended for storing generated ETS files.',
|
|
31
36
|
},
|
|
32
37
|
{
|
|
33
38
|
name: '--cpp-output-path <path>',
|
|
@@ -58,9 +63,12 @@ export const commandCodegenHarmony: Command = {
|
|
|
58
63
|
const MAX_SUPPORTED_CODEGEN_VERSION = 2;
|
|
59
64
|
// prepare the input data
|
|
60
65
|
validateArgs(args);
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
let etsOutputPath = args.etsOutputPath || args.rnohModulePath;
|
|
67
|
+
const isEndWithGenerated = /\/generated\/?$/.test(etsOutputPath);
|
|
68
|
+
etsOutputPath = new AbsolutePath(etsOutputPath);
|
|
69
|
+
if (!isEndWithGenerated) {
|
|
70
|
+
etsOutputPath = etsOutputPath.copyWithNewSegment('generated');
|
|
71
|
+
}
|
|
64
72
|
const enableSafetyCheck: boolean = args.safetyCheck;
|
|
65
73
|
const cppOutputPath = new AbsolutePath(args.cppOutputPath);
|
|
66
74
|
const projectRootPath = new AbsolutePath(args.projectRootPath);
|
|
@@ -159,11 +167,13 @@ export const commandCodegenHarmony: Command = {
|
|
|
159
167
|
};
|
|
160
168
|
|
|
161
169
|
function validateArgs(args: any) {
|
|
162
|
-
if (!args.rnohModulePath) {
|
|
170
|
+
if (!args.rnohModulePath && !args.etsOutputPath) {
|
|
163
171
|
throw new DescriptiveError({
|
|
164
|
-
whatHappened:
|
|
172
|
+
whatHappened: '--ets-output-path is required',
|
|
165
173
|
whatCanUserDo: [
|
|
166
|
-
'Please provide
|
|
174
|
+
'Please provide an output path for the ETS file.',
|
|
175
|
+
'It is recommended to place it in the same directory as the custom component or TurboModule.',
|
|
176
|
+
'Do not place it inside @rnoh/react-native-openharmony, otherwise a jscrash may occur when using react_native_openharmony_release2.har.'
|
|
167
177
|
],
|
|
168
178
|
});
|
|
169
179
|
}
|
|
@@ -19,8 +19,11 @@ import {
|
|
|
19
19
|
startServerInNewWindow,
|
|
20
20
|
findDevServerPort,
|
|
21
21
|
} from '@react-native-community/cli-tools';
|
|
22
|
+
import { launchHarmonySimulator } from '../simulator';
|
|
22
23
|
|
|
23
24
|
const COMMAND_NAME = 'run-harmony';
|
|
25
|
+
const LOOPBACK_IP = '127.0.0.1';
|
|
26
|
+
const DEFAULT_SIMULATOR_NAME = `${LOOPBACK_IP}:5555`;
|
|
24
27
|
|
|
25
28
|
export const commandRunHarmony: Command = {
|
|
26
29
|
name: COMMAND_NAME,
|
|
@@ -108,7 +111,7 @@ export const commandRunHarmony: Command = {
|
|
|
108
111
|
const buildMode: string = rawArgs.buildMode;
|
|
109
112
|
const moduleName: string = rawArgs.module;
|
|
110
113
|
const abilityName: string = rawArgs.ability;
|
|
111
|
-
|
|
114
|
+
let simulatorName: string = rawArgs.simulator;
|
|
112
115
|
const defaultPort: number = rawArgs.port;
|
|
113
116
|
const packager: boolean = rawArgs.packager;
|
|
114
117
|
const devEcoStudioToolsPath = new AbsolutePath(
|
|
@@ -125,6 +128,32 @@ export const commandRunHarmony: Command = {
|
|
|
125
128
|
)
|
|
126
129
|
).app.bundleName;
|
|
127
130
|
|
|
131
|
+
let currentPort: number = defaultPort;
|
|
132
|
+
if (packager) {
|
|
133
|
+
const root: string = _config.root || '.';
|
|
134
|
+
const reactNativePath: string = _config.reactNativePath || path.dirname(
|
|
135
|
+
require.resolve('react-native', { paths: [root] }),
|
|
136
|
+
);
|
|
137
|
+
const { port: newPort, startPackager } = await findDevServerPort(
|
|
138
|
+
defaultPort,
|
|
139
|
+
root,
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
if (newPort !== 8081) {
|
|
143
|
+
await trySetMetroPort(harmonyProjectPath.copyWithNewSegment(
|
|
144
|
+
'entry', 'src', 'main', 'ets', 'pages', 'Index.ets').toString(), newPort);
|
|
145
|
+
}
|
|
146
|
+
if (startPackager) {
|
|
147
|
+
startServerInNewWindow(
|
|
148
|
+
newPort,
|
|
149
|
+
root,
|
|
150
|
+
reactNativePath,
|
|
151
|
+
getDefaultUserTerminal(),
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
currentPort = newPort;
|
|
155
|
+
}
|
|
156
|
+
|
|
128
157
|
const selectDevice = async (deviceAndSimulatorInfos: string) => {
|
|
129
158
|
const lines = deviceAndSimulatorInfos.trim().split('\n');
|
|
130
159
|
const availableDevices = lines.map((line) => {
|
|
@@ -150,6 +179,11 @@ export const commandRunHarmony: Command = {
|
|
|
150
179
|
return simulatorName;
|
|
151
180
|
}
|
|
152
181
|
const connectedDevices = availableDevices.filter((deviceOrSimulator) => deviceOrSimulator.state === 'Connected');
|
|
182
|
+
|
|
183
|
+
if (connectedDevices.length === 1) {
|
|
184
|
+
return connectedDevices[0].name;
|
|
185
|
+
}
|
|
186
|
+
|
|
153
187
|
if (connectedDevices.length > 1) {
|
|
154
188
|
const answers = await inquirer.prompt([
|
|
155
189
|
{
|
|
@@ -160,14 +194,33 @@ export const commandRunHarmony: Command = {
|
|
|
160
194
|
}
|
|
161
195
|
])
|
|
162
196
|
return connectedDevices[parseInt(answers.selectedDeviceIndex) - 1].name;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
try {
|
|
200
|
+
await launchHarmonySimulator({
|
|
201
|
+
devEcoStudioToolsPath,
|
|
202
|
+
sdkToolchainsPath,
|
|
203
|
+
cli,
|
|
204
|
+
logger,
|
|
205
|
+
env: process.env,
|
|
206
|
+
});
|
|
207
|
+
simulatorName = DEFAULT_SIMULATOR_NAME;
|
|
208
|
+
return simulatorName;
|
|
209
|
+
} catch (e) {
|
|
210
|
+
if (e instanceof DescriptiveError) {
|
|
211
|
+
throw new DescriptiveError({
|
|
212
|
+
whatHappened: `${e.getMessage()} \n No devices are connected. Failed to auto-launch simulator.`,
|
|
213
|
+
whatCanUserDo: [...e.getSuggestions()],
|
|
214
|
+
extraData: e.getRawData().extraData,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
166
217
|
throw new DescriptiveError({
|
|
167
|
-
whatHappened: `No devices are connected in the current environment.`,
|
|
218
|
+
whatHappened: `No devices are connected in the current environment (auto-launch attempt failed).`,
|
|
168
219
|
whatCanUserDo: [
|
|
169
|
-
'
|
|
170
|
-
|
|
220
|
+
'Connect a HarmonyOS device via USB or start the simulator manually.',
|
|
221
|
+
'Re-run the command after a device is listed by: hdc list targets -v',
|
|
222
|
+
],
|
|
223
|
+
extraData: e,
|
|
171
224
|
});
|
|
172
225
|
}
|
|
173
226
|
};
|
|
@@ -180,32 +233,9 @@ export const commandRunHarmony: Command = {
|
|
|
180
233
|
}
|
|
181
234
|
);
|
|
182
235
|
|
|
183
|
-
const deviceOrSimulatorName = await selectDevice(deviceAndSimulatorInfo)
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (packager) {
|
|
187
|
-
const root: string = _config.root || '.';
|
|
188
|
-
const reactNativePath: string = _config.reactNativePath || path.dirname(
|
|
189
|
-
require.resolve('react-native', { paths: [root] }),
|
|
190
|
-
);
|
|
191
|
-
const { port: newPort, startPackager } = await findDevServerPort(
|
|
192
|
-
defaultPort,
|
|
193
|
-
root,
|
|
194
|
-
);
|
|
195
|
-
|
|
196
|
-
if (newPort !== 8081) {
|
|
197
|
-
await trySetMetroPort(harmonyProjectPath.copyWithNewSegment(
|
|
198
|
-
'entry', 'src', 'main', 'ets', 'pages', 'Index.ets').toString(), newPort);
|
|
199
|
-
}
|
|
200
|
-
if (startPackager) {
|
|
201
|
-
startServerInNewWindow(
|
|
202
|
-
newPort,
|
|
203
|
-
root,
|
|
204
|
-
reactNativePath,
|
|
205
|
-
getDefaultUserTerminal(),
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
currentPort = newPort;
|
|
236
|
+
const deviceOrSimulatorName = await selectDevice(deviceAndSimulatorInfo);
|
|
237
|
+
if (deviceOrSimulatorName.includes(`${LOOPBACK_IP}:`)) {
|
|
238
|
+
simulatorName = deviceOrSimulatorName;
|
|
209
239
|
}
|
|
210
240
|
|
|
211
241
|
const runJob = async (name: string, job: () => Promise<void>) => {
|
|
@@ -235,14 +265,11 @@ export const commandRunHarmony: Command = {
|
|
|
235
265
|
.copyWithNewSegment('ohpm', 'bin', 'ohpm.bat');
|
|
236
266
|
}
|
|
237
267
|
await cli.run(
|
|
238
|
-
|
|
239
|
-
ohpmPath.toString(),
|
|
268
|
+
`"${ohpmPath.toString()}"`,
|
|
240
269
|
{
|
|
241
270
|
args: [
|
|
242
271
|
'install',
|
|
243
272
|
'--all',
|
|
244
|
-
'--strict_ssl',
|
|
245
|
-
'true',
|
|
246
273
|
],
|
|
247
274
|
cwd: harmonyProjectPath,
|
|
248
275
|
shell: true,
|
|
@@ -265,10 +292,9 @@ export const commandRunHarmony: Command = {
|
|
|
265
292
|
nodePath = devEcoStudioToolsPath.copyWithNewSegment('node', 'node');
|
|
266
293
|
}
|
|
267
294
|
let hvigorPathRaw = devEcoStudioToolsPath.copyWithNewSegment('hvigor', 'bin', 'hvigorw.js').toString();
|
|
268
|
-
const hvigorPath =
|
|
295
|
+
const hvigorPath = `"${hvigorPathRaw}"`;
|
|
269
296
|
await cli.run(
|
|
270
|
-
|
|
271
|
-
nodePath.toString(),
|
|
297
|
+
`"${nodePath.toString()}"`,
|
|
272
298
|
{
|
|
273
299
|
args: [
|
|
274
300
|
hvigorPath,
|
|
@@ -321,7 +347,7 @@ export const commandRunHarmony: Command = {
|
|
|
321
347
|
const hdcPathStrRaw = sdkToolchainsPath
|
|
322
348
|
.copyWithNewSegment('hdc')
|
|
323
349
|
.toString();
|
|
324
|
-
const hdcPathStr =
|
|
350
|
+
const hdcPathStr = `"${hdcPathStrRaw.toString()}"`;
|
|
325
351
|
|
|
326
352
|
const tryRemoveForwardPorting = async () => {
|
|
327
353
|
let fportInfo: string = '';
|
|
@@ -10,6 +10,13 @@
|
|
|
10
10
|
"deliveryWithInstall": true,
|
|
11
11
|
"installationFree": false,
|
|
12
12
|
"pages": "$profile:main_pages",
|
|
13
|
+
// This is needed by bundleManager.canOpenLink to check if the app can open some url
|
|
14
|
+
"querySchemes": [
|
|
15
|
+
"maps",
|
|
16
|
+
"http",
|
|
17
|
+
"https",
|
|
18
|
+
"customDomain"
|
|
19
|
+
],
|
|
13
20
|
"requestPermissions": [
|
|
14
21
|
{
|
|
15
22
|
"name": "ohos.permission.INTERNET"
|