55# ------------------------------------------------------------------------------
66# Copyright (c) 2018, International Business Machines. All Rights Reserved.
77# ------------------------------------------------------------------------------
8- $VERSION = " 1.2.0"
9- $PROG = " IBM Cloud Developer Tools - Installer for Windows"
8+ $Global : VERSION = " 1.2.0"
9+ $Global : PROG = " IBM Cloud Developer Tools - Installer for Windows"
1010
11- $INSTALLER_URL = " https://ibm.biz/idt-win-installer"
12- $GIT_URL = " https://github.com/IBM-Cloud/ibm-cloud-developer-tools"
13- $SLACK_URL = " https://slack-invite-ibm-cloud-tech.mybluemix.net/"
14- $IDT_INSTALL_BMX_URL = " https://clis.ng.bluemix.net/install"
15- $IDT_INSTALL_BMX_REPO_NAME = " Bluemix"
16- $IDT_INSTALL_BMX_REPO_URL = " https://plugins.ng.bluemix.net"
11+ $Global : INSTALLER_URL = " https://ibm.biz/idt-win-installer"
12+ $Global : GIT_URL = " https://github.com/IBM-Cloud/ibm-cloud-developer-tools"
13+ $Global : SLACK_URL = " https://slack-invite-ibm-cloud-tech.mybluemix.net/"
14+ $Global : IDT_INSTALL_BMX_URL = " https://clis.ng.bluemix.net/install"
15+ $Global : IDT_INSTALL_BMX_REPO_NAME = " Bluemix"
16+ $Global : IDT_INSTALL_BMX_REPO_URL = " https://plugins.ng.bluemix.net"
1717
1818$Global :FORCE = $false
1919$Global :NEEDS_REBOOT = $false
@@ -23,7 +23,7 @@ $Global:SECS = 0
2323function help {
2424 Write-Output @"
2525
26- $PROG
26+ $Global : PROG
2727 Usage: idt-win-installer [<args>]
2828
2929 Where <args> is:
@@ -42,8 +42,8 @@ function help {
4242 - idt update : Runs this installer checking for and installing any updates
4343 - idt uninstall : Uninstalls IDT, 'bx' cli, and all plugins
4444
45- Chat with us on Slack: ${ SLACK_URL} , channel #developer-tools
46- Submit any issues to : ${ GIT_URL} /issues
45+ Chat with us on Slack: $Global : SLACK_URL , channel #developer-tools
46+ Submit any issues to : $Global : GIT_URL /issues
4747
4848"@
4949}
@@ -125,9 +125,9 @@ function install() {
125125 $reply = Read-Host - Prompt " Use IBM internal repos for install/updates (Y/n)?"
126126 Write-Output
127127 if ($reply -match " [Yy]*" ) {
128- $IDT_INSTALL_BMX_URL = " https://clis.stage1.ng.bluemix.net/install"
129- $IDT_INSTALL_BMX_REPO_NAME = " stage1"
130- $IDT_INSTALL_BMX_REPO_URL = " https://plugins.stage1.ng.bluemix.net"
128+ $Global : IDT_INSTALL_BMX_URL = " https://clis.stage1.ng.bluemix.net/install"
129+ $Global : IDT_INSTALL_BMX_REPO_NAME = " stage1"
130+ $Global : IDT_INSTALL_BMX_REPO_URL = " https://plugins.stage1.ng.bluemix.net"
131131 }
132132 }
133133 }
@@ -148,7 +148,7 @@ function install_deps() {
148148
149149 # -- git
150150 log " Checking for external dependency: git"
151- if ( -not (get-command git - erroraction ' silentlycontinue' ) -or $Global :FORC ) {
151+ if ( -not (get-command git - erroraction ' silentlycontinue' ) -or $Global :FORCE ) {
152152 log " Installing/updating external dependency: git"
153153 $gitVersion = (Invoke-WebRequest " https://git-scm.com/downloads/latest" - UseBasicParsing).Content
154154 Invoke-WebRequest " https://github.com/git-for-windows/git/releases/download/v$gitVersion .windows.1/Git-$gitVersion -64-bit.exe" - UseBasicParsing - outfile " git-installer.exe"
@@ -160,7 +160,7 @@ function install_deps() {
160160
161161 # -- docker
162162 log " Checking for external dependency: docker"
163- if ( -not (get-command docker - erroraction ' silentlycontinue' ) -or $Global :FORC ) {
163+ if ( -not (get-command docker - erroraction ' silentlycontinue' ) -or $Global :FORCE ) {
164164 log " Installing/updating external dependency: docker"
165165 Invoke-WebRequest " https://download.docker.com/win/stable/InstallDocker.msi" - UseBasicParsing - outfile " InstallDocker.msi"
166166 msiexec / i InstallDocker.msi / passive | Out-Null
@@ -170,7 +170,7 @@ function install_deps() {
170170
171171 # -- kubectl
172172 log " Checking for external dependency: kubectl"
173- if ( -not ( get-command kubectl - erroraction ' silentlycontinue' ) -or $Global :FORC ) {
173+ if ( -not ( get-command kubectl - erroraction ' silentlycontinue' ) -or $Global :FORCE ) {
174174 log " Installing/updating external dependency: kubectl"
175175 $kube_version = (Invoke-WebRequest " https://storage.googleapis.com/kubernetes-release/release/stable.txt" - UseBasicParsing).Content
176176 $kube_version = $kube_version -replace " `n |`r "
@@ -184,7 +184,7 @@ function install_deps() {
184184
185185 # -- helm
186186 log " Checking for external dependency: helm"
187- if ( -not (get-command helm - erroraction ' silentlycontinue' ) -or $Global :FORC ) {
187+ if ( -not (get-command helm - erroraction ' silentlycontinue' ) -or $Global :FORCE ) {
188188 log " Installing/updating external dependency: helm"
189189 $helm_url = ((Invoke-WebRequest https:// github.com / kubernetes/ helm - UseBasicParsing).Links.OuterHTML | Where-Object {$_ -match ' windows-amd64.tar.gz' } | Select-Object - first 1 ).Split(' "' )[1 ]
190190 log " Helm URL : $helm_url "
@@ -228,7 +228,7 @@ function install_bx() {
228228 bx update
229229 } else {
230230 log " Installing IBM Cloud 'bx' CLI for Windows..."
231- $url = $IDT_INSTALL_BMX_URL + " /powershell"
231+ $url = $Global : IDT_INSTALL_BMX_URL + " /powershell"
232232 log " Downloading and installing IBM Cloud 'bx' CLI from: $url "
233233 Invoke-Expression (New-Object Net.WebClient).DownloadString( $url )
234234 $Global :NEEDS_REBOOT = $true
@@ -241,23 +241,26 @@ function install_bx() {
241241# -- Install Bluemix CLI Plugins.
242242function install_plugins {
243243 log " Installing/updating IBM Cloud CLI plugins used by IDT..."
244- $EXT_PLUGINS = " Cloud-Functions" ,
245- " container-registry" ,
246- " container-service" ,
247- " dev" ,
248- " schematics" ,
249- " sdk-gen"
244+ $plugins = " Cloud-Functions" ,
245+ " container-registry" ,
246+ " container-service" ,
247+ " dev" ,
248+ " schematics" ,
249+ " sdk-gen"
250250 $pluginlist = C:\" Program Files" \IBM\Bluemix\bin\bx.exe plugin list
251- Foreach ($plugin in $EXT_PLUGINS ) {
252- log " Checking status of plugin: $plugin "
253- if ($pluginlist -match " \b$plugin \b" ) {
254- log " Updating plugin '$plugin '"
255- C:\" Program Files" \IBM\Bluemix\bin\bx.exe plugin update - r $IDT_INSTALL_BMX_REPO_NAME $plugin
256- } else {
257- log " Installing plugin '$plugin '"
258- C:\" Program Files" \IBM\Bluemix\bin\bx.exe plugin install - r $IDT_INSTALL_BMX_REPO_NAME $plugin
259- }
251+ Foreach ($plugin in $plugins ) {
252+ log " Checking status of plugin: $plugin "
253+ if ($pluginlist -match " \b$plugin \b" ) {
254+ log " Updating plugin '$plugin '"
255+ C:\" Program Files" \IBM\Bluemix\bin\bx.exe plugin update - r $Global : IDT_INSTALL_BMX_REPO_NAME $plugin
256+ } else {
257+ log " Installing plugin '$plugin '"
258+ C:\" Program Files" \IBM\Bluemix\bin\bx.exe plugin install - r $Global : IDT_INSTALL_BMX_REPO_NAME $plugin
259+ }
260260 }
261+ log " Running 'bx plugin list'..."
262+ C:\" Program Files" \IBM\Bluemix\bin\bx.exe plugin list
263+ log " Finished installing/updating plugins"
261264}
262265
263266# ------------------------------------------------------------------------------
@@ -294,7 +297,7 @@ REM #-----------------------------------------------------------
294297# MAIN
295298# ------------------------------------------------------------------------------
296299function main {
297- log " --==[ $PROG , v$VERSION ]==--"
300+ log " --==[ $Global : PROG , v$Global : VERSION ]==--"
298301 $Global :SECS = (Get-Date )
299302
300303 # -- Check for Windows 10
@@ -325,12 +328,13 @@ function main {
325328 Set-PSDebug - Trace 1
326329 }
327330 " --force" {
328- $Global :FORC = $true
331+ $Global :FORCE = $true
329332 warn " Forcing updates for all dependencies and other settings"
330333 }
331334 " update" { $ACTION = " install" }
332335 " install" { $ACTION = " install" }
333336 " uninstall" { $ACTION = " uninstall" }
337+ " help" { $ACTION = " help" }
334338 default { $ACTION = " help" }
335339 }
336340 }
0 commit comments