shawnrice / alfred-bundler

a utility / workflow to handle dependencies
MIT License
21 stars 3 forks source link

Applescript Libraries #69

Closed fractaledmind closed 10 years ago

fractaledmind commented 10 years ago

I want to provide access to a few key Applescript libraries that have functions for a lot of standard work in Applescript. I want to make sure I implement this properly. Obviously they should be housed at ~/.../alfred.bundler-{version}/data/assets/applescript. In order to have them "bundled" with the Bundler (i.e. added on installation), I need to [1] save them to the repo, and [2] generate the proper JSON file for each, correct? Is there any thing else?

My plan right now is merely to package the scripts here: http://applescript.bratis-lover.net/library/

I use these functions all of the time when I write Applescript. They should be a part of the bundler.

shawnrice commented 10 years ago

Just create a JSON file for each. The JSON files are located in bundler/meta/defaults. Look at the ones that exist. Probably the most relevant is the Workflows.json. You can see how others work as well. As long as you set the type to applescript in the JSON, then they'll be installed into ..../data/assets/applescript.

fractaledmind commented 10 years ago

But, these files don't exist anywhere currently. So we will need to host them in the repo. That will work, right?

shawnrice commented 10 years ago

For the AS, you could have a "library" function that would do the loading. Basically, if you need set _string to load script alias ((path to desktop as text) & "_string.scpt") to load a library, then you could change it to set _string to B's library "_string".

shawnrice commented 10 years ago

The JSON files? They need to go in the bundler/meta/defaults. The JSON will just have the instructions on how to download them from the site that you just linked to.

shawnrice commented 10 years ago

Basically, the JSON files will look pretty much like this:

{
    "name": "_string",
    "type": "applescript",
    "versions": {
        "latest": {
            "invoke": "_string.scpt",
            "files": [
                {
                    "url": "http://applescript.bratis-lover.net/library/string/_string.scpt.zip",
                    "method": "zip"
                }
            ],
            "install": [
                "cp -f '__CACHE__/_string.scpt' '__DATA__'"
            ]
        }
    }
}

You just need to make sure that the URL is right, and you'll be using zip as the method because (I think) they're all zip files to download. Then, you just need to make sure that the install gets the right file name.

Oh, and the filename needs to match the name value. So this one would have to be saved as _string.json.

fractaledmind commented 10 years ago

No. The actual .scpt files. That site is just text. What I'll do is make the files. Create a repo, and download from there. That way, it's kept separate from the Bundler as a whole.

shawnrice commented 10 years ago

You can download the actual .scpt files from the site.

Try this download link.

fractaledmind commented 10 years ago

Oh. I see what you're saying. Got it now. Thank you.

fractaledmind commented 10 years ago

Can I change the names, both of the JSON file and of the asset, so long as the URL as correct? I'd like to add something to mark them as AppleScript. Or is that unnecessary?

shawnrice commented 10 years ago

The name of the file needs to match the name in the "name" field, which is the name that the workflow author uses to load. So, we could call Pashua mycoolthing as long as the JSON was named mycoolthing.json and the "name" value in the JSON was mycoolthing. Then, people would load it with load utility mycoolthing... even though it would load Pashua.

fractaledmind commented 10 years ago

Well, for now, I say we just keep the default names as they are on the website. But thanks for the info.