-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·75 lines (66 loc) · 2.96 KB
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
set -e
echo "================================================================================"
echo "[SUBMODULES] Updating submodules..."
git submodule update --init
echo "[SUBMODULES] Updating submodules... Done."
# echo "================================================================================"
# echo "[CRATES.IO] Updating database dumps..."
# rm -f ./db-dump.tar.gz
# wget https://static.crates.io/db-dump.tar.gz
# tar -xf ./db-dump.tar.gz
# rm -f ./db-dump.tar.gz
# echo "[CRATES.IO] Updating database dumps... Done."
echo "================================================================================"
echo "[GENERATION] Generating Custom GPT documentation..."
find ./.output -mindepth 1 ! -name 'README.md' -exec rm -Rf {} +
sleep 1 # Wait for the filesystem to catch up
declare -a documentation_subdirectories=("book" "edition-guide" "nomicon" "perf-book" "reference" "rust-by-example" "tauri-docs")
for subdir in "${documentation_subdirectories[@]}"; do
if [[ "$subdir" == "tauri-docs" ]]; then
search_path="./$subdir/docs"
else
search_path="./$subdir/src"
fi
find "${search_path}" -type f -name "*.md" | while read -r src_file; do
if [[ "$subdir" == "tauri-docs" ]]; then
dest_file="${src_file/.\//./.output/tauri-docs/}" # Special path for tauri-docs
else
dest_file="${src_file/.\//./.output/}" # Replace './' with './.output/' at the beginning
dest_file="${dest_file/src\//}" # Remove '/src/' part
fi
mkdir -p "$(dirname "$dest_file")"
cp "$src_file" "$dest_file"
done
done
echo "[GENERATION] Generating Custom GPT documentation... Done."
echo "================================================================================"
echo "[INDEXING] Updating Custom GPT documentation REAME..."
cat ./.output/README.md | sed '/## File List/q' >> ./.output/README.md.temp
mv ./.output/README.md.temp ./.output/README.md
sleep 1 # Wait for the filesystem to catch up
{
echo ""
find ./.output -type f -name "*.md" | grep -v 'README.md' | while read -r src_file; do
# Get the relative file path
relative_path="${src_file/.\//}"
relative_path="${relative_path/.output\//}"
# Format as markdown link
echo "- [${relative_path}](${relative_path})"
done
echo ""
} >> ./.output/README.md
echo "[INDEXING] Updating Custom GPT documentation README... Done."
echo "================================================================================"
echo "[ARCHIVING] Generating Custom GPT Knowledge Base..."
rm -Rf ./*.tar.gz
version_tag=$(date "+%Y.%m.%d")
archive_name="custom_gpt_rust-v2021_tauri-v1_knowledge_base-v${version_tag}.tar.gz"
pushd ./.output
tar -czf "${archive_name}" *
popd
mv "./.output/${archive_name}" "./${archive_name}"
echo "[ARCHIVING] Generating Custom GPT Knowledge Base... Done."
echo "================================================================================"
echo ""
echo "You can now upload this archive to your Custom GPT Assistant: ./${archive_name}."