diff --git a/.github/workflows/pake-cli.yaml b/.github/workflows/pake-cli.yaml index 8fda576..7a6c43d 100644 --- a/.github/workflows/pake-cli.yaml +++ b/.github/workflows/pake-cli.yaml @@ -111,9 +111,8 @@ jobs: key: ${{ inputs.platform }}-cargo-${{ hashFiles('node_modules/pake-cli/src-tauri/Cargo.lock') }} - name: build with pake-cli - shell: pwsh run: | - pwsh ./script/build_with_pake_cli.ps1 + node ./script/build_with_pake_cli.js env: URL: ${{ inputs.url }} NAME: ${{ inputs.name }} diff --git a/script/build_with_pake_cli.js b/script/build_with_pake_cli.js new file mode 100644 index 0000000..f56ea32 --- /dev/null +++ b/script/build_with_pake_cli.js @@ -0,0 +1,77 @@ +const shell = require('shelljs'); +const axios = require('axios'); +const fs = require('fs'); +const path = require('path'); + +console.log("Welcome to use Pake Cli~"); +console.log("\n=======================\n"); + +console.log("\n======================="); +console.log("pake parameters is: "); +console.log("url: ", process.env.URL); +console.log("name: ", process.env.NAME); +console.log("icon: ", process.env.ICON); +console.log("height: ", process.env.HEIGHT); +console.log("width: ", process.env.WIDTH); +console.log("transparent: ", process.env.TRANSPARENT); +console.log("resize: ", process.env.RESIZE); +console.log("is multi arch? only for Mac: ", process.env.MULTI_ARCH); +console.log("targets type? only for Linux: ", process.env.TARGETS); +console.log("===========================\n"); + +shell.cd('node_modules/pake-cli'); +let params = `node cli.js ${process.env.URL} --name ${process.env.NAME}`; + +if (process.env.ICON) { + const iconPath = path.join(__dirname, 'icon'); + axios({ + method: 'get', + url: process.env.ICON, + responseType: 'stream' + }).then(function (response) { + response.data.pipe(fs.createWriteStream(iconPath)); + params = `${params} --icon ${iconPath}`; + }); +} + +params = `${params} --height ${process.env.HEIGHT} --width ${process.env.WIDTH}`; + +if (process.env.TRANSPARENT === 'true') { + params = `${params} --transparent`; +} + +if (process.env.FULLSCREEN === 'true') { + params = `${params} --resize`; +} + +if (process.env.MULTI_ARCH === 'true') { + shell.exec('rustup target add aarch64-apple-darwin'); + params = `${params} --multi-arch`; +} + +if (process.env.TARGETS) { + params = `${params} --targets ${process.env.TARGETS}`; +} + +if (process.platform === 'win32') { + params = `${params} --show-system-tray`; +} + +if (process.platform === 'linux') { + params = `${params} --show-system-tray`; +} + +if (process.platform === 'darwin') { + params = `${params} --show-menu`; +} + +console.log("Pake parameters is: ", params); +console.log("compile...."); +shell.exec(params); + +if (!fs.existsSync('output')) { + fs.mkdirSync('output'); +} +shell.mv(`${process.env.NAME}.*`, 'output/'); +console.log("Build Success"); +shell.cd('../..'); diff --git a/script/build_with_pake_cli.ps1 b/script/build_with_pake_cli.ps1 index 004186a..42457a4 100644 --- a/script/build_with_pake_cli.ps1 +++ b/script/build_with_pake_cli.ps1 @@ -1,4 +1,4 @@ -Write-Host "Welcome to use Powershell" +Write-Host "Welcome to use Powershell" Write-Host "`n=======================" Write-Host "build for windows" Write-Host "make ture powershell == 7.2.10" @@ -15,7 +15,6 @@ Write-Host "icon: " $env:ICON Write-Host "height: " $env:HEIGHT Write-Host "width: " $env:WIDTH Write-Host "transparent: " $env:TRANSPARENT -# Write-Host "fullscreen: " $env:FULLSCREEN Write-Host "resize: " $env:RESIZE Write-Host "is multi arch? only for Mac: " $env:MULTI_ARCH Write-Host "targets type? only for Linux: " $env:TARGETS @@ -50,11 +49,6 @@ if ("$env:TRANSPARENT" -eq "true") { ${Params}="${Params} --transparent" } -# fullscreen -# if ("$env:FULLSCREEN" -eq "true") { -# ${Params}="${Params} --fullscreen" -# } - # resize if ("$env:FULLSCREEN" -eq "true" ) { ${Params}="${Params} --resize"