Skip to content

AllenFang/lerna-tutorial-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Lerna Tutorial Example

This repo give you an independent enviornment to play with lerna. We leverage on Docker to provide you a gitserver and a lightweight npm server so that you can easy to understand and learn how lerna publish, release and so on.

You will have following components after setup:

  • NPM server(We use verdaccio)
    • npmserver is docker dontainer name
  • GIT server(Simple git server on SSH and already contain a bare repository)
    • gitserver is docker dontainer name
  • Workspace(Git, Node.js and NPM installed), develop/testing/deploy/publish here!!
    • workspace is docker dontainer name

Setup

Install and run

####### GENERATE SSH KEY IF YOU DON'T HAVE YET #######
$ cd ~
$ mkdir .ssh
$ ssh-keygen -t rsa
######################################################

$ git clone https://github.com/AllenFang/lerna-tutorial-example.git
$ cd lerna-tutorial-example
$ cp ~/.ssh/id_rsa.pub ./docker/git-server/keys
$ cp ~/.ssh/id_rsa ./docker/git-server/keys
$ cd docker
$ docker-compose up -d

After docker compose start, gitserver and npmserver will run in the background then you need to type following commands to launch to workspace container to do further setup:

docker-compose run workspace sh

Setup NPM

$ npm set registry http://npmserver:4873
$ npm adduser --registry http://npmserver:4873  # Keyin your username, password and email

Then open your browser and do login via http://localhost:4873. After login, you will see no any package published yet. So two steps you need to do as below:

Setup GIT

$ git config --global user.email "you@example.com"  # Keyin your email
$ git config --global user.name "Your Name"  # Keyin your username

Setup Dummy Project

$ git clone ssh://git@gitserver/git-server/repos/examples.git
$ cd examples
$ npm install

Lerna Test

After above commands, you already setup the git and npm config in the workspace container then it's time that we can publish modules via lerna:

$ ./node_modules/.bin/lerna publish

After above comment, lerna will ask you auto detect what packages had changes since last publish and ask you what version you want to upgrade by a prmopt. Following is the result screenshot:

lerna publish result

When you go to http://localhost:4873, you will see following result: npm publish result

About

A lerna practice project provided by Docker

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages