Skip to content

Commit

Permalink
Merge pull request #49 from qlrd/main
Browse files Browse the repository at this point in the history
added yahboom and cube to devices list
  • Loading branch information
qlrd authored Mar 12, 2024
2 parents 04bd7c8 + 4a53e68 commit d273429
Show file tree
Hide file tree
Showing 44 changed files with 178 additions and 208 deletions.
4 changes: 2 additions & 2 deletions lib/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ export default class App extends Base {

this.log('Creating Browser Window')
this.win = new BrowserWindow({
width: 840,
height: 640,
width: 880,
height: 880,
title: this.title,
icon: icon,
show: false,
Expand Down
2 changes: 1 addition & 1 deletion lib/change-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ export default class ChangePageHandler extends Handler {
}
})
}
}
}
33 changes: 18 additions & 15 deletions lib/check-if-it-will-flash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,25 @@ export default class CheckIfItWillFlashHandler extends Handler {
const os = this.storage.get('os') as string
const isMac10 = this.storage.get('isMac10') as boolean

if (device.match(/maixpy_(m5stickv|amigo_ips|amigo_tft|bit|dock)/g)) {
if (device.match(/maixpy_(m5stickv|amigo|amigo_ips|amigo_tft|bit|dock|yahboom|cube)/g)) {
if (version.match(/selfcustody\/.*/g)) {
const __version__ = version.split('tag/')[1]
const destinationResourceZip = join(resources, __version__, `krux-${__version__}.zip`)
const destinationResourceSha = join(resources, __version__, `krux-${__version__}.zip.sha256.txt`)
const destinationResourceSig = join(resources, __version__, `krux-${__version__}.zip.sig`)

if (
await existsAsync(destinationResourceZip) &&
await existsAsync(destinationResourceSha) &&
await existsAsync(destinationResourceSig)
) {
this.send(`${this.name}:success`, { showFlash: true })
} else {

if (device === 'maixpy_cube') {
this.send(`${this.name}:success`, { showFlash: false })
} else {
const __version__ = version.split('tag/')[1]
const destinationResourceZip = join(resources, __version__, `krux-${__version__}.zip`)
const destinationResourceSha = join(resources, __version__, `krux-${__version__}.zip.sha256.txt`)
const destinationResourceSig = join(resources, __version__, `krux-${__version__}.zip.sig`)

if (
await existsAsync(destinationResourceZip) &&
await existsAsync(destinationResourceSha) &&
await existsAsync(destinationResourceSig)
) {
this.send(`${this.name}:success`, { showFlash: true })
} else {
this.send(`${this.name}:success`, { showFlash: false })
}
}
} else if (version.match(/odudex\/krux_binaries/g)) {
const destinationResourceFirmware = join(resources, version, 'main', device, 'firmware.bin')
Expand Down Expand Up @@ -89,4 +92,4 @@ export default class CheckIfItWillFlashHandler extends Handler {
}
})
}
}
}
27 changes: 27 additions & 0 deletions lib/flash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { join } from 'path'
import { SudoerLinux, SudoerDarwin } from '@o/electron-sudo/src/sudoer'
import ElectronStore from 'electron-store'
import Handler from './handler'
import { SerialPort } from 'serialport'

export default class FlashHandler extends Handler {

Expand Down Expand Up @@ -70,6 +71,32 @@ export default class FlashHandler extends Handler {
// SEE https://github.com/odudex/krux_binaries#flash-instructions
if (device.match(/maixpy_dock/g)) {
flash.args = ['--verbose', '-B', 'dan', '-b', '1500000', kboot]
} else if (device.match(/maixpy_yahboom/g)){
flash.args = ['--verbose', '-B', 'goE', '-b', '1500000', kboot]
try {
const ports = await SerialPort.list()
ports.forEach(function(port) {
if (port.productId == "7523") {
flash.args.push("-p")
flash.args.push(port.path)
}
})
} catch (error) {
this.send(`${this.name}:error`, { done: false, name: error.name, message: error.message, stack: error.stack })
}
} else if (device.match(/maixpy_cube/g)) {
flash.args = ['--verbose', '-B', 'goE', '-b', '1500000', kboot]
try {
const ports = await SerialPort.list()
ports.forEach(function(port) {
if (port.productId == "0403") {
flash.args.push("-p")
flash.args.push(port.path)
}
})
} catch (error) {
this.send(`${this.name}:error`, { done: false, name: error.name, message: error.message, stack: error.stack })
}
} else {
flash.args = ['--verbose', '-B', 'goE', '-b', '1500000', kboot]
}
Expand Down
11 changes: 11 additions & 0 deletions lib/unzip-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ export default class UnzipResourceHandler extends Handler {
const isMac10 = this.storage.get('isMac10') as boolean;
version = version.split('tag/')[1];
const zipFilePath = join(resources, version, `krux-${version}.zip`)

if (version.match(/24\.\d+\.\d+/)) {
if (device.match(/maixpy_amigo_(tft|ips)/g)) {
const error = new Error(`Device '${device}' not used anymore in version ${version}. Use 'maixpy_amigo' instead`)
this.send(`${this.name}:error`, { name: error.name, message: error.message, stack: error.stack})
}
if (device.match(/maixpy_cube/g)) {
const error = new Error(`Device '${device}' not implemented for version '${version}'`)
this.send(`${this.name}:error`, { name: error.name, message: error.message, stack: error.stack})
}
}

this.send(`${this.name}:data`, `Extracting ${zipFilePath}<br/><br/>`)

Expand Down
7 changes: 4 additions & 3 deletions lib/verify-official-releases-hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export default class VerifyOfficialReleasesHashHandler extends Handler {
try {
const exists = await existsAsync(p)
const sha256buffer = await readFileAsync(shaFilePath, null)
const sha256txt = sha256buffer.toString()
const sha256txt = sha256buffer.toString().split(" ")[0]

if (exists && sha256txt !== '') {
result.push({
name: shaFileRelPath,
Expand All @@ -75,7 +76,7 @@ export default class VerifyOfficialReleasesHashHandler extends Handler {
name: zipFileRelPath,
value: hashSum.digest('hex')
})

const isMatch = result[0].value === result[1].value

if (isMatch) {
Expand Down Expand Up @@ -106,4 +107,4 @@ export default class VerifyOfficialReleasesHashHandler extends Handler {
const interval = setInterval(verify, 1000, shaFilePath)
})
}
}
}
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "krux-installer",
"version": "0.0.11",
"version": "0.0.12",
"main": "dist-electron/main/index.js",
"description": "Graphical User Interface to download, verify and flash Krux´s firmware on Kendryte K210 hardwares as bitcoin signature devices",
"author": "qlrd <[email protected]>",
Expand Down Expand Up @@ -73,7 +73,7 @@
"vite-plugin-electron-renderer": "^0.14.1",
"vite-plugin-html": "^3.2.0",
"vue": "^3.3.13",
"vue-tsc": "^1.8.26",
"vue-tsc": "^2.0.6",
"wdio-electron-service": "^6.0.2"
},
"dependencies": {
Expand All @@ -83,9 +83,10 @@
"command-exists": "^1.2.9",
"debug": "^4.3.4",
"electron-store": "^8.1.0",
"serialport": "^12.0.0",
"vite-plugin-vuetify": "^2.0.1",
"vue-asciimorph": "^0.0.3",
"vuetify": "^3.4.8",
"yauzl": "^2.10.0"
"yauzl": "^3.1.2"
}
}
7 changes: 4 additions & 3 deletions src/pages/SelectDevice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,11 @@ import { Ref, ref } from 'vue'
const devices: Ref<string[]> = ref([
'maixpy_m5stickv',
'maixpy_amigo_ips',
'maixpy_amigo_tft',
'maixpy_amigo',
'maixpy_bit',
'maixpy_dock'
'maixpy_dock',
'maixpy_yahboom',
'maixpy_cube'
])
async function selectDevice (device: string) {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SelectVersion.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ function transformVersion (version: string): string {
return version.replace(/[\/\_\.]/g, '-')
}
</script>
</script>
54 changes: 21 additions & 33 deletions test/e2e/pageobjects/app.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ class App {

private __select_device_page__: string;
private __select_device_page_maixpy_m5stickv_button__: string;
private __select_device_page_maixpy_amigo_ips_button__: string;
private __select_device_page_maixpy_amigo_tft_button__: string;
private __select_device_page_maixpy_amigo_button__: string;
private __select_device_page_maixpy_bit_button__: string;
private __select_device_page_maixpy_dock_button__: string;
private __select_device_page_maixpy_back_button__: string;
private __select_device_page_maixpy_m5stickv_text__: string;
private __select_device_page_maixpy_amigo_ips_text__: string;
private __select_device_page_maixpy_amigo_tft_text__: string;
private __select_device_page_maixpy_amigo_text__: string;
private __select_device_page_maixpy_bit_text__: string;
private __select_device_page_maixpy_dock_text__: string;
private __select_device_page_maixpy_back_text__: string;
Expand Down Expand Up @@ -135,23 +133,21 @@ class App {

this.__select_device_page__ = 'div#select-device-page';
this.__select_device_page_maixpy_m5stickv_button__ = 'div#select-device-page-maixpy_m5stickv-button'
this.__select_device_page_maixpy_amigo_ips_button__ = 'div#select-device-page-maixpy_amigo_ips-button'
this.__select_device_page_maixpy_amigo_tft_button__ = 'div#select-device-page-maixpy_amigo_tft-button'
this.__select_device_page_maixpy_amigo_button__ = 'div#select-device-page-maixpy_amigo-button'
this.__select_device_page_maixpy_bit_button__ = 'div#select-device-page-maixpy_bit-button'
this.__select_device_page_maixpy_dock_button__ = 'div#select-device-page-maixpy_dock-button'
this.__select_device_page_maixpy_back_button__ = 'div#select-device-page-back-button'
this.__select_device_page_maixpy_m5stickv_text__ = 'div#select-device-page-maixpy_m5stickv-text'
this.__select_device_page_maixpy_amigo_ips_text__ = 'div#select-device-page-maixpy_amigo_ips-text'
this.__select_device_page_maixpy_amigo_tft_text__ = 'div#select-device-page-maixpy_amigo_tft-text'
this.__select_device_page_maixpy_amigo_text__ = 'div#select-device-page-maixpy_amigo-text'
this.__select_device_page_maixpy_bit_text__ = 'div#select-device-page-maixpy_bit-text'
this.__select_device_page_maixpy_dock_text__ = 'div#select-device-page-maixpy_dock-text'
this.__select_device_page_maixpy_back_text__ = 'div#select-device-page-back-text'

this.__select_version_page__ = 'div#select-version-page';
this.__select_version_page_selfcustody_button__ = 'div#select-version-page-selfcustody-krux-releases-tag-v23-09-1-button'
this.__select_version_page_selfcustody_button__ = 'div#select-version-page-selfcustody-krux-releases-tag-v24-03-0-button'
this.__select_version_page_back_button__ = 'div#select-version-page-back-button'
this.__select_version_page_odudex_button__ = 'div#select-version-page-odudex-krux-binaries-button'
this.__select_version_page_selfcustody_text__ = 'div#select-version-page-selfcustody-krux-releases-tag-v23-09-1-text'
this.__select_version_page_selfcustody_text__ = 'div#select-version-page-selfcustody-krux-releases-tag-v24-03-0-text'
this.__select_version_page_odudex_text__ = 'div#select-version-page-odudex-krux-binaries-text'
this.__select_version_page_back_text__ = 'div#select-version-page-back-text'

Expand All @@ -162,22 +158,22 @@ class App {
this.__download_official_release_zip_subtitle__ = 'div#download-official-release-zip-page-subtitle'
this.__download_official_release_zip_progress__ = 'div#download-official-release-zip-page-progress'

this.__checking_release_zip_msg__ = 'pre#checking-v23-09-1-krux-v23-09-1-zip'
this.__not_found_release_zip_msg__ = 'pre#v23-09-1-krux-v23-09-1-zip-not-found'
this.__found_release_zip_msg__ = 'pre#v23-09-1-krux-v23-09-1-zip-found'
this.__checking_release_zip_msg__ = 'pre#checking-v24-03-0-krux-v24-03-0-zip'
this.__not_found_release_zip_msg__ = 'pre#v24-03-0-krux-v24-03-0-zip-not-found'
this.__found_release_zip_msg__ = 'pre#v24-03-0-krux-v24-03-0-zip-found'

this.__checking_release_zip_sha256_txt_msg__ = 'pre#checking-v23-09-1-krux-v23-09-1-zip-sha256-txt'
this.__not_found_release_zip_sha256_txt_msg__ = 'pre#v23-09-1-krux-v23-09-1-zip-sha256-txt-not-found'
this.__found_release_zip_sha256_txt_msg__ = 'pre#v23-09-1-krux-v23-09-1-zip-sha256-txt-found'
this.__checking_release_zip_sha256_txt_msg__ = 'pre#checking-v24-03-0-krux-v24-03-0-zip-sha256-txt'
this.__not_found_release_zip_sha256_txt_msg__ = 'pre#v24-03-0-krux-v24-03-0-zip-sha256-txt-not-found'
this.__found_release_zip_sha256_txt_msg__ = 'pre#v24-03-0-krux-v24-03-0-zip-sha256-txt-found'

this.__download_official_release_zip_sha256_txt_page__ = 'div#download-official-release-zip-sha256-txt-page'
this.__download_official_release_zip_sha256_txt_page_title__ = 'div#download-official-release-zip-sha256-txt-page-title'
this.__download_official_release_zip_sha256_txt_page_subtitle__ = 'div#download-official-release-zip-sha256-txt-page-subtitle'
this.__download_official_release_zip_sha256_txt_page_progress__ = 'div#download-official-release-zip-sha256-txt-page-progress'

this.__checking_release_zip_sig_msg__ = 'pre#checking-v23-09-1-krux-v23-09-1-zip-sig'
this.__not_found_release_zip_sig_msg__ = 'pre#v23-09-1-krux-v23-09-1-zip-sig-not-found'
this.__found_release_zip_sig_msg__ = 'pre#v23-09-1-krux-v23-09-1-zip-sig-found'
this.__checking_release_zip_sig_msg__ = 'pre#checking-v24-03-0-krux-v24-03-0-zip-sig'
this.__not_found_release_zip_sig_msg__ = 'pre#v24-03-0-krux-v24-03-0-zip-sig-not-found'
this.__found_release_zip_sig_msg__ = 'pre#v24-03-0-krux-v24-03-0-zip-sig-found'

this.__download_official_release_zip_sig_page__ = 'div#download-official-release-zip-sig-page'
this.__download_official_release_zip_sig_title__ = 'div#download-official-release-zip-sig-page-title'
Expand Down Expand Up @@ -216,8 +212,8 @@ class App {

this.__verified_official_release_page__ = 'div#verified-official-release-page'
this.__verified_official_release_page_sha256_integrity_title__ = 'div#verified-official-release-page-sha256-integrity-title'
this.__verified_official_release_page_sha256_integrity_txt__ = 'div#verified-official-release-page-sha256-integrity-v23-09-1-krux-v23-09-1-zip-sha256-txt'
this.__verified_official_release_page_sha256_integrity__ = 'div#verified-official-release-page-sha256-integrity-v23-09-1-krux-v23-09-1-zip'
this.__verified_official_release_page_sha256_integrity_txt__ = 'div#verified-official-release-page-sha256-integrity-v24-03-0-krux-v24-03-0-zip-sha256-txt'
this.__verified_official_release_page_sha256_integrity__ = 'div#verified-official-release-page-sha256-integrity-v24-03-0-krux-v24-03-0-zip'
this.__verified_official_release_page_signature_title__ = 'div#verified-official-release-page-signature-title'
this.__verified_official_release_page_signature_command__ = 'span#verified-official-release-page-signature-command'
this.__verified_official_release_page_signature_result__ = 'span#verified-official-release-page-signature-result'
Expand Down Expand Up @@ -300,12 +296,8 @@ class App {
return $(this.__select_device_page_maixpy_m5stickv_button__)
}

get selectMaixpyAmigoIpsButton () {
return $(this.__select_device_page_maixpy_amigo_ips_button__)
}

get selectMaixpyAmigoTftButton () {
return $(this.__select_device_page_maixpy_amigo_tft_button__)
get selectMaixpyAmigoButton () {
return $(this.__select_device_page_maixpy_amigo_button__)
}

get selectMaixpyBitButton () {
Expand All @@ -324,12 +316,8 @@ class App {
return $(this.__select_device_page_maixpy_m5stickv_text__)
}

get selectMaixpyAmigoIpsText () {
return $(this.__select_device_page_maixpy_amigo_ips_text__)
}

get selectMaixpyAmigoTftText () {
return $(this.__select_device_page_maixpy_amigo_tft_text__)
get selectMaixpyAmigoText () {
return $(this.__select_device_page_maixpy_amigo_text__)
}

get selectMaixpyBitText () {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/specs/002.app-startup.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('KruxInstaller start up', () => {
const version = await browser.electron.execute(function (electron) {
return electron.app.getVersion()
})
expect(version).to.be.equal('0.0.11')
expect(version).to.be.equal('0.0.12')
})

})
22 changes: 6 additions & 16 deletions test/e2e/specs/006.select-device-show-only.spec.mts
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,14 @@ describe('KruxInstaller SelectDevice page (show only)', () => {
await expect(instance.selectMaixpyM5StickVText).toHaveText('maixpy_m5stickv')
})

it('should \'maixpy_amigo_ips\' button be displayed', async () => {
await instance.selectMaixpyAmigoIpsButton.waitForExist()
await expect(instance.selectMaixpyAmigoIpsButton).toBeDisplayed()
it('should \'maixpy_amigo\' button be displayed', async () => {
await instance.selectMaixpyAmigoButton.waitForExist()
await expect(instance.selectMaixpyAmigoButton).toBeDisplayed()
})

it('should \'maixpy_amigo_ips\' button have \'maixpy_amigo_ips\' text', async () => {
await instance.selectMaixpyAmigoIpsText.waitForExist()
await expect(instance.selectMaixpyAmigoIpsText).toHaveText('maixpy_amigo_ips')
})

it('should \'maixpy_amigo_tft\' button be displayed', async () => {
await instance.selectMaixpyAmigoTftButton.waitForExist()
await expect(instance.selectMaixpyAmigoTftButton).toBeDisplayed()
})

it('should \'maixpy_amigo_tft\' button have \'maixpy_amigo_tft\' text', async () => {
await instance.selectMaixpyAmigoTftText.waitForExist()
await expect(instance.selectMaixpyAmigoTftText).toHaveText('maixpy_amigo_tft')
it('should \'maixpy_amigo\' button have \'maixpy_amigo\' text', async () => {
await instance.selectMaixpyAmigoText.waitForExist()
await expect(instance.selectMaixpyAmigoText).toHaveText('maixpy_amigo')
})

it('should \'maixpy_bit\' button be displayed', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createRequire } from 'module'

const App = createRequire(import.meta.url)('../pageobjects/app.page')

describe('KruxInstaller SelectDevice page selects \'maixpy_amigo_ips\' device', () => {
describe('KruxInstaller SelectDevice page selects \'maixpy_amigo\' device', () => {

let instance: any;

Expand Down Expand Up @@ -32,8 +32,8 @@ describe('KruxInstaller SelectDevice page selects \'maixpy_amigo_ips\' device',
await instance.mainSelectDeviceButton.click()
await instance.mainPage.waitForExist({ reverse: true })
await instance.selectDevicePage.waitForExist()
await instance.selectMaixpyAmigoIpsButton.waitForExist()
await instance.selectMaixpyAmigoIpsButton.click()
await instance.selectMaixpyAmigoButton.waitForExist()
await instance.selectMaixpyAmigoButton.click()
})

it('should change to Main page', async () => {
Expand All @@ -43,8 +43,8 @@ describe('KruxInstaller SelectDevice page selects \'maixpy_amigo_ips\' device',
await expect(instance.mainPage).toBeDisplayed()
})

it('should \'Select device\' button changed its text to \'Device: maixpy_amigo_ips\'', async () => {
await expect(instance.mainSelectDeviceText).toHaveText('Device: maixpy_amigo_ips')
it('should \'Select device\' button changed its text to \'Device: maixpy_amigo\'', async () => {
await expect(instance.mainSelectDeviceText).toHaveText('Device: maixpy_amigo')
})

})
Loading

0 comments on commit d273429

Please sign in to comment.