Linking local dependencies¶
This guide explains how to link local dependencies into a Lime CRM solution.
Info
Linking local dependencies is super helpful when you're developing libraries and testing them in a solution. It's useful when doing end-to-end testing, debugging, and before making commits / PRs / releases.
The diagram below presents a convenient setup for most developers in Lime CRM:
---
title: Conceptual diagram of local development dependencies
---
graph LR
subgraph lime-crm-components
crm-components(package.json)
end
subgraph lime-web-components
web-components(package.json)
end
subgraph solution-kulfon
solution-python(pyproject.toml)
end
subgraph lime-crm
crm-python(pyproject.toml)
end
subgraph lime-webclient
webclient-python(pyproject.toml)
webclient-js(package.json)
webclient-webclient-js(webclient/package.json)
webclient-admin-js(admin/package.json)
end
subgraph lime-core
core-python(pyproject.toml)
end
solution-python -- poetry add --> crm-python
crm-python -- poetry add --> webclient-python
crm-python -- poetry add --> core-python
webclient-python -- poetry add --> core-python
web-components -- npm link --> crm-components
crm-components -- npm link --> webclient-js
webclient-js -. use from root .- webclient-webclient-js
webclient-js -. use from root .- webclient-admin-js
classDef python fill:green,color:white,stroke-width:0px;
classDef js fill:blue,color:white,stroke-width:0px;
class solution-python,crm-python,webclient-python,core-python python;
class webclient-js,webclient-webclient-js,webclient-admin-js,web-components,crm-components js;
solution-kulfon here is an example solution created by running lime-project new solution.
Prerequisite¶
Ensure all projects are cloned and installed according to instructions which can be found in relevant repositories.
Setup¶
Setup consists of few steps that depend on each other. Linking all local dependencies is optional and you can skip linking any of npm module / Python package. In such case you need to do this consequently, so if you decide to not link e.g. local lime-web-components then you should not attach this module in lime-crm-components and lime-webclient, to have consistent setup. Also you can skip steps 4 and 5 if you are not using any "solution" and want to run lime-webclient directly.
1. Prepare lime-web-components and lime-crm-components for local development¶
- Navigate to
lime-web-components/packages/lime-web-componentsfolder. - Build the project by running
npm run build. - Run
npm link. This will register locallime-web-componentsin globalnode_modules. - Navigate to
lime-crm-componentsroot folder. - Run
npm install. - Run
npm link @limetech/lime-web-components. - Now local
lime-crm-componentsshould use locallime-web-components! - Run
npm link. This will register locallime-crm-componentsin globalnode_modules. - Done! Now
lime-web-componentsandlime-crm-componentsare ready to be linked tolime-webclientfrontend applications! ✨
To verify that everything works as expected you can run npm list --global. It should look similar to:
/home/kulfon/.nvm/versions/node/v16.18.0/lib
├── @limetech/[email protected] -> ./../../../../../Projects/update_platform_docs/lime-web-components
├── @lundalogik/[email protected] -> ./../../../../../Projects/update_platform_docs/lime-crm-components
├── [email protected]
└── [email protected]
2. Linking lime-web-components and lime-crm-components to lime-webclient¶
- Navigate to the root folder of
lime-webclient. - Run
npm installandnpm link @limetech/lime-web-components @lundalogik/lime-crm-components. - Now it is the time to build all frontend applications. In each of
frontend/adminandfrontend/webclientdirectories run: npm installnpm run build
Done! Now all your frontend applications should use local lime-crm-components and lime-web-components! ✨
You can verify that by running npm list in lime-webclient root folder. It should look similar to:
lime-webclient@ /home/kulfon/Projects/lime-webclient
├── @limetech/[email protected]
├── @limetech/[email protected]
├── @limetech/[email protected] -> ./../lime-web-components
├── @lundalogik/[email protected] -> ./../lime-crm-components
├── @lundalogik/[email protected]
└── @lundalogik/[email protected]
3. Linking lime-core to lime-webclient¶
- Navigate to
lime-webclientroot folder. - Run
poetry add -e <path_to_local_lime-core_root>to use lime-core in editable development mode - Run
poetry install. - Done! Now
lime-webclientshould use local version oflime-core! ✨
4. Linking lime-core and lime-webclient to lime-crm¶
- Navigate to
lime-crmroot folder. - Run
poetry add -e <path_to_local_lime-core_root>to use lime-core in editable development mode - Run
poetry add -e <path_to_local_lime-webclient_rootto use lime-webclient in editable development mode - Run
poetry install. - Done! Now
lime-crmshould use local versions oflime-coreandlime-webclient! ✨
5. Linking lime-crm to solution-kulfon¶
- Navigate to
solution-kulfonroot folder. - Run
poetry add -e <path_to_local_lime-crm_root>to use lime-crm in editable development mode - Run
poetry install. - Done! Now
solution-kulfonshould use local version oflime-crm! ✨
Running solution¶
Using full setup with solution-kulfon¶
- Navigate to
lime-crm-componentsroot folder and runnpm start. - In separate terminal navigate to
lime-webclient/frontend/webclientand runnpm start. - In separate terminal navigate to
lime-webclient/frontend/adminand runnpm start(if you need the access to the admin page). - In separate terminal navigate to
solution-kulfon, make sure thatFLASK_ENV=developmentis present in.envfile, and runpoetry run flask runor run the server in the debugging mode in VSCode.
Using lime-webclient only¶
- Navigate to
lime-crm-componentsroot folder and runnpm start. - In separate terminal navigate to
lime-webclient/frontend/webclientand runnpm start. - In separate terminal navigate to
lime-webclient/frontend/adminand runnpm start(if you need the access to the admin page). - In separate terminal navigate to
lime-webclientand runpoetry run flask runor run the server in the debugging mode in VSCode.
General notes¶
pyproject.tomlis versioned file, so make sure to not push changes that relate to linking local Python dependencies.- Alternative way of linking local Python dependencies is running
poetry add <path_to_dependency>. If you already have the remote package in your venv-folder you might have to remove it manually first. - Running
npm installafter linking local JavaScript dependencies will reset them according to a project'spackage.json, so you will need to link them to a dependant project again.