@sebastienrousseau/dotfiles 0.2.469 → 0.2.499

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.
Files changed (221) hide show
  1. package/docs/ARCHITECTURE.md +62 -0
  2. package/docs/COMPLIANCE.md +47 -0
  3. package/docs/COPYRIGHT +6 -0
  4. package/docs/OPERATIONS.md +103 -0
  5. package/docs/PLAN.md +161 -0
  6. package/docs/PR_DESCRIPTION.md +150 -0
  7. package/docs/ROADMAP.md +148 -0
  8. package/docs/ROADMAP_legacy.md +556 -0
  9. package/docs/SECURITY_CHECKLIST.md +25 -0
  10. package/docs/TASK.md +99 -0
  11. package/docs/WALKTHROUGH.md +46 -0
  12. package/package.json +64 -76
  13. package/scripts/backup.sh +142 -0
  14. package/{dist/scripts → scripts}/banner.sh +1 -1
  15. package/scripts/benchmark.sh +20 -0
  16. package/{dist/scripts → scripts}/build.sh +1 -1
  17. package/{dist/scripts → scripts}/clean.sh +1 -1
  18. package/{dist/scripts → scripts}/compile.sh +1 -1
  19. package/{dist/scripts → scripts}/copy.sh +1 -1
  20. package/scripts/detect-collisions.py +84 -0
  21. package/scripts/doctor.sh +79 -0
  22. package/{dist/scripts → scripts}/dotfiles.sh +1 -1
  23. package/{dist/scripts → scripts}/download.sh +1 -1
  24. package/{dist/scripts → scripts}/help.sh +1 -1
  25. package/scripts/lock-configs.sh +57 -0
  26. package/scripts/package.sh +46 -0
  27. package/{dist/scripts → scripts}/ssh.sh +1 -1
  28. package/scripts/teleport.sh +23 -0
  29. package/scripts/test-aliases.sh +25 -0
  30. package/scripts/test_smoke.sh +88 -0
  31. package/{dist/scripts → scripts}/unpack.sh +1 -1
  32. package/scripts/verify_state.sh +60 -0
  33. package/templates/projects/go/README.md +3 -0
  34. package/templates/projects/go/cmd/__PROJECT_NAME__/main.go +7 -0
  35. package/templates/projects/go/go.mod +3 -0
  36. package/templates/projects/node/README.md +3 -0
  37. package/templates/projects/node/package.json +10 -0
  38. package/templates/projects/node/src/index.js +2 -0
  39. package/templates/projects/python/README.md +3 -0
  40. package/templates/projects/python/pyproject.toml +10 -0
  41. package/templates/projects/python/src/__PROJECT_NAME__/__init__.py +1 -0
  42. package/templates/projects/python/tests/test_basic.py +2 -0
  43. package/LICENSE +0 -1283
  44. package/README.md +0 -398
  45. package/dist/Makefile +0 -140
  46. package/dist/bin/backup.d.ts +0 -3
  47. package/dist/bin/backup.d.ts.map +0 -1
  48. package/dist/bin/backup.js +0 -4
  49. package/dist/bin/backup.js.map +0 -1
  50. package/dist/bin/constants.d.ts +0 -7
  51. package/dist/bin/constants.d.ts.map +0 -1
  52. package/dist/bin/constants.js +0 -2
  53. package/dist/bin/constants.js.map +0 -1
  54. package/dist/bin/copy.d.ts +0 -3
  55. package/dist/bin/copy.d.ts.map +0 -1
  56. package/dist/bin/copy.js +0 -3
  57. package/dist/bin/copy.js.map +0 -1
  58. package/dist/bin/dotfiles.d.ts +0 -3
  59. package/dist/bin/dotfiles.d.ts.map +0 -1
  60. package/dist/bin/dotfiles.js +0 -2
  61. package/dist/bin/dotfiles.js.map +0 -1
  62. package/dist/bin/download.d.ts +0 -3
  63. package/dist/bin/download.d.ts.map +0 -1
  64. package/dist/bin/download.js +0 -2
  65. package/dist/bin/download.js.map +0 -1
  66. package/dist/bin/index.d.ts +0 -2
  67. package/dist/bin/index.d.ts.map +0 -1
  68. package/dist/bin/index.js +0 -1
  69. package/dist/bin/index.js.map +0 -1
  70. package/dist/bin/transfer.d.ts +0 -3
  71. package/dist/bin/transfer.d.ts.map +0 -1
  72. package/dist/bin/transfer.js +0 -4
  73. package/dist/bin/transfer.js.map +0 -1
  74. package/dist/bin/unpack.d.ts +0 -3
  75. package/dist/bin/unpack.d.ts.map +0 -1
  76. package/dist/bin/unpack.js +0 -3
  77. package/dist/bin/unpack.js.map +0 -1
  78. package/dist/filesizes.txt +0 -382
  79. package/dist/lib/README.md +0 -86
  80. package/dist/lib/aliases/README.md +0 -57
  81. package/dist/lib/aliases/archives/README.md +0 -145
  82. package/dist/lib/aliases/archives/archives.aliases.sh +0 -114
  83. package/dist/lib/aliases/cd/README.md +0 -146
  84. package/dist/lib/aliases/cd/cd.aliases.sh +0 -51
  85. package/dist/lib/aliases/chmod/README.md +0 -160
  86. package/dist/lib/aliases/chmod/chmod.aliases.sh +0 -107
  87. package/dist/lib/aliases/clear/README.md +0 -37
  88. package/dist/lib/aliases/clear/clear.aliases.sh +0 -71
  89. package/dist/lib/aliases/configuration/README.md +0 -39
  90. package/dist/lib/aliases/configuration/configuration.aliases.sh +0 -70
  91. package/dist/lib/aliases/default/README.md +0 -40
  92. package/dist/lib/aliases/default/default.aliases.sh +0 -139
  93. package/dist/lib/aliases/dig/README.md +0 -37
  94. package/dist/lib/aliases/dig/dig.aliases.sh +0 -43
  95. package/dist/lib/aliases/disk-usage/README.md +0 -36
  96. package/dist/lib/aliases/disk-usage/du.aliases.sh +0 -84
  97. package/dist/lib/aliases/editor/README.md +0 -53
  98. package/dist/lib/aliases/editor/editor.aliases.sh +0 -26
  99. package/dist/lib/aliases/find/README.md +0 -46
  100. package/dist/lib/aliases/find/find.aliases.sh +0 -60
  101. package/dist/lib/aliases/gcloud/README.md +0 -63
  102. package/dist/lib/aliases/gcloud/gcloud.aliases.sh +0 -335
  103. package/dist/lib/aliases/git/README.md +0 -153
  104. package/dist/lib/aliases/git/git.aliases.sh +0 -544
  105. package/dist/lib/aliases/gnu/README.md +0 -89
  106. package/dist/lib/aliases/gnu/gnucoreutils-aliases.sh +0 -150
  107. package/dist/lib/aliases/heroku/README.md +0 -430
  108. package/dist/lib/aliases/heroku/heroku.aliases.sh +0 -1053
  109. package/dist/lib/aliases/interactive/README.md +0 -55
  110. package/dist/lib/aliases/interactive/interactive.aliases.sh +0 -50
  111. package/dist/lib/aliases/list/README.md +0 -131
  112. package/dist/lib/aliases/list/list.aliases.sh +0 -132
  113. package/dist/lib/aliases/macOS/README.md +0 -42
  114. package/dist/lib/aliases/macOS/macos.aliases.sh +0 -65
  115. package/dist/lib/aliases/make/README.md +0 -32
  116. package/dist/lib/aliases/make/make.aliases.sh +0 -35
  117. package/dist/lib/aliases/mkdir/README.md +0 -30
  118. package/dist/lib/aliases/mkdir/mkdir.aliases.sh +0 -29
  119. package/dist/lib/aliases/npm/README.md +0 -41
  120. package/dist/lib/aliases/npm/npm.aliases.sh +0 -61
  121. package/dist/lib/aliases/permission/README.md +0 -47
  122. package/dist/lib/aliases/permission/permission.aliases.sh +0 -73
  123. package/dist/lib/aliases/pnpm/README.md +0 -53
  124. package/dist/lib/aliases/pnpm/pnpm.aliases.sh +0 -76
  125. package/dist/lib/aliases/ps/README.md +0 -29
  126. package/dist/lib/aliases/ps/ps.aliases.sh +0 -20
  127. package/dist/lib/aliases/python/python.aliases.sh +0 -141
  128. package/dist/lib/aliases/rsync/README.md +0 -25
  129. package/dist/lib/aliases/rsync/rsync.aliases.sh +0 -17
  130. package/dist/lib/aliases/rust/README.md +0 -182
  131. package/dist/lib/aliases/rust/rust.aliases.sh +0 -119
  132. package/dist/lib/aliases/subversion/README.md +0 -66
  133. package/dist/lib/aliases/subversion/subversion.aliases.sh +0 -47
  134. package/dist/lib/aliases/sudo/README.md +0 -27
  135. package/dist/lib/aliases/sudo/sudo.aliases.sh +0 -20
  136. package/dist/lib/aliases/tmux/README.md +0 -31
  137. package/dist/lib/aliases/tmux/tmux.aliases.sh +0 -36
  138. package/dist/lib/aliases/update/README.md +0 -38
  139. package/dist/lib/aliases/update/update.aliases.sh +0 -310
  140. package/dist/lib/aliases/uuid/README.md +0 -24
  141. package/dist/lib/aliases/uuid/uuid.aliases.sh +0 -19
  142. package/dist/lib/aliases/wget/README.md +0 -27
  143. package/dist/lib/aliases/wget/wget.aliases.sh +0 -22
  144. package/dist/lib/aliases.sh +0 -50
  145. package/dist/lib/configurations/README.md +0 -18
  146. package/dist/lib/configurations/bash/bashrc +0 -167
  147. package/dist/lib/configurations/curl/cacert.pem +0 -3460
  148. package/dist/lib/configurations/curl/curlrc +0 -53
  149. package/dist/lib/configurations/default/color.sh +0 -24
  150. package/dist/lib/configurations/default/constants.sh +0 -43
  151. package/dist/lib/configurations/default/editor.sh +0 -18
  152. package/dist/lib/configurations/default/prompt.sh +0 -48
  153. package/dist/lib/configurations/gem/gemrc +0 -9
  154. package/dist/lib/configurations/input/inputrc +0 -23
  155. package/dist/lib/configurations/jshint/jshintrc +0 -37
  156. package/dist/lib/configurations/nano/nanorc +0 -35
  157. package/dist/lib/configurations/profile/profile +0 -37
  158. package/dist/lib/configurations/prompt/prompt.sh +0 -81
  159. package/dist/lib/configurations/tmux/default +0 -18
  160. package/dist/lib/configurations/tmux/display +0 -30
  161. package/dist/lib/configurations/tmux/linux +0 -18
  162. package/dist/lib/configurations/tmux/navigation +0 -30
  163. package/dist/lib/configurations/tmux/panes +0 -10
  164. package/dist/lib/configurations/tmux/theme +0 -29
  165. package/dist/lib/configurations/tmux/tmux +0 -21
  166. package/dist/lib/configurations/vim/vimrc +0 -193
  167. package/dist/lib/configurations/wget/wgetrc +0 -40
  168. package/dist/lib/configurations/zsh/zshrc +0 -50
  169. package/dist/lib/configurations.sh +0 -45
  170. package/dist/lib/functions/README.md +0 -92
  171. package/dist/lib/functions/apihealth.sh +0 -277
  172. package/dist/lib/functions/apilatency.sh +0 -157
  173. package/dist/lib/functions/apiload.sh +0 -165
  174. package/dist/lib/functions/backup.sh +0 -143
  175. package/dist/lib/functions/cdls.sh +0 -60
  176. package/dist/lib/functions/curlheader.sh +0 -78
  177. package/dist/lib/functions/curlstatus.sh +0 -74
  178. package/dist/lib/functions/curltime.sh +0 -75
  179. package/dist/lib/functions/encode64.sh +0 -107
  180. package/dist/lib/functions/environment.sh +0 -78
  181. package/dist/lib/functions/extract.sh +0 -86
  182. package/dist/lib/functions/freespace.sh +0 -67
  183. package/dist/lib/functions/genpwd.sh +0 -105
  184. package/dist/lib/functions/goto.sh +0 -67
  185. package/dist/lib/functions/hexdump.sh +0 -96
  186. package/dist/lib/functions/hiddenfiles.sh +0 -77
  187. package/dist/lib/functions/hostinfo.sh +0 -98
  188. package/dist/lib/functions/hstats.sh +0 -75
  189. package/dist/lib/functions/httpdebug.sh +0 -113
  190. package/dist/lib/functions/kebabcase.sh +0 -61
  191. package/dist/lib/functions/keygen.sh +0 -194
  192. package/dist/lib/functions/last.sh +0 -112
  193. package/dist/lib/functions/logout.sh +0 -120
  194. package/dist/lib/functions/lowercase.sh +0 -61
  195. package/dist/lib/functions/matrix.sh +0 -216
  196. package/dist/lib/functions/mount_read_only.sh +0 -11
  197. package/dist/lib/functions/myproc.sh +0 -9
  198. package/dist/lib/functions/prependpath.sh +0 -21
  199. package/dist/lib/functions/ql.sh +0 -9
  200. package/dist/lib/functions/rd.sh +0 -17
  201. package/dist/lib/functions/remove_disk.sh +0 -11
  202. package/dist/lib/functions/ren.sh +0 -73
  203. package/dist/lib/functions/sentencecase.sh +0 -63
  204. package/dist/lib/functions/showhiddenfiles.sh +0 -14
  205. package/dist/lib/functions/size.sh +0 -16
  206. package/dist/lib/functions/snakecase.sh +0 -61
  207. package/dist/lib/functions/stopwatch.sh +0 -15
  208. package/dist/lib/functions/sysinfo.sh +0 -145
  209. package/dist/lib/functions/titlecase.sh +0 -65
  210. package/dist/lib/functions/uppercase.sh +0 -61
  211. package/dist/lib/functions/view-source.sh +0 -9
  212. package/dist/lib/functions/vscode.sh +0 -32
  213. package/dist/lib/functions/whoisport.sh +0 -14
  214. package/dist/lib/functions/zipf.sh +0 -16
  215. package/dist/lib/functions.sh +0 -46
  216. package/dist/lib/history.sh +0 -90
  217. package/dist/lib/paths/README.md +0 -52
  218. package/dist/lib/paths/custom.paths.sh +0 -40
  219. package/dist/lib/paths/default.paths.sh +0 -37
  220. package/dist/lib/paths.sh +0 -46
  221. package/dist/scripts/backup.sh +0 -95
@@ -1,277 +0,0 @@
1
- #!/usr/bin/env bash
2
- ################################################################################
3
- # 🅳🅾🆃🅵🅸🅻🅴🆂 - apihealth
4
- # Made with ♥ by Sebastien Rousseau
5
- # License: MIT
6
- #
7
- # apihealth - API Health Check Script
8
- #
9
- # This script checks the health/status of one or multiple APIs by sending HTTP
10
- # requests to specified endpoints. It supports different HTTP methods, allows
11
- # specifying expected HTTP status codes, and accepts custom HTTP headers.
12
- #
13
- # Usage:
14
- # apihealth [OPTIONS] URL [URL ...]
15
- #
16
- # Options:
17
- # -h, --help Show this help message and exit
18
- # -v, --version Show script version and exit
19
- # -m, --method METHOD Specify HTTP method (default: GET)
20
- # -e, --expect STATUS Specify expected HTTP status code (default: 200)
21
- # -H, --header HEADER Specify HTTP header (can be used multiple times)
22
- # -t, --timeout SECONDS Specify request timeout in seconds (default: 10)
23
- #
24
- # Examples:
25
- # apihealth https://api.example.com/health
26
- # apihealth -m POST -e 201 https://api.example.com/create
27
- # apihealth --method GET --expect 204 https://api.example.com/status1 https://api.example.com/status2
28
- # apihealth -H "Authorization: Bearer token123" -H "Content-Type: application/json" https://api.example.com/secure
29
- # apihealth -t 5 https://api.example.com/health
30
- #
31
- ################################################################################
32
-
33
- # Constants
34
- APIHEALTH_SCRIPT_NAME="apihealth"
35
- APIHEALTH_VERSION="0.1"
36
-
37
- # Default values
38
- DEFAULT_METHOD="GET"
39
- DEFAULT_EXPECT_STATUS=200
40
- DEFAULT_TIMEOUT=10
41
-
42
- # Initialize headers array
43
- HEADERS=()
44
-
45
- #######################################
46
- # Print usage information.
47
- # Returns:
48
- # 0 if help was shown
49
- #######################################
50
- print_help() {
51
- cat << EOF
52
- Usage: $APIHEALTH_SCRIPT_NAME [OPTIONS] URL [URL ...]
53
-
54
- Options:
55
- -h, --help Show this help message and exit
56
- -v, --version Show script version and exit
57
- -m, --method METHOD Specify HTTP method (default: GET)
58
- -e, --expect STATUS Specify expected HTTP status code (default: 200)
59
- -H, --header HEADER Specify HTTP header (can be used multiple times)
60
- -t, --timeout SECONDS Specify request timeout in seconds (default: 10)
61
-
62
- Examples:
63
- $APIHEALTH_SCRIPT_NAME https://api.example.com/health
64
- $APIHEALTH_SCRIPT_NAME -m POST -e 201 https://api.example.com/create
65
- $APIHEALTH_SCRIPT_NAME -H "Authorization: Bearer token123" https://api.example.com/secure
66
- $APIHEALTH_SCRIPT_NAME -t 5 https://api.example.com/health
67
- EOF
68
- return 0
69
- }
70
-
71
-
72
- #######################################
73
- # Print version information.
74
- # Returns:
75
- # 0 if version was shown
76
- #######################################
77
- print_version() {
78
- echo "$APIHEALTH_SCRIPT_NAME version $APIHEALTH_VERSION"
79
- return 0
80
- }
81
-
82
- #######################################
83
- # Check if required dependencies are installed.
84
- # Returns:
85
- # 1 if dependencies are missing
86
- #######################################
87
- check_dependencies() {
88
- if ! command -v curl >/dev/null 2>&1; then
89
- echo -e "\e[31m[ERROR]\e[0m Required command 'curl' is not installed."
90
- return 1
91
- fi
92
- return 0
93
- }
94
-
95
- #######################################
96
- # Check API health/status endpoints.
97
- # Arguments:
98
- # $1 - URL
99
- # $2 - HTTP Method
100
- # $3 - Expected HTTP Status Code
101
- # $4 - Timeout in seconds
102
- # Returns:
103
- # 0 if health check passed, 1 if failed
104
- #######################################
105
- apihealthealth() {
106
- local url="$1"
107
- local method="${2:-$DEFAULT_METHOD}"
108
- local expect_status="${3:-$DEFAULT_EXPECT_STATUS}"
109
- local timeout="${4:-$DEFAULT_TIMEOUT}"
110
- local curl_headers=()
111
-
112
- echo -e "[INFO] Testing API health: $url"
113
- echo -e "[INFO] Method: $method, Expected Status: $expect_status, Timeout: ${timeout}s"
114
-
115
- # Build curl headers array
116
- if [[ ${#HEADERS[@]} -gt 0 ]]; then
117
- for header in "${HEADERS[@]}"; do
118
- curl_headers+=(-H "$header")
119
- done
120
- fi
121
-
122
- # Perform the HTTP request
123
- local response
124
- if [[ ${#curl_headers[@]} -gt 0 ]]; then
125
- response=$(curl -s -o /dev/null -w "%{http_code}" \
126
- -X "$method" \
127
- --max-time "$timeout" \
128
- "${curl_headers[@]}" \
129
- "$url" 2>/dev/null || echo "000")
130
- else
131
- response=$(curl -s -o /dev/null -w "%{http_code}" \
132
- -X "$method" \
133
- --max-time "$timeout" \
134
- "$url" 2>/dev/null || echo "000")
135
- fi
136
-
137
- if [[ "$response" -eq "$expect_status" ]]; then
138
- echo -e "\e[32m[SUCCESS]\e[0m API is healthy (Status: $response)"
139
- return 0
140
- elif [[ "$response" -eq "000" ]]; then
141
- echo -e "\e[31m[ERROR]\e[0m API health check failed (No response)"
142
- return 1
143
- else
144
- echo -e "\e[31m[ERROR]\e[0m API health check failed (Status: $response)"
145
- return 1
146
- fi
147
- }
148
-
149
- #######################################
150
- # Parse command-line arguments.
151
- # Arguments:
152
- # Command line arguments
153
- # Returns:
154
- # 0 if parsing successful, 1 if failed
155
- #######################################
156
- parse_arguments() {
157
- # Initialize variables
158
- METHOD="$DEFAULT_METHOD"
159
- EXPECT_STATUS="$DEFAULT_EXPECT_STATUS"
160
- TIMEOUT="$DEFAULT_TIMEOUT"
161
- URLS=()
162
- HEADERS=()
163
-
164
- while [[ $# -gt 0 ]]; do
165
- case "$1" in
166
- -h|--help)
167
- print_help
168
- return 2 # Special return code for help/version display
169
- ;;
170
- -v|--version)
171
- print_version
172
- return 2 # Special return code for help/version display
173
- ;;
174
- -m|--method)
175
- if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
176
- METHOD="$2"
177
- shift 2
178
- else
179
- echo -e "\e[31m[ERROR]\e[0m --method requires a non-empty option argument."
180
- return 1
181
- fi
182
- ;;
183
- -e|--expect)
184
- if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
185
- EXPECT_STATUS="$2"
186
- shift 2
187
- else
188
- echo -e "\e[31m[ERROR]\e[0m --expect requires a non-empty option argument."
189
- return 1
190
- fi
191
- ;;
192
- -H|--header)
193
- if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
194
- if [[ ! "$2" =~ ^[^:]+:[[:space:]]*[^[:space:]]+.*$ ]]; then
195
- echo -e "\e[31m[ERROR]\e[0m Invalid header format: '$2'. Expected 'Key: Value'"
196
- return 1
197
- fi
198
- HEADERS+=("$2")
199
- shift 2
200
- else
201
- echo -e "\e[31m[ERROR]\e[0m --header requires a non-empty option argument."
202
- return 1
203
- fi
204
- ;;
205
- -t|--timeout)
206
- if [[ -n "${2:-}" && ! "$2" =~ ^- ]]; then
207
- if ! [[ "$2" =~ ^[0-9]+$ ]]; then
208
- echo -e "\e[31m[ERROR]\e[0m Timeout must be a positive integer."
209
- return 1
210
- fi
211
- TIMEOUT="$2"
212
- shift 2
213
- else
214
- echo -e "\e[31m[ERROR]\e[0m --timeout requires a non-empty option argument."
215
- return 1
216
- fi
217
- ;;
218
- -*)
219
- echo -e "\e[31m[ERROR]\e[0m Unknown option: $1"
220
- print_help
221
- return 1
222
- ;;
223
- *)
224
- URLS+=("$1")
225
- shift
226
- ;;
227
- esac
228
- done
229
-
230
- # Validate URLs provided
231
- if [[ ${#URLS[@]} -eq 0 ]]; then
232
- echo -e "\e[31m[ERROR]\e[0m No URLs provided."
233
- print_help
234
- return 1
235
- fi
236
-
237
- return 0
238
- }
239
-
240
- #######################################
241
- # Main execution function.
242
- # Arguments:
243
- # Command line arguments
244
- # Returns:
245
- # 0 if all checks passed, 1 if any failed
246
- #######################################
247
- apihealth_main() {
248
- if ! check_dependencies; then
249
- return 1
250
- fi
251
-
252
- if ! parse_arguments "$@"; then
253
- return 1
254
- fi
255
-
256
- local overall_status=0
257
-
258
- for url in "${URLS[@]}"; do
259
- if ! apihealthealth "$url" "$METHOD" "$EXPECT_STATUS" "$TIMEOUT"; then
260
- overall_status=1
261
- fi
262
- echo "----------------------------------------"
263
- done
264
-
265
- if [[ "$overall_status" -eq 0 ]]; then
266
- echo -e "\e[32mAll API health checks passed successfully.\e[0m"
267
- else
268
- echo -e "\e[31mSome API health checks failed.\e[0m"
269
- fi
270
-
271
- return "$overall_status"
272
- }
273
-
274
- # Define the function for sourcing
275
- apihealth() {
276
- apihealth_main "$@"
277
- }
@@ -1,157 +0,0 @@
1
- #!/usr/bin/env bash
2
- ################################################################################
3
- # 🅳🅾🆃🅵🅸🅻🅴🆂 - apilatency
4
- # Made with ♥ by Sebastien Rousseau
5
- # License: MIT
6
- #
7
- # apilatency - API Latency / Response Time Monitor
8
- #
9
- # This script monitors the response time of an API endpoint over a specified
10
- # number of requests and interval.
11
- #
12
- # Usage:
13
- # apilatency URL [COUNT] [INTERVAL]
14
- #
15
- # Options:
16
- # -h, --help Show this help message and exit
17
- # -v, --version Show script version and exit
18
- #
19
- # Examples:
20
- # apilatency https://api.example.com 10 1
21
- # apilatency https://api.example.com 20 0.5
22
- #
23
- ################################################################################
24
-
25
- # Constants
26
- APILATENCY_SCRIPT_NAME="apilatency"
27
- APILATENCY_VERSION="0.0.1"
28
-
29
- #######################################
30
- # Print usage information.
31
- #######################################
32
- apilatency_print_help() {
33
- cat << EOF
34
- Usage: $APILATENCY_SCRIPT_NAME URL [COUNT] [INTERVAL]
35
-
36
- Arguments:
37
- URL The API endpoint to monitor
38
- COUNT Number of requests to perform (default: 10)
39
- INTERVAL Delay between requests in seconds (default: 1)
40
-
41
- Options:
42
- -h, --help Show this help message and exit
43
- -v, --version Show script version and exit
44
-
45
- Examples:
46
- $APILATENCY_SCRIPT_NAME https://api.example.com 10 1
47
- $APILATENCY_SCRIPT_NAME https://api.example.com 20 0.5
48
- EOF
49
- }
50
-
51
- #######################################
52
- # Print version information.
53
- #######################################
54
- apilatency_print_version() {
55
- echo "$APILATENCY_SCRIPT_NAME version $APILATENCY_VERSION"
56
- }
57
-
58
- #######################################
59
- # Monitor API response time.
60
- #######################################
61
- apilatency_monitor() {
62
- local url="$1"
63
- local count="${2:-10}"
64
- local interval="${3:-1}"
65
-
66
- echo -e "[INFO] Monitoring API latency for $url"
67
- echo -e "[INFO] Total Requests: $count, Delay Between Requests: $interval seconds"
68
- echo "Time,Response_Time"
69
-
70
- for ((i = 1; i <= count; i++)); do
71
- local start=$(date +%s.%N)
72
- curl -s -o /dev/null "$url"
73
- local end=$(date +%s.%N)
74
- local latency=$(echo "$end - $start" | bc)
75
- echo "$(date '+%H:%M:%S'),$latency"
76
- sleep "$interval"
77
- done
78
-
79
- echo -e "\e[32m[SUCCESS]\e[0m Latency monitoring completed."
80
- }
81
-
82
- #######################################
83
- # Parse command-line arguments.
84
- #######################################
85
- apilatency_parse_arguments() {
86
- # First argument handling
87
- case "${1:-}" in
88
- -h|--help)
89
- apilatency_print_help
90
- return 2
91
- ;;
92
- -v|--version)
93
- apilatency_print_version
94
- return 2
95
- ;;
96
- "")
97
- echo -e "\e[31m[ERROR]\e[0m Missing required URL argument."
98
- apilatency_print_help
99
- return 1
100
- ;;
101
- esac
102
-
103
- # Store arguments
104
- local url="$1"
105
- local count="${2:-10}"
106
- local interval="${3:-1}"
107
-
108
- # Validate URL
109
- if [[ ! "$url" =~ ^https?:// ]]; then
110
- echo -e "\e[31m[ERROR]\e[0m Invalid URL format. Must start with http:// or https://"
111
- return 1
112
- fi
113
-
114
- # Validate count
115
- if ! [[ "$count" =~ ^[0-9]+$ ]]; then
116
- echo -e "\e[31m[ERROR]\e[0m COUNT must be a positive integer."
117
- return 1
118
- fi
119
-
120
- # Validate interval
121
- if ! [[ "$interval" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
122
- echo -e "\e[31m[ERROR]\e[0m INTERVAL must be a positive number."
123
- return 1
124
- fi
125
-
126
- # Export variables for use in main function
127
- URL="$url"
128
- COUNT="$count"
129
- INTERVAL="$interval"
130
-
131
- return 0
132
- }
133
-
134
- #######################################
135
- # Main function.
136
- #######################################
137
- apilatency_main() {
138
- apilatency_parse_arguments "$@"
139
- local parse_result=$?
140
-
141
- case $parse_result in
142
- 0) # Normal operation
143
- apilatency_monitor "$URL" "$COUNT" "$INTERVAL"
144
- ;;
145
- 2) # Help or version was displayed
146
- return 0
147
- ;;
148
- *) # Error occurred
149
- return 1
150
- ;;
151
- esac
152
- }
153
-
154
- # The main function that gets exported for use
155
- apilatency() {
156
- apilatency_main "$@"
157
- }
@@ -1,165 +0,0 @@
1
- #!/usr/bin/env bash
2
- ################################################################################
3
- # 🅳🅾🆃🅵🅸🅻🅴🆂 - apiload
4
- # Made with ♥ by Sebastien Rousseau
5
- # License: MIT
6
- #
7
- # apiload - API Load Testing Script
8
- #
9
- # This script performs basic load testing on a specified API endpoint using
10
- # default utilities available in macOS, Linux, or Windows environments. It allows
11
- # you to specify the number of total requests and the delay between requests.
12
- #
13
- # Usage:
14
- # apiload URL [REQUESTS] [DELAY]
15
- #
16
- # Examples:
17
- # apiload https://api.example.com 100 0.1
18
- # apiload https://api.example.com 500 0.5
19
- #
20
- ################################################################################
21
-
22
- # Constants
23
- APILOAD_SCRIPT_NAME="apiload"
24
- APILOAD_VERSION="0.0.1"
25
-
26
- #######################################
27
- # Print usage information.
28
- #######################################
29
- apiload_print_help() {
30
- cat << EOF
31
- Usage: $APILOAD_SCRIPT_NAME URL [REQUESTS] [DELAY]
32
-
33
- Arguments:
34
- URL The API endpoint to load test
35
- REQUESTS Number of total requests to perform (default: 100)
36
- DELAY Delay between requests in seconds (default: 0.1)
37
-
38
- Options:
39
- -h, --help Show this help message and exit
40
- -v, --version Show script version and exit
41
-
42
- Examples:
43
- $APILOAD_SCRIPT_NAME https://api.example.com 100 0.1
44
- $APILOAD_SCRIPT_NAME https://api.example.com 500 0.5
45
- EOF
46
- }
47
-
48
- #######################################
49
- # Print version information.
50
- #######################################
51
- apiload_print_version() {
52
- echo "$APILOAD_SCRIPT_NAME version $APILOAD_VERSION"
53
- }
54
-
55
- #######################################
56
- # Perform API load testing.
57
- #######################################
58
- apiload_load_test() {
59
- local url="$1"
60
- local requests="${2:-100}"
61
- local delay="${3:-0.1}"
62
-
63
- echo -e "[INFO] Running load test on $url"
64
- echo -e "[INFO] Total Requests: $requests, Delay Between Requests: $delay seconds"
65
-
66
- local success_count=0
67
- local fail_count=0
68
-
69
- for ((i = 1; i <= requests; i++)); do
70
- response=$(curl -s -o /dev/null -w "%{http_code}" "$url")
71
- if [[ "$response" -eq 200 ]]; then
72
- echo -e "\e[32m[Request $i]\e[0m Success (HTTP 200)"
73
- ((success_count++))
74
- else
75
- echo -e "\e[31m[Request $i]\e[0m Failed (HTTP $response)"
76
- ((fail_count++))
77
- fi
78
- sleep "$delay"
79
- done
80
-
81
- echo -e "\n[SUMMARY]"
82
- echo -e "Total Requests: $requests"
83
- echo -e "Successful: \e[32m$success_count\e[0m"
84
- echo -e "Failed: \e[31m$fail_count\e[0m"
85
- echo -e "Success Rate: $(( (success_count * 100) / requests ))%"
86
-
87
- echo -e "\n\e[32m[SUCCESS]\e[0m Load test completed."
88
- }
89
-
90
- #######################################
91
- # Parse command-line arguments.
92
- #######################################
93
- apiload_parse_arguments() {
94
- # First argument handling
95
- case "${1:-}" in
96
- -h|--help)
97
- apiload_print_help
98
- return 2
99
- ;;
100
- -v|--version)
101
- apiload_print_version
102
- return 2
103
- ;;
104
- "")
105
- echo -e "\e[31m[ERROR]\e[0m Missing required URL argument."
106
- apiload_print_help
107
- return 1
108
- ;;
109
- esac
110
-
111
- # Store arguments
112
- local url="$1"
113
- local requests="${2:-100}"
114
- local delay="${3:-0.1}"
115
-
116
- # Validate URL
117
- if [[ ! "$url" =~ ^https?:// ]]; then
118
- echo -e "\e[31m[ERROR]\e[0m Invalid URL format. Must start with http:// or https://"
119
- return 1
120
- fi
121
-
122
- # Validate requests
123
- if ! [[ "$requests" =~ ^[0-9]+$ ]]; then
124
- echo -e "\e[31m[ERROR]\e[0m REQUESTS must be a positive integer."
125
- return 1
126
- fi
127
-
128
- # Validate delay
129
- if ! [[ "$delay" =~ ^[0-9]+(\.[0-9]+)?$ ]]; then
130
- echo -e "\e[31m[ERROR]\e[0m DELAY must be a positive number."
131
- return 1
132
- fi
133
-
134
- # Export variables for use in main function
135
- URL="$url"
136
- REQUESTS="$requests"
137
- DELAY="$delay"
138
-
139
- return 0
140
- }
141
-
142
- #######################################
143
- # Main function.
144
- #######################################
145
- apiload_main() {
146
- apiload_parse_arguments "$@"
147
- local parse_result=$?
148
-
149
- case $parse_result in
150
- 0) # Normal operation
151
- apiload_load_test "$URL" "$REQUESTS" "$DELAY"
152
- ;;
153
- 2) # Help or version was displayed
154
- return 0
155
- ;;
156
- *) # Error occurred
157
- return 1
158
- ;;
159
- esac
160
- }
161
-
162
- # The apiload_main function that gets exported for use
163
- apiload() {
164
- apiload_main "$@"
165
- }