From 4b387b6e1f3dd85230a1c93edfd54ae407504a49 Mon Sep 17 00:00:00 2001 From: Shveta Sachdeva Date: Tue, 29 Oct 2024 12:10:35 -0700 Subject: [PATCH 1/2] Remove Drag n Drop dependency --- .env.example | 2 +- e2e/utilities/download.utils.ts | 34 ++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index e6cdc676..aedebf17 100644 --- a/.env.example +++ b/.env.example @@ -9,7 +9,7 @@ VSCODE_EXECUTABLE_PATH='/usr/share/code/code' VSIX_FILE_PATH='/home/sshveta/Work/kai-ci/' VSIX_FILE_NAME='konveyor-linux-0.0.1.vsix' -VSIX_DOWNLOAD_URL= 'https://github.com/konveyor/editor-extensions/releases/download/v0.0.1-dev%2B20241017/konveyor-linux-0.0.1.vsix' +VSIX_DOWNLOAD_URL= 'https://github.com/konveyor/editor-extensions/releases/download/v0.0.1-dev%2B20241022/konveyor-linux-0.0.1.vsix' PLUGIN_URL= 'https://github.com/konveyor/editor-extensions/releases/download/' PLUGIN_VERSION= 'v0.0.1-dev%2B' diff --git a/e2e/utilities/download.utils.ts b/e2e/utilities/download.utils.ts index 141faaae..8e3e5c55 100644 --- a/e2e/utilities/download.utils.ts +++ b/e2e/utilities/download.utils.ts @@ -11,15 +11,10 @@ import { getKAIPluginPath, getOSInfo, getKAIPluginName } from './utils'; export async function downloadFile(): Promise { const outputLocationPath = getKAIPluginPath(); const fileUrl = buildDownloadUrl(); + const defaultUrl = process.env.VSIX_DOWNLOAD_URL; const writer = fs.createWriteStream(outputLocationPath); - - const response = await axios({ - url: fileUrl, - method: 'GET', - responseType: 'stream', - }); - + const response = await fetchUrl(fileUrl, defaultUrl); response.data.pipe(writer); return new Promise((resolve, reject) => { @@ -28,6 +23,31 @@ export async function downloadFile(): Promise { }); } +async function fetchUrl(fileUrl, defaultUrl) { + try { + const response = await axios({ + url: fileUrl, + method: 'GET', + responseType: 'stream', + }); + return response; + } catch (error) { + // Check if the error is a 404 + if (error.response && error.response.status === 404) { + console.log('404 error, using default URL:', defaultUrl); + const response = await axios({ + url: defaultUrl, + method: 'GET', + responseType: 'stream', + }); + return response; + } else { + console.error('Error fetching URL:', error); + throw error; + } + } +} + export async function downloadLatestKAIPlugin() { try { await downloadFile(); From aea24b8a6a67d691f99eed95055dbfeeee1b17ab Mon Sep 17 00:00:00 2001 From: Shveta Sachdeva Date: Tue, 29 Oct 2024 15:51:24 -0700 Subject: [PATCH 2/2] README Signed-off-by: Shveta Sachdeva --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 70146b81..6f0a8d98 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,13 @@ Install the required packages using npm: Create .env file and copy the content of .env.example into it and provide appropriate values: VSCODE_EXECUTABLE_PATH='/usr/share/code/code' - VSIX_FILE_PATH='/home/sshveta/Downloads/kai-vscode-plugin-0.0.3.vsix' + + # Path to Save the vsix file + VSIX_FILE_PATH="/home/sshveta/Work/kai-ci/" + + # URL to download the vsix file, update this if the URL is different. + VSIX_DOWNLOAD_URL= 'https://github.com/konveyor/editor-extensions/releases/download/v0.0.1-dev%2B20241022/konveyor-linux-0.0.1.vsix' + ## Running Tests