-
-
Notifications
You must be signed in to change notification settings - Fork 13
fix: skip pnpm supply-chain re-verify in Flatpak offline builds #702
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| /** | ||
| * Shared Flatpak manifest contract for offline pnpm 11 install. | ||
| * | ||
| * Failure point: loose YAML regex can match commented or quoted keys outside the | ||
| * mesh-client module env map. Fallback: parse only that scoped env block and | ||
| * require exact unquoted YAML booleans. | ||
| */ | ||
|
|
||
| /** | ||
| * @param {string} yaml | ||
| * @returns {Record<string, boolean | string> | null} | ||
| */ | ||
| export function parseMeshClientModuleBuildEnv(yaml) { | ||
| const moduleMatch = yaml.match(/^ {2}- name: mesh-client\s*$/m); | ||
| if (!moduleMatch || moduleMatch.index == null) return null; | ||
|
|
||
| const fromModule = yaml.slice(moduleMatch.index); | ||
| const nextModuleOffset = fromModule.slice(1).search(/^ {2}- name: /m); | ||
| const moduleBlock = | ||
| nextModuleOffset === -1 ? fromModule : fromModule.slice(0, nextModuleOffset + 1); | ||
|
|
||
| const envMatch = moduleBlock.match(/^ {6}env:\s*$/m); | ||
| if (!envMatch || envMatch.index == null) return null; | ||
|
Comment on lines
+22
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Scope This accepts an 🤖 Prompt for AI Agents |
||
|
|
||
| const envIndent = 6; | ||
| const afterEnv = moduleBlock.slice(envMatch.index + envMatch[0].length); | ||
| /** @type {Record<string, boolean | string>} */ | ||
| const env = {}; | ||
|
|
||
| for (const line of afterEnv.split('\n')) { | ||
| if (line.trim() === '') continue; | ||
| const indent = line.match(/^ */)[0].length; | ||
| if (indent <= envIndent) break; | ||
|
|
||
| const trimmed = line.trim(); | ||
| if (trimmed.startsWith('#')) continue; | ||
|
|
||
| const m = trimmed.match(/^([A-Za-z0-9_]+):\s*(.+)$/); | ||
| if (!m) continue; | ||
|
|
||
| const [, key, raw] = m; | ||
| if (raw === 'true') { | ||
| env[key] = true; | ||
| } else if (raw === 'false') { | ||
| env[key] = false; | ||
| } else if ( | ||
| (raw.startsWith("'") && raw.endsWith("'")) || | ||
| (raw.startsWith('"') && raw.endsWith('"')) | ||
| ) { | ||
| // Quoted values are strings, not YAML booleans — reject for required keys. | ||
| env[key] = raw.slice(1, -1); | ||
| } else { | ||
| env[key] = raw; | ||
| } | ||
| } | ||
|
|
||
| return env; | ||
| } | ||
|
|
||
| /** | ||
| * @param {string} yaml | ||
| * @param {string} [fileRel] | ||
| * @returns {{ file: string, message: string }[]} | ||
| */ | ||
| export function offlinePnpmEnvContractViolations( | ||
| yaml, | ||
| fileRel = 'org.coloradomesh.MeshClient.yml', | ||
| ) { | ||
| const env = parseMeshClientModuleBuildEnv(yaml); | ||
| /** @type {{ file: string, message: string }[]} */ | ||
| const violations = []; | ||
|
|
||
| if (!env) { | ||
| violations.push({ | ||
| file: fileRel, | ||
| message: 'manifest mesh-client module build-options.env is missing', | ||
| }); | ||
| return violations; | ||
| } | ||
|
|
||
| if (env.PNPM_CONFIG_TRUST_LOCKFILE !== true) { | ||
| violations.push({ | ||
| file: fileRel, | ||
| message: | ||
| 'manifest mesh-client build-options.env must set PNPM_CONFIG_TRUST_LOCKFILE: true (unquoted boolean; skip registry supply-chain re-verify offline)', | ||
| }); | ||
| } | ||
|
|
||
| if (env.PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN !== false) { | ||
| violations.push({ | ||
| file: fileRel, | ||
| message: | ||
| 'manifest mesh-client build-options.env must set PNPM_CONFIG_VERIFY_DEPS_BEFORE_RUN: false (unquoted boolean; pnpm run must not auto-install offline)', | ||
| }); | ||
| } | ||
|
|
||
| return violations; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.