-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgenerate-test-app.sh
More file actions
executable file
·80 lines (69 loc) · 2.01 KB
/
generate-test-app.sh
File metadata and controls
executable file
·80 lines (69 loc) · 2.01 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
#!/bin/bash
set -e # Exit on any error
# Get the current plugin directory
PLUGIN_DIR="$(pwd)"
PLUGIN_NAME="$(basename "$PLUGIN_DIR")"
TEST_APP_NAME="pirsch-plugin-test-app"
TEST_APP_DIR="/tmp/${TEST_APP_NAME}"
# Cleanup function
cleanup() {
echo ""
echo "🧹 Cleaning up test app directory..."
rm -rf "$TEST_APP_DIR"
echo "✨ Cleanup complete!"
}
# Set up signal traps for cleanup
trap cleanup EXIT INT TERM
echo "🧹 Cleaning up existing test app..."
rm -rf "$TEST_APP_DIR"
echo "🏗️ Creating new Strapi test application at $TEST_APP_DIR..."
cd /tmp
npx create-strapi@latest --ts --use-npm --install --no-git-init --example --skip-cloud --skip-db "$TEST_APP_NAME"
echo "📁 Entering test app directory..."
cd "$TEST_APP_DIR"
echo "👤 Creating admin user..."
npx strapi admin:create-user --firstname=Test --lastname=User --email=test@user.pri --password=Testing12345
echo "🔌 Configuring pirsch plugin..."
# Create the plugins configuration file
cat > config/plugins.ts << EOF
export default () => ({
'pirsch': {
enabled: true,
resolve: '$PLUGIN_DIR',
config: {},
},
});
EOF
echo "🛡️ Configuring middleware for Pirsch dashboard..."
# Overwrite the middleware configuration to allow Pirsch iframe
cat > config/middlewares.ts << 'EOF'
export default [
'strapi::logger',
'strapi::errors',
{
name: 'strapi::security',
config: {
contentSecurityPolicy: {
directives: {
'frame-src': ["'self'", 'https://pirsch.pirsch.io'],
'connect-src': ["'self'", 'https://api.pirsch.io'],
},
},
},
},
'strapi::cors',
'strapi::poweredBy',
'strapi::query',
'strapi::body',
'strapi::session',
'strapi::favicon',
'strapi::public',
];
EOF
echo "✅ Test app setup complete!"
echo "📍 Location: $(pwd)"
echo "🚀 Starting Strapi development server..."
echo "⚙️ Use https://pirsch.pirsch.io as an example Pirsch Dashboard URL."
echo "👤 Admin User - Email: test@user.pri"
echo "👤 Admin User - Password: Testing12345"
npm run develop