Skip to content

Commit fbfd436

Browse files
authored
Merge branch 'main' into reduce-ios-install-time
2 parents b947a6e + 256e7a5 commit fbfd436

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1714
-526
lines changed

.changeset/rich-donuts-mix.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
"react-native-node-api-test-app": patch
2+
"@react-native-node-api/test-app": patch
33
"react-native-node-api": patch
44
---
55

.github/workflows/check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
node-version: lts/jod
2727
- run: npm ci
2828
- run: npm run lint
29+
- run: npm run prettier:check
2930
unit-tests:
3031
strategy:
3132
fail-fast: false

.prettierignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Ignore artifacts
2+
dist
3+
build
4+
Pods
5+
target
6+
.cxx
7+
8+
# Ignore hermes
9+
packages/host/hermes
10+
packages/node-addon-examples/examples
11+
packages/node-tests/node
12+
packages/node-tests/tests
13+
packages/node-tests/*.generated.js

apps/test-app/App.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,32 @@ import {
99
} from "mocha-remote-react-native";
1010

1111
import { suites as nodeAddonExamplesSuites } from "@react-native-node-api/node-addon-examples";
12+
import { suites as nodeTestsSuites } from "@react-native-node-api/node-tests";
1213

1314
function describeIf(
1415
condition: boolean,
1516
title: string,
16-
fn: (this: Mocha.Suite) => void
17+
fn: (this: Mocha.Suite) => void,
1718
) {
1819
return condition ? describe(title, fn) : describe.skip(title, fn);
1920
}
2021

2122
type Context = {
2223
allTests?: boolean;
2324
nodeAddonExamples?: boolean;
25+
nodeTests?: boolean;
2426
ferricExample?: boolean;
2527
};
2628

2729
function loadTests({
2830
allTests = false,
2931
nodeAddonExamples = allTests,
32+
nodeTests = allTests,
3033
ferricExample = allTests,
3134
}: Context) {
3235
describeIf(nodeAddonExamples, "Node Addon Examples", () => {
3336
for (const [suiteName, examples] of Object.entries(
34-
nodeAddonExamplesSuites
37+
nodeAddonExamplesSuites,
3538
)) {
3639
describe(suiteName, () => {
3740
for (const [exampleName, requireExample] of Object.entries(examples)) {
@@ -46,6 +49,22 @@ function loadTests({
4649
}
4750
});
4851

52+
describeIf(nodeTests, "Node Tests", () => {
53+
function registerTestSuite(suite: typeof nodeTestsSuites) {
54+
for (const [name, suiteOrTest] of Object.entries(suite)) {
55+
if (typeof suiteOrTest === "function") {
56+
it(name, suiteOrTest);
57+
} else {
58+
describe(name, () => {
59+
registerTestSuite(suiteOrTest);
60+
});
61+
}
62+
}
63+
}
64+
65+
registerTestSuite(nodeTestsSuites);
66+
});
67+
4968
describeIf(ferricExample, "ferric-example", () => {
5069
it("exports a callable sum function", () => {
5170
/* eslint-disable-next-line @typescript-eslint/no-require-imports -- TODO: Determine why a dynamic import doesn't work on Android */

apps/test-app/babel.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module.exports = {
2-
presets: ['module:@react-native/babel-preset'],
2+
presets: ["module:@react-native/babel-preset"],
33
// plugins: [['module:react-native-node-api/babel-plugin', { stripPathSuffix: true }]],
4-
plugins: ['module:react-native-node-api/babel-plugin'],
4+
plugins: ["module:react-native-node-api/babel-plugin"],
55
};

apps/test-app/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
"test:android": "mocha-remote --exit-on-error -- concurrently --kill-others-on-fail --passthrough-arguments npm:metro 'npm:android -- {@}' --",
1111
"test:android:allTests": "MOCHA_REMOTE_CONTEXT=allTests npm run test:android -- ",
1212
"test:android:nodeAddonExamples": "MOCHA_REMOTE_CONTEXT=nodeAddonExamples npm run test:android -- ",
13+
"test:android:nodeTests": "MOCHA_REMOTE_CONTEXT=nodeTests npm run test:android -- ",
1314
"test:android:ferricExample": "MOCHA_REMOTE_CONTEXT=ferricExample npm run test:android -- ",
1415
"test:ios": "mocha-remote --exit-on-error -- concurrently --passthrough-arguments --kill-others-on-fail npm:metro 'npm:ios -- {@}' --",
1516
"test:ios:allTests": "MOCHA_REMOTE_CONTEXT=allTests npm run test:ios -- ",
1617
"test:ios:nodeAddonExamples": "MOCHA_REMOTE_CONTEXT=nodeAddonExamples npm run test:ios -- ",
18+
"test:ios:nodeTests": "MOCHA_REMOTE_CONTEXT=nodeTests npm run test:ios -- ",
1719
"test:ios:ferricExample": "MOCHA_REMOTE_CONTEXT=ferricExample npm run test:ios -- "
1820
},
1921
"dependencies": {
@@ -23,6 +25,8 @@
2325
"@react-native-community/cli": "^18.0.0",
2426
"@react-native-community/cli-platform-android": "^18.0.0",
2527
"@react-native-community/cli-platform-ios": "^18.0.0",
28+
"@react-native-node-api/node-addon-examples": "*",
29+
"@react-native-node-api/node-tests": "*",
2630
"@react-native/babel-preset": "0.79.0",
2731
"@react-native/metro-config": "0.79.0",
2832
"@react-native/typescript-config": "0.79.0",

apps/test-app/react-native.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
const project = (() => {
32
try {
43
const { configureProjects } = require("react-native-test-app");
@@ -25,4 +24,4 @@ const project = (() => {
2524

2625
module.exports = {
2726
...(project ? { project } : undefined),
28-
};
27+
};

docs/HOW-IT-WORKS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The generated code looks something like this:
2525

2626
```javascript
2727
module.exports = require("react-native-node-api").requireNodeAddon(
28-
"calculator-lib--prebuild"
28+
"calculator-lib--prebuild",
2929
);
3030
```
3131

eslint.config.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,30 @@
22

33
import { globalIgnores } from "eslint/config";
44
import globals from "globals";
5-
import eslint from '@eslint/js';
6-
import tseslint from 'typescript-eslint';
5+
import eslint from "@eslint/js";
6+
import tseslint from "typescript-eslint";
7+
import eslintConfigPrettier from "eslint-config-prettier/flat";
78

89
export default tseslint.config(
9-
globalIgnores([".nx/**"]),
10-
globalIgnores(["**/dist/**"]),
11-
globalIgnores(["apps/test-app/ios/**"]),
12-
globalIgnores(["packages/host/hermes/**"]),
13-
globalIgnores(["packages/node-addon-examples/examples/**"]),
14-
globalIgnores(["packages/ferric-example/ferric_example.d.ts"]),
10+
globalIgnores([
11+
"**/dist/**",
12+
"apps/test-app/ios/**",
13+
"packages/host/hermes/**",
14+
"packages/node-addon-examples/examples/**",
15+
"packages/ferric-example/ferric_example.d.ts",
16+
"packages/node-tests/node/**",
17+
"packages/node-tests/tests/**",
18+
]),
1519
eslint.configs.recommended,
1620
tseslint.configs.recommended,
21+
eslintConfigPrettier,
1722
{
1823
files: [
1924
"apps/test-app/*.js",
2025
"packages/node-addon-examples/*.js",
2126
"packages/host/babel-plugin.js",
22-
"packages/host/react-native.config.js"
27+
"packages/host/react-native.config.js",
28+
"packages/node-tests/tests.generated.js",
2329
],
2430
languageOptions: {
2531
parserOptions: {
@@ -38,7 +44,7 @@ export default tseslint.config(
3844
files: [
3945
"packages/gyp-to-cmake/bin/*.js",
4046
"packages/host/bin/*.mjs",
41-
"packages/host/scripts/*.mjs"
47+
"packages/host/scripts/*.mjs",
4248
],
4349
languageOptions: {
4450
globals: {

0 commit comments

Comments
 (0)