From 7172b54a4df91cba350e602422504248c580ce08 Mon Sep 17 00:00:00 2001 From: Joshua Willing Date: Thu, 17 Oct 2024 18:24:57 -0700 Subject: [PATCH] add generate-script-steps script --- package.json | 1 + scripts/generate-script-steps.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 scripts/generate-script-steps.js diff --git a/package.json b/package.json index 811e934..358828f 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "deploy-to-fm": "npm run build && npm run upload", "build": "parcel build index.html", "upload": "node ./scripts/upload", + "generate-script-steps": "node ./scripts/generate-script-steps", "clear-cache": "rm -rf .parcel-cache dist", "reset-dev": "npm run clear-cache && npm run start", "start-fm-dev": "node ./scripts/start-fm-dev", diff --git a/scripts/generate-script-steps.js b/scripts/generate-script-steps.js new file mode 100644 index 0000000..c1524da --- /dev/null +++ b/scripts/generate-script-steps.js @@ -0,0 +1,28 @@ +const { exec, spawn } = require("child_process"); + +function pbcopy(data) { + const proc = spawn("pbcopy"); + proc.stdin.write(data); + proc.stdin.end(); +} + +function convertClipboardToFM() { + exec( + "osascript -e 'set the clipboard to (do shell script \"pbpaste\" as «class XMSS»)'", + (error, stdout, stderr) => { + if (error) { + console.error(`exec error: ${error}`); + return; + } + } + ); +} + +const xml = `$callbackName$promiseID$parameterYour logic here$webviewer

`; + +pbcopy(xml); +console.log("\x1b[34mXML copied to clipboard.\x1b[0m"); +convertClipboardToFM(); +console.log( + "\x1b[32mConverted to script steps. Go paste it in your FM script!\x1b[0m" +);