Skip to content
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

chore(nitro-config): adds a json schema for the nitro config file #390

Merged
merged 4 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
99 changes: 99 additions & 0 deletions docs/static/nitro.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Nitro Modules Configuration",
"type": "object",
"required": [
"cxxNamespace",
"ios",
"android",
"autolinking"
],
"properties": {
"cxxNamespace": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"description": "Represents the C++ namespace of the module that will be generated. This can have multiple sub-namespaces, and is always relative to `margelo::nitro`."
},
"ios": {
"type": "object",
"required": [
"iosModuleName"
],
"properties": {
"iosModuleName": {
"type": "string",
"minLength": 1,
"description": "Represents the iOS module name of the module that will be generated This will be used to generate Swift bridges, as those are always namespaced within the clang module. If you are using CocoaPods, this should be the Pod name defined in the `.podspec`."
}
},
"description": "Required: iOS configuration"
},
"android": {
"type": "object",
"required": [
"androidNamespace",
"androidCxxLibName"
],
"properties": {
"androidNamespace": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"description": "Represents the Android namespace ('package') of the module that will be generated. This can have multiple sub-namespaces, and is always relative to `com.margelo.nitro`."
},
"androidCxxLibName": {
"type": "string",
"minLength": 1,
"description": "Represents the name of the Android C++ library (aka name in CMakeLists.txt `add_library(..)`). This will be loaded via `System.loadLibrary(...)`."
}
},
"description": "Required: Android configuration"
},
"autolinking": {
"type": "object",
"description": "Configures the code that gets generated for autolinking (registering) Hybrid Object constructors.",
"patternProperties": {
"^.*$": {
"type": "object",
"oneOf": [
{
"properties": {
"cpp": {
"type": "string"
}
},
"additionalProperties": false,
"required": [
"cpp"
]
},
{
"properties": {
"swift": {
"type": "string"
},
"kotlin": {
"type": "string"
}
},
"minProperties": 1,
"additionalProperties": false
}
]
}
}
},
"ignorePaths": {
"type": "array",
"items": {
"type": "string"
},
"description": "A list of paths relative to the project directory that should be ignored by nitrogen. Nitrogen will not look for `.nitro.ts` files in these directories."
}
}
}
2 changes: 1 addition & 1 deletion packages/nitrogen/src/config/NitroUserConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const NitroUserConfigSchema = z.object({
.min(1),

/**
* Returns the name of the Android C++ library (aka name in CMakeLists.txt `add_library(..)`).
* Represents the name of the Android C++ library (aka name in CMakeLists.txt `add_library(..)`).
* This will be loaded via `System.loadLibrary(...)`.
* @example `NitroImage`
*/
Expand Down
13 changes: 10 additions & 3 deletions packages/react-native-nitro-image/nitro.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"cxxNamespace": ["image"],
"$schema": "https://nitro.margelo.com/nitro.schema.json",
"cxxNamespace": [
"image"
],
"ios": {
"iosModuleName": "NitroImage"
},
"android": {
"androidNamespace": ["image"],
"androidNamespace": [
"image"
],
"androidCxxLibName": "NitroImage"
},
"autolinking": {
Expand All @@ -28,5 +33,7 @@
"kotlin": "HybridChild"
}
},
"ignorePaths": ["node_modules"]
"ignorePaths": [
"node_modules"
]
}
13 changes: 10 additions & 3 deletions packages/template/nitro.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{
"cxxNamespace": ["<<cxxNamespace>>"],
"$schema": "https://nitro.margelo.com/nitro.schema.json",
"cxxNamespace": [
"<<cxxNamespace>>"
],
"ios": {
"iosModuleName": "<<iosModuleName>>"
},
"android": {
"androidNamespace": ["<<androidNamespace>>"],
"androidNamespace": [
"<<androidNamespace>>"
],
"androidCxxLibName": "<<androidCxxLibName>>"
},
"autolinking": {},
"ignorePaths": ["node_modules"]
"ignorePaths": [
"node_modules"
]
}