Skip to content

feat: add init command #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e25d2a3
added initial files
dougg0k Jul 25, 2025
4745e5a
removed ferric example
dougg0k Jul 25, 2025
bfb0e6e
add some setup
dougg0k Jul 25, 2025
1fb0a22
add scripts
dougg0k Jul 26, 2025
da39e3a
changed template to files
dougg0k Jul 26, 2025
0fdc681
add changes
dougg0k Jul 26, 2025
815ebd3
Merge branch 'main' of github.com:dougg0k/react-native-node-api into …
dougg0k Jul 26, 2025
77bcff1
added package template
dougg0k Jul 26, 2025
de848cd
renamed command
dougg0k Jul 26, 2025
2720b01
add progress
dougg0k Jul 26, 2025
1ac1df2
fixed replacing
dougg0k Jul 26, 2025
789e2b8
removed test files
dougg0k Jul 26, 2025
30d0fe9
removed pnpm workspace stuff
dougg0k Jul 26, 2025
cf4b994
updated package lock
dougg0k Jul 26, 2025
9aedc44
added changeset
dougg0k Jul 26, 2025
344a875
add changes
dougg0k Jul 26, 2025
5f3f513
updated check
dougg0k Jul 26, 2025
2b5471a
removed unused var
dougg0k Jul 26, 2025
21a91f6
format and updated readme
dougg0k Jul 26, 2025
2f074fa
updated readme
dougg0k Jul 27, 2025
be9202a
some refactoring
dougg0k Jul 27, 2025
efab2cb
changed pnpm command
dougg0k Jul 28, 2025
16d15b6
Merge remote-tracking branch 'upstream/main' into add-generate-command
dougg0k Aug 1, 2025
b9b5565
improved readme
dougg0k Aug 3, 2025
82a991a
fix readme format
dougg0k Aug 3, 2025
759d9e2
updated some package versions
dougg0k Aug 8, 2025
9ce867b
Merge remote-tracking branch 'upstream/main' into add-generate-command
dougg0k Aug 8, 2025
87d7ee6
updated package lock
dougg0k Aug 8, 2025
a7107cd
removed some config from files
dougg0k Aug 9, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/many-pens-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"ferric-cli": minor
"@react-native-node-api/test-app": minor
---

- Created `init` command to generate / scaffold the project.
- Replacing `ferric-example` with `app-test`, scaffolding the project there.
- Added `Cargo.toml` optimizations for size.
5 changes: 2 additions & 3 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
# Bootstrap host package to get weak-node-api and ferric-example to get types
# TODO: Solve this by adding an option to ferric to build only types or by committing the types into the repo as a fixture for an "init" command
- run: npm run bootstrap --workspace react-native-node-api
- run: npm run bootstrap --workspace @react-native-node-api/ferric-example
- run: npm run lint
env:
DEBUG: eslint:eslint
Expand Down Expand Up @@ -152,9 +151,9 @@ jobs:
- name: Build weak-node-api for all architectures
run: npm run build-weak-node-api -- --android
working-directory: packages/host
- name: Build ferric-example for all architectures
- name: Build lib_in_rust for android architectures
run: npm run build -- --android
working-directory: packages/ferric-example
working-directory: apps/test-app/lib_in_rust
- name: Run tests (Android)
timeout-minutes: 75
uses: reactivecircus/android-emulator-runner@v2
Expand Down
14 changes: 0 additions & 14 deletions apps/test-app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ type Context = {
allTests?: boolean;
nodeAddonExamples?: boolean;
nodeTests?: boolean;
ferricExample?: boolean;
};

function loadTests({
allTests = false,
nodeAddonExamples = allTests,
nodeTests = allTests,
ferricExample = allTests,
}: Context) {
describeIf(nodeAddonExamples, "Node Addon Examples", () => {
for (const [suiteName, examples] of Object.entries(
Expand Down Expand Up @@ -67,18 +65,6 @@ function loadTests({

registerTestSuite(nodeTestsSuites);
});

describeIf(ferricExample, "ferric-example", () => {
it("exports a callable sum function", () => {
const exampleAddon =
/* eslint-disable-next-line @typescript-eslint/no-require-imports -- TODO: Determine why a dynamic import doesn't work on Android */
require("ferric-example") as typeof import("ferric-example");
const result = exampleAddon.sum(1, 3);
if (result !== 4) {
throw new Error(`Expected 1 + 3 to equal 4, but got ${result}`);
}
});
});
}

export default function App() {
Expand Down
8 changes: 8 additions & 0 deletions apps/test-app/lib_in_rust/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
target
Cargo.lock

*.xcframework/
*.apple.node/
*.android.node/

dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "ferric-example"
name = "lib_in_rust"
version = "1.0.0"
edition = "2021"
license = "MIT"
Expand All @@ -23,3 +23,5 @@ napi-build = "2"
[profile.release]
lto = true
codegen-units = 1
strip = "symbols"
opt-level = "z"
File renamed without changes.
14 changes: 14 additions & 0 deletions apps/test-app/lib_in_rust/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "lib_in_rust",
"private": true,
"version": "0.1.0",
"main": "dist/lib_in_rust.js",
"types": "dist/lib_in_rust.d.ts",
"scripts": {
"build": "ferric build",
"build:release": "npm run build -- --configuration release"
},
"devDependencies": {
"ferric-cli": "latest"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ use napi_derive::napi;

#[napi]
pub fn sum(a: i32, b: i32) -> i32 {
a + b
a + b
}
8 changes: 5 additions & 3 deletions apps/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
"test:ios": "mocha-remote --exit-on-error -- concurrently --passthrough-arguments --kill-others-on-fail npm:metro 'npm:ios -- {@}' --",
"test:ios:allTests": "MOCHA_REMOTE_CONTEXT=allTests npm run test:ios -- ",
"test:ios:nodeAddonExamples": "MOCHA_REMOTE_CONTEXT=nodeAddonExamples npm run test:ios -- ",
"test:ios:nodeTests": "MOCHA_REMOTE_CONTEXT=nodeTests npm run test:ios -- ",
"test:ios:ferricExample": "MOCHA_REMOTE_CONTEXT=ferricExample npm run test:ios -- "
"gen:rs": "ferric init lib_in_rust",
"build:rs": "ferric build --cwd lib_in_rust",
"build:rs:release": "npm run build:rs -- --configuration release",
"test:ios:nodeTests": "MOCHA_REMOTE_CONTEXT=nodeTests npm run test:ios -- "
},
"dependencies": {
"@babel/core": "^7.26.10",
Expand All @@ -34,7 +36,7 @@
"@types/mocha": "^10.0.10",
"@types/react": "^19.0.0",
"concurrently": "^9.1.2",
"ferric-example": "^0.1.0",
"ferric-cli": "*",
"mocha": "^11.6.0",
"mocha-remote-cli": "^1.13.2",
"mocha-remote-react-native": "^1.13.2",
Expand Down
3 changes: 0 additions & 3 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ export default tseslint.config(
"apps/test-app/ios/**",
"packages/host/hermes/**",
"packages/node-addon-examples/examples/**",
"packages/ferric-example/ferric_example.js",
"packages/ferric-example/ferric_example.d.ts",
"packages/ferric-example/target/**",
"packages/node-tests/node/**",
"packages/node-tests/tests/**",
"packages/node-tests/*.generated.js",
Expand Down
Loading
Loading