Skip to content

Commit

Permalink
Local-Client&Specs: update 'Tool\Other' pack type
Browse files Browse the repository at this point in the history
  • Loading branch information
joedf committed Jun 24, 2014
1 parent 866c910 commit 16e9b44
Show file tree
Hide file tree
Showing 12 changed files with 138 additions and 32 deletions.
6 changes: 4 additions & 2 deletions Local-Client/Lib/Install.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
,Error_DeleteStdLib: 0x0B
,Error_DeleteStdLibSubDir: 0x0C
,Error_DeleteRepoSubDir: 0x0D
,Error_AhkVersionInvalid: 0x0E
,Error_NoAction: 0x0F
,Error_ToolInstallScript: 0x0E
,Error_ToolRemoveScript: 0x0F
,Error_AhkVersionInvalid: 0x10
,Error_NoAction: 0x11
,Error_RunInstaller: "ERROR"
,Success: 0xDEAD } ;random chosen value, "Maximum" value is 0x80000000
;see http://msdn.microsoft.com/en-us/library/system.environment.exitcode.aspx
Expand Down
13 changes: 13 additions & 0 deletions Local-Client/Package_Builder.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,19 @@ Build:
else
{
jdata:=Manifest_FromFile(SelectedFile)

if Instr(jdata.type,"Lib") {
if !FileExist(package_dir "\Lib") {
MsgBox, 48, , 'Library' type packages must have a '\Lib' folder.`nPlease try again.
return
}
} else {
if ( !FileExist(package_dir "\Execute.ahk") || !FileExist(package_dir "\Install.ahk") || !FileExist(package_dir "\Remove.ahk") ) {
MsgBox, 48, , 'Tool/Other' type packages must have the following files:`n`n`tExecute.ahk`n`tInstall.ahk`n`tRemove.ahk`n`nPlease try again.
return
}
}

_package_out_name := RegExReplace(jdata.id,"\W")
FileSelectFile, outP, S18, %_package_out_name%.ahkp, Save the built package file, AHKP file (*.ahkp)
if outP =
Expand Down
29 changes: 21 additions & 8 deletions Local-Client/Package_Installer.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,32 @@ for Current, FilePath in packs
FileCreateDir, % ExtractDir := Local_Repo "\" mdata["id"]
if ErrorLevel
ExitApp, % Install.Error_CreateRepoSubDir
RepoSubDir := ExtractDir "\Lib"

;Extract package to local repo
if !Package_Extract(ExtractDir, FilePath)
ExitApp, % Install.Error_Extraction

;Copy data from local repo "Lib\" to StdLib "Lib\"
FileCopyDir,%RepoSubDir%,%InstallationFolder%,1
if ErrorLevel
{
;Delete or clean before exit
FileRemoveDir,%ExtractDir%,1
ExitApp, % Install.Error_CopyToStdLib
if (Instr(mdata["type"],"Lib")) { ;if package type is 'library'
;Copy data from local repo "Lib\" to StdLib "Lib\"
RepoSubDir := ExtractDir "\Lib"
FileCopyDir,%RepoSubDir%,%InstallationFolder%,1
if ErrorLevel
{
;Delete or clean before exit
FileRemoveDir,%ExtractDir%,1
ExitApp, % Install.Error_CopyToStdLib
}
} else { ;'Tool/Other' type package
try_install_tool:
RunWait, %ExtractDir%\Install.ahk, %ExtractDir%, UseErrorLevel
if ( ErrorLevel || ErrorLevel=="ERROR" ) { ;Install Script failure
_tmpname:=mdata["id"]
MsgBox, 20, , The '%_tmpname%' tool install script has failed.`nTry again?`n`nError code: [%ErrorLevel%]
ifMsgBox, Yes
goto,try_install_tool
else
ExitApp, % Install.Error_ToolInstallScript
}
}

;delete key in case of "double-install"
Expand Down
57 changes: 36 additions & 21 deletions Local-Client/Package_Remover.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,47 @@ for Current, id_akhp in packs

;Setup Deletion Lists
RepoSubDir := Local_Repo "\" mdata["id"]
RepoSubDirLib := RepoSubDir "\Lib"
if (!FileExist(RepoSubDirLib))
ExitApp, % Install.Error_NonExistantDir
RemList:=Object()
Loop, %RepoSubDirLib%\*, 1, 0
{
RemList.Insert(A_LoopFileName)
}

;Delete files in StdLib folder
For each, file in RemList
{
if (_fAttrib:=FileExist(InstallationFolder "\" file))

if (Instr(mdata["type"],"Lib")) { ;if package type is 'library'
RepoSubDirLib := RepoSubDir "\Lib"
if (!FileExist(RepoSubDirLib))
ExitApp, % Install.Error_NonExistantDir
RemList:=Object()
Loop, %RepoSubDirLib%\*, 1, 0
{
if (InStr(_fAttrib, "D")) {
FileRemoveDir,%InstallationFolder%\%file%,1
if ErrorLevel
ExitApp, % Install.Error_DeleteStdLibSubDir
}
else
RemList.Insert(A_LoopFileName)
}

;Delete files in StdLib folder
For each, file in RemList
{
if (_fAttrib:=FileExist(InstallationFolder "\" file))
{
FileDelete,%InstallationFolder%\%file%
if ErrorLevel
ExitApp, % Install.Error_DeleteStdLib
if (InStr(_fAttrib, "D")) {
FileRemoveDir,%InstallationFolder%\%file%,1
if ErrorLevel
ExitApp, % Install.Error_DeleteStdLibSubDir
}
else
{
FileDelete,%InstallationFolder%\%file%
if ErrorLevel
ExitApp, % Install.Error_DeleteStdLib
}
}
}
} else { ;'Tool/Other' type package
try_remove_tool:
RunWait, %ExtractDir%\Remove.ahk, %ExtractDir%, UseErrorLevel
if ( ErrorLevel || ErrorLevel=="ERROR" ) { ;Remove Script failure
_tmpname:=mdata["id"]
MsgBox, 20, , The '%_tmpname%' tool remove script has failed.`nTry again?`n`nError code: [%ErrorLevel%]
ifMsgBox, Yes
goto,try_remove_tool
else
ExitApp, % Install.Error_ToolRemoveScript
}
}

;Delete data in local repo "[ID]\"
Expand Down
8 changes: 8 additions & 0 deletions Local-Client/Test_Packages/sample_tool/execute.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;Launch script

#NoEnv
#NoTrayIcon
#SingleInstance,off
SetWorkingDir %A_ScriptDir%
RunWait,files\main_script.ahk
ExitApp
10 changes: 10 additions & 0 deletions Local-Client/Test_Packages/sample_tool/files/main_script.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn ; Recommended for catching common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;<<<<<<<< HEADER END >>>>>>>>>

FileRead,stuff,some_text.txt
MsgBox Sample tool`n`nContents of "some_text.txt" :`n`n%stuff%

ExitApp
4 changes: 4 additions & 0 deletions Local-Client/Test_Packages/sample_tool/files/some_text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1234567890
abcdefghijklmnopqrstuvwxyz
ABCDEFGHIJKLMNOPQRSTUVWXYZ
!@#$%^&*()`~-_=+,./<>?;'\:"|[]{}
1 change: 1 addition & 0 deletions Local-Client/Test_Packages/sample_tool/install.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
;empty since no registry or any special handling is needed.
26 changes: 26 additions & 0 deletions Local-Client/Test_Packages/sample_tool/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"ahkbranch":"v1.1",
"ahkflavour":[
"a32",
"u32",
"u64"
],
"ahkversion":"1.1.15.00",
"author":"Joe DF",
"description":"This is a sample description.\nThis is the second sentence of this description.",
"forumurl":"http:\/\/forum.com\/?topic=1234",
"id":"sample_tool",
"license":"ASPDM Default License",
"name":"Sample tool",
"required":{

},
"screenshot":"",
"tags":[
"sample",
"tool",
"test"
],
"type":"Tool",
"version":"1.0.0.0"
}
1 change: 1 addition & 0 deletions Local-Client/Test_Packages/sample_tool/remove.ahk
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
;empty since no registry or any special handling is needed.
12 changes: 12 additions & 0 deletions Specifications/Database.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ _**Licenses :**_ packages submitted to ahkscript.org without the license attribu
Package Structure
-------------------

### 'Library' packages

Library packages should have a standard package structure consisting of the following folders:

- `Lib\` (*Mandatory*) : StdLib files
Expand All @@ -62,6 +64,16 @@ Library packages should have a standard package structure consisting of the foll

_Note:_ When installing a package into a StdLib folder, the files in the package's `Lib\` folder would be copied to it.

### 'Tool/Other' packages

Tool/Other packages should have a standard package structure consisting of the following:

- `Install.ahk` (*Mandatory*) : Executed on package installation
- `Remove.ahk` (*Mandatory*) : Executed on package removal
- `Execute.ahk` (*Mandatory*) : Execute the tool
- `Doc\` : Documentation
- Root folder : Examples, etc.

Package File Format
-------------------

Expand Down
3 changes: 2 additions & 1 deletion Specifications/Guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ Submission
----------

- Any package can be submitted to the repository, and should meet all mandatory requirements in the Package Quality Guidelines section.
- All packages must have the mandatory `Lib\` folder. See [Package Structure](Database.md)
- All 'library' packages must have the mandatory `Lib\` folder. See [Package Structure](Database.md)
- All 'tool/other' packages must have the mandatory `Install.ahk`, `Remove.ahk` and `Execute.ahk` files. See [Package Structure](Database.md)
- All packages should be submitted with a license. Those submitted without a license are assumed to be released under the [ahkscript.org Default Package License](License.md).
- Package author is included in the package metadata.
- (In case of moderation queue):
Expand Down

4 comments on commit 16e9b44

@perfaram
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great !

@joedf
Copy link
Member Author

@joedf joedf commented on 16e9b44 Jun 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, ASPDM is coming along well! 👍

@fincs
Copy link
Contributor

@fincs fincs commented on 16e9b44 Jun 26, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep up the good work! I've just opened #9, #10 and #11, since these are things that IMO need to be changed or added.
In the future I may choose to deploy SciTE4AHK using ASPDM.

@joedf
Copy link
Member Author

@joedf joedf commented on 16e9b44 Jun 27, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! ... and thanks! I will check them out. 😄

Please sign in to comment.