@react-native-oh/react-native-harmony-cli 0.0.28 → 0.0.36
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/ArkTSComponentCodeGeneratorArkTS.js +3 -0
- package/dist/codegen/generators/ArkTSComponentCodeGeneratorCAPI.js +3 -0
- package/dist/codegen/generators/CppComponentCodeGenerator.js +3 -0
- package/dist/codegen/templates/ComponentJSIBinderHTemplate.js +15 -0
- package/dist/commands/bundle-harmony.js +5 -68
- 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 +438 -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/package.json +10 -3
- 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/ArkTSComponentCodeGeneratorArkTS.ts +3 -0
- package/src/codegen/generators/ArkTSComponentCodeGeneratorCAPI.ts +3 -0
- package/src/codegen/generators/CppComponentCodeGenerator.ts +3 -0
- package/src/codegen/templates/ComponentJSIBinderHTemplate.ts +24 -1
- package/src/commands/bundle-harmony.ts +6 -82
- 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 +478 -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
|
@@ -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.
|
|
@@ -14,11 +14,9 @@ export function createEventNameFromEventHandlerName(
|
|
|
14
14
|
if (eventName.length === 0) {
|
|
15
15
|
throw new CodegenError({
|
|
16
16
|
whatHappened: `Received invalid event handler name: ${eventHandlerName}`,
|
|
17
|
-
whatCanUserDo:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
],
|
|
21
|
-
},
|
|
17
|
+
whatCanUserDo: [
|
|
18
|
+
'Change your event listener name to match naming convention "onEventName" e.g. "onPress"',
|
|
19
|
+
],
|
|
22
20
|
});
|
|
23
21
|
}
|
|
24
22
|
return eventName.charAt(0).toLowerCase() + eventName.slice(1);
|
|
@@ -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.
|
|
@@ -54,11 +54,9 @@ export class UberSchema implements ValueObject {
|
|
|
54
54
|
if (err instanceof Error) {
|
|
55
55
|
throw new CodegenError({
|
|
56
56
|
whatHappened: "Couldn't create the schema",
|
|
57
|
-
whatCanUserDo:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
],
|
|
61
|
-
},
|
|
57
|
+
whatCanUserDo: [
|
|
58
|
+
`There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n${err.message}`,
|
|
59
|
+
],
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
62
|
throw err;
|
|
@@ -119,11 +117,9 @@ export class UberSchema implements ValueObject {
|
|
|
119
117
|
if (err instanceof Error) {
|
|
120
118
|
throw new CodegenError({
|
|
121
119
|
whatHappened: "Couldn't create the schema",
|
|
122
|
-
whatCanUserDo:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
],
|
|
126
|
-
},
|
|
120
|
+
whatCanUserDo: [
|
|
121
|
+
`There's probably at least one spec file defined in your project or in a third-party package that breaks some code generation restrictions. Please check the message below. If it's ambiguous, debug the problem with divide and conquer strategy.\n\n${err.message}`,
|
|
122
|
+
],
|
|
127
123
|
});
|
|
128
124
|
}
|
|
129
125
|
throw err;
|
|
@@ -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) => ({
|
|
@@ -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) => ({
|
|
@@ -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
|
|
|
@@ -125,86 +127,8 @@ async function retrieveAssetsData(
|
|
|
125
127
|
...MetroServer.DEFAULT_BUNDLE_OPTIONS,
|
|
126
128
|
...buildOptions,
|
|
127
129
|
entryFile: buildOptions.entry,
|
|
128
|
-
bundleType: 'todo',
|
|
129
130
|
});
|
|
130
131
|
} finally {
|
|
131
132
|
metroServer.end();
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
|
-
|
|
135
|
-
async function copyAssets(
|
|
136
|
-
assetsData: readonly AssetData[],
|
|
137
|
-
assetsDest: Path
|
|
138
|
-
): Promise<void> {
|
|
139
|
-
if (assetsDest == null) {
|
|
140
|
-
console.warn('Assets destination folder is not set, skipping...');
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
await fse.ensureDir(assetsDest);
|
|
144
|
-
const fileDestBySrc: Record<Path, Path> = {};
|
|
145
|
-
for (const asset of assetsData) {
|
|
146
|
-
const idx = getHighestQualityFileIdx(asset);
|
|
147
|
-
fileDestBySrc[asset.files[idx]] = pathUtils.join(
|
|
148
|
-
assetsDest,
|
|
149
|
-
getAssetDestRelativePath(asset)
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
return copyFiles(fileDestBySrc);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
function getHighestQualityFileIdx(assetData: AssetData): number {
|
|
156
|
-
let result = 0;
|
|
157
|
-
let maxScale = -1;
|
|
158
|
-
for (let idx = 0; idx < assetData.scales.length; idx++) {
|
|
159
|
-
const scale = assetData.scales[idx];
|
|
160
|
-
if (scale > maxScale) {
|
|
161
|
-
maxScale = scale;
|
|
162
|
-
result = idx;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return result;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function copyFiles(fileDestBySrc: Record<Path, Path>) {
|
|
169
|
-
const fileSources = Object.keys(fileDestBySrc);
|
|
170
|
-
if (fileSources.length === 0) {
|
|
171
|
-
return Promise.resolve();
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
console.info(`Copying ${fileSources.length} asset files`);
|
|
175
|
-
return new Promise<void>((resolve, reject) => {
|
|
176
|
-
const copyNext = (error?: Error) => {
|
|
177
|
-
if (error) {
|
|
178
|
-
reject(error);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (fileSources.length === 0) {
|
|
182
|
-
console.info('Done copying assets');
|
|
183
|
-
resolve();
|
|
184
|
-
} else {
|
|
185
|
-
// fileSources.length === 0 is checked in previous branch, so this is string
|
|
186
|
-
const src = fileSources.shift()!;
|
|
187
|
-
const dest = fileDestBySrc[src];
|
|
188
|
-
copyFile(src, dest, copyNext);
|
|
189
|
-
}
|
|
190
|
-
};
|
|
191
|
-
copyNext();
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function copyFile(
|
|
196
|
-
src: string,
|
|
197
|
-
dest: string,
|
|
198
|
-
onFinished: (error?: Error) => void
|
|
199
|
-
): void {
|
|
200
|
-
const destDir = pathUtils.dirname(dest);
|
|
201
|
-
fs.mkdir(destDir, { recursive: true }, (err?) => {
|
|
202
|
-
if (err) {
|
|
203
|
-
onFinished(err);
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
fs.createReadStream(src)
|
|
207
|
-
.pipe(fs.createWriteStream(dest))
|
|
208
|
-
.on('finish', onFinished);
|
|
209
|
-
});
|
|
210
|
-
}
|
|
@@ -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';
|