nikivi Posted October 6, 2017 Share Posted October 6, 2017 I think it would be quite useful to include version number prepended to workflow file-name when exporting workflows that have a version set in them. Similar to how @deanishe does it here. I think it would be useful to know what version a workflow is when exporting them. Link to comment Share on other sites More sharing options...
vitor Posted October 6, 2017 Share Posted October 6, 2017 This makes little sense as an Alfred Feature Request. It’s just a name: if a developer wants to add the version number to it, they will. Similarly, if Alfred automatically added the version number on export, one could simply remove it and I would. deanishe 1 Link to comment Share on other sites More sharing options...
nikivi Posted October 6, 2017 Author Share Posted October 6, 2017 (edited) 21 minutes ago, vitor said: It’s just a name: if a developer wants to add the version number to it, they will That is true. It's just a bit cumbersome to do it every time. I don't actually add version numbers myself to the exports because of this reason. But I do think there is value in knowing the version of the workflow you are downloading. Edited October 6, 2017 by nikivi Link to comment Share on other sites More sharing options...
vitor Posted October 6, 2017 Share Posted October 6, 2017 1 hour ago, nikivi said: I don't actually add version numbers myself to the exports because of this reason. But I do think there is value in knowing the version of the workflow you are downloading. So you’re not asking for Alfred to add the version numbers; you’re asking for other developers to do it. That’s not a problem that can be solved by Alfred, or any technical means. Link to comment Share on other sites More sharing options...
nikivi Posted October 6, 2017 Author Share Posted October 6, 2017 21 minutes ago, vitor said: So you’re not asking for Alfred to add the version numbers; you’re asking for other developers to do it. No I was asking for Alfred to automatically prepend version number to exports. As it is tedious to add the version number yourself. Link to comment Share on other sites More sharing options...
vitor Posted October 6, 2017 Share Posted October 6, 2017 (edited) Here is an adapted version of the function I use to release my Workflows. Save it as workflow-packager, or something, and give it execution permissions (chmod +x workflow-packager). Then, whenever you’re in the top directory of a Workflow, in the terminal, run workflow-packager. It’ll package it up correctly — including removing variables that should not be exported — to your Desktop as Name-Version.alfredworkflow. I might release it properly in another post later. #!/bin/bash readonly workflow_dir="$(pwd)" if [[ "${workflow_dir}" != *'Alfred.alfredpreferences/workflows/user.workflow.'* ]] || [[ ! -f "${workflow_dir}/info.plist" ]]; then echo "You need to be inside the workflow’s root directory in Alfred’s preferences directory." >&2 exit 1 fi readonly workflow_name="$(/usr/libexec/PlistBuddy -c 'print name' "${workflow_dir}/info.plist")" readonly workflow_version="$(/usr/libexec/PlistBuddy -c 'print version' "${workflow_dir}/info.plist")" readonly workflow_file="${HOME}/Desktop/${workflow_name}-${workflow_version}.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 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 October 7, 2017 by vitor nikivi 1 Link to comment Share on other sites More sharing options...
nikivi Posted October 7, 2017 Author Share Posted October 7, 2017 Thank you @vitor. This is indeed really awesome. I now modified this awesome alfred extension to export the workflow with a modifier keypress using your script. Here is the modified workflow. The only disadvantage is that searching is super slow because I have so many workflows. Thank you again for sharing it. Link to comment Share on other sites More sharing options...
vitor Posted October 8, 2017 Share Posted October 8, 2017 Link to comment Share on other sites More sharing options...
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