@stacksjs/shell 0.70.53 → 0.70.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -2
- package/src/buddy.plugin.zsh +122 -0
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/shell",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.55",
|
|
5
5
|
"description": "A better Stacks shell experience. Currently only fully supporting Oh My Zsh. Stay tuned for more. Or request one!",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"buddy.plugin.zsh",
|
|
33
|
-
"dist"
|
|
33
|
+
"dist",
|
|
34
|
+
"src"
|
|
34
35
|
],
|
|
35
36
|
"scripts": {
|
|
36
37
|
"build": "bun build.ts",
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
#!/usr/bin/env zsh
|
|
2
|
+
#--------------------------------------------------------------------------
|
|
3
|
+
# Stacks buddy plugin for zsh
|
|
4
|
+
#--------------------------------------------------------------------------
|
|
5
|
+
#
|
|
6
|
+
# This plugin adds an `buddy` shell command that will find and execute
|
|
7
|
+
# Stacks's buddy command from anywhere within the project. It also
|
|
8
|
+
# adds shell completions that work anywhere buddy can be located.
|
|
9
|
+
#
|
|
10
|
+
# Many thanks to Jess Archer for providing the initial scripts:
|
|
11
|
+
# https://github.com/jessarcher/zsh-artisan
|
|
12
|
+
|
|
13
|
+
buddy() {
|
|
14
|
+
local buddy_path=$(_buddy_find)
|
|
15
|
+
|
|
16
|
+
if [[ "$buddy_path" = "" ]]; then
|
|
17
|
+
echo >&2 "shell: buddy not found. Are you in a Stacks directory? This only happens if you are not within a Stacks project, and buddy is not installed globally."
|
|
18
|
+
return 1
|
|
19
|
+
fi
|
|
20
|
+
|
|
21
|
+
local buddy_path=$(dirname $buddy_path)
|
|
22
|
+
local buddy_cmd
|
|
23
|
+
|
|
24
|
+
buddy_cmd="bun $buddy_path/buddy $*"
|
|
25
|
+
|
|
26
|
+
local buddy_start_time=$(date +%s)
|
|
27
|
+
|
|
28
|
+
# shellcheck disable=SC2086
|
|
29
|
+
eval "$buddy_cmd" $*
|
|
30
|
+
|
|
31
|
+
local buddy_exit_status=$? # Store the exit status so we can return it later
|
|
32
|
+
|
|
33
|
+
if [[ $1 = "make:"* && "$BUDDY_OPEN_ON_MAKE_EDITOR" != "" ]]; then
|
|
34
|
+
# Find and open files created by buddy
|
|
35
|
+
find \
|
|
36
|
+
"$buddy_path/app" \
|
|
37
|
+
"$buddy_path/tests" \
|
|
38
|
+
-type f \
|
|
39
|
+
-newermt "-$(($(date +%s) - $buddy_start_time + 1)) seconds" \
|
|
40
|
+
-exec "$BUDDY_OPEN_ON_MAKE_EDITOR" {} \; 2>/dev/null
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
return "$buddy_exit_status"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
bud() {
|
|
47
|
+
buddy $*
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
stacks() {
|
|
51
|
+
buddy $*
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
stx() {
|
|
55
|
+
buddy $*
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
b() {
|
|
59
|
+
buddy $*
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
bi() {
|
|
63
|
+
buddy install
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
ba() {
|
|
67
|
+
buddy add "$@"
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
bd() {
|
|
71
|
+
buddy dev "$@"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
bb() {
|
|
75
|
+
buddy build "$@"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
bt() {
|
|
79
|
+
buddy test
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
bu() {
|
|
83
|
+
buddy upgrade
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
brb() {
|
|
87
|
+
bun run build
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
compdef _buddy_add_completion buddy
|
|
91
|
+
|
|
92
|
+
_buddy_find() {
|
|
93
|
+
# First, try to find a globally installed buddy binary
|
|
94
|
+
local global_buddy_path=$(which buddy)
|
|
95
|
+
if [[ -n "$global_buddy_path" ]]; then
|
|
96
|
+
echo "$global_buddy_path"
|
|
97
|
+
return 0
|
|
98
|
+
fi
|
|
99
|
+
|
|
100
|
+
# If not found globally, look for buddy up the file tree until the root directory
|
|
101
|
+
local dir=.
|
|
102
|
+
until [[ "$dir" -ef / ]]; do
|
|
103
|
+
if [[ -f "$dir/buddy" ]]; then
|
|
104
|
+
echo "$dir/buddy"
|
|
105
|
+
return 0
|
|
106
|
+
fi
|
|
107
|
+
|
|
108
|
+
dir+=/..
|
|
109
|
+
done
|
|
110
|
+
|
|
111
|
+
return 1
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
_buddy_add_completion() {
|
|
115
|
+
if [[ "$(_buddy_find)" != "" ]]; then
|
|
116
|
+
compadd $(_buddy_get_command_list)
|
|
117
|
+
fi
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
_buddy_get_command_list() {
|
|
121
|
+
buddy list | sed "s/[[ :space: ]].*//g"
|
|
122
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { $ } from 'bun'
|