My day job is software development with modern languages. I have been promising myself for years that I would learn AppleScript and now I finally have some time to do it. I have a couple of scripts that I am happy with and that work, so now I am wondering how to do Source Code Control with AppleScript.
Modern software projects are just a bunch of text files that typically coexist together in a certain directory. It is easy to use a Source Code Control tool like git to keep versions of the code and store it in a safe place like Github. You can experiment in your sandbox without fear of breaking a functioning system. The thing I canāt yet grok about AppleScript is how to do that.
AppleScript favors a binary format, which certainly can be stored in git, but you canāt do a diff between one version and another. AppleScript wants to sprawl all over my file system, in a multitude of places like
~/Library/Scripts
~/Library/Script Libraries
~/Library/Scripts/Folder Action Scripts
If I want to experiment with new additions to a script that resides in one of these standard places, I have to risk breaking an existing setup to keep these required locations.
Has anyone come up with a good workflow to handle these issues?
So how does that workflow look? Lets say I create a new file in Script Editor as .applescript. While Iām in the code-test-debug cycle, donāt I need to save as a .scpt file? Or does that only need to occur when I want the script to be able to run stand-alone?
You can use .applescript files in Script Editor just as usual. Once you have a āreleaseā that you want to distribute, you could make a .scpt
Having said that, I donāt do a lot in AppleScript, so Iām not an expert, by far. Most of my AppleScripts are fine in plain-text files and I call them via osascript in shell scripts, etc.
Iād recommend taking a look at Late Night Softwareās Script Debugger help, and Dougās AppleScript - Using Script Editor (3 pages). They each give some insights into the pros and cons of the different save formats and what you can and cannot do with them.
A simple way to think about the .script vs. .applescript scenario is that you would strictly version control your source code, but when you compile it (AppleScript happens to support editing the ācompiledā script), you would probably just keep an archive/backup copy rather than apply the same level of version control; though of course you could - you just canāt work with the content in the same way.
can eliminate a lot of your applescript, especially if you have tools in other languages that do what you want (probably fasterā¦).
In the example above, I wouldnāt use applescript for the actual case transform. My ideal rule of thumb would be to only use AS where 1) data structures are too complex to convert or 2) I need to change the UI. In practice I use a lot more because iām lazy and familiar with it, but itās not an approach Iād recommend if you can do the same thing easily in a faster language.