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
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@
"@types/node": "^25.9.5",
"@types/node-forge": "^1.3.14",
"@types/qrcode": "^1.5.6",
"@types/react": "^19.2.17",
"@types/react-dom": "^19.2.3",
"@types/react": "^19.2.18",
"@types/react-dom": "^19.2.4",
"@typescript-eslint/eslint-plugin": "^8.65.0",
"@typescript-eslint/parser": "^8.65.0",
"@vitejs/plugin-react": "^6.0.5",
Expand Down
76 changes: 38 additions & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions scripts/check-flatpak-offline-pnpm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
missingOfflineTarballs,
parseGeneratedPnpmManifest,
listLockfilePackageIds,
resolveFlatpakNodeGeneratorBin,
storeVersionFromPackageManager,
} from './flatpakPnpmStoreVersion.mjs';

Expand All @@ -39,15 +40,16 @@ const GENERATOR_TIMEOUT_MS = 5 * 60 * 1000;
* @returns {string | null}
*/
function resolveGeneratorBin() {
const fromEnv = process.env.FLATPAK_NODE_GENERATOR?.trim();
if (fromEnv) return fromEnv;

const which = spawnSync('which', ['flatpak-node-generator'], { encoding: 'utf8' });
if (which.status === 0) {
const bin = which.stdout.trim().split('\n')[0];
if (bin) return bin;
}
return null;
return resolveFlatpakNodeGeneratorBin({
root: ROOT,
env: process.env,
which: () => {
const result = spawnSync('which', ['flatpak-node-generator'], { encoding: 'utf8' });
if (result.status !== 0) return null;
const bin = result.stdout.trim().split('\n')[0];
return bin || null;
},
});
}

/**
Expand Down
68 changes: 68 additions & 0 deletions scripts/flatpakPnpmStoreVersion.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* Flatpak offline pnpm store version must match the packageManager major
* (pnpm 11 → store v11). flatpak-node-generator defaults to v10 for lockfile 9.
*/
import fs from 'node:fs';
import path from 'node:path';

/**
* Pinned flatpak-builder-tools commit used by Flatpak CI + PR offline checks.
Expand Down Expand Up @@ -30,6 +32,72 @@ export const FLATPAK_NODE_GENERATOR_PIP_INSTALL_ARGS = [
/** Shell one-liner for workflows / docs (keep in sync with PIP_INSTALL_ARGS). */
export const FLATPAK_NODE_GENERATOR_PIP_INSTALL_CMD = `pip3 ${FLATPAK_NODE_GENERATOR_PIP_INSTALL_ARGS.map((a) => (/\s/.test(a) ? `'${a}'` : a)).join(' ')}`;

/** Documented local CI-pin venv (see check:flatpak-offline-pnpm install hint). */
export const FLATPAK_NODE_GENERATOR_LOCAL_VENV_DIR = '.cache/flatpak-node-venv';

/**
* Resolve flatpak-node-generator: FLATPAK_NODE_GENERATOR → PATH → local CI-pin venv.
*
* @param {{
* root: string;
* env?: NodeJS.ProcessEnv | Record<string, string | undefined>;
* which?: (() => string | null) | null;
* platform?: NodeJS.Platform;
* existsSync?: (p: string) => boolean;
* accessSync?: (p: string, mode?: number) => void;
* X_OK?: number;
* }} opts
* @returns {string | null}
*/
export function resolveFlatpakNodeGeneratorBin(opts) {
const env = opts.env ?? process.env;
const fromEnv =
typeof env.FLATPAK_NODE_GENERATOR === 'string' ? env.FLATPAK_NODE_GENERATOR.trim() : '';
if (fromEnv) return fromEnv;

if (opts.which) {
const fromPath = opts.which()?.trim();
if (fromPath) return fromPath;
}

const platform = opts.platform ?? process.platform;
const exists = opts.existsSync ?? ((p) => fs.existsSync(p));
const access = opts.accessSync ?? ((p, mode) => fs.accessSync(p, mode));
const xOk = opts.X_OK ?? fs.constants.X_OK;

/** @param {string} candidate */
const usable = (candidate) => {
try {
if (!exists(candidate)) return false;
access(candidate, xOk);
return true;
} catch {
// catch-no-log-ok missing/non-executable local venv is a normal miss, not a fault
return false;
}
};

if (platform === 'win32') {
const winBin = path.join(
opts.root,
FLATPAK_NODE_GENERATOR_LOCAL_VENV_DIR,
'Scripts',
'flatpak-node-generator.exe',
);
return usable(winBin) ? winBin : null;
}

const unixBin = path.join(
opts.root,
FLATPAK_NODE_GENERATOR_LOCAL_VENV_DIR,
'bin',
'flatpak-node-generator',
);
if (usable(unixBin)) return unixBin;

return null;
}

/**
* @param {string | null | undefined} packageManager
* @returns {number | null}
Expand Down
Loading