@@ -14,6 +14,7 @@ import {
1414 vite ,
1515 electronVersion ,
1616} from './globals.js'
17+ import { TARGET_ELECTRON , DIR_ELECTRON , DIR_MOBILE } from './constants.js'
1718import {
1819 BuildHooks ,
1920 ServiceBuildOptions ,
@@ -35,11 +36,8 @@ import merge from './utils/merge.js'
3536// chainArtifactBuildCompleted,
3637// debugAfterPack,
3738// makeAfterPackEmbedAsarIntegrity,
38- // readIntegrityResource,
39- // afterPackFlipFuses
40- // } from "./utils/asar/security.js";
41-
42- // import { logAsarState } from "./utils/asar/debug.js";
39+ // ASAR security features - commented out pending future implementation
40+ // See: https://github.com/commoners/commoners/issues/XXX
4341
4442// Core Internal Imports
4543import { configureForDesktop , resolveConfig , resolveHooks } from './index.js'
@@ -61,8 +59,6 @@ export const buildServices = async (config: UserConfig = {}, options: ServiceBui
6159
6260 const { outDir } = options
6361
64- // if (!dev) await printHeader(`${name} – ${buildOnlyServices ? 'Building Selected Services' : `${getTargetDisplayName(target)} Build`}`)
65-
6662 const resolvedConfig = await resolveConfig ( config , { services, build : true } )
6763 const { hooks } = resolvedConfig
6864
@@ -117,7 +113,7 @@ export async function buildApp(
117113
118114 const { publish, sign } = build
119115
120- const isElectronBuild = target === 'electron'
116+ const isElectronBuild = target === TARGET_ELECTRON
121117 const isDesktopBuild = isDesktop ( target )
122118 const isMobileBuild = isMobile ( target )
123119
@@ -131,7 +127,7 @@ export async function buildApp(
131127
132128 let wasOverwritten = false
133129 if ( customTempDir ) {
134- outDir = join ( root , globalTempDir , isElectronBuild ? 'electron' : 'mobile' )
130+ outDir = join ( root , globalTempDir , isElectronBuild ? DIR_ELECTRON : DIR_MOBILE )
135131 const { overwrite : __wasOverwritten } = await handleTemporaryDirectories (
136132 dirname ( outDir ) ,
137133 overwrite
@@ -178,7 +174,7 @@ export async function buildApp(
178174
179175 if ( onBuildAssets ) {
180176 const result = onBuildAssets ( outDir )
181- if ( result === null ) return // Skip packaging if requested
177+ if ( result === null ) return undefined // Skip packaging if requested
182178 }
183179
184180 // ------------------------- Target-Specific Build Steps -------------------------
@@ -272,7 +268,7 @@ export async function buildApp(
272268 if ( preferredWinIcon ) buildConfig . win . icon = resolveIconPath ( preferredWinIcon )
273269
274270 // Ensure proper absolute paths are provided for Electron build
275- const electronTemplateDir = path . join ( templateDir , 'electron' )
271+ const electronTemplateDir = path . join ( templateDir , DIR_ELECTRON )
276272
277273 buildConfig . directories . buildResources = path . join (
278274 electronTemplateDir ,
@@ -297,103 +293,8 @@ export async function buildApp(
297293 buildConfig [ key ] = path . join ( root , buildConfig [ key ] ) // Resolve paths relative to the root
298294 }
299295
300- // // Ensure electron-builder runs our integrity injector first, then flips fuses
301- // if (buildConfig.asar && security.integrity) {
302-
303- // // Create debugged hook functions
304- // const debuggedAfterPackFlipFuses = async (context: any) => {
305- // const asarPath = join(context.appOutDir, 'resources', 'app.asar');
306- // logAsarState('BEFORE_FUSE_FLIP', asarPath, { hook: 'afterPackFlipFuses' });
307-
308- // await afterPackFlipFuses(context);
309-
310- // logAsarState('AFTER_FUSE_FLIP', asarPath, { hook: 'afterPackFlipFuses' });
311- // };
312-
313- // // Add this after your signing step
314- // const verifyIntegrityAfterSigning = async (config: any, fail = true) => {
315- // const exePath = path.resolve(config.file);
316-
317- // // Log ASAR state during artifact build completion
318- // const artifactDir = path.dirname(exePath);
319- // const possibleAsarPaths = [
320- // path.join(artifactDir, 'win-unpacked', 'resources', 'app.asar'),
321- // path.join(path.dirname(artifactDir), 'win-unpacked', 'resources', 'app.asar'),
322- // ];
323-
324- // for (const asarPath of possibleAsarPaths) {
325- // if (existsSync(asarPath)) {
326- // logAsarState('ARTIFACT_BUILD_COMPLETED_VERIFICATION', asarPath, {
327- // artifact: path.basename(exePath),
328- // hook: 'verifyIntegrityAfterSigning'
329- // });
330- // break;
331- // }
332- // }
333-
334- // const embedded = readIntegrityResource(exePath);
335- // if (!embedded.length) {
336- // const message = `⚠️\tNo integrity resource found in ${exePath}. This may indicate a problem with the signing process.`;
337- // if (fail) throw new Error(message);
338- // console.warn(message);
339- // return;
340- // }
341- // };
342-
343- // // OPTIONAL: if you still patch app.asar (e.g., your test blocker), do it here.
344- // // Ensure it modifies the ASAR at `${appOutDir}/resources/app.asar` (Win/Linux) or
345- // // `${appOutDir}/${product}.app/Contents/Resources/app.asar` (macOS).
346- // const mutateAsar = async ({ appOutDir, productName }) => {
347- // // Track ASAR state before mutation
348- // const asarPath = join(appOutDir, 'resources', 'app.asar');
349- // logAsarState('MUTATE_ASAR_START', asarPath, { hook: 'mutateAsar' });
350-
351- // // Example: run your patcher here so the final hash matches what ships.
352- // // await cp.execFile('node', ['utilities/patch-electron-asar.js', '--app', appOutDir]);
353- // console.log('🔧 ASAR mutation step (currently no-op)');
354-
355- // logAsarState('MUTATE_ASAR_END', asarPath, { hook: 'mutateAsar' });
356- // };
357-
358- // // Hook setup with comprehensive debugging
359- // buildConfig.afterPack = chainAfterPack(
360- // buildConfig.afterPack,
361- // debugAfterPack,
362- // debuggedAfterPackFlipFuses, // flip fuses first
363- // makeAfterPackEmbedAsarIntegrity(mutateAsar) // then embed integrity LAST
364- // );
365-
366- // buildConfig.artifactBuildCompleted = chainArtifactBuildCompleted(
367- // buildConfig.artifactBuildCompleted,
368- // (config) => {
369- // // Add comprehensive logging for artifact build completion
370- // const exePath = path.resolve(config.file);
371- // console.log(`\n🔍 Artifact Build Completed: ${path.basename(exePath)}`);
372-
373- // // Find and log the associated unpacked directory
374- // const artifactDir = path.dirname(exePath);
375- // const possibleUnpackedDirs = [
376- // path.join(artifactDir, 'win-unpacked'),
377- // path.join(path.dirname(artifactDir), 'win-unpacked'),
378- // ];
379-
380- // for (const unpackedDir of possibleUnpackedDirs) {
381- // if (existsSync(unpackedDir)) {
382- // const asarPath = path.join(unpackedDir, 'resources', 'app.asar');
383- // if (existsSync(asarPath)) {
384- // logAsarState('ARTIFACT_BUILD_COMPLETED', asarPath, {
385- // artifact: path.basename(exePath),
386- // unpackedDir,
387- // hook: 'artifactBuildCompleted'
388- // });
389- // }
390- // }
391- // }
392-
393- // return verifyIntegrityAfterSigning(config, false);
394- // }
395- // );
396- // }
296+ // TODO: Implement ASAR integrity checking
297+ // See: https://github.com/commoners/commoners/issues/XXX
397298
398299 buildConfig . mac . entitlementsInherit = path . join (
399300 electronTemplateDir ,
0 commit comments