🔀 merge dev

This commit is contained in:
Tw93
2023-04-08 20:29:02 +08:00
38 changed files with 3162 additions and 973 deletions

99
script/build.bat vendored Normal file
View File

@@ -0,0 +1,99 @@
@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.
:: 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
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
::echo name is !name! !name_zh! !url!
:: replace url
.\script\sd.exe -s !old_url! !url! src-tauri\pake.json
::replace pacakge name
.\script\sd.exe !old_title! !title! src-tauri\tauri.conf.json
.\script\sd.exe !old_name! !name! src-tauri\tauri.conf.json
.\script\sd.exe !old_name! !name! src-tauri\tauri.windows.conf.json
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!
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"
::recovery code
.\script\sd.exe %url% %init_url% src-tauri\pake.json
.\script\sd.exe %title% %init_title% src-tauri\tauri.conf.json
.\script\sd.exe %name% %init_name% src-tauri\tauri.conf.json
.\script\sd.exe %name% %init_name% src-tauri\tauri.windows.conf.json

20
script/build.ps1 vendored
View File

@@ -29,6 +29,7 @@ $identifier_prefix = "com.tw93"
# total package number
$index = 1
$total = (Get-Content ./app.csv | Measure-Object -Line).Lines
$pake_conf_path = "src-tauri/pake.json"
$common_conf_path = "src-tauri/tauri.conf.json"
$windows_conf_path = "src-tauri/tauri.windows.conf.json"
@@ -47,20 +48,27 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) {
Write-Host "name_zh = ${name_zh}"
Write-Host "url = ${url}"
Write-Host "=========================="
# -- replace url --
# -- replace url -- #
# clear url with regex
(Get-Content -Path $common_conf_path -Raw) -replace '"url":\s*"[^"]*"', '"url": ""' | Set-Content -Path $common_conf_path
(Get-Content -Path $pake_conf_path -Raw) -replace '"url":\s*"[^"]*"', '"url": ""' | Set-Content -Path $pake_conf_path
# replace url with no regex
(Get-Content -Path $common_conf_path -Raw) | ForEach-Object { $_.Replace('"url": ""', "`"url`": `"${url}`"") } | Set-Content $common_conf_path
(Get-Content -Path $pake_conf_path -Raw) | ForEach-Object { $_.Replace('"url": ""', "`"url`": `"${url}`"") } | Set-Content $pake_conf_path
# replace package name
# -- 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
(Get-Content -Path $common_conf_path -Raw) | ForEach-Object { $_.Replace('"productName": ""', "`"productName`": `"${title}`"") } | Set-Content $common_conf_path
# -- replace icon --
# -- replace systemTray iconPath -- #
# clear systemTray iconPath with regex
(Get-Content -Path $common_conf_path -Raw) -replace '"iconPath":\s*"[^"]*"', '"iconPath": ""' | Set-Content -Path $common_conf_path
# replace systemTray iconPath with no regex
(Get-Content -Path $common_conf_path -Raw) | ForEach-Object { $_.Replace('"iconPath": ""', "`"iconPath`": `"png/${name}_32.ico`"") } | 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
# replace icon path with no regex
@@ -85,7 +93,7 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) {
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

23
script/build.sh vendored
View File

@@ -61,12 +61,12 @@ do
package_title=${arr[1]}
package_zh_name=${arr[2]}
url=${arr[3]}
# replace package info
# clear url with regex
$sd "\"url\": \"(.*?)\"," "\"url\": \"\"," src-tauri/tauri.conf.json
$sd "\"url\": \"(.*?)\"," "\"url\": \"\"," src-tauri/pake.json
# replace url with no regex
$sd -s "\"url\": \"\"," "\"url\": \"${url}\"," src-tauri/tauri.conf.json
$sd -s "\"url\": \"\"," "\"url\": \"${url}\"," src-tauri/pake.json
# for apple, need replace title
if [[ "$OSTYPE" =~ ^darwin ]]; then
@@ -106,14 +106,25 @@ do
echo "warning"
cp "src-tauri/png/icon_512.png" "src-tauri/png/${package_name}_512.png"
fi
# -- replace package name -- #
# clear package_name with regex
$sd "\"productName\": \"(.*?)\"," "\"productName\": \"\"," src-tauri/tauri.conf.json
# replace package_name with no regex
$sd -s "\"productName\": \"\"," "\"productName\": \"${package_prefix}-${package_name}\"," src-tauri/tauri.conf.json
# -- replace systemTray iconPath -- #
# clear systemTray iconPath with regex
$sd "\"iconPath\": \"(.*?)\"," "\"iconPath\": \"\"," src-tauri/tauri.conf.json
# replace systemTray iconPath with no regex
$sd -s "\"iconPath\": \"\"," "\"iconPath\": \"png/${package_name}_512.png\"," src-tauri/tauri.conf.json
# -- replace icon -- #
# clear icon path with regex
$sd "\"icon\": \[\"(.*?)\"\]," "\"icon\": [\"\"]," src-tauri/tauri.linux.conf.json
# replace icon path with no regex
$sd -s "\"icon\": [\"\"]," "\"icon\": [\"png/${package_name}_512.png\"]," src-tauri/tauri.linux.conf.json
# -- replace identifier -- #
# clear identifier with regex
$sd "\"identifier\": \"(.*?)\"," "\"identifier\": \"\"," src-tauri/tauri.linux.conf.json
# replace identifier with not regex
@@ -122,10 +133,10 @@ do
new_desktop="${PROJECT_FOLDER}/src-tauri/assets/${package_prefix}-${package_name}.desktop"
new_desktop_map_path="/usr/share/applications/${package_prefix}-${package_name}.desktop"
for file in `ls ${PROJECT_FOLDER}/src-tauri/assets/`
for file in `ls ${PROJECT_FOLDER}/src-tauri/assets/*.desktop`
do
mv "${PROJECT_FOLDER}/src-tauri/assets/${file}" "${new_desktop}"
echo mv "${PROJECT_FOLDER}/src-tauri/assets/${file}" "${new_desktop}"
mv "${file}" "${new_desktop}"
echo mv "${file}" "${new_desktop}"
done
# clear desktop file with regex
$sd "\"files\": \{\"(.*)\"\}" "\"files\": \{\"\"\}" src-tauri/tauri.linux.conf.json

BIN
script/sd.exe vendored

Binary file not shown.