[tauri] InstallerName: Publish the Windows installer as RoseaDomi_<version>_x64-setup.exe, a name Aula and Atrium accept; productName stays Rosea Domi
This commit is contained in:
@@ -51,7 +51,7 @@ describe('domi-app.toml', () => {
|
||||
|
||||
it('is made before every desktop build and never committed', () => {
|
||||
const pkg = JSON.parse(readFileSync(join(HERE, '..', 'package.json'), 'utf8')) as { scripts: Record<string, string> };
|
||||
expect(pkg.scripts['build:desktop']).toMatch(/tsx scripts\/domi-app\.ts && tauri build$/);
|
||||
expect(pkg.scripts['build:desktop']).toMatch(/tsx scripts\/domi-app\.ts && tauri build( |$)/);
|
||||
expect(pkg.scripts['dev']).toContain('tsx scripts/domi-app.ts');
|
||||
const ignore = readFileSync(join(HERE, '..', '..', '..', '.gitignore'), 'utf8');
|
||||
expect(ignore).toContain('apps/rosea-tauri/src-tauri/atrium/');
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import { mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
import { renameInstaller } from '../scripts/installer-name.js';
|
||||
import { INSTALLER_PATTERN, installerName, tauriInstallerName } from '../src/installer-name.js';
|
||||
|
||||
describe('installerName', () => {
|
||||
it('has no space, and matches what Aula and Atrium accept', () => {
|
||||
expect(installerName('0.1.2')).toBe('RoseaDomi_0.1.2_x64-setup.exe');
|
||||
expect(installerName('0.1.2')).toMatch(INSTALLER_PATTERN);
|
||||
expect(installerName('12.0.31')).toMatch(INSTALLER_PATTERN);
|
||||
});
|
||||
|
||||
it("knows Tauri's own name has a space, which Aula refuses", () => {
|
||||
expect(tauriInstallerName('0.1.2')).toBe('Rosea Domi_0.1.2_x64-setup.exe');
|
||||
expect(tauriInstallerName('0.1.2')).not.toMatch(INSTALLER_PATTERN);
|
||||
});
|
||||
|
||||
it('refuses something that is not a version', () => {
|
||||
expect(() => installerName('0.1')).toThrow(/not a version/);
|
||||
expect(() => installerName('0.1.2 x')).toThrow(/not a version/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('the desktop build', () => {
|
||||
it('renames the installer right after tauri build, so the release never sees the name with a space', () => {
|
||||
const pkg = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json'), 'utf8')) as { scripts: Record<string, string> };
|
||||
expect(pkg.scripts['build:desktop']).toMatch(/&& tauri build && tsx scripts\/installer-name\.ts$/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('renameInstaller', () => {
|
||||
let dir = '';
|
||||
afterEach(() => {
|
||||
if (dir) rmSync(dir, { recursive: true, force: true });
|
||||
dir = '';
|
||||
});
|
||||
|
||||
it("renames the built installer, and leaves only names Aula accepts", () => {
|
||||
dir = mkdtempSync(join(tmpdir(), 'rosea-nsis-'));
|
||||
writeFileSync(join(dir, 'Rosea Domi_0.1.2_x64-setup.exe'), 'exe');
|
||||
const to = renameInstaller(dir, '0.1.2');
|
||||
expect(to).toBe(join(dir, 'RoseaDomi_0.1.2_x64-setup.exe'));
|
||||
expect(readdirSync(dir)).toEqual(['RoseaDomi_0.1.2_x64-setup.exe']);
|
||||
});
|
||||
|
||||
it('fails when the build left no installer', () => {
|
||||
dir = mkdtempSync(join(tmpdir(), 'rosea-nsis-'));
|
||||
expect(() => renameInstaller(dir, '0.1.2')).toThrow(/no installer to rename/);
|
||||
});
|
||||
|
||||
it("removes an older build's installers, so the release publishes only this one", () => {
|
||||
dir = mkdtempSync(join(tmpdir(), 'rosea-nsis-'));
|
||||
writeFileSync(join(dir, 'Rosea Domi_0.1.2_x64-setup.exe'), 'exe');
|
||||
writeFileSync(join(dir, 'Rosea Domi_0.1.1_x64-setup.exe'), 'old');
|
||||
writeFileSync(join(dir, 'RoseaDomi_0.1.1_x64-setup.exe'), 'old');
|
||||
writeFileSync(join(dir, 'notes.txt'), 'kept');
|
||||
renameInstaller(dir, '0.1.2');
|
||||
expect(readdirSync(dir).sort()).toEqual(['RoseaDomi_0.1.2_x64-setup.exe', 'notes.txt']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user