From 9a91711c90056bc148b9c1772394fba52d5ebb1a Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 09:52:43 +0800 Subject: [PATCH 01/11] update bat for windows --- script/build.bat | 57 ++++++++++++++++++------------- src-tauri/tauri.windows.conf.json | 5 +-- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/script/build.bat b/script/build.bat index 6f4fd92..3c6974a 100644 --- a/script/build.bat +++ b/script/build.bat @@ -20,22 +20,16 @@ echo "build for windows" echo ======================= echo. +set identifier_prefix="com.tw93" + + + :: total package number set /A index=1 for /f %%a in (' find /c /v "" ^<"app.csv" ') do set /A total=%%a :: ignore first header line set /A total=total-1 -set old_name=weread -set old_title=WeRead -set old_zh_name=微信阅读 -set old_url=https://weread.qq.com/ - -:: set init name, we will recovery code to init when build finish. -set init_name=%old_name% -set init_title=%old_title% -set init_zh_name=%old_zh_name% -set init_url=%old_url% :: for windows, we need replace package name to title :: .\script\sd.exe "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri\tauri.conf.json @@ -48,12 +42,36 @@ for /f "skip=1 tokens=1-4 delims=," %%i in (app.csv) do ( set url=%%l @echo on - ::echo name is !name! !name_zh! !url! :: replace url - .\script\sd.exe -s !old_url! !url! src-tauri\tauri.conf.json + :: clear url with regex + .\script\sd.exe "\"url\": \"(.*?)\"," "\"url\": \"\"," src-tauri/tauri.conf.json + :: replace url with no regex + .\script\sd.exe -s "\"url\": \"\"," "\"url\": \"!url!\"," src-tauri/tauri.conf.json + ::replace pacakge name - .\script\sd.exe -s !old_title! !title! src-tauri\tauri.conf.json - .\script\sd.exe -s !old_name! !name! src-tauri\tauri.windows.conf.json + :: clear package_name with regex + .\script\sd.exe "\"productName\": \"(.*?)\"," "\"productName\": \"\"," src-tauri/tauri.conf.json + :: replace package_name with no regex + .\script\sd.exe -s "\"productName\": \"\"," "\"productName\": \"!title!\"," src-tauri/tauri.conf.json + + :: replace icon + ::clear icon path with regex + .\script\sd.exe "\"icon\": \[\"(.*?)\"\]," "\"icon\": [\"\"]," src-tauri/tauri.windows.conf.json + :: replace icon path with no regex + .\script\sd.exe -s "\"icon\": [\"\"]," "\"icon\": [\"icons/!name!_256.ico\", \"!name!_32.ico\"]," src-tauri/tauri.windows.conf.json + + :: replace identifier + :: clear identifier with regex + .\script\sd.exe "\"identifier\": \"(.*?)\"," "\"identifier\": \"\"," src-tauri/tauri.windows.conf.json + :: replace identifier with not regex + .\script\sd.exe -s "\"identifier\": \"\"," "\"identifier\": \"!identifier_prefix!.!name!\"," src-tauri/tauri.windows.conf.json + + :: replace icon resources + :: clear resources with regex + .\script\sd.exe "\"resources\": \[\"(.*?)\"\]" "\"resources\": \[\"\"\]" src-tauri/tauri.windows.conf.json + :: replace resources with no regex + .\script\sd.exe -s "\"resources\": [\"\"]" "\"resources\": [\"!name!_32.ico\"]" src-tauri/tauri.windows.conf.json + if not exist src-tauri\png\!name!_32.ico ( copy src-tauri\png\icon_32.ico src-tauri\png\!name!_32.ico ) @@ -62,11 +80,7 @@ for /f "skip=1 tokens=1-4 delims=," %%i in (app.csv) do ( copy src-tauri\png\icon_256.ico src-tauri\png\!name!_256.ico ) echo. - ::update package info - set old_zh_name=!name_zh! - set old_name=!name! - set old_title=!title! - set old_url=!url! + ::build package echo building package !index!/!total! echo package name is !name! !name_zh! @@ -96,8 +110,3 @@ for /f "skip=1 tokens=1-4 delims=," %%i in (app.csv) do ( :: for windows, we need replace package name to lower again :: .\script\sd.exe "\"productName\": \"WeRead\"" "\"productName\": \"weread\"" src-tauri\tauri.conf.json echo "output dir is output\windows" - -::recovery code -.\script\sd.exe -s %url% %init_url% src-tauri\tauri.conf.json -.\script\sd.exe -s %title% %init_title% src-tauri\tauri.conf.json -.\script\sd.exe -s %name% %init_name% src-tauri\tauri.windows.conf.json \ No newline at end of file diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index 0c2eb5b..b46b429 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -1,10 +1,7 @@ { "tauri": { "bundle": { - "icon": [ - "png/weread_256.ico", - "png/weread_32.ico" - ], + "icon": ["png/weread_256.ico", "png/weread_32.ico"], "identifier": "com.tw93.weread", "active": true, "category": "DeveloperTool", From 1f741dec0a8086af5dbab8ec45e3919d23e14a00 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 11:40:10 +0800 Subject: [PATCH 02/11] replace cmd .bat with powershell .ps1 --- package.json | 2 +- script/build.bat | 112 ------------------------------------------- script/build.ps1 | 120 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+), 113 deletions(-) delete mode 100644 script/build.bat create mode 100644 script/build.ps1 diff --git a/package.json b/package.json index beb7886..7f0097e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "build": "npm run tauri build --release", "build:mac": "npm run tauri build -- --target universal-apple-darwin", "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh", - "build:all-windows": ".\\script\\build.bat", + "build:all-windows": ".\\script\\build.ps1", "tauri": "tauri", "cli": "rollup -c rollup.config.js --watch", "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js", diff --git a/script/build.bat b/script/build.bat deleted file mode 100644 index 3c6974a..0000000 --- a/script/build.bat +++ /dev/null @@ -1,112 +0,0 @@ -@echo off -chcp 65001 - -if not exist node_modules ( - call npm i -) - -if not exist output ( - mkdir output -) - - -if not exist output\windows ( - mkdir output\windows -) - -echo. -echo ======================= -echo "build for windows" -echo ======================= -echo. - -set identifier_prefix="com.tw93" - - - -:: total package number -set /A index=1 -for /f %%a in (' find /c /v "" ^<"app.csv" ') do set /A total=%%a -:: ignore first header line -set /A total=total-1 - - -:: for windows, we need replace package name to title -:: .\script\sd.exe "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri\tauri.conf.json - -for /f "skip=1 tokens=1-4 delims=," %%i in (app.csv) do ( - setlocal enabledelayedexpansion - set name=%%i - set title=%%j - set name_zh=%%k - set url=%%l - @echo on - - :: replace url - :: clear url with regex - .\script\sd.exe "\"url\": \"(.*?)\"," "\"url\": \"\"," src-tauri/tauri.conf.json - :: replace url with no regex - .\script\sd.exe -s "\"url\": \"\"," "\"url\": \"!url!\"," src-tauri/tauri.conf.json - - ::replace pacakge name - :: clear package_name with regex - .\script\sd.exe "\"productName\": \"(.*?)\"," "\"productName\": \"\"," src-tauri/tauri.conf.json - :: replace package_name with no regex - .\script\sd.exe -s "\"productName\": \"\"," "\"productName\": \"!title!\"," src-tauri/tauri.conf.json - - :: replace icon - ::clear icon path with regex - .\script\sd.exe "\"icon\": \[\"(.*?)\"\]," "\"icon\": [\"\"]," src-tauri/tauri.windows.conf.json - :: replace icon path with no regex - .\script\sd.exe -s "\"icon\": [\"\"]," "\"icon\": [\"icons/!name!_256.ico\", \"!name!_32.ico\"]," src-tauri/tauri.windows.conf.json - - :: replace identifier - :: clear identifier with regex - .\script\sd.exe "\"identifier\": \"(.*?)\"," "\"identifier\": \"\"," src-tauri/tauri.windows.conf.json - :: replace identifier with not regex - .\script\sd.exe -s "\"identifier\": \"\"," "\"identifier\": \"!identifier_prefix!.!name!\"," src-tauri/tauri.windows.conf.json - - :: replace icon resources - :: clear resources with regex - .\script\sd.exe "\"resources\": \[\"(.*?)\"\]" "\"resources\": \[\"\"\]" src-tauri/tauri.windows.conf.json - :: replace resources with no regex - .\script\sd.exe -s "\"resources\": [\"\"]" "\"resources\": [\"!name!_32.ico\"]" src-tauri/tauri.windows.conf.json - - if not exist src-tauri\png\!name!_32.ico ( - copy src-tauri\png\icon_32.ico src-tauri\png\!name!_32.ico - ) - - if not exist src-tauri\png\!name!_256.ico ( - copy src-tauri\png\icon_256.ico src-tauri\png\!name!_256.ico - ) - echo. - - ::build package - echo building package !index!/!total! - echo package name is !name! !name_zh! - echo npm run build:windows - @echo off - call npm run tauri build -- --target x86_64-pc-windows-msvc - move src-tauri\target\x86_64-pc-windows-msvc\release\bundle\msi\*.msi output\windows\!title!_x64.msi - ::rm cache - del /q /f /s src-tauri\target\x86_64-pc-windows-msvc\release\*.exe - del /q /f /s src-tauri\target\x86_64-pc-windows-msvc\release\resources\*.ico - del /q /f /s src-tauri\target\x86_64-pc-windows-msvc\release\png\*.ico - del /q /f /s src-tauri\target\x86_64-pc-windows-msvc\release\wix\*.* - del /q /f /s src-tauri\target\x86_64-pc-windows-msvc\release\app.* - rd /s /q src-tauri\target\x86_64-pc-windows-msvc\release\resources - rd /s /q src-tauri\target\x86_64-pc-windows-msvc\release\png - rd /s /q src-tauri\target\x86_64-pc-windows-msvc\release\wix - @echo on - echo package build success! - echo. - echo. - - set /A index=index+1 - @echo off - -) - -:: for windows, we need replace package name to lower again -:: .\script\sd.exe "\"productName\": \"WeRead\"" "\"productName\": \"weread\"" src-tauri\tauri.conf.json -echo "output dir is output\windows" diff --git a/script/build.ps1 b/script/build.ps1 new file mode 100644 index 0000000..886cde2 --- /dev/null +++ b/script/build.ps1 @@ -0,0 +1,120 @@ +chcp 65001 | Out-Null + +if (-not (Test-Path node_modules)) { + npm i +} + +if (-not (Test-Path output)) { + New-Item -ItemType Directory -Path output +} + +if (-not (Test-Path output\windows)) { + New-Item -ItemType Directory -Path output\windows +} + +Write-Host "`n=======================" +Write-Host "build for windows" +Write-Host "=======================`n" + +$identifier_prefix = "com.tw93" + +# total package number +$index = 1 +$total = (Get-Content ./app.csv | Measure-Object -Line).Lines +$common_conf_path = "src-tauri/tauri.conf.json" +$windows_conf_path = "src-tauri/tauri.windows.conf.json" + +# ignore first header line +$total = $total - 1 + +# for windows, we need replace package name to title +# .\script\sd.exe "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri\tauri.conf.json +ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { + $name, $title, $name_zh, $url = $line.Split(",") + Write-Host "building package ${index}/${total}" + Write-Host "package name is ${name} ${name_zh}" + Write-Host "==========================" + Write-Host "building Args is:" + Write-Host "name = ${name}" + Write-Host "title = ${title}" + Write-Host "name_zh = ${name_zh}" + Write-Host "url = ${url}" + Write-Host "==========================" + # -- replace url -- + # clear url with regex + (Get-Content -Path $common_conf_path -Raw) -replace '"url":\s*"[^"]*"', '"url": ""' | Set-Content -Path $common_conf_path + # replace url with no regex + .\script\sd.exe -s '"url": ""' "`"url`": `"${url}`"" $common_conf_path + + # replace package name + # clear package_name with regex + (Get-Content -Path $common_conf_path -Raw) -replace '"productName":\s*"[^"]*"', '"productName": ""' | Set-Content -Path $common_conf_path + # replace package_name with no regex + .\script\sd.exe -s '"productName": ""' "`"productName`": `"$title`"" $common_conf_path + + # -- replace icon -- + # clear icon path with regex + (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"icon":\s*\[[^\]]*\]', '"icon": []' | Set-Content -Path $windows_conf_path + # replace icon path with no regex + .\script\sd.exe -s '"icon": []' "`"icon`": [`"png/${name}_256.ico`", `"png/${name}_32.ico`"]" $windows_conf_path + + # -- replace identifier -- + # clear identifier with regex + (Get-Content -Path $windows_conf_path -Raw) -replace '"identifier":\s*"[^"]*"', '"identifier": ""' | Set-Content -Path $windows_conf_path + # -- replace identifier with no regex -- + .\script\sd.exe -s '"identifier": ""' "`"identifier`": `"${identifier_prefix}.${name}`"" $windows_conf_path + + # -- replace icon resources -- + # clear resources with regex + (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"resources":\s*\[[^\]]*\]', '"resources": []' | Set-Content -Path $windows_conf_path + # replace resources with no regex + .\script\sd.exe -s '"resources": []' "`"resources`": [`"png/${name}_32.ico`"]" $windows_conf_path + + if (-not (Test-Path "src-tauri\png\${name}_32.ico")) { + Copy-Item "src-tauri\png\icon_32.ico" "src-tauri\png\${name}_32.ico" + } + + if (-not (Test-Path "src-tauri\png\${name}_256.ico")) { + Copy-Item "src-tauri\png\icon_256.ico" "src-tauri\png\${name}_256.ico" + } + + # build package + Write-Host "npm run build:windows" + npm run tauri build -- --target x86_64-pc-windows-msvc + Move-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\bundle\msi\*.msi" -Destination "output\windows\${title}_x64.msi" + #rm cache + Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\*.exe" -Recurse -Force + Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\resources\*.ico" -Recurse -Force + Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\png\*.ico" -Recurse -Force + Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\wix\*.*" -Recurse -Force + Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\app.*" -Force + Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\resources" -Recurse -Force + Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\png" -Recurse -Force + Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\wix" -Recurse -Force + Write-Host "package build success!" + Write-Host "" + $index++ + # strip blank line for common_conf_path + $lines = Get-Content ${common_conf_path} + $lastNonEmptyLineIndex = ($lines.Count - 1) + while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { + $lastNonEmptyLineIndex-- + } + if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { + $lines = $lines[0..$lastNonEmptyLineIndex] + } + Set-Content -Path ${common_conf_path} -Value $lines + + # strip blank line for windows conf_path + $lines = Get-Content ${windows_conf_path} + $lastNonEmptyLineIndex = ($lines.Count - 1) + while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { + $lastNonEmptyLineIndex-- + } + if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { + $lines = $lines[0..$lastNonEmptyLineIndex] + } + Set-Content -Path ${windows_conf_path} -Value $lines +} + +Write-Host "output dir is output\windows" From 75276595a55b972c424d076f0e1ae9265f475fd1 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 11:42:26 +0800 Subject: [PATCH 03/11] replace cmd .bat with powershell .ps1 --- package.json | 2 +- src-tauri/tauri.conf.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7f0097e..2121150 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "build": "npm run tauri build --release", "build:mac": "npm run tauri build -- --target universal-apple-darwin", "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh", - "build:all-windows": ".\\script\\build.ps1", + "build:all-windows": "powershell .\\script\\build.ps1", "tauri": "tauri", "cli": "rollup -c rollup.config.js --watch", "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js", diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index bd260ec..55a6c01 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -6,7 +6,7 @@ "tauri": { "windows": [ { - "url": "https://weread.qq.com/", + "url": "", "transparent": true, "fullscreen": false, "width": 1200, @@ -28,3 +28,4 @@ "beforeDevCommand": "" } } + From f14bbc52b7339dfd3dfd1226e9c42f2a33953c54 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 11:50:24 +0800 Subject: [PATCH 04/11] replace cmd with pwsh(powershell) --- .github/workflows/pake_build.yaml | 1 + .github/workflows/pake_build_with_cache.yaml | 1 + package.json | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pake_build.yaml b/.github/workflows/pake_build.yaml index 0c69a33..6e53d7d 100644 --- a/.github/workflows/pake_build.yaml +++ b/.github/workflows/pake_build.yaml @@ -77,6 +77,7 @@ jobs: - name: build for windows if: matrix.os == 'windows-latest' + shell: pwsh run: | npm run build:all-windows diff --git a/.github/workflows/pake_build_with_cache.yaml b/.github/workflows/pake_build_with_cache.yaml index d75984d..96c0a2c 100644 --- a/.github/workflows/pake_build_with_cache.yaml +++ b/.github/workflows/pake_build_with_cache.yaml @@ -74,6 +74,7 @@ jobs: - name: build for windows if: matrix.os == 'windows-latest' + shell: pwsh run: | npm run build:all-windows diff --git a/package.json b/package.json index 2121150..7eccf9f 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "build": "npm run tauri build --release", "build:mac": "npm run tauri build -- --target universal-apple-darwin", "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh", - "build:all-windows": "powershell .\\script\\build.ps1", + "build:all-windows": "pwsh .\\script\\build.ps1", "tauri": "tauri", "cli": "rollup -c rollup.config.js --watch", "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js", From db9b6629bc9b5cd85cfaf2b70b58d7abda05fd60 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 12:04:14 +0800 Subject: [PATCH 05/11] update powershell file for windows --- script/build.ps1 | 4 ++-- src-tauri/tauri.conf.json | 5 +++-- src-tauri/tauri.windows.conf.json | 9 ++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/script/build.ps1 b/script/build.ps1 index 886cde2..75cf0f9 100644 --- a/script/build.ps1 +++ b/script/build.ps1 @@ -28,7 +28,6 @@ $windows_conf_path = "src-tauri/tauri.windows.conf.json" $total = $total - 1 # for windows, we need replace package name to title -# .\script\sd.exe "\"productName\": \"weread\"" "\"productName\": \"WeRead\"" src-tauri\tauri.conf.json ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { $name, $title, $name_zh, $url = $line.Split(",") Write-Host "building package ${index}/${total}" @@ -48,7 +47,8 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { # replace package name # clear package_name with regex - (Get-Content -Path $common_conf_path -Raw) -replace '"productName":\s*"[^"]*"', '"productName": ""' | Set-Content -Path $common_conf_path + .\script\sd.exe "`"productName`":\s`"(.*?)`"" '"productName": ""' $common_conf_path + # (Get-Content -Path $common_conf_path -Raw) -replace '"productName":\s*"[^"]*"', '"productName": ""' | Set-Content -Path $common_conf_path # replace package_name with no regex .\script\sd.exe -s '"productName": ""' "`"productName`": `"$title`"" $common_conf_path diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 55a6c01..cad1afa 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,12 +1,12 @@ { "package": { - "productName": "WeRead", + "productName": "", "version": "1.0.0" }, "tauri": { "windows": [ { - "url": "", + "url": "https://riju.codes/", "transparent": true, "fullscreen": false, "width": 1200, @@ -29,3 +29,4 @@ } } + diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index b46b429..ca3d017 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -1,14 +1,14 @@ { "tauri": { "bundle": { - "icon": ["png/weread_256.ico", "png/weread_32.ico"], - "identifier": "com.tw93.weread", + "icon": ["png/coderunner_256.ico", "png/coderunner_32.ico"], + "identifier": "com.tw93.coderunner", "active": true, "category": "DeveloperTool", "copyright": "", "externalBin": [], "longDescription": "", - "resources": ["png/weread_32.ico"], + "resources": ["png/coderunner_32.ico"], "shortDescription": "", "targets": ["msi"], "windows": { @@ -23,3 +23,6 @@ } } } + + + From 12402bcd6024110d283840ef1f75c1836286d979 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 12:06:07 +0800 Subject: [PATCH 06/11] Update build.ps1 Signed-off-by: Tlntin --- script/build.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/build.ps1 b/script/build.ps1 index 886cde2..c781d57 100644 --- a/script/build.ps1 +++ b/script/build.ps1 @@ -48,7 +48,7 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { # replace package name # clear package_name with regex - (Get-Content -Path $common_conf_path -Raw) -replace '"productName":\s*"[^"]*"', '"productName": ""' | Set-Content -Path $common_conf_path + .\script\sd.exe "`"productName`":\s`"(.*?)`"" '"productName": ""' $common_conf_path # replace package_name with no regex .\script\sd.exe -s '"productName": ""' "`"productName`": `"$title`"" $common_conf_path From d17a3b996369dd25c9c4684ad54e6882ddaa2e49 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 12:34:54 +0800 Subject: [PATCH 07/11] update powershell file for windows --- package.json | 2 +- script/build.ps1 | 54 +++++++++++++++++-------------- src-tauri/tauri.conf.json | 6 ++-- src-tauri/tauri.windows.conf.json | 6 ++-- 4 files changed, 36 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 7eccf9f..eacef42 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "build": "npm run tauri build --release", "build:mac": "npm run tauri build -- --target universal-apple-darwin", "build:all-unix": "chmod +x ./script/build.sh && ./script/build.sh", - "build:all-windows": "pwsh .\\script\\build.ps1", + "build:all-windows": "pwsh ./script/build.ps1", "tauri": "tauri", "cli": "rollup -c rollup.config.js --watch", "cli:build": "cross-env NODE_ENV=production rollup -c rollup.config.js", diff --git a/script/build.ps1 b/script/build.ps1 index af09480..eb4aefb 100644 --- a/script/build.ps1 +++ b/script/build.ps1 @@ -10,6 +10,9 @@ if (-not (Test-Path output)) { if (-not (Test-Path output\windows)) { New-Item -ItemType Directory -Path output\windows +} else { + Remove-Item output\windows -Recurse -Force + New-Item -ItemType Directory -Path output\windows } Write-Host "`n=======================" @@ -41,7 +44,7 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { Write-Host "==========================" # -- replace url -- # clear url with regex - (Get-Content -Path $common_conf_path -Raw) -replace '"url":\s*"[^"]*"', '"url": ""' | Set-Content -Path $common_conf_path + .\script\sd.exe "`"url`":\s`"(.*?)`"" '"url": ""' $common_conf_path # replace url with no regex .\script\sd.exe -s '"url": ""' "`"url`": `"${url}`"" $common_conf_path @@ -53,19 +56,22 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { # -- replace icon -- # clear icon path with regex - (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"icon":\s*\[[^\]]*\]', '"icon": []' | Set-Content -Path $windows_conf_path + # (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"icon":\s*\[[^\]]*\]', '"icon": []' | Set-Content -Path $windows_conf_path + .\script\sd.exe "`"icon`":\s(.*)`]" '"icon": []' $windows_conf_path # replace icon path with no regex .\script\sd.exe -s '"icon": []' "`"icon`": [`"png/${name}_256.ico`", `"png/${name}_32.ico`"]" $windows_conf_path # -- replace identifier -- # clear identifier with regex - (Get-Content -Path $windows_conf_path -Raw) -replace '"identifier":\s*"[^"]*"', '"identifier": ""' | Set-Content -Path $windows_conf_path + # (Get-Content -Path $windows_conf_path -Raw) -replace '"identifier":\s*"[^"]*"', '"identifier": ""' | Set-Content -Path $windows_conf_path + .\script\sd.exe "`"identifier`":\s`"(.*?)`"" '"identifier": ""' $windows_conf_path # -- replace identifier with no regex -- .\script\sd.exe -s '"identifier": ""' "`"identifier`": `"${identifier_prefix}.${name}`"" $windows_conf_path # -- replace icon resources -- # clear resources with regex - (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"resources":\s*\[[^\]]*\]', '"resources": []' | Set-Content -Path $windows_conf_path + #(Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"resources":\s*\[[^\]]*\]', '"resources": []' | Set-Content -Path $windows_conf_path + .\script\sd.exe "`"resources`":\s(.*)`]" '"resources": []' $windows_conf_path # replace resources with no regex .\script\sd.exe -s '"resources": []' "`"resources`": [`"png/${name}_32.ico`"]" $windows_conf_path @@ -93,27 +99,27 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { Write-Host "package build success!" Write-Host "" $index++ - # strip blank line for common_conf_path - $lines = Get-Content ${common_conf_path} - $lastNonEmptyLineIndex = ($lines.Count - 1) - while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { - $lastNonEmptyLineIndex-- - } - if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { - $lines = $lines[0..$lastNonEmptyLineIndex] - } - Set-Content -Path ${common_conf_path} -Value $lines + # # strip blank line for common_conf_path + # $lines = Get-Content ${common_conf_path} + # $lastNonEmptyLineIndex = ($lines.Count - 1) + # while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { + # $lastNonEmptyLineIndex-- + # } + # if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { + # $lines = $lines[0..$lastNonEmptyLineIndex] + # } + # Set-Content -Path ${common_conf_path} -Value $lines - # strip blank line for windows conf_path - $lines = Get-Content ${windows_conf_path} - $lastNonEmptyLineIndex = ($lines.Count - 1) - while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { - $lastNonEmptyLineIndex-- - } - if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { - $lines = $lines[0..$lastNonEmptyLineIndex] - } - Set-Content -Path ${windows_conf_path} -Value $lines + # # strip blank line for windows conf_path + # $lines = Get-Content ${windows_conf_path} + # $lastNonEmptyLineIndex = ($lines.Count - 1) + # while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { + # $lastNonEmptyLineIndex-- + # } + # if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { + # $lines = $lines[0..$lastNonEmptyLineIndex] + # } + # Set-Content -Path ${windows_conf_path} -Value $lines } Write-Host "output dir is output\windows" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index cad1afa..bd260ec 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,12 +1,12 @@ { "package": { - "productName": "", + "productName": "WeRead", "version": "1.0.0" }, "tauri": { "windows": [ { - "url": "https://riju.codes/", + "url": "https://weread.qq.com/", "transparent": true, "fullscreen": false, "width": 1200, @@ -28,5 +28,3 @@ "beforeDevCommand": "" } } - - diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index ca3d017..c95e88d 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -1,14 +1,14 @@ { "tauri": { "bundle": { - "icon": ["png/coderunner_256.ico", "png/coderunner_32.ico"], - "identifier": "com.tw93.coderunner", + "icon": ["png/weread_256.ico", "png/weread_32.ico"], + "identifier": "com.tw93.weread", "active": true, "category": "DeveloperTool", "copyright": "", "externalBin": [], "longDescription": "", - "resources": ["png/coderunner_32.ico"], + "resources": ["png/weread_32.ico"], "shortDescription": "", "targets": ["msi"], "windows": { From be8fddedddfd268f8d6c59029a217708207edd67 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 12:48:17 +0800 Subject: [PATCH 08/11] update powershell file for windows --- script/build.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/script/build.ps1 b/script/build.ps1 index eb4aefb..9e0bfb6 100644 --- a/script/build.ps1 +++ b/script/build.ps1 @@ -94,8 +94,6 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\wix\*.*" -Recurse -Force Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\app.*" -Force Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\resources" -Recurse -Force - Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\png" -Recurse -Force - Remove-Item -Path "src-tauri\target\x86_64-pc-windows-msvc\release\wix" -Recurse -Force Write-Host "package build success!" Write-Host "" $index++ From fe02ca29f0f9298af1171b6a1b7bc1ba3ad66a63 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 14:12:56 +0800 Subject: [PATCH 09/11] update powershell file for windows --- .github/workflows/pake_build.yaml | 3 ++- .github/workflows/pake_build_with_cache.yaml | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pake_build.yaml b/.github/workflows/pake_build.yaml index 6e53d7d..2b2f8ae 100644 --- a/.github/workflows/pake_build.yaml +++ b/.github/workflows/pake_build.yaml @@ -79,7 +79,8 @@ jobs: if: matrix.os == 'windows-latest' shell: pwsh run: | - npm run build:all-windows + $PSVersionTable + .\script\build.ps1 - name: Upload files env: diff --git a/.github/workflows/pake_build_with_cache.yaml b/.github/workflows/pake_build_with_cache.yaml index 96c0a2c..84932c6 100644 --- a/.github/workflows/pake_build_with_cache.yaml +++ b/.github/workflows/pake_build_with_cache.yaml @@ -76,8 +76,9 @@ jobs: if: matrix.os == 'windows-latest' shell: pwsh run: | - npm run build:all-windows - + $PSVersionTable + .\script\build.ps1 + - name: Upload files env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 772604d2814b615cd330968ee379f6903d36abee Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 15:47:02 +0800 Subject: [PATCH 10/11] update powershell file for windows --- .github/workflows/pake_build.yaml | 3 +- .github/workflows/pake_build_with_cache.yaml | 3 +- script/build.ps1 | 69 ++++++++++---------- src-tauri/tauri.windows.conf.json | 3 - 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/.github/workflows/pake_build.yaml b/.github/workflows/pake_build.yaml index 2b2f8ae..1cc7903 100644 --- a/.github/workflows/pake_build.yaml +++ b/.github/workflows/pake_build.yaml @@ -79,8 +79,7 @@ jobs: if: matrix.os == 'windows-latest' shell: pwsh run: | - $PSVersionTable - .\script\build.ps1 + build:all-windows - name: Upload files env: diff --git a/.github/workflows/pake_build_with_cache.yaml b/.github/workflows/pake_build_with_cache.yaml index 84932c6..4adb497 100644 --- a/.github/workflows/pake_build_with_cache.yaml +++ b/.github/workflows/pake_build_with_cache.yaml @@ -76,8 +76,7 @@ jobs: if: matrix.os == 'windows-latest' shell: pwsh run: | - $PSVersionTable - .\script\build.ps1 + build:all-windows - name: Upload files env: diff --git a/script/build.ps1 b/script/build.ps1 index 9e0bfb6..e71ae83 100644 --- a/script/build.ps1 +++ b/script/build.ps1 @@ -17,8 +17,13 @@ if (-not (Test-Path output\windows)) { Write-Host "`n=======================" Write-Host "build for windows" +Write-Host "make ture powershell == 7.2.10" +Write-Host "powershell 7.2.10 download url: https://github.com/PowerShell/PowerShell/releases/tag/v7.2.10" +Write-Host "Powershell info in your localhost " +$PSVersionTable Write-Host "=======================`n" + $identifier_prefix = "com.tw93" # total package number @@ -44,36 +49,34 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { Write-Host "==========================" # -- replace url -- # clear url with regex - .\script\sd.exe "`"url`":\s`"(.*?)`"" '"url": ""' $common_conf_path + (Get-Content -Path $common_conf_path -Raw) -replace '"url":\s*"[^"]*"', '"url": ""' | Set-Content -Path $common_conf_path # replace url with no regex - .\script\sd.exe -s '"url": ""' "`"url`": `"${url}`"" $common_conf_path + (Get-Content -Path $common_conf_path -Raw) | ForEach-Object { $_.Replace('"url": ""', "`"url`": `"${url}`"") } | Set-Content $common_conf_path + # replace package name # clear package_name with regex - .\script\sd.exe "`"productName`":\s`"(.*?)`"" '"productName": ""' $common_conf_path + (Get-Content -Path $common_conf_path -Raw) -replace '"productName":\s*"[^"]*"', '"productName": ""' | Set-Content -Path $common_conf_path # replace package_name with no regex - .\script\sd.exe -s '"productName": ""' "`"productName`": `"$title`"" $common_conf_path + (Get-Content -Path $common_conf_path -Raw) | ForEach-Object { $_.Replace('"productName": ""', "`"productName`": `"${title}`"") } | Set-Content $common_conf_path # -- replace icon -- # clear icon path with regex - # (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"icon":\s*\[[^\]]*\]', '"icon": []' | Set-Content -Path $windows_conf_path - .\script\sd.exe "`"icon`":\s(.*)`]" '"icon": []' $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"icon":\s*\[[^\]]*\]', '"icon": []' | Set-Content -Path $windows_conf_path # replace icon path with no regex - .\script\sd.exe -s '"icon": []' "`"icon`": [`"png/${name}_256.ico`", `"png/${name}_32.ico`"]" $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) | ForEach-Object { $_.Replace('"icon": []', "`"icon`": [`"png/${name}_256.ico`", `"png/${name}_32.ico`"]") } | Set-Content $windows_conf_path # -- replace identifier -- # clear identifier with regex - # (Get-Content -Path $windows_conf_path -Raw) -replace '"identifier":\s*"[^"]*"', '"identifier": ""' | Set-Content -Path $windows_conf_path - .\script\sd.exe "`"identifier`":\s`"(.*?)`"" '"identifier": ""' $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) -replace '"identifier":\s*"[^"]*"', '"identifier": ""' | Set-Content -Path $windows_conf_path # -- replace identifier with no regex -- - .\script\sd.exe -s '"identifier": ""' "`"identifier`": `"${identifier_prefix}.${name}`"" $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) | ForEach-Object { $_.Replace('"identifier": ""', "`"identifier`": `"${identifier_prefix}.${name}`"") } | Set-Content $windows_conf_path # -- replace icon resources -- # clear resources with regex - #(Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"resources":\s*\[[^\]]*\]', '"resources": []' | Set-Content -Path $windows_conf_path - .\script\sd.exe "`"resources`":\s(.*)`]" '"resources": []' $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"resources":\s*\[[^\]]*\]', '"resources": []' | Set-Content -Path $windows_conf_path # replace resources with no regex - .\script\sd.exe -s '"resources": []' "`"resources`": [`"png/${name}_32.ico`"]" $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) | ForEach-Object { $_.Replace('"resources": []', "`"resources`": [`"png/${name}_32.ico`"]") } | Set-Content $windows_conf_path if (-not (Test-Path "src-tauri\png\${name}_32.ico")) { Copy-Item "src-tauri\png\icon_32.ico" "src-tauri\png\${name}_32.ico" @@ -97,27 +100,27 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { Write-Host "package build success!" Write-Host "" $index++ - # # strip blank line for common_conf_path - # $lines = Get-Content ${common_conf_path} - # $lastNonEmptyLineIndex = ($lines.Count - 1) - # while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { - # $lastNonEmptyLineIndex-- - # } - # if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { - # $lines = $lines[0..$lastNonEmptyLineIndex] - # } - # Set-Content -Path ${common_conf_path} -Value $lines + # strip blank line for common_conf_path + $lines = Get-Content ${common_conf_path} + $lastNonEmptyLineIndex = ($lines.Count - 1) + while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { + $lastNonEmptyLineIndex-- + } + if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { + $lines = $lines[0..$lastNonEmptyLineIndex] + } + Set-Content -Path ${common_conf_path} -Value $lines - # # strip blank line for windows conf_path - # $lines = Get-Content ${windows_conf_path} - # $lastNonEmptyLineIndex = ($lines.Count - 1) - # while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { - # $lastNonEmptyLineIndex-- - # } - # if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { - # $lines = $lines[0..$lastNonEmptyLineIndex] - # } - # Set-Content -Path ${windows_conf_path} -Value $lines + # strip blank line for windows conf_path + $lines = Get-Content ${windows_conf_path} + $lastNonEmptyLineIndex = ($lines.Count - 1) + while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { + $lastNonEmptyLineIndex-- + } + if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { + $lines = $lines[0..$lastNonEmptyLineIndex] + } + Set-Content -Path ${windows_conf_path} -Value $lines } Write-Host "output dir is output\windows" diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index c95e88d..b46b429 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -23,6 +23,3 @@ } } } - - - From bfd040637d71a0558834d7ee227f6debb2cb5872 Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 15:51:36 +0800 Subject: [PATCH 11/11] update powershell file for windows --- .github/workflows/pake_build.yaml | 2 +- .github/workflows/pake_build_with_cache.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pake_build.yaml b/.github/workflows/pake_build.yaml index 1cc7903..6e53d7d 100644 --- a/.github/workflows/pake_build.yaml +++ b/.github/workflows/pake_build.yaml @@ -79,7 +79,7 @@ jobs: if: matrix.os == 'windows-latest' shell: pwsh run: | - build:all-windows + npm run build:all-windows - name: Upload files env: diff --git a/.github/workflows/pake_build_with_cache.yaml b/.github/workflows/pake_build_with_cache.yaml index 4adb497..db3ba57 100644 --- a/.github/workflows/pake_build_with_cache.yaml +++ b/.github/workflows/pake_build_with_cache.yaml @@ -76,7 +76,7 @@ jobs: if: matrix.os == 'windows-latest' shell: pwsh run: | - build:all-windows + npm run build:all-windows - name: Upload files env: