Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use yalc for package link and unlink #6266

Merged
merged 8 commits into from
Jul 2, 2020

Conversation

mikemurray
Copy link
Member

@mikemurray mikemurray commented Jun 30, 2020

Resolves #6248
Impact: minor
Type: feature|chore

MERGE FIRST (node-dev image updates) = reactioncommerce/docker-base#31

Issue

package-unlink seems to unlink more packages than it should. This, plus issues with package-link itself linking packages, but not properly resolving dependencies which leads to code & tests passing locally, then failing on CI.

Solution

Use yalc instead of npm link.

Command breakdown

Linking

Link all packages found in yalc-packages where path/to/package=true
Unlink all packages found in yalc-packages where path/to/package=false

./bin/package-link

Link a new package & update an existing package when you've made changes

./bin/package-link @reactioncommerce/api-plugin-accounts

Unlinking

Unlink a package, run npm install, and re-link previously linked packages

./bin/package-unlink @reactioncommerce/api-plugin-accounts

Updating

Update linked packages based on the entries from the yalc.lock file. If you stopped and started the API container, this will re-link everything.

./bin/package-update

Breaking changes

None, but...

You should destroy your containers and start fresh. Since this is a dev tool, it won't break dependency management otherwise.

Testing

  1. Checkout the reaction-development-platform
  2. Follow setup instructions namely make init and make clone-api-plugin
  3. run the API
  4. cd reaction
  5. ./bin/package-link @reactioncommerce/api-core or any api plugin in the api-plugins directory
  6. See the package is installed and running
  7. Make the ping query in a GraphQL playgorund (http://localhost:3000/graphql) to see pong
  8. Make a change or something. I edited src/graphql/resolvers/index.js and changed ping to ping: () => "pong TEST"
  9. run ./bin/package-link @reactioncommerce/api-core again to update
  10. run the ping query and see pong TEST
  11. unlink with ./bin/package-unlink @reactioncommerce/api-core
  12. run the ping query again, and you should only see pong

  1. run ./bin/package-link without any arguments
  2. see all packages are linked
  3. edit yalc-packages
  4. set some packages to false
  5. run ./bin/package-link again
  6. verify that those packages are removed

@mikemurray mikemurray marked this pull request as ready for review June 30, 2020 22:03
@mikemurray mikemurray changed the title chore: use yalc for package link and unlink [WIP] chore: use yalc for package link and unlink Jun 30, 2020
mpaktiti
mpaktiti previously approved these changes Jul 1, 2020
Copy link
Contributor

@mpaktiti mpaktiti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! 🚢

@mikemurray mikemurray requested a review from mpaktiti July 1, 2020 22:36
@mikemurray
Copy link
Member Author

@mpaktiti Need a re-review please! 😄

I added a yalc-packages.exmaple file that is automatically copied (if it doesn't exist) and read when running ./bin/package-link without any arguments.

This allows for bulk linking of api plugins and should be even more of a help when testing multiple changed packages. package-link will still work normally if you want to do one at a time though.

I also removed the yalc check/install code because it was actually checking your local machine for yalc instead of the container. I made a new node-dev image that has yalc pre-installed here: reactioncommerce/docker-base#31

@mikemurray mikemurray changed the title [WIP] chore: use yalc for package link and unlink chore: use yalc for package link and unlink Jul 1, 2020
Copy link
Member

@manueldelreal manueldelreal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit: LGTM

@mikemurray mikemurray merged commit b4bc8ee into trunk Jul 2, 2020
@mikemurray mikemurray deleted the chore-6248-mikemurray-fix-package-link-scripts branch July 2, 2020 17:40
@almousa1990
Copy link

Works great with reaction plugins.

I am not sure if this is the right place to ask, but is there any way to link custom packages? as i understand, packages are loaded from package.json, i tried to do package-link @reaction/custom-plugin, then added this plugin in package.json. However, it doesn't seem to able to locate it.

@almousa1990
Copy link

I got it, yalc publish on plugin folder did the trick

@kieckhafer kieckhafer mentioned this pull request Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bin/package-unlink unlinks all packages instead of the one that was specified
4 participants