@roninoss/plugin-primitives
v0.0.2
Published
A collection of type-safe config plugin primitives that handle common native configuration tasks
Downloads
120
Readme
Plugin Primitives
What is it?
A collection of type-safe config plugin primitives that handle common native configuration tasks.
API
withColor
🤖
Adds, modifies, or removes a color value to the colors.xml
file. Supports both normal and night modes.
withColor(config, {
name: "primaryColor",
value: "#000000",
night: true,
});
withString
🤖
Adds, modifies, or removes a string value to the strings.xml
file.
withString(config, {
name: "stringName",
value: "Hello, world!",
translatable: true,
});
withEntitlement
🍎
Adds, modifies, or removes an entitlement to your app, allowing it to access a feature on the device.
withEntitlement(config, {
key: "com.apple.developer.healthkit.access",
value: "yes",
});
withInfo
🍎
Adds, modifies, or removes a key/value pair to the Info.plist
file.
withInfo(config, {
key: "NSHealthShareUsageDescription",
value: "We need access to your health data.",
});
withModifyFile
🤖 🍎
Modify a file by finding and replacing a string.
withModifyFile(config, {
filePath: "AppDelegate.m",
find: "something",
replace: "something else",
});
Or insert a string at a specific anchor and offset.
withModifyFile(config, {
filePath: "AppDelegate.m",
newSrc: "hello",
anchor: "something",
offset: 10,
});
withSourceFile
🤖 🍎
Apply modifications to a source file. Accepts an optional contents
parameter to specify the contents of the file. If not provided, the contents will be read from the file at plugins/<filePath>
. Also accepts an optional parallelDir
parameter to specify a directory (relative to the project root) to place the file in, which defaults to plugins
.
withSourceFile(config, {
filePath: "ios/AppDelegate.m",
contents: `
#import "AppDelegate.h"
#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
...
`,
});
withResourceFile
🤖 🍎
Add a resource file to the project. Accepts an optional parallelDir
parameter to specify a directory (relative to the project root) to place the file in, which defaults to plugins
.
withResourceFile(config, {
filePath: "android/src/main/res/values/strings2.xml",
});
withRemoveFile
🤖 🍎
Removes a file and any references to it from the project.
withRemoveFile(config, {
filePath: "path/to/file",
});
withPlugins
🤖 🍎
Applies multiple plugins.
withPlugins(config, [
[withEntitlement, { key: "aps-environment", value: "development" }],
[
withColorValue,
{ name: "primaryColor", value: "#000000", colorScheme: "dark" },
],
]);