Skip to content

Commit 2933a9a

Browse files
author
jcapovkh
authored
Merge pull request #13 from justcoded/feat/LK-13133-git-plop
feat: ✨ add git-plop
2 parents 1801ec1 + 8aa6d74 commit 2933a9a

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

bin/git-plop

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env bash
2+
3+
find_plop_json() {
4+
current_dir=$(pwd)
5+
6+
while [ "$current_dir" != "/" ]; do
7+
if [ -f "$current_dir/.plop.json" ]; then
8+
echo "$current_dir/.plop.json"
9+
return 0
10+
fi
11+
current_dir=$(dirname "$current_dir")
12+
done
13+
14+
return 1 # Return 1 if not found, no print
15+
}
16+
17+
plop_json_path=$(find_plop_json)
18+
19+
# Check if .plop.json was found
20+
if [ -z "$plop_json_path" ]; then
21+
echo "Error: .plop.json not found"
22+
exit 1
23+
fi
24+
25+
plop_json_dir=$(dirname "$plop_json_path")
26+
27+
src=$(jq -r '.src' "$plop_json_path")
28+
workdir=$(jq -r '.workdir' "$plop_json_path")
29+
30+
src_dir="$plop_json_dir/$src"
31+
workdir_dir="$plop_json_dir/$workdir"
32+
33+
# Check for package.json and plopfile in src directory
34+
if [ ! -f "$src_dir/package.json" ] || { [ ! -f "$src_dir/plopfile.js" ] && [ ! -f "$src_dir/plopfile.ts" ]; }; then
35+
echo "Unable to find plopfile at [$src_dir]"
36+
exit 1
37+
fi
38+
39+
echo "Found plopfile: [$src_dir/plopfile.*]"
40+
echo "Run plop with codebase: [$workdir_dir]"
41+
42+
# Run Docker with the updated mounts and env variable
43+
docker run -it --rm \
44+
-v "$src_dir:/plop" \
45+
-v "$workdir_dir:/codebase" \
46+
-e CODEBASE_DIR="$workdir_dir" \
47+
ghcr.io/justcoded/plopjs:0.1.0

0 commit comments

Comments
 (0)