Skip to content
Merged
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
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release
on:
push:
tags:
- 'v*.*.*'
- "v*.*.*"

permissions: {}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`);
}
Expand Down
10 changes: 10 additions & 0 deletions src/sfw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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 });
Expand Down