Skip to content

Commit 93e288b

Browse files
authored
Make react-native-node-api-cmake spawn async and add spinners (#8)
* Hoist .DS_Store in root .gitignore * Make spawn async and add spinners * Rename options to context and parse triplets into a set * Use oraPromise * Remove libraryPaths
1 parent 6665402 commit 93e288b

File tree

7 files changed

+344
-101
lines changed

7 files changed

+344
-101
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.DS_Store
2+
13
node_modules/
24
dist/
35

apps/test-app/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
*.hprof
33
*.xcworkspace/
44
*.zip
5-
.DS_Store
65
.gradle/
76
.idea/
87
.vs/

package-lock.json

Lines changed: 199 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/node-addon-examples/scripts/build-examples.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ for (const projectDirectory of projectDirectories) {
1010
cwd: projectDirectory,
1111
stdio: "inherit",
1212
});
13+
console.log();
1314
}

packages/react-native-node-api-cmake/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
},
1414
"dependencies": {
1515
"@commander-js/extra-typings": "^13.1.0",
16+
"bufout": "^0.3.1",
17+
"chalk": "^5.4.1",
1618
"cmake-js": "^7.3.1",
17-
"commander": "^13.1.0"
19+
"commander": "^13.1.0",
20+
"ora": "^8.2.0"
1821
},
1922
"peerDependencies": {
2023
"node-addon-api": "^8.3.1",

packages/react-native-node-api-cmake/src/apple.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import fs from "node:fs";
44
import path from "node:path";
55

66
import type { SupportedTriplet } from "./triplets.js";
7+
import { spawn } from "bufout";
78

89
export const APPLE_TRIPLETS = [
910
"arm64;x86_64-apple-darwin",
@@ -123,7 +124,6 @@ export function getAppleBuildArgs() {
123124
}
124125

125126
type XCframeworkOptions = {
126-
libraryPaths: string[];
127127
frameworkPaths: string[];
128128
outputPath: string;
129129
};
@@ -168,8 +168,7 @@ export function createFramework(libraryPath: string) {
168168
return frameworkPath;
169169
}
170170

171-
export function createXCframework({
172-
libraryPaths,
171+
export async function createXCframework({
173172
frameworkPaths,
174173
outputPath,
175174
}: XCframeworkOptions) {
@@ -178,20 +177,18 @@ export function createXCframework({
178177
// Ideally, it would only be necessary to delete the specific platform+arch, to allow selectively building from source.
179178
fs.rmSync(outputPath, { recursive: true, force: true });
180179

181-
const { status } = cp.spawnSync(
180+
await spawn(
182181
"xcodebuild",
183182
[
184183
"-create-xcframework",
185-
...libraryPaths.flatMap((p) => ["-library", p]),
186184
...frameworkPaths.flatMap((p) => ["-framework", p]),
187185
"-output",
188186
outputPath,
189187
],
190188
{
191-
stdio: "inherit",
189+
outputMode: "buffered",
192190
}
193191
);
194-
assert.equal(status, 0, "Failed to create xcframework");
195192
// Write a file to mark the xcframework is a Node-API module
196193
// TODO: Consider including this in the Info.plist file instead
197194
fs.writeFileSync(

0 commit comments

Comments
 (0)