Skip to content

Commit ebdec65

Browse files
committed
Fixed upgrade script compatibility issues between MacOS & Linux, suppressed some errors
1 parent 257cb25 commit ebdec65

3 files changed

Lines changed: 44 additions & 36 deletions

File tree

docs/theming.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Then preview your theme by running:
2828
npm run dev
2929
```
3030

31+
You may need to open the dev server (http://localhost:3000) in a second window in a private tab or different browser on first load to resolve the layout rendering error.
32+
3133
## Tailwind & CSS
3234
Prez UI uses [Tailwind](https://tailwindcss.com) for most of its styling, which you can use in this starter template to easily style using classes.
3335

packages/create-prez-app/template/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Then preview your theme by running:
1414
npm run dev
1515
```
1616

17+
You may need to open the dev server (http://localhost:3000) in a second window in a private tab or different browser on first load to resolve the layout rendering error.
18+
1719
## Configuration
1820
### Environment Variables
1921
The main configuration required for running Prez UI are done with environment variables:

upgrade.sh

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,99 +5,103 @@ if $UPGRADE_DONE; then
55
fi
66

77
MAC_OS=$([ $(uname -s) == Darwin ] && echo true || echo false)
8-
SED_FLAGS=$($MAC_OS && echo '"-i" ""' || echo "-i")
9-
USE_PNPM=$([ -f pnpm-lock.yaml ]; echo $?)
8+
USE_PNPM=$([ -f pnpm-lock.yaml ] && echo true || echo false)
9+
10+
if $MAC_OS; then
11+
SED_FLAGS=( -i '' )
12+
else
13+
SED_FLAGS=( -i )
14+
fi
1015

1116
# 1. Uninstall old packages
1217
REMOVE_PACKAGES="@nuxtjs/tailwindcss radix-vue shadcn-nuxt prez-ui tailwind-merge nuxt"
13-
if [ $USE_PNPM ]; then
18+
if $USE_PNPM; then
1419
pnpm remove $REMOVE_PACKAGES
1520
else
1621
npm uninstall $REMOVE_PACKAGES
1722
fi
1823

19-
sed $SED_FLAGS "-e" 's/\"@nuxtjs\/tailwindcss\"[,]\{0,1\}//g' nuxt.config.ts
20-
sed $SED_FLAGS "-e" 's/\"shadcn-nuxt\"[,]\{0,1\}//g' nuxt.config.ts
21-
22-
# 2. Remove required files & folders
23-
rm components.json
24-
rm tailwind.config.js
25-
rm -r components/ui
24+
sed "${SED_FLAGS[@]}" "-e" 's/\"@nuxtjs\/tailwindcss\"[,]\{0,1\}//g' nuxt.config.ts
25+
sed "${SED_FLAGS[@]}" "-e" 's/\"shadcn-nuxt\"[,]\{0,1\}//g' nuxt.config.ts
2626

27-
# 3. Backup Tailwind variables
27+
# 2. Backup Tailwind variables
2828
mv assets/css/tailwind.css assets/css/tailwind.txt
2929
touch assets/css/tailwind.css
3030

31-
# 4. Reinstall packages
32-
rm -r .nuxt
33-
rm -r .output
34-
rm -r node_modules
35-
36-
if [ $USE_PNPM ]; then
37-
pnpm install
38-
else
39-
npm install
40-
fi
31+
# 3. Remove files
32+
rm -f components.json
33+
rm -f tailwind.config.js
34+
rm -rf components/ui
35+
rm -rf .nuxt
36+
rm -rf .output
37+
rm -rf node_modules
4138

42-
# 5. Install Nuxt 4
39+
# 4. Reorganise folder structure
4340
mkdir app
44-
mv assets components composables layouts lib pages utils app.config.ts app.vue -t app
41+
mv assets components composables layouts lib pages utils app.config.ts app.vue -t app 2>/dev/null
4542

4643
curl https://cdn.jsdelivr.net/gh/rdflib/prez-ui@feature/tailwind4/packages/create-prez-app/template/tsconfig.json > tsconfig.json
4744

48-
if [ $USE_PNPM ]; then
45+
# 5. Reinstall packages
46+
if $USE_PNPM; then
4947
pnpm add -D nuxt
5048
else
5149
npm install -D nuxt
5250
fi
5351

52+
PREPARE="nuxi prepare"
53+
if $USE_PNPM; then
54+
pnpm dlx $PREPARE
55+
else
56+
npx $PREPARE
57+
fi
58+
5459
# 6. Install Tailwind 4
5560
TAILWIND_PACKAGES="tailwindcss @tailwindcss/vite"
56-
if [ $USE_PNPM ]; then
61+
if $USE_PNPM; then
5762
pnpm add $TAILWIND_PACKAGES
5863
else
5964
npm install $TAILWIND_PACKAGES
6065
fi
6166

6267
echo '@import "tailwindcss";' > app/assets/css/tailwind.css
6368

64-
sed $SED_FLAGS "-e" '1s/^/import tailwindcss from "@tailwindcss\/vite";\n\n/' nuxt.config.ts
65-
sed $SED_FLAGS '/vite: {/ a\
69+
sed "${SED_FLAGS[@]}" "-e" '1s/^/import tailwindcss from "@tailwindcss\/vite";\n\n/' nuxt.config.ts
70+
sed "${SED_FLAGS[@]}" '/vite: {/ a\
6671
plugins: \[tailwindcss\(\)\],
6772
' nuxt.config.ts
6873

6974
# 7. Install & initialise shadcn-vue
7075
SHAD_ADD="nuxi@latest module add shadcn-nuxt"
71-
if [ $USE_PNPM ]; then
76+
if $USE_PNPM; then
7277
pnpm dlx $SHAD_ADD
7378
else
7479
npx $SHAD_ADD
7580
fi
7681

77-
sed $SED_FLAGS "-e" 's/\(}\)$/\1,/g' nuxt.config.ts
82+
sed "${SED_FLAGS[@]}" "-e" 's/\(}\)$/\1,/g' nuxt.config.ts
7883

79-
sed $SED_FLAGS '/});$/ i\
84+
sed "${SED_FLAGS[@]}" '/});$/ i\
8085
shadcn: \{\
8186
prefix: \"\",\
8287
componentDir: \"@\/components\/ui\"\
8388
\},\
8489
' nuxt.config.ts
8590

86-
PREPARE="nuxi prepare"
87-
if [ $USE_PNPM ]; then
91+
if $USE_PNPM; then
8892
pnpm dlx $PREPARE
8993
else
9094
npx $PREPARE
9195
fi
9296

9397
SHAD_INIT="shadcn-vue@latest init -d"
94-
if [ $USE_PNPM ]; then
98+
if $USE_PNPM; then
9599
pnpm dlx $SHAD_INIT
96100
else
97101
npx $SHAD_INIT
98102
fi
99103

100-
sed $SED_FLAGS "-e" 's/zinc/slate/g' components.json
104+
sed "${SED_FLAGS[@]}" "-e" 's/zinc/slate/g' components.json
101105

102106
git clone -n --depth=1 --filter=tree:0 -b feature/tailwind4 --single-branch https://github.com/rdflib/prez-ui
103107
cd prez-ui
@@ -108,7 +112,7 @@ mv prez-ui/packages/create-prez-app/template/app/components/ui app/components
108112
rm -rf prez-ui
109113

110114
# 8. Install reka-ui
111-
if [ $USE_PNPM ]; then
115+
if $USE_PNPM; then
112116
pnpm add reka-ui
113117
else
114118
npm install reka-ui
@@ -118,7 +122,7 @@ fi
118122
curl https://cdn.jsdelivr.net/gh/rdflib/prez-ui@feature/tailwind4/packages/create-prez-app/template/app/assets/css/tailwind.css > app/assets/css/tailwind.css
119123

120124
# 10. Install prez-ui
121-
if [ $USE_PNPM ]; then
125+
if $USE_PNPM; then
122126
pnpm add -D ../prez-ui/packages/prez-ui
123127
else
124128
npm install -D ../prez-ui/packages/prez-ui

0 commit comments

Comments
 (0)