Skip to content

Commit

Permalink
Chore: Add npm build support
Browse files Browse the repository at this point in the history
  • Loading branch information
Jvcon authored Jun 9, 2023
1 parent c85e847 commit 1fdec29
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- main
tags:
- 'v[0-9]+.[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+'

jobs:
build:
Expand Down
43 changes: 35 additions & 8 deletions EhAria2.ahk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; --------------------- COMPILER DIRECTIVES --------------------------

;@Ahk2Exe-SetDescription Enhanced Aria2AHK
;@Ahk2Exe-SetVersion 0.0.0.5
;@Ahk2Exe-SetVersion 0.0.6
;@Ahk2Exe-SetCopyright Jacques Yip
;@Ahk2Exe-SetMainIcon EhAria2.ico
;@Ahk2Exe-SetOrigFilename EhAria2.exe
Expand Down Expand Up @@ -121,11 +121,11 @@ global LangMenu := Menu()
WindowsTheme.SetAppMode(!sysThemeMode)

InitialLanguage()

CreateTrayMenu()
CreateLangMenu()
CreateProfileMenu()
CreateSpeedMenu()
InitialProxy()

; --------------------- Intial --------------------------
If (CONF.Setting.BTTrackers = "") {
Expand All @@ -134,7 +134,7 @@ If (CONF.Setting.BTTrackers = "") {

StartAria2()

return
Return

; --------------------- Func --------------------------
CreateTrayMenu(*){
Expand All @@ -147,9 +147,6 @@ CreateTrayMenu(*){
EhAria2Tray.Add(lTraySpeedLimit, SubMenuSpeed)
EhAria2Tray.Add(lTrayProfile, SubMenuProflie)
EhAria2Tray.Add(lTrayEnableProxy, SwitchProxyStatus)
If (CONF.Setting.Aria2ProxyEnable = 1) {
EhAria2Tray.Check(lTrayEnableProxy)
}
EhAria2Tray.Add(lTrayUpdateTrackerList, UpdateBTTracker)
EhAria2Tray.Add
EhAria2Tray.Add(lTrayExit, ExitTray)
Expand All @@ -164,6 +161,7 @@ CreateTrayMenu(*){
EhAria2Tray.Add
EhAria2Tray.Add(lTrayAddTorrent, AddTorrent)
EhAria2Tray.Add(lTrayAddTask, AddTaskMenuHandler)
return
}

CreateLangMenu(*) {
Expand All @@ -173,6 +171,7 @@ CreateLangMenu(*) {
LangMenu.Add(FileNameNoExt, SwitchLanguage)
}
LangMenu.Check(CONF.Setting.Language)
return
}

CreateProfileMenu(recreate := 0) {
Expand Down Expand Up @@ -375,6 +374,7 @@ SwitchSpeedLimit(ItemName := 0, ItemPos := 0, MyMenu := 0) {
CONF.Speed.CurrentSpeed := ItemPos
global CurrentSpeedName := IniRead(CONF_Path, "Speed", "SpeedName" . CONF.Speed.CurrentSpeed)
SubMenuSpeed.ToggleCheck(CurrentSpeedName)
CONF.WriteFile()
RestartAria2()
return
}
Expand All @@ -384,6 +384,7 @@ SwitchProfile(ItemName := 0, ItemPos := 0, MyMenu := 0) {
CONF.Profile.CurrentProfile := ItemPos
global CurrentProfileName := IniRead(CONF_Path, "Profile", "ProfileName" . CONF.Profile.CurrentProfile)
SubMenuProflie.ToggleCheck(CurrentProfileName)
CONF.WriteFile()
RestartAria2()
return
}
Expand All @@ -394,10 +395,27 @@ SwitchProxyStatus(*) {
} else {
CONF.Setting.Aria2ProxyEnable := 1
}
EhAria2Tray.ToggleCheck(lTrayEnableProxy)
CONF.WriteFile()
InitialProxy()
RestartAria2()
return
}

InitialProxy(*){
If (CONF.Setting.Aria2ProxyEnable = 1) {
If (!(CONF.Setting.Aria2Proxy = "")){
EhAria2Tray.Check(lTrayEnableProxy)
}
else{
MsgBox lMsgProxyError
}
}
else{
EhAria2Tray.Uncheck(lTrayEnableProxy)

}
}

UpdateBTTracker(ItemName := 0, ItemPos := 0, MyMenu := 0)
{
Download CONF.Setting.BTTrackersList, A_ScriptDir . "\TrackersLists.list"
Expand Down Expand Up @@ -445,6 +463,11 @@ StartAria2(*) {
If (CONF.Setting.Aria2RpcSecret != "") {
cmd .= " --rpc-secret=" CONF.Setting.Aria2RpcSecret
}
If (CONF.Setting.Aria2ProxyEnable = 1){
If (!(CONF.Setting.Aria2Proxy = "")){
cmd .= " --all-proxy=`"" CONF.Setting.Aria2Proxy "`""
}
}
cmd .= " --max-overall-download-limit=" . CurrentSpeedLimit
cmd .= " --max-download-limit=" . CurrentSpeedLimit
cmd .= " --dir=" . CurrentProfilePath
Expand Down Expand Up @@ -472,6 +495,7 @@ SwitchLanguage(ItemName, ItemPos, MyMenu) {
InitialLanguage()
CreateTrayMenu()
CreateLangMenu()
return
}

InitialLanguage(*) {
Expand All @@ -497,11 +521,14 @@ InitialLanguage(*) {
global lGuiUriInputBtnOK := IniRead(LANG_PATH, "GuiUriInput", "btnok")
global lGuiUriInputBtnCancel := IniRead(LANG_PATH, "GuiUriInput", "btncancel")
global lGuiUriInputTitle := IniRead(LANG_PATH, "GuiUriInput", "title")

global lMsgProxyError := IniRead(LANG_PATH, "Msg", "proxyerror")
return
}

ExitTray(*) {
CheckKillAria2()
CONF.WriteFile()
ExitApp
Return
}
}
4 changes: 2 additions & 2 deletions EhAria2Torrent.ahk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; --------------------- COMPILER DIRECTIVES --------------------------

;@Ahk2Exe-SetDescription Enhanced Aria2Torrent
;@Ahk2Exe-SetVersion 0.0.0.3
;@Ahk2Exe-SetVersion 0.0.6
;@Ahk2Exe-SetCopyright Jacques Yip
;@Ahk2Exe-SetMainIcon EhAria2Torrent.ico
;@Ahk2Exe-SetOrigFilename EhAria2Torrent.exe
Expand Down Expand Up @@ -61,4 +61,4 @@ HttpPost(URL, PData) {
WebRequest.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
WebRequest.Send(PData)
WebRequest.WaitForResponse(-1)
}
}
48 changes: 48 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Import-Module Microsoft.PowerShell.Utility

Write-Host "Version:" $args
$cwd = (Get-Location).Path
$ahkpath = "C:\Users\Jacques\scoop\apps\autohotkey\current"
$ahk2exe = $ahkpath + "\Compiler\Ahk2Exe.exe"
$ahk64base = $ahkpath + "\v2\AutoHotkey64.exe"
$command = $ahk2exe + " /silent verbose " + " /base " + $ahk64base + " /out $cwd\build\"

$setversion = ";@Ahk2Exe-SetVersion " + $args

Get-ChildItem $cwd\*.ahk | ForEach-Object {
(Get-Content $_) | ForEach-Object {$_ -Replace (";@Ahk2Exe-SetVersion " + '[0-9]+.[0-9]+.[0-9]+') , $setversion } | Set-Content $_
}

if (!(Test-Path -Path "$cwd\build")) {
mkdir $cwd\build
}

foreach ($file in (Get-ChildItem -Path $cwd\*.ahk)) {
Invoke-Expression($command + " /in $file")
}

while ( !(Test-Path -Path "$cwd\build\EhAria2.exe" )) {
Start-Sleep 1
}

while (!(Test-Path -Path "$cwd\build\EhAria2Torrent.exe")) {
Start-Sleep 1
}

if ((Test-Path -Path "$cwd\build\checksums_v$args.txt")) {
Remove-Item -Path $cwd\build\checksums_v$args.txt
}

if ((Test-Path -Path "$cwd\build\EhAria2_v$args.zip")) {
Remove-Item -Force -Path $cwd\build\EhAria2_v$args.zip
}

Compress-Archive -Path .\build\*.exe -DestinationPath .\build\EhAria2_v$args.zip

$value = (Get-FileHash -Path .\build\EhAria2_v$args.zip -Algorithm SHA256).Hash + " EhAria2_v$args.zip"
Tee-Object -Append -InputObject $value -FilePath $cwd\build\checksums_v$args.txt


foreach ($file in (Get-ChildItem -Path $cwd\build\*.exe)) {
Invoke-Expression("Remove-Item -Force -Path $file")
}
4 changes: 3 additions & 1 deletion lang/en_us.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ addtorrentto=Add Torrent to...
addtaskproxyto=Add Task with Proxy to ...
addtaskto=Add Task to ...
addtorrent=Add Torrent
addstask=Add Task
addstask=Add Task
[Msg]
proxyerror=Can't found any proxy address!
4 changes: 3 additions & 1 deletion lang/zh_cn.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ addtorrentto=添加种子至...
addtaskproxyto=添加任务(代理)至...
addtaskto=添加任务至...
addtorrent=添加种子
addstask=添加任务
addstask=添加任务
[Msg]
proxyerror=没有配置代理地址!
40 changes: 23 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
{
"name": "EhAria2",
"version": "0.0.0.3",
"description": "",
"main": "EhAria2.ahk",
"scripts": {
"name": "EhAria2",
"version": "0.0.6",
"description": "",
"main": "EhAria2.ahk",
"scripts": {
"start": "nodemon --exec EhAria2.ahk",
"test": "echo \"Error: no script specified\" && exit 1"
},
"nodemonConfig": {
"ignore": ["node_modules", "dist"],
"build": "@powershell -NoProfile -ExecutionPolicy Unrestricted -Command ./build.ps1 %npm_package_version%"
},
"nodemonConfig": {
"ignore": [
"node_modules",
"dist"
],
"delay": "250",
"watch": ["*", "scripts/*"],
"watch": [
"*",
"scripts/*"
],
"ext": "js, json, ahk, ini, conf"
},
"keywords": [],
"author": "",
"license": "",
"dependencies": {
},
"keywords": [],
"author": "",
"license": "",
"dependencies": {
"nodemon": "^2.0.22"
}
}
}
}

0 comments on commit 1fdec29

Please sign in to comment.