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

[Feature] Cargo Export/Import multimachine #13

Merged
merged 32 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ad8d135
Added cargo export/import
gtrabanco May 18, 2021
0e01e28
Fix(dump.sh): Apply patch to fix wrong importing file
gtrabanco May 24, 2021
7b84efa
Restored dot and output from master to avoid merging problems
gtrabanco May 27, 2021
28ef1ce
Updated with latest feature/core
gtrabanco May 28, 2021
de9688c
Merge branch 'feature/core' into feature/cargo_export_import
gtrabanco May 28, 2021
808af19
Merge branch 'feature/multiple_machines' into feature/cargo_export_im…
gtrabanco May 28, 2021
145f4d9
Merge branch 'feature/multiple_machines' into feature/cargo_export_im…
gtrabanco May 28, 2021
5d991c2
Added double quotes in _main for DOTLY_PATH because it can contain no…
gtrabanco May 28, 2021
4089eae
Improved output::join with a stackoverflow function in: https://stack…
gtrabanco Mar 28, 2021
27603ab
Added closed and unapproved PR #61 because it is needed when I use be…
gtrabanco Mar 28, 2021
5ef26e0
Added a way to modify DOTFILES_PATH structure when add a feature to d…
gtrabanco Mar 29, 2021
17e1a79
Added some core functions:
gtrabanco Mar 31, 2021
c63122b
Added async library
gtrabanco Apr 1, 2021
ad49d03
Merge branch 'feature/core' into feature/cargo_export_import
gtrabanco May 29, 2021
337c4b3
Merge branch 'feature/multiple_machines' into feature/cargo_export_im…
gtrabanco May 29, 2021
e5bc080
Merge branch 'feature/multiple_machines' into feature/cargo_export_im…
gtrabanco May 29, 2021
c19927f
Merge branch 'feature/core' into feature/cargo_export_import
gtrabanco May 30, 2021
981b866
Merge branch 'feature/multiple_machines' into feature/cargo_export_im…
gtrabanco May 30, 2021
f1febe8
Merge branch 'feature/core' into feature/cargo_export_import
gtrabanco May 30, 2021
ed169e7
Merge branch 'feature/multiple_machines' into feature/cargo_export_im…
gtrabanco May 30, 2021
3a69d40
Merge branch 'feature/multiple_machines' into feature/cargo_export_im…
gtrabanco May 30, 2021
43d4142
Added couple of kill to view the effecto of importing defaults
gtrabanco May 31, 2021
6afe2e1
Fixed not well included dump.sh library
gtrabanco May 31, 2021
8317fa2
Added couple of kill to view the effect of importing defaults
gtrabanco May 31, 2021
6dd661c
Fixed not well included dump.sh library
gtrabanco May 31, 2021
0c516e8
Fix update when no update yaml file is given and no choose in fzf sel…
gtrabanco Jun 2, 2021
4864a79
Merge branch 'feature/core' into feature/multiple_machines
gtrabanco Jun 3, 2021
9e8e7ae
Changed the name of dot::get_script_src_path to dot::load_library.
gtrabanco Jun 3, 2021
e77c7d4
Changed the name of dot::get_script_src_path to dot::load_library
gtrabanco Jun 3, 2021
e84aa4f
Merge branch 'feature/multiple_machines' into feature/cargo_export_im…
gtrabanco Jun 9, 2021
2fdb4cd
Merge branch 'feature/multiple_machines' into feature/cargo_export_im…
gtrabanco Jun 9, 2021
d25d1d8
Merge branch 'feature/multiple_machines' into feature/cargo_export_im…
gtrabanco Jun 13, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions scripts/package/dump
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fi
HOMEBREW_DUMP_FILE_PATH="$DOTFILES_PATH/os/$(platform::os)/brew/${HOSTNAME}.txt"
APT_DUMP_FILE_PATH="$DOTFILES_PATH/os/linux/apt/${HOSTNAME}.txt"
SNAP_DUMP_FILE_PATH="$DOTFILES_PATH/os/linux/snap/${HOSTNAME}.txt"
CARGO_DUMP_FILE_PATH="$DOTFILES_PATH/langs/rust/cargo/${HOSTNAME}.txt"
PYTHON_DUMP_FILE_PATH="$DOTFILES_PATH/langs/python/${HOSTNAME}.txt"
NPM_DUMP_FILE_PATH="$DOTFILES_PATH/langs/js/npm/${HOSTNAME}.txt"
VOLTA_DUMP_FILE_PATH="$DOTFILES_PATH/langs/js/volta/${HOSTNAME}.txt"
Expand All @@ -51,6 +52,13 @@ VOLTA_DUMP_FILE_PATH="$DOTFILES_PATH/langs/js/volta/${HOSTNAME}.txt"
output::empty_line
} || package::clarification "${snap_title:-SNAP}"

{
platform::command_exists cargo &&\
package::cargo_dump "$CARGO_DUMP_FILE_PATH" &&\
output::answer "${cargo_title:-Cargo} apps dumped on $CARGO_DUMP_FILE_PATH" &&\
output::empty_line
} || package::clarification "${cargo_title:-Cargo}"

{
platform::command_exists pip3 && \
package::python_dump "$PYTHON_DUMP_FILE_PATH" && \
Expand Down
11 changes: 11 additions & 0 deletions scripts/package/import
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ docs::parse "$@"
BREW_PATH="${BREW_PATH:-$DOTFILES_PATH/os/$(platform::os)/brew}"
APT_PATH="${APT_PATH:-$DOTFILES_PATH/os/linux/apt}"
SNAP_PATH="${SNAP_PATH:-$DOTFILES_PATH/os/linux/snap}"
CARGO_PATH="${CARGO_PATH:-$DOTFILES_PATH/langs/rust/cargo/}"
PYTHON_PATH="${PYTHON_PATH:-$DOTFILES_PATH/langs/python}"
NPM_PATH="${NPM_PATH:-$DOTFILES_PATH/langs/js/npm}"
VOLTA_PATH="${VOLTA_PATH:-$DOTFILES_PATH/langs/js/volta}"
Expand All @@ -36,6 +37,7 @@ VOLTA_PATH="${VOLTA_PATH:-$DOTFILES_PATH/langs/js/volta}"
HOMEBREW_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$BREW_PATH")"
APT_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$APT_PATH")"
SNAP_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$SNAP_PATH")"
CARGO_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$CARGO_PATH")"
PYTHON_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$PYTHON_PATH")"
NPM_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$NPM_PATH")"
VOLTA_DUMP_FILE_PATH="$(package::exists_dump_current_machine_file "$VOLTA_PATH")"
Expand All @@ -44,6 +46,7 @@ if ! ${never_prompt:-false}; then
platform::command_exists brew && [[ -z "$HOMEBREW_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$BREW_PATH" "Select ${brew_title:-Brew} file to import" "HOMEBREW_DUMP_FILE_PATH"
platform::command_exists apt && [[ -z "$APT_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$APT_PATH" "Select ${apt_title:-APT} file of modules to import" "APT_DUMP_FILE_PATH"
platform::command_exists snap && [[ -z "$SNAP_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$SNAP_PATH" "Select ${snap_title:-SNAP} file of modules to import" "SNAP_DUMP_FILE_PATH"
platform::command_exists cargo && [[ -z "$CARGO_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$CARGO_PATH" "Select ${cargo_title:-Cargo} file to import" "CARGO_DUMP_FILE_PATH"
platform::command_exists pip3 && [[ -z "$PYTHON_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$PYTHON_PATH" "Select ${pip_title:-Python} requirements file to import" "PYTHON_DUMP_FILE_PATH"
platform::command_exists volta && [[ -z "$VOLTA_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$VOLTA_PATH" "Select ${volta_title:-volta} file to import" "VOLTA_DUMP_FILE_PATH"
platform::command_exists npm && [[ -z "$NPM_DUMP_FILE_PATH" ]] || ${prompt:-false} && package::which_file "$NPM_PATH" "Select ${npm_title:-NPM} file of modules to import" "NPM_DUMP_FILE_PATH"
Expand Down Expand Up @@ -75,6 +78,14 @@ output::write "🎩 Let's import your packages (this could take a while)" && out
} ||\
output::answer "Ignoring SNAP"

{
platform::command_exists cargo &&\
output::header "Importing Cargo apps from $CARGO_DUMP_FILE_PATH" &&\
package::cargo_import &&\
output::empty_line
} ||\
output::answer "Ignoring Cargo"

{
platform::command_exists pip3 && [[ -n "$PYTHON_DUMP_FILE_PATH" ]] &&\
output::empty_line &&\
Expand Down
48 changes: 36 additions & 12 deletions scripts/package/src/dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ package::brew_dump() {
if package::common_dump_check brew "$HOMEBREW_DUMP_FILE_PATH"; then
output::write "🚀 Starting Brew dump to '$HOMEBREW_DUMP_FILE_PATH'"

brew bundle dump --file="$HOMEBREW_DUMP_FILE_PATH" --force | log::file "Exporting $brew_title packages list"
brew bundle dump --file="$HOMEBREW_DUMP_FILE_PATH" --force | log::file "Exporting $brew_title packages"
brew bundle --file="$HOMEBREW_DUMP_FILE_PATH" --force cleanup || true

return 0
Expand All @@ -91,7 +91,7 @@ package::brew_import() {

if package::common_import_check brew "$HOMEBREW_DUMP_FILE_PATH"; then
output::write "🚀 Importing 🍺 brew from '$HOMEBREW_DUMP_FILE_PATH'"
brew bundle install --file="$HOMEBREW_DUMP_FILE_PATH" | log::file "Importing $brew_title packages list"
brew bundle install --file="$HOMEBREW_DUMP_FILE_PATH" | log::file "Importing $brew_title packages"

return 0
fi
Expand All @@ -104,7 +104,7 @@ package::apt_dump() {

if package::common_dump_check apt "$APT_DUMP_FILE_PATH"; then
output::write "🚀 Starting APT dump to '$APT_DUMP_FILE_PATH'"
apt-mark showmanual >|"$APT_DUMP_FILE_PATH" | log::file "Exporting $apt_title packages list"
apt-mark showmanual >|"$APT_DUMP_FILE_PATH" | log::file "Exporting $apt_title packages"

return 0
fi
Expand All @@ -117,7 +117,7 @@ package::apt_import() {

if package::common_import_check apt "$APT_DUMP_FILE_PATH"; then
output::write "🚀 Importing APT from '$HOMEBREW_DUMP_FILE_PATH'"
xargs sudo apt-get install -y <"$APT_DUMP_FILE_PATH" | log::file "Importing $apt_title packages list"
xargs sudo apt-get install -y <"$APT_DUMP_FILE_PATH" | log::file "Importing $apt_title packages"
fi
}

Expand All @@ -126,7 +126,7 @@ package::snap_dump() {

if package::common_dump_check snap "$SNAP_DUMP_FILE_PATH"; then
output::write "🚀 Starting SNAP dump to '$SNAP_DUMP_FILE_PATH'"
snap list | tail -n +2 | awk '{ print $1 }' >|"$SNAP_DUMP_FILE_PATH" | log::file "Exporting $snap_title containers list"
snap list | tail -n +2 | awk '{ print $1 }' >|"$SNAP_DUMP_FILE_PATH" | log::file "Exporting $snap_title containers"

return 0
fi
Expand All @@ -139,7 +139,7 @@ package::snap_import() {

if package::common_import_check snap "$SNAP_DUMP_FILE_PATH"; then
output::write "🚀 Importing SNAP from '$HOMEBREW_DUMP_FILE_PATH'"
xargs -I_ sudo snap install "_" <"$SNAP_DUMP_FILE_PATH" | log::file "Importing $snap_title containers list"
xargs -I_ sudo snap install "_" <"$SNAP_DUMP_FILE_PATH" | log::file "Importing $snap_title containers"
fi
}

Expand All @@ -148,7 +148,7 @@ package::python_dump() {

if package::common_dump_check pip3 "$PYTHON_DUMP_FILE_PATH"; then
output::write "🚀 Starting Python dump to '$PYTHON_DUMP_FILE_PATH'"
pip3 freeze >"$PYTHON_DUMP_FILE_PATH" | log::file "Exporting $pip_title packages list"
pip3 freeze >"$PYTHON_DUMP_FILE_PATH" | log::file "Exporting $pip_title packages"

return 0
fi
Expand All @@ -160,7 +160,7 @@ package::python_import() {
PYTHON_DUMP_FILE_PATH="${1:-$PYTHON_DUMP_FILE_PATH}"

if package::common_import_check pip3 "$PYTHON_DUMP_FILE_PATH"; then
output::write "🚀 Importing Python packages from '$PYTHON_DUMP_FILE_PATH'" | log::file "Importing $pip_title packages list"
output::write "🚀 Importing Python packages from '$PYTHON_DUMP_FILE_PATH'" | log::file "Importing $pip_title packages"
pip3 install -r "$PYTHON_DUMP_FILE_PATH"

return 0
Expand All @@ -174,7 +174,7 @@ package::npm_dump() {

if package::common_dump_check npm "$NPM_DUMP_FILE_PATH"; then
output::write "🚀 Starting NPM dump to '$NPM_DUMP_FILE_PATH'"
ls -1 /usr/local/lib/node_modules | grep -v npm >|"$NPM_DUMP_FILE_PATH" | log::file "Exporting $npm_title packages list"
ls -1 /usr/local/lib/node_modules | grep -v npm >|"$NPM_DUMP_FILE_PATH" | log::file "Exporting $npm_title packages"

return 0
fi
Expand All @@ -187,7 +187,7 @@ package::npm_import() {

if package::common_import_check npm "$NPM_DUMP_FILE_PATH"; then
output::write "🚀 Importing NPM packages from '$NPM_DUMP_FILE_PATH'"
xargs -I_ npm install -g "_" < "$NPM_DUMP_FILE_PATH" | log::file "Importing $npm_title packages list"
xargs -I_ npm install -g "_" < "$NPM_DUMP_FILE_PATH" | log::file "Importing $npm_title packages"
fi

return 1
Expand All @@ -198,7 +198,7 @@ package::volta_dump() {

if package::common_dump_check volta "$VOLTA_DUMP_FILE_PATH"; then
output::write "🚀 Starting VOLTA packages from '$VOLTA_DUMP_FILE_PATH'"
volta list all --format plain | awk '{print $2}' >|"$VOLTA_DUMP_FILE_PATH" | log::file "Exporting $volta_title packages list"
volta list all --format plain | awk '{print $2}' >|"$VOLTA_DUMP_FILE_PATH" | log::file "Exporting $volta_title packages"

return 0
fi
Expand All @@ -211,7 +211,31 @@ package::volta_import() {

if package::common_import_check volta "$VOLTA_DUMP_FILE_PATH"; then
output::write "🚀 Importing VOLTA packages from '$VOLTA_DUMP_FILE_PATH'"
xargs -I_ volta install "_" <"$VOLTA_DUMP_FILE_PATH" | log::file "Importing ⚡︎⚔️ volta packages list"
xargs -I_ volta install "_" <"$VOLTA_DUMP_FILE_PATH" | log::file "Importing $volta_title packages"

return 0
fi

return 1
}

package::cargo_dump() {
CARGO_DUMP_FILE_PATH="${1:-$CARGO_DUMP_FILE_PATH}"

if package::common_dump_check cargo "$CARGO_DUMP_FILE_PATH"; then
cargo install --list | grep -E '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ' >|"$CARGO_DUMP_FILE_PATH" | log::file "Exporting $cargo_title packages"

return 0
fi

return 1
}

package::cargo_import() {
CARGO_DUMP_FILE_PATH="${1:-$VOLTA_DUMP_FILE_PATH}"

if package::common_import_check cargo "$CARGO_DUMP_FILE_PATH"; then
xargs -I_ cargo install < "$CARGO_DUMP_FILE_PATH" | log::file "Importing $cargo_title packages"

return 0
fi
Expand Down