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

Major updates of libraries to go to a stable version of the software #36

Merged
merged 15 commits into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from 10 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
4 changes: 2 additions & 2 deletions .github/workflows/build-linux-appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: "20.10.0"

- name: Variables helpers
id: setup
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:

- name: Upload artifacts
uses: actions/upload-artifact@v3
#if: ${{ github.ref_name == 'main' }}
if: ${{ github.ref_name == 'main' }}
with:
name: ${{ runner.os }}-${{ steps.setup.outputs.app-name }}-AppImage
retention-days: 5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-mac-dmg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: "20.10.0"

- name: Variables helpers
id: setup
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build-windows-nsis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ jobs:
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 18
node-version: "20.10.0"

- name: Variables helpers
id: setup
shell: pwsh
run: |
$loc = Get-Location
$firmware_version = "v23.09.0"
$firmware_version = "v23.09.1"
$zipname = "krux-$firmware_version.zip"
$signame = "krux-$firmware_version.zip.sig"
$pemname = "selfcustody.pem"
$extraResources = "$loc\extraResources"
$opensslVersion = "3.1.3"
$opensslVersion = "3.2.0"
$release_url = "https://github.com/selfcustody/krux/releases/download"
$raw_url = "https://raw.githubusercontent.com/selfcustody/krux/main"
$app_version = node -e "console.log(require('./package.json').version)"
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
- name: Install chromedriver.exe
shell: pwsh
run: |
$url = "https://chromedriver.storage.googleapis.com/106.0.5249.61/chromedriver_win32.zip"
$url = "https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/120.0.6099.56/win32/chrome-win32.zip"
$tmp_path = ".\chromedriver_win32.zip"
$dest_path = "node_modules\chromedriver\bin"
Invoke-WebRequest -Uri $url -OutFile $tmp_path
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:

- name: Upload artifacts
uses: actions/upload-artifact@v3
#if: ${{ github.ref_name == 'main' }}
if: ${{ github.ref_name == 'main' }}
with:
name: ${{ runner.os}}-${{ steps.setup.outputs.app-name }}-Nsis
retention-days: 5
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- ".vscode"
- ".dockerignore"
- "Dockerfile"
#- ".gitignore"
- ".gitignore"
#- ".github/**"
#- "!.github/workflows/build.yml"

Expand All @@ -27,7 +27,7 @@ jobs:
secrets:
token: ${{ secrets.github_token }}

build-mac-dmg:
uses: ./.github/workflows/build-mac-dmg.yml
secrets:
token: ${{ secrets.github_token }}
#build-mac-dmg:
# uses: ./.github/workflows/build-mac-dmg.yml
# secrets:
# token: ${{ secrets.github_token }}
3 changes: 2 additions & 1 deletion .vscode/.e2e.env
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DEBUG=krux:*
DEBUG=krux:*
NODE_ENV=test
58 changes: 25 additions & 33 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,25 @@
## 2022-10-03

[v2.1.0](https://github.com/electron-vite/electron-vite-vue/pull/267)

- `vite-electron-plugin` is Fast, and WYSIWYG. 🌱
- last-commit: db2e830 v2.1.0: use `vite-electron-plugin` instead `vite-plugin-electron`

## 2022-06-04

[v2.0.0](https://github.com/electron-vite/electron-vite-vue/pull/156)

- 🖖 Based on the `vue-ts` template created by `npm create vite`, integrate `vite-plugin-electron`
- ⚡️ More simplify, is in line with Vite project structure
- last-commit: a15028a (HEAD -> main) feat: hoist `process.env`

## 2022-01-30

[v1.0.0](https://github.com/electron-vite/electron-vite-vue/releases/tag/v1.0.0)

- ⚡️ Main、Renderer、preload, all built with vite

## 2022-01-27
- Refactor the scripts part.
- Remove `configs` directory.

## 2021-11-11
- Refactor the project. Use vite.config.ts build `Main-process`, `Preload-script` and `Renderer-process` alternative rollup.
- Scenic `Vue>=3.2.13`, `@vue/compiler-sfc` is no longer necessary.
- If you prefer Rollup, Use rollup branch.

```bash
Error: @vitejs/plugin-vue requires vue (>=3.2.13) or @vue/compiler-sfc to be present in the dependency tree.
```
# 0.0.1

- Updated main dependencies:
- `electron`: 28.0.0;
- `vite-plugin-electron`: 0.15.5;
- `wdio-electron-service`: 6.0.2.

- Refactored `test/e2e/specs`:
- to suit `wdio-electron-service` major updates that break E2E tests;
- renamed extensions to `mts` to suit `vite-plugin-electron`;
- updated krux firmware version checks to `23.09.1`.

- Updated `openssl` for windows to `3.2.0`.

- Removed MacOS release since the current approach did not worked well
on MacOS;

**Disclaimer**:
> We will replace the development to python/kivy due to
two different situations: (1) Windows: needs a custom compilation of openssl
and `electron` use `boringssl`; with a python release, it's possible to use
krux python modules inside the application, so the krux team envisioned
better compatibility between linux, windows and mac without inject an `opeessl`
binary in windows; (2) some extended permissions in MacOS and/or the lack
of an Apple ID linked to the software on darwin system do not allow the flash feature.
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ For more information, see [flash the firmware onto the device](https://selfcusto

- MacOS

**Help Wanted**: we need mac users!

## Install

- See [releases page](https://github.com/selfcustody/krux-installer/releases);
Expand Down Expand Up @@ -102,6 +100,13 @@ if you want to show some debug messages:
DEBUG=krux:* yarn run dev
```

#### Debug development app with VSCode/VSCodium

If you're codding with VSCode/VSCodium, go to `Run and Debug`
tab and select `Debug App`:

![VScodium Debug](images/vscodium_debug.png)

### Test

#### Prepare tests
Expand Down Expand Up @@ -159,6 +164,22 @@ In linux/mac:
DEBUG=krux:* yarn run build --<os> <target>
```

##### Run tests

To run all tests in command line:

```bash
NODE_ENV=test yarn run e2e
```

#### Debug test in VSCode/VSCodium

If you're codding with VSCode/VSCodium, the `NODE_ENV`
variable is already configured. To run, tests, go to `Run and Debug`
tab and select `Test E2E App`:

![VScodium E2E test](images/vscodium.png)

##### Filter tests

Additionaly, you can filter some tests with
Expand All @@ -168,13 +189,13 @@ For example, if you want to exclude tests until `25th` test,
you can do this:

```bash
yarn run e2e --filter '0([0-1][0-9]|2[0-4]).*.spec.ts'
NODE_ENV=test yarn run e2e --filter '0([0-1][0-9]|2[0-4]).*.spec.mts'
```

if you want to debug some messages:

```bash
DEBUG=krux:* yarn run e2e --filter '0([0-1][0-9]|2[0-4]).*.spec.ts'
DEBUG=krux:* NODE_ENV=test yarn run e2e --filter '0([0-1][0-9]|2[0-4]).*.spec.mts'
```

#### WARNING: Builtin OpenSSL for windows in KruxInstaller
Expand Down
65 changes: 20 additions & 45 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,92 +20,67 @@ const kruxInstaller = new App(`KruxInstaller | v${version}`)
kruxInstaller.start(async ({ app, win, ipcMain}) => {
// Create storage
const storageBuilder = new Storage(app)
const store = await storageBuilder.build()
app.store = await storageBuilder.build()

// Reset configurations
store.set('device', 'Select device')
store.set('version', 'Select version')
store.set('versions', [])
app.store.set('device', 'Select device')
app.store.set('version', 'Select version')
app.store.set('versions', [])

// Create download resource handler
const changePage = new ChangePageHandler(win, store, ipcMain)
const changePage = new ChangePageHandler(win, app.store, ipcMain)
changePage.build()

// Create download resource handler
const downloadResource = new DownloadResourcesHandler(win, store, ipcMain)
const downloadResource = new DownloadResourcesHandler(win, app.store, ipcMain)
downloadResource.build()

// Create check resource handler
const checkResource = new CheckResourcesHandler(win, store, ipcMain)
const checkResource = new CheckResourcesHandler(win, app.store, ipcMain)
checkResource.build()

// Create unzip resource handler
const unzipResource = new UnzipResourceHandler(win, store, ipcMain)
const unzipResource = new UnzipResourceHandler(win, app.store, ipcMain)
unzipResource.build()

// Create fetcher for newest official release handler
const verifyOfficialReleasesFetch = new VerifyOfficialReleasesFetchHandler(win, store, ipcMain)
const verifyOfficialReleasesFetch = new VerifyOfficialReleasesFetchHandler(win, app.store, ipcMain)
verifyOfficialReleasesFetch.build()

// Create handler for official release sha256.txt
const verifyOfficialReleasesHash = new VerifyOfficialReleasesHashHandler(win, store, ipcMain)
const verifyOfficialReleasesHash = new VerifyOfficialReleasesHashHandler(win, app.store, ipcMain)
verifyOfficialReleasesHash.build()

// Create handler for official release .sig and .pem handler
const verifyOfficialReleasesSign = new VerifyOfficialReleasesSignHandler(win, store, ipcMain)
const verifyOfficialReleasesSign = new VerifyOfficialReleasesSignHandler(win, app.store, ipcMain)
verifyOfficialReleasesSign.build()

// Create handler for verify existence of openssl
const verifyOpenssl = new VerifyOpensslHandler(win, store, ipcMain)
const verifyOpenssl = new VerifyOpensslHandler(win, app.store, ipcMain)
verifyOpenssl.build()

// Create store setter handler
const storeSet = new StoreSetHandler(win, store, ipcMain)
const storeSet = new StoreSetHandler(win, app.store, ipcMain)
storeSet.build()

// Create store getter handler
const storeGet = new StoreGetHandler(win, store, ipcMain)
const storeGet = new StoreGetHandler(win, app.store, ipcMain)
storeGet.build()

// Create 'check if it will flash' handler
const checkIfItWillFlashHandler = new CheckIfItWillFlashHandler(win, store, ipcMain)
const checkIfItWillFlashHandler = new CheckIfItWillFlashHandler(win, app.store, ipcMain)
checkIfItWillFlashHandler.build()

// Create flash' handler
const flashHandler = new FlashHandler(win, store, ipcMain)
const flashHandler = new FlashHandler(win, app.store, ipcMain)
flashHandler.build()

// Create Wdio test handlers
// if environment variable WDIO_ELECTRON equals 'true'
if (process.env.TEST === 'true' && process.env.WDIO_ELECTRON === 'true') {
win.webContents.send('building ipcMain.handle for \'wdio-electron.app\'')
ipcMain.handle('wdio-electron.app', (_event, funcName, ...args) => {
const appProp = app[funcName];
if (typeof appProp === 'function') {
return appProp.apply(app, args);
}
return appProp;
});

win.webContents.send('building ipcMain.handle for \'wdio-electron\'')
ipcMain.handle('wdio-electron', (_events, ...args) => {
return {
appData: app.getPath('appData'),
documents: app.getPath('documents'),
store: {
appVersion: store.get('appVersion'),
resources: store.get('resources'),
os: store.get('os'),
versions: store.get('versions'),
version: store.get('version'),
device: store.get('device'),
sdcard: store.get('sdcard'),
showFlash: store.get('showFlash')
}
}
if (process.env.NODE_ENV === 'test') {
const _electron = await import('electron')
ipcMain.handle("wdio-electron.execute", (_, script, args) => {
return new Function(`return (${script}).apply(this, arguments)`)(_electron, ...args);
})
} else {
win.webContents.send("skip build ipcMain.handle for 'wdio-electron.app'")
win.webContents.send("skip build ipcMain.handle for 'wdio-electron'")
}
})
24 changes: 3 additions & 21 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,10 @@ ipcRenderer.on('main-process-message', (_event, args) => {
console.log(args)
})

if (process.env.TEST === 'true') {
const validChannels = [
'wdio-electron',
'wdio-electron.app'
];
const invoke = async (channel, ...data) => {
if (!validChannels.includes(channel)) {
throw new Error(`Channel "${channel}" is invalid`);
}
if (!process.env.WDIO_ELECTRON) {
throw new Error('Electron APIs can not be invoked outside of WDIO');
}
return ipcRenderer.invoke(channel, ...data);
};
if (process.env.NODE_ENV === 'test') {
contextBridge.exposeInMainWorld('wdioElectron', {
app: {
invoke: (funcName, ...args) => invoke('wdio-electron.app', funcName, ...args),
},
custom: {
invoke: (...args) => invoke('wdio-electron', ...args),
}
});
execute: (script, args) => ipcRenderer.invoke("wdio-electron.execute", script, args)
})
}

contextBridge.exposeInMainWorld('api', {
Expand Down
Binary file added images/vscodium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/vscodium_debug.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion lib/check-resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export default class CheckResourcesHandler extends Handler {
build () {
super.build(async (options) => {
try {
console.log(options)
const resources = this.storage.get('resources') as string
const destinationResource = join(resources, options.resource)

Expand Down
1 change: 0 additions & 1 deletion lib/download-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export default class DownloadResourcesHandler extends Handler {
this.log(options)

const destinationResource = dirname(resourceTo)
console.log(destinationResource)

try {
// First check if destination resource exists
Expand Down
Loading