Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Custom actions aren't detected as used when only used inside other custom actions #58

Closed
NoelTautges opened this issue May 29, 2024 · 0 comments · Fixed by #61
Closed
Labels
bug Something isn't working

Comments

@NoelTautges
Copy link
Contributor

Describe the bug

When you only use a custom action in another custom action, it won't get marked as used, even if the custom action that used it is used. Such a Shortcut will compile, but the custom action won't be included, leaving the custom action that uses it to call it in vain.

To Reproduce

action test1() {
	output("Testing!")
}

action test2() {
	const ret = test2()
	output(ret)
}

test2()

Debug output

Parsing nested_usage.cherri...
Parsing includes...
### INCLUDES ###

## INCLUDED ##
[]

## INCLUDES MAP ##
[]

Done.

### CUSTOM ACTIONS ###

identifier: test1()
used: false
parameters:
[]
body:
output("Testing!")
(end)

identifier: test2()
used: true
parameters:
[]
body:
const ret = test2()
        output(ret)
(end)

if ShortcutInput {
    const _cherri_inputType = typeOf(ShortcutInput)
    if _cherri_inputType == "Dictionary" {
        const _cherri_input = getDictionary(ShortcutInput)
        const _cherri_identifier = getValue(_cherri_input, "cherri_functions")
        const _cherri_valid = number(_cherri_identifier)
        if _cherri_valid == true {
            const _cherri_function = getValue(_cherri_input, "function")
            const _cherri_function_name = "{_cherri_function}"
            const _cherri_function_args = getValue(_cherri_input, "arguments")
            if _cherri_function_name == "test2" {
const ret = test2()
        output(ret)
            }
            output(nil)
        }
    }
}









test2()

### PARSING ###

Previous Character:
) 29:0

Current Character:
EMPTY 29:0

Current Line:

## TOKENS ##
 1 | {conditional fe7a3963-5a46-454b-a2d6-7e4fc8b5f3ad if {variable ShortcutInput 100  <nil>  <nil>}}
 2 | {variable _cherri_inputType action {typeOf [{variable ShortcutInput}]}}
 3 | {conditional 8ab2e7b8-a29e-4901-86ba-3791916dbc33 if {variable _cherri_inputType 4 text Dictionary  <nil>}}
 4 | {variable _cherri_input action {getDictionary [{variable ShortcutInput}]}}
 5 | {variable _cherri_identifier action {getValue [{variable _cherri_input} {text cherri_functions}]}}
 6 | {variable _cherri_valid action {number [{variable _cherri_identifier}]}}
 7 | {conditional d6967cf2-f00f-48a0-9911-ed1dd9156e70 if {variable _cherri_valid 4 bool %!s(bool=true)  <nil>}}
 8 | {variable _cherri_function action {getValue [{variable _cherri_input} {text function}]}}
 9 | {variable _cherri_function_name text {_cherri_function}}
10 | {variable _cherri_function_args action {getValue [{variable _cherri_input} {text arguments}]}}
11 | {conditional fbce5f50-6c67-4a69-a3de-448362be9ed2 if {variable _cherri_function_name 4 text test2  <nil>}}
12 | {variable _test2_cherri_call dictionary map[arguments:[] cherri_functions:%!s(float64=1) function:test2]}
13 | {variable ret action {runSelf [{variable _test2_cherri_call}]}}
14 | {action output action {output [{variable ret}]}}
15 | {action nothing action {nothing []}}
16 | {conditional fbce5f50-6c67-4a69-a3de-448362be9ed2 endif <nil>}
17 | {action output action {output [{nil <nil>}]}}
18 | {action nothing action {nothing []}}
19 | {conditional d6967cf2-f00f-48a0-9911-ed1dd9156e70 endif <nil>}
20 | {action nothing action {nothing []}}
21 | {conditional 8ab2e7b8-a29e-4901-86ba-3791916dbc33 endif <nil>}
22 | {action nothing action {nothing []}}
23 | {conditional fe7a3963-5a46-454b-a2d6-7e4fc8b5f3ad endif <nil>}
24 | {variable _test2_cherri_call dictionary map[arguments:[] cherri_functions:%!s(float64=1) function:test2]}
25 | {action runSelf action {runSelf [{variable _test2_cherri_call}]}}

## DEFINITIONS ##
Name: nested_usage
Color: -1263359489
Glyph: 61440
Inputs: []
Outputs: []
Workflows: []
No Input: { []}
macOS Only: false
Mininum Version: 2106.0.3
iOS Version: 17.0

## VARIABLES ##
const _cherri_function = {getValue [{variable _cherri_input} {text function}]} (action)
const _cherri_function_args = {getValue [{variable _cherri_input} {text arguments}]} (action)
const ret = {runSelf [{variable _test2_cherri_call}]} (action)
const _cherri_inputType = {typeOf [{variable ShortcutInput}]} (action)
const _cherri_valid = {number [{variable _cherri_identifier}]} (action)
const _cherri_function_name = {_cherri_function} (text)
const test2 = map[arguments:[] cherri_functions:%!s(float64=1) function:test2] (dictionary)
const _cherri_input = {getDictionary [{variable ShortcutInput}]} (action)
const _cherri_identifier = {getValue [{variable _cherri_input} {text cherri_functions}]} (action)

## MENUS ##
map[]

## IMPORT QUESTIONS ##
map[]

Done.

Generating plist...### PLIST GEN ###

## UUIDS ##
map[_cherri_function:1db73339-c177-48ec-88da-12c3a86033ad _cherri_function_args:2074b9a5-e16b-4a68-8c4a-270669e15a27 _cherri_function_name:f1ddb302-cf97-40de-a0c8-746a6d579909 _cherri_identifier:e1ec7f10-feb0-4752-9d27-f2a298f038d5 _cherri_input:46d6f3eb-3d45-4597-bcc1-aa1e8884eb72 _cherri_inputType:5aa66a29-788f-46ae-8851-8f2bff964a17 _cherri_valid:884c2c18-7567-4614-87a5-31b1c638fcbe _test2_cherri_call:427d8f74-37a1-4ab7-af2f-a59814483973 ret:7bdbad57-ad60-4fb3-8f1f-95a697d478a4]

Done.

Writing to nested_usage.plist...Done.
Writing to nested_usage_unsigned.shortcut...Done.
Warning: macOS is required to sign shortcuts. The compiled Shortcut will not run on iOS 15+ or macOS 12+.

However...
NEW! Use --hubsign to use RoutineHub's remote service to sign the compiled Shortcut.

Expected behavior

I expected the action to be marked as used and included in the compiled Shortcut. Instead, its invocation is included, but the action isn't.

Screenshots

Pictured: test2 is the only function included in the compiled Shortcut.

image

Version Information:

  • Linux version): Linux cs-171148009998-default 6.1.77+ #1 SMP PREEMPT_DYNAMIC Sat May 4 16:42:09 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
  • Golang version: go version go1.22.3 linux/amd64

Additional context

The checkCustomActionUsage function used to determine whether custom actions are included in the compiled Shortcut or not checks if any actions are used in contents, but by this point, contents has already been razed of custom actions, which means that uses in the bodies of custom actions aren't counted.

I made a fix for this that I'll be getting up later today! It's of dubious quality, though.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
1 participant