From f6b4d66869f55305acde62cba0bab9cfbca38297 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Wed, 24 Jun 2026 10:40:52 +0530 Subject: [PATCH] chore: update Command Line SDK to 22.2.1 --- CHANGELOG.md | 4 +++ README.md | 4 +-- install.ps1 | 4 +-- install.sh | 2 +- lib/auth/refresh-token.ts | 60 ++++++++++++++++++++++++++++++++++++-- lib/constants.ts | 2 +- package-lock.json | 4 +-- package.json | 8 ++--- scoop/appwrite.config.json | 6 ++-- 9 files changed, 76 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6a8755..3ee969e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 22.2.1 + +* Fixed: Compiled binaries no longer crash from `@napi-rs/keyring` native bindings + ## 22.2.0 * Added: OAuth refresh tokens now stored in the OS keychain via `@napi-rs/keyring`, falling back to config diff --git a/README.md b/README.md index 1574604..ab904e8 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using ```sh $ appwrite -v -22.2.0 +22.2.1 ``` ### Install using prebuilt binaries @@ -83,7 +83,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc Once the installation completes, you can verify your install using ``` $ appwrite -v -22.2.0 +22.2.1 ``` ## Getting Started diff --git a/install.ps1 b/install.ps1 index 81b0736..c277304 100644 --- a/install.ps1 +++ b/install.ps1 @@ -13,8 +13,8 @@ # You can use "View source" of this page to see the full script. # REPO -$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/22.2.0/appwrite-cli-win-x64.exe" -$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/22.2.0/appwrite-cli-win-arm64.exe" +$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/22.2.1/appwrite-cli-win-x64.exe" +$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/22.2.1/appwrite-cli-win-arm64.exe" $APPWRITE_BINARY_NAME = "appwrite.exe" diff --git a/install.sh b/install.sh index 292e4c3..0796583 100644 --- a/install.sh +++ b/install.sh @@ -120,7 +120,7 @@ verifyMacOSCodeSignature() { downloadBinary() { echo "[2/5] Downloading executable for $OS ($ARCH) ..." - GITHUB_LATEST_VERSION="22.2.0" + GITHUB_LATEST_VERSION="22.2.1" GITHUB_FILE="appwrite-cli-${OS}-${ARCH}" GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE" diff --git a/lib/auth/refresh-token.ts b/lib/auth/refresh-token.ts index 091f9d7..b049f23 100644 --- a/lib/auth/refresh-token.ts +++ b/lib/auth/refresh-token.ts @@ -1,4 +1,3 @@ -import { Entry } from "@napi-rs/keyring"; import { globalConfig } from "../config.js"; import { EXECUTABLE_NAME } from "../constants.js"; import type { SessionData } from "../types.js"; @@ -11,10 +10,65 @@ interface KeyringEntry { deletePassword(): boolean; } +type KeyringEntryConstructor = new ( + service: string, + account: string, +) => KeyringEntry; + type KeyringEntryFactory = (service: string, account: string) => KeyringEntry; -let keyringEntryFactory: KeyringEntryFactory = (service, account) => - new Entry(service, account); +// undefined = unresolved; null = resolved but no native binding (use fallback). +let cachedEntry: KeyringEntryConstructor | null | undefined; + +// Resolve @napi-rs/keyring lazily via a literal per-platform require: a top-level +// import would crash the `bun --compile` binaries ("Cannot find native binding"), +// whereas a literal specifier lets bun embed the matching .node per --target so +// secure storage still works. Anything unresolved falls back to config storage. +/* eslint-disable @typescript-eslint/no-require-imports */ +const loadEntry = (): KeyringEntryConstructor | null => { + if (cachedEntry !== undefined) { + return cachedEntry; + } + + cachedEntry = null; + if (typeof require !== "function") { + return cachedEntry; + } + + try { + let mod: { Entry: KeyringEntryConstructor } | undefined; + if (process.platform === "darwin" && process.arch === "arm64") { + mod = require("@napi-rs/keyring-darwin-arm64"); + } else if (process.platform === "darwin" && process.arch === "x64") { + mod = require("@napi-rs/keyring-darwin-x64"); + } else if (process.platform === "linux" && process.arch === "x64") { + mod = require("@napi-rs/keyring-linux-x64-gnu"); + } else if (process.platform === "linux" && process.arch === "arm64") { + mod = require("@napi-rs/keyring-linux-arm64-gnu"); + } else if (process.platform === "win32" && process.arch === "x64") { + mod = require("@napi-rs/keyring-win32-x64-msvc"); + } else if (process.platform === "win32" && process.arch === "arm64") { + mod = require("@napi-rs/keyring-win32-arm64-msvc"); + } + + mod ??= require("@napi-rs/keyring"); + cachedEntry = mod.Entry; + } catch { + cachedEntry = null; + } + + return cachedEntry; +}; +/* eslint-enable @typescript-eslint/no-require-imports */ + +let keyringEntryFactory: KeyringEntryFactory = (service, account) => { + const Entry = loadEntry(); + if (!Entry) { + throw new Error("Secure credential storage is unavailable in this build."); + } + + return new Entry(service, account); +}; const getSessionData = (sessionId: string): SessionData | undefined => globalConfig.get(sessionId) as SessionData | undefined; diff --git a/lib/constants.ts b/lib/constants.ts index 060f054..e500cb2 100644 --- a/lib/constants.ts +++ b/lib/constants.ts @@ -1,7 +1,7 @@ // SDK export const SDK_TITLE = 'Appwrite'; export const SDK_TITLE_LOWER = 'appwrite'; -export const SDK_VERSION = '22.2.0'; +export const SDK_VERSION = '22.2.1'; export const SDK_NAME = 'Command Line'; export const SDK_PLATFORM = 'console'; export const SDK_LANGUAGE = 'cli'; diff --git a/package-lock.json b/package-lock.json index 032c310..61ee8e0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "appwrite-cli", - "version": "22.2.0", + "version": "22.2.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "appwrite-cli", - "version": "22.2.0", + "version": "22.2.1", "license": "BSD-3-Clause", "dependencies": { "@appwrite.io/console": "^15.1.1", diff --git a/package.json b/package.json index 06e278c..7aaa3d9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "type": "module", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API", - "version": "22.2.0", + "version": "22.2.1", "license": "BSD-3-Clause", "main": "dist/index.cjs", "module": "dist/index.js", @@ -35,9 +35,9 @@ "build:types": "tsc -p tsconfig.json --emitDeclarationOnly", "build:runtime": "npm run build:lib:runtime && npm run build:cli", "build:lib:runtime": "npm run build:lib:esm && npm run build:lib:cjs", - "build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --external:@napi-rs/keyring --external:terminal-image --outfile=dist/index.js", - "build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:@napi-rs/keyring --external:terminal-image --outfile=dist/index.cjs", - "build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:@napi-rs/keyring --external:fsevents --external:terminal-image --outfile=dist/cli.cjs", + "build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --external:@napi-rs/keyring --external:@napi-rs/keyring-* --external:terminal-image --outfile=dist/index.js", + "build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:@napi-rs/keyring --external:@napi-rs/keyring-* --external:terminal-image --outfile=dist/index.cjs", + "build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:@napi-rs/keyring --external:@napi-rs/keyring-* --external:fsevents --external:terminal-image --outfile=dist/cli.cjs", "lint": "eslint .", "format": "prettier --write \"**/*.{js,ts,json,md}\"", "generate": "tsx scripts/generate-commands.ts", diff --git a/scoop/appwrite.config.json b/scoop/appwrite.config.json index 9603dbd..968f72a 100644 --- a/scoop/appwrite.config.json +++ b/scoop/appwrite.config.json @@ -1,12 +1,12 @@ { "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json", - "version": "22.2.0", + "version": "22.2.1", "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.", "homepage": "https://github.com/appwrite/sdk-for-cli", "license": "BSD-3-Clause", "architecture": { "64bit": { - "url": "https://github.com/appwrite/sdk-for-cli/releases/download/22.2.0/appwrite-cli-win-x64.exe", + "url": "https://github.com/appwrite/sdk-for-cli/releases/download/22.2.1/appwrite-cli-win-x64.exe", "bin": [ [ "appwrite-cli-win-x64.exe", @@ -15,7 +15,7 @@ ] }, "arm64": { - "url": "https://github.com/appwrite/sdk-for-cli/releases/download/22.2.0/appwrite-cli-win-arm64.exe", + "url": "https://github.com/appwrite/sdk-for-cli/releases/download/22.2.1/appwrite-cli-win-arm64.exe", "bin": [ [ "appwrite-cli-win-arm64.exe",