chore: add package link and unlink scripts #6238
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Impact: minor
Type: chore
Issue
It's difficult to properly link a work-in-progress plugin (or other npm package) into the API running in a Docker container.
Solution
Adds two new scripts in
bin
:Run
docker-compose up -d
before running any of these commands, and wait until the API has fully started.bin/package-link <package-name>
to link locally cloned package repo into the container andnpm link
it. This assumes that the package lives in../api-plugins
, which will be true if it's a plugin package and you used themake clone-api-plugins
command to clone it.bin/package-link <package-name> <path-to-package-repo>
for any package that is not located in../api-plugins
bin/package-unlink <package-name>
Some additional points
api
service, you will likely get into a loop where the API won't ever start. If this happens, delete the node_modules volume with something likedocker volume rm reaction_api_node_modules
, and thendocker-compose up -d
should work.bin/package-link
command again. You do NOT have to (and must not) manually restart theapi
container. The Reaction API will magically restart after the linking finishes.Example workflow
I cloned reaction-development-platform and ran
make
. API is now running the latest production.Now I want to make a change in the
api-plugin-shops
plugin.First I can clone all plugins by running this in the
reaction-development-platform
directory:Now I need to switch the API to run in development mode:
Now let's move into the API directory:
cd reaction
Then I'll view the logs to make sure the API fully starts:
When I see that it's running, I'll CTRL+C to stop.
Now I can open
<reaction-development-platform directory>/api-plugins/api-plugin-shops
in my editor and make some changes.When I'm ready to link in those changes to test them, I run this in the API directory:
The API will restart when it's done and should reflect the local code changes.
I then make more changes and again run:
When everything is working properly I run:
This reverts the link. Then I can
docker-compose down
if I want to, or link in other packages.Breaking changes
None
Testing
Try it out!