import {release} from 'os'; import {app, shell, MenuItemConstructorOptions, dialog, clipboard} from 'electron'; import {getConfig, getPlugins} from '../../config'; const {arch, env, platform, versions} = process; import {version} from '../../package.json'; export default (commands: Record, showAbout: () => void): MenuItemConstructorOptions => { const submenu: MenuItemConstructorOptions[] = [ { label: `${app.name} Website`, click() { shell.openExternal('https://hyper.is'); } }, { label: 'Report Issue', click(menuItem, focusedWindow) { const body = ` - [ ] Your Hyper.app version is **${version}**. Please verify your using the [latest](https://github.com/vercel/hyper/releases/latest) Hyper.app version - [ ] I have searched the [issues](https://github.com/vercel/hyper/issues) of this repo and believe that this is not a duplicate --- - **Any relevant information from devtools?** _(CMD+OPTION+I on macOS, CTRL+SHIFT+I elsewhere)_: - **Is the issue reproducible in vanilla Hyper.app?** ## Issue --- - **${app.name} version**: ${env.TERM_PROGRAM_VERSION} "${app.getVersion()}" - **OS ARCH VERSION:** ${platform} ${arch} ${release()} - **Electron:** ${versions.electron} **LANG:** ${env.LANG} - **SHELL:** ${env.SHELL} **TERM:** ${env.TERM}
.hyper.js contents \`\`\`json ${JSON.stringify(getConfig(), null, 2)} \`\`\`
plugins \`\`\`json ${JSON.stringify(getPlugins(), null, 2)} \`\`\`
`; const issueURL = `https://github.com/vercel/hyper/issues/new?body=${encodeURIComponent(body)}`; const copyAndSend = () => { clipboard.writeText(body); shell.openExternal( `https://github.com/vercel/hyper/issues/new?body=${encodeURIComponent( '\n' )}` ); }; if (!focusedWindow) { copyAndSend(); } else if (issueURL.length > 6144) { dialog .showMessageBox(focusedWindow, { message: 'There is too much data to send to GitHub directly. The data will be copied to the clipboard, ' + 'please paste it into the GitHub issue page that will open.', type: 'warning', buttons: ['OK', 'Cancel'] }) .then((result) => { if (result.response === 0) { copyAndSend(); } }); } else { shell.openExternal(issueURL); } } } ]; if (process.platform !== 'darwin') { submenu.push( {type: 'separator'}, { role: 'about', click() { showAbout(); } } ); } return { role: 'help', submenu }; };