@columenlabs/lumen-ship 0.1.153 → 0.1.154
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/README.md +2 -1
- package/bin/lumen-ship +3 -3
- package/package.json +1 -1
- package/scripts/check-parts.sh +67 -0
package/README.md
CHANGED
|
@@ -100,9 +100,10 @@ lumen-ship check kit-neutral [paths] # no name from LUMEN_FORBIDDEN_NAMES (def
|
|
|
100
100
|
lumen-ship check suppressions # a useExhaustiveDependencies suppression needs a reason of 3+ words
|
|
101
101
|
lumen-ship check settings-copy # a Settings section description is one plain line of 64 characters or less
|
|
102
102
|
lumen-ship check magic-numbers # hard-coded px/rem class values may only go down
|
|
103
|
+
lumen-ship check parts <folders> # the kit's part pages: hint-text, text-action, raw-overlay may only go down
|
|
103
104
|
```
|
|
104
105
|
|
|
105
|
-
Run each from a package folder in its `lint` script. `magic-numbers` reads the repo's `scripts/magic-numbers.baseline` (or `LUMEN_SHIP_BASELINE`): one `<folder> <count>` a line, lowered in the change that removes one.
|
|
106
|
+
Run each from a package folder in its `lint` script; run `parts` from the repo root with the app folders (`lumen-ship check parts apps/*/web/src`). `magic-numbers` reads the repo's `scripts/magic-numbers.baseline` (or `LUMEN_SHIP_BASELINE`): one `<folder> <count>` a line, lowered in the change that removes one. `parts` reads `scripts/parts.baseline` (or `LUMEN_SHIP_PARTS_BASELINE`): one `<folder> <rule> <count>` a line; `--write-baseline` writes today's counts on a first run. Each rule is explained, with what to write instead, at https://lumen.columenlabs.com/parts/README.md.
|
|
106
107
|
|
|
107
108
|
## Versions
|
|
108
109
|
|
package/bin/lumen-ship
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# lumen-ship: releases and lint guards shared by every app. Run from the repo root.
|
|
3
3
|
# lumen-ship release [patch | minor | notes | tag v<version>] see scripts/release.sh
|
|
4
|
-
# lumen-ship check suppressions | settings-copy | magic-numbers | kit-neutral [paths]
|
|
4
|
+
# lumen-ship check suppressions | settings-copy | magic-numbers | kit-neutral | parts [paths]
|
|
5
5
|
set -euo pipefail
|
|
6
6
|
here=$(cd "$(dirname "$(readlink -f "$0")")/../scripts" && pwd)
|
|
7
7
|
cmd=${1:-}
|
|
@@ -12,9 +12,9 @@ case "$cmd" in
|
|
|
12
12
|
name=${1:-}
|
|
13
13
|
shift || true
|
|
14
14
|
case "$name" in
|
|
15
|
-
suppressions | settings-copy | magic-numbers | kit-neutral) exec "$here/check-$name.sh" "$@" ;;
|
|
15
|
+
suppressions | settings-copy | magic-numbers | kit-neutral | parts) exec "$here/check-$name.sh" "$@" ;;
|
|
16
16
|
esac
|
|
17
|
-
echo "usage: lumen-ship check suppressions | settings-copy | magic-numbers | kit-neutral" >&2
|
|
17
|
+
echo "usage: lumen-ship check suppressions | settings-copy | magic-numbers | kit-neutral | parts" >&2
|
|
18
18
|
exit 1
|
|
19
19
|
;;
|
|
20
20
|
esac
|
package/package.json
CHANGED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# The kit's part pages (docs/parts in the Lumen repo) hold in an app: each rule below counts its
|
|
3
|
+
# breaks per folder, and a count may only fall. The repo's scripts/parts.baseline (or
|
|
4
|
+
# LUMEN_SHIP_PARTS_BASELINE) holds today's counts, one `<folder> <rule> <count>` a line; lower a
|
|
5
|
+
# count in the change that removes a break. `--write-baseline` writes the counts as they are now,
|
|
6
|
+
# for a first run. Run from the repo root with the app folders: lumen-ship check parts apps/*/web/src
|
|
7
|
+
# hint-text a grey line under a field or title: <p className="... text-xs ... text-muted-foreground ...">
|
|
8
|
+
# text-action a <Button> whose text is an action: an IconButton (or SaveButton) instead
|
|
9
|
+
# raw-overlay an import of the kit's raw ui/sheet, ui/dialog, ui/select, ui/command or ui/combobox
|
|
10
|
+
set -euo pipefail
|
|
11
|
+
write=0
|
|
12
|
+
if [ "${1:-}" = "--write-baseline" ]; then
|
|
13
|
+
write=1
|
|
14
|
+
shift
|
|
15
|
+
fi
|
|
16
|
+
if [ $# -eq 0 ]; then
|
|
17
|
+
echo "usage: lumen-ship check parts [--write-baseline] <folder>..." >&2
|
|
18
|
+
exit 1
|
|
19
|
+
fi
|
|
20
|
+
baseline=${LUMEN_SHIP_PARTS_BASELINE:-$(git rev-parse --show-toplevel)/scripts/parts.baseline}
|
|
21
|
+
rules="hint-text text-action raw-overlay"
|
|
22
|
+
|
|
23
|
+
# Prints `file:line` for each break of one rule in one folder.
|
|
24
|
+
hits() {
|
|
25
|
+
local rule=$1 dir=$2
|
|
26
|
+
find "$dir" -type f -name '*.tsx' -not -path '*/node_modules/*' -print0 \
|
|
27
|
+
| xargs -0 -r perl -0777 -ne '
|
|
28
|
+
my $rule = "'"$rule"'";
|
|
29
|
+
my $re;
|
|
30
|
+
if ($rule eq "hint-text") {
|
|
31
|
+
$re = qr/<p\s[^>]*className="(?=[^"]*\btext-xs\b)(?=[^"]*\btext-muted-foreground\b)[^"]*"/;
|
|
32
|
+
} elsif ($rule eq "text-action") {
|
|
33
|
+
$re = qr/<Button\b[^>]*>\s*(?:<[A-Z]\w*[^>]*\/>\s*)?(?:\{[^}]*\?\s*)?\x27?(?:Save|Run|Test|Send|Sync|Refresh|Copy|Edit|Delete|Remove|Retry|Reset)\b/;
|
|
34
|
+
} else {
|
|
35
|
+
$re = qr/from\s+[\x27"]\@columenlabs\/lumen-ui\/ui\/(?:sheet|dialog|select|command|combobox)[\x27"]/;
|
|
36
|
+
}
|
|
37
|
+
while (/$re/g) {
|
|
38
|
+
my $line = 1 + (substr($_, 0, $-[0]) =~ tr/\n//);
|
|
39
|
+
print "$ARGV:$line\n";
|
|
40
|
+
}'
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
failed=0
|
|
44
|
+
out=""
|
|
45
|
+
for dir in "$@"; do
|
|
46
|
+
[ -d "$dir" ] || continue
|
|
47
|
+
for rule in $rules; do
|
|
48
|
+
list=$(hits "$rule" "$dir")
|
|
49
|
+
n=$(printf '%s' "$list" | grep -c . || true)
|
|
50
|
+
if [ "$write" = 1 ]; then
|
|
51
|
+
out+="$dir $rule $n"$'\n'
|
|
52
|
+
continue
|
|
53
|
+
fi
|
|
54
|
+
base=$( [ -f "$baseline" ] && awk -v d="$dir" -v r="$rule" '$1 == d && $2 == r { print $3 }' "$baseline" || true)
|
|
55
|
+
base=${base:-0}
|
|
56
|
+
if [ "$n" -gt "$base" ]; then
|
|
57
|
+
failed=1
|
|
58
|
+
echo "$dir: $n $rule, baseline $base (see docs/parts/README.md in the Lumen repo):" >&2
|
|
59
|
+
printf '%s\n' "$list" >&2
|
|
60
|
+
fi
|
|
61
|
+
done
|
|
62
|
+
done
|
|
63
|
+
if [ "$write" = 1 ]; then
|
|
64
|
+
printf '%s' "$out" | awk '$3 > 0' > "$baseline"
|
|
65
|
+
echo "wrote $baseline" >&2
|
|
66
|
+
fi
|
|
67
|
+
exit "$failed"
|