vitor Posted October 8, 2017 Share Posted October 8, 2017 (edited) Occasionally there comes a user tired of packaging Workflows by using Alfred’s GUI. Maybe they’ve been developing a bunch of Workflows in a row, or maybe they’ve been making a lot of changes to the same one, but they’ll then ask about a way of doing it programatically. This is a post to address that, to easily link people to. Copy the code below, save it as workflow-packager and put it in your PATH. Whenever you’re in your terminal, in the top directory of a Workflow, you need only run workflow-packager and it’ll save the packaged Workflow to your Desktop. #!/bin/bash readonly workflow_dir="$(pwd)" if [[ ! -f "${workflow_dir}/info.plist" ]]; then echo "You need to be inside the workflow’s root directory." >&2 exit 1 fi readonly workflow_name="$(/usr/libexec/PlistBuddy -c 'print name' "${workflow_dir}/info.plist")" readonly workflow_file="${HOME}/Desktop/${workflow_name}.alfredworkflow" find "${workflow_dir}" -iname '.DS_Store' -delete if /usr/libexec/PlistBuddy -c 'Print variablesdontexport' "${workflow_dir}/info.plist" &> /dev/null; then readonly workflow_dir_to_package="$(mktemp -d)" cp -R "${workflow_dir}/"* "${workflow_dir_to_package}" readonly tmp_info_plist="${workflow_dir_to_package}/info.plist" /usr/libexec/PlistBuddy -c 'print variablesdontexport' "${tmp_info_plist}" | grep ' ' | sed -E 's/ {4}//' | xargs -I {} /usr/libexec/PlistBuddy -c "set variables:'{}' ''" "${tmp_info_plist}" else readonly workflow_dir_to_package="${workflow_dir}" fi if DITTONORSRC=1 ditto -ck "${workflow_dir_to_package}" "${workflow_file}"; then echo "Created ${workflow_file}" exit 0 else echo "There was and error creating ${workflow_file}." >&2 exit 1 fi Edited December 28, 2017 by vitor nikivi and deanishe 2 Link to comment
deanishe Posted October 8, 2017 Share Posted October 8, 2017 (edited) 11 hours ago, vitor said: [[ "${workflow_dir}" != *'Alfred.alfredpreferences/workflows/user.workflow.'* ]] I think you should remove this check. The info.plist one should be sufficient. A lot of developers keep their workflow source code in ~/Code or similar and symlink the directory to Alfred's workflows folder. Also, the smart ones name the symlink (or indeed all their workflows' folders) after the bundle ID instead of using Alfred's meaningless, random folder names. Edited October 8, 2017 by deanishe Link to comment
vitor Posted October 8, 2017 Author Share Posted October 8, 2017 2 hours ago, deanishe said: I think you should remove this check. The info.plist one should be sufficient. A lot of developers keep their workflow source code in ~/Code or similar and symlink the directory to Alfred's workflows folder. Also, the smart ones name the symlink (or indeed all their workflows' folders) after the bundle ID instead of using Alfred's meaningless, random folder names. Agreed. Made the change. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now