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

switched version source from js file to json #37

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"dependencies": {
"@tauri-apps/api": "^1.5.3",
"ansi_up": "^5.2.1",
"jsonrepair": "^3.7.1",
"vue": "^3.3.4",
"vue-router": "^4.2.4"
},
Expand Down
9 changes: 3 additions & 6 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const GITHUB_REPOSITORY: &str = "espressif/esp-idf";

#[tauri::command]
async fn get_available_idf_versions() -> Result<String, String> {
let url = "https://dl.espressif.com/dl/esp-idf/idf_versions.js".to_string();
let url = "https://dl.espressif.com/dl/esp-idf/idf_versions.json".to_string();
let client = reqwest::Client::builder()
.user_agent("esp-workbench")
.build()
Expand All @@ -196,14 +196,11 @@ async fn get_available_idf_versions() -> Result<String, String> {
.send()
.await
.map_err(|err| format!("Failed to make request: {}", err))?;
let js_versions_file = response
let json_versions_file = response
.text()
.await
.map_err(|err| format!("Failed to read response: {}", err))?;
// Find the start and end index of the object within the JavaScript file
let object_start = js_versions_file.find("{").ok_or("Object start not found")?;
let object_end = js_versions_file.rfind("}").ok_or("Object end not found")? + 1;
Ok(js_versions_file[object_start..object_end].to_string())
Ok(json_versions_file)
}

// Comand to get the current user home
Expand Down
3 changes: 1 addition & 2 deletions src/components/VersionSelector.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
import { onMounted, ref, computed } from "vue";
import { invoke } from "@tauri-apps/api/tauri";
import { jsonrepair } from 'jsonrepair';

const props = defineProps({
selectedVersion: String,
Expand Down Expand Up @@ -67,7 +66,7 @@ const targetsOfSelectedVersion = computed(() => {
onMounted(() => {
invoke("get_available_idf_versions").then((response) => {
try {
let data = JSON.parse(jsonrepair(response as string));
let data = JSON.parse(response as string);
versionsData.value = data;
} catch (error) {
console.error(error);
Expand Down