-
Notifications
You must be signed in to change notification settings - Fork 2
Open
0 / 50 of 5 issues completedDescription
Critical pieces which currently only work from desktop:
shortcuts/lib/tasks/import.yaml
Lines 44 to 112 in 47a73c5
| extract: | |
| deps: [export-from-account] | |
| requires: | |
| vars: ["BUILD_DIR", "SHORTCUT_PATH"] | |
| cmds: | |
| - { silent: true, cmd: 'mkdir -p {{q .BUILD_DIR}}/{{q (dir .SHORTCUT_PATH)}}' } | |
| # https://github.com/0xilis/libshortcutsign/blob/753da95f42945ea76bc9ac8f5cccdfa31cc300cc/libshortcutsign.m#L330-L388 | |
| # `fq` below is https://github.com/wader/fq. | |
| - >- | |
| tmp=$(mktemp -d); | |
| cat {{q .IMPORT_DIR}}/{{q .SHORTCUT_PATH}}.shortcut | |
| | tee {{q .BUILD_DIR}}/{{q .SHORTCUT_PATH}}.shortcut | |
| | fq -r -d bytes '.[((.[0x8:0xC] | explode | reverse | tobytes | tonumber) + 0x495c):] | print' | |
| | lzfse -decode | |
| | aa extract -d "$tmp" | |
| && | |
| mv "$tmp"/Shortcut.wflow {{q .BUILD_DIR}}/{{q .SHORTCUT_PATH}}.wflow | |
| && | |
| cat {{q .BUILD_DIR}}/{{q .SHORTCUT_PATH}}.wflow | |
| | plutil -convert json -o - - | |
| | jq --sort-keys '(.WFWorkflowTypes, .WFWorkflowOutputContentItemClasses) |= sort' | |
| > {{q .BUILD_DIR}}/{{q .SHORTCUT_PATH}}-in.json | |
| init-sg-lang: | |
| internal: true | |
| run: once | |
| status: | |
| - ! test -e lib/ast-grep/custom-language/tree-sitter-jsonnet.so | |
| cmds: | |
| - > | |
| cd lib/ast-grep/custom-language/tree-sitter-jsonnet | |
| && npm install | |
| && TREE_SITTER_LIBDIR=build | |
| npm test | |
| default: | |
| desc: Imports a single Apple Shortcut at {{"{{.SHORTCUT_PATH}}"}} into `{{.SOURCE_DIR}}`. | |
| deps: | |
| - task: init-sg-lang | |
| - task: extract | |
| vars: | |
| SHORTCUT_PATH: '{{.SHORTCUT_PATH}}' | |
| requires: | |
| vars: ["SOURCE_DIR", "BUILD_DIR", "SHORTCUT_PATH"] | |
| vars: | |
| SRC: '{{.SOURCE_DIR}}/{{.SHORTCUT_PATH}}.jsonnet' | |
| PHASES: | |
| sh: find lib/ast-grep/rules/* -printf '%f\n' | cut -d- -f1 | sort -g | uniq | |
| cmds: | |
| - { silent: true, cmd: 'mkdir -p {{q .SOURCE_DIR}}/{{q (dir .SHORTCUT_PATH)}}' } | |
| - jsonnetfmt {{q .BUILD_DIR}}/{{q .SHORTCUT_PATH}}-in.json > {{q .SRC}} | |
| - for: { var: PHASES, as: PHASE, split: "\n" } | |
| cmd: >- | |
| seen=(); | |
| while true; do | |
| find lib/ast-grep/rules/{{.PHASE}}-* | |
| -exec sg scan --update-all --rule='{}' {{q .SRC}} \; | |
| -exec jsonnetfmt -i {{q .SRC}} \; | |
| || break; | |
| next_sha=$(sha1sum {{q .SRC}} | awk '{print $1}'); | |
| if printf '%s\n' "${seen[@]}" | grep -Fq "$next_sha"; then | |
| break; | |
| fi; | |
| seen+=("${next_sha:-}"); | |
| done; |
extract:
deps: [export-from-account]
requires:
vars: ["BUILD_DIR", "SHORTCUT_PATH"]
cmds:
- { silent: true, cmd: 'mkdir -p {{q .BUILD_DIR}}/{{q (dir .SHORTCUT_PATH)}}' }
# https://github.com/0xilis/libshortcutsign/blob/753da95f42945ea76bc9ac8f5cccdfa31cc300cc/libshortcutsign.m#L330-L388
# `fq` below is https://github.com/wader/fq.
- >-
tmp=$(mktemp -d);
cat {{q .IMPORT_DIR}}/{{q .SHORTCUT_PATH}}.shortcut
| tee {{q .BUILD_DIR}}/{{q .SHORTCUT_PATH}}.shortcut
| fq -r -d bytes '.[((.[0x8:0xC] | explode | reverse | tobytes | tonumber) + 0x495c):] | print'
| lzfse -decode
| aa extract -d "$tmp"
&&
mv "$tmp"/Shortcut.wflow {{q .BUILD_DIR}}/{{q .SHORTCUT_PATH}}.wflow
&&
cat {{q .BUILD_DIR}}/{{q .SHORTCUT_PATH}}.wflow
| plutil -convert json -o - -
| jq --sort-keys '(.WFWorkflowTypes, .WFWorkflowOutputContentItemClasses) |= sort'
> {{q .BUILD_DIR}}/{{q .SHORTCUT_PATH}}-in.json
init-sg-lang:
internal: true
run: once
status:
- ! test -e lib/ast-grep/custom-language/tree-sitter-jsonnet.so
cmds:
- >
cd lib/ast-grep/custom-language/tree-sitter-jsonnet
&& npm install
&& TREE_SITTER_LIBDIR=build
npm test
default:
desc: Imports a single Apple Shortcut at {{"{{.SHORTCUT_PATH}}"}} into `{{.SOURCE_DIR}}`.
deps:
- task: init-sg-lang
- task: extract
vars:
SHORTCUT_PATH: '{{.SHORTCUT_PATH}}'
requires:
vars: ["SOURCE_DIR", "BUILD_DIR", "SHORTCUT_PATH"]
vars:
SRC: '{{.SOURCE_DIR}}/{{.SHORTCUT_PATH}}.jsonnet'
PHASES:
sh: find lib/ast-grep/rules/* -printf '%f\n' | cut -d- -f1 | sort -g | uniq
cmds:
- { silent: true, cmd: 'mkdir -p {{q .SOURCE_DIR}}/{{q (dir .SHORTCUT_PATH)}}' }
- jsonnetfmt {{q .BUILD_DIR}}/{{q .SHORTCUT_PATH}}-in.json > {{q .SRC}}
- for: { var: PHASES, as: PHASE, split: "\n" }
cmd: >-
seen=();
while true; do
find lib/ast-grep/rules/{{.PHASE}}-*
-exec sg scan --update-all --rule='{}' {{q .SRC}} \;
-exec jsonnetfmt -i {{q .SRC}} \;
|| break;
next_sha=$(sha1sum {{q .SRC}} | awk '{print $1}');
if printf '%s\n' "${seen[@]}" | grep -Fq "$next_sha"; then
break;
fi;
seen+=("${next_sha:-}");
done;
Sub-issues
Metadata
Metadata
Assignees
Labels
No labels