You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maka.apache.org by as...@apache.org on 2026/09/03 19:56:08 UTC

(maka) 01/06: fix(desktop): omit Windows PTY build intermediates

This is an automated email from the ASF dual-hosted git repository.

Astro-Han pushed a commit to branch fix/windows-reproducible-payload
in repository https://gitbox.apache.org/repos/asf/maka.git

commit aea13ebf8dde1cdcbdfea0347588e665e6476c73
Author: AstroHan <le...@outlook.com>
AuthorDate: Wed Sep 2 23:47:19 2026 +0800

    fix(desktop): omit Windows PTY build intermediates
    
    Keep the native addons and ConPTY runtime helpers while excluding node-gyp projects and link scratch files. Those files embed checkout paths and generated project IDs in the shipped ASAR header. Exercise electron-builder’s dependency collector against a runtime and build-output fixture.
    
    Generated-by: Codex
---
 apps/desktop/electron-builder.config.mjs |  7 ++++
 scripts/verify-packaged-app.test.mjs     | 60 +++++++++++++++++++++++++++++++-
 2 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/apps/desktop/electron-builder.config.mjs b/apps/desktop/electron-builder.config.mjs
index 5893b1e875..1dbe3bfd68 100644
--- a/apps/desktop/electron-builder.config.mjs
+++ b/apps/desktop/electron-builder.config.mjs
@@ -262,6 +262,13 @@ const baseDesktopBuilderConfig = {
   },
   win: {
     artifactName: 'Maka-${version}-win-${arch}.${ext}',
+    // node-gyp leaves checkout-specific projects and link intermediates here.
+    // Only the native addons and their ConPTY DLL/helper are used at runtime.
+    files: [
+      '!**/node_modules/node-pty/build/!(Release){,/**}',
+      '!**/node_modules/node-pty/build/Release/!(*.node|conpty){,/**}',
+      '!**/node_modules/node-pty/node-addon-api{,/**}',
+    ],
     // Same reason as `mac.icon` above: the .exe, the installer and the
     // shortcut are drawn by the OS from this file, not by us.
     icon: 'assets/app-icons/sky.png',
diff --git a/scripts/verify-packaged-app.test.mjs b/scripts/verify-packaged-app.test.mjs
index e5ada284f9..54a52f177e 100644
--- a/scripts/verify-packaged-app.test.mjs
+++ b/scripts/verify-packaged-app.test.mjs
@@ -20,15 +20,73 @@
 import assert from 'node:assert/strict';
 import { mkdir, mkdtemp, readFile, rename, rm, writeFile } from 'node:fs/promises';
 import { tmpdir } from 'node:os';
-import { dirname, join } from 'node:path';
+import { dirname, join, relative } from 'node:path';
 import { after, describe, test } from 'node:test';
 import { createPackage } from '@electron/asar';
+import { FileMatcher, getNodeModuleFileMatcher } from 'app-builder-lib/out/fileMatcher.js';
+import { NodeModuleCopyHelper } from 'app-builder-lib/out/util/NodeModuleCopyHelper.js';
+import { resolveDesktopBuilderConfig } from '../apps/desktop/electron-builder.config.mjs';
 import {
   asarLookupPath,
   assertPackagedDependencyClosure,
   assertPackagedResources,
 } from './verify-packaged-app.mjs';
 
+test('Windows packaging keeps node-pty runtime files without its build intermediates', async (t) => {
+  const root = await mkdtemp(join(tmpdir(), 'maka-pty-package-'));
+  t.after(() => rm(root, { recursive: true, force: true }));
+  const moduleRoot = join(root, 'node_modules', 'node-pty');
+  const runtimeFiles = [
+    'package.json',
+    'LICENSE',
+    'lib/index.js',
+    'lib/worker/conoutSocketWorker.js',
+    'build/Release/conpty.node',
+    'build/Release/conpty_console_list.node',
+    'build/Release/conpty/conpty.dll',
+    'build/Release/conpty/OpenConsole.exe',
+    'prebuilds/win32-x64/conpty.node',
+    'prebuilds/win32-x64/conpty/conpty.dll',
+    'prebuilds/win32-x64/conpty/OpenConsole.exe',
+  ];
+  const buildFiles = [
+    'build/conpty.vcxproj',
+    'build/conpty.vcxproj.filters',
+    'build/Release/conpty.exp',
+    'build/Release/conpty.iobj',
+    'build/Release/conpty.ipdb',
+    'build/Release/obj/conpty/conpty.tlog/CL.command.1.tlog',
+    'build/Release/obj/conpty/conpty.node.recipe',
+    'node-addon-api/node_addon_api_except.vcxproj',
+    'node-addon-api/Release/obj/node_addon_api_except/n.nativecodeanalysis.xml',
+  ];
+  for (const name of [...runtimeFiles, ...buildFiles]) {
+    const path = join(moduleRoot, name);
+    await mkdir(dirname(path), { recursive: true });
+    await writeFile(path, name);
+  }
+  const config = resolveDesktopBuilderConfig({});
+  const packager = {
+    config,
+    appInfo: { type: 'module' },
+    debugLogger: { isEnabled: false },
+    getWorkspaceRoot: async () => root,
+  };
+  const destination = join(root, 'output');
+  const mainMatcher = getNodeModuleFileMatcher(root, destination, (s) => s, config.win, packager);
+  const matcher = new FileMatcher(moduleRoot, destination, (s) => s, mainMatcher.patterns);
+  const copier = new NodeModuleCopyHelper(matcher, packager);
+  const files = await copier.collectNodeModules(
+    { name: 'node-pty', dir: moduleRoot },
+    [],
+    join('node_modules', 'node-pty'),
+  );
+  assert.deepEqual(
+    files.map((file) => relative(moduleRoot, file).replaceAll('\\', '/')).sort(),
+    runtimeFiles.sort(),
+  );
+});
+
 test('packaged resources forbid the retired bundled Git distribution', async () => {
   const required = [];
   const forbidden = [];


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@maka.apache.org
For additional commands, e-mail: commits-help@maka.apache.org