-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup_nuxt.sh.backup
executable file
·210 lines (180 loc) · 5.07 KB
/
setup_nuxt.sh.backup
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
# Assign the first argument to PROJECT_DIR
PROJECT_DIR="$1"
# Check if PROJECT_DIR is provided
if [ -z "$PROJECT_DIR" ]; then
echo "Error: PROJECT_DIR parameter is missing, for example nuxt3."
echo "Usage: $0 <project_directory>"
exit 1
fi
# Define the necessary directories
dirs=(
# Nuxt build directories
".output" ".nuxt"
# Application structure
"app"
"app/assets" "app/components" "app/composables" "app/layouts" "app/middleware" "app/pages" "app/pages/demo" "app/plugins" "app/utils" "app/stores" "app/lang" "app/lang/json"
# Content and module layers
"content" "layers" "modules" "node_modules" "public"
# Type definitions
"types"
# Server-side directories
"server"
"server/api" "server/middleware" "server/plugins" "server/routes" "server/utils"
"server/api/fm" "server/api/fmtest" "server/api/sqltest"
)
# Create directories
for dir in "${dirs[@]}"; do
mkdir -p "$PROJECT_DIR/$dir" || { echo "Error: Failed to create directory $PROJECT_DIR/$dir"; exit 1; }
# We want also empty dirs pushed to github:
touch "$PROJECT_DIR/$dir/.gitkeep"
done
# remove legacy app.vue
rm -f "$PROJECT_DIR/app.vue"
# Create the app.vue compatibility version 4 file with boilerplate content
cat <<EOF > "$PROJECT_DIR/app/app.vue"
// app.vue is the top-level component that wraps everything.
<template>
<NuxtLayout>
<header></header>
<main>
<NuxtPage />
</main>
<footer></footer>
</NuxtLayout>
</template>
<script setup>
import { NuxtLayout, NuxtPage } from '#components'
</script>
<style scoped></style>
EOF
# Create the default.vue layout with boilerplate content
cat <<EOF > "$PROJECT_DIR/app/layouts/default.vue"
<template>
<div>
<slot />
</div>
</template>
<script setup>
</script>
<style scoped>
/* Styles specific to this layout */
</style>
EOF
# Create the admin.vue layout with boilerplate content
cat <<EOF > "$PROJECT_DIR/app/layouts/admin.vue"
<template>
<div>
<header></header>
<main>
<slot />
</main>
<footer></footer>
</div>
</template>
<script setup>
</script>
<style scoped></style>
EOF
# Create the index.vue page with boilerplate content
cat <<EOF > "$PROJECT_DIR/app/pages/index.vue"
<script setup>
definePageMeta({
layout: 'default',
})
</script>
<template>
<div>
<h1>Welcome to the Home Page</h1>
</div>
</template>
EOF
# Create the admin.vue page with boilerplate content
cat <<EOF > "$PROJECT_DIR/app/pages/admin.vue"
<script setup>
definePageMeta({
layout: 'admin',
})
</script>
<template>
<div>
<h1>Admin Page</h1>
</div>
</template>
EOF
# Check if jq is installed
if ! command -v jq &> /dev/null; then
echo "Error: jq is not installed. Please install it and try again."
exit 1
fi
if [ ! -f "$PROJECT_DIR/nuxt.config.ts" ]; then
echo "Error: One or more configuration files not found."
exit 1
fi
# Define the temporary file for configuration changes
TEMP_FILE=$(mktemp)
trap 'rm -f "$TEMP_FILE"' EXIT
# Write the configuration changes to the temporary file
cat <<EOF > "$TEMP_FILE"
future: {
compatibilityVersion: 4,
},
app: {
baseURL: '/nuxt/',
},
server: {
host: "0.0.0.0",
port: 3001
},
devServer: {
host: "localhost",
port: 3001
},
runtimeConfig: {
xapiBaseUrl: process.env.SERVER_API_BASE_URL || "http://" + process.env.SERVERIP + ":" + process.env.SERVERPORT,
authSecret: process.env.AUTH_SECRET,
csamPass: process.env.CSAM_PASS,
dbHost: process.env.DB_HOST,
dbUser: process.env.DB_USER,
dbPassword: process.env.DB_PASSWORD,
dbName: process.env.DB_NAME,
solrLogin: process.env.SOLR_LOGIN,
solrPassword: process.env.SOLR_PASSWORD,
auDatabase: process.env.AU_DATABASE,
auPassword: process.env.AU_PASSWORD,
auServername: process.env.AU_SERVERNAME,
auUsername: process.env.AU_USERNAME,
fakeSecret: process.env.FAKE_SECRET,
solrHost: process.env.SOLR_HOST,
solrPort: process.env.SOLR_PORT,
apiBaseUrl: process.env.API_URL,
baseUrl: process.env.BASE_URL,
fm1ProxyUrl: process.env.FM1_PROXY_URL,
fm2ProxyUrl: process.env.FM2_PROXY_URL,
public: {
clientId: process.env.CLIENT_ID,
csamUser: process.env.CSAM_USER,
logoutRedirectUri: process.env.LOGOUT_REDIRECT_URI,
redirectUri: process.env.REDIRECT_URI,
csamBaseUrl: process.env.CSAM_BASE_URL,
accessTokenUri: process.env.ACCESSTOKEN_URI,
userinfoUri: process.env.USERINFO_URI,
authorizeUri: process.env.AUTHORIZE_URI,
tokeninfoUri: process.env.TOKENINFO_URI,
introspectUri: process.env.INTROSPECT_URI,
endSession: process.env.ENDSESSION,
fakePublic: process.env.FAKE_PUBLIC,
mailmanProxyUrl: process.env.MAILMAN_PROXY_URL,
},
},
EOF
# Check if nuxt.config.ts exists
if [ ! -f "$PROJECT_DIR/nuxt.config.ts" ]; then
echo "Error: nuxt.config.ts not found in the current directory."
exit 1
fi
# Add the configuration changes to nuxt.config.ts
sed -i "/export default defineNuxtConfig({/r $TEMP_FILE" "$PROJECT_DIR/nuxt.config.ts"
echo "#####################"
echo "Configuration changes have been added to nuxt.config.ts."
echo "#####################"