@react-native-oh/react-native-harmony-cli 0.0.30 → 0.77.18
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/LICENSE +21 -0
- package/README.md +4 -4
- package/dist/assetResolver.js +105 -10
- package/dist/autolinking/Autolinking.js +21 -26
- package/dist/autolinking/index.js +0 -6
- package/dist/codegen/core/CodeGenerator.js +0 -6
- package/dist/codegen/core/CodegenError.js +0 -6
- package/dist/codegen/core/EventUtils.js +4 -13
- package/dist/codegen/core/TypeAnnotationToTS.js +3 -9
- package/dist/codegen/core/UberSchema.js +8 -21
- package/dist/codegen/core/index.js +0 -6
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +2 -7
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +3 -6
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +3 -6
- package/dist/codegen/generators/CppComponentCodeGenerator.js +3 -6
- package/dist/codegen/generators/LibGlueCodeGenerator.js +2 -8
- package/dist/codegen/generators/NativeModuleCodeGenerator.js +1 -7
- package/dist/codegen/generators/SharedComponentCodeGenerator.js +0 -6
- package/dist/codegen/generators/UberGeneratorV1.js +0 -6
- package/dist/codegen/generators/UberGeneratorV2.js +0 -6
- package/dist/codegen/generators/index.js +0 -6
- package/dist/codegen/index.js +0 -6
- package/dist/codegen/templates/BaseComponentInstanceHTemplate.js +0 -6
- package/dist/codegen/templates/BasePackageHTemplate.js +12 -7
- package/dist/codegen/templates/ComponentDescriptorHTemplate.js +1 -6
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +15 -6
- package/dist/codegen/templates/ComponentUtilsTSTemplate.js +0 -6
- package/dist/codegen/templates/IndexTSTemplate.js +0 -6
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +12 -7
- package/dist/codegen/templates/TurboModuleCppTemplate.js +0 -6
- package/dist/codegen/templates/TurboModuleHTemplate.js +0 -6
- package/dist/codegen/templates/TurboModuleSpecTSTemplate.js +0 -6
- package/dist/codegen/templates/index.js +0 -6
- package/dist/commands/bundle-harmony.js +133 -101
- package/dist/commands/clean-harmony.js +84 -0
- package/dist/commands/codegen-harmony.js +12 -22
- package/dist/commands/codegen-lib-harmony.js +15 -25
- package/dist/commands/index.js +3 -9
- package/dist/commands/init-harmony.js +226 -0
- package/dist/commands/init.js +703 -0
- package/dist/commands/link-harmony.js +12 -16
- package/dist/commands/run-harmony.js +438 -0
- package/dist/commands/types.js +2 -0
- package/dist/commands/verify-package-harmony.js +7 -11
- package/dist/core/AbsolutePath.js +3 -6
- package/dist/core/CodegenConfig.js +3 -11
- package/dist/core/DescriptiveError.js +7 -9
- package/dist/core/FileSystem.js +0 -6
- package/dist/core/OHPackageJSON5.js +0 -6
- package/dist/core/PackageJSON.js +4 -7
- package/dist/core/ProjectDependenciesManager.js +6 -14
- package/dist/core/ValidationError.js +0 -6
- package/dist/core/ValueObject.js +0 -6
- package/dist/core/fs.js +16 -10
- package/dist/core/index.js +0 -6
- package/dist/index.js +3 -9
- package/dist/init/templates/AppScopeAppJSON5Template.js +30 -0
- package/dist/init/templates/AppScopeStringVarTemplate.js +28 -0
- package/dist/init/templates/EntryIndexTemplate.js +65 -0
- package/dist/init/templates/EntryStringVarTemplate.js +38 -0
- package/dist/init/templates/HvigorConfigJson5Template.js +44 -0
- package/dist/init/templates/MetroConfigTemplate.js +47 -0
- package/dist/init/templates/OhPackageJson5Template.js +37 -0
- package/dist/init/templates/harmony/AppScope/app.json5 +10 -0
- package/dist/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
- package/dist/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/dist/init/templates/harmony/build-profile.json5 +36 -0
- package/dist/init/templates/harmony/codelinter.json +32 -0
- package/dist/init/templates/harmony/entry/build-profile.json5 +18 -0
- package/dist/init/templates/harmony/entry/gitignore +7 -0
- package/dist/init/templates/harmony/entry/hvigorfile.ts +13 -0
- package/dist/init/templates/harmony/entry/oh-package.json5 +9 -0
- package/dist/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
- package/dist/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
- package/dist/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
- package/dist/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
- package/dist/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
- package/dist/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
- package/dist/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
- 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 +16 -0
- package/dist/init/templates/harmony/entry/src/main/module.json5 +58 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
- package/dist/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
- 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 +7 -0
- 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 +5 -0
- package/dist/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
- package/dist/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
- package/dist/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
- package/dist/init/templates/harmony/gitignore +16 -0
- package/dist/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
- package/dist/init/templates/harmony/hvigorfile.ts +7 -0
- package/dist/init/templates/index.js +21 -0
- package/dist/io/CliExecutor.js +56 -29
- package/dist/io/Logger.js +71 -47
- package/dist/io/RealFS.js +10 -6
- package/dist/io/TarGz.js +3 -10
- package/dist/io/__fixtures__.js +8 -8
- package/dist/io/fsUtils.js +1 -8
- package/dist/io/index.js +1 -6
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +1 -8
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +1 -8
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +1 -8
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +1 -8
- package/dist/package-verifier/checks/index.js +0 -6
- package/dist/package-verifier/index.js +0 -6
- package/dist/package-verifier/types.js +0 -6
- package/dist/package-verifier/verify-package.js +5 -14
- package/jest.config.js +0 -7
- package/package.json +20 -16
- package/react-native.config.js +0 -7
- package/scripts/copy-template.js +18 -0
- package/src/assetResolver.ts +117 -11
- package/src/autolinking/Autolinking.test.ts +54 -18
- package/src/autolinking/Autolinking.ts +32 -31
- package/src/autolinking/index.ts +1 -8
- package/src/codegen/core/CodeGenerator.ts +0 -7
- package/src/codegen/core/CodegenError.ts +0 -7
- package/src/codegen/core/EventUtils.ts +3 -12
- package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -7
- package/src/codegen/core/TypeAnnotationToTS.ts +3 -8
- package/src/codegen/core/UberSchema.ts +9 -22
- package/src/codegen/core/index.ts +0 -7
- package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +5 -8
- package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +3 -7
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +3 -7
- package/src/codegen/generators/CppComponentCodeGenerator.ts +3 -7
- package/src/codegen/generators/LibGlueCodeGenerator.ts +2 -9
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +1 -8
- package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -7
- package/src/codegen/generators/UberGeneratorV1.ts +0 -7
- package/src/codegen/generators/UberGeneratorV2.ts +0 -7
- package/src/codegen/generators/index.ts +0 -7
- package/src/codegen/index.ts +0 -7
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -7
- package/src/codegen/templates/BasePackageHTemplate.ts +13 -8
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +1 -7
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +24 -8
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -7
- package/src/codegen/templates/IndexTSTemplate.ts +0 -7
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +13 -8
- package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -7
- package/src/codegen/templates/TurboModuleHTemplate.ts +0 -7
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -7
- package/src/codegen/templates/index.ts +0 -7
- package/src/commands/bundle-harmony.ts +178 -118
- package/src/commands/clean-harmony.ts +54 -0
- package/src/commands/codegen-harmony.ts +13 -25
- package/src/commands/codegen-lib-harmony.ts +16 -28
- package/src/commands/index.ts +3 -10
- package/src/commands/init-harmony.ts +299 -0
- package/src/commands/init.ts +755 -0
- package/src/commands/link-harmony.ts +14 -19
- package/src/commands/run-harmony.ts +478 -0
- package/src/commands/types.ts +14 -0
- package/src/commands/verify-package-harmony.ts +9 -12
- package/src/core/AbsolutePath.ts +4 -7
- package/src/core/CodegenConfig.ts +3 -12
- package/src/core/DescriptiveError.ts +8 -15
- package/src/core/FileSystem.ts +5 -8
- package/src/core/OHPackageJSON5.ts +0 -7
- package/src/core/PackageJSON.ts +4 -13
- package/src/core/ProjectDependenciesManager.ts +14 -22
- package/src/core/ValidationError.ts +0 -7
- package/src/core/ValueObject.ts +0 -7
- package/src/core/fs.ts +14 -8
- package/src/core/index.ts +0 -7
- package/src/index.ts +8 -15
- package/src/init/templates/AppScopeAppJSON5Template.ts +24 -0
- package/src/init/templates/AppScopeStringVarTemplate.ts +22 -0
- package/src/init/templates/EntryIndexTemplate.ts +59 -0
- package/src/init/templates/EntryStringVarTemplate.ts +31 -0
- package/src/init/templates/HvigorConfigJson5Template.ts +40 -0
- package/src/init/templates/MetroConfigTemplate.ts +41 -0
- package/src/init/templates/OhPackageJson5Template.ts +31 -0
- package/src/init/templates/harmony/AppScope/app.json5 +10 -0
- package/src/init/templates/harmony/AppScope/resources/base/element/string.json +8 -0
- package/src/init/templates/harmony/AppScope/resources/base/media/app_icon.png +0 -0
- package/src/init/templates/harmony/build-profile.json5 +36 -0
- package/src/init/templates/harmony/codelinter.json +32 -0
- package/src/init/templates/harmony/entry/build-profile.json5 +18 -0
- package/src/init/templates/harmony/entry/gitignore +7 -0
- package/src/init/templates/harmony/entry/hvigorfile.ts +13 -0
- package/src/init/templates/harmony/entry/oh-package.json5 +9 -0
- package/src/init/templates/harmony/entry/src/main/cpp/CMakeLists.txt +27 -0
- package/src/init/templates/harmony/entry/src/main/cpp/PackageProvider.cpp +13 -0
- package/src/init/templates/harmony/entry/src/main/cpp/gitignore +4 -0
- package/src/init/templates/harmony/entry/src/main/ets/PackageProvider.ets +8 -0
- package/src/init/templates/harmony/entry/src/main/ets/codegen/gitignore +2 -0
- package/src/init/templates/harmony/entry/src/main/ets/entryability/EntryAbility.ets +11 -0
- package/src/init/templates/harmony/entry/src/main/ets/gitignore +1 -0
- package/src/init/templates/harmony/entry/src/main/ets/pages/.gitkeep +0 -0
- package/src/init/templates/harmony/entry/src/main/ets/workers/RNOHWorker.ets +16 -0
- package/src/init/templates/harmony/entry/src/main/module.json5 +58 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/element/color.json +8 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/element/string.json +16 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/media/background.png +0 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/media/foreground.png +0 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/media/layered_image.json +7 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/src/init/templates/harmony/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/src/init/templates/harmony/entry/src/main/resources/gitignore +1 -0
- package/src/init/templates/harmony/entry/src/ohosTest/ets/test/List.test.ets +2 -0
- package/src/init/templates/harmony/entry/src/ohosTest/module.json5 +13 -0
- package/src/init/templates/harmony/gitignore +16 -0
- package/src/init/templates/harmony/hvigor/hvigor-config.json5 +22 -0
- package/src/init/templates/harmony/hvigorfile.ts +7 -0
- package/src/init/templates/index.ts +5 -0
- package/src/io/CliExecutor.ts +55 -40
- package/src/io/Logger.ts +77 -51
- package/src/io/RealFS.ts +15 -8
- package/src/io/TarGz.ts +1 -8
- package/src/io/__fixtures__.ts +15 -18
- package/src/io/fsUtils.ts +1 -7
- package/src/io/index.ts +1 -7
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -7
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -7
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -7
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -7
- package/src/package-verifier/checks/index.ts +0 -7
- package/src/package-verifier/index.ts +0 -7
- package/src/package-verifier/types.ts +0 -7
- package/src/package-verifier/verify-package.ts +4 -13
- package/tsconfig.build.json +2 -5
- package/tsconfig.json +4 -0
- package/dist/commands/create-metro-host-constants.js +0 -67
- package/dist/commands/pack-harmony.js +0 -106
- package/dist/commands/unpack-harmony.js +0 -191
- package/src/commands/create-metro-host-constants.ts +0 -55
- package/src/commands/pack-harmony.ts +0 -128
- package/src/commands/unpack-harmony.ts +0 -240
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -55,12 +49,14 @@ exports.commandLinkHarmony = {
|
|
|
55
49
|
default: './oh-package.json5',
|
|
56
50
|
},
|
|
57
51
|
{
|
|
58
|
-
name: '--exclude-npm-packages [string]',
|
|
59
|
-
description: "Lists npm package names to be excluded from the autolinking process
|
|
52
|
+
name: '--exclude-npm-packages [string...]',
|
|
53
|
+
description: "Lists npm package names to be excluded from the autolinking process. By default every library is included. Can't be used with --included-npm-packages.",
|
|
54
|
+
parse: (val, prev) => (prev ? [...prev, val] : [val]),
|
|
60
55
|
},
|
|
61
56
|
{
|
|
62
|
-
name: '--include-npm-packages [string]',
|
|
63
|
-
description: "Lists npm package names to be included from the autolinking process
|
|
57
|
+
name: '--include-npm-packages [string...]',
|
|
58
|
+
description: "Lists npm package names to be included from the autolinking process. By default every library is included. Can't be used with --excluded-npm-packages.",
|
|
59
|
+
parse: (val, prev) => (prev ? [...prev, val] : [val]),
|
|
64
60
|
},
|
|
65
61
|
],
|
|
66
62
|
func: (_argv, _config, rawArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -76,12 +72,12 @@ exports.commandLinkHarmony = {
|
|
|
76
72
|
cppRNOHPackagesFactoryPathRelativeToHarmony: rawArgs.cppRnohPackagesFactoryPathRelativeToHarmony,
|
|
77
73
|
etsRNOHPackagesFactoryPathRelativeToHarmony: rawArgs.etsRnohPackagesFactoryPathRelativeToHarmony,
|
|
78
74
|
ohPackagePathRelativeToHarmony: rawArgs.ohPackagePathRelativeToHarmony,
|
|
79
|
-
excludedNpmPackageNames: new Set(rawArgs.excludeNpmPackages
|
|
80
|
-
?
|
|
81
|
-
:
|
|
82
|
-
includedNpmPackageNames: new Set(rawArgs.includeNpmPackages
|
|
83
|
-
?
|
|
84
|
-
:
|
|
75
|
+
excludedNpmPackageNames: new Set(((_a = rawArgs.excludeNpmPackages) === null || _a === void 0 ? void 0 : _a.length) === 1
|
|
76
|
+
? rawArgs.excludeNpmPackages[0].split(';')
|
|
77
|
+
: rawArgs.excludeNpmPackages),
|
|
78
|
+
includedNpmPackageNames: new Set(((_b = rawArgs.includeNpmPackages) === null || _b === void 0 ? void 0 : _b.length) === 1
|
|
79
|
+
? rawArgs.includeNpmPackages[0].split(';')
|
|
80
|
+
: rawArgs.includeNpmPackages),
|
|
85
81
|
});
|
|
86
82
|
const result = autolinking.evaluate(config);
|
|
87
83
|
autolinking.saveAndLogOutput(result);
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) 2025 Huawei Technologies Co., Ltd.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.commandRunHarmony = void 0;
|
|
22
|
+
const core_1 = require("../core");
|
|
23
|
+
const io_1 = require("../io");
|
|
24
|
+
const CliExecutor_1 = require("../io/CliExecutor");
|
|
25
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
26
|
+
const node_crypto_1 = __importDefault(require("node:crypto"));
|
|
27
|
+
const json5_1 = __importDefault(require("json5"));
|
|
28
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
29
|
+
const path_1 = __importDefault(require("path"));
|
|
30
|
+
const cli_tools_1 = require("@react-native-community/cli-tools");
|
|
31
|
+
const COMMAND_NAME = 'run-harmony';
|
|
32
|
+
exports.commandRunHarmony = {
|
|
33
|
+
name: COMMAND_NAME,
|
|
34
|
+
description: 'Builds your app and starts it on your phone.',
|
|
35
|
+
options: [
|
|
36
|
+
{
|
|
37
|
+
name: '--harmony-project-path <path>',
|
|
38
|
+
description: 'Specifies the root of your OpenHarmony project.',
|
|
39
|
+
default: './harmony',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: '--module <string>',
|
|
43
|
+
description: 'Name of the OH module to run.',
|
|
44
|
+
default: 'entry',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: '--build-mode <string>',
|
|
48
|
+
description: 'Debug or Release.',
|
|
49
|
+
default: 'debug',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: '--product <string>',
|
|
53
|
+
description: 'OpenHarmony product defined in build-profile.json5.',
|
|
54
|
+
default: 'default',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: '--ability <string>',
|
|
58
|
+
description: 'Name of the ability to start.',
|
|
59
|
+
default: 'EntryAbility',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
name: '--simulator <string>',
|
|
63
|
+
description: 'The name of the simulator that are currently connected.',
|
|
64
|
+
default: 'undefined',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: '--port <number>',
|
|
68
|
+
description: 'The port to use for the device.',
|
|
69
|
+
default: process.env.RCT_METRO_PORT || 8081,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: '--no-packager',
|
|
73
|
+
description: 'Do not launch packager while running the app.',
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
func: (_argv, _config, rawArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
const logger = new io_1.Logger();
|
|
78
|
+
try {
|
|
79
|
+
const DEVECO_SDK_HOME = process.env.DEVECO_SDK_HOME;
|
|
80
|
+
if (!DEVECO_SDK_HOME) {
|
|
81
|
+
throw new core_1.DescriptiveError({
|
|
82
|
+
whatHappened: 'DEVECO_SDK_HOME environment variable is not set',
|
|
83
|
+
whatCanUserDo: [
|
|
84
|
+
process.platform === 'darwin'
|
|
85
|
+
? 'On MacOS, the contents directory is typically located at: /Applications/DevEco-Studio.app/Contents/sdk. Set this path as the value of DEVECO_SDK_HOME'
|
|
86
|
+
: "Locate the installation directory of DevEco Studio, and set its 'sdk' subdirectory as the value of DEVECO_SDK_HOME environment variable.",
|
|
87
|
+
],
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
const fs = new io_1.RealFS();
|
|
91
|
+
const sdkPath = new core_1.AbsolutePath(DEVECO_SDK_HOME);
|
|
92
|
+
const sdkDirectoryNames = fs
|
|
93
|
+
.readDirentsSync(sdkPath)
|
|
94
|
+
.flatMap((dirent) => {
|
|
95
|
+
if (dirent.isDirectory()) {
|
|
96
|
+
return [dirent.name];
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
return [];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
if (sdkDirectoryNames.length === 0) {
|
|
103
|
+
throw new core_1.DescriptiveError({
|
|
104
|
+
whatHappened: `${sdkPath.toString()} has no directories`,
|
|
105
|
+
unexpected: true,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
const sdkToolchainsPath = sdkPath.copyWithNewSegment(sdkDirectoryNames[0], 'openharmony', 'toolchains');
|
|
109
|
+
const cli = new CliExecutor_1.RealCliExecutor();
|
|
110
|
+
const harmonyProjectPath = new core_1.AbsolutePath(rawArgs.harmonyProjectPath);
|
|
111
|
+
const productName = rawArgs.product;
|
|
112
|
+
const buildMode = rawArgs.buildMode;
|
|
113
|
+
const moduleName = rawArgs.module;
|
|
114
|
+
const abilityName = rawArgs.ability;
|
|
115
|
+
const simulatorName = rawArgs.simulator;
|
|
116
|
+
const defaultPort = rawArgs.port;
|
|
117
|
+
const packager = rawArgs.packager;
|
|
118
|
+
const devEcoStudioToolsPath = new core_1.AbsolutePath(DEVECO_SDK_HOME).copyWithNewSegment('..', 'tools');
|
|
119
|
+
if (!fs.existsSync(devEcoStudioToolsPath)) {
|
|
120
|
+
throw new core_1.DescriptiveError({
|
|
121
|
+
whatHappened: `${devEcoStudioToolsPath.toString()} doesn't exist`,
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const bundleName = json5_1.default.parse(fs.readTextSync(harmonyProjectPath.copyWithNewSegment('AppScope', 'app.json5'))).app.bundleName;
|
|
125
|
+
const selectDevice = (deviceAndSimulatorInfos) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
+
const lines = deviceAndSimulatorInfos.trim().split('\n');
|
|
127
|
+
const availableDevices = lines.map((line) => {
|
|
128
|
+
const parts = line.split(/\s+/);
|
|
129
|
+
return {
|
|
130
|
+
name: parts[0],
|
|
131
|
+
method: parts[1],
|
|
132
|
+
state: parts[2],
|
|
133
|
+
locate: parts[3],
|
|
134
|
+
connectTool: parts[4]
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
if (simulatorName !== 'undefined') {
|
|
138
|
+
const isRequestedDeviceAvailable = availableDevices.some((deviceOrSimulator) => deviceOrSimulator.name === simulatorName);
|
|
139
|
+
if (!isRequestedDeviceAvailable) {
|
|
140
|
+
throw new core_1.DescriptiveError({
|
|
141
|
+
whatHappened: `Simulator with name "${simulatorName}" not found.`,
|
|
142
|
+
whatCanUserDo: [
|
|
143
|
+
'Please confirm whether the entered simulator name has been activated.',
|
|
144
|
+
]
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
return simulatorName;
|
|
148
|
+
}
|
|
149
|
+
const connectedDevices = availableDevices.filter((deviceOrSimulator) => deviceOrSimulator.state === 'Connected');
|
|
150
|
+
if (connectedDevices.length > 1) {
|
|
151
|
+
const answers = yield inquirer_1.default.prompt([
|
|
152
|
+
{
|
|
153
|
+
type: 'list',
|
|
154
|
+
name: 'selectedDeviceIndex',
|
|
155
|
+
message: 'Please select a device:',
|
|
156
|
+
choices: connectedDevices.map((deviceOrSimulator, index) => `${index + 1}. ${deviceOrSimulator.name}`)
|
|
157
|
+
}
|
|
158
|
+
]);
|
|
159
|
+
return connectedDevices[parseInt(answers.selectedDeviceIndex) - 1].name;
|
|
160
|
+
}
|
|
161
|
+
else if (connectedDevices.length === 1) {
|
|
162
|
+
return connectedDevices[0].name;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
throw new core_1.DescriptiveError({
|
|
166
|
+
whatHappened: `No devices are connected in the current environment.`,
|
|
167
|
+
whatCanUserDo: [
|
|
168
|
+
'Please connect your HarmonyOS device or open the simulator.',
|
|
169
|
+
]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
const deviceAndSimulatorInfo = yield cli.run(sdkToolchainsPath.copyWithNewSegment('hdc').toString(), {
|
|
174
|
+
args: ['list', 'targets', '-v'],
|
|
175
|
+
cwd: harmonyProjectPath,
|
|
176
|
+
});
|
|
177
|
+
const deviceOrSimulatorName = yield selectDevice(deviceAndSimulatorInfo);
|
|
178
|
+
let currentPort = defaultPort;
|
|
179
|
+
if (packager) {
|
|
180
|
+
const root = _config.root || '.';
|
|
181
|
+
const reactNativePath = _config.reactNativePath || path_1.default.dirname(require.resolve('react-native', { paths: [root] }));
|
|
182
|
+
const { port: newPort, startPackager } = yield (0, cli_tools_1.findDevServerPort)(defaultPort, root);
|
|
183
|
+
if (newPort !== 8081) {
|
|
184
|
+
yield trySetMetroPort(harmonyProjectPath.copyWithNewSegment('entry', 'src', 'main', 'ets', 'pages', 'Index.ets').toString(), newPort);
|
|
185
|
+
}
|
|
186
|
+
if (startPackager) {
|
|
187
|
+
(0, cli_tools_1.startServerInNewWindow)(newPort, root, reactNativePath, (0, cli_tools_1.getDefaultUserTerminal)());
|
|
188
|
+
}
|
|
189
|
+
currentPort = newPort;
|
|
190
|
+
}
|
|
191
|
+
const runJob = (name, job) => __awaiter(void 0, void 0, void 0, function* () {
|
|
192
|
+
const stop = logger.start((s) => s.bold(name));
|
|
193
|
+
logger.info((s) => s.bold(`${name} started`));
|
|
194
|
+
try {
|
|
195
|
+
yield job();
|
|
196
|
+
logger.succeed((s) => s.bold(`${name} finished`));
|
|
197
|
+
}
|
|
198
|
+
catch (err) {
|
|
199
|
+
if (err instanceof core_1.DescriptiveError) {
|
|
200
|
+
throw err;
|
|
201
|
+
}
|
|
202
|
+
throw new core_1.DescriptiveError({
|
|
203
|
+
whatHappened: `${name} failed`,
|
|
204
|
+
extraData: err,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
stop();
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
yield runJob('[1/3] installing dependencies', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
212
|
+
let ohpmPath = devEcoStudioToolsPath
|
|
213
|
+
.copyWithNewSegment('ohpm', 'bin', 'ohpm');
|
|
214
|
+
if (process.platform === 'win32') {
|
|
215
|
+
ohpmPath = devEcoStudioToolsPath
|
|
216
|
+
.copyWithNewSegment('ohpm', 'bin', 'ohpm.bat');
|
|
217
|
+
}
|
|
218
|
+
yield cli.run(process.platform === 'win32' ? `"${ohpmPath.toString()}"` :
|
|
219
|
+
ohpmPath.toString(), {
|
|
220
|
+
args: [
|
|
221
|
+
'install',
|
|
222
|
+
'--all',
|
|
223
|
+
'--strict_ssl',
|
|
224
|
+
'true',
|
|
225
|
+
],
|
|
226
|
+
cwd: harmonyProjectPath,
|
|
227
|
+
shell: true,
|
|
228
|
+
onArgsStringified: (commandWithArgs) => {
|
|
229
|
+
logger.debug((s) => s.bold(s.gray(commandWithArgs)));
|
|
230
|
+
},
|
|
231
|
+
onStdout: (msg) => {
|
|
232
|
+
logger.debug((s) => s.gray(msg.trimEnd()));
|
|
233
|
+
},
|
|
234
|
+
onStderr(msg) {
|
|
235
|
+
logger.debug(() => msg.trimEnd());
|
|
236
|
+
},
|
|
237
|
+
});
|
|
238
|
+
}));
|
|
239
|
+
yield runJob('[2/3] building app', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
240
|
+
let nodePath = devEcoStudioToolsPath
|
|
241
|
+
.copyWithNewSegment('node', 'bin', 'node');
|
|
242
|
+
if (!fs.existsSync(nodePath)) {
|
|
243
|
+
nodePath = devEcoStudioToolsPath.copyWithNewSegment('node', 'node');
|
|
244
|
+
}
|
|
245
|
+
let hvigorPathRaw = devEcoStudioToolsPath.copyWithNewSegment('hvigor', 'bin', 'hvigorw.js').toString();
|
|
246
|
+
const hvigorPath = process.platform === 'win32' ? `"${hvigorPathRaw}"` : hvigorPathRaw;
|
|
247
|
+
yield cli.run(process.platform === 'win32' ? `"${nodePath.toString()}"` :
|
|
248
|
+
nodePath.toString(), {
|
|
249
|
+
args: [
|
|
250
|
+
hvigorPath,
|
|
251
|
+
`-p`,
|
|
252
|
+
`module=${moduleName}@default`,
|
|
253
|
+
`-p`,
|
|
254
|
+
`product=${productName}`,
|
|
255
|
+
`-p`,
|
|
256
|
+
`buildMode=${buildMode}`,
|
|
257
|
+
`-p`,
|
|
258
|
+
`requiredDeviceType=phone`,
|
|
259
|
+
`assembleHap`,
|
|
260
|
+
],
|
|
261
|
+
cwd: harmonyProjectPath,
|
|
262
|
+
shell: true,
|
|
263
|
+
onArgsStringified: (commandWithArgs) => {
|
|
264
|
+
logger.debug((s) => s.bold(s.gray(commandWithArgs)));
|
|
265
|
+
},
|
|
266
|
+
onStdout: (msg) => {
|
|
267
|
+
logger.debug((s) => s.gray(msg.trimEnd()));
|
|
268
|
+
},
|
|
269
|
+
onStderr(msg) {
|
|
270
|
+
logger.debug(() => msg.trimEnd());
|
|
271
|
+
},
|
|
272
|
+
});
|
|
273
|
+
}));
|
|
274
|
+
yield runJob('[3/3] installing and opening app', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
275
|
+
const tmpDirName = generateRandomString();
|
|
276
|
+
const ohosTmpDirPath = `data/local/tmp/${tmpDirName}`;
|
|
277
|
+
const exec = (command, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
278
|
+
const result = yield cli.run(command, {
|
|
279
|
+
args: args,
|
|
280
|
+
shell: true,
|
|
281
|
+
onArgsStringified: (commandWithArgs) => logger.debug((s) => s.bold(s.gray(commandWithArgs))),
|
|
282
|
+
});
|
|
283
|
+
if (result.startsWith('[Fail]')) {
|
|
284
|
+
throw new core_1.DescriptiveError({ whatHappened: result });
|
|
285
|
+
}
|
|
286
|
+
if (result) {
|
|
287
|
+
logger.debug((s) => s.gray(result.trimEnd() + '\n'));
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
logger.debug(() => '');
|
|
291
|
+
}
|
|
292
|
+
return result;
|
|
293
|
+
});
|
|
294
|
+
const hdcPathStrRaw = sdkToolchainsPath
|
|
295
|
+
.copyWithNewSegment('hdc')
|
|
296
|
+
.toString();
|
|
297
|
+
const hdcPathStr = process.platform === 'win32' ? `"${hdcPathStrRaw.toString()}"` : hdcPathStrRaw;
|
|
298
|
+
const tryRemoveForwardPorting = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
299
|
+
let fportInfo = '';
|
|
300
|
+
yield cli.run(hdcPathStrRaw, {
|
|
301
|
+
args: ['fport', 'ls'],
|
|
302
|
+
cwd: harmonyProjectPath,
|
|
303
|
+
onStdout: (msg) => {
|
|
304
|
+
fportInfo += msg;
|
|
305
|
+
},
|
|
306
|
+
onStderr: (msg) => {
|
|
307
|
+
logger.debug((s) => s.gray(msg.trimEnd()));
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
if (fportInfo.includes(`tcp:${currentPort} tcp:${currentPort}`)) {
|
|
311
|
+
yield exec(hdcPathStr, [
|
|
312
|
+
'fport',
|
|
313
|
+
'rm',
|
|
314
|
+
`tcp:${currentPort}`,
|
|
315
|
+
`tcp:${currentPort}`
|
|
316
|
+
]);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
yield exec(hdcPathStr, ['-t', deviceOrSimulatorName, 'shell', 'aa', 'force-stop', bundleName]);
|
|
320
|
+
try {
|
|
321
|
+
yield exec(hdcPathStr, ['-t', deviceOrSimulatorName, 'shell', 'mkdir', ohosTmpDirPath]);
|
|
322
|
+
let hapName = `${moduleName}-default-signed.hap`;
|
|
323
|
+
if (simulatorName !== 'undefined') {
|
|
324
|
+
hapName = `${moduleName}-default-unsigned.hap`;
|
|
325
|
+
}
|
|
326
|
+
yield exec(hdcPathStr, [
|
|
327
|
+
'-t',
|
|
328
|
+
deviceOrSimulatorName,
|
|
329
|
+
'file',
|
|
330
|
+
'send',
|
|
331
|
+
harmonyProjectPath
|
|
332
|
+
.copyWithNewSegment(moduleName, 'build', 'default', 'outputs', 'default', hapName)
|
|
333
|
+
.toString(),
|
|
334
|
+
ohosTmpDirPath,
|
|
335
|
+
]);
|
|
336
|
+
const installationResult = yield exec(hdcPathStr, [
|
|
337
|
+
'-t',
|
|
338
|
+
deviceOrSimulatorName,
|
|
339
|
+
'shell',
|
|
340
|
+
'bm',
|
|
341
|
+
'install',
|
|
342
|
+
'-p',
|
|
343
|
+
ohosTmpDirPath,
|
|
344
|
+
]);
|
|
345
|
+
if (installationResult.includes('failed to install')) {
|
|
346
|
+
throw new core_1.DescriptiveError({
|
|
347
|
+
whatHappened: 'Installation failed.',
|
|
348
|
+
whatCanUserDo: [
|
|
349
|
+
`If an application with the same bundle name is already installed, try uninstalling it:\n${hdcPathStr} shell bm uninstall -n ${bundleName}`,
|
|
350
|
+
],
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
finally {
|
|
355
|
+
yield exec(hdcPathStr, ['-t', deviceOrSimulatorName, 'shell', 'rm', '-rf', ohosTmpDirPath]);
|
|
356
|
+
}
|
|
357
|
+
yield exec(hdcPathStr, [
|
|
358
|
+
'-t',
|
|
359
|
+
deviceOrSimulatorName,
|
|
360
|
+
'shell',
|
|
361
|
+
'aa',
|
|
362
|
+
'start',
|
|
363
|
+
'-a',
|
|
364
|
+
abilityName,
|
|
365
|
+
'-b',
|
|
366
|
+
bundleName,
|
|
367
|
+
]);
|
|
368
|
+
yield tryRemoveForwardPorting();
|
|
369
|
+
yield exec(hdcPathStr, [
|
|
370
|
+
'-t',
|
|
371
|
+
deviceOrSimulatorName,
|
|
372
|
+
'rport',
|
|
373
|
+
`tcp:${currentPort}`,
|
|
374
|
+
`tcp:${currentPort}`
|
|
375
|
+
]);
|
|
376
|
+
}));
|
|
377
|
+
}
|
|
378
|
+
catch (err) {
|
|
379
|
+
if (err instanceof core_1.DescriptiveError) {
|
|
380
|
+
logger.descriptiveError(new core_1.DescriptiveError({
|
|
381
|
+
whatHappened: err.getMessage(),
|
|
382
|
+
whatCanUserDo: [
|
|
383
|
+
...err.getSuggestions(),
|
|
384
|
+
'Try building and running the app from DevEco studio.',
|
|
385
|
+
],
|
|
386
|
+
extraData: err.getRawData().extraData,
|
|
387
|
+
}));
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
throw err;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}),
|
|
394
|
+
};
|
|
395
|
+
function generateRandomString(length = 32) {
|
|
396
|
+
const chars = '0123456789abcdefghijklmnopqrstuvwxyz';
|
|
397
|
+
let result = '';
|
|
398
|
+
const randomValues = new Uint8Array(length);
|
|
399
|
+
node_crypto_1.default.getRandomValues(randomValues);
|
|
400
|
+
for (let i = 0; i < length; i++) {
|
|
401
|
+
const randomIndex = randomValues[i] % chars.length;
|
|
402
|
+
result += chars[randomIndex];
|
|
403
|
+
}
|
|
404
|
+
return result;
|
|
405
|
+
}
|
|
406
|
+
function trySetMetroPort(filePath, port) {
|
|
407
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
408
|
+
let content = yield fs_extra_1.default.readFile(filePath, 'utf-8');
|
|
409
|
+
const reFromServerIp = /MetroJSBundleProvider\.fromServerIp\(\s*"([^"]+)"\s*,\s*(\d+)\s*\)/;
|
|
410
|
+
if (reFromServerIp.test(content)) {
|
|
411
|
+
content = content.replace(reFromServerIp, (_match, host) => {
|
|
412
|
+
return `MetroJSBundleProvider.fromServerIp("${host}", ${port})`;
|
|
413
|
+
});
|
|
414
|
+
yield fs_extra_1.default.writeFile(filePath, content, 'utf-8');
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
const reNewProvider = /new\s+MetroJSBundleProvider\s*\(\s*\)/;
|
|
418
|
+
if (reNewProvider.test(content)) {
|
|
419
|
+
content = content.replace(reNewProvider, () => {
|
|
420
|
+
return `MetroJSBundleProvider.fromServerIp("localhost", ${port}),\n new MetroJSBundleProvider()`;
|
|
421
|
+
});
|
|
422
|
+
yield fs_extra_1.default.writeFile(filePath, content, 'utf-8');
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
throw new core_1.DescriptiveError({
|
|
426
|
+
whatHappened: `Unable to set the specified port [${port}] for the Metro server automatically.`,
|
|
427
|
+
whatCanUserDo: [
|
|
428
|
+
`Please manually add "MetroJSBundleProvider.fromServerIp("localhost", ${port})" in the "new AnyJSBundleProvider" section of your ${filePath} file.
|
|
429
|
+
e.g:
|
|
430
|
+
new AnyJSBundleProvider([
|
|
431
|
+
MetroJSBundleProvider.fromServerIp("localhost", ${port}),
|
|
432
|
+
new MetroJSBundleProvider(),
|
|
433
|
+
new ResourceJSBundleProvider(this.rnohCoreContext.uiAbilityContext.resourceManager, 'hermes_bundle.hbc'),
|
|
434
|
+
])`
|
|
435
|
+
],
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
}
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -44,8 +38,9 @@ exports.commandVerifyPackageHarmony = {
|
|
|
44
38
|
description: 'Disable har verification',
|
|
45
39
|
},
|
|
46
40
|
{
|
|
47
|
-
name: '--skip-checks <string
|
|
48
|
-
description: 'Disable certain checks by their names
|
|
41
|
+
name: '--skip-checks <string...>',
|
|
42
|
+
description: 'Disable certain checks by their names',
|
|
43
|
+
parse: (val, prev) => (prev ? [...prev, val] : [val]),
|
|
49
44
|
},
|
|
50
45
|
],
|
|
51
46
|
func: (argv, config, rawArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -98,17 +93,18 @@ exports.commandVerifyPackageHarmony = {
|
|
|
98
93
|
}),
|
|
99
94
|
};
|
|
100
95
|
function validateArgs(args) {
|
|
101
|
-
var _a;
|
|
102
96
|
if (!args.packagePath) {
|
|
103
97
|
throw new core_1.DescriptiveError({
|
|
104
98
|
whatHappened: 'package-path is undefined',
|
|
105
|
-
whatCanUserDo:
|
|
99
|
+
whatCanUserDo: ['Please provide --package-path'],
|
|
106
100
|
});
|
|
107
101
|
}
|
|
108
102
|
return {
|
|
109
103
|
packagePath: new core_1.AbsolutePath(args.packagePath),
|
|
110
104
|
hasHarmonyCode: args.harmonyCode,
|
|
111
|
-
checkNamesToSkip:
|
|
105
|
+
checkNamesToSkip: args.skipChecks.length === 1
|
|
106
|
+
? args.skipChecks[0].split(';')
|
|
107
|
+
: args.skipChecks,
|
|
112
108
|
};
|
|
113
109
|
}
|
|
114
110
|
function logCheckResult(loader, checkResult) {
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
4
|
};
|
|
@@ -35,6 +29,9 @@ class AbsolutePath {
|
|
|
35
29
|
}
|
|
36
30
|
return null;
|
|
37
31
|
}
|
|
32
|
+
getBasename() {
|
|
33
|
+
return node_path_1.default.basename(this.value);
|
|
34
|
+
}
|
|
38
35
|
getDirectoryPath() {
|
|
39
36
|
const dirPath = node_path_1.default.extname(this.value)
|
|
40
37
|
? node_path_1.default.dirname(this.value)
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
4
|
};
|
|
@@ -29,11 +23,9 @@ class CodegenConfig {
|
|
|
29
23
|
if (!node_fs_1.default.existsSync(specPath.getValue())) {
|
|
30
24
|
throw new DescriptiveError_1.DescriptiveError({
|
|
31
25
|
whatHappened: `No such file or directory: ${specPath.getValue()}`,
|
|
32
|
-
whatCanUserDo:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
],
|
|
36
|
-
},
|
|
26
|
+
whatCanUserDo: [
|
|
27
|
+
`Please verify "${packageName}/package.json::harmony::codegenConfig". If you are not the maintainer of this package, please report this problem to the package maintainer.`,
|
|
28
|
+
],
|
|
37
29
|
});
|
|
38
30
|
}
|
|
39
31
|
if (node_fs_1.default.lstatSync(specPath.getValue()).isDirectory()) {
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.DescriptiveError = void 0;
|
|
10
4
|
class DescriptiveError extends Error {
|
|
@@ -18,14 +12,18 @@ class DescriptiveError extends Error {
|
|
|
18
12
|
getMessage() {
|
|
19
13
|
return this.data.whatHappened;
|
|
20
14
|
}
|
|
21
|
-
|
|
15
|
+
getSuggestions() {
|
|
16
|
+
var _a;
|
|
22
17
|
if ('whatCanUserDo' in this.data) {
|
|
23
|
-
return this.data.whatCanUserDo;
|
|
18
|
+
return (_a = this.data.whatCanUserDo) !== null && _a !== void 0 ? _a : [];
|
|
24
19
|
}
|
|
25
20
|
else {
|
|
26
|
-
return
|
|
21
|
+
return [];
|
|
27
22
|
}
|
|
28
23
|
}
|
|
24
|
+
getRawData() {
|
|
25
|
+
return this.data;
|
|
26
|
+
}
|
|
29
27
|
getDetails() {
|
|
30
28
|
var _a;
|
|
31
29
|
if (!this.data.extraData) {
|
package/dist/core/FileSystem.js
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
4
|
};
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
4
|
-
*
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
4
|
};
|
package/dist/core/PackageJSON.js
CHANGED
|
@@ -9,12 +9,10 @@ class PackageJSON {
|
|
|
9
9
|
if (!fs.existsSync(packageJSONPath)) {
|
|
10
10
|
throw new DescriptiveError_1.DescriptiveError({
|
|
11
11
|
whatHappened: "Couldn't find 'package.json'",
|
|
12
|
-
whatCanUserDo:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
],
|
|
17
|
-
},
|
|
12
|
+
whatCanUserDo: [
|
|
13
|
+
'Check if the path to project root is correct',
|
|
14
|
+
'Try changing working directory to project root',
|
|
15
|
+
],
|
|
18
16
|
extraData: packageJSONPath.getValue(),
|
|
19
17
|
});
|
|
20
18
|
}
|
|
@@ -24,7 +22,6 @@ class PackageJSON {
|
|
|
24
22
|
catch (err) {
|
|
25
23
|
throw new DescriptiveError_1.DescriptiveError({
|
|
26
24
|
whatHappened: "Couldn't parse package.json",
|
|
27
|
-
whatCanUserDo: {},
|
|
28
25
|
extraData: { packageJSONPath, err },
|
|
29
26
|
});
|
|
30
27
|
}
|