forked from couetilc/react-social-icons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli
executable file
·143 lines (116 loc) · 2.4 KB
/
cli
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
143
#!/usr/bin/env bash
PRETTIER_PATTERN=("./*.js" "src/**" "test/**" "db/**")
build() {
build:pkg "$@"
}
build:pkg() {
pnpm rollup -c rollup.config.js "$@"
}
# shellcheck disable=SC2120
build:visual() {
build:pkg
pnpm vite build -c test/visual/vite.config.js "$@" test/visual
}
build:www() {
pnpm vite build -c www/vite.config.js www/
}
dev() {
info:visual
}
info:bundlesize() {
build
tar -c dist | gzip > dist.tar.gz
du -h dist dist.tar.gz
rm dist.tar.gz
}
info:visual() {
pnpm vite --force -c vite.config.js test/visual/
}
info:www() {
pnpm vite -c vite.config.js www/
}
task:icons-shot() {
./cli build:www
pnpx playwright
}
task:fmt() {
pnpm prettier -u -w "${PRETTIER_PATTERN[@]}"
}
task:update-node() {
brew upgrade nodenv node-build
latest="$(node-build --definitions | sort -urn | head -n 1)"
echo "$latest" > .node-version
nodenv install --skip-existing "$(cat .node-version)"
corepack enable
node -e "
var packagejson = require('./package.json')
packagejson.packageManager = 'pnpm@$(pnpm -v)'
fs.writeFileSync(
'./package.json',
JSON.stringify(packagejson, null, 2)
)
"
}
task:setup-dev() {
brew install nodenv node-build
echo "eval \"\$(nodenv init -)\"" >> ".${SHELL/[a-z\/]*\//}rc"
nodenv install
corepack enable
pnpm install
}
test:lint() {
build --silent
pnpm eslint .eslintrc.cjs . db/*
}
test:publint() {
build --silent
pnpm publint .
}
test:fmt() {
pnpm prettier -u -c "${PRETTIER_PATTERN[@]}"
}
test:ts() {
pnpm tsc
}
test:unit() {
build --silent
pnpm vitest test/unit/*.test.js "$@"
}
test:src() {
pnpm vitest test/unit/src.test.js "$@"
}
test:codesplitting() {
build --silent
./test/codesplitting.sh
}
test:visual() {
scale=2
network=tiktok
out=./tmp/visual-test/shot.png
pnpx playwright screenshot \
--viewport-size="$((1250 * scale)), $((400 * scale))" \
"http://localhost:5173/?network=$network&knobs=false&scale=$scale" \
"$out"
}
test:dep() {
[[ ! -a 'package-lock.json' ]] || (
echo "Error: invalid package manager npm detected, this project uses pnpm." && exit 1
)
[[ ! -a 'yarn.lock' ]] || (
echo "Error: invalid package manager yarn detected, this project uses pnpm." && exit 1
)
}
test:() {
set -e
test:lint;
test:publint;
test:fmt;
test:ts;
test:unit --run --silent;
test:codesplitting;
test:dep
echo
echo Passed All Tests
set +e
}
"$@"