run custom install, merge 2channels, include git rev in buildconfig

This commit is contained in:
andreas 2023-09-07 11:17:15 +02:00
parent e8890a879c
commit 4366116d63
5 changed files with 69 additions and 12 deletions

View File

@ -44,7 +44,7 @@ jobs:
- run: - run:
name: "save build config" name: "save build config"
working_directory: ".pio/build/<< pipeline.parameters.environment >>" working_directory: ".pio/build/<< pipeline.parameters.environment >>"
command: "echo 'PLATFORMIO_BUILD_FLAGS=\"<< pipeline.parameters.build_flags >>\" pio run -e << pipeline.parameters.environment >> ' > buildconfig.txt" command: "echo 'GIT_SHA=\"<< pipeline.git.revision >>\" PLATFORMIO_BUILD_FLAGS=\"<< pipeline.parameters.build_flags >>\" pio run -e << pipeline.parameters.environment >> ' > buildconfig.txt"
- run: - run:
name: "rename" name: "rename"
working_directory: ".pio/build/<< pipeline.parameters.environment >>" working_directory: ".pio/build/<< pipeline.parameters.environment >>"

View File

@ -22,3 +22,17 @@ body {
font-family: system-ui; font-family: system-ui;
line-height: 1.5em; line-height: 1.5em;
} }
#loading{
height: 6em;
}
#loadingText{
text-align: center;
}
#loadingFrame{
display: flex;
flex-direction: column;
align-items: center;
}
.hidden{
display: none !important;
}

View File

@ -11,7 +11,12 @@
<body> <body>
<div class="heading"></div> <div class="heading"></div>
<div class="console"></div> <div class="console"></div>
<div class="content"></div> <div class="content">
<div id="loadingFrame">
<div id="loadingText" ></div>
<img id="loading" src="spinner.gif"/>
</div>
</div>
<div id="terminal"></div> <div id="terminal"></div>
</body> </body>
</html> </html>

View File

@ -1,6 +1,6 @@
import {XtermOutputHandler} from "./installUtil.js"; import {XtermOutputHandler} from "./installUtil.js";
import ESPInstaller from "./installUtil.js"; import ESPInstaller from "./installUtil.js";
import { addEl, getParam } from "./helper.js"; import { addEl, getParam, setValue, setVisible } from "./helper.js";
import * as zip from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.29/+esm"; import * as zip from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.29/+esm";
(function(){ (function(){
let espLoaderTerminal; let espLoaderTerminal;
@ -130,12 +130,16 @@ import * as zip from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.29/+esm";
} }
} }
const buildCustomButtons = (name, updateData, fullData,version,element) => { const buildCustomButtons = (name, updateData, fullData,version,info,element) => {
let bFrame = document.querySelector(element || '.content'); let bFrame = document.querySelector(element || '.content');
if (!bFrame) return; if (!bFrame) return;
bFrame.textContent = ''; bFrame.textContent = '';
addEl('div', 'version', bFrame, "Custom Installation"); let item=addEl('div','item',bFrame);
let btLine = addEl('div', 'buttons', bFrame); addEl('div', 'version', item, "Custom "+version);
if (info){
addEl('div','version',item,info);
}
let btLine = addEl('div', 'buttons', item);
let tb = addEl('button', 'installButton', btLine, 'Initial'); let tb = addEl('button', 'installButton', btLine, 'Initial');
tb.addEventListener('click', async () => { tb.addEventListener('click', async () => {
enableConsole(false, true); enableConsole(false, true);
@ -162,8 +166,25 @@ import * as zip from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.29/+esm";
}); });
} }
const showLoading=(on)=>{ const showLoading=(on)=>{
setVisible('loadingFrame',on);
}; };
class BinaryStringWriter extends zip.Writer {
constructor() {
super();
this.binaryString = "";
}
writeUint8Array(array) {
for (let indexCharacter = 0; indexCharacter < array.length; indexCharacter++) {
this.binaryString += String.fromCharCode(array[indexCharacter]);
}
}
getData() {
return this.binaryString;
}
}
window.onload = async () => { window.onload = async () => {
if (! ESPInstaller.checkAvailable()){ if (! ESPInstaller.checkAvailable()){
showError("your browser does not support the ESP flashing (no serial)"); showError("your browser does not support the ESP flashing (no serial)");
@ -172,6 +193,7 @@ import * as zip from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.29/+esm";
let custom=getParam('custom'); let custom=getParam('custom');
let user; let user;
let repo; let repo;
let errorText=`unable to query release info for user ${user}, repo ${repo}: `;
if (! custom){ if (! custom){
user = window.gitHubUser||getParam('user'); user = window.gitHubUser||getParam('user');
repo = window.gitHubRepo || getParam('repo'); repo = window.gitHubRepo || getParam('repo');
@ -189,26 +211,42 @@ import * as zip from "https://cdn.jsdelivr.net/npm/@zip.js/zip.js@2.7.29/+esm";
buildButtons(user, repo); buildButtons(user, repo);
} }
else{ else{
errorText="unable to download custom build";
showLoading(true); showLoading(true);
setValue('loadingText','downloading custom build')
let reader= new zip.HttpReader(custom); let reader= new zip.HttpReader(custom);
let zipReader= new zip.ZipReader(reader); let zipReader= new zip.ZipReader(reader);
const entries=(await zipReader.getEntries()); const entries=(await zipReader.getEntries());
let fullData; let fullData;
let updateData; let updateData;
let base=""; let base="";
let environment;
let buildflags;
for (let i=0;i<entries.length;i++){ for (let i=0;i<entries.length;i++){
if (entries[i].filename.match(/-all.bin$/)){ if (entries[i].filename.match(/-all.bin$/)){
fullData=await(entries[i].getData(new zip.BlobWriter())) fullData=await(entries[i].getData(new BinaryStringWriter()))
base=entries[i].filename.replace("-all.bin",""); base=entries[i].filename.replace("-all.bin","");
} }
if (entries[i].filename.match(/-update.bin$/)){ if (entries[i].filename.match(/-update.bin$/)){
updateData=await(entries[i].getData(new zip.BlobWriter())) updateData=await(entries[i].getData(new BinaryStringWriter()))
base=entries[i].filename.replace("-update.bin",""); base=entries[i].filename.replace("-update.bin","");
} }
if (entries[i].filename === 'buildconfig.txt'){
let txt=await(entries[i].getData(new zip.TextWriter()));
environment=txt.replace(/.*pio run *.e */,'').replace(/ .*/,'');
buildflags=txt.replace(/.*PLATFORMIO_BUILD_FLAGS="/,'').replace(/".*/,'');
} }
buildCustomButtons("dummy",updateData,fullData,base); }
let info;
if (environment !== undefined && buildflags !== undefined){
info=`env=${environment}, flags=${buildflags}`;
}
buildCustomButtons("dummy",updateData,fullData,base,info);
showLoading(false); showLoading(false);
} }
} catch(error){alert("unable to query release info for user "+user+", repo "+repo+": "+error)}; } catch(error){
showLoading(false);
alert(errorText+error)
};
} }
})(); })();

View File

@ -276,7 +276,7 @@ class ESPInstaller{
* @param {*} version the info shown in the dialog * @param {*} version the info shown in the dialog
* @returns * @returns
*/ */
async runFlash(isFull,address,imageData,version,assetName){ async runFlash(isFull,imageData,address,version,assetName){
try { try {
await this.connect(); await this.connect();
if (typeof (assetName) === 'function') { if (typeof (assetName) === 'function') {