Skip to content

Commit 54a6e0a

Browse files
committed
add bash script to add things
1 parent c434d4c commit 54a6e0a

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

add

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
# Script to install shadcn-vue components and move them to the correct location
4+
# Usage: ./add <component-name>
5+
6+
# Check if component name is provided
7+
if [ -z "$1" ]; then
8+
echo "Error: Component name is required"
9+
echo "Usage: ./add <component-name>"
10+
exit 1
11+
fi
12+
13+
COMPONENT=$1
14+
15+
echo "Installing component: $COMPONENT"
16+
17+
# Run shadcn-vue installation command
18+
npx shadcn-vue@latest add $COMPONENT
19+
20+
# Check if installation was successful
21+
if [ $? -ne 0 ]; then
22+
echo "Error: Failed to install component $COMPONENT"
23+
exit 1
24+
fi
25+
26+
# Create target directory if it doesn't exist
27+
mkdir -p src/components/$COMPONENT
28+
29+
# Move files from ui directory to components directory
30+
if [ -d "src/components/ui/$COMPONENT" ]; then
31+
echo "Moving files from src/components/ui/$COMPONENT to src/components/$COMPONENT"
32+
mv -f src/components/ui/$COMPONENT/* src/components/$COMPONENT/
33+
34+
# Remove the now empty ui directory for this component
35+
rmdir src/components/ui/$COMPONENT 2>/dev/null
36+
37+
echo "Component $COMPONENT successfully installed and moved to the correct location"
38+
else
39+
echo "Warning: Directory src/components/ui/$COMPONENT not found"
40+
echo "Check if the component was installed correctly"
41+
exit 1
42+
fi

app/pages/contribution-guide.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
## Adding Components
44
Gooey is built primarily with [Shadcdn-vue](https://www.shadcn-vue.com/) components.
55

6-
Components can be installed into the project following the standard installation method, eg. `npx shadcn-vue@latest add sidebar`.
6+
Components can be installed into the project using the `./add <component>` command, which handles the installation and file movement automatically:
77

8-
Some components are customised wrappers around shadcn-vue to alter the API slightly.
8+
```bash
9+
./add <component-name>
10+
```
11+
12+
Alternatively, you can use the standard installation method, eg. `npx shadcn-vue@latest add <component-name>`.
13+
14+
Note that due to an ongoing bug in shadcn-vue and the `components.json` `aliases.ui` value, components will not install directly to `./src/components`. The `./add` script handles this automatically, but if you're using the standard method, you should copy the component up one level manually.
915

1016
When adding a component, ensure you do these things:
1117

12-
1. Install from shadcn-vue, eg. `npx shadcn-vue@latest add sidebar`
18+
1. Install the component using `./add <component-name>` or from shadcn-vue directly with `npx shadcn-vue@latest add <component-name>`
1319
2. Register the component in `src/index.ts`
1420
3. Create a vue file matching the component name in app/components, and register it in `app/pages/index.ts`
1521
4. Register the documentation route in `app/router/index.ts`

0 commit comments

Comments
 (0)