Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the index and files from the artifact repo #20

Merged
merged 1 commit into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 2 additions & 15 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,9 @@ jobs:
- name: Get supported target version artifacts
run: |
cd dist
mkdir firmware
cd firmware
curl -L -o index.json https://artifactory.expresslrs.org/ExpressLRS/index.json
for i in `cat index.json | jq '.tags | keys[]' | grep -v -- -RC | sed 's/"//g' | sort -r` ; do
HASH=`grep \"$i\" index.json | sed 's/.* "//' | sed 's/".*//'`
curl -L -o firmware.zip "https://artifactory.expresslrs.org/ExpressLRS/$HASH/firmware.zip"
unzip firmware.zip
rm firmware.zip
mv firmware $i
VERSIONS=$VERSIONS", '$i'"
done
rm -f index.json
VERSIONS=`echo $VERSIONS|sed 's/, //'`
sed -i~ "s/\"@VERSIONS@\"/$VERSIONS/" ../main*.js
bash ../get_artifacts.sh
GITHASH=`git rev-parse --short HEAD`
sed -i~ "s/@GITHASH@/$GITHASH/" ../index.html
sed -i~ "s/@GITHASH@/$GITHASH/" index.html
- name: Setup Pages
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/configure-pages@v1
Expand Down
15 changes: 7 additions & 8 deletions get_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
mkdir -p firmware
cd firmware
curl -L -o index.json https://artifactory.expresslrs.org/ExpressLRS/index.json
for i in `cat index.json | jq '.tags | keys[]' | grep -v -- -RC | sed 's/"//g' | sort -r` ; do
for i in `cat index.json | jq '.tags | keys[]' | sed 's/"//g' | sort -r` ; do
HASH=`grep \"$i\" index.json | sed 's/.* "//' | sed 's/".*//'`
curl -L -o firmware.zip "https://artifactory.expresslrs.org/ExpressLRS/$HASH/firmware.zip"
unzip firmware.zip
mkdir $HASH
cd $HASH
unzip -q ../firmware.zip
mv firmware/* .
rmdir firmware
cd ..
rm firmware.zip
mv firmware $i
VERSIONS=$VERSIONS", '$i'"
done
rm -f index.json
VERSIONS=`echo $VERSIONS|sed 's/, //'`
sed -i~ "s/\'@VERSIONS@\'/$VERSIONS/" ../src/js/index.js
rm ../src/js/index.js~
41 changes: 29 additions & 12 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import { SwalMUI, Toast } from './swalmui.js'
import FileSaver from 'file-saver'
import mui from 'muicss'

// DO NOT COMMIT CHANGES TO THE FOLLOWING LINE!!!
const versions = ['@VERSIONS@']
//
const versionSelect = _('version')
const flashMode = _('flash-mode')
const flashButton = _('flashButton')
Expand All @@ -23,6 +20,9 @@ const methodSelect = _('method')
const deviceNext = _('device-next')
const deviceDiscoverButton = _('device-discover')

const mode = 'tags'
const showRCs = true
let index = null
let hardware = null
let selectedModel = null
let device = null
Expand Down Expand Up @@ -231,7 +231,21 @@ async function downloadFile (url, filename) {
}
}

function initialise () {
const compareSemanticVersions = (a, b) => {
const a1 = a.split(/[.-]/)
const b1 = b.split(/[.-]/)
const len = Math.min(a1.length, b1.length)
for (let i = 0; i < len; i++) {
const a2 = +a1[i] || 0
const b2 = +b1[i] || 0
if (a2 !== b2) {
return a2 > b2 ? 1 : -1
}
}
return b1.length - a1.length
}

async function initialise () {
checkProxy()
setInterval(() => { checkProxy() }, 30000)
term = new Terminal()
Expand All @@ -244,15 +258,18 @@ function initialise () {
}

initBindingPhraseGen()
index = await checkStatus(await fetch('firmware/index.json')).json()
let selected = true
for (const v in versions) {
Object.keys(index[mode]).sort(compareSemanticVersions).reverse().forEach((version, i) => {
const opt = document.createElement('option')
opt.value = versions[v]
opt.innerHTML = versions[v]
opt.selected = selected
versionSelect.appendChild(opt)
selected = false
}
if (version.indexOf('-RC') === -1 || showRCs) {
opt.value = index[mode][version]
opt.innerHTML = version
opt.selected = selected
versionSelect.appendChild(opt)
selected = false
}
})
versionSelect.onchange()
initFiledrag()
}
Expand Down Expand Up @@ -453,7 +470,7 @@ const getSettings = async (deviceType) => {
const config = selectedModel
const firmwareUrl = `firmware/${versionSelect.value}/${_('fcclbt').value}/${config.firmware}/firmware.bin`
const options = {
'flash-discriminator': Math.floor(Math.random()*((2**31)-2)+1)
'flash-discriminator': Math.floor(Math.random() * ((2 ** 31) - 2) + 1)
}

if (_('uid').value !== '') {
Expand Down
Loading