From 33182b66c52ec4478d5a9255756784052e51d927 Mon Sep 17 00:00:00 2001 From: Ankan Saha Date: Tue, 24 Feb 2026 00:49:41 +0530 Subject: [PATCH 1/3] feat: Implement auto-update functionality and update project version to 9.1.0. --- Documentation/package.json | 2 +- Extension/package.json | 2 +- VERSION | 2 +- main.go | 14 +++++-- src/Update/Updater.go | 77 ++++++++++++++++++++++++++++++++++++++ src/repl/repl.go | 2 +- 6 files changed, 92 insertions(+), 7 deletions(-) create mode 100644 src/Update/Updater.go diff --git a/Documentation/package.json b/Documentation/package.json index 6b077d2..01497f4 100644 --- a/Documentation/package.json +++ b/Documentation/package.json @@ -1,6 +1,6 @@ { "name": "documentation", - "version": "9.0.1", + "version": "9.1.0", "private": true, "scripts": { "dev": "next dev --turbopack", diff --git a/Extension/package.json b/Extension/package.json index 7b2a8d6..21e7c11 100644 --- a/Extension/package.json +++ b/Extension/package.json @@ -2,7 +2,7 @@ "name": "banglacode", "displayName": "BanglaCode", "description": "Language support for BanglaCode (.bang, .bangla, .bong) - Bengali Programming Language created by Ankan from West Bengal, India", - "version": "9.0.1", + "version": "9.1.0", "publisher": "AnkanSaha", "author": { "name": "AnkanSaha" diff --git a/VERSION b/VERSION index 37ad5c8..47da986 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -9.0.1 +9.1.0 diff --git a/main.go b/main.go index 679adf2..4a0fcbc 100644 --- a/main.go +++ b/main.go @@ -6,6 +6,7 @@ import ( "os/user" "path/filepath" + "BanglaCode/src/Update" "BanglaCode/src/evaluator" "BanglaCode/src/evaluator/builtins" "BanglaCode/src/lexer" @@ -27,7 +28,12 @@ func main() { return } - // Check for flags + // Check for commands and flags + if len(os.Args) == 2 && update.CheckUpdateCommand(os.Args[1:], "update") { + update.Updater() + return + } + if os.Args[1] == "--help" || os.Args[1] == "-h" { printHelp() return @@ -55,6 +61,7 @@ func printHelp() { fmt.Println("\033[1;33m▸ Usage:\033[0m") fmt.Println(" \033[1;32mbanglacode\033[0m Start interactive REPL") fmt.Println(" \033[1;32mbanglacode \033[0m Execute a BanglaCode file") + fmt.Println(" \033[1;32mbanglacode update\033[0m Update to the latest version") fmt.Println(" \033[1;32mbanglacode --help, -h\033[0m Show this help message") fmt.Println(" \033[1;32mbanglacode --version, -v\033[0m Show version information") fmt.Println("") @@ -66,6 +73,7 @@ func printHelp() { fmt.Println(" \033[0;34m$\033[0m banglacode hello.bang \033[2m# Run hello.bang file\033[0m") fmt.Println(" \033[0;34m$\033[0m banglacode app.bangla \033[2m# Run app.bangla file\033[0m") fmt.Println(" \033[0;34m$\033[0m banglacode server.bong \033[2m# Run server.bong file\033[0m") + fmt.Println(" \033[0;34m$\033[0m banglacode update \033[2m# Update to latest version\033[0m") fmt.Println("") fmt.Println("\033[1;36m╚══════════════════════════════════════════════════════════════════╝\033[0m") fmt.Println(" 📄 For more information, see \033[1;35mSYNTAX.md\033[0m") @@ -74,10 +82,10 @@ func printHelp() { func printVersion() { fmt.Println("\033[1;36m╔════════════════════════════════════════════════════════╗") - fmt.Println("║ BanglaCode v9.0.1 ║") + fmt.Println("║ BanglaCode v9.1.0 ║") fmt.Println("║ A Programming Language in Bengali (Banglish) ║") fmt.Println("╠════════════════════════════════════════════════════════╣\033[0m") - fmt.Println("\033[1;36m║\033[0m 📦 \033[1mVersion:\033[0m \033[1;32m9.0.1\033[0m \033[1;36m║\033[0m") + fmt.Println("\033[1;36m║\033[0m 📦 \033[1mVersion:\033[0m \033[1;32m9.1.0\033[0m \033[1;36m║\033[0m") fmt.Println("\033[1;36m║\033[0m 👨‍💻 \033[1mAuthor:\033[0m \033[1;35mAnkan Saha\033[0m \033[1;36m║\033[0m") fmt.Println("\033[1;36m║\033[0m 🌍 \033[1mFrom:\033[0m \033[1;37mWest Bengal, India\033[0m \033[1;36m║\033[0m") fmt.Println("\033[1;36m║\033[0m 🔗 \033[1mGitHub:\033[0m \033[1;34mhttps://github.com/nexoral/BanglaCode\033[0m \033[1;36m║\033[0m") diff --git a/src/Update/Updater.go b/src/Update/Updater.go new file mode 100644 index 0000000..c08c6c0 --- /dev/null +++ b/src/Update/Updater.go @@ -0,0 +1,77 @@ +package update + +import ( + "fmt" + "os" + "os/exec" + "runtime" + "strings" +) + +// Update commands for each operating system +var updateCommands = map[string]updateCommand{ + "linux": { + shell: "bash", + shellArg: "-c", + script: "curl -fsSL https://raw.githubusercontent.com/nexoral/BanglaCode/main/Scripts/install.sh | bash", + }, + "darwin": { + shell: "bash", + shellArg: "-c", + script: "curl -fsSL https://raw.githubusercontent.com/nexoral/BanglaCode/main/Scripts/install.sh | bash", + }, + "windows": { + shell: "powershell", + shellArg: "-Command", + script: "irm https://raw.githubusercontent.com/nexoral/BanglaCode/main/Scripts/install.ps1 | iex", + }, +} + +type updateCommand struct { + shell string + shellArg string + script string +} + +// Update checks if the update command was passed and executes the appropriate update script +func Updater() { + fmt.Println("\033[1;36m╔════════════════════════════════════════════════════════╗") + fmt.Println("║ Updating BanglaCode... ║") + fmt.Println("╚════════════════════════════════════════════════════════╝\033[0m") + fmt.Println() + + // Detect operating system + currentOS := runtime.GOOS + cmd, exists := updateCommands[currentOS] + + if !exists { + fmt.Fprintf(os.Stderr, "\033[31mError: Unsupported operating system '%s'\033[0m\n", currentOS) + fmt.Fprintf(os.Stderr, "Supported systems: Linux, macOS (darwin), Windows\n") + os.Exit(1) + } + + fmt.Printf("Detected OS: \033[1;32m%s\033[0m\n", currentOS) + fmt.Printf("Running update command...\n\n") + + // Execute the appropriate update command + command := exec.Command(cmd.shell, cmd.shellArg, cmd.script) + command.Stdout = os.Stdout + command.Stderr = os.Stderr + + if err := command.Run(); err != nil { + fmt.Fprintf(os.Stderr, "\n\033[31mError: Update failed: %v\033[0m\n", err) + os.Exit(1) + } + + fmt.Println("\n\033[1;32m✓ Update completed successfully!\033[0m") +} + +// checkUpdateCommand checks if the "update" argument is present in the command-line args +func CheckUpdateCommand(args []string, target string) bool { + for _, arg := range args { + if strings.ToLower(arg) == target { + return true + } + } + return false +} diff --git a/src/repl/repl.go b/src/repl/repl.go index cd8de47..80ced73 100644 --- a/src/repl/repl.go +++ b/src/repl/repl.go @@ -12,7 +12,7 @@ import ( "strings" ) -const Version = "9.0.1" +const Version = "9.1.0" const PROMPT = "\033[1;33m>> \033[0m" From 8398a4304e345e20194fecc32783ae9f964e134c Mon Sep 17 00:00:00 2001 From: Ankan Saha Date: Tue, 24 Feb 2026 01:01:44 +0530 Subject: [PATCH 2/3] feat: Add checksum verification to install scripts for downloaded binaries. --- Scripts/install.ps1 | 38 ++++++++++++++++++++++++++++++++++++++ Scripts/install.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/Scripts/install.ps1 b/Scripts/install.ps1 index 1408496..9deb619 100644 --- a/Scripts/install.ps1 +++ b/Scripts/install.ps1 @@ -234,7 +234,9 @@ Write-ColorOutput "[+] Latest Version: v$VERSION" "Green" # Prepare download $DOWNLOAD_FILE = "banglacode-windows-$ARCH.zip" $DOWNLOAD_URL = "https://github.com/$REPO/releases/download/v$VERSION/$DOWNLOAD_FILE" +$CHECKSUM_URL = "https://github.com/$REPO/releases/download/v$VERSION/checksums.txt" $TMP_FILE = Join-Path $env:TEMP $DOWNLOAD_FILE +$CHECKSUM_FILE = Join-Path $env:TEMP "checksums.txt" Write-ColorOutput "[*] Downloading $DOWNLOAD_FILE..." "White" @@ -249,6 +251,42 @@ if (-not (Download-File -Url $DOWNLOAD_URL -Destination $TMP_FILE)) { Write-ColorOutput "[+] Download complete" "Green" +# Download checksums +Write-ColorOutput "[*] Verifying checksum..." "White" +if (-not (Download-File -Url $CHECKSUM_URL -Destination $CHECKSUM_FILE)) { + Write-ColorOutput "[X] Failed to download checksums" "Red" + Remove-Item $TMP_FILE -Force -ErrorAction SilentlyContinue + exit 1 +} + +# Parse expected checksum +$checksumContent = Get-Content $CHECKSUM_FILE +$expectedChecksum = ($checksumContent | Select-String -Pattern "$DOWNLOAD_FILE").Line -split '\s+' | Select-Object -First 1 + +if (-not $expectedChecksum) { + Write-ColorOutput "[X] Checksum not found for $DOWNLOAD_FILE" "Red" + Remove-Item $TMP_FILE, $CHECKSUM_FILE -Force -ErrorAction SilentlyContinue + exit 1 +} + +# Calculate actual checksum +$actualChecksum = (Get-FileHash -Path $TMP_FILE -Algorithm SHA256).Hash.ToLower() +$expectedChecksum = $expectedChecksum.ToLower() + +if ($actualChecksum -ne $expectedChecksum) { + Write-ColorOutput "[X] Checksum verification failed!" "Red" + Write-ColorOutput " Expected: $expectedChecksum" "Red" + Write-ColorOutput " Got: $actualChecksum" "Red" + Write-ColorOutput " This may indicate a compromised download." "Red" + Remove-Item $TMP_FILE, $CHECKSUM_FILE -Force -ErrorAction SilentlyContinue + exit 1 +} + +Write-ColorOutput "[+] Checksum verified" "Green" + +# Cleanup checksum file +Remove-Item $CHECKSUM_FILE -Force -ErrorAction SilentlyContinue + # Create install directory Write-ColorOutput "[*] Installing to $INSTALL_DIR..." "White" diff --git a/Scripts/install.sh b/Scripts/install.sh index 2d7b634..bd1363e 100755 --- a/Scripts/install.sh +++ b/Scripts/install.sh @@ -79,18 +79,47 @@ else fi DOWNLOAD_URL="https://github.com/$REPO/releases/download/v$VERSION/$DOWNLOAD_FILE" +CHECKSUM_URL="https://github.com/$REPO/releases/download/v$VERSION/checksums.txt" echo -e "${YELLOW}⬇${NC} Downloading $DOWNLOAD_FILE..." TMP_DIR=$(mktemp -d) cd "$TMP_DIR" +# Download the binary/package if ! curl -fsSL -o "$DOWNLOAD_FILE" "$DOWNLOAD_URL"; then echo -e "${RED}❌ Download failed${NC}" rm -rf "$TMP_DIR" exit 1 fi +# Download checksums +echo -e "${YELLOW}🔐${NC} Verifying checksum..." +if ! curl -fsSL -o "checksums.txt" "$CHECKSUM_URL"; then + echo -e "${RED}❌ Failed to download checksums${NC}" + rm -rf "$TMP_DIR" + exit 1 +fi + +# Verify checksum +EXPECTED_CHECKSUM=$(grep "$DOWNLOAD_FILE" checksums.txt | awk '{print $1}') +if [ -z "$EXPECTED_CHECKSUM" ]; then + echo -e "${RED}❌ Checksum not found for $DOWNLOAD_FILE${NC}" + rm -rf "$TMP_DIR" + exit 1 +fi + +ACTUAL_CHECKSUM=$(sha256sum "$DOWNLOAD_FILE" | awk '{print $1}') +if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then + echo -e "${RED}❌ Checksum verification failed!${NC}" + echo -e "${RED} Expected: $EXPECTED_CHECKSUM${NC}" + echo -e "${RED} Got: $ACTUAL_CHECKSUM${NC}" + echo -e "${RED} This may indicate a compromised download.${NC}" + rm -rf "$TMP_DIR" + exit 1 +fi + +echo -e "${GREEN}✓${NC} Checksum verified" echo -e "${YELLOW}📦${NC} Installing..." if [ "$INSTALL_CMD" = "tar" ]; then From 1fed73fc63cf951c268c2c134df04a9a15d5dff5 Mon Sep 17 00:00:00 2001 From: Ankan Saha Date: Tue, 24 Feb 2026 01:03:45 +0530 Subject: [PATCH 3/3] feat: implement or refine the update mechanism within `Updater.go`. --- src/Update/Updater.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Update/Updater.go b/src/Update/Updater.go index c08c6c0..e9ff25d 100644 --- a/src/Update/Updater.go +++ b/src/Update/Updater.go @@ -11,19 +11,19 @@ import ( // Update commands for each operating system var updateCommands = map[string]updateCommand{ "linux": { - shell: "bash", + shell: "bash", shellArg: "-c", - script: "curl -fsSL https://raw.githubusercontent.com/nexoral/BanglaCode/main/Scripts/install.sh | bash", + script: "curl -fsSL https://raw.githubusercontent.com/nexoral/BanglaCode/main/Scripts/install.sh | bash", }, "darwin": { - shell: "bash", + shell: "bash", shellArg: "-c", - script: "curl -fsSL https://raw.githubusercontent.com/nexoral/BanglaCode/main/Scripts/install.sh | bash", + script: "curl -fsSL https://raw.githubusercontent.com/nexoral/BanglaCode/main/Scripts/install.sh | bash", }, "windows": { - shell: "powershell", + shell: "powershell", shellArg: "-Command", - script: "irm https://raw.githubusercontent.com/nexoral/BanglaCode/main/Scripts/install.ps1 | iex", + script: "irm https://raw.githubusercontent.com/nexoral/BanglaCode/main/Scripts/install.ps1 | iex", }, }