🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis β†’
Socket
Book a DemoInstallSign in
Socket

@roninoss/plugin-primitives

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@roninoss/plugin-primitives

A collection of type-safe config plugin primitives that handle common native configuration tasks

latest
Source
npmnpm
Version
0.0.3
Version published
Maintainers
0
Created
Source

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 from 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 from 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.",
});

withPbxProject 🍎

Modifies the project.pbxproj file by overwritting it with an updated version. The plugin will use the project.pbxproj file found in the parallelDir directory, which defaults to plugins and overwitten. This ensures that the iOS project is always in a consistent state.

withPbxProject(config);

withModifyFile πŸ€– 🍎

Modifies an arbitrary file by

  • Finding and replacing a string
withModifyFile(config, {
  filePath: "ios/AppDelegate.m",
  find: "something",
  replace: "something else",
});
  • Inserting a string at a specific anchor and offset
withModifyFile(config, {
  filePath: "ios/myapp/AppDelegate.mmm",
  newSrc: "hello",
  anchor: "something",
  offset: 0,
});

This is primaririly used to modify unstructured files that don't have a specific format. For structured files, use more specific plugins like withInfo, withColor, etc.

withSourceFile πŸ€– 🍎

Adds a source file to the project. 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 (which defaults to plugins) to specify a directory (relative to the project root) to place the file in. The parallel directory mirrors the ios or android directory structure.

withSourceFile(config, {
  filePath: "ios/myapp/NewFile.swift",
});

Example file structure:

ios/
β”œβ”€β”€ myapp/
β”‚   β”œβ”€β”€ NewFile.swift
|   └── ...
plugins/
β”œβ”€β”€ ios/
β”‚   └── myapp/
β”‚       └── NewFile.swift
└── ...

withResourceFile πŸ€– 🍎

Add a resource file to the project. Accepts an optional parallelDir parameter (which defaults to plugins) to specify a directory (relative to the project root) to place the file in. The parallel directory mirrors the ios or android directory structure.

withResourceFile(config, {
  filePath: "android/src/main/res/values/strings2.xml",
});

Example file structure:

android/
β”œβ”€β”€ src/
|   β”œβ”€β”€ ...
β”‚   └── main/
β”‚       └── res/
β”‚           └── values/
β”‚               └── strings2.xml
|
plugins/
β”œβ”€β”€ 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. Accepts an array of plugins, where each element is either a plugin or a tuple of a plugin and its (type-safe) options.

withPlugins(config, [
  withPbxProject,
  [withEntitlement, { key: "aps-environment", value: "development" }],
  [withColor, { name: "primaryColor", value: "#000000", night: true }],
]);

Keywords

json

FAQs

Package last updated on 25 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts