@bgord/ui 0.1.0 → 0.1.1
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/dist/components/button.d.ts +1 -0
- package/dist/hooks/use-toggle.d.ts +32 -0
- package/dist/index.js +526 -0
- package/package.json +4 -1
- package/.gitmodules +0 -3
- package/bgord-scripts/ansible-decrypt-file.sh +0 -13
- package/bgord-scripts/ansible-encrypt-file.sh +0 -13
- package/bgord-scripts/ansible-view-file.sh +0 -13
- package/bgord-scripts/app-readme-generate.sh +0 -79
- package/bgord-scripts/base.sh +0 -209
- package/bgord-scripts/biome-check.sh +0 -14
- package/bgord-scripts/build-prechecks.sh +0 -14
- package/bgord-scripts/changelog-generate.sh +0 -17
- package/bgord-scripts/compare-configs.sh +0 -33
- package/bgord-scripts/compressor.ts +0 -103
- package/bgord-scripts/cspell.sh +0 -30
- package/bgord-scripts/css-purge.sh +0 -10
- package/bgord-scripts/database-sync-production-to-local.sh +0 -12
- package/bgord-scripts/drizzle-generate.sh +0 -10
- package/bgord-scripts/drizzle-migrate.sh +0 -10
- package/bgord-scripts/drizzle-open-studio.sh +0 -3
- package/bgord-scripts/drizzle-seed.sh +0 -12
- package/bgord-scripts/e2e-open.sh +0 -10
- package/bgord-scripts/e2e-run.sh +0 -19
- package/bgord-scripts/format-staged.sh +0 -14
- package/bgord-scripts/format.sh +0 -10
- package/bgord-scripts/frontend-build.sh +0 -15
- package/bgord-scripts/frontend-watch.sh +0 -12
- package/bgord-scripts/image-identify.sh +0 -14
- package/bgord-scripts/image-svg-optmise.sh +0 -14
- package/bgord-scripts/lint-commit-message.sh +0 -10
- package/bgord-scripts/list.sh +0 -20
- package/bgord-scripts/local-server-start.sh +0 -25
- package/bgord-scripts/npm-publish.sh +0 -77
- package/bgord-scripts/outdated-dependencies.sh +0 -24
- package/bgord-scripts/production-server-inspect.sh +0 -13
- package/bgord-scripts/production-sqlite-backup.sh +0 -20
- package/bgord-scripts/shellcheck.sh +0 -14
- package/bgord-scripts/templates/.commitlint-config.cjs +0 -11
- package/bgord-scripts/templates/biome.json +0 -66
- package/bgord-scripts/templates/cspell.json +0 -117
- package/bgord-scripts/templates/drizzle.config.ts +0 -8
- package/bgord-scripts/templates/index.html +0 -30
- package/bgord-scripts/templates/knip.json +0 -11
- package/bgord-scripts/templates/lefthook-target.yml +0 -2
- package/bgord-scripts/templates/lefthook.yml +0 -46
- package/bgord-scripts/templates/postcss.config.js +0 -10
- package/bgord-scripts/templates/server.tsconfig.json +0 -15
- package/bgord-scripts/test-coverage.sh +0 -11
- package/bgord-scripts/test-run.sh +0 -16
- package/bgord-scripts/test-watch.sh +0 -16
- package/bgord-scripts/typecheck-frontend-watch.sh +0 -20
- package/bgord-scripts/typecheck-frontend.sh +0 -22
- package/bgord-scripts/typecheck-prune.sh +0 -10
- package/bgord-scripts/typecheck-watch.sh +0 -8
- package/bgord-scripts/typecheck.sh +0 -10
- package/bgord-scripts/update.sh +0 -15
- package/bgord-scripts/workflows/codeql-analysis.yml +0 -35
- package/bgord-scripts/workflows/dependabot.yml +0 -7
- package/bgord-scripts/workflows/deploy-project.yml +0 -65
- package/bgord-scripts/workflows/deploy-server.yml +0 -71
- package/bgord-scripts/workflows/docs-app.yml +0 -47
- package/bun.lock +0 -29
- package/bunfig.toml +0 -6
- package/src/components/button.tsx +0 -3
- package/src/hooks/use-toggle.ts +0 -68
- package/tsconfig.json +0 -15
- /package/{src/components/index.ts → dist/components/index.d.ts} +0 -0
- /package/{src/hooks/index.ts → dist/hooks/index.d.ts} +0 -0
- /package/{src/index.ts → dist/index.d.ts} +0 -0
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
source bgord-scripts/base.sh
|
|
4
|
-
setup_base_config
|
|
5
|
-
|
|
6
|
-
OUTPUT_FILE="readme.md"
|
|
7
|
-
|
|
8
|
-
PROJECT_NAME=$1
|
|
9
|
-
|
|
10
|
-
validate_non_empty "PROJECT_NAME" $PROJECT_NAME
|
|
11
|
-
|
|
12
|
-
echo "# $PROJECT_NAME" > "$OUTPUT_FILE"
|
|
13
|
-
echo "" >> "$OUTPUT_FILE"
|
|
14
|
-
|
|
15
|
-
echo "[Check status](https://bgord.github.io/statuses/history/$PROJECT_NAME)" >> "$OUTPUT_FILE"
|
|
16
|
-
echo "" >> "$OUTPUT_FILE"
|
|
17
|
-
|
|
18
|
-
# ===============
|
|
19
|
-
|
|
20
|
-
echo "## Configuration:" >> "$OUTPUT_FILE"
|
|
21
|
-
echo "" >> "$OUTPUT_FILE"
|
|
22
|
-
|
|
23
|
-
echo "Clone the repository" >> "$OUTPUT_FILE"
|
|
24
|
-
echo "" >> "$OUTPUT_FILE"
|
|
25
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
26
|
-
echo "git clone git@github.com:bgord/journal.git --recurse-submodules" >> "$OUTPUT_FILE"
|
|
27
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
28
|
-
echo "" >> "$OUTPUT_FILE"
|
|
29
|
-
|
|
30
|
-
echo "Install packages" >> "$OUTPUT_FILE"
|
|
31
|
-
echo "" >> "$OUTPUT_FILE"
|
|
32
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
33
|
-
echo "bun i" >> "$OUTPUT_FILE"
|
|
34
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
35
|
-
echo "" >> "$OUTPUT_FILE"
|
|
36
|
-
|
|
37
|
-
echo "Create env files" >> "$OUTPUT_FILE"
|
|
38
|
-
echo "" >> "$OUTPUT_FILE"
|
|
39
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
40
|
-
echo "cp .env.example .env.local" >> "$OUTPUT_FILE"
|
|
41
|
-
echo "cp .env.example .env.test" >> "$OUTPUT_FILE"
|
|
42
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
43
|
-
echo "" >> "$OUTPUT_FILE"
|
|
44
|
-
|
|
45
|
-
echo "Start the app" >> "$OUTPUT_FILE"
|
|
46
|
-
echo "" >> "$OUTPUT_FILE"
|
|
47
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
48
|
-
echo "./bgord-scripts/local-server-start.sh" >> "$OUTPUT_FILE"
|
|
49
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
50
|
-
echo "" >> "$OUTPUT_FILE"
|
|
51
|
-
|
|
52
|
-
echo "Run the tests" >> "$OUTPUT_FILE"
|
|
53
|
-
echo "" >> "$OUTPUT_FILE"
|
|
54
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
55
|
-
echo "./bgord-scripts/test-run.sh" >> "$OUTPUT_FILE"
|
|
56
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
57
|
-
echo "" >> "$OUTPUT_FILE"
|
|
58
|
-
|
|
59
|
-
# ===============
|
|
60
|
-
|
|
61
|
-
echo "## Domain:" >> "$OUTPUT_FILE"
|
|
62
|
-
echo "" >> "$OUTPUT_FILE"
|
|
63
|
-
|
|
64
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
65
|
-
tree modules/ | grep -v index.ts | sed -e :a -e '$d;N;2,2ba' -e 'P;D' >> "$OUTPUT_FILE"
|
|
66
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
67
|
-
echo "" >> "$OUTPUT_FILE"
|
|
68
|
-
|
|
69
|
-
# ===============
|
|
70
|
-
|
|
71
|
-
echo "## Infra:" >> "$OUTPUT_FILE"
|
|
72
|
-
echo "" >> "$OUTPUT_FILE"
|
|
73
|
-
|
|
74
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
|
75
|
-
tree infra/ -I drizzle \
|
|
76
|
-
| grep -v index.ts \
|
|
77
|
-
| grep -v CHANGELOG.md \
|
|
78
|
-
| sed -e :a -e '$d;N;2,2ba' -e 'P;D' >> "$OUTPUT_FILE"
|
|
79
|
-
echo "\`\`\`" >> "$OUTPUT_FILE"
|
package/bgord-scripts/base.sh
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
function setup_base_config {
|
|
4
|
-
# -e (exit immediately if a command fails)
|
|
5
|
-
# -o pipefail (quit even if a command in a pipeline fails)
|
|
6
|
-
|
|
7
|
-
set -eo pipefail
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
RED="\033[1;31m"
|
|
11
|
-
GREEN="\033[1;32m"
|
|
12
|
-
BLUE="\033[1;34m"
|
|
13
|
-
NC="\033[0m"
|
|
14
|
-
|
|
15
|
-
PROJECT_NAME=$(basename $(git rev-parse --show-toplevel 2>/dev/null) 2>/dev/null || echo "not-in-git")
|
|
16
|
-
|
|
17
|
-
CURRENT_TIME=$(date +%F-%H-%M-%S)
|
|
18
|
-
CURRENT_TIMESTAMP=$(date +%s)
|
|
19
|
-
|
|
20
|
-
function info {
|
|
21
|
-
local MESSAGE=$1
|
|
22
|
-
echo -e "$BLUE [info]$NC $MESSAGE"
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function success {
|
|
26
|
-
local MESSAGE=$1
|
|
27
|
-
# shellcheck disable=SC1087
|
|
28
|
-
echo -e "$GREEN[success]$NC $MESSAGE"
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function error {
|
|
32
|
-
local MESSAGE=$1
|
|
33
|
-
echo -e "$RED [error]$NC $MESSAGE"
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function new_line {
|
|
37
|
-
echo -e ""
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function check_if_file_exists {
|
|
41
|
-
if test -f "$1"
|
|
42
|
-
then
|
|
43
|
-
success "$1 file exists!"
|
|
44
|
-
else
|
|
45
|
-
error "$1 file doesn't exist!"
|
|
46
|
-
exit 1
|
|
47
|
-
fi
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function check_if_directory_exists {
|
|
51
|
-
if test -d "$1"
|
|
52
|
-
then
|
|
53
|
-
success "$1 directory exists!"
|
|
54
|
-
else
|
|
55
|
-
error "$1 directory doesn't exist!"
|
|
56
|
-
exit 1
|
|
57
|
-
fi
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function check_if_directory_does_not_exist {
|
|
61
|
-
if test -d "$1"
|
|
62
|
-
then
|
|
63
|
-
error "$1 directory already exists!"
|
|
64
|
-
exit 1
|
|
65
|
-
else
|
|
66
|
-
success "$1 directory doesn't exist."
|
|
67
|
-
fi
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function validate_non_empty {
|
|
71
|
-
local VARIABLE_NAME=$1
|
|
72
|
-
local VARIABLE_VALUE=$2
|
|
73
|
-
|
|
74
|
-
if test -z "$VARIABLE_VALUE"
|
|
75
|
-
then
|
|
76
|
-
error "Empty argument: $VARIABLE_NAME";
|
|
77
|
-
exit 1
|
|
78
|
-
else
|
|
79
|
-
success "Correct argument: $VARIABLE_NAME";
|
|
80
|
-
fi
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function install_dev_package {
|
|
84
|
-
bun i -D $@
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function check_if_binary_exists {
|
|
88
|
-
if test -x "$(command -v $1)"
|
|
89
|
-
then
|
|
90
|
-
success "$2 is installed!"
|
|
91
|
-
else
|
|
92
|
-
error "$2 is not installed!"
|
|
93
|
-
exit 1
|
|
94
|
-
fi
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function allow_to_skip_within_5s {
|
|
98
|
-
info "You can skip within 5s"
|
|
99
|
-
|
|
100
|
-
info "5..."
|
|
101
|
-
sleep 1
|
|
102
|
-
|
|
103
|
-
info "4..."
|
|
104
|
-
sleep 1
|
|
105
|
-
|
|
106
|
-
info "3..."
|
|
107
|
-
sleep 1
|
|
108
|
-
|
|
109
|
-
info "2..."
|
|
110
|
-
sleep 1
|
|
111
|
-
|
|
112
|
-
info "1..."
|
|
113
|
-
sleep 1
|
|
114
|
-
|
|
115
|
-
success "Proceeding..."
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function check_if_linux_or_macos {
|
|
119
|
-
local KERNEL_NAME=$(uname -s)
|
|
120
|
-
|
|
121
|
-
if test $KERNEL_NAME == "Linux" || test $KERNEL_NAME == "Darwin"
|
|
122
|
-
then
|
|
123
|
-
success "Your host machine is either Linux or MacOS!"
|
|
124
|
-
else
|
|
125
|
-
error "Unsupported operating system, Linux or MacOS required."
|
|
126
|
-
exit 1
|
|
127
|
-
fi
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function ensure_git_root_directory {
|
|
131
|
-
local NEAREST_GIT_REPOSITORY_ROOT_DIRECTORY=$(git rev-parse --show-toplevel)
|
|
132
|
-
local CURRENT_DIRECTORY=$(pwd)
|
|
133
|
-
|
|
134
|
-
if test $NEAREST_GIT_REPOSITORY_ROOT_DIRECTORY != $CURRENT_DIRECTORY
|
|
135
|
-
then
|
|
136
|
-
error "It seems you're trying to run the script outside the root git repository directory."
|
|
137
|
-
exit 1
|
|
138
|
-
fi
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
function press_enter_to_continue {
|
|
142
|
-
read -s -p "Press enter to continue..."
|
|
143
|
-
echo -e ""
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function confirm_dangerous_action {
|
|
147
|
-
WORD=$(grep -E '^[a-z]{4,5}$' /usr/share/dict/words | shuf -n1)
|
|
148
|
-
|
|
149
|
-
read -rp "Type the word '$WORD' if you really want to perform this action: " TYPED
|
|
150
|
-
|
|
151
|
-
if test "$WORD" != "$TYPED"
|
|
152
|
-
then
|
|
153
|
-
error "You typed "$WORD" wrong, aborting."
|
|
154
|
-
exit 1
|
|
155
|
-
fi
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function ensure_ssh_staging_alias {
|
|
159
|
-
(ssh -q staging exit)
|
|
160
|
-
|
|
161
|
-
if test $? != '0'
|
|
162
|
-
then
|
|
163
|
-
error "The [staging] ssh alias is not present or doesn't work."
|
|
164
|
-
exit 1
|
|
165
|
-
fi
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
function ensure_ssh_production_alias {
|
|
169
|
-
(ssh -q production exit)
|
|
170
|
-
|
|
171
|
-
if test $? != '0'
|
|
172
|
-
then
|
|
173
|
-
error "The [production] ssh alias is not present or doesn't work."
|
|
174
|
-
exit 1
|
|
175
|
-
fi
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function validate_environment_file {
|
|
179
|
-
if bun run --env-file=".env.$NODE_ENV" infra/env.ts
|
|
180
|
-
then
|
|
181
|
-
success "Correct environment file!"
|
|
182
|
-
else
|
|
183
|
-
error "Invalid environment file, see the output below, quitting."
|
|
184
|
-
exit 1
|
|
185
|
-
fi
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function validate_pascal_case {
|
|
189
|
-
local VALUE="$1"
|
|
190
|
-
|
|
191
|
-
if expr "$VALUE" : '^[A-Z][a-z]\{1,\}\([A-Z][a-z]\{1,\}\)*$' >/dev/null; then
|
|
192
|
-
success "Correct PascalCase: $VALUE"
|
|
193
|
-
else
|
|
194
|
-
error "Invalid PascalCase: $VALUE"
|
|
195
|
-
exit 1
|
|
196
|
-
fi
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function pascal_case_to_kebab_case {
|
|
200
|
-
local PASCAL_CASE_VALUE="$1"
|
|
201
|
-
local KEBAB_CASE_VALUE=$(echo "$PASCAL_CASE_VALUE" | sed 's/\([a-z0-9]\)\([A-Z]\)/\1-\2/g' | tr '[:upper:]' '[:lower:]')
|
|
202
|
-
|
|
203
|
-
echo "$KEBAB_CASE_VALUE"
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
function set_node_timezone_to_utc {
|
|
207
|
-
info "Setting node timezone to UTC"
|
|
208
|
-
export TZ=UTC
|
|
209
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source bgord-scripts/base.sh
|
|
4
|
-
setup_base_config
|
|
5
|
-
|
|
6
|
-
info "Performing biome analysis..."
|
|
7
|
-
|
|
8
|
-
bunx @biomejs/biome check \
|
|
9
|
-
--config-path=bgord-scripts/templates/biome.json \
|
|
10
|
-
--no-errors-on-unmatched \
|
|
11
|
-
--write \
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
success "Biome analysis performed!"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source bgord-scripts/base.sh
|
|
4
|
-
setup_base_config
|
|
5
|
-
|
|
6
|
-
info "Running build prechecks..."
|
|
7
|
-
|
|
8
|
-
./bgord-scripts/typecheck.sh
|
|
9
|
-
./bgord-scripts/biome-check.sh
|
|
10
|
-
./bgord-scripts/test-run.sh
|
|
11
|
-
./bgord-scripts/cspell.sh
|
|
12
|
-
./bgord-scripts/shellcheck.sh
|
|
13
|
-
./bgord-scripts/compare-configs.sh
|
|
14
|
-
./bgord-scripts/e2e-run.sh
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
output_directory="infra"
|
|
4
|
-
output_file="$output_directory/CHANGELOG.md"
|
|
5
|
-
|
|
6
|
-
echo "# Changelog" > "$output_file"
|
|
7
|
-
|
|
8
|
-
lines=$(git log --pretty=format:"- %ad %h **%s**" --date=format:'%Y-%m-%d %H:%M')
|
|
9
|
-
tags=$(git tag -l --sort=-creatordate)
|
|
10
|
-
|
|
11
|
-
while read -r tag; do
|
|
12
|
-
tag_date=$(git log -1 --pretty=format:"%ad" --date=format:'%Y-%m-%d %H:%M' $tag)
|
|
13
|
-
tag_hash=$(git rev-parse --short $tag)
|
|
14
|
-
lines="$lines\n## $tag_date $tag"
|
|
15
|
-
done <<< "$tags"
|
|
16
|
-
|
|
17
|
-
echo -e "$lines" | sort -r -k 2 >> "$output_file"
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source bgord-scripts/base.sh
|
|
4
|
-
setup_base_config
|
|
5
|
-
|
|
6
|
-
PAIRS=(
|
|
7
|
-
".github/dependabot.yml:bgord-scripts/workflows/dependabot.yml"
|
|
8
|
-
".github/workflows/codeql-analysis.yml:bgord-scripts/workflows/codeql-analysis.yml"
|
|
9
|
-
".github/workflows/deploy-server.yml:bgord-scripts/workflows/deploy-server.yml"
|
|
10
|
-
".github/workflows/docs-app.yml:bgord-scripts/workflows/docs-app.yml"
|
|
11
|
-
"lefthook.yml:bgord-scripts/templates/lefthook-target.yml"
|
|
12
|
-
)
|
|
13
|
-
|
|
14
|
-
ALL_OK=true
|
|
15
|
-
|
|
16
|
-
for pair in "${PAIRS[@]}"; do
|
|
17
|
-
IFS=: read -r FILE TEMPLATE <<<"$pair"
|
|
18
|
-
|
|
19
|
-
# Presence checks
|
|
20
|
-
[[ -f "$FILE" ]] || { error "❌ $FILE not found"; ALL_OK=false; continue; }
|
|
21
|
-
[[ -f "$TEMPLATE" ]] || { error "❌ $TEMPLATE not found"; ALL_OK=false; continue; }
|
|
22
|
-
|
|
23
|
-
# Comparison
|
|
24
|
-
if diff -u --color=always --label "$TEMPLATE" --label "$FILE" "$TEMPLATE" "$FILE" > /dev/null; then
|
|
25
|
-
success "$FILE matches $TEMPLATE"
|
|
26
|
-
else
|
|
27
|
-
error "$FILE differs from $TEMPLATE:"
|
|
28
|
-
diff -u --color=always --label "$TEMPLATE" --label "$FILE" "$TEMPLATE" "$FILE" || true
|
|
29
|
-
ALL_OK=false
|
|
30
|
-
fi
|
|
31
|
-
done
|
|
32
|
-
|
|
33
|
-
$ALL_OK && exit 0 || exit 1
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { brotliCompressSync } from "node:zlib";
|
|
4
|
-
|
|
5
|
-
async function compressDirectory(
|
|
6
|
-
dir: string,
|
|
7
|
-
extensions: string[] = [".html", ".css", ".js", ".png", ".ico"],
|
|
8
|
-
) {
|
|
9
|
-
const results = [];
|
|
10
|
-
|
|
11
|
-
for await (const filepath of walker(dir, extensions)) {
|
|
12
|
-
const content = await fs.readFile(filepath);
|
|
13
|
-
const originalSize = content.length;
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
const gzipped = Bun.gzipSync(content);
|
|
17
|
-
const brotlied = brotliCompressSync(content);
|
|
18
|
-
|
|
19
|
-
await Promise.all([fs.writeFile(`${filepath}.gz`, gzipped), fs.writeFile(`${filepath}.br`, brotlied)]);
|
|
20
|
-
|
|
21
|
-
const result = new CompressionResult({
|
|
22
|
-
originalSize,
|
|
23
|
-
file: path.relative(dir, filepath),
|
|
24
|
-
gzipSize: gzipped.byteLength,
|
|
25
|
-
brotliSize: brotlied.length,
|
|
26
|
-
});
|
|
27
|
-
result.print();
|
|
28
|
-
|
|
29
|
-
results.push(result);
|
|
30
|
-
} catch (error) {
|
|
31
|
-
console.error(`Failed to compress ${filepath}:`, error);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (results.length === 0) {
|
|
36
|
-
console.log(`No matching files found in ${dir}`);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return results;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
class CompressionResult {
|
|
43
|
-
constructor(
|
|
44
|
-
private output: {
|
|
45
|
-
originalSize: number;
|
|
46
|
-
file: string;
|
|
47
|
-
gzipSize: number;
|
|
48
|
-
brotliSize: number;
|
|
49
|
-
},
|
|
50
|
-
) {}
|
|
51
|
-
|
|
52
|
-
print(): void {
|
|
53
|
-
const original = this.humanify(this.output.originalSize);
|
|
54
|
-
const gzipSize = this.humanify(this.output.gzipSize);
|
|
55
|
-
const gzipChange = this.compare(this.output.gzipSize, this.output.originalSize);
|
|
56
|
-
const brotliSize = this.humanify(this.output.brotliSize);
|
|
57
|
-
const brotliChange = this.compare(this.output.brotliSize, this.output.originalSize);
|
|
58
|
-
|
|
59
|
-
console.log(`${this.output.file}: ${original}`);
|
|
60
|
-
console.log(` → .gz: ${gzipSize} → (${gzipChange} %)`);
|
|
61
|
-
console.log(` → .br: ${brotliSize} → (${brotliChange} %)\n`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private humanify(value: number): string {
|
|
65
|
-
return `${(value / 1024).toFixed(2)} KB`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private compare(one: number, another: number) {
|
|
69
|
-
return ((one / another) * 100).toFixed(1);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function* walker(dir: string, extensions: string[]): AsyncGenerator<string> {
|
|
74
|
-
const entries = await fs.readdir(dir, { withFileTypes: true });
|
|
75
|
-
|
|
76
|
-
for (const entry of entries) {
|
|
77
|
-
const fullPath = path.join(dir, entry.name);
|
|
78
|
-
if (entry.isDirectory()) {
|
|
79
|
-
yield* walker(fullPath, extensions);
|
|
80
|
-
} else if (entry.isFile() && extensions.includes(path.extname(entry.name))) {
|
|
81
|
-
yield fullPath;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Handle CLI
|
|
87
|
-
// @ts-ignore
|
|
88
|
-
if (import.meta.main) {
|
|
89
|
-
const args = process.argv.slice(2);
|
|
90
|
-
|
|
91
|
-
const dir = args[0] || "./build/static";
|
|
92
|
-
const extensions = args[1]?.split(",") || [".html", ".css", ".js", ".png", ".ico"];
|
|
93
|
-
|
|
94
|
-
console.log(`Compressing ${dir} (${extensions})...\n`);
|
|
95
|
-
|
|
96
|
-
try {
|
|
97
|
-
// @ts-ignore
|
|
98
|
-
await compressDirectory(dir, extensions);
|
|
99
|
-
} catch (error) {
|
|
100
|
-
console.error("Error:", error instanceof Error ? error.message : error);
|
|
101
|
-
process.exit(1);
|
|
102
|
-
}
|
|
103
|
-
}
|
package/bgord-scripts/cspell.sh
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source bgord-scripts/base.sh
|
|
4
|
-
setup_base_config
|
|
5
|
-
|
|
6
|
-
info "Detecting spelling mistakes..."
|
|
7
|
-
|
|
8
|
-
git ls-files \
|
|
9
|
-
| grep -v "package.json" \
|
|
10
|
-
| grep -v "prisma" \
|
|
11
|
-
| grep -v "infra/translations/pl.json" \
|
|
12
|
-
| grep -v "infra/drizzle" \
|
|
13
|
-
| grep -v "dist" \
|
|
14
|
-
| grep -v "LICENSE" \
|
|
15
|
-
| grep -v "CHANGELOG" \
|
|
16
|
-
| grep -v "changelog.md" \
|
|
17
|
-
| grep -v "static" \
|
|
18
|
-
| grep -v "env" \
|
|
19
|
-
| grep -v "github" \
|
|
20
|
-
| grep -v "gitignore" \
|
|
21
|
-
| bunx cspell \
|
|
22
|
-
--file-list stdin \
|
|
23
|
-
--locale "en" \
|
|
24
|
-
--unique \
|
|
25
|
-
--no-progress \
|
|
26
|
-
--cache \
|
|
27
|
-
--config "bgord-scripts/templates/cspell.json" \
|
|
28
|
-
$@
|
|
29
|
-
|
|
30
|
-
success "Files are correct!"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source bgord-scripts/base.sh
|
|
4
|
-
setup_base_config
|
|
5
|
-
|
|
6
|
-
info "Syncing database from production to local"
|
|
7
|
-
|
|
8
|
-
info "Using project: $PROJECT_NAME"
|
|
9
|
-
|
|
10
|
-
scp "production:/var/www/$PROJECT_NAME/sqlite.db" prisma
|
|
11
|
-
|
|
12
|
-
success "Successfully synced database for $PROJECT_NAME"
|
package/bgord-scripts/e2e-run.sh
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source bgord-scripts/base.sh
|
|
4
|
-
setup_base_config
|
|
5
|
-
|
|
6
|
-
set_node_timezone_to_utc
|
|
7
|
-
|
|
8
|
-
if test -d "infra/e2e"
|
|
9
|
-
then
|
|
10
|
-
info "Running E2E..."
|
|
11
|
-
else
|
|
12
|
-
info "E2E tests not available"
|
|
13
|
-
exit 0
|
|
14
|
-
fi
|
|
15
|
-
|
|
16
|
-
bunx playwright install
|
|
17
|
-
bunx playwright test --reporter null --pass-with-no-tests
|
|
18
|
-
|
|
19
|
-
success "E2E tests ran!"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source bgord-scripts/base.sh
|
|
4
|
-
setup_base_config
|
|
5
|
-
|
|
6
|
-
info "Formatting all staged files..."
|
|
7
|
-
|
|
8
|
-
npx @biomejs/biome format \
|
|
9
|
-
--write \
|
|
10
|
-
--staged \
|
|
11
|
-
--no-errors-on-unmatched \
|
|
12
|
-
--config-path=bgord-scripts/templates/biome.json
|
|
13
|
-
|
|
14
|
-
success "Staged files formatted successfully!"
|
package/bgord-scripts/format.sh
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source bgord-scripts/base.sh
|
|
4
|
-
setup_base_config
|
|
5
|
-
|
|
6
|
-
info "Environment: production"
|
|
7
|
-
info "Building frontend..."
|
|
8
|
-
|
|
9
|
-
cp frontend/node_modules/@bgord/design/dist/main.min.css frontend/public/
|
|
10
|
-
cp frontend/node_modules/@bgord/design/dist/normalize.min.css frontend/public/
|
|
11
|
-
|
|
12
|
-
cd frontend/
|
|
13
|
-
bunx react-router build
|
|
14
|
-
|
|
15
|
-
success "Frontend built!"
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
source bgord-scripts/base.sh
|
|
4
|
-
setup_base_config
|
|
5
|
-
|
|
6
|
-
info "Watching and rebuilding frontend..."
|
|
7
|
-
|
|
8
|
-
cp frontend/node_modules/@bgord/design/dist/main.min.css frontend/public/
|
|
9
|
-
cp frontend/node_modules/@bgord/design/dist/normalize.min.css frontend/public/
|
|
10
|
-
|
|
11
|
-
cd frontend/
|
|
12
|
-
bunx react-router dev
|