Skip to content

Commit c222839

Browse files
committed
Move prettyPath to cli-utils
1 parent 0419678 commit c222839

File tree

9 files changed

+31
-19
lines changed

9 files changed

+31
-19
lines changed

packages/cli-utils/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ export * from "bufout";
55

66
export * from "./actions.js";
77
export * from "./errors.js";
8+
export * from "./paths.js";

packages/cli-utils/src/paths.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import chalk from "chalk";
2+
import path from "node:path";
3+
4+
export function prettyPath(p: string) {
5+
return chalk.dim(
6+
path.relative(process.cwd(), p) || chalk.italic("current directory"),
7+
);
8+
}

packages/ferric/src/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
oraPromise,
99
assertFixable,
1010
wrapAction,
11+
prettyPath,
1112
} from "@react-native-node-api/cli-utils";
1213

1314
import {
@@ -19,7 +20,6 @@ import {
1920
createXCframework,
2021
createUniversalAppleLibrary,
2122
determineLibraryBasename,
22-
prettyPath,
2323
} from "react-native-node-api";
2424

2525
import { ensureCargo, build } from "./cargo.js";

packages/gyp-to-cmake/src/cli.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import fs from "node:fs";
22
import path from "node:path";
3-
4-
import { Command, wrapAction } from "@react-native-node-api/cli-utils";
3+
import {
4+
Command,
5+
prettyPath,
6+
wrapAction,
7+
Option,
8+
} from "@react-native-node-api/cli-utils";
59

610
import { readBindingFile } from "./gyp.js";
711
import {
@@ -29,15 +33,18 @@ export function transformBindingGypFile(
2933
...restOfOptions
3034
}: TransformOptions,
3135
) {
32-
console.log("Transforming", gypPath);
33-
const gyp = readBindingFile(gypPath, disallowUnknownProperties);
3436
const parentPath = path.dirname(gypPath);
37+
const cmakeListsPath = path.join(parentPath, "CMakeLists.txt");
38+
console.log(
39+
`Transforming ${prettyPath(gypPath)}${prettyPath(cmakeListsPath)}`,
40+
);
41+
42+
const gyp = readBindingFile(gypPath, disallowUnknownProperties);
3543
const result = bindingGypToCmakeLists({
3644
gyp,
3745
projectName,
3846
...restOfOptions,
3947
});
40-
const cmakeListsPath = path.join(parentPath, "CMakeLists.txt");
4148
fs.writeFileSync(cmakeListsPath, result, "utf-8");
4249
}
4350

packages/host/src/node/cli/hermes.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import {
99
spawn,
1010
UsageError,
1111
wrapAction,
12+
prettyPath,
1213
} from "@react-native-node-api/cli-utils";
1314
import { packageDirectorySync } from "pkg-dir";
1415

15-
import { prettyPath } from "../path-utils";
16-
1716
const HOST_PACKAGE_ROOT = path.resolve(__dirname, "../../..");
1817
// FIXME: make this configurable with reasonable fallback before public release
1918
const HERMES_GIT_URL = "https://github.com/kraenhansen/hermes.git";

packages/host/src/node/cli/link-modules.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import path from "node:path";
22
import fs from "node:fs";
33

4-
import { chalk, SpawnFailure } from "@react-native-node-api/cli-utils";
4+
import {
5+
chalk,
6+
SpawnFailure,
7+
prettyPath,
8+
} from "@react-native-node-api/cli-utils";
59

610
import {
711
findNodeApiModulePathsByDependency,
@@ -10,7 +14,6 @@ import {
1014
logModulePaths,
1115
NamingStrategy,
1216
PlatformName,
13-
prettyPath,
1417
} from "../path-utils";
1518

1619
export type ModuleLinker = (

packages/host/src/node/cli/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
SpawnFailure,
99
oraPromise,
1010
wrapAction,
11+
prettyPath,
1112
} from "@react-native-node-api/cli-utils";
1213

1314
import {
@@ -19,7 +20,6 @@ import {
1920
normalizeModulePath,
2021
PlatformName,
2122
PLATFORMS,
22-
prettyPath,
2323
} from "../path-utils";
2424

2525
import { command as vendorHermes } from "./hermes";

packages/host/src/node/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ export {
2222
determineXCFrameworkFilename,
2323
} from "./prebuilds/apple.js";
2424

25-
export { determineLibraryBasename, prettyPath } from "./path-utils.js";
25+
export { determineLibraryBasename } from "./path-utils.js";
2626

2727
export { weakNodeApiPath } from "./weak-node-api.js";

packages/host/src/node/path-utils.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { packageDirectorySync } from "pkg-dir";
55
import { readPackageSync } from "read-pkg";
66
import { createRequire } from "node:module";
77

8-
import { chalk } from "@react-native-node-api/cli-utils";
8+
import { chalk, prettyPath } from "@react-native-node-api/cli-utils";
99

1010
import { findDuplicates } from "./duplicates";
1111

@@ -194,12 +194,6 @@ export function getLibraryName(modulePath: string, naming: NamingStrategy) {
194194
)}`;
195195
}
196196

197-
export function prettyPath(p: string) {
198-
return chalk.dim(
199-
path.relative(process.cwd(), p) || chalk.italic("current directory"),
200-
);
201-
}
202-
203197
export function resolvePackageRoot(
204198
requireFromPackageRoot: NodeJS.Require,
205199
packageName: string,

0 commit comments

Comments
 (0)