Code Monkey home page Code Monkey logo

lernaman's Introduction

lernaman

Manager for arranging/managing lerna-based packages under your app project.

Why?

React-native's metro builder really doesn't like working with peer directories. So the easiest way to get benefit from managing your JS modules is to use a lerna-managed monorepo, and then link those packages to your app in a parent/ancestor directory.

Basically,it makes JS development for nontrivial React-native much much easier.

Installation

This is easier than manual work, but it still has some steps:

  1. Make a lerna-based repository with the code you want to use. (for example https://github.com/me/modules)
  2. Make an app using react-native init or create-react-native-app
  3. Switch to your app directory
  4. yarn add lernaman
  5. yarn run lernaman add https://github.com/me/modules --update
  6. Set your "root" component to be one of your modules - using the pakage name. (I like to use react-native-set-root for this, eg react-native-set-root @rhdeck/rootmodule)
  7. yarn start
  8. Oops! Discover your missing dependencies (probably defined as peerDependencies in your module) and yarn add them.
  9. 'yarn start' again, and watch everything just work

Rehydration

Later, when you have committed your app then pull it down somewhere later, after your initial git clone and yarn install steps, run yarn run lernaman init --update to get your lerna packages deployed into your app. That's all there is to it!

Usage

lernaman --help

Get listing of commands. Useful.

lernaman add [name][--init] [--update]

lernaman init [name][--update]

Initialize lerna package [name] that is specified in package.json by copying/cloning into the appropriate directory. If --update is passed, the functionality of lernaman update [name] gets applied subsequently.

If name is not supplied, it will run the link process for all.

lernaman update [name]

NPM/Yarn isntall an initialized lerna package [name], bootstrap it, and run the "build" script defined within. Will automatically run the lernaman link functionality immediately after.

If name is not supplied, it will run the link process for all.

lernaman link [name]

Deploy symbolic links from the packages managed at lernas/[name] to your immediate node_modules directory. No bootstrap or other build process is applied.

If name is not supplied, it will run the link process for all.

lernaman remove

Remove the package at lernas/[name]. The package itself is recursively removed and the entry in package.json is eliminated to prevent future re-hydration.

Notes

This tool is for handling a complex situation, so it takes a little more work to get the most out of it. But

lernaman's People

Contributors

rhdeck avatar

Watchers

James Cloos avatar  avatar

lernaman's Issues

Request: Add support for exiting 'lernman update' on error

Description:
Add release/dev switch to pass to 'lernaman update' so that in 'release' mode any errors encountered during 'lernaman update' will stop the update process (e.g. exit(1)) and alert the user.

Use case:
Using 'fastlane' to automate build of lernaman app always returns false positive.

Running 'lernaman update' via fastlane will always return success even though the lernaman ran into errors.

Lernaman 'update' fails if directory is missing package.json

Description:
Running yarn run lernaman update failed when a direcotry in lernas/ did not include a package.json

Error message:

Error: Cannot find module '/Users//Documents/builds/maketime4app2/lernas/maketime4/packages/deprecated/package.json'

Note:
'deprecated' does not have a package.json file because folder holds code that is not being used in primary app, but may still have some value for future reference.

Project directory structure looks like:
root/
lernas/
maketime/
deprecated/

Workaround:
Add package.json file

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.