@react-native-oh/react-native-harmony-cli 0.0.37 → 0.0.40-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/dist/autolinking/Autolinking.js +14 -11
- package/dist/codegen/generators/UberGeneratorV1.js +9 -2
- package/dist/codegen/generators/UberGeneratorV2.js +8 -1
- package/dist/commands/codegen-harmony.js +16 -5
- package/dist/commands/run-harmony.js +0 -2
- package/dist/core/ProjectDependenciesManager.js +5 -7
- package/dist/simulator/LaunchSimulator.js +9 -2
- package/harmony/rnoh-hvigor-plugin-0.3.0.tgz +0 -0
- package/package.json +10 -2
- package/.prettierrc +0 -6
- package/src/assetResolver.ts +0 -134
- package/src/autolinking/Autolinking.test.ts +0 -483
- package/src/autolinking/Autolinking.ts +0 -382
- package/src/autolinking/index.ts +0 -8
- package/src/codegen/core/CodeGenerator.ts +0 -16
- package/src/codegen/core/CodegenError.ts +0 -10
- package/src/codegen/core/EventUtils.ts +0 -23
- package/src/codegen/core/TypeAnnotationToTS.test.ts +0 -82
- package/src/codegen/core/TypeAnnotationToTS.ts +0 -195
- package/src/codegen/core/UberSchema.ts +0 -152
- package/src/codegen/core/index.ts +0 -12
- package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +0 -124
- package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +0 -128
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +0 -122
- package/src/codegen/generators/CppComponentCodeGenerator.ts +0 -95
- package/src/codegen/generators/LibGlueCodeGenerator.ts +0 -98
- package/src/codegen/generators/NativeModuleCodeGenerator.ts +0 -124
- package/src/codegen/generators/SharedComponentCodeGenerator.ts +0 -57
- package/src/codegen/generators/UberGeneratorV1.ts +0 -75
- package/src/codegen/generators/UberGeneratorV2.ts +0 -114
- package/src/codegen/generators/index.ts +0 -15
- package/src/codegen/index.ts +0 -9
- package/src/codegen/templates/BaseComponentInstanceHTemplate.ts +0 -128
- package/src/codegen/templates/BasePackageHTemplate.ts +0 -159
- package/src/codegen/templates/ComponentDescriptorHTemplate.ts +0 -63
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +0 -121
- package/src/codegen/templates/ComponentUtilsTSTemplate.ts +0 -222
- package/src/codegen/templates/IndexTSTemplate.ts +0 -62
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +0 -150
- package/src/codegen/templates/TurboModuleCppTemplate.ts +0 -61
- package/src/codegen/templates/TurboModuleHTemplate.ts +0 -42
- package/src/codegen/templates/TurboModuleSpecTSTemplate.ts +0 -101
- package/src/codegen/templates/index.ts +0 -16
- package/src/commands/bundle-harmony.ts +0 -134
- package/src/commands/codegen-harmony.ts +0 -297
- package/src/commands/codegen-lib-harmony.ts +0 -389
- package/src/commands/create-metro-host-constants.ts +0 -55
- package/src/commands/index.ts +0 -16
- package/src/commands/init.ts +0 -755
- package/src/commands/link-harmony.ts +0 -102
- package/src/commands/pack-harmony.ts +0 -128
- package/src/commands/run-harmony.ts +0 -506
- package/src/commands/types.ts +0 -21
- package/src/commands/unpack-harmony.ts +0 -238
- package/src/commands/verify-package-harmony.ts +0 -113
- package/src/core/AbsolutePath.ts +0 -66
- package/src/core/CodegenConfig.ts +0 -67
- package/src/core/DescriptiveError.ts +0 -68
- package/src/core/FileSystem.ts +0 -57
- package/src/core/OHPackageJSON5.ts +0 -30
- package/src/core/PackageJSON.ts +0 -104
- package/src/core/ProjectDependenciesManager.ts +0 -103
- package/src/core/ValidationError.ts +0 -8
- package/src/core/ValueObject.ts +0 -9
- package/src/core/fs.ts +0 -38
- package/src/core/index.ts +0 -17
- package/src/index.ts +0 -33
- package/src/io/CliExecutor.ts +0 -69
- package/src/io/Logger.ts +0 -112
- package/src/io/RealFS.ts +0 -62
- package/src/io/TarGz.ts +0 -33
- package/src/io/__fixtures__.ts +0 -139
- package/src/io/fsUtils.ts +0 -44
- package/src/io/index.ts +0 -11
- package/src/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.ts +0 -35
- package/src/package-verifier/checks/HarmonyDirExistsCheck.ts +0 -31
- package/src/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.ts +0 -25
- package/src/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.ts +0 -54
- package/src/package-verifier/checks/index.ts +0 -11
- package/src/package-verifier/index.ts +0 -9
- package/src/package-verifier/types.ts +0 -19
- package/src/package-verifier/verify-package.ts +0 -123
- package/src/simulator/LaunchSimulator.ts +0 -352
- package/src/simulator/index.ts +0 -8
|
@@ -1,102 +0,0 @@
|
|
|
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
|
-
import { Command } from './types';
|
|
9
|
-
import { AbsolutePath, DescriptiveError } from '../core';
|
|
10
|
-
import { Logger, RealFS } from '../io';
|
|
11
|
-
import { Autolinking } from '../autolinking';
|
|
12
|
-
|
|
13
|
-
const COMMAND_NAME = 'link-harmony';
|
|
14
|
-
|
|
15
|
-
export const commandLinkHarmony: Command = {
|
|
16
|
-
name: COMMAND_NAME,
|
|
17
|
-
description:
|
|
18
|
-
'Handles the automatic linking of RNOH libraries. This command is meant to be used by the RNOH HvigorPlugin.',
|
|
19
|
-
options: [
|
|
20
|
-
{
|
|
21
|
-
name: '--harmony-project-path <path>',
|
|
22
|
-
description: 'Specifies the root of your OpenHarmony project.',
|
|
23
|
-
default: './harmony',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: '--node-modules-path <path>',
|
|
27
|
-
description:
|
|
28
|
-
'Defines the path to the node_modules directory which holds npm packages.',
|
|
29
|
-
default: './node_modules',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: '--cmake-autolink-path-relative-to-harmony <path>',
|
|
33
|
-
description:
|
|
34
|
-
'Path relative to the root of your OpenHarmony project for the generated CMake file involved in autolinking.',
|
|
35
|
-
default: './entry/src/main/cpp/autolinking.cmake',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: '--cpp-rnoh-packages-factory-path-relative-to-harmony <path>',
|
|
39
|
-
description:
|
|
40
|
-
'Path relative to the root of your OpenHarmony project, for the generated file used to link packages on C++ side.',
|
|
41
|
-
default: './entry/src/main/cpp/RNOHPackagesFactory.h',
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: '--ets-rnoh-packages-factory-path-relative-to-harmony <path>',
|
|
45
|
-
description:
|
|
46
|
-
'Path relative to the root of your OpenHarmony project, for the generated file used to link packages on ETS side.',
|
|
47
|
-
default: './entry/src/main/ets/RNOHPackagesFactory.ets',
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
name: '--oh-package-path-relative-to-harmony <path>',
|
|
51
|
-
description:
|
|
52
|
-
'Path to the oh-package.json5 relative to the root of your OpenHarmony project.',
|
|
53
|
-
default: './oh-package.json5',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
name: '--exclude-npm-packages [string]',
|
|
57
|
-
description:
|
|
58
|
-
"Lists npm package names to be excluded from the autolinking process, separated by semicolons. By default every library is included. Can't be used with --included-npm-packages.",
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
name: '--include-npm-packages [string]',
|
|
62
|
-
description:
|
|
63
|
-
"Lists npm package names to be included from the autolinking process, separated by semicolons. By default every library is included. Can't be used with --excluded-npm-packages.",
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
func: async (_argv, _config, rawArgs: any) => {
|
|
67
|
-
const logger = new Logger();
|
|
68
|
-
const fs = new RealFS();
|
|
69
|
-
const autolinking = new Autolinking(fs, logger);
|
|
70
|
-
try {
|
|
71
|
-
const config = await autolinking.prepareInput({
|
|
72
|
-
harmonyProjectPath: new AbsolutePath(rawArgs.harmonyProjectPath),
|
|
73
|
-
nodeModulesPath: new AbsolutePath(rawArgs.nodeModulesPath),
|
|
74
|
-
cmakeAutolinkPathRelativeToHarmony:
|
|
75
|
-
rawArgs.cmakeAutolinkPathRelativeToHarmony,
|
|
76
|
-
cppRNOHPackagesFactoryPathRelativeToHarmony:
|
|
77
|
-
rawArgs.cppRnohPackagesFactoryPathRelativeToHarmony,
|
|
78
|
-
etsRNOHPackagesFactoryPathRelativeToHarmony:
|
|
79
|
-
rawArgs.etsRnohPackagesFactoryPathRelativeToHarmony,
|
|
80
|
-
ohPackagePathRelativeToHarmony: rawArgs.ohPackagePathRelativeToHarmony,
|
|
81
|
-
excludedNpmPackageNames: new Set(
|
|
82
|
-
rawArgs.excludeNpmPackages
|
|
83
|
-
? (rawArgs.excludeNpmPackages ?? '').split(';')
|
|
84
|
-
: undefined
|
|
85
|
-
),
|
|
86
|
-
includedNpmPackageNames: new Set(
|
|
87
|
-
rawArgs.includeNpmPackages
|
|
88
|
-
? (rawArgs.includeNpmPackages ?? '').split(';')
|
|
89
|
-
: undefined
|
|
90
|
-
),
|
|
91
|
-
});
|
|
92
|
-
const result = autolinking.evaluate(config);
|
|
93
|
-
autolinking.saveAndLogOutput(result);
|
|
94
|
-
} catch (err) {
|
|
95
|
-
if (err instanceof DescriptiveError && !err.isUnexpected()) {
|
|
96
|
-
logger.descriptiveError(err);
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
throw err;
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
};
|
|
@@ -1,128 +0,0 @@
|
|
|
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
|
-
import { Command } from './types';
|
|
9
|
-
import { globSync } from 'glob';
|
|
10
|
-
import pathUtils from 'path';
|
|
11
|
-
import tar from 'tar';
|
|
12
|
-
import fs from 'fs';
|
|
13
|
-
import { ValidationError } from '../core';
|
|
14
|
-
import ignore, { Ignore } from 'ignore';
|
|
15
|
-
import JSON5 from 'json5';
|
|
16
|
-
|
|
17
|
-
export const commandPackHarmony: Command = {
|
|
18
|
-
name: 'pack-harmony',
|
|
19
|
-
description: 'Pack native code. Used for package development.',
|
|
20
|
-
options: [
|
|
21
|
-
{
|
|
22
|
-
name: '--oh-module-path <string>',
|
|
23
|
-
description: 'Path to the OH module',
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: '--harmony-dir-path <string>',
|
|
27
|
-
description: 'Path to the harmony dir',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: '--package-json-path <string>',
|
|
31
|
-
description: 'Path to the package.json',
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
func: async (argv, config, args: any) => {
|
|
35
|
-
try {
|
|
36
|
-
await pack(
|
|
37
|
-
pathUtils.resolve(args.harmonyDirPath),
|
|
38
|
-
pathUtils.resolve(args.ohModulePath),
|
|
39
|
-
pathUtils.resolve(args.packageJsonPath)
|
|
40
|
-
);
|
|
41
|
-
} catch (err) {
|
|
42
|
-
if (err instanceof ValidationError) {
|
|
43
|
-
console.error('[ERROR]', err.message);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
} else {
|
|
46
|
-
throw err;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
async function pack(
|
|
53
|
-
harmonyDirPath: string,
|
|
54
|
-
ohModuleDirPath: string,
|
|
55
|
-
packageJSONPath: string
|
|
56
|
-
) {
|
|
57
|
-
syncVersions(
|
|
58
|
-
packageJSONPath,
|
|
59
|
-
pathUtils.join(ohModuleDirPath, 'oh-package.json5')
|
|
60
|
-
);
|
|
61
|
-
if (!fs.existsSync(harmonyDirPath)) {
|
|
62
|
-
fs.mkdirSync(harmonyDirPath, { recursive: true });
|
|
63
|
-
}
|
|
64
|
-
await createTGZFromDir(
|
|
65
|
-
ohModuleDirPath,
|
|
66
|
-
pathUtils.join(
|
|
67
|
-
harmonyDirPath,
|
|
68
|
-
`${pathUtils.parse(ohModuleDirPath).name}.tar.gz`
|
|
69
|
-
)
|
|
70
|
-
);
|
|
71
|
-
await createTGZFromDir(
|
|
72
|
-
harmonyDirPath,
|
|
73
|
-
pathUtils.join(pathUtils.dirname(harmonyDirPath), 'harmony.tar.gz')
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function syncVersions(
|
|
78
|
-
packageJSONFilePath: string,
|
|
79
|
-
ohPackageJSONFilePath: string
|
|
80
|
-
) {
|
|
81
|
-
const packageJSONFileContent = JSON.parse(
|
|
82
|
-
fs.readFileSync(packageJSONFilePath, { encoding: 'utf-8' })
|
|
83
|
-
);
|
|
84
|
-
if (fs.existsSync(ohPackageJSONFilePath)) {
|
|
85
|
-
const ohPackageJSONFileContent = JSON5.parse(
|
|
86
|
-
fs.readFileSync(ohPackageJSONFilePath, { encoding: 'utf-8' })
|
|
87
|
-
);
|
|
88
|
-
ohPackageJSONFileContent['version'] = packageJSONFileContent['version'];
|
|
89
|
-
fs.writeFileSync(
|
|
90
|
-
ohPackageJSONFilePath,
|
|
91
|
-
JSON5.stringify(ohPackageJSONFileContent, null, 2)
|
|
92
|
-
);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async function createTGZFromDir(dirPath: string, outputFilePath: string) {
|
|
97
|
-
const ig = getIgnoreUtil(pathUtils.join(dirPath, '.tarignore'));
|
|
98
|
-
const filesToInclude = globSync('**', {
|
|
99
|
-
cwd: dirPath,
|
|
100
|
-
nodir: true,
|
|
101
|
-
}).filter((path) => !ig.ignores(path));
|
|
102
|
-
await createArchive(outputFilePath, dirPath, filesToInclude);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function getIgnoreUtil(tarignorePath: string): Ignore {
|
|
106
|
-
if (!fs.existsSync(tarignorePath)) {
|
|
107
|
-
return ignore();
|
|
108
|
-
}
|
|
109
|
-
return ignore().add(fs.readFileSync(tarignorePath).toString());
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async function createArchive(
|
|
113
|
-
outputFilePath: string,
|
|
114
|
-
packageDirPath: string,
|
|
115
|
-
filesToInclude: string[]
|
|
116
|
-
) {
|
|
117
|
-
if (filesToInclude.length === 0) {
|
|
118
|
-
throw new ValidationError('Nothing to pack');
|
|
119
|
-
}
|
|
120
|
-
await tar.c(
|
|
121
|
-
{
|
|
122
|
-
gzip: true,
|
|
123
|
-
file: outputFilePath,
|
|
124
|
-
cwd: packageDirPath,
|
|
125
|
-
},
|
|
126
|
-
filesToInclude
|
|
127
|
-
);
|
|
128
|
-
}
|