1
1
mirror of https://github.com/primer/css.git synced 2024-12-24 14:42:26 +03:00

chore: rm script/reorg 💥

This commit is contained in:
Shawn Allen 2019-02-08 11:39:00 -08:00
parent 54e20045c8
commit 49fb5a10d2

View File

@ -1,106 +0,0 @@
#!/bin/bash
set -e
flag="$1"
dirs="modules tools"
if [[ $flag = "--help" || $flag = "-h" ]]; then
echo
echo "Reorg the monorepo! There are some options available:"
echo
echo " --dry-run Echo all of the commands to be run rather than running them"
echo " --reset Un-stage all changes made by this script to the modules dir"
echo " --help, -h Show this helpful message"
echo
echo "Running this script will stage the entire modules directory so that you"
echo "can more easily see what's moved and changed. In this state, you can still"
echo "diff files with:"
echo
echo " git diff --staged path/to/file"
echo
echo "To return to the original state of the git HEAD, run:"
echo
echo " script/reorg --reset"
echo
exit
elif [[ "$1" = "--reset" ]]; then
git reset $dirs
rm -r $dirs
git co -- $dirs
exit
elif [[ "$1" = "--dry-run" ]]; then
DRY_RUN=1
else
DRY_RUN=0
fi
packages=$($(dirname $0)/get-packages)
modules=$(echo "$packages" | egrep 'modules/' | egrep -v 'primer$')
tools=$(echo "$packages" | egrep 'tools/')
function __() {
if [[ $DRY_RUN -eq 1 ]]; then
echo $@
else
$@
fi
}
function set_json() {
jq "$1 = $2" "$3" > "$3.tmp"
mv "$3.tmp" "$3"
}
function write() {
echo "$1" > "$2"
}
# __ npx lerna clean
primer=modules/primer
# primer/primer => primer/css
__ perl -pi -e 's#primer/primer#primer/css#' {modules,tools}/*/{package.json,*.md,docs/*.md}
for dir in $modules; do
name="${dir/modules\/primer-/}"
dest="$primer/$name"
if [[ -z $dest ]]; then
echo "Ack! Unable strip modules/primer- prefix from: '$dir'"
exit 1
fi
echo "# $dir => $dest"
__ rm -rf $dest
__ mkdir -p $dest
__ git mv $dir/index.scss $dir/README.md $dest
if [[ -e $dir/lib ]]; then
__ git mv $dir/lib/* $dest
fi
if [[ -e $dir/docs ]]; then
__ git mv $dir/docs $dest
fi
__ pushd $dest > /dev/null
__ perl -pi -e 's#primer-#../#' index.scss
__ perl -pi -e 's#/lib/#/#' index.scss
__ popd > /dev/null
__ rm -r $dir
done
for dir in $primer/marketing-*; do
name="${dir/$primer\/marketing-/}"
__ git mv $dir $primer/marketing/$name
done
__ pushd $primer > /dev/null
__ set_json '.name' '"@primer/css"' package.json
__ set_json '.dependencies' '{}' package.json
__ perl -pi -e 's#primer-#./#' index.scss
__ popd > /dev/null
__ rm -rf tools/generator-primer-module
__ git add $dirs