MCPcopy
hub / github.com/desktop/desktop / copyCopilotDependency

Function copyCopilotDependency

script/build.ts:497–643  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

495}
496
497function copyCopilotDependency() {
498 const currentPlatform = process.platform
499 const currentArch = getDistArchitecture()
500
501 // The @github/copilot package now uses platform-specific optional
502 // dependencies (e.g. @github/copilot-darwin-arm64) that already contain only
503 // the binaries for the target platform, so we copy the appropriate one
504 // directly instead of the base @github/copilot package.
505 const copilotPkgDir = path.resolve(
506 projectRoot,
507 `app/node_modules/@github/copilot-${currentPlatform}-${currentArch}`
508 )
509
510 const copilotDestination = path.resolve(outRoot, 'copilot')
511 removeAndCopy(copilotPkgDir, copilotDestination)
512
513 // Platforms and architectures to remove from prebuild directories. This is
514 // an exhaustive list of all non-current platforms rather than an allowlist,
515 // because some packages (clipboard, pvrecorder) have entries without
516 // standard platform identifiers that we must preserve.
517 const nonValidPlatforms = [
518 'darwin',
519 'linux',
520 'win32',
521 'freebsd',
522 'openbsd',
523 'musl',
524 ].filter(p => p !== currentPlatform)
525 const nonValidArchitectures = [
526 'x64',
527 'arm64',
528 'ia32',
529 'armhf',
530 'riscv64',
531 'loong64',
532 ].filter(a => a !== currentArch)
533
534 // Also map platform names for packages that use non-standard naming
535 // (e.g., pvrecorder uses "mac" and "windows" instead of "darwin"/"win32")
536 const platformAliases: Record<string, string> = {
537 darwin: 'mac',
538 win32: 'windows',
539 }
540 const currentPlatformAlias = platformAliases[currentPlatform]
541 const nonValidPlatformAliases = Object.values(platformAliases).filter(
542 a => a !== currentPlatformAlias
543 )
544
545 // Removing unnecessary prebuild binaries from the copilot package to reduce
546 // bundle size and prevent signing failures on Windows (signtool can't sign
547 // non-PE binaries from other platforms).
548 const prebuildsDirs = [
549 path.join(copilotDestination, 'prebuilds'),
550 path.join(copilotDestination, 'ripgrep', 'bin'),
551 path.join(copilotDestination, 'clipboard', 'node_modules', '@teddyzhu'),
552 path.join(
553 copilotDestination,
554 'clipboard',

Callers 1

copyDependenciesFunction · 0.85

Calls 6

getDistArchitectureFunction · 0.90
removeAndCopyFunction · 0.85
isMacOSBinaryFunction · 0.85
isLinuxBinaryFunction · 0.85
isWindowsBinaryFunction · 0.85
filterMethod · 0.65

Tested by

no test coverage detected