Skip to content

Commit 66fdb6d

Browse files
committed
Added asdf strap
1 parent 8c29399 commit 66fdb6d

File tree

12 files changed

+220
-7
lines changed

12 files changed

+220
-7
lines changed

Makefile

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
INSTALL_DIR=/usr/local/bin
22

3+
# List of files that contain the version
4+
VERSIONED_FILES=strapped src/helpers.sh _static/_stay/index.html
5+
VERSION="0.3.0"
6+
7+
VERSION_REPLACE_EXP="s/^VERSION=\".+\"/VERSION=\"${VERSION}\"/g"
8+
39
.PHONY: all exec install uninstall test strap straps docs
410

511
all: exec straps binary docs test
@@ -15,13 +21,13 @@ test:
1521
docs:
1622
@./build/docs.sh
1723

18-
strap:
24+
strap: update-version
1925
@./build/compiler.sh ${yml}
2026

21-
straps:
27+
straps: update-version
2228
@./build/straps.sh
2329

24-
binary:
30+
binary: update-version
2531
@./build/binary.sh
2632

2733
install: strapped
@@ -32,4 +38,11 @@ install: strapped
3238

3339
uninstall:
3440
@echo "🗑️ Uninstalling strapped"
35-
@rm $(INSTALL_DIR)/strapped
41+
@rm $(INSTALL_DIR)/strapped
42+
43+
$(VERSIONED_FILES): Makefile
44+
@echo "Updateing version in " $@ " to "$(VERSION)
45+
@sed -i .old -E $(VERSION_REPLACE_EXP) $@ && rm "$@.old"
46+
47+
.PHONY: update-version
48+
update-version: $(VERSIONED_FILES)

_static/_stay/index.html

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
VERSION="0.3.0"
12
print_folder_err() {
23
echo "Could not install strapped to /usr/local/bin" > /dev/stderr
34
echo "" > /dev/stderr
@@ -35,7 +36,7 @@
3536
if [ ! -d '/usr/local/bin' ]; then
3637
mkdir /usr/local/bin 2> /dev/null || print_folder_err
3738
fi
38-
curl -s -L https://raw.githubusercontent.com/azohra/strapped.sh/0.2.0/strapped --output /usr/local/bin/strapped || print_copy_err
39+
curl -s -L "https://raw.githubusercontent.com/azohra/strapped.sh/$VERSION/strapped" --output /usr/local/bin/strapped || print_copy_err
3940
echo "Your all set to 🔫 #StayStrapped"
4041
chmod u+x /usr/local/bin/strapped 2> /dev/null || print_chmod_err
4142
echo $PATH | grep "[:^]/usr/local/bin[:$]" > /dev/null || print_path_err

src/cli.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ while [ $# -gt 0 ] ; do
4747
auto_approve="true"
4848
;;
4949
-v|--version)
50-
echo 'v0.2.0' && exit 0
50+
echo "v$VERSION" && exit 0
5151
;;
5252
-h|--help)
5353
usage

src/helpers.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# shellcheck source=/dev/null
33

4+
VERSION="0.3.0"
45
C_GREEN="\\033[32m"
56
C_BLUE="\\033[94m"
67
C_REG="\\033[0;39m"

strapped

100644100755
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# shellcheck source=/dev/null
33

4+
VERSION="0.3.0"
45
C_GREEN="\\033[32m"
56
C_BLUE="\\033[94m"
67
C_REG="\\033[0;39m"
@@ -152,7 +153,7 @@ while [ $# -gt 0 ] ; do
152153
auto_approve="true"
153154
;;
154155
-v|--version)
155-
echo 'v0.2.0' && exit 0
156+
echo "v$VERSION" && exit 0
156157
;;
157158
-h|--help)
158159
usage

straps/asdf/latest/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# asdf :: v0.1.0
2+
3+
| Attribute | Value |
4+
|--------------:|----|
5+
| Namespace | asdf |
6+
| Emoji | 🐙 [plugins][versions] |
7+
| Description | Extendable version manager |
8+
| Dependencies | asdf |
9+
| Compatability | unix |
10+
11+
## Configuration
12+
13+
```yml
14+
asdf:
15+
plugins:
16+
- { name: clojure, url: https://github.com/halcyon/asdf-clojure.git }
17+
versions:
18+
- { dir: ~/opeional_local_install, name: clojure, version: 1.9.0 }
19+
```

straps/asdf/latest/asdf.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
function strapped_asdf() {
4+
# Variables to hold the deps and corresponding checks
5+
local __deps="asdf "
6+
local __resp
7+
# Performing each check for each dep
8+
for dep in ${__deps}; do
9+
command -v "${dep}" &> /dev/null
10+
__resp=$?
11+
if [[ $__resp -ne 0 ]]; then
12+
echo "ERROR: dep ${dep} not found:"
13+
case "${dep}" in
14+
"asdf")
15+
echo -e "
16+
Please ensure you have asdf installed on your system
17+
To install asdf, follow the instructions at https://asdf-vm.com/#/core-manage-asdf-vm
18+
"
19+
;;
20+
esac
21+
exit 1
22+
fi
23+
done
24+
25+
# Declaring local variables for the 'plugins' routine
26+
local name
27+
local url
28+
29+
# Declaring local variables for the 'versions' routine
30+
local dir
31+
local name
32+
local version
33+
local input=${1}
34+
35+
# Initialize array iterator
36+
local i=0
37+
38+
# performing functionality for routine 'plugins'
39+
for ((i=0; i<$( ysh -T "${input}" -c plugins ); i++)); do
40+
41+
# Getting fields for routine 'plugins'
42+
name=$( ysh -T "${input}" -l plugins -i ${i} -Q name )
43+
url=$( ysh -T "${input}" -l plugins -i ${i} -Q url )
44+
45+
# Writing message for routine 'plugins'
46+
pretty_print ":info:" "🐙 adding ${name} plugin to asdf"
47+
48+
# Executing the command(s) for routine 'plugins'
49+
run_command "asdf plugin-add ${name} ${url}"
50+
done
51+
52+
53+
# performing functionality for routine 'versions'
54+
for ((i=0; i<$( ysh -T "${input}" -c versions ); i++)); do
55+
56+
# Getting fields for routine 'versions'
57+
dir=$( ysh -T "${input}" -l versions -i ${i} -Q dir )
58+
name=$( ysh -T "${input}" -l versions -i ${i} -Q name )
59+
version=$( ysh -T "${input}" -l versions -i ${i} -Q version )
60+
61+
# Writing message for routine 'versions'
62+
pretty_print ":info:" "⌨ shimming ${name} to ${version}"
63+
64+
# Executing the command(s) for routine 'versions'
65+
run_command "test '${dir}' && (cd ${dir} && asdf local ${name} ${version}) || asdf global global ${name} ${version}"
66+
done
67+
}

straps/asdf/latest/asdf.sh.DIGEST

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
076b4d730b35b2bc758b28f2457f7d1df0d1075a3b505dbb295978e34defa8e6 straps/asdf/v0.1.0/asdf.sh

straps/asdf/spec.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
strap:
2+
namespace: asdf
3+
version: v0.1.0
4+
description: "Extendable version manager"
5+
compatability: unix
6+
deps:
7+
- name: asdf
8+
msg:
9+
- "\n\tPlease ensure you have asdf installed on your system"
10+
- "\tTo install asdf, follow the instructions at https://asdf-vm.com/#/core-manage-asdf-vm"
11+
routines:
12+
plugins:
13+
exec: "asdf plugin-add ${name} ${url}"
14+
message: "adding ${name} plugin to asdf"
15+
emoji: 🐙
16+
input:
17+
- { name: clojure, url: https://github.com/halcyon/asdf-clojure.git }
18+
versions:
19+
exec: "test '${dir}' && (cd ${dir} && asdf local ${name} ${version}) || asdf global global ${name} ${version}"
20+
message: "shimming ${name} to ${version}"
21+
emoji:
22+
input:
23+
- { name: clojure, version: 1.9.0, dir: ~/opeional_local_install }

straps/asdf/v0.1.0/README.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# asdf :: v0.1.0
2+
3+
| Attribute | Value |
4+
|--------------:|----|
5+
| Namespace | asdf |
6+
| Emoji | 🐙 [plugins][versions] |
7+
| Description | Extendable version manager |
8+
| Dependencies | asdf |
9+
| Compatability | unix |
10+
11+
## Configuration
12+
13+
```yml
14+
asdf:
15+
plugins:
16+
- { name: clojure, url: https://github.com/halcyon/asdf-clojure.git }
17+
versions:
18+
- { dir: ~/opeional_local_install, name: clojure, version: 1.9.0 }
19+
```

straps/asdf/v0.1.0/asdf.sh

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
function strapped_asdf() {
4+
# Variables to hold the deps and corresponding checks
5+
local __deps="asdf "
6+
local __resp
7+
# Performing each check for each dep
8+
for dep in ${__deps}; do
9+
command -v "${dep}" &> /dev/null
10+
__resp=$?
11+
if [[ $__resp -ne 0 ]]; then
12+
echo "ERROR: dep ${dep} not found:"
13+
case "${dep}" in
14+
"asdf")
15+
echo -e "
16+
Please ensure you have asdf installed on your system
17+
To install asdf, follow the instructions at https://asdf-vm.com/#/core-manage-asdf-vm
18+
"
19+
;;
20+
esac
21+
exit 1
22+
fi
23+
done
24+
25+
# Declaring local variables for the 'plugins' routine
26+
local name
27+
local url
28+
29+
# Declaring local variables for the 'versions' routine
30+
local dir
31+
local name
32+
local version
33+
local input=${1}
34+
35+
# Initialize array iterator
36+
local i=0
37+
38+
# performing functionality for routine 'plugins'
39+
for ((i=0; i<$( ysh -T "${input}" -c plugins ); i++)); do
40+
41+
# Getting fields for routine 'plugins'
42+
name=$( ysh -T "${input}" -l plugins -i ${i} -Q name )
43+
url=$( ysh -T "${input}" -l plugins -i ${i} -Q url )
44+
45+
# Writing message for routine 'plugins'
46+
pretty_print ":info:" "🐙 adding ${name} plugin to asdf"
47+
48+
# Executing the command(s) for routine 'plugins'
49+
run_command "asdf plugin-add ${name} ${url}"
50+
done
51+
52+
53+
# performing functionality for routine 'versions'
54+
for ((i=0; i<$( ysh -T "${input}" -c versions ); i++)); do
55+
56+
# Getting fields for routine 'versions'
57+
dir=$( ysh -T "${input}" -l versions -i ${i} -Q dir )
58+
name=$( ysh -T "${input}" -l versions -i ${i} -Q name )
59+
version=$( ysh -T "${input}" -l versions -i ${i} -Q version )
60+
61+
# Writing message for routine 'versions'
62+
pretty_print ":info:" "⌨ shimming ${name} to ${version}"
63+
64+
# Executing the command(s) for routine 'versions'
65+
run_command "test '${dir}' && (cd ${dir} && asdf local ${name} ${version}) || asdf global global ${name} ${version}"
66+
done
67+
}

straps/asdf/v0.1.0/asdf.sh.DIGEST

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
076b4d730b35b2bc758b28f2457f7d1df0d1075a3b505dbb295978e34defa8e6 straps/asdf/v0.1.0/asdf.sh

0 commit comments

Comments
 (0)