###Prerequisites
- Should install yarn first.Rig is using yarn workspace to do module-hoisting.
npm i -g yarn
###Installation
yarn global add rigjs
###Configuration You could try the demo for quick practice.
####1.init rig in your project In your project's root path.
rig init
package.rig.json5 will be added to your project's root.
####2.Put the modules you want in git repos
-
Create semver style tag for your modules
-
Tags like 1,1.0,1.0.0,v1.0.0-alpha.110 are supported.
Or you can just use following repos for testing:
rig-test-1:git@github.com:FlashHand/rig-test-1.git
rig-test-2:git@github.com:FlashHand/rig-test-2.git
####3.configuring package.rig.json5
copy this and try
//dev is false by default
[
// {
// name: 'module',//module's name
// source: 'git@git.domain.com:path/module.git',//module's source,not supporting http for now.
// version: '1.0.0',//Notice:this used as tag.module's version ,
// },
{
name: 'rig-test-1',
source: 'git@github.com:FlashHand/rig-test-1.git',
version: '1.0.0',
},
{
name: 'rig-test-2',
source: 'git@github.com:FlashHand/rig-test-2.git',
version: '1.0.1',
dev: true
}
]
####4.run install:
yarn
Result:
rig-test-1 will be installed in node_modules.
rig-test-2 will be cloned to rigs/.A shortcut of rig-test-2 will be created in node_modules.
###Intergrating and reusing codes really fast.
- Git is enough.No need to publish to npm or private registry.Much simpler than git submodule.
- Easily configurable.After configuration in simply use 'yarn install' and import/require your modules just like npm modules.
- Support modules in any scale: from a simple js file to many web page files.
###Easily develop and debug modules inside your project.
###All modules managed by rigjs are flatten.
-
Put the modules you wanna intergrating in git repos.
-
Configure those modules in
-
Integrating other git reposCreated for modular architecture.
-
An organizer for multi repos.
-
You can develop and test your module within your project just by setting dev to true,then rigjs automatically create shortcuts in node_modules folder for your developing modules in rigs folder.
-
Modules are hoisted,because rigjs uses yarn's workspace.
-
Automatically create shortcuts in node_modules folder for your developing modules in rigs folder.
Rig is inspired by cocoapods. Not like those popular monorepo solutions,rig is a tool for organizing multi repos. So rig create a file named "package.rig.json5". Data in "package.rig.json5" can look like this:
//dev is false by default
//dev 默认为false
[
// {
// name: 'r-a',//module's name
// source: 'git@git.domain.com:common/r-a.git',//module's source
// version: '1.0.0',//Notice:this used as tag.module's version ,
// },
{
name: 'r-b',
source: 'git@git.domain.com:common/r-b.git',
version: '1.0.0',
},
{
name: 'r-c',
source: 'git@git.domain.com:common/r-c.git',
version: '1.0.0',
dev: true
}
]
package.rig.json5 has an array of modules.
So rig create a folder named "rigs".
When dev is true,the module will be cloned in rigs/(using master branch).
And it gets automatically linked in node_modules.
//Rig will insert these to package.json
//Rig won't cover your preinstall or postinstall's settings.Scripts and workspaces will be appended.
let inserted = {
private: true,
workspaces: [
"rigs/*",
"rigs_dev/*"
],
scripts: {
preinstall: "rig preinstall",
postinstall: "rig postinstall",
}
}
How to remove your modules
Remove your modules from both package.json and package.rig.json5 then run rig install or yarn install.
//TODO: rig check //if has dev:true then end shell rig tag //using package.json version
- create a "package.rig.json5" file
- insert config to package.json
- create "rigs" folder
- modify .gitignore
equals to "yarn install"
If a module's dev status is true in "package.rig.json5",the config will not be passed!
Make sure you are not using developing modules for production.
Using version in package.json to tag.
This command is specially for vue.This command reads the file named "env.rig.json5" in the root directory, and looks for the environment configuration in mode .Then it will create a file named ".env.rig" or overwrite the file if ".env.rig" is not existed. After "rig --vueenv" you must use "--mode rig" to make it effective. e.g.
#serving a local site in dev enviroment
rig --env dev && vue-cli-service serve --mode rig
#building a site in prod enviroment
rig --env prod && vue-cli-service build --mode rig