|
| 1 | +import { describe, expect, it } from 'vitest' |
| 2 | +import { readFileSync } from 'node:fs' |
| 3 | +import { createRequire } from 'node:module' |
| 4 | +const require = createRequire(import.meta.url) |
| 5 | +require('app-builder-lib') // Initialize its public entrypoint before internal helpers. |
| 6 | +const { load } = require('js-yaml') |
| 7 | +const { expandMacro } = require('app-builder-lib/out/util/macroExpander') |
| 8 | +const { computeSafeArtifactNameIfNeeded } = require('app-builder-lib/out/platformPackager') |
| 9 | +const { NsisTarget } = require('app-builder-lib/out/targets/nsis/NsisTarget') |
| 10 | +const defaultPattern = Object.getOwnPropertyDescriptor(NsisTarget.prototype, 'installerFilenamePattern')!.get!.call({ isPortable: false }) |
| 11 | +const expand = (pattern: string, productName: string) => expandMacro(pattern, 'x64', { productName, version: '0.2.6' }, { ext: 'exe' }, false) |
| 12 | + |
| 13 | +describe('Windows installer names used by external GitHub publication', () => { |
| 14 | + it('reproduces the default NSIS filename/manifest mismatch', () => { |
| 15 | + const filename = expand(defaultPattern, 'KeepMind') |
| 16 | + expect(filename).toBe('KeepMind Setup 0.2.6.exe') |
| 17 | + expect(computeSafeArtifactNameIfNeeded(filename, () => '')).toBe('KeepMind-Setup-0.2.6.exe') |
| 18 | + }) |
| 19 | + it.each(['electron-builder.yml', 'electron-builder.corp.yml'])('%s produces the same on-disk and update-manifest filename', file => { |
| 20 | + const config = load(readFileSync(file, 'utf8')) |
| 21 | + const filename = expand(config.nsis?.artifactName ?? defaultPattern, config.productName) |
| 22 | + expect(filename).toMatch(/^[A-Za-z0-9._-]+\.exe$/) |
| 23 | + expect(computeSafeArtifactNameIfNeeded(filename, () => '')).toBeNull() |
| 24 | + }) |
| 25 | +}) |
0 commit comments