Fix Windows artifact naming in desktop packaging

- Fix the naming convention in Electron output to align with previous
  artifact naming to not break external/internal URLs.
- In desktop execution tests, make artifact locator logic stricter to
  test regression.
This commit is contained in:
undergroundwires
2023-08-30 13:34:30 +02:00
parent ad0576a752
commit f4d86fccfd
9 changed files with 95 additions and 53 deletions

View File

@@ -1,20 +1,22 @@
import { mkdtemp, rm } from 'fs/promises';
import { join } from 'path';
import { tmpdir } from 'os';
import { findSingleFileByExtension, exists } from '../../utils/io';
import { exists } from '../../utils/io';
import { log, die, LogLevel } from '../../utils/log';
import { runCommand } from '../../utils/run-command';
import { ExtractionResult } from './extraction-result';
import { ExtractionResult } from './common/extraction-result';
import { findByFilePattern } from './common/app-artifact-locator';
export async function prepareWindowsApp(
desktopDistPath: string,
projectRootDir: string,
): Promise<ExtractionResult> {
const workdir = await mkdtemp(join(tmpdir(), 'win-nsis-installation-'));
if (await exists(workdir)) {
log(`Temporary directory ${workdir} already exists, cleaning up...`);
await rm(workdir, { recursive: true });
}
const appExecutablePath = await installNsis(workdir, desktopDistPath);
const appExecutablePath = await installNsis(workdir, desktopDistPath, projectRootDir);
return {
appExecutablePath,
cleanup: async () => {
@@ -31,16 +33,26 @@ export async function prepareWindowsApp(
async function installNsis(
installationPath: string,
desktopDistPath: string,
projectRootDir: string,
): Promise<string> {
const { absolutePath: installerPath } = await findSingleFileByExtension('exe', desktopDistPath);
const { absolutePath: installerPath } = await findByFilePattern(
// eslint-disable-next-line no-template-curly-in-string
'${name}-Setup-${version}.exe',
desktopDistPath,
projectRootDir,
);
log(`Silently installing contents of ${installerPath} to ${installationPath}...`);
const { error } = await runCommand(`"${installerPath}" /S /D=${installationPath}`);
if (error) {
return die(`Failed to install.\n${error}`);
}
const { absolutePath: appExecutablePath } = await findSingleFileByExtension('exe', installationPath);
const { absolutePath: appExecutablePath } = await findByFilePattern(
// eslint-disable-next-line no-template-curly-in-string
'${name}.exe',
installationPath,
projectRootDir,
);
return appExecutablePath;
}