Skip to content

Commit 6d6c933

Browse files
committed
feat: Create 'basalt global install' command
1 parent 9042411 commit 6d6c933

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

pkg/lib/commands/do-global-add.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ do-global-add() {
3333
util.text_add_dependency "$BASALT_GLOBAL_DATA_DIR/global/dependencies" "$url@$version"
3434
done
3535

36-
pkg.do-global-install
36+
do-global-install
3737
}

pkg/lib/commands/do-global-install.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# shellcheck shell=bash
2+
3+
do-global-install() {
4+
util.init_global
5+
6+
if (($# != 0)); then
7+
newindent.die "No arguments or flags must be specified"
8+
fi
9+
10+
# TODO: this should be changed when we make global location dot_basalt
11+
if ! rm -rf "$BASALT_GLOBAL_DATA_DIR/global/.basalt"; then
12+
print.indent-die "Could not remove global '.basalt' directory"
13+
fi
14+
15+
local -a deps=()
16+
local dep=
17+
while IFS= read -r dep; do
18+
if [ -z "$dep" ]; then
19+
continue
20+
fi
21+
22+
deps+=("$dep")
23+
done < "$BASALT_GLOBAL_DATA_DIR/global/dependencies"; unset dep
24+
25+
pkg.install_package "$BASALT_GLOBAL_DATA_DIR/global" 'lenient' "${deps[@]}"
26+
}

pkg/lib/commands/do-global-remove.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ do-global-remove() {
3232
util.text_remove_dependency "$BASALT_GLOBAL_DATA_DIR/global/dependencies" "$url" "$flag_force"
3333
done
3434

35-
pkg.do-global-install
35+
do-global-install
3636
}

pkg/lib/commands/do-install.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,10 @@
33
do-install() {
44
util.init_local
55

6-
for arg; do case "$arg" in
7-
-*)
8-
print.die "Flag '$arg' not recognized"
9-
;;
10-
esac done
6+
if (($# != 0)); then
7+
newindent.die "No arguments or flags must be specified"
8+
fi
119

12-
# Everything in the local ./.basalt is a symlink to some file or directory
13-
# stored globally (per-user). Thus, we can just remove it since it won't take long
14-
# to re-symlink. Additionally, this will provide auto package pruning
1510
if ! rm -rf "$BASALT_LOCAL_PROJECT_DIR/.basalt"; then
1611
print.die "Could not remove local '.basalt' directory"
1712
fi

pkg/lib/util/pkg.sh

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,5 @@
11
# shellcheck shell=bash
22

3-
# @description This fufills the function of a 'basalt global install'
4-
# command. Since that's not a real command, it does not have its own
5-
# file in 'commands'; it's here instead
6-
pkg.do-global-install() {
7-
if ! rm -rf "$BASALT_GLOBAL_DATA_DIR/global/.basalt"; then
8-
print.indent-die "Could not remove global '.basalt' directory"
9-
fi
10-
11-
local -a deps=()
12-
local dep=
13-
14-
while IFS= read -r dep; do
15-
if [ -z "$dep" ]; then
16-
continue
17-
fi
18-
19-
deps+=("$dep")
20-
done < "$BASALT_GLOBAL_DATA_DIR/global/dependencies"; unset dep
21-
22-
pkg.install_package "$BASALT_GLOBAL_DATA_DIR/global" 'lenient' "${deps[@]}"
23-
}
24-
253
# @description Installs a pacakge and all its dependencies, relative to a
264
# particular project_dir. symlink_mode changes how components of its direct
275
# dependencies are synced

pkg/lib/util/util.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ util.init_global() {
3434
print.die "Either 'BASALT_GLOBAL_REPO' or 'BASALT_GLOBAL_DATA_DIR' is empty. Did you forget to run add 'basalt init <shell>' in your shell configuration?"
3535
fi
3636

37+
# TODO
3738
[ -d "$BASALT_GLOBAL_REPO" ] || mkdir -p "$BASALT_GLOBAL_REPO"
3839
[ -d "$BASALT_GLOBAL_DATA_DIR/global" ] || mkdir -p "$BASALT_GLOBAL_DATA_DIR/global"
3940
[ -d "$BASALT_GLOBAL_DATA_DIR/store" ] || mkdir -p "$BASALT_GLOBAL_DATA_DIR/store"
@@ -352,12 +353,12 @@ Global subcommands:
352353
add <package>
353354
Installs a global package
354355
355-
upgrade <package>
356-
Upgrades a global package
357-
358356
remove [--force] [package...]
359357
Uninstalls a global package
360358
359+
install
360+
Installs all global dependencies
361+
361362
list [--fetch] [--format=<simple>] [package...]
362363
List all installed packages or just the specified ones
363364

0 commit comments

Comments
 (0)