Files
orca/config/packaged-windows-only-runtime-files.cjs
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* refactor(tooling): organize test runtime and maintenance owners

* test(tooling): preserve relocated runtime fixture dependency edges

* refactor(tooling): preserve xterm routing owner checks

* ci(tooling): include routing owner in sparse checkout

* test(tooling): preserve copied workflow dependency closures

* fix(tooling): normalize hashed JSON assets in release parity

* fix(tooling): distinguish asset aliases from literal references

* fix(tooling): frame normalized asset reference payloads

* fix(tooling): normalize decoded JSON asset references

* refactor(tooling): organize build, CI and release owners

* fix(tooling): align moved generator and workflow path contracts

* fix(tooling): update generated plugin bundle owner banners

* test(tooling): create relocated mobile verifier fixture directories

* test(tooling): copy headless detector dependency closure

* test(tooling): align native batch policy fixtures with owner path

* fix(tooling): link moved reliability command to historical evidence

* fix(tooling): preserve nested sandbox owners and canonical guide source

* fix(tooling): target release version owners in checkout fixture
2026-11-04 21:08:19 -08:00

61 lines
2.2 KiB
JavaScript

'use strict'
const { existsSync, readdirSync } = require('node:fs')
const { join, relative } = require('node:path')
const { readPeMachine } = require('./scripts/native-build/windows/windows-pe-machine.cjs')
/** Files a runtime package publishes that no desktop package, or only Windows, loads. */
const RUNTIME_PACKAGE_EXCLUDED_FILES = {
// ssh2 uses pagent.exe only on Windows; C source/build script are build-only everywhere.
ssh2: {
everyPlatform: ['util/pagent.c', 'util/build_pagent.bat'],
nonWindows: ['util/pagent.exe']
}
}
/** extraResources filter patterns that keep `packageName`'s excluded files out of the copy. */
function runtimePackageExcludeFilter(packageName, electronPlatformName) {
const excluded = RUNTIME_PACKAGE_EXCLUDED_FILES[packageName]
if (!excluded) {
return []
}
return [
...excluded.everyPlatform,
...(electronPlatformName === 'win32' ? [] : excluded.nonWindows)
].map((file) => `!${file}`)
}
function collectWindowsExecutables(directory, found) {
for (const entry of readdirSync(directory, { withFileTypes: true })) {
const entryPath = join(directory, entry.name)
if (entry.isDirectory()) {
collectWindowsExecutables(entryPath, found)
} else if (entry.isFile() && readPeMachine(entryPath) !== null) {
found.push(entryPath)
}
}
return found
}
// Inspect content: dependency bumps can add PE files under arbitrary names, and scanners flag them in non-Windows installs.
function assertNoWindowsExecutablesInRuntimeNodeModules(resourcesDir, electronPlatformName) {
const nodeModulesDir = join(resourcesDir, 'node_modules')
if (electronPlatformName === 'win32' || !existsSync(nodeModulesDir)) {
return
}
const found = collectWindowsExecutables(nodeModulesDir, [])
if (found.length > 0) {
throw new Error(
`The ${electronPlatformName} package ships Windows executables in node_modules: ` +
`${found.map((file) => relative(resourcesDir, file).replace(/\\/g, '/')).join(', ')}. ` +
'Exclude them in config/packaged-windows-only-runtime-files.cjs or prune them after packing.'
)
}
}
module.exports = {
RUNTIME_PACKAGE_EXCLUDED_FILES,
assertNoWindowsExecutablesInRuntimeNodeModules,
runtimePackageExcludeFilter
}