npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@roninoss/plugin-primitives

v0.0.3

Published

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

Downloads

79

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 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

  1. Finding and replacing a string
withModifyFile(config, {
  filePath: "ios/AppDelegate.m",
  find: "something",
  replace: "something else",
});
  1. 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 }],
]);