const path = require('path');
const { createWindowsInstaller } = require('electron-winstaller');

async function main() {
  const root = __dirname;
  const appDirectory = path.join(root, 'release', 'FizzABC-win32-x64');
  const outputDirectory = path.join(root, 'release', 'installer');
  const setupIcon = path.join(root, 'build', 'setup.ico');
  const iconUrl = 'https://learn.fizzabc.com/favicon.ico';

  await createWindowsInstaller({
    appDirectory,
    outputDirectory,
    authors: 'FizzABC',
    exe: 'FizzABC.exe',
    name: 'FizzABC',
    title: 'FizzABC Desktop',
    setupExe: 'FizzABC-Setup.exe',
    noMsi: true,
    setupIcon,
    loadingGif: undefined,
    iconUrl
  });

  console.log('INSTALLER_CREATED');
}

main().catch((err) => {
  console.error(err);
  process.exit(1);
});
