@react-native-oh/react-native-harmony-cli 0.0.30 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assetResolver.js +105 -10
- package/dist/autolinking/Autolinking.js +9 -11
- package/dist/codegen/core/EventUtils.js +5 -8
- package/dist/codegen/core/TypeAnnotationToTS.js +3 -3
- package/dist/codegen/core/UberSchema.js +7 -11
- package/dist/codegen/generators/AppBuildTimeGlueCodeGenerator.js +2 -1
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorArkTS.js +3 -0
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +3 -0
- package/dist/codegen/generators/CppComponentCodeGenerator.js +3 -0
- package/dist/codegen/generators/LibGlueCodeGenerator.js +2 -2
- package/dist/codegen/templates/BasePackageHTemplate.js +12 -1
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +15 -0
- package/dist/codegen/templates/RNOHGeneratedPackageHTemplate.js +12 -1
- package/dist/commands/bundle-harmony.js +4 -67
- package/dist/commands/codegen-harmony.js +13 -17
- package/dist/commands/codegen-lib-harmony.js +10 -14
- package/dist/commands/create-metro-host-constants.js +1 -1
- package/dist/commands/index.js +2 -1
- package/dist/commands/init.js +703 -0
- package/dist/commands/link-harmony.js +1 -1
- package/dist/commands/pack-harmony.js +1 -1
- package/dist/commands/run-harmony.js +462 -0
- package/dist/commands/types.js +8 -0
- package/dist/commands/unpack-harmony.js +2 -4
- package/dist/commands/verify-package-harmony.js +2 -2
- package/dist/core/CodegenConfig.js +4 -6
- package/dist/core/DescriptiveError.js +8 -4
- package/dist/core/PackageJSON.js +4 -7
- package/dist/core/fs.js +4 -5
- package/dist/index.js +2 -1
- package/dist/io/CliExecutor.js +57 -24
- package/dist/io/Logger.js +72 -42
- package/dist/io/TarGz.js +1 -2
- package/dist/io/__fixtures__.js +9 -3
- package/dist/io/fsUtils.js +1 -2
- package/dist/package-verifier/checks/HarmonyDirContainsOnlyHarsCheck.js +1 -2
- package/dist/package-verifier/checks/HarmonyDirExistsCheck.js +1 -2
- package/dist/package-verifier/checks/NpmAnAndOhPackageVersionsAreEqual.js +1 -2
- package/dist/package-verifier/checks/OhPackageNameFollowsNamingConventionCheck.js +1 -2
- package/dist/package-verifier/verify-package.js +7 -10
- package/dist/simulator/LaunchSimulator.js +311 -0
- package/dist/simulator/index.js +23 -0
- package/package.json +13 -6
- package/src/assetResolver.ts +117 -11
- package/src/autolinking/Autolinking.ts +10 -12
- package/src/codegen/core/EventUtils.ts +4 -6
- package/src/codegen/core/UberSchema.ts +7 -11
- package/src/codegen/generators/AppBuildTimeGlueCodeGenerator.ts +5 -1
- package/src/codegen/generators/ArkTSComponentCodeGeneratorArkTS.ts +3 -0
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +3 -0
- package/src/codegen/generators/CppComponentCodeGenerator.ts +3 -0
- package/src/codegen/generators/LibGlueCodeGenerator.ts +2 -2
- package/src/codegen/templates/BasePackageHTemplate.ts +13 -1
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +24 -1
- package/src/codegen/templates/RNOHGeneratedPackageHTemplate.ts +13 -1
- package/src/commands/bundle-harmony.ts +6 -81
- package/src/commands/codegen-harmony.ts +14 -19
- package/src/commands/codegen-lib-harmony.ts +11 -16
- package/src/commands/create-metro-host-constants.ts +2 -2
- package/src/commands/index.ts +2 -1
- package/src/commands/init.ts +755 -0
- package/src/commands/link-harmony.ts +2 -2
- package/src/commands/pack-harmony.ts +2 -2
- package/src/commands/run-harmony.ts +506 -0
- package/src/commands/types.ts +21 -0
- package/src/commands/unpack-harmony.ts +3 -5
- package/src/commands/verify-package-harmony.ts +3 -3
- package/src/core/CodegenConfig.ts +4 -6
- package/src/core/DescriptiveError.ts +9 -9
- package/src/core/PackageJSON.ts +5 -8
- package/src/core/fs.ts +2 -2
- package/src/index.ts +5 -3
- package/src/io/CliExecutor.ts +56 -34
- package/src/io/Logger.ts +78 -45
- package/src/io/__fixtures__.ts +15 -11
- package/src/package-verifier/verify-package.ts +5 -7
- package/src/simulator/LaunchSimulator.ts +352 -0
- package/src/simulator/index.ts +8 -0
|
@@ -74,6 +74,9 @@ export class ArkTSComponentCodeGeneratorArkTS implements SpecCodeGenerator {
|
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
shape.commands.forEach((command) => {
|
|
77
|
+
componentJSIBinderHTemplate.addCommand({
|
|
78
|
+
name: command.name,
|
|
79
|
+
});
|
|
77
80
|
componentUtilsTSTemplate.addCommand({
|
|
78
81
|
name: command.name,
|
|
79
82
|
argsTSType:
|
|
@@ -63,6 +63,9 @@ export class CppComponentCodeGenerator implements CodeGenerator<LibraryData> {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
shape.commands.forEach((command) => {
|
|
66
|
+
componentJSIBinderHTemplate.addCommand({
|
|
67
|
+
name: command.name,
|
|
68
|
+
});
|
|
66
69
|
componentInstanceSpecHTemplate.addCommand({
|
|
67
70
|
name: command.name,
|
|
68
71
|
args: command.typeAnnotation.params.map((param) => ({
|
|
@@ -57,13 +57,13 @@ export class LibGlueCodeGenerator implements CodeGenerator<LibGlueCodeData> {
|
|
|
57
57
|
});
|
|
58
58
|
arkTSComponents.forEach(({ componentName, eventNames }) => {
|
|
59
59
|
components_indexTS.addReexport({ from: `./${componentName}` });
|
|
60
|
-
basePackageTemplate.addComponent({ name: componentName, libraryCppName });
|
|
60
|
+
basePackageTemplate.addComponent({ name: componentName, libraryCppName, isArkTSComponent: true });
|
|
61
61
|
eventNames.forEach((eventName) =>
|
|
62
62
|
basePackageTemplate.addArkTSEvent({ name: eventName })
|
|
63
63
|
);
|
|
64
64
|
});
|
|
65
65
|
cppComponents.forEach(({ componentName }) => {
|
|
66
|
-
basePackageTemplate.addComponent({ name: componentName, libraryCppName });
|
|
66
|
+
basePackageTemplate.addComponent({ name: componentName, libraryCppName, isArkTSComponent: false });
|
|
67
67
|
});
|
|
68
68
|
fileContentByPath.set(
|
|
69
69
|
this.cppOutputPath.copyWithNewSegment(
|
|
@@ -46,16 +46,26 @@ class {{name}}EventEmitRequestHandler : public EventEmitRequestHandler {
|
|
|
46
46
|
public:
|
|
47
47
|
void handleEvent(Context const &ctx) override {
|
|
48
48
|
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
49
|
+
auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
|
|
50
|
+
|
|
49
51
|
if (eventEmitter == nullptr) {
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
52
54
|
|
|
55
|
+
std::vector<std::string> supportedComponentNames = {
|
|
56
|
+
{{#arkTSComponents}}
|
|
57
|
+
"{{name}}",
|
|
58
|
+
{{/arkTSComponents}}
|
|
59
|
+
};
|
|
60
|
+
|
|
53
61
|
std::vector<std::string> supportedEventNames = {
|
|
54
62
|
{{#arkTSEvents}}
|
|
55
63
|
"{{name}}",
|
|
56
64
|
{{/arkTSEvents}}
|
|
57
65
|
};
|
|
58
|
-
|
|
66
|
+
|
|
67
|
+
if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
|
|
68
|
+
std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
59
69
|
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
60
70
|
}
|
|
61
71
|
}
|
|
@@ -103,6 +113,7 @@ type GeneratedPackageTurboModule = {
|
|
|
103
113
|
type GeneratedPackageComponent = {
|
|
104
114
|
name: string;
|
|
105
115
|
libraryCppName: string;
|
|
116
|
+
isArkTSComponent: boolean;
|
|
106
117
|
};
|
|
107
118
|
|
|
108
119
|
type ArkTSEvent = {
|
|
@@ -138,6 +149,7 @@ export class BasePackageHTemplate {
|
|
|
138
149
|
name: this.name,
|
|
139
150
|
turboModules: this.turboModules,
|
|
140
151
|
components: this.components,
|
|
152
|
+
arkTSComponents: this.components.filter((component) => component.isArkTSComponent),
|
|
141
153
|
arkTSEvents: this.arkTSEvents,
|
|
142
154
|
libraries: Array.from(this.libraryCppNames).map((name) => ({
|
|
143
155
|
name,
|
|
@@ -28,6 +28,14 @@ class {{name}}JSIBinder : public ViewComponentJSIBinder {
|
|
|
28
28
|
return object;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
facebook::jsi::Object createCommands(facebook::jsi::Runtime &rt) override {
|
|
32
|
+
auto commands = ViewComponentJSIBinder::createCommands(rt);
|
|
33
|
+
{{#commands}}
|
|
34
|
+
commands.setProperty(rt, "{{name}}", "{{name}}");
|
|
35
|
+
{{/commands}}
|
|
36
|
+
return commands;
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override {
|
|
32
40
|
facebook::jsi::Object events(rt);
|
|
33
41
|
{{#bubblingEvents}}
|
|
@@ -52,6 +60,10 @@ type ComponentJSIBinderHProp = {
|
|
|
52
60
|
isObject: boolean;
|
|
53
61
|
};
|
|
54
62
|
|
|
63
|
+
type ComponentJSIBinderHCommand = {
|
|
64
|
+
name: string;
|
|
65
|
+
};
|
|
66
|
+
|
|
55
67
|
type ComponentJSIBinderHEvent = {
|
|
56
68
|
type: 'direct' | 'bubble';
|
|
57
69
|
eventHandlerName: string;
|
|
@@ -59,14 +71,22 @@ type ComponentJSIBinderHEvent = {
|
|
|
59
71
|
|
|
60
72
|
export class ComponentJSIBinderHTemplate {
|
|
61
73
|
private props: ComponentJSIBinderHProp[] = [];
|
|
74
|
+
private commands: ComponentJSIBinderHCommand[] = [];
|
|
62
75
|
private events: ComponentJSIBinderHEvent[] = [];
|
|
63
76
|
|
|
64
|
-
constructor(
|
|
77
|
+
constructor(
|
|
78
|
+
private name: string,
|
|
79
|
+
private codegenNoticeLines: string[]
|
|
80
|
+
) {}
|
|
65
81
|
|
|
66
82
|
addProp(prop: ComponentJSIBinderHProp) {
|
|
67
83
|
this.props.push(prop);
|
|
68
84
|
}
|
|
69
85
|
|
|
86
|
+
addCommand(command: ComponentJSIBinderHCommand) {
|
|
87
|
+
this.commands.push(command);
|
|
88
|
+
}
|
|
89
|
+
|
|
70
90
|
addEvent(event: ComponentJSIBinderHEvent) {
|
|
71
91
|
this.events.push(event);
|
|
72
92
|
}
|
|
@@ -81,6 +101,9 @@ export class ComponentJSIBinderHTemplate {
|
|
|
81
101
|
name: prop.name,
|
|
82
102
|
type: prop.isObject ? '"Object"' : 'true',
|
|
83
103
|
})),
|
|
104
|
+
commands: this.commands.map((command) => ({
|
|
105
|
+
name: command.name,
|
|
106
|
+
})),
|
|
84
107
|
bubblingEvents: this.events
|
|
85
108
|
.filter((event) => event.type === 'bubble')
|
|
86
109
|
.map((event) => ({
|
|
@@ -49,16 +49,26 @@ class GeneratedEventEmitRequestHandler : public EventEmitRequestHandler {
|
|
|
49
49
|
public:
|
|
50
50
|
void handleEvent(Context const &ctx) override {
|
|
51
51
|
auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<facebook::react::EventEmitter>(ctx.tag);
|
|
52
|
+
auto componentName = ctx.shadowViewRegistry->getComponentName(ctx.tag);
|
|
53
|
+
|
|
52
54
|
if (eventEmitter == nullptr) {
|
|
53
55
|
return;
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
std::vector<std::string> supportedComponentNames = {
|
|
59
|
+
{{#arkTSComponents}}
|
|
60
|
+
"{{name}}",
|
|
61
|
+
{{/arkTSComponents}}
|
|
62
|
+
};
|
|
63
|
+
|
|
56
64
|
std::vector<std::string> supportedEventNames = {
|
|
57
65
|
{{#supportedEvents}}
|
|
58
66
|
"{{name}}",
|
|
59
67
|
{{/supportedEvents}}
|
|
60
68
|
};
|
|
61
|
-
|
|
69
|
+
|
|
70
|
+
if (std::find(supportedComponentNames.begin(), supportedComponentNames.end(), componentName) != supportedComponentNames.end() &&
|
|
71
|
+
std::find(supportedEventNames.begin(), supportedEventNames.end(), ctx.eventName) != supportedEventNames.end()) {
|
|
62
72
|
eventEmitter->dispatchEvent(ctx.eventName, ArkJS(ctx.env).getDynamic(ctx.payload));
|
|
63
73
|
}
|
|
64
74
|
}
|
|
@@ -105,6 +115,7 @@ type RNOHGeneratedPackageTurboModule = {
|
|
|
105
115
|
type RNOHGeneratedPackageComponent = {
|
|
106
116
|
name: string;
|
|
107
117
|
supportedEventNames: string[];
|
|
118
|
+
isArkTSComponent: boolean;
|
|
108
119
|
};
|
|
109
120
|
|
|
110
121
|
export class RNOHGeneratedPackageHTemplate {
|
|
@@ -130,6 +141,7 @@ export class RNOHGeneratedPackageHTemplate {
|
|
|
130
141
|
return mustache.render(TEMPLATE.trimStart(), {
|
|
131
142
|
turboModules: this.turboModules,
|
|
132
143
|
components: this.components,
|
|
144
|
+
arkTSComponents: this.components.filter((component) => component.isArkTSComponent),
|
|
133
145
|
supportedEvents: this.supportedEventNames.map((eventName) => ({
|
|
134
146
|
name: eventName,
|
|
135
147
|
})),
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
2
|
+
* Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Command } from '
|
|
8
|
+
import { Command } from './types';
|
|
9
9
|
import fs from 'fs';
|
|
10
10
|
import fse from 'fs-extra';
|
|
11
11
|
import Metro from 'metro';
|
|
12
12
|
import { RunBuildOptions as BuildOptions } from 'metro';
|
|
13
13
|
import MetroServer from 'metro/src/Server';
|
|
14
14
|
import pathUtils from 'path';
|
|
15
|
-
import {
|
|
15
|
+
import { copyAssets } from '../assetResolver';
|
|
16
16
|
import { ConfigT as MetroConfig } from 'metro-config';
|
|
17
|
+
import { Logger } from '../io';
|
|
17
18
|
|
|
18
19
|
const ARK_RESOURCE_PATH = './harmony/entry/src/main/resources/rawfile';
|
|
19
20
|
const ASSETS_DEFAULT_DEST_PATH =
|
|
@@ -68,6 +69,7 @@ export const commandBundleHarmony: Command = {
|
|
|
68
69
|
},
|
|
69
70
|
],
|
|
70
71
|
func: async (argv, config, args: any) => {
|
|
72
|
+
const logger = new Logger();
|
|
71
73
|
const buildOptions: BuildOptions = {
|
|
72
74
|
entry: args.entryFile,
|
|
73
75
|
platform: 'harmony',
|
|
@@ -80,7 +82,7 @@ export const commandBundleHarmony: Command = {
|
|
|
80
82
|
const bundle = await createBundle(metroConfig, buildOptions);
|
|
81
83
|
await saveBundle(bundle, args.bundleOutput, args.sourcemapOutput);
|
|
82
84
|
const assets = await retrieveAssetsData(metroConfig, buildOptions);
|
|
83
|
-
copyAssets(assets, args.assetsDest);
|
|
85
|
+
copyAssets(logger, assets, args.assetsDest);
|
|
84
86
|
},
|
|
85
87
|
};
|
|
86
88
|
|
|
@@ -130,80 +132,3 @@ async function retrieveAssetsData(
|
|
|
130
132
|
metroServer.end();
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
|
|
134
|
-
async function copyAssets(
|
|
135
|
-
assetsData: readonly AssetData[],
|
|
136
|
-
assetsDest: Path
|
|
137
|
-
): Promise<void> {
|
|
138
|
-
if (assetsDest == null) {
|
|
139
|
-
console.warn('Assets destination folder is not set, skipping...');
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
await fse.ensureDir(assetsDest);
|
|
143
|
-
const fileDestBySrc: Record<Path, Path> = {};
|
|
144
|
-
for (const asset of assetsData) {
|
|
145
|
-
const idx = getHighestQualityFileIdx(asset);
|
|
146
|
-
fileDestBySrc[asset.files[idx]] = pathUtils.join(
|
|
147
|
-
assetsDest,
|
|
148
|
-
getAssetDestRelativePath(asset)
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
return copyFiles(fileDestBySrc);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function getHighestQualityFileIdx(assetData: AssetData): number {
|
|
155
|
-
let result = 0;
|
|
156
|
-
let maxScale = -1;
|
|
157
|
-
for (let idx = 0; idx < assetData.scales.length; idx++) {
|
|
158
|
-
const scale = assetData.scales[idx];
|
|
159
|
-
if (scale > maxScale) {
|
|
160
|
-
maxScale = scale;
|
|
161
|
-
result = idx;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return result;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
function copyFiles(fileDestBySrc: Record<Path, Path>) {
|
|
168
|
-
const fileSources = Object.keys(fileDestBySrc);
|
|
169
|
-
if (fileSources.length === 0) {
|
|
170
|
-
return Promise.resolve();
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
console.info(`Copying ${fileSources.length} asset files`);
|
|
174
|
-
return new Promise<void>((resolve, reject) => {
|
|
175
|
-
const copyNext = (error?: Error) => {
|
|
176
|
-
if (error) {
|
|
177
|
-
reject(error);
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
if (fileSources.length === 0) {
|
|
181
|
-
console.info('Done copying assets');
|
|
182
|
-
resolve();
|
|
183
|
-
} else {
|
|
184
|
-
// fileSources.length === 0 is checked in previous branch, so this is string
|
|
185
|
-
const src = fileSources.shift()!;
|
|
186
|
-
const dest = fileDestBySrc[src];
|
|
187
|
-
copyFile(src, dest, copyNext);
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
copyNext();
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
function copyFile(
|
|
195
|
-
src: string,
|
|
196
|
-
dest: string,
|
|
197
|
-
onFinished: (error?: Error) => void
|
|
198
|
-
): void {
|
|
199
|
-
const destDir = pathUtils.dirname(dest);
|
|
200
|
-
fs.mkdir(destDir, { recursive: true }, (err?) => {
|
|
201
|
-
if (err) {
|
|
202
|
-
onFinished(err);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
fs.createReadStream(src)
|
|
206
|
-
.pipe(fs.createWriteStream(dest))
|
|
207
|
-
.on('finish', onFinished);
|
|
208
|
-
});
|
|
209
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
2
|
+
* Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import pathUtils from 'node:path';
|
|
9
9
|
import Case from 'case';
|
|
10
|
-
import { Command } from '
|
|
10
|
+
import { Command } from './types';
|
|
11
11
|
import {
|
|
12
12
|
AbsolutePath,
|
|
13
13
|
DescriptiveError,
|
|
@@ -169,11 +169,9 @@ function validateArgs(args: any) {
|
|
|
169
169
|
if (!args.rnohModulePath) {
|
|
170
170
|
throw new DescriptiveError({
|
|
171
171
|
whatHappened: "--rnoh-module-path argument wasn't provided",
|
|
172
|
-
whatCanUserDo:
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
],
|
|
176
|
-
},
|
|
172
|
+
whatCanUserDo: [
|
|
173
|
+
'Please provide a path to the native React Native for Open Harmony module (rnoh) which is probably located somewhere in "<PROJECT_ROOT>/harmony" directory',
|
|
174
|
+
],
|
|
177
175
|
});
|
|
178
176
|
}
|
|
179
177
|
}
|
|
@@ -222,12 +220,10 @@ function throwErrorIfUnsupportedCodegenVersion(
|
|
|
222
220
|
if (codegenVersion > maxSupportedCodegenVersion) {
|
|
223
221
|
throw new CodegenError({
|
|
224
222
|
whatHappened: `Package "${packageName}" requires codegenVersion: ${codegenVersion}, which is not supported (maxSupportedCodegenVersion=${maxSupportedCodegenVersion}).`,
|
|
225
|
-
whatCanUserDo:
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
],
|
|
230
|
-
},
|
|
223
|
+
whatCanUserDo: [
|
|
224
|
+
`Try downgrading "${packageName}".`,
|
|
225
|
+
'Update the "@react-native-oh/react-native-harmony-cli" package.',
|
|
226
|
+
],
|
|
231
227
|
});
|
|
232
228
|
}
|
|
233
229
|
}
|
|
@@ -262,7 +258,7 @@ function prepareDirectory(path: AbsolutePath, enableSafetyCheck: boolean) {
|
|
|
262
258
|
if (enableSafetyCheck && !path.getValue().startsWith(process.cwd())) {
|
|
263
259
|
throw new DescriptiveError({
|
|
264
260
|
whatHappened: `Tried to remove files in ${path.getValue()}\nand that path is outside current working directory`,
|
|
265
|
-
whatCanUserDo:
|
|
261
|
+
whatCanUserDo: ['Run codegen from different location'],
|
|
266
262
|
});
|
|
267
263
|
}
|
|
268
264
|
maybeRemoveFilesInDirectory(path);
|
|
@@ -278,15 +274,14 @@ function logCodegenResult(
|
|
|
278
274
|
);
|
|
279
275
|
sortedRelativePathStrings.sort();
|
|
280
276
|
sortedRelativePathStrings.forEach((pathStr) => {
|
|
281
|
-
logger.
|
|
277
|
+
logger.debug((styles) => styles.gray(`• ${pathStr}`));
|
|
282
278
|
});
|
|
283
|
-
logger.
|
|
279
|
+
logger.debug(() => '');
|
|
284
280
|
logger.info(
|
|
285
281
|
(styles) =>
|
|
286
|
-
`Generated ${styles.green(styles.bold(fileContentByPath.size))} file(s)
|
|
287
|
-
{ prefix: true }
|
|
282
|
+
`Generated ${styles.green(styles.bold(fileContentByPath.size))} file(s)`
|
|
288
283
|
);
|
|
289
|
-
logger.
|
|
284
|
+
logger.debug(() => '');
|
|
290
285
|
}
|
|
291
286
|
|
|
292
287
|
function deriveCppDirectoryNameFromNpmPackageName(
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
2
|
+
* Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Command } from '
|
|
8
|
+
import { Command } from './types';
|
|
9
9
|
import {
|
|
10
10
|
AbsolutePath,
|
|
11
11
|
DescriptiveError,
|
|
@@ -147,19 +147,19 @@ function validateRawArgs(rawArgs: RawArgs): Args {
|
|
|
147
147
|
if (!rawArgs.npmPackageName) {
|
|
148
148
|
throw new DescriptiveError({
|
|
149
149
|
whatHappened: '--npm-package-name is required',
|
|
150
|
-
whatCanUserDo:
|
|
150
|
+
whatCanUserDo: ['Please specify --npm-package-name'],
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
if (!rawArgs.cppOutputPath) {
|
|
154
154
|
throw new DescriptiveError({
|
|
155
155
|
whatHappened: '--cpp-output-path is required',
|
|
156
|
-
whatCanUserDo:
|
|
156
|
+
whatCanUserDo: ['Please specify --cpp-output-path'],
|
|
157
157
|
});
|
|
158
158
|
}
|
|
159
159
|
if (!rawArgs.etsOutputPath) {
|
|
160
160
|
throw new DescriptiveError({
|
|
161
161
|
whatHappened: '--ets-output-path is required',
|
|
162
|
-
whatCanUserDo:
|
|
162
|
+
whatCanUserDo: ['Please specify --ets-output-path'],
|
|
163
163
|
});
|
|
164
164
|
}
|
|
165
165
|
return {
|
|
@@ -185,9 +185,7 @@ function specPathsToSpecFilePaths(specPaths: AbsolutePath[]): AbsolutePath[] {
|
|
|
185
185
|
if (!fs.existsSync(specPath.getValue())) {
|
|
186
186
|
throw new DescriptiveError({
|
|
187
187
|
whatHappened: `No such file or directory: ${specPath.getValue()}`,
|
|
188
|
-
whatCanUserDo:
|
|
189
|
-
default: [`Are you sure provided specPath exists?`],
|
|
190
|
-
},
|
|
188
|
+
whatCanUserDo: [`Are you sure provided specPath exists?`],
|
|
191
189
|
});
|
|
192
190
|
}
|
|
193
191
|
if (fs.lstatSync(specPath.getValue()).isDirectory()) {
|
|
@@ -361,12 +359,10 @@ function prepareDirectory(path: AbsolutePath, enableSafetyCheck: boolean) {
|
|
|
361
359
|
if (enableSafetyCheck && !path.getValue().startsWith(process.cwd())) {
|
|
362
360
|
throw new DescriptiveError({
|
|
363
361
|
whatHappened: `Tried to remove files in ${path.getValue()}\nand that path is outside current working directory`,
|
|
364
|
-
whatCanUserDo:
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
],
|
|
369
|
-
},
|
|
362
|
+
whatCanUserDo: [
|
|
363
|
+
'Run this command with --no-safety-check flag',
|
|
364
|
+
'Run codegen from different location',
|
|
365
|
+
],
|
|
370
366
|
});
|
|
371
367
|
}
|
|
372
368
|
maybeRemoveFilesInDirectory(path);
|
|
@@ -387,8 +383,7 @@ function logCodegenResult(
|
|
|
387
383
|
logger.info(() => '');
|
|
388
384
|
logger.info(
|
|
389
385
|
(styles) =>
|
|
390
|
-
`Generated ${styles.green(styles.bold(fileContentByPath.size))} file(s)
|
|
391
|
-
{ prefix: true }
|
|
386
|
+
`Generated ${styles.green(styles.bold(fileContentByPath.size))} file(s)`
|
|
392
387
|
);
|
|
393
388
|
logger.info(() => '');
|
|
394
389
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
2
|
+
* Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Command } from '
|
|
8
|
+
import { Command } from './types';
|
|
9
9
|
import os from 'node:os';
|
|
10
10
|
import fs from 'node:fs';
|
|
11
11
|
import pathUtils from 'node:path';
|
package/src/commands/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright (c) 2024 Huawei Technologies Co., Ltd.
|
|
2
|
+
* Copyright (c) 2024-2025 Huawei Technologies Co., Ltd.
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE-MIT file in the root directory of this source tree.
|
|
@@ -13,3 +13,4 @@ export * from './codegen-harmony';
|
|
|
13
13
|
export * from './verify-package-harmony';
|
|
14
14
|
export * from './codegen-lib-harmony';
|
|
15
15
|
export * from './link-harmony';
|
|
16
|
+
export * from './run-harmony';
|