@react-native-oh/react-native-harmony-cli 0.0.36 → 0.77.18-1
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/autolinking/Autolinking.js +13 -16
- 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 +0 -6
- package/dist/codegen/core/TypeAnnotationToTS.js +0 -6
- package/dist/codegen/core/UberSchema.js +2 -11
- package/dist/codegen/core/index.js +0 -6
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +2 -7
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +0 -6
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +0 -6
- package/dist/codegen/generators/CppComponentCodeGenerator.js +0 -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 +0 -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 +131 -36
- package/dist/commands/clean-harmony.js +84 -0
- package/dist/commands/codegen-harmony.js +0 -6
- package/dist/commands/codegen-lib-harmony.js +6 -12
- package/dist/commands/index.js +2 -9
- package/dist/commands/init-harmony.js +226 -0
- package/dist/commands/init.js +0 -0
- package/dist/commands/link-harmony.js +12 -16
- package/dist/commands/types.js +0 -6
- package/dist/commands/verify-package-harmony.js +6 -10
- package/dist/core/AbsolutePath.js +3 -6
- package/dist/core/CodegenConfig.js +0 -6
- package/dist/core/DescriptiveError.js +0 -6
- package/dist/core/FileSystem.js +0 -6
- package/dist/core/OHPackageJSON5.js +0 -6
- 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 +13 -6
- package/dist/core/index.js +0 -6
- package/dist/index.js +2 -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 +0 -6
- package/dist/io/Logger.js +0 -6
- package/dist/io/RealFS.js +10 -6
- package/dist/io/TarGz.js +2 -8
- package/dist/io/__fixtures__.js +0 -6
- package/dist/io/fsUtils.js +0 -6
- package/dist/io/index.js +1 -6
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +0 -6
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +0 -6
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +0 -6
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +0 -6
- 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 +1 -7
- package/harmony/rnoh-hvigor-plugin-0.77.18.tgz +0 -0
- package/jest.config.js +0 -7
- package/package.json +15 -18
- package/react-native.config.js +0 -7
- package/scripts/copy-template.js +18 -0
- package/src/autolinking/Autolinking.test.ts +54 -18
- package/src/autolinking/Autolinking.ts +23 -20
- 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 +0 -7
- package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -7
- package/src/codegen/core/TypeAnnotationToTS.ts +3 -8
- package/src/codegen/core/UberSchema.ts +3 -12
- package/src/codegen/core/index.ts +0 -7
- package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +5 -8
- package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -7
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -7
- package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -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 +0 -7
- 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 +174 -39
- package/src/commands/clean-harmony.ts +54 -0
- package/src/commands/codegen-harmony.ts +0 -7
- package/src/commands/codegen-lib-harmony.ts +6 -13
- package/src/commands/index.ts +2 -10
- package/src/commands/init-harmony.ts +299 -0
- package/src/commands/link-harmony.ts +13 -18
- package/src/commands/types.ts +0 -7
- package/src/commands/verify-package-harmony.ts +7 -10
- package/src/core/AbsolutePath.ts +4 -7
- package/src/core/CodegenConfig.ts +0 -7
- package/src/core/DescriptiveError.ts +0 -7
- package/src/core/FileSystem.ts +5 -8
- package/src/core/OHPackageJSON5.ts +0 -7
- package/src/core/PackageJSON.ts +0 -6
- 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 +13 -7
- package/src/core/index.ts +0 -7
- package/src/index.ts +4 -13
- 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 +1 -8
- package/src/io/Logger.ts +0 -7
- package/src/io/RealFS.ts +15 -8
- package/src/io/TarGz.ts +1 -8
- package/src/io/__fixtures__.ts +1 -8
- 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 +0 -7
- 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 -189
- 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 -238
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
modelVersion: '5.0.0',
|
|
3
|
+
dependencies: {
|
|
4
|
+
// "@rnoh/hvigor-plugin": "../../node_modules/<RNOH_CLI>/harmony/rnoh-hvigor-plugin-X.X.X.tgz",
|
|
5
|
+
},
|
|
6
|
+
execution: {
|
|
7
|
+
// "analyze": "default", /* Define the build analyze mode. Value: [ "default" | "verbose" | false ]. Default: "default" */
|
|
8
|
+
// "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
|
|
9
|
+
// "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
|
|
10
|
+
// "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
|
|
11
|
+
// "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
|
|
12
|
+
},
|
|
13
|
+
logging: {
|
|
14
|
+
// "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
|
|
15
|
+
},
|
|
16
|
+
debugging: {
|
|
17
|
+
// "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
|
|
18
|
+
},
|
|
19
|
+
nodeOptions: {
|
|
20
|
+
// "maxOldSpaceSize": 4096 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process */
|
|
21
|
+
},
|
|
22
|
+
}
|
package/src/io/CliExecutor.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import { AbsolutePath } from '../core';
|
|
9
2
|
import { spawn } from 'node:child_process';
|
|
10
3
|
|
|
@@ -66,4 +59,4 @@ export class RealCliExecutor extends CliExecutor {
|
|
|
66
59
|
});
|
|
67
60
|
});
|
|
68
61
|
}
|
|
69
|
-
}
|
|
62
|
+
}
|
package/src/io/Logger.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import chalk from 'chalk';
|
|
9
2
|
import { DescriptiveError } from '../core';
|
|
10
3
|
import { getLoader, logger as LOGGER } from '@react-native-community/cli-tools';
|
package/src/io/RealFS.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import { AbsolutePath } from '../core';
|
|
9
2
|
import { Dirent, FS } from '../core/FileSystem';
|
|
10
3
|
import fs, { Dirent as NodeFSDirent } from 'node:fs';
|
|
@@ -18,9 +11,19 @@ class RealFSDirent extends Dirent {
|
|
|
18
11
|
return this.nodeFSDirent.isDirectory();
|
|
19
12
|
}
|
|
20
13
|
|
|
14
|
+
isSymbolicLink(): boolean {
|
|
15
|
+
return this.nodeFSDirent.isSymbolicLink();
|
|
16
|
+
}
|
|
17
|
+
|
|
21
18
|
get name(): string {
|
|
22
19
|
return this.nodeFSDirent.name;
|
|
23
20
|
}
|
|
21
|
+
|
|
22
|
+
get path(): AbsolutePath {
|
|
23
|
+
return new AbsolutePath(this.nodeFSDirent.path).copyWithNewSegment(
|
|
24
|
+
this.nodeFSDirent.name
|
|
25
|
+
);
|
|
26
|
+
}
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
export class RealFS extends FS {
|
|
@@ -59,4 +62,8 @@ export class RealFS extends FS {
|
|
|
59
62
|
})
|
|
60
63
|
.map((rawDirent) => new RealFSDirent(rawDirent));
|
|
61
64
|
}
|
|
62
|
-
|
|
65
|
+
|
|
66
|
+
renameSync(oldPath: AbsolutePath, newPath: AbsolutePath) {
|
|
67
|
+
fs.renameSync(oldPath.toString(), newPath.toString());
|
|
68
|
+
}
|
|
69
|
+
}
|
package/src/io/TarGz.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import fs from 'node:fs';
|
|
9
|
-
import zlib from 'zlib';
|
|
2
|
+
import zlib from 'node:zlib';
|
|
10
3
|
import tar from 'tar';
|
|
11
4
|
import { AbsolutePath } from '../core';
|
|
12
5
|
|
package/src/io/__fixtures__.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import { AbsolutePath, DescriptiveError, Dirent, FS } from '../core';
|
|
9
2
|
import { CliExecutor, CliOptions } from './CliExecutor';
|
|
10
3
|
import { IFs, memfs, NestedDirectoryJSON } from 'memfs';
|
|
@@ -136,4 +129,4 @@ export class MockedLogger extends Logger {
|
|
|
136
129
|
getLogs() {
|
|
137
130
|
return this.logs;
|
|
138
131
|
}
|
|
139
|
-
}
|
|
132
|
+
}
|
package/src/io/fsUtils.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import pathUtils from 'node:path';
|
|
2
|
+
|
|
9
3
|
import { AbsolutePath } from '../core';
|
|
10
4
|
import { IFs } from 'memfs';
|
|
11
5
|
import MemDirent from 'memfs/lib/Dirent';
|
package/src/io/index.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
export * from './Logger';
|
|
9
2
|
export * from './fsUtils';
|
|
10
3
|
export * from './TarGz';
|
|
11
4
|
export * from './RealFS';
|
|
5
|
+
export * from './CliExecutor';
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import fs from 'node:fs';
|
|
9
2
|
import { AbsolutePath } from '../../core';
|
|
10
3
|
import { Check } from '../types';
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import fs from 'node:fs';
|
|
9
2
|
import { AbsolutePath } from '../../core';
|
|
10
3
|
import { Check } from '../types';
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import { Check } from '../types';
|
|
9
2
|
|
|
10
3
|
export function createNpmAndOhPackageVersionsAreEqualCheck(
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import { Check } from '../types';
|
|
9
2
|
|
|
10
3
|
export function createOhPackageNameFollowsNamingConventionCheck(
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
export * from './HarmonyDirExistsCheck';
|
|
9
2
|
export * from './HarmonyDirContainsOnlyHarsCheck';
|
|
10
3
|
export * from './NpmAnAndOhPackageVersionsAreEqual';
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
export type CheckStatus = 'pass' | 'fail' | 'skip';
|
|
9
2
|
|
|
10
3
|
export type Check = {
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the MIT license found in the
|
|
5
|
-
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
1
|
import fs from 'node:fs';
|
|
9
2
|
import tmp from 'tmp';
|
|
10
3
|
import {
|
package/tsconfig.build.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2024-2025 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
|
-
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.commandCreateMetroConstantsHarmony = void 0;
|
|
22
|
-
const node_os_1 = __importDefault(require("node:os"));
|
|
23
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
24
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
25
|
-
exports.commandCreateMetroConstantsHarmony = {
|
|
26
|
-
name: 'create-metro-host-constants-harmony',
|
|
27
|
-
description: 'Creates a Typescript file that exports constant with IP of the host machine. That IP is later used to connect to the Metro server from a physical device.',
|
|
28
|
-
options: [
|
|
29
|
-
{
|
|
30
|
-
name: '--output <string>',
|
|
31
|
-
description: 'Output file',
|
|
32
|
-
default: './harmony/entry/src/main/ets/codegen/MetroHostConstants.ts',
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
-
createMetroHostConstants(node_path_1.default.resolve(args.output));
|
|
37
|
-
}),
|
|
38
|
-
};
|
|
39
|
-
function createMetroHostConstants(outputPath) {
|
|
40
|
-
const networkInterfacesByName = node_os_1.default.networkInterfaces();
|
|
41
|
-
const getIP = () => {
|
|
42
|
-
var _a;
|
|
43
|
-
for (let name of Object.keys(networkInterfacesByName)) {
|
|
44
|
-
for (let net of (_a = networkInterfacesByName[name]) !== null && _a !== void 0 ? _a : []) {
|
|
45
|
-
// skip over non-ipv4 and internal (i.e. 127.0.0.1) addresses
|
|
46
|
-
if (net.family === 'IPv4' && !net.internal) {
|
|
47
|
-
return net.address;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return;
|
|
52
|
-
};
|
|
53
|
-
const ip = getIP();
|
|
54
|
-
const tsCode = [
|
|
55
|
-
'// This file is autogenerated. Do not modify it manually.',
|
|
56
|
-
'',
|
|
57
|
-
`export const METRO_SERVER_IP = '${ip}';\n`,
|
|
58
|
-
];
|
|
59
|
-
node_fs_1.default.writeFile(outputPath, tsCode.join('\n'), (err) => {
|
|
60
|
-
if (err) {
|
|
61
|
-
console.error(`Error writing to ${outputPath}:`, err);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
console.log(`Created file at ${outputPath}`);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2024-2025 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
|
-
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.commandPackHarmony = void 0;
|
|
22
|
-
const glob_1 = require("glob");
|
|
23
|
-
const path_1 = __importDefault(require("path"));
|
|
24
|
-
const tar_1 = __importDefault(require("tar"));
|
|
25
|
-
const fs_1 = __importDefault(require("fs"));
|
|
26
|
-
const core_1 = require("../core");
|
|
27
|
-
const ignore_1 = __importDefault(require("ignore"));
|
|
28
|
-
const json5_1 = __importDefault(require("json5"));
|
|
29
|
-
exports.commandPackHarmony = {
|
|
30
|
-
name: 'pack-harmony',
|
|
31
|
-
description: 'Pack native code. Used for package development.',
|
|
32
|
-
options: [
|
|
33
|
-
{
|
|
34
|
-
name: '--oh-module-path <string>',
|
|
35
|
-
description: 'Path to the OH module',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: '--harmony-dir-path <string>',
|
|
39
|
-
description: 'Path to the harmony dir',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: '--package-json-path <string>',
|
|
43
|
-
description: 'Path to the package.json',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
-
try {
|
|
48
|
-
yield pack(path_1.default.resolve(args.harmonyDirPath), path_1.default.resolve(args.ohModulePath), path_1.default.resolve(args.packageJsonPath));
|
|
49
|
-
}
|
|
50
|
-
catch (err) {
|
|
51
|
-
if (err instanceof core_1.ValidationError) {
|
|
52
|
-
console.error('[ERROR]', err.message);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
throw err;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}),
|
|
60
|
-
};
|
|
61
|
-
function pack(harmonyDirPath, ohModuleDirPath, packageJSONPath) {
|
|
62
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
syncVersions(packageJSONPath, path_1.default.join(ohModuleDirPath, 'oh-package.json5'));
|
|
64
|
-
if (!fs_1.default.existsSync(harmonyDirPath)) {
|
|
65
|
-
fs_1.default.mkdirSync(harmonyDirPath, { recursive: true });
|
|
66
|
-
}
|
|
67
|
-
yield createTGZFromDir(ohModuleDirPath, path_1.default.join(harmonyDirPath, `${path_1.default.parse(ohModuleDirPath).name}.tar.gz`));
|
|
68
|
-
yield createTGZFromDir(harmonyDirPath, path_1.default.join(path_1.default.dirname(harmonyDirPath), 'harmony.tar.gz'));
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function syncVersions(packageJSONFilePath, ohPackageJSONFilePath) {
|
|
72
|
-
const packageJSONFileContent = JSON.parse(fs_1.default.readFileSync(packageJSONFilePath, { encoding: 'utf-8' }));
|
|
73
|
-
if (fs_1.default.existsSync(ohPackageJSONFilePath)) {
|
|
74
|
-
const ohPackageJSONFileContent = json5_1.default.parse(fs_1.default.readFileSync(ohPackageJSONFilePath, { encoding: 'utf-8' }));
|
|
75
|
-
ohPackageJSONFileContent['version'] = packageJSONFileContent['version'];
|
|
76
|
-
fs_1.default.writeFileSync(ohPackageJSONFilePath, json5_1.default.stringify(ohPackageJSONFileContent, null, 2));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function createTGZFromDir(dirPath, outputFilePath) {
|
|
80
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
const ig = getIgnoreUtil(path_1.default.join(dirPath, '.tarignore'));
|
|
82
|
-
const filesToInclude = (0, glob_1.globSync)('**', {
|
|
83
|
-
cwd: dirPath,
|
|
84
|
-
nodir: true,
|
|
85
|
-
}).filter((path) => !ig.ignores(path));
|
|
86
|
-
yield createArchive(outputFilePath, dirPath, filesToInclude);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
function getIgnoreUtil(tarignorePath) {
|
|
90
|
-
if (!fs_1.default.existsSync(tarignorePath)) {
|
|
91
|
-
return (0, ignore_1.default)();
|
|
92
|
-
}
|
|
93
|
-
return (0, ignore_1.default)().add(fs_1.default.readFileSync(tarignorePath).toString());
|
|
94
|
-
}
|
|
95
|
-
function createArchive(outputFilePath, packageDirPath, filesToInclude) {
|
|
96
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
97
|
-
if (filesToInclude.length === 0) {
|
|
98
|
-
throw new core_1.ValidationError('Nothing to pack');
|
|
99
|
-
}
|
|
100
|
-
yield tar_1.default.c({
|
|
101
|
-
gzip: true,
|
|
102
|
-
file: outputFilePath,
|
|
103
|
-
cwd: packageDirPath,
|
|
104
|
-
}, filesToInclude);
|
|
105
|
-
});
|
|
106
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Copyright (c) 2024-2025 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
|
-
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.commandUnpackHarmony = void 0;
|
|
22
|
-
const io_1 = require("../io");
|
|
23
|
-
const path_1 = __importDefault(require("path"));
|
|
24
|
-
const fs_1 = __importDefault(require("fs"));
|
|
25
|
-
const zlib_1 = __importDefault(require("zlib"));
|
|
26
|
-
const tar_1 = __importDefault(require("tar"));
|
|
27
|
-
const json5_1 = __importDefault(require("json5"));
|
|
28
|
-
const core_1 = require("../core");
|
|
29
|
-
exports.commandUnpackHarmony = {
|
|
30
|
-
name: 'unpack-harmony',
|
|
31
|
-
description: 'Unpacks native code.',
|
|
32
|
-
options: [
|
|
33
|
-
{
|
|
34
|
-
name: '--project-root-path <path>',
|
|
35
|
-
description: 'Relative path to package root',
|
|
36
|
-
default: '.',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: '--output-dir <string>',
|
|
40
|
-
description: 'Output directory to which OH modules should be unpacked to',
|
|
41
|
-
default: './harmony/rnoh_modules',
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
func: (argv, config, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
|
-
try {
|
|
46
|
-
yield unpack(new core_1.AbsolutePath(args.projectRootPath), new core_1.AbsolutePath(args.outputDir));
|
|
47
|
-
}
|
|
48
|
-
catch (err) {
|
|
49
|
-
if (err instanceof core_1.ValidationError) {
|
|
50
|
-
console.error('[ERROR]', err.message);
|
|
51
|
-
process.exit(1);
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}),
|
|
58
|
-
};
|
|
59
|
-
function unpack(projectRootPath, outputDirPath) {
|
|
60
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const logger = new io_1.Logger();
|
|
62
|
-
const fs = new io_1.RealFS();
|
|
63
|
-
const projectDependenciesManager = new core_1.ProjectDependenciesManager(fs, projectRootPath);
|
|
64
|
-
logger.info((styles) => styles.bold(`Unpacking RNOH modules`));
|
|
65
|
-
let unpackedArchivesCount = 0;
|
|
66
|
-
let skippedArchivesCount = 0;
|
|
67
|
-
yield projectDependenciesManager.forEachAsync((dependency) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
const packageJSON = dependency.readPackageJSON();
|
|
69
|
-
const harmonyArchivePath = dependency
|
|
70
|
-
.getRootPath()
|
|
71
|
-
.copyWithNewSegment('harmony.tar.gz');
|
|
72
|
-
const pkgHarmonyDirPath = dependency
|
|
73
|
-
.getRootPath()
|
|
74
|
-
.copyWithNewSegment('harmony');
|
|
75
|
-
const harmonyTarGzPathStr = dependency
|
|
76
|
-
.getRootPath()
|
|
77
|
-
.copyWithNewSegment('harmony.tar.gz')
|
|
78
|
-
.relativeTo(projectRootPath)
|
|
79
|
-
.getValue();
|
|
80
|
-
if (packageJSON.version &&
|
|
81
|
-
shouldUnpack(harmonyArchivePath, pkgHarmonyDirPath, outputDirPath, packageJSON.version)) {
|
|
82
|
-
if (!fs.existsSync(pkgHarmonyDirPath)) {
|
|
83
|
-
/**
|
|
84
|
-
* After fresh install, harmony.tar.gz wasn't unpacked to harmony. Updating npm package should remove unpacked harmony dir.
|
|
85
|
-
*/
|
|
86
|
-
logger.info((styles) => `[${styles.cyan('unpacking')}] ${styles.gray(harmonyTarGzPathStr)}`);
|
|
87
|
-
yield unpackTarGz(harmonyArchivePath, pkgHarmonyDirPath);
|
|
88
|
-
unpackedArchivesCount++;
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
skippedArchivesCount++;
|
|
92
|
-
logger.info((styles) => `[${styles.yellow('skipped')}] ${styles.gray(harmonyTarGzPathStr)}`);
|
|
93
|
-
}
|
|
94
|
-
const ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
|
|
95
|
-
for (const ohModuleInfo of ohModulesInfo) {
|
|
96
|
-
const moduleArchivePathStr = dependency
|
|
97
|
-
.getRootPath()
|
|
98
|
-
.copyWithNewSegment('harmony', ohModuleInfo.archiveFileName)
|
|
99
|
-
.relativeTo(projectRootPath)
|
|
100
|
-
.getValue();
|
|
101
|
-
logger.info((styles) => `[${styles.cyan('unpacking')}] ${styles.gray(moduleArchivePathStr)}`);
|
|
102
|
-
unpackedArchivesCount++;
|
|
103
|
-
yield unpackTarGz(ohModuleInfo.archivePath, ohModuleInfo.computedModulePath);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
if (fs.existsSync(harmonyArchivePath)) {
|
|
108
|
-
skippedArchivesCount++;
|
|
109
|
-
logger.info((styles) => `[${styles.yellow('skipped')}] ${styles.gray(harmonyTarGzPathStr)}`);
|
|
110
|
-
}
|
|
111
|
-
const ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
|
|
112
|
-
for (const ohModuleInfo of ohModulesInfo) {
|
|
113
|
-
const moduleArchivePathStr = dependency
|
|
114
|
-
.getRootPath()
|
|
115
|
-
.copyWithNewSegment('harmony', ohModuleInfo.archiveFileName)
|
|
116
|
-
.relativeTo(projectRootPath)
|
|
117
|
-
.getValue();
|
|
118
|
-
skippedArchivesCount++;
|
|
119
|
-
logger.info((styles) => `[${styles.yellow('skipped')}] ${styles.gray(moduleArchivePathStr)}`);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}));
|
|
123
|
-
logger.info((styles) => `\nUnpacked: ${styles.cyan(unpackedArchivesCount)}, Skipped: ${styles.yellow(skippedArchivesCount)}`);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
function shouldUnpack(harmonyArchivePath, pkgHarmonyDirPath, outputDirPath, nodePackageVersion) {
|
|
127
|
-
if (!fs_1.default.existsSync(harmonyArchivePath.getValue()))
|
|
128
|
-
return false;
|
|
129
|
-
if (!fs_1.default.existsSync(pkgHarmonyDirPath.getValue()))
|
|
130
|
-
return true;
|
|
131
|
-
const ohModulesInfo = getOhModulesInfo(pkgHarmonyDirPath, outputDirPath);
|
|
132
|
-
for (const ohModuleInfo of ohModulesInfo) {
|
|
133
|
-
if (!fs_1.default.existsSync(ohModuleInfo.computedModulePath.getValue()) ||
|
|
134
|
-
getOhPackageVersion(ohModuleInfo.computedModulePath) !==
|
|
135
|
-
nodePackageVersion) {
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
function getOhPackageVersion(modulePath) {
|
|
142
|
-
const ohPackagePath = modulePath.copyWithNewSegment('oh-package.json5');
|
|
143
|
-
if (!fs_1.default.existsSync(ohPackagePath.getValue()))
|
|
144
|
-
return null;
|
|
145
|
-
const content = fs_1.default.readFileSync(ohPackagePath.getValue(), {
|
|
146
|
-
encoding: 'utf-8',
|
|
147
|
-
});
|
|
148
|
-
return json5_1.default.parse(content)['version'];
|
|
149
|
-
}
|
|
150
|
-
function getOhModulesInfo(pkgHarmonyDirPath, outputDirPath) {
|
|
151
|
-
const results = [];
|
|
152
|
-
if (!fs_1.default.existsSync(pkgHarmonyDirPath.getValue()))
|
|
153
|
-
return [];
|
|
154
|
-
const names = fs_1.default.readdirSync(pkgHarmonyDirPath.getValue());
|
|
155
|
-
for (const name of names) {
|
|
156
|
-
if (name.endsWith('.tar.gz')) {
|
|
157
|
-
const archivePath = pkgHarmonyDirPath.copyWithNewSegment(name);
|
|
158
|
-
const computedModuleName = path_1.default
|
|
159
|
-
.parse(archivePath.getValue())
|
|
160
|
-
.name.split('.')[0];
|
|
161
|
-
const computedModulePath = outputDirPath.copyWithNewSegment(computedModuleName);
|
|
162
|
-
results.push({
|
|
163
|
-
archivePath,
|
|
164
|
-
archiveFileName: name,
|
|
165
|
-
computedModulePath,
|
|
166
|
-
computedModuleName,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
return results;
|
|
171
|
-
}
|
|
172
|
-
function unpackTarGz(archivePath, outputDirPath) {
|
|
173
|
-
if (!fs_1.default.existsSync(outputDirPath.getValue())) {
|
|
174
|
-
fs_1.default.mkdirSync(outputDirPath.getValue(), { recursive: true });
|
|
175
|
-
}
|
|
176
|
-
const readStream = fs_1.default.createReadStream(archivePath.getValue());
|
|
177
|
-
const writeStream = tar_1.default.extract({
|
|
178
|
-
cwd: outputDirPath.getValue(),
|
|
179
|
-
});
|
|
180
|
-
readStream.pipe(zlib_1.default.createGunzip()).pipe(writeStream);
|
|
181
|
-
return new Promise((resolve, reject) => {
|
|
182
|
-
writeStream.on('finish', () => {
|
|
183
|
-
resolve(undefined);
|
|
184
|
-
});
|
|
185
|
-
writeStream.on('error', (err) => {
|
|
186
|
-
reject(err);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
189
|
-
}
|