Skip to content

Commit 6ac6a37

Browse files
committed
JBDS-3959 DevSuite Uninstaller for Windows
Use: powershell -ExecutionPolicy bypass -Filec:\ds\uninstaller\uninstall.ps1
1 parent 5bdd4c7 commit 6ac6a37

5 files changed

Lines changed: 71 additions & 28 deletions

File tree

browser/model/helpers/util.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ class Util {
8888
}
8989

9090
static resolveFile(relativePath, filename) {
91+
return require(Util.resolveFileLocation(relativePath,filename));
92+
}
93+
94+
static resolveFileLocation(relativePath, filename) {
9195
let pathForBuild = path.join('resources', 'app.asar');
9296
let fileForTests = path.resolve(path.join(relativePath, filename));
9397
let fileForRT = path.join(path.resolve('.'), pathForBuild, relativePath, filename);
9498

9599
let reqs;
96100
if (fs.existsSync(fileForTests)) {
97-
reqs = require(fileForTests);
101+
reqs = fileForTests;
98102
} else if ( fs.existsSync(fileForRT) ) {
99-
reqs = require(fileForRT);
103+
reqs = fileForRT;
100104
}
101105

102106
return reqs;

browser/services/data.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import InstallableItem from '../model/installable-item';
44
import Logger from './logger';
5+
import Util from '../model/helpers/util';
56

67
let os = require('os');
78
let path = require('path');
89
let fs = require('fs');
10+
let fsExtra = require('fs-extra');
911
let electron = require('electron');
1012
var mkdirp = require('mkdirp');
1113

@@ -46,6 +48,18 @@ class InstallerDataService {
4648

4749
if (!fs.existsSync(this.installRoot)) {
4850
mkdirp.sync(path.resolve(this.installRoot));
51+
let uninstallerLocation = path.resolve(this.installRoot,'unistaller');
52+
Logger.info(`Data - Create uninstaller in ${uninstallerLocation}`);
53+
mkdirp.sync(uninstallerLocation);
54+
let uninstallerPs1 = Util.resolveFileLocation('./uninstaller','uninstall.ps1');
55+
// write file content to uninstaller/uninstaller.ps1
56+
fsExtra.copy(uninstallerPs1, path.join(uninstallerLocation,'uninstall.ps1'), (err) => {
57+
if (err) {
58+
Logger.error('Data - ' + err);
59+
} else {
60+
Logger.info('Data - Copy ' + uninstallerPs1 + ' to ' + path.join(uninstallerLocation,'uninstall.ps1') + ' SUCCESS');
61+
}
62+
});
4963
}
5064
Logger.initialize(this.installRoot);
5165
}
@@ -203,7 +217,6 @@ class InstallerDataService {
203217

204218
if (!this.isDownloading() && this.toInstall.size == 0) {
205219
Logger.info('All installs complete');
206-
207220
this.installing = false;
208221
this.router.go('start');
209222
}

gulpfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ gulp.task('transpile:app', ['create-modules-link'], function() {
6262
.pipe(sourcemaps.write())
6363
.pipe(gulp.dest('transpiled'));
6464

65-
var resources = gulp.src(['browser/**/*', '!browser/**/*.js', '*.json'], {base: '.'})
65+
var resources = gulp.src(['browser/**/*', '!browser/**/*.js', '*.json', 'uninstaller/*.ps1'], {base: '.'})
6666
.pipe(gulp.dest('transpiled'));
6767

6868
return merge(sources, resources);
@@ -83,7 +83,7 @@ gulp.task('clean-all', ['clean'], function() {
8383

8484
// clean dist/ folder in prep for fresh build
8585
gulp.task('clean', function() {
86-
return del(['dist'], { force: true });
86+
return del(['dist','transpiled'], { force: true });
8787
});
8888

8989
// Create default callback for exec

test/unit/services/data-test.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import Logger from 'services/logger';
1111
import path from 'path';
1212
import os from 'os';
1313
import fs from 'fs';
14+
import fsExtra from 'fs-extra';
1415
chai.use(sinonChai);
1516

1617

@@ -35,7 +36,7 @@ describe('InstallerDataService', function() {
3536
sandbox.restore();
3637
});
3738

38-
let logStub, fsStub, infoStub, errorStub;
39+
let logStub, fsStub, infoStub, errorStub, fxExtraStub;
3940
let fakeProgress = {
4041
installTrigger: function() {},
4142
setStatus: function(status) {}
@@ -46,13 +47,15 @@ describe('InstallerDataService', function() {
4647
infoStub = sinon.stub(Logger, 'info');
4748
errorStub = sinon.stub(Logger, 'error');
4849
fsStub = sinon.stub(fs, 'mkdirSync');
50+
fxExtraStub = sinon.stub(fsExtra, 'copy');
4951
});
5052

5153
after(function() {
5254
logStub.restore();
5355
fsStub.restore();
5456
infoStub.restore();
5557
errorStub.restore();
58+
fxExtraStub.restore();
5659
});
5760

5861
describe('initial state', function() {

uninstaller/uninstall.ps1

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,58 @@
1-
param(
2-
[string]$folder = 'c:\DevelopmentSuite'
3-
)
4-
echo '(1/6) Removing VirtualBox'
5-
$vbox = Get-WmiObject Win32_Product | where {$_.Name -like '*VirtualBox*'}
6-
msiexec /x $vbox.IdentifyingNumber /qb /norestart | Out-Null
7-
echo 'DONE'
8-
9-
echo '(2/6) Removing VirtualBox VMs folder'
10-
Remove-Item -Recurse $env:USERPROFILE'\VirtualBox VMs'
11-
echo 'DONE'
1+
#
2+
$folder = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
3+
4+
$vboxInstalled = Test-Path $folder'\..\virtualbox'
5+
$vagrantInstalled = Test-Path $folder'\..\vagrant'
6+
$openjdkInstalled = Test-Path $folder'\..\jdk8'
7+
8+
echo 'Uninstalling Red Hat Development Suite'
9+
10+
if ( $vboxInstalled ) {
11+
echo 'Removing VirtualBox'
12+
$vbox = Get-WmiObject Win32_Product | where {$_.Name -like '*VirtualBox*'}
13+
msiexec /x $vbox.IdentifyingNumber /qb /norestart | Out-Null
14+
echo 'DONE'
15+
16+
$vboxVmsExists = Test-Path $env:USERPROFILE'\VirtualBox VMs'
17+
if($vboxVmsExists) {
18+
echo 'Removing VirtualBox VMs folder'
19+
Remove-Item -Recurse $env:USERPROFILE'\VirtualBox VMs'
20+
echo 'DONE'
21+
}
22+
}
1223

13-
echo '(3/6) Removing vagrant.d folder'
14-
Remove-Item -Recurse $env:USERPROFILE'\.vagrant.d'
15-
echo 'DONE'
24+
if( $vagrantInstalled ) {
25+
echo 'Removing Vagrant'
26+
$vagrant = Get-WmiObject Win32_Product | where {$_.Name -like '*Vagrant*'}
27+
msiexec /x $vagrant.IdentifyingNumber /qb /norestart | Out-Null
28+
echo 'DONE'
29+
30+
$vagrantDExists = Test-Path $env:USERPROFILE'\.vagrant.d'
31+
if($vagrantDExists){
32+
echo 'Removing vagrant.d folder'
33+
Remove-Item -Recurse $env:USERPROFILE'\.vagrant.d'
34+
echo 'DONE'
35+
}
36+
}
1637

17-
echo '(4/6) Removing Vagrant'
18-
$vagrant = Get-WmiObject Win32_Product | where {$_.Name -like '*Vagrant*'}
19-
msiexec /x $vagrant.IdentifyingNumber /qb /norestart | Out-Null
20-
echo 'DONE'
38+
if ( $openJdkInstalled ) {
39+
echo 'Removing Red Hat OpenJDK'
40+
$vbox = Get-WmiObject Win32_Product | where {$_.Name -like '*OpenJDK*'}
41+
msiexec /x $vbox.IdentifyingNumber /qb /norestart | Out-Null
42+
echo 'DONE'
43+
}
2144

22-
echo '(5/6) Removing the DevelopmentSuite installation folder'
23-
Cmd /C "rmdir /S /Q $folder" | Out-Null
45+
echo 'Removing installation folder'
46+
Cmd /C "rmdir /S /Q $folder\.." | Out-Null
2447
echo 'DONE'
2548

26-
echo '(6/6) Removing path entries'
49+
echo 'Removing path entries'
2750
[string[]] $pathFolders = [Environment]::GetEnvironmentVariable("Path", "User") -Split ';'
2851
[Collections.ArrayList] $folderList = New-Object Collections.Arraylist
2952

3053
$pathFolders | foreach {
3154
If (-Not ($_ -like "$folder*")) {
32-
$folderList.Add($_) | Out-Null
55+
$folderList.Add($_) | Out-Null
3356
}
3457
}
3558

0 commit comments

Comments
 (0)