make.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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', 'AppImage:x64'],
  33. config: {
  34. ...cfg_common,
  35. mac: {
  36. category: 'public.app-category.productivity',
  37. icon: 'assets/app.icns',
  38. gatekeeperAssess: false,
  39. hardenedRuntime: true,
  40. entitlements: 'scripts/entitlements.mac.plist',
  41. entitlementsInherit: 'scripts/entitlements.mac.plist',
  42. artifactName: '${productName}_macOS_${version}(${buildVersion}).${ext}'
  43. },
  44. dmg: {
  45. backgroundColor: '#f1f1f6',
  46. //background: 'assets/dmg-bg.png',
  47. //icon: 'assets/dmg-icon.icns',
  48. iconSize: 160,
  49. window: {
  50. width: 600,
  51. height: 420
  52. },
  53. contents: [{
  54. x: 150,
  55. y: 200
  56. }, {
  57. x: 450,
  58. y: 200,
  59. type: 'link',
  60. path: '/Applications'
  61. }],
  62. sign: false,
  63. artifactName: '${productName}_macOS_${version}(${buildVersion}).${ext}'
  64. },
  65. win: {
  66. icon: 'assets/app.ico'
  67. },
  68. nsis: {
  69. //installerIcon: 'assets/installer-icon.ico',
  70. oneClick: false,
  71. allowToChangeInstallationDirectory: true,
  72. artifactName: '${productName}_windows_installer_${version}(${buildVersion}).${ext}'
  73. },
  74. portable: {
  75. artifactName: '${productName}_windows_portable_${version}(${buildVersion}).${ext}'
  76. },
  77. linux: {
  78. category: 'Development',
  79. artifactName: '${productName}_linux_${arch}_${version}(${buildVersion}).${ext}'
  80. }
  81. }
  82. })
  83. console.log('done!')
  84. }
  85. (async () => {
  86. await makeApp()
  87. })()