Please ensure you have node installed on your machine.
We will use yarn workspace concepts, hence ensure you've got a key workspaces in your package.json
# package.json
{
...,
"workspaces": ["packages/*"],
...
}otherwise add it. Ensure you are in this project root dir on your shell and run:
# from root dir
mkdir -p packages
cd packages
yarn create-libThese commands created a new directory packages (which should anyway be there already),
then moved into it and run the cli script to spawn a new library.
When prompted:
- insert the name of your library (we will use
custom-lib), - choose whether you want opt in for typescript (we will in this tutorial but it doesn't affect the tutorial that much),
- refuse to create a git repository since we already have one and,
- default the last question
then let's move inside the newly created lib and let's make it apt for a workspace by removing some stuff
# from ./packages
cd custom-lib
rm -rf .yarn .yarnrc.yml yarn.lock
cd ../../and we're back to root dir, please check that everything went ok by running
yarn install
yarn workspace custom-lib testobviously use the library name you prompted in the cli steps.
In your main dir launch,
npx -y -p @micro-lc/backoffice-local-cli create-libor, with yarn 2+,
yarn dlx -p @micro-lc/backoffice-local-cli create-libWhen prompted,
- insert the name of your library (we will use
custom-lib), - choose whether you want opt in for typescript (we will in this tutorial but it doesn't affect the tutorial that much),
- choose whether you want to initialize a git repository,
- default the last question
Please check that everything went ok by running
cd custom-lib
yarn install
yarn testor with npm
cd custom-lib
npm install
npm run testwhere custom-lib must be replaced by the name you gave to your new custom library.
Since the newly created repository comes with out-of-the-box support for yarn stable,
if you want to opt-in for npm you could (but it'd work anyway) remove all yarn-related
files
rm -rf .yarn .yarnrc.yml yarn.lock