Skip to content

Commit

Permalink
little windows modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
fax1ty committed Nov 12, 2024
1 parent a1bbdd1 commit 89446ad
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 40 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ jobs:
fail-fast: false
matrix:
include:
# - platform: "macos-latest" # for Arm based macs (M1 and above).
# args: "--target aarch64-apple-darwin"
# - platform: "macos-latest" # for Intel based macs.
# args: "--target x86_64-apple-darwin"
# - platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04.
- platform: "macos-latest" # for Arm based macs (M1 and above).
args: "--target aarch64-apple-darwin"
- platform: "macos-latest" # for Intel based macs.
args: "--target x86_64-apple-darwin"
# - platform: "ubuntu-22.04"
# args: ""
- platform: "windows-latest"
args: ""
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "emu",
"private": true,
"version": "0.1.0",
"version": "0.1.1",
"type": "module",
"scripts": {
"dev": "vite",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "emu"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
version = "0.1.1"
description = "Manage emulators with ease"
authors = ["fax1ty"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "emu",
"version": "0.1.0",
"version": "0.1.1",
"identifier": "emu.app",
"build": {
"beforeDevCommand": "bun run dev",
Expand Down
34 changes: 17 additions & 17 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ function App() {
await window.close();
};

if (!emulators) return null;

return (
<>
<nav
Expand Down Expand Up @@ -62,20 +60,22 @@ function App() {
</nav>

<main className="flex-1 px-4 pb-2 py-1">
<ul>
{Object.values(emulators).map((emulator, i) => (
<EmulatorListItem
key={i}
emulator={emulator}
onOptionsButtonPressed={(event) => {
setSelectedEmulator(emulator.name);
show({
event,
});
}}
/>
))}
</ul>
{emulators && (
<ul>
{Object.values(emulators).map((emulator, i) => (
<EmulatorListItem
key={i}
emulator={emulator}
onOptionsButtonPressed={(event) => {
setSelectedEmulator(emulator.name);
show({
event,
});
}}
/>
))}
</ul>
)}
</main>

<Menu
Expand All @@ -87,7 +87,7 @@ function App() {
<Item
disabled={
!selectedEmulator ||
emulators[selectedEmulator]?.state !== "offline"
emulators?.[selectedEmulator]?.state !== "offline"
}
onClick={async () => {
if (!selectedEmulator) return;
Expand Down
2 changes: 1 addition & 1 deletion src/services/api/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const getEmulatorProps = async (id: string) => {
};

export const getEmulatorFeatures = async (id: string) => {
const output = await adb("shell pm list features");
const output = await adb(`-s ${id} shell pm list features`);
return output.split("\n");
};

Expand Down
20 changes: 9 additions & 11 deletions src/services/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,32 @@ const getAndroidHomePrefix = () => {

switch (currentPlatfrom) {
case "windows":
return "%ANDROID_HOME";
return "%ANDROID_HOME%";

default:
return "$ANDROID_HOME";
}
};

const makeCommand = (executable: string, ...args: string[]) => {
const makeCommand = (executable: string, args: string) => {
const currentPlatfrom = platform();

switch (currentPlatfrom) {
case "windows":
return Command.create("cmd.exe", [
"/c",
executable + ".exe " + args.join(" "),
]);
const command = ["/c", `${executable}.exe ${args}`];
return Command.create("cmd.exe", command);

default:
return Command.create("sh", ["-c", executable + " " + args.join(" ")]);
return Command.create("sh", ["-c", `${executable} ${args}`]);
}
};

export const execute = async (
executable: string,
args: string[] = [],
args: string,
options?: SpawnOptions & { timeout?: number; verbose?: boolean }
) => {
const cmd = makeCommand(executable, ...args);
const cmd = makeCommand(executable, args);
cmd.stdout.on("data", (v) => {
if (options?.verbose) console.info(executable, args, v);
});
Expand All @@ -49,10 +47,10 @@ export const execute = async (

export const emulator = (command: string) => {
const prefix = getAndroidHomePrefix();
return execute(`${prefix}/emulator/emulator`, [command]);
return execute(`${prefix}/emulator/emulator`, command);
};

export const adb = (command: string) => {
const prefix = getAndroidHomePrefix();
return execute(`${prefix}/platform-tools/adb`, [command]);
return execute(`${prefix}/platform-tools/adb`, command);
};

0 comments on commit 89446ad

Please sign in to comment.