-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_dev_env.ps1
More file actions
135 lines (121 loc) · 3.6 KB
/
setup_dev_env.ps1
File metadata and controls
135 lines (121 loc) · 3.6 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
# Function to display a message
function echo_message {
Write-Host ""
Write-Host "======================================"
Write-Host "$1"
Write-Host "======================================"
Write-Host ""
}
# Function to handle errors
function handle_error {
Write-Host ""
Write-Host "======================================"
Write-Host "Error occurred during: $1"
Write-Host "Exiting script."
Write-Host "======================================"
exit 1
}
# Function to install Chocolatey if not already installed
function install_chocolatey {
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
echo_message "Installing Chocolatey..."
Set-ExecutionPolicy Bypass -Scope Process -Force
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
}
# Function to install common dependencies
function install_dependencies {
echo_message "Installing curl, git, unzip, and 7zip..."
choco install -y curl git unzip 7zip
}
# Function to install or upgrade Node.js and npm
function install_nodejs {
echo_message "Installing or upgrading Node.js and npm..."
$NODE_VERSION = Read-Host "Enter the version of Node.js to install (default is 16)"
if (-not $NODE_VERSION) {
$NODE_VERSION = 16
}
Invoke-WebRequest -Uri "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-x64.msi" -OutFile "node_installer.msi"
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i node_installer.msi /quiet" -Wait
Remove-Item -Path "node_installer.msi"
}
# Function to install or upgrade create-react-app
function install_react {
install_nodejs
echo_message "Installing or upgrading create-react-app globally..."
npm install -g create-react-app
}
# Function to install or upgrade Flutter
function install_flutter {
echo_message "Installing or upgrading Dart SDK..."
if (-not (Get-Command flutter -ErrorAction SilentlyContinue)) {
choco install -y dart-sdk flutter
}
}
# Function to install or upgrade Android Studio
function install_android_studio {
if (-not (Get-Command studio -ErrorAction SilentlyContinue)) {
choco install -y android-studio
}
}
# Function to install or upgrade Visual Studio Code
function install_vscode {
if (-not (Get-Command code -ErrorAction SilentlyContinue)) {
choco install -y vscode
}
}
# Function to install or upgrade Laravel
function install_laravel {
echo_message "Installing or upgrading Laravel..."
install_nodejs
if (-not (Get-Command composer -ErrorAction SilentlyContinue)) {
choco install -y composer
}
composer global require laravel/installer
}
# Update and upgrade the system
echo_message "Updating and upgrading the system..."
if (-not (Get-Command choco -ErrorAction SilentlyContinue)) {
install_chocolatey
}
choco upgrade all -y
# Prompt user for input
Write-Host "Choose the development field name to setup (Node.js, React, Flutter, Android Studio, vscode, Laravel):"
$userInput = Read-Host
# Call the appropriate installation function
switch ($userInput) {
"Node.js" {
install_dependencies
install_nodejs
}
"React" {
install_dependencies
install_react
}
"Flutter" {
install_flutter
}
"Android Studio" {
install_android_studio
}
"vscode" {
install_vscode
}
"Laravel" {
install_dependencies
install_laravel
}
default {
echo_message "Invalid option selected. Please choose a valid development field name."
exit 1
}
}
# Verify installations
echo_message "Verifying installations..."
node -v
npm -v
flutter --version
dart --version
code --version
laravel --version
echo_message "Development environment setup completed successfully!"