-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathworkflows.sh
More file actions
135 lines (111 loc) · 3.52 KB
/
Copy pathworkflows.sh
File metadata and controls
135 lines (111 loc) · 3.52 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
#!/bin/bash
set -euo pipefail
# Helpers
pmgr() {
if command -v pnpm >/dev/null 2>&1; then echo pnpm; return; fi
if command -v yarn >/dev/null 2>&1; then echo yarn; return; fi
echo npm
}
root_dir() {
git rev-parse --show-toplevel 2>/dev/null || pwd
}
# 1) Discoverability
function ui-help() {
npx dedevs-ui --help
}
function ui-version() {
npx dedevs-ui --version
}
function ui-list() {
npx dedevs-ui list
}
# 2) Add components
function ui-add() {
if [ -z "${1:-}" ]; then
echo "Usage: ui-add <component-name>"
return 1
fi
npx dedevs-ui add "$1"
}
function ui-add-many() {
if [ "$#" -lt 1 ]; then
echo "Usage: ui-add-many <component-1> <component-2> ..."
return 1
fi
npx dedevs-ui add "$@"
}
# Alias to keep old name working
function add-component() { ui-add "$@"; }
# 3) Local dev on CLI (from monorepo root)
function ui-build-cli() {
local mgr; mgr=$(pmgr)
(cd "$(root_dir)" && $mgr run build:cli)
}
function ui-test-cli() {
# Prints CLI help to verify build artifact
ui-build-cli
node "$(root_dir)/dist/index.js" --help
}
# 4) Registry workflows (see docs/registry/* and package.json)
function ui-gen-registry() {
# Generate registry JSON from packages
local mgr; mgr=$(pmgr)
(cd "$(root_dir)" && $mgr run gen:registry)
}
function ui-build-registry() {
# Build shadcn registry and copy public assets for docs
local mgr; mgr=$(pmgr)
(cd "$(root_dir)" && $mgr run build:registry)
}
function ui-registry() {
ui-gen-registry && ui-build-registry
}
# 5) Publishing wrappers (call existing scripts)
# NOTE: These run the repo-defined scripts which may publish to npm.
# Ensure you're authenticated and on the correct branch/tag.
function ui-pub-patch() { (cd "$(root_dir)" && $(pmgr) run pub:patch); }
function ui-pub-minor() { (cd "$(root_dir)" && $(pmgr) run pub:minor); }
function ui-pub-major() { (cd "$(root_dir)" && $(pmgr) run pub:major); }
# 6) Add from a local JSON file via shadcn (validates registry item locally)
function ui-add-from-file() {
if [ -z "${1:-}" ]; then
echo "Usage: ui-add-from-file </absolute/or/relative/path/to/registry-item.json>"
return 1
fi
# Ensure shadcn is initialized if needed (non-interactive)
if [ ! -f components.json ]; then
echo "Initializing shadcn components.json"
npx shadcn@latest init -y >/dev/null 2>&1 || true
fi
npx shadcn@latest add "$1"
}
# 7) App-targeted add (useful in monorepo to add into a specific app path)
function ui-add-in() {
if [ "$#" -lt 2 ]; then
echo "Usage: ui-add-in <app-path> <component-name> [more components...]"
echo "Example: ui-add-in apps/web ai-response"
return 1
fi
local app_path="$1"; shift
(cd "$app_path" && npx dedevs-ui add "$@")
}
# 8) Quick sanity workflows
function ui-sanity() {
ui-test-cli
ui-list
}
# 9) Monorepo dev and maintenance
function ui-dev-root() { (cd "$(root_dir)" && $(pmgr) run dev); }
function ui-lint() { (cd "$(root_dir)" && $(pmgr) run lint); }
function ui-format() { (cd "$(root_dir)" && $(pmgr) run format); }
function ui-analyze() { (cd "$(root_dir)" && $(pmgr) run analyze); }
function ui-bump-deps() { (cd "$(root_dir)" && $(pmgr) run bump-deps); }
# Be careful: this uses git clean -xdf node_modules (as defined in package.json)
function ui-clean() { (cd "$(root_dir)" && $(pmgr) run clean); }
# 10) Docs/dev convenience
function ui-docs-dev() {
# Prefer running the full monorepo dev since docs relies on workspace
ui-dev-root
}
# 11) Quick convenience installers
function ui-add-ai-response-web() { (cd "apps/web" && npx dedevs-ui add ai-response); }