Skip to content

Commit

Permalink
added sdk only installation
Browse files Browse the repository at this point in the history
  • Loading branch information
sampathbalivada committed May 10, 2020
1 parent 468086c commit 67f9732
Show file tree
Hide file tree
Showing 14 changed files with 553 additions and 28 deletions.
9 changes: 9 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ function previousPage(currentPageID) {
}
}

function sdkNextPage(currentPageID) {
currentPageID++;
if (currentPageID == 3) {
window.location.href = `../${pages[currentPageID]}/index.html`;
} else if (currentPageID < pages.length) {
window.location.href = `../sdk_${pages[currentPageID]}/index.html`;
}
}

function closeWindow() {
var window = remote.getCurrentWindow();
window.close();
Expand Down
1 change: 1 addition & 0 deletions app/download/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<div class="valign-wrapper" style="width: 100%; height: 80%;">
<div class="container" style="padding-top: 10%; height: 100%;">
<img src="../../assets/flutter_logo_lockup.svg" alt="Flutter Logo" style="height: 10%; margin-bottom: 2%;">
<div class="left-align">
<h5>These components will be downloaded:</h5>
</div>
Expand Down
13 changes: 10 additions & 3 deletions app/finish/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,25 @@

<div class="valign-wrapper" style="width: 100%; height: 65%;">
<div class="container" style="padding-top: 10%; height: 100%;">
<img src="../../assets/flutter_logo_lockup.svg" alt="Flutter Logo" style="height: 12%; margin-bottom: 2%;">
<div class="left-align">
<h5>Installation Successful</h5>
<p>We've successfully installed Flutter SDK on your PC. If you feedback for the utility or if you want
to contribute, visit the repository on <a href="javascript:void(0)"
<p>Flutter SDK was successfully installed on your PC. To give feedback, suggestions or contribute to the installer please visit the repository on <a href="javascript:void(0)"
onclick="openURL('https://github.com/sampathbalivada/flutter_installer')"
style="-webkit-user-select: text;">GitHub</a>.</p>
<p>
To install additional SDK Tools refer to the Android sdkmanager documentation <a href="javascript:void(0)"
onclick="openURL('https://developer.android.com/studio/command-line/sdkmanager')"
style="-webkit-user-select: text;">here</a>.
</p>
</div>
</div>
</div>

<!-- Disclaimer -->
<div class="row center-align">
<p style="font-style: italic;">Flutter, Android and the related logos are trademarks of Google LLC.</p>
<p style="font-style: italic;">Flutter, Android and the related logos are trademarks of Google LLC.<br>Visual
Studio and the related logos are trademarks of Microsoft Corporation.</p>
</div>

<!-- button bar -->
Expand Down
31 changes: 24 additions & 7 deletions app/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,33 @@

<div class="valign-wrapper" style="width: 100%; height: 90%;">
<div class="container">
<img src="../../assets/flutter.gif" class="" style="width: 100%;">
<div class="center-align">
<a href="javascript:void(0)" onclick="nextPage(0)"
class="waves-effect waves-light light-blue darken-1 btn">Install
Flutter</a>
<img src="../../assets/flutter.gif" class="" style="max-width: 70%;">
</div>
<div class="center-align">
<p style="font-style: italic;">Does not install <strong>Android Studio</strong>.<br> Installs minimal
amount
of components to build Flutter applications with <strong>Visual Studio Code</strong>.</p>
<p style="font-style: italic;">
Choose <strong>Install SDK Only</strong> if you already have <strong>Android Studio</strong> installed.
</p>
</div>
<div class="row">
<a href="javascript:void(0)" onclick="sdkNextPage(0)">
<div class="col s5 push-s1">
<div class="card">
<div class="card-image">
<img src="../../assets/sdk-only.svg">
</div>
</div>
</div>
</a>
<a href="javascript:void(0)" onclick="nextPage(0)">
<div class="col s5 push-s1">
<div class="card">
<div class="card-image">
<img src="../../assets/minimal.svg">
</div>
</div>
</div>
</a>
</div>
</div>
</div>
Expand Down
8 changes: 7 additions & 1 deletion app/install/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

<div class="valign-wrapper" style="width: 100%; height: 80%;">
<div class="container" style="padding-top: 10%; height: 100%;">
<img src="../../assets/flutter_logo_lockup.svg" alt="Flutter Logo" style="height: 10%; margin-bottom: 2%;">
<div class="left-align">
<h5>Extracting components:</h5>
</div>
Expand All @@ -45,14 +46,19 @@ <h5>Extracting components:</h5>
<div id="path-loader" class="loader"></div>
<i id="path-done" class="material-icons completion-icon">done</i>
</li>
<li>
<strong>Installing SDK Tools: API 28</strong> &nbsp; &nbsp;
<div id="tools-loader" class="loader"></div>
<i id="tools-done" class="material-icons completion-icon">done</i>
</li>
</ul>
</div>
</div>
</div>

<!-- button bar -->
<div class="row center-align">
<a id="finish-button" href="javascript:void(0)" onclick="nextPage(2)"
<a id="next-button" href="javascript:void(0)" onclick="nextPage(2)"
class="waves-effect waves-light light-blue darken-1 btn disabled">Next</a>
</div>
<progress id="progress-bar" max='100' value='0'></progress>
Expand Down
69 changes: 52 additions & 17 deletions app/install/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ const exec = util.promisify(require('child_process').exec);

const extract = require('extract-zip');

const folder = "D:\\Android";
const folder = "C:\\Android";

// Set this constant to `true` while debugging
// Should always be `false` while building a release
const debug = true;
const debug = false;

function installComponents() {
var urls;
var jdkDirName;
dwn.getURLs('https://raw.githubusercontent.com/sampathbalivada/flutter_installer/master/urls.json?token=AGLFFNEZK75GHLTNLMTQOR26X57GO')
.then((fetchedURLs) => {
urls = fetchedURLs;
Expand All @@ -27,6 +26,9 @@ function installComponents() {
return;
}
var fileName = dwn.getFilenameFromUrl(urls['command-line-tools'])
if (fs.existsSync(folder + "\\cmdline-tools\\latest")) {
return
}
return extract(folder + "\\" + fileName, {
dir: folder + "\\cmdline-tools"
});
Expand All @@ -44,6 +46,9 @@ function installComponents() {
return;
}
var fileName = dwn.getFilenameFromUrl(urls['jdk']);
if (fs.existsSync(folder + "\\openjdk")) {
return
}
return extract(folder + "\\" + fileName, {
dir: folder
});
Expand All @@ -61,6 +66,9 @@ function installComponents() {
return;
}
var fileName = dwn.getFilenameFromUrl(urls['flutter-sdk'])
if (fs.existsSync(folder + "\\flutter")) {
return
}
return extract(folder + "\\" + fileName, {
dir: folder
});
Expand All @@ -84,17 +92,22 @@ function renameDirectories() {
document.getElementById('progress-bar').value = 80;
addComponentsToPath();
} else {
fs.renameSync(folder + "\\cmdline-tools\\tools", folder + "\\cmdline-tools\\latest");
fs.readdir(folder, (err, files) => {
files.forEach((name) => {
if (name.substr(0, 3) == 'jdk') {
jdkDirName = name;
fs.renameSync(folder + "\\" + name, folder + "\\openjdk");
document.getElementById('progress-bar').value = 80;
addComponentsToPath();
}
if (!fs.existsSync(folder + "\\cmdline-tools\\latest")) {
fs.renameSync(folder + "\\cmdline-tools\\tools", folder + "\\cmdline-tools\\latest");
}
if (!fs.existsSync(folder + "\\openjdk")) {
//find JDK folder in the directory and rename
fs.readdir(folder, (err, files) => {
files.forEach((name) => {
if (name.substr(0, 3) == 'jdk') {
jdkDirName = name;
fs.renameSync(folder + "\\" + name, folder + "\\openjdk");
}
});
});
});
}
document.getElementById('progress-bar').value = 80;
addComponentsToPath();
}
}

Expand All @@ -103,7 +116,9 @@ function addComponentsToPath() {
document.getElementById('progress-bar').value = 100;
document.getElementById('path-loader').style.display = 'none';
document.getElementById('path-done').style.visibility = 'visible';
enableFinish();
document.getElementById('tools-loader').style.visibility = 'visible';

installSDKComponents();
return
} else {
exec('setx ANDROID_HOME "C:\\Android\\')
Expand All @@ -130,13 +145,33 @@ function addComponentsToPath() {
}
document.getElementById('path-loader').style.display = 'none';
document.getElementById('path-done').style.visibility = 'visible';
document.getElementById('progress-bar').value = 100;
document.getElementById('tools-loader').style.visibility = 'visible';
document.getElementById('progress-bar').value = 95;

installSDKComponents();
})
}
}

function installSDKComponents() {
if (debug) {
document.getElementById('progress-bar').value = 100;
document.getElementById('tools-loader').style.display = 'none';
document.getElementById('tools-done').style.visibility = 'visible';
enableNext();
return
} else {
exec('sdkmanager "platform-tools" "platforms;android-28" "build-tools;28.0.3"')
.then(() => {
document.getElementById('tools-loader').style.display = 'none';
document.getElementById('tools-done').style.visibility = 'visible';
enableNext();
})
}
}

function enableFinish(params) {
document.getElementById('finish-button').classList.remove('disabled');
function enableNext(params) {
document.getElementById('next-button').classList.remove('disabled');
}

// Comment this line while debugging.
Expand Down
43 changes: 43 additions & 0 deletions app/sdk_download/download.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const fs = require('fs');
const dwn = require('../download-helper');

function startDownload() {
var download_button = document.getElementById('download-button');
var urls;
var downloadPath = "C:\\Android";
const progressIndicator = document.getElementById('progress-bar');
download_button.onclick = '';
download_button.classList.add("disabled");
dwn.getURLs('https://raw.githubusercontent.com/sampathbalivada/flutter_installer/master/urls.json?token=AGLFFNEZK75GHLTNLMTQOR26X57GO')
.then((fetchedURLs) => {
urls = fetchedURLs;
showFileNames(urls);

//Downloading Flutter SDK
document.getElementById('sdk-loader').style.visibility = 'visible';
var finalPath = downloadPath + "\\" + dwn.getFilenameFromUrl(urls['flutter-sdk']);
if (fs.existsSync(finalPath)) {
return
}
return dwn.downloadFile({
remoteFile: urls['flutter-sdk'],
localFile: finalPath,
onProgress: function (received, total) {
var percentage = (received * 100) / total;
progressIndicator.value = percentage;
}
})
})
.then(() => {
document.getElementById('sdk-loader').style.display = 'none';
document.getElementById('sdk-done').style.visibility = 'visible';
progressIndicator.value = 100;
download_button.classList.remove("disabled");
download_button.innerHTML = 'Install Components';
download_button.setAttribute('onclick', 'sdkNextPage(1)');
})
}

function showFileNames(urls) {
document.getElementById('sdk-name').innerHTML += dwn.getFilenameFromUrl(urls['flutter-sdk']);
}
50 changes: 50 additions & 0 deletions app/sdk_download/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flutter Installer</title>
<script src="../../materialize/js/materialize.min.js"></script>
<link rel="stylesheet" href="../app.css">
<script src="../app.js"></script>
<script src="./download.js"></script>
</head>

<body>
<div class="titlebar">
<button class="topcorner" id="close-button" onclick="closeWindow()">
<i class="material-icons close-button">close</i>
</button>
</div>

<div class="valign-wrapper" style="width: 100%; height: 80%;">
<div class="container" style="padding-top: 10%; height: 100%;">
<img src="../../assets/flutter_logo_lockup.svg" alt="Flutter Logo" style="height: 10%; margin-bottom: 2%;">
<div class="left-align">
<h5>The Flutter SDK will be downloaded:</h5>
</div>
<div class="left-align">
<ul>
<li>
<strong>Flutter SDK</strong> &nbsp; &nbsp;
<div id="sdk-loader" class="loader"></div>
<i id="sdk-done" class="material-icons completion-icon">done</i>
<p id="sdk-name" style="font-style: italic;">version: </p>
</li>
</ul>
</div>

</div>

</div>
<div class="row center-align">
<a id="download-button" href="javascript:void(0)" onclick="startDownload()"
class="waves-effect waves-light light-blue darken-1 btn">Start Download</a>
</div>
<!-- <p style="position: absolute; left: 10px; bottom: 1%;">80%</p> -->
<progress id="progress-bar" max='100' value='0'></progress>

</body>

</html>
Loading

0 comments on commit 67f9732

Please sign in to comment.