maestro icon indicating copy to clipboard operation
maestro copied to clipboard

Add support for string interpolation in runScript file names

Open Dambakk opened this issue 6 months ago • 4 comments

Proposed changes

Will enable runScript commands to have js string interpolation in their file names. Example:

appId: com.example.app
env:
    SCRIPT_FILE: 125_myScript.js
---
- runScript: 125_myScript.js
- runScript:
      file: ${SCRIPT_FILE}
- runScript: ${ (120 + 5) + '_myScript.js' }
- evalScript: ${ output.somePath = "125_myScript.js" }
- runScript: ${ output.somePath }

This change moves some file handling from the orchestra module to the orchestra-models module (including the corresponding InvalidFlowFile exception), to be able to read the script files after the jsEngine has done its magic and applied any string interpolation. This, however, means that any "file not found" issues are now not reported until runtime instead of when the maestro command is ran. After quick discussion with Dan Caseley, we figured this would be an acceptable tradeoff.

Testing

I've added a test to the integration test suite, and built the Maestro CLI locally and tested on some sample flow.

Issues fixed

This change does not fully fix a single issue, but is a partial fix or the beginning on a fix to the following issues:

  • Discussing runFlow and runScript: https://github.com/mobile-dev-inc/Maestro/issues/2012
  • Discussing runFlow: https://github.com/mobile-dev-inc/Maestro/issues/1314

Dambakk avatar Jun 19 '25 06:06 Dambakk

Thanks for having a look at this, hope we can get it merged soon! 🙏

Dambakk avatar Dec 09 '25 10:12 Dambakk

@Dambakk You'll note that I moved the tests from 125 to 131 in my previous rebase, and that the next rebase will need to increment them further. I hate the sequencing in that file...

Fishbowler avatar Dec 09 '25 10:12 Fishbowler

Yeah, that looks like a bit of a hazzle..

Dambakk avatar Dec 09 '25 11:12 Dambakk

Is there anything I can do to help get this through? @Fishbowler

Dambakk avatar Dec 12 '25 07:12 Dambakk