I’m trying to define a decent workflow that allows me to develop and maintain non-trivial scripts and script libraries. One of the key tools in this sense is a version control system (Git in my case). I have some trouble, however, making AppleScript and Git good friends. And no, it’s not AS Editor reformatting the source code
Does anyone have any experience to share in this sense?
To be more specific, suppose that I want to develop an AS script Foo that makes use of a script library Lib. Since the components must be distributed together, the obvious choice is to make Foo a script bundle (or an application) and to embed Lib in it. In the simplest case, the directory structure of the built product would be like this:
Foo.scptd
__Contents
____Info.plist
____Resources
______Scripts
________main.scpt
______Script Libraries
________Lib.scptd
__________Contents
____________Info.plist
____________Resources
______________Scripts
________________main.scpt
There are two problems with keeping this under version control:
- The two main scripts are binary files, making it impossible to diff with previous versions (they might even be execute-only);
- AS Editor writes the position of the text editor’s window into Info.plist, so Info.plist files change every time a window is moved or resized.
While (2) can be solved by using a different editor, I don’t know how to solve (1). In principle, all I need to keep under version control are Foo.applescript and Lib.applescript. The problem is, I can’t build Foo.scptd from Foo.applescript, because Foo.applescript contains a use Lib instruction and of course Lib can’t be searched in Foo’s bundle because the bundle does not exist yet. Result: Foo.applescript cannot be compiled. As a workaround, I might temporarily put Lib.scptd in a shared location, say ~/Library/Script Libraries, but that is a bit cumbersome, and prone to errors: what if I compile Foo with the shared version of Lib and then I put a different version in its bundle? Another possibility is to keep the above directory structure under version control and, in addition, periodically export the script bundles to text format to separately commit them into the repository. That is also not very convenient.
Do you have other ideas?
[Edit] Fixed directory structure