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:
@@ -1,38 +1,5 @@
|
||||
import { extname, join } from 'path';
|
||||
import { readdir, access } from 'fs/promises';
|
||||
import { constants } from 'fs';
|
||||
import { log, die, LogLevel } from './log';
|
||||
|
||||
export async function findSingleFileByExtension(
|
||||
extension: string,
|
||||
directory: string,
|
||||
): Promise<FileSearchResult> {
|
||||
if (!directory) { throw new Error('Missing directory'); }
|
||||
if (!extension) { throw new Error('Missing file extension'); }
|
||||
|
||||
if (!await exists(directory)) {
|
||||
return die(`Directory does not exist: ${directory}`);
|
||||
}
|
||||
|
||||
const directoryContents = await readdir(directory);
|
||||
const foundFileNames = directoryContents.filter((file) => extname(file) === `.${extension}`);
|
||||
const withoutUninstaller = foundFileNames.filter(
|
||||
(fileName) => !fileName.toLowerCase().includes('uninstall'), // NSIS build has `Uninstall {app-name}.exe`
|
||||
);
|
||||
if (!withoutUninstaller.length) {
|
||||
return die(`No ${extension} found in ${directory} directory.`);
|
||||
}
|
||||
if (withoutUninstaller.length > 1) {
|
||||
log(`Found multiple ${extension} files: ${withoutUninstaller.join(', ')}. Using first occurrence`, LogLevel.Warn);
|
||||
}
|
||||
return {
|
||||
absolutePath: join(directory, withoutUninstaller[0]),
|
||||
};
|
||||
}
|
||||
|
||||
interface FileSearchResult {
|
||||
readonly absolutePath?: string;
|
||||
}
|
||||
|
||||
export async function exists(path: string): Promise<boolean> {
|
||||
if (!path) { throw new Error('Missing path'); }
|
||||
|
||||
@@ -64,15 +64,22 @@ export async function npmBuild(
|
||||
}
|
||||
}
|
||||
|
||||
const appNameCache = new Map<string, string>();
|
||||
|
||||
export async function getAppName(projectDir: string): Promise<string> {
|
||||
if (!projectDir) { throw new Error('missing project directory'); }
|
||||
if (appNameCache.has(projectDir)) {
|
||||
return appNameCache.get(projectDir);
|
||||
}
|
||||
const packageData = await readPackageJsonContents(projectDir);
|
||||
try {
|
||||
const packageJson = JSON.parse(packageData);
|
||||
if (!packageJson.name) {
|
||||
const name = packageJson.name as string;
|
||||
if (!name) {
|
||||
return die(`The \`package.json\` file doesn't specify a name: ${packageData}`);
|
||||
}
|
||||
return packageJson.name;
|
||||
appNameCache.set(projectDir, name);
|
||||
return name;
|
||||
} catch (error) {
|
||||
return die(`Unable to parse \`package.json\`. Error: ${error}\nContent: ${packageData}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user