make.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /**
  2. * build
  3. * @author: oldj
  4. * @homepage: https://oldj.net
  5. */
  6. const path = require('path')
  7. const builder = require('electron-builder')
  8. const homedir = require('os').homedir()
  9. const moment = require('moment')
  10. //const Platform = builder.Platform
  11. const version = require('../app/version')
  12. //const dist_dir = path.normalize(path.join(__dirname, '..', 'dist'))
  13. const cfg_common = {
  14. appId: 'SwitchHosts',
  15. productName: 'SwitchHosts',
  16. copyright: moment().format('Y'),
  17. buildVersion: version[3],
  18. directories: {
  19. buildResources: 'app',
  20. app: 'app'
  21. },
  22. electronDownload: {
  23. cache: path.join(homedir, '.electron'),
  24. mirror: 'https://npm.taobao.org/mirrors/electron/'
  25. }
  26. }
  27. const makeApp = async () => {
  28. await builder.build({
  29. //targets: Platform.MAC.createTarget(),
  30. mac: ['default'], // ['default', 'mas'],
  31. win: ['nsis:ia32', 'nsis:x64', 'portable:ia32'],
  32. linux: ['zip:x64'],
  33. config: {
  34. ...cfg_common,
  35. mac: {
  36. category: 'public.app-category.productivity',
  37. icon: 'assets/app.icns',
  38. gatekeeperAssess: false,
  39. identity: 'oldj',
  40. artifactName: '${productName}_macOS_${version}(${buildVersion}).${ext}'
  41. },
  42. dmg: {
  43. backgroundColor: '#f1f1f6',
  44. //background: 'assets/dmg-bg.png',
  45. //icon: 'assets/dmg-icon.icns',
  46. iconSize: 160,
  47. window: {
  48. width: 600,
  49. height: 420
  50. },
  51. contents: [{
  52. x: 150,
  53. y: 200
  54. }, {
  55. x: 450,
  56. y: 200,
  57. type: 'link',
  58. path: '/Applications'
  59. }],
  60. artifactName: '${productName}_macOS_${version}(${buildVersion}).${ext}'
  61. },
  62. win: {
  63. icon: 'assets/app.ico'
  64. },
  65. nsis: {
  66. //installerIcon: 'assets/installer-icon.ico',
  67. oneClick: false,
  68. allowToChangeInstallationDirectory: true,
  69. artifactName: '${productName}_windows_installer_${version}(${buildVersion}).${ext}'
  70. },
  71. portable: {
  72. artifactName: '${productName}_windows_portable_${version}(${buildVersion}).${ext}'
  73. },
  74. linux: {
  75. artifactName: '${productName}_linux_${arch}_${version}(${buildVersion}).${ext}'
  76. }
  77. }
  78. })
  79. console.log('done!')
  80. }
  81. (async () => {
  82. await makeApp()
  83. })()