-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
302 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
const PIO_CORE_MIN_VERSION = '3.5.2-rc.3'; | ||
const STORAGE_STATE_KEY = 'platformio-ide:installer-state'; | ||
|
||
const pioNodeHelpers = require('platformio-node-helpers'); | ||
const StateStorage = require('./state-storage'); | ||
|
||
class PythonPrompt { | ||
constructor() { | ||
this.STATUS_TRY_AGAIN = 0; | ||
this.STATUS_ABORT = 1; | ||
this.STATUS_CUSTOMEXE = 2; | ||
} | ||
async prompt(){ | ||
return { status: this.STATUS_ABORT }; | ||
} | ||
} | ||
|
||
function installer() { | ||
var obj = {}; | ||
obj.stateStorage = new StateStorage(STORAGE_STATE_KEY); | ||
obj.onDidStatusChange = function () { console.log('onDidStatusChange', arguments)} | ||
|
||
var i = new pioNodeHelpers.installer.PlatformIOCoreStage(obj.stateStorage, obj.onDidStatusChange, { | ||
pioCoreMinVersion: PIO_CORE_MIN_VERSION, | ||
useBuiltinPIOCore: true, | ||
setUseBuiltinPIOCore: (value) => console.log('platformio-ide.advanced.useBuiltinPIOCore', value), | ||
useDevelopmentPIOCore: false, | ||
pythonPrompt: new PythonPrompt() | ||
}) | ||
if(process.platform.startsWith('win') && process.env.PATH.indexOf('.platformio') < 0) | ||
process.env.PATH+=";"+process.env.USERPROFILE+"\\.platformio\\penv\\Scripts;"; | ||
return i; | ||
} | ||
module.exports=installer(); | ||
//i.check().then(console.log).catch(console.error); | ||
//installer().install().then(console.log).catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
/** @babel */ | ||
|
||
/** | ||
* Copyright (c) 2017-present PlatformIO <[email protected]> | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the license found in the LICENSE file in | ||
* the root directory of this source tree. | ||
*/ | ||
|
||
module.exports = class StateStorage { | ||
|
||
constructor(stateKey) { | ||
this.stateKey = stateKey; | ||
} | ||
|
||
_loadState() { | ||
const value = localStorage.getItem(this.stateKey); | ||
if (!value) { | ||
return {}; | ||
} | ||
try { | ||
return JSON.parse(value); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
return {}; | ||
} | ||
|
||
getValue(key) { | ||
const data = this._loadState(); | ||
if (data && data.hasOwnProperty(key)) { | ||
return data[key]; | ||
} | ||
return null; | ||
} | ||
|
||
setValue(key, value) { | ||
const data = this._loadState(); | ||
data[key] = value; | ||
localStorage.setItem(this.stateKey, JSON.stringify(data)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script> | ||
<style type="text/css"> | ||
body { | ||
display: flex; | ||
text-align:center; | ||
} | ||
.starter { | ||
width: 400px; | ||
margin: auto; | ||
} | ||
.component { | ||
width: 150px; | ||
height: 150px; | ||
border-radius: 5px; | ||
display: inline-block; | ||
border: 1px solid red; | ||
background-color: pink; | ||
margin: 5px; | ||
text-align: center; | ||
vertical-align: top; | ||
} | ||
.component>div { | ||
height: 50%; | ||
padding:10px; | ||
box-sizing: border-box; | ||
} | ||
.component .state { | ||
margin:5px; | ||
*padding:5px; | ||
} | ||
.component img { | ||
max-height: 100%; | ||
max-width:100%; | ||
} | ||
.component.installed { | ||
border: 1px solid green; | ||
background-color: lightgreen; | ||
} | ||
.site { | ||
border: 1px solid black; | ||
background-color: lightyellow; | ||
} | ||
.folder { | ||
border: 1px solid black; | ||
background-color: lightblue; | ||
} | ||
button { | ||
margin: auto; | ||
display: block; | ||
background-color: greenyellow; | ||
box-shadow: 2px 2px gray; | ||
border-radius: 3px; | ||
border: solid gray 1px; | ||
transition: opacity .15s ease-in-out; | ||
cursor: pointer; | ||
user-select: none; | ||
padding: 5px 20px; | ||
vertical-align: middle; | ||
outline: none; | ||
margin-bottom: 10px; | ||
} | ||
.installed button { | ||
background-color: lightgray; | ||
} | ||
button:active { | ||
opacity: .3; | ||
box-shadow: 0 0; | ||
} | ||
ul { | ||
list-style: none; | ||
margin: 5px; | ||
padding:0; | ||
} | ||
li { | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
direction: rtl; | ||
text-align: left; | ||
} | ||
li:first-child { | ||
text-align:center; | ||
} | ||
li.active { | ||
background-color: gray; | ||
} | ||
li:hover { | ||
opacity: .5; | ||
} | ||
|
||
</style> | ||
<script> | ||
typeof $ == 'undefined' && ($ = require('jquery')); | ||
$(function() { | ||
var shell = require('electron').shell; | ||
window.opener = shell.openExternal; | ||
|
||
$('a, button[href]').on('click', function (ev) { | ||
ev.preventDefault(); | ||
window.opener($(this).attr('href'), '_blank') | ||
}) | ||
$('ul').on('click', 'li', function() { | ||
$(this).addClass('active').siblings().removeClass('active'); | ||
}) | ||
$('.pio button').on('click', function () { | ||
$(this).attr('disabled', '').siblings('.state').text('wait a minute...'); | ||
ipc.send('starter-pio'); | ||
}) | ||
$('.folder button').on('click', function () { | ||
ipc.send('starter-folder', [$('li.active').attr('n')]); | ||
}) | ||
var ipc = require('electron').ipcRenderer; | ||
ipc.send('starter-init'); | ||
ipc.on('starter-pio', function(ev, data) { | ||
$('.component.pio .state').text(data ? 'instaled' : 'error'); | ||
data && $('.component.pio').addClass('installed'); | ||
}); | ||
ipc.on('starter-init', function(ev, data) { | ||
['git','pio'].map(function(i) { | ||
var c = $('.component.' + i) | ||
data[i] && c.addClass('installed'); | ||
c.find('.state').text(data[i] ? 'Installed' : 'NOT Installed'); | ||
}); | ||
data.pio && $('.component.pio button').text('reinstall') | ||
+(data.folders || []).slice(0,4).map(function(f, n) { | ||
$('ul').append($('<li>').text(f).attr('n', n).attr('title', f)) | ||
}); | ||
}) | ||
}) | ||
</script> | ||
<div class="starter"> | ||
<div class="component git"> | ||
<div><img src="https://git-scm.com/images/[email protected]" alt="git" title="git"> | ||
</div><div> | ||
<div class="state">not found</div> | ||
<button href="https://git-scm.com/downloads">install</button></div> | ||
</div> | ||
<div class="component pio"> | ||
<div><img src="https://platformio.org/images/platformio-logo.17fdc3bc.png" alt="PlatformIO" title="PlatformIO"> | ||
</div><div title="it can take up to 5 minutes"> | ||
<div class="state">not found</div> | ||
<button>auto install</button> | ||
</div> | ||
</div> | ||
|
||
<div class="component site"> | ||
<div><a href="https://github.com/akaJes/marlin-config"><img src="https://raw.githubusercontent.com/akaJes/marlin-config/master/build/icons/icon_128x128.png"></a></div> | ||
<div> | ||
<button href="http://lt.rv.ua/mc">configurations</button> | ||
<a href="https://www.paypal.me/AKruk508"> | ||
<img src="https://img.shields.io/badge/Donate-PayPal-green.svg"></a> | ||
</div></div> | ||
|
||
<div class="component folder"> | ||
<br> | ||
<button>open folder</button> | ||
<ul> | ||
<li n="new" class="active">new</li> | ||
</ul> | ||
</div> | ||
|
||
</div> |