mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-07-12 16:01:38 +08:00
add script for making dist for current platform and arch
This commit is contained in:
29
packages/ui/scripts/make-dist-for-current-platform.mjs
Normal file
29
packages/ui/scripts/make-dist-for-current-platform.mjs
Normal file
@@ -0,0 +1,29 @@
|
||||
import builder from 'electron-builder'
|
||||
import yaml from 'js-yaml'
|
||||
import url from 'node:url'
|
||||
import path from 'node:path'
|
||||
import fs from 'node:fs'
|
||||
import { buildTargetListMapByPlatform, osPlatformToBuildCommandMap } from './vars/os.mjs'
|
||||
|
||||
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
|
||||
|
||||
const getBuilderConfig = () => {
|
||||
return yaml.load(fs.readFileSync(path.join(__dirname, '../electron-builder.yml'), 'utf8'))
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
const buildTargets = buildTargetListMapByPlatform[process.platform]
|
||||
const platformKeyForBuildParameter = osPlatformToBuildCommandMap[process.platform]
|
||||
if (!buildTargets?.length || !platformKeyForBuildParameter) {
|
||||
console.log('Cannot build for current platform')
|
||||
process.exit(1)
|
||||
}
|
||||
const buildParameter = {
|
||||
config: getBuilderConfig()
|
||||
}
|
||||
buildParameter[platformKeyForBuildParameter] = buildTargets.map((it) => `${it}:${process.arch}`)
|
||||
|
||||
return await builder.build(buildParameter)
|
||||
}
|
||||
|
||||
main()
|
||||
@@ -1,12 +1,5 @@
|
||||
import childProcess from 'node:child_process'
|
||||
import os from 'node:os'
|
||||
|
||||
const currentOsPlatform = os.platform()
|
||||
const osPlatformToBuildCommandMap = {
|
||||
darwin: 'mac',
|
||||
linux: 'linux',
|
||||
win32: 'win'
|
||||
}
|
||||
import { osPlatformToBuildCommandMap, currentOsPlatform } from '../vars/os.mjs'
|
||||
|
||||
export default function buildUiOnCurrentPlatform() {
|
||||
try {
|
||||
|
||||
13
packages/ui/scripts/vars/os.mjs
Normal file
13
packages/ui/scripts/vars/os.mjs
Normal file
@@ -0,0 +1,13 @@
|
||||
import os from 'node:os'
|
||||
|
||||
export const currentOsPlatform = os.platform()
|
||||
export const osPlatformToBuildCommandMap = {
|
||||
darwin: 'mac',
|
||||
linux: 'linux',
|
||||
win32: 'win'
|
||||
}
|
||||
export const buildTargetListMapByPlatform = {
|
||||
darwin: ['dmg'],
|
||||
linux: ['deb'],
|
||||
win32: ['nsis']
|
||||
}
|
||||
Reference in New Issue
Block a user