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

simple-react-native-clone

v1.2.4

Published

Clones similar react-native projects with minor changes

Downloads

15

Readme

simple-react-native-clone

Bulk cloning of a react-native based project to support similar applications. Language 🇺🇸 /

Required

node

brew install node

yarn

brew install yarn

Installation

Produced at the root of the react-native base project

yarn add simple-react-native-clone --dev

You need to create a config file next to package.json

./clone.config.js

Basic configuration example clone.config.js

Launch

Add quick start scripts to package.json

"scripts": {
    "clone": "simple-rn-clone clone",
    "build": "simple-rn-clone build"
}

Clone base project for all clone configurations

yarn clone

Clone base project for one clone configuration named name

yarn clone "name"
yarn clone name     // name without spaces

Build project for all clone configuration

yarn build

Build a project for one configuration named name

yarn build "name"
yarn build name     // name without spaces

Additional launch options -i-ios -a-android

yarn build -a         // collect everything, only for the android platform
yarn build name -i    // build one clone for the ios platform
yarn build -ai        // prepare for build, but not build

Settings

Specify the data of the base project from which the cloning will be performed.

base: {
        folder: '../rn_starter',    // the relative location of the project folder
        name: 'rn_starter',         // his current name
        package: 'com.rn_starter',  // package name
},

Setting up an array of clones

clone: [
    {
        folder: '../rn_starter_company',    // the relative location of the clone folder
        name: 'New AppName',                // new project name and displayName
        package: 'com.rn_starter.company',  // change package name
    },
    //.....
],

When cloning, exclude this data, according to template rsync -av --exclude=PATTERN

exclude: [
    'clone.config.js',
    'node_modules',
    'npm*',
    '.git',
    '.history',
    //.....
],

Copying

Copy files or directories to each clone. The paths are set relative. You need to write the paths as it would work for the base project. The variable ${clone.nameProject} will be replaced with the name of the clone, if the clone has the name "New AppName", then the variable clone.nameProject=NewAppName, This means that the base project must have a folder ./ios/rn_starter/Images_NewAppName.xcassets, which will replace the folder in the clone ./ios/rn_starter/Images.xcassets

All copied files or folders are included in exclude, so that there is no extra data in the clone. Those. the clone will contain only the data that was intended for it.

⚠️ Copying the .git folder from the base project is prohibited by default, each new clone creates its own repository.

copy_global: [
    {
        from: './ios/rn_starter/Images_${clone.nameProject}.xcassets',
        to: './ios/rn_starter/Images.xcassets',
    },
    {
        from: './android/app/src/main/res_${clone.nameProject}',
        to: './android/app/src/main/res',
    },
],

The same principle of copying works for each individual clone, if you need to apply copying not for everyone, but only for a particular case.

clone: [
    {
        folder: '../rn_starter_company',
        name: 'New AppName',
        package: 'com.rn_starter.company',
        copy: [
           {
              from: './android/app/src/main/res_${clone.nameProject}',
              to: './android/app/src/main/res',
           },
        ],
    },
    //.....
],

Copy rules are implemented by the module copy-dir

Replacement

Replacing lines within files or all files in the target directory, for all clones.

replace_global: [
    {
        files: './android/app/build.gradle',       // target file or folder to change
        from: '/(applicationId\\s*")(.+)(")/giu',  // RegExp for search
        to: ['$1${clone.package}$3'],              // what to replace
    },
],

Replacement rules are implemented by the module replace-in-file It works the same way for a specific clone.

Build all clones

The commands for each clone are sequentially executed, they can be changed for your tasks.

build_ios: ['npx react-native run-ios --configuration "Release"'],
build_android: [
    'cd ./android',
    'pwd',
    // './gradlew cleanBuildCache',
    './gradlew assembleRelease',
],