NPM Scope Change
Relevant Epic: NPM Ownership · Issue #23 · openedx/axim-engineering
tl;dr: Openedx NPM Packages are currently under the @edx
scope and owned by a user shared with 2U. We want to move it to a scope called @openedx
that is managed by Axim while leaving behind any packages that are 2U specific.
Plan
How-Tos
How to Move from the @edx
scope to the @openedx
scope
Update the docs in the repo that you’re updating. It will be a PR like this: fix: Update docs for a final publish before we move this package. by feanil · Pull Request #2744 · openedx/paragon
Ensure that the PR has been published to the old package and the latest docs reflect the changes we expect.
Make a PR to move the package to the new scope. It will probably look like this: feanil/move package by feanil · Pull Request #2745 · openedx/paragon
Ensure that the new package is published and looks correct.
Add a new post here on discourse. Look at some of the earlier posts for examples.
Update the spreadsheet above with the date when the move occurred.
How to Update all the places where the package is referenced
Once the repo has moved, we need to update all the repos that reference the old package in their package.json
so that it uses the new package. We’ll also need to update code that imports the old package to import the new package.
Use repo-tools to clone the whole
openedx
org locally.pip install git+https://github.com/openedx/repo-tools.git@master export GITHUB_TOKEN=.... clone_org openedx --username <your_github_username> --token $GITHUB_TOKE
Find all the repos that are referencing the old package name.
# rg '@edx/paragon' **/package.json -l | awk -F/ '{ print $1 }' | sort -u > paragon_upgrade.repos rg '<your_package_name_here>' **/package.json -l | awk -F/ '{ print $1 }' | sort -u > old_scope.repos
Review the list and make sure it looks okay.
Run something like the following to update all the references to the old package. Maybe run it on just one or two repos to start with before you run it on everything.
#!/usr/bin/env zsh cat <<EOF > paragon_upgrade.message chore: Update to the new version of paragon in the new scope. Part of https://github.com/openedx/axim-engineering/issues/23 This replaces the `@edx/paragon` packag to point to the `paragon` package at the `openedx` scope(`@openedx/paragon`). Imports have been updated to use the same locations in the new package. EOF for i in `cat paragon_upgrade.repos | grep -v "^#"`; do ; cd $i; echo `pwd`; git checkout -b feanil/update_paragon_dependency; perl -pi -e "s#\"\@edx/paragon\": \"([\^~>=]{,2})?\d+\.\d+\.\d+\"#\"\@openedx/paragon\": \"21.5.7\"#" package.json nvm use; npm install; rg "@import ['\"]~?@edx/paragon" -l | xargs -I{} perl -pi -e "s#\@import ([\'\"])(\~)?\@edx/paragon#\@import \1\2\@openedx/paragon#" {} rg "from ['\"]~?@edx/paragon" -l | xargs -I{} perl -pi -e "s#from ([\'\"])(\~)?\@edx/paragon#from \1\2\@openedx/paragon#" {} git commit -a -F /home/feanil/src/openedx/paragon_upgrade.message; # create a draft PR gh pr create -f -d && gh pr view --web; cd /home/feanil/src/openedx; break; done;