robbielyman / seamstress

seamstress is an art engine
GNU General Public License v3.0
129 stars 12 forks source link

feat: semantic versioning check #93

Closed dndrks closed 1 year ago

dndrks commented 1 year ago

this PR adds a check for a seamstress.version_required string outside of a script's init function, to determine if the installed instance of seamstress matches the requirements of the script. if this check fails, the script init() is not executed and an error is printed to the REPL.

test script

seamstress.version_required = "1.0.7" -- replace with different semantic version strings

function init()
  print("script loaded!")
end

testing with 1.0.5

failed

seamstress.version_required = "1.0.7" fails with:

seamstress version: 1.0.5
!!! this script (<scriptname>) requires seamstress version 1.0.7
!!! script not initialized, please update seamstress

seamstress.version_required = "2.0.5" fails with:

seamstress version: 1.0.5
!!! this script (<scriptname>) requires seamstress version 2.0.5
!!! script not initialized, please update seamstress

seamstress.version_required = "1.1" fails with:

seamstress version: 1.0.5
!!! this script (<scriptname>) requires seamstress version 1.1
!!! script not initialized, please update seamstress

passed

robbielyman commented 1 year ago

elegant parsing, love it! thank you!!