0.2.8 • Published 5 years ago

protato v0.2.8

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

protato logo

travis CI

HMR. Auto-update parent module's child dependency when you update that child dependency's file

FAQ

This is a summary of how Protato fits into my design/development flow.

Install (Optional)

If you'd rather not install, you can use npx

  • Install CLI globally npm install -g protato
  • Install CLI as dev dependency npm install -D protato

Usage

Watch your files and update your dependency tree automatically

protato watch

CLI Config

In order to watch your files, you need to supply protato with a config file. It must be named .protato.json

Example used in unit tests

{
	"parent": {
		"dir": "sandbox/node-starter"
	},
	"children": [
		{
			"dir": "sandbox/npm-starter-sample-module",
			"src": "src"
		},
		{
			"dir": "sandbox/library-genesis",
			"src": "src"
		}
	]
}

What differentiates this unit test example is I'm making the parent a subdirectory as well. Normally, your parent directory would be your root directory/cwd. The sandbox directory was initialized using repo-genesis

Abstract example

  • protato-cli
    • protato-lib
    • tacker

In this project example, I want "protato-cli" to update its dependencies whenever "protato-lib" or "tacker" are updated locally. Let's say I changed protato-lib/src/index.js, it would then trigger an update which would re-link the packages.

Breaking down the example

NameCategoryAttributes Description
protato.jsonConfig file namethis file should be declared at the root of your project
parentTop-level keythis represents your entry point project; it relies on your child modules
childrenTop-level keymodules you are working on locally
dirParent & Children keyroot of children to watch or parent project to update; relative from cwd
srcChildren keyspecific directory to watch

Roadmap

CLI Commands

StatusNameDescription
:white_check_mark:watchBegin watching your child modules for updates
:ballot_box_with_check:yalcList your current packages; install yalc if directory not found.
:ballot_box_with_check:configGenerate an empty config if you don't have one in your CWD.

CLI Flags

StatusNameDescription
:white_check_mark:--helpPrint help menu
:ballot_box_with_check:--linkAdd child package symlink in your parent project
:ballot_box_with_check:--addPull child package contents into your parent project

Minor Features

  • Currently doesn't update child module builds before re-linking

    TODO: Create CLI flag and library logic to parse "build" in package.json before updating dependency

  • Each child module relies on the same root directory. This is prohibitive.

    TODO: Enable per-child-module cwd. Add object to config and handle parsing.

  • Currently, child modules cannot exist outside of the current "monolith". They assume they same CWD

    TODO:This is fine if repo-genesis is being used. But it could be annoying for others. Fix to this is allow absolute pathing. Add a "cwd" object to the config to specify root directory. Override the cwd default (be that process.cwd() or process.env.configRootDir)

  • It'd be great to have a demo project.

    TODO: Have to make some changes to repo-genesis (to allow auto-install modules)

  • process.env.configRootDir was added but never tested or discussed in readme

    TODO: Write unit test and update readme accordingly

  • Especially in the case of newly cloned projects, it's annoying that protato will throw IF node_modules are missing.

    CONTEXT: While npm install is an easy fix, it's obnoxious if there are multiple subdirectories being cloned via repo-genesis TODO: Add auto-install node_modules feature to protato-lib