From 2d2172f8ccde1c7b10ea1ffaf1109b93ff1dc136 Mon Sep 17 00:00:00 2001 From: Ahmad Nassri Date: Fri, 22 May 2026 12:10:54 -0400 Subject: [PATCH 1/2] feat: add skip update flag --- README.md | 2 ++ src/github.ts | 7 +++---- src/sfw.ts | 10 ++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 404d832..f309e3a 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ This is a wrapper script to download os + arch prebuilt executables of [Socket F It will automatically try to update in the background once a day if it finds a new release. +Set `SFW_SKIP_UPDATE_CHECK=1` to skip the background update check when a cached binary is already present (useful for offline or air-gapped environments). The initial download still runs if no binary is cached. + Directory Structure: ```console diff --git a/src/github.ts b/src/github.ts index 6f5c5b0..90a8afa 100644 --- a/src/github.ts +++ b/src/github.ts @@ -43,10 +43,9 @@ function mapArch() { export function expectedAssetName() { const plat = mapPlatform(); const arch = mapArch(); - if (plat === 'windows' && arch === 'x86_64') return 'sfw-free-windows-x86_64.exe'; - if (plat === 'macos' && (arch === 'arm64' || arch === 'x86_64')) return `sfw-free-macos-${arch}`; - if (plat === 'linux' && arch === 'x86_64') return 'sfw-free-linux-x86_64'; - if (plat === 'linux' && arch === 'arm64') return 'sfw-free-linux-arm64'; + if (plat === 'windows') return `sfw-free-windows-${arch}.exe`; + if (plat === 'macos') return `sfw-free-macos-${arch}`; + if (plat === 'linux') return `sfw-free-linux-${arch}`; // If we get here, there's no published combo throw new Error(`No published asset for ${process.platform}/${process.arch}`); } diff --git a/src/sfw.ts b/src/sfw.ts index 1d5f7ea..b85342f 100644 --- a/src/sfw.ts +++ b/src/sfw.ts @@ -44,6 +44,9 @@ function getCachePaths(releaseName: string, assetName: string) { } function shouldCheckForUpdate() { + if (isUpdateCheckDisabled()) { + return false; + } try { const data = fs.readFileSync(NEXT_CHECK_PATH, 'utf8'); const nextCheck = Date.parse(data.trim()); @@ -56,6 +59,13 @@ function shouldCheckForUpdate() { } } +function isUpdateCheckDisabled() { + const v = process.env.SFW_SKIP_UPDATE_CHECK; + if (!v) return false; + const s = v.toLowerCase(); + return s === '1' || s === 'true' || s === 'yes'; +} + function setNextCheckTimeSync() { const nextCheck = Date.now() + CHECK_TTL; fs.mkdirSync(path.dirname(NEXT_CHECK_PATH), { recursive: true }); From 7b1e111b8475e3754454e913104b7f5ddd00f5d7 Mon Sep 17 00:00:00 2001 From: Ahmad Nassri Date: Fri, 22 May 2026 12:13:35 -0400 Subject: [PATCH 2/2] ci: disable npm cache --- .github/workflows/ci.yml | 13 +++++++------ .github/workflows/release.yml | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0fce453..062c8a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,18 +19,19 @@ jobs: uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: persist-credentials: false - + - name: Setup Node.js uses: actions/setup-node@89d709d423dc495668cd762a18dd4a070611be3f with: - node-version-file: 'package.json' - cache: 'npm' - + package-manager-cache: false + node-version-file: "package.json" + cache: "npm" + - name: Install dependencies run: npm ci - + - name: Run check run: npm run check - + - name: Build run: npm run build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cbad55c..9f396dd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Release on: push: tags: - - 'v*.*.*' + - "v*.*.*" permissions: {} @@ -42,8 +42,9 @@ jobs: - name: Setup Node.js uses: actions/setup-node@89d709d423dc495668cd762a18dd4a070611be3f with: - node-version-file: 'package.json' - registry-url: 'https://registry.npmjs.org' + package-manager-cache: false + node-version-file: "package.json" + registry-url: "https://registry.npmjs.org" - name: Update npm to latest run: npm install -g npm@latest