-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtask
More file actions
executable file
·142 lines (116 loc) · 3.83 KB
/
Copy pathtask
File metadata and controls
executable file
·142 lines (116 loc) · 3.83 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
set -e
if [[ -a ".env" ]]; then
export $(cat .env | sed 's/^#.*//g' | xargs)
fi
function help() {
echo
echo "task <command> [options]"
echo
echo "commands:"
echo
CMD_WIDTH=20
OPT_WIDTH=6
DESC_WIDTH=45
COLUMN="| %-${CMD_WIDTH}s | %-${OPT_WIDTH}s | %-${DESC_WIDTH}s |\n"
printf "$COLUMN" "Command" "Option" "Description"
echo "|$(printf '%*s' $((CMD_WIDTH + 2)) '' | tr ' ' '-')|$(printf '%*s' $((OPT_WIDTH + 2)) '' | tr ' ' '-')|$(printf '%*s' $((DESC_WIDTH + 2)) '' | tr ' ' '-')|"
printf "$COLUMN" "install" "" "Install build dependencies."
printf "$COLUMN" "update" "" "Update build dependencies."
printf "$COLUMN" "dev-vuepress" "" "Start vuepress development server."
printf "$COLUMN" "build-vuepress" "" "Create vuepress build."
printf "$COLUMN" "serve-vuepress" "" "Serve vuepress build."
printf "$COLUMN" "convert-files" "" "Convert markdown wiki links to normal link."
printf "$COLUMN" "convert-canvas" "" "Convert canvas files to svg."
printf "$COLUMN" "generate-bases-views" "" "Generate markdown tables from bases."
printf "$COLUMN" "delete-bases-views" "" "Delete bases markdown files."
printf "$COLUMN" "review-notes" "" "Open a random note reviewed note."
printf "$COLUMN" "lint" "" "Lint code with prettier."
}
if [ -d "$HOME/taskfile.build/bin" ]; then
for file in "$HOME/taskfile.build/bin/"*; do
if [ -f "$file" ]; then
source "$file"
fi
done
fi
function review-notes() {
VAULT_PATH="$(pwd)"
REVIEW_LOG="$VAULT_PATH/review-note.csv"
if [[ ! -f "$REVIEW_LOG" ]]; then
echo "Init review log."
echo "note_name,timestamp" > "$REVIEW_LOG"
fi
echo "Get reviewed files."
REVIEWED_FILES=$(cut -d',' -f1 "$REVIEW_LOG" | tail -n +2)
echo "Find all markdown files."
MD_FILES=$(find . -type f -name "*.md" | grep -vFf <(git check-ignore -v $(find . -type d) | awk '{print $2}'))
echo "Filter unreviewed files."
UNREVIEWED_FILES=$(echo "$MD_FILES")
if [[ -z "$UNREVIEWED_FILES" ]]; then
echo "No new files to review!"
return
fi
echo "Pick a random file."
SELECTED_FILE=$(echo "$UNREVIEWED_FILES" | shuf -n 1)
NOTE_NAME=$(basename "$SELECTED_FILE" .md)
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
ENCODED_FILE=$(echo -n "$NOTE_NAME" | jq -sRr @uri)
echo "Encode '$NOTE_NAME' to '$ENCODED_FILE'"
echo "Opening obsidian://open?vault=$(basename "$PWD")&file=$ENCODED_FILE"
obsidian "obsidian://open?vault=$(basename "$PWD")&file=$ENCODED_FILE" &
echo "Log the review."
echo "\"$NOTE_NAME\",\"$TIMESTAMP\"" >> "$REVIEW_LOG"
}
function install() {
pnpm install
}
function update() {
pnpm install -D @vuepress/bundler-vite@next
pnpm install -D @vuepress/client@next
pnpm install -D @vuepress/plugin-docsearch@next
pnpm install -D @vuepress/plugin-search@next
pnpm install -D @vuepress/plugin-shiki@next
pnpm install -D @vuepress/theme-default@next
pnpm install -D @vuepress/utils@next
pnpm install -D vuepress@next
}
function dev-vuepress() {
pnpm run pre-build
open-url-with-delay 'http://localhost:8081/' & pnpm run dev
}
function build-vuepress() {
pnpm run build
}
function serve-vuepress() {
cd ./src/.vuepress/dist
pnpx serve
}
function generate-bases-views() {
node generate-bases-views.js
}
function delete-bases-views() {
node delete-bases-views.js
}
function convert-files() {
node build.js vuepress
node build.js convert
node build.js attachments
}
function convert-canvas() {
node build.js canvas
}
function lint() {
pnpm exec prettier . --write
}
if declare -f "$1" > /dev/null; then
"$1" "${@:2}"
else
case "$1" in
*)
echo "Unknown command: $1"
help task
exit 1
;;
esac
fi