geet-geet 0.1.0
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/README.md +58 -0
- package/bin/geet.sh +150 -0
- package/docs/AUTO_PROMOTE.md +173 -0
- package/docs/CONTRIBUTING.md +142 -0
- package/docs/DEMO.md +131 -0
- package/docs/DEV_GUIDE.md +519 -0
- package/docs/FAQ.md +128 -0
- package/docs/MERGE_KEEP_OURS.md +243 -0
- package/docs/MULTI_LAYERED_TEMPLATES.md +92 -0
- package/docs/PREVENT_COMMIT_PATTERNS.md +250 -0
- package/docs/PUBLISHING_A_TEMPLATE.md +150 -0
- package/docs/UNDERSTANDING_GEET.md +68 -0
- package/docs/USING_A_TEMPLATE.md +131 -0
- package/lib/detach.sh +225 -0
- package/lib/digest-and-locate.sh +476 -0
- package/lib/doctor.sh +252 -0
- package/lib/flags.sh +52 -0
- package/lib/ghcli.sh +386 -0
- package/lib/git.sh +55 -0
- package/lib/help.sh +53 -0
- package/lib/ignored.sh +4 -0
- package/lib/include.sh +54 -0
- package/lib/init.sh +234 -0
- package/lib/install.sh +166 -0
- package/lib/logger.sh +278 -0
- package/lib/pre-commit/auto-promote-pgi.sh +20 -0
- package/lib/pre-commit/auto-promote-readme.sh +20 -0
- package/lib/pre-commit/hook.sh +66 -0
- package/lib/pre-commit/protect-patterns.sh +76 -0
- package/lib/pre-commit/unstage-soft-detached-files.sh +48 -0
- package/lib/prework.sh +181 -0
- package/lib/session.sh +111 -0
- package/lib/split.sh +120 -0
- package/lib/sync.sh +98 -0
- package/lib/template.sh +635 -0
- package/lib/tree.sh +252 -0
- package/lib/whoops.sh +37 -0
- package/package.json +15 -0
package/lib/tree.sh
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# tree.sh — show what files a layer template includes (and check membership)
|
|
2
|
+
# Usage:
|
|
3
|
+
# source tree.sh
|
|
4
|
+
# tree [subcommand] [args...]
|
|
5
|
+
#
|
|
6
|
+
# Read-only introspection tool to answer:
|
|
7
|
+
# 1) "What files are included in this template layer?"
|
|
8
|
+
# 2) "Is this specific file included? Why / why not?"
|
|
9
|
+
|
|
10
|
+
tree() {
|
|
11
|
+
debug "tree"
|
|
12
|
+
|
|
13
|
+
# digest-and-locate.sh provides: APP_DIR, TEMPLATE_DIR, DOTGIT, TEMPLATE_NAME,
|
|
14
|
+
# TEMPLATE_GEETINCLUDE, TEMPLATE_GEETEXCLUDE, die, log, debug
|
|
15
|
+
|
|
16
|
+
###############################################################################
|
|
17
|
+
# Preconditions
|
|
18
|
+
###############################################################################
|
|
19
|
+
|
|
20
|
+
need_dotgit() {
|
|
21
|
+
[[ -d "$DOTGIT" && -f "$DOTGIT/HEAD" ]] || die "missing $DOTGIT (run: $GEET_ALIAS init)"
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# We rely on compiled excludes existing to ensure the whitelist semantics are
|
|
25
|
+
# actually in effect.
|
|
26
|
+
need_compiled_exclude() {
|
|
27
|
+
[[ -f "$TEMPLATE_DIR/.geetexclude" ]] || die "missing compiled exclude: $TEMPLATE_DIR/.geetexclude (run: $GEET_ALIAS sync)"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
# Run git in the layer view (read-only usage only)
|
|
31
|
+
git_layer() {
|
|
32
|
+
GIT_DIR="$DOTGIT" GIT_WORK_TREE="$APP_DIR" git "$@"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
###############################################################################
|
|
36
|
+
# Inclusion checks
|
|
37
|
+
###############################################################################
|
|
38
|
+
|
|
39
|
+
# Returns 0 if NOT ignored (i.e. included by whitelist), nonzero otherwise.
|
|
40
|
+
is_included() {
|
|
41
|
+
local p="${1:?missing path}"
|
|
42
|
+
# check-ignore exits 0 if ignored, 1 if not ignored
|
|
43
|
+
if git_layer check-ignore -q -- "$p"; then
|
|
44
|
+
return 1
|
|
45
|
+
else
|
|
46
|
+
return 0
|
|
47
|
+
fi
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Returns 0 if tracked by the template repo.
|
|
51
|
+
is_tracked() {
|
|
52
|
+
local p="${1:?missing path}"
|
|
53
|
+
git_layer ls-files --error-unmatch -- "$p" >/dev/null 2>&1
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
###############################################################################
|
|
57
|
+
# Printing a simple tree from a list of paths (stdin)
|
|
58
|
+
###############################################################################
|
|
59
|
+
print_tree_from_paths() {
|
|
60
|
+
# Expect newline-separated relative paths on stdin.
|
|
61
|
+
# Prints a simple ascii tree (directories/files) without requiring `tree`.
|
|
62
|
+
# Sort first, then process with awk (portable - no asorti needed)
|
|
63
|
+
sort | awk '
|
|
64
|
+
BEGIN { FS="/"; }
|
|
65
|
+
{
|
|
66
|
+
split($0, parts, "/")
|
|
67
|
+
prefix = ""
|
|
68
|
+
for (j = 1; j <= length(parts); j++) {
|
|
69
|
+
node = prefix parts[j]
|
|
70
|
+
if (!(node in seen)) {
|
|
71
|
+
indent = ""
|
|
72
|
+
for (k = 1; k < j; k++) indent = indent " "
|
|
73
|
+
print indent parts[j]
|
|
74
|
+
seen[node] = 1
|
|
75
|
+
}
|
|
76
|
+
prefix = node "/"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
'
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
###############################################################################
|
|
83
|
+
# Commands
|
|
84
|
+
###############################################################################
|
|
85
|
+
usage() {
|
|
86
|
+
cat <<EOF
|
|
87
|
+
[$TEMPLATE_NAME tree] Show which files are included in this layer template
|
|
88
|
+
|
|
89
|
+
Usage:
|
|
90
|
+
$GEET_ALIAS tree [tracked|all] # Show tree view (default)
|
|
91
|
+
$GEET_ALIAS tree list [tracked|all] # List files
|
|
92
|
+
$GEET_ALIAS tree contains <path> # Check if path is included
|
|
93
|
+
|
|
94
|
+
Modes:
|
|
95
|
+
tracked - only files currently tracked by the layer template repo (fast)
|
|
96
|
+
all - any file in working tree that is INCLUDED by whitelist (slower)
|
|
97
|
+
|
|
98
|
+
Notes:
|
|
99
|
+
- Requires layer gitdir: $DOTGIT
|
|
100
|
+
- Requires compiled exclude: $TEMPLATE_DIR/.geetexclude
|
|
101
|
+
If missing, run: $GEET_ALIAS sync
|
|
102
|
+
EOF
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
# Parse first argument - could be subcommand or mode
|
|
106
|
+
first_arg="${1:-}"
|
|
107
|
+
debug "first_arg=$first_arg"
|
|
108
|
+
|
|
109
|
+
# Check if it's a known subcommand
|
|
110
|
+
case "$first_arg" in
|
|
111
|
+
list|contains|help|-h|--help)
|
|
112
|
+
cmd="$first_arg"
|
|
113
|
+
shift
|
|
114
|
+
;;
|
|
115
|
+
tracked|all|"")
|
|
116
|
+
# It's a mode or empty, default to tree command
|
|
117
|
+
cmd="tree"
|
|
118
|
+
# Don't shift - let the tree command handle the mode
|
|
119
|
+
;;
|
|
120
|
+
*)
|
|
121
|
+
# Unknown - could be a path for contains, or error
|
|
122
|
+
# Default to tree and let it handle
|
|
123
|
+
cmd="tree"
|
|
124
|
+
;;
|
|
125
|
+
esac
|
|
126
|
+
|
|
127
|
+
debug "cmd=$cmd"
|
|
128
|
+
|
|
129
|
+
case "$cmd" in
|
|
130
|
+
help|-h|--help)
|
|
131
|
+
usage
|
|
132
|
+
;;
|
|
133
|
+
|
|
134
|
+
list)
|
|
135
|
+
need_dotgit
|
|
136
|
+
need_compiled_exclude
|
|
137
|
+
mode="${1:-tracked}"
|
|
138
|
+
|
|
139
|
+
case "$mode" in
|
|
140
|
+
tracked)
|
|
141
|
+
# Authoritative and fast: what the layer repo currently tracks
|
|
142
|
+
git_layer ls-files
|
|
143
|
+
;;
|
|
144
|
+
all)
|
|
145
|
+
# Slower: scan the working tree and filter by whitelist using check-ignore.
|
|
146
|
+
#
|
|
147
|
+
# We use git's own file listing (including untracked) but do NOT depend
|
|
148
|
+
# on the app repo ignores. We then apply the layer's whitelist via the
|
|
149
|
+
# layer repo check-ignore rules.
|
|
150
|
+
#
|
|
151
|
+
# Exclude some common heavy dirs to keep it usable; customize as needed.
|
|
152
|
+
git -C "$APP_DIR" ls-files -co --exclude-standard \
|
|
153
|
+
-- ':!:**/node_modules/**' \
|
|
154
|
+
-- ':!:**/.git/**' \
|
|
155
|
+
-- ':!:**/dot-git/**' \
|
|
156
|
+
-- ':!:**/.expo/**' \
|
|
157
|
+
-- ':!:**/.idea/**' \
|
|
158
|
+
-- ':!:**/.DS_Store' \
|
|
159
|
+
| while IFS= read -r p; do
|
|
160
|
+
if is_included "$p"; then
|
|
161
|
+
echo "$p"
|
|
162
|
+
fi
|
|
163
|
+
done
|
|
164
|
+
;;
|
|
165
|
+
*)
|
|
166
|
+
die "usage: $GEET_ALIAS tree list [tracked|all]"
|
|
167
|
+
;;
|
|
168
|
+
esac
|
|
169
|
+
;;
|
|
170
|
+
|
|
171
|
+
tree)
|
|
172
|
+
debug "calling tree"
|
|
173
|
+
need_dotgit
|
|
174
|
+
debug "here"
|
|
175
|
+
need_compiled_exclude
|
|
176
|
+
debug "okay"
|
|
177
|
+
mode="${1:-tracked}"
|
|
178
|
+
debug "mode=$mode"
|
|
179
|
+
|
|
180
|
+
case "$mode" in
|
|
181
|
+
tracked)
|
|
182
|
+
geet_git ls-files | print_tree_from_paths
|
|
183
|
+
;;
|
|
184
|
+
all)
|
|
185
|
+
# Re-invoke tree list all
|
|
186
|
+
tree list all | print_tree_from_paths
|
|
187
|
+
;;
|
|
188
|
+
*)
|
|
189
|
+
die "usage: $GEET_ALIAS tree [tracked|all]"
|
|
190
|
+
;;
|
|
191
|
+
esac
|
|
192
|
+
;;
|
|
193
|
+
|
|
194
|
+
contains)
|
|
195
|
+
need_dotgit
|
|
196
|
+
need_compiled_exclude
|
|
197
|
+
p="${1:-}"
|
|
198
|
+
[[ -n "$p" ]] || die "usage: $GEET_ALIAS tree contains <path>"
|
|
199
|
+
|
|
200
|
+
# If user provides an absolute path inside the repo, convert to relative
|
|
201
|
+
if [[ "$p" == "$APP_DIR/"* ]]; then
|
|
202
|
+
p="${p#"$APP_DIR/"}"
|
|
203
|
+
fi
|
|
204
|
+
|
|
205
|
+
# Existence is informative, but not required
|
|
206
|
+
if [[ ! -e "$APP_DIR/$p" ]]; then
|
|
207
|
+
log "note: path does not exist in working tree: $p"
|
|
208
|
+
fi
|
|
209
|
+
|
|
210
|
+
if is_included "$p"; then
|
|
211
|
+
included="YES"
|
|
212
|
+
reason="not ignored by layer whitelist (.geetinclude -> .geetexclude)"
|
|
213
|
+
else
|
|
214
|
+
included="NO"
|
|
215
|
+
# Show the ignore rule that matched (source:line:pattern path)
|
|
216
|
+
rule="$(git_layer check-ignore -v -- "$p" 2>/dev/null || true)"
|
|
217
|
+
reason="ignored by layer view: ${rule:-"(no details)"}"
|
|
218
|
+
fi
|
|
219
|
+
|
|
220
|
+
if is_tracked "$p"; then
|
|
221
|
+
tracked="YES"
|
|
222
|
+
else
|
|
223
|
+
tracked="NO"
|
|
224
|
+
fi
|
|
225
|
+
|
|
226
|
+
echo "layer: $TEMPLATE_NAME"
|
|
227
|
+
echo "path: $p"
|
|
228
|
+
echo "included-by-whitelist: $included"
|
|
229
|
+
echo "tracked-by-template: $tracked"
|
|
230
|
+
echo "details: $reason"
|
|
231
|
+
|
|
232
|
+
if [[ "$included" == "YES" && "$tracked" == "NO" ]]; then
|
|
233
|
+
echo
|
|
234
|
+
echo "hint: included but not tracked. Add it with:"
|
|
235
|
+
echo " $GEET_ALIAS add -- \"$p\""
|
|
236
|
+
fi
|
|
237
|
+
|
|
238
|
+
if [[ "$included" == "NO" ]]; then
|
|
239
|
+
echo
|
|
240
|
+
echo "hint: to include it, add a line to:"
|
|
241
|
+
echo " $TEMPLATE_DIR/.geetinclude"
|
|
242
|
+
echo "then regenerate excludes by running:"
|
|
243
|
+
echo " $GEET_ALIAS sync"
|
|
244
|
+
fi
|
|
245
|
+
;;
|
|
246
|
+
|
|
247
|
+
*)
|
|
248
|
+
die "unknown command '$cmd' (try: $GEET_ALIAS tree help)"
|
|
249
|
+
;;
|
|
250
|
+
esac
|
|
251
|
+
|
|
252
|
+
} # end of tree()
|
package/lib/whoops.sh
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
open_issue() {
|
|
2
|
+
local title="${2:-}"
|
|
3
|
+
local body="${3:-}"
|
|
4
|
+
|
|
5
|
+
case "$title" in
|
|
6
|
+
help|-h|--help)
|
|
7
|
+
cat <<'EOF'
|
|
8
|
+
Usage:
|
|
9
|
+
$GEET_ALIAS issue "<title>" ["body"]
|
|
10
|
+
|
|
11
|
+
Examples:
|
|
12
|
+
$GEET_ALIAS issue "Bug: crash on launch"
|
|
13
|
+
$GEET_ALIAS issue "Feature request: something cool" "It would be great if..."
|
|
14
|
+
|
|
15
|
+
Notes:
|
|
16
|
+
- Opens a browser to create a GitHub issue
|
|
17
|
+
EOF
|
|
18
|
+
return 0
|
|
19
|
+
;;
|
|
20
|
+
esac
|
|
21
|
+
|
|
22
|
+
local q_title q_body
|
|
23
|
+
q_title="$(urlencode "$title")"
|
|
24
|
+
q_body="$(urlencode "$body")"
|
|
25
|
+
|
|
26
|
+
local url="$TEMPLATE_GH_URL/issues/new"
|
|
27
|
+
[[ -n "$q_title" ]] && url+="?title=${q_title}"
|
|
28
|
+
[[ -n "$q_body" ]] && url+="${q_title:+&}body=${q_body}"
|
|
29
|
+
|
|
30
|
+
if command -v open >/dev/null; then
|
|
31
|
+
open "$url"
|
|
32
|
+
elif command -v xdg-open >/dev/null; then
|
|
33
|
+
xdg-open "$url"
|
|
34
|
+
else
|
|
35
|
+
echo "$url"
|
|
36
|
+
fi
|
|
37
|
+
}
|