From a162ae65de7b1e6e5760f505cde64b49cc45c68c Mon Sep 17 00:00:00 2001 From: Abdulhakim Ajetunmobi Date: Thu, 28 Nov 2024 16:09:55 +0000 Subject: [PATCH] preview banner scripting --- .../TemplateWorkspace/.vscode/preview.sh | 13 ++++++++++ .../TemplateWorkspace/.vscode/settings.json | 1 + .../TemplateWorkspace/.vscode/tasks.json | 26 ++++++++++++++----- scripting/createWorkspace.sh | 19 +++++++++++++- .../messages_api-sms/tutorial-config.json | 3 +-- 5 files changed, 52 insertions(+), 10 deletions(-) create mode 100644 scripting/TemplateWorkspace/.vscode/preview.sh diff --git a/scripting/TemplateWorkspace/.vscode/preview.sh b/scripting/TemplateWorkspace/.vscode/preview.sh new file mode 100644 index 0000000..547bc6a --- /dev/null +++ b/scripting/TemplateWorkspace/.vscode/preview.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# Change VS Browser Column to "Three" and URL for 2nd Browser +SETTINGSFILE="./.vscode/settings.json" +if [ -f "$SETTINGSFILE" ]; then + sed -i.bak \ + -e 's/"Two"/"Three"/g' \ + -e 's|"vs-browser\.url": ".*"|"vs-browser.url": "https://www.example.com"|' \ + "$SETTINGSFILE" + rm -f "${SETTINGSFILE}.bak" +else + echo "File not found: $SETTINGSFILE" +fi \ No newline at end of file diff --git a/scripting/TemplateWorkspace/.vscode/settings.json b/scripting/TemplateWorkspace/.vscode/settings.json index 92627c9..f0384ff 100644 --- a/scripting/TemplateWorkspace/.vscode/settings.json +++ b/scripting/TemplateWorkspace/.vscode/settings.json @@ -6,6 +6,7 @@ "vcr.yml": true, }, "vs-browser.url": "", + "vs-browser.columnToShowIn": "Two", "vs-browser.reload.onSave": false, "workbench.startupEditor": "none" } \ No newline at end of file diff --git a/scripting/TemplateWorkspace/.vscode/tasks.json b/scripting/TemplateWorkspace/.vscode/tasks.json index 4cd95cc..de1aea5 100644 --- a/scripting/TemplateWorkspace/.vscode/tasks.json +++ b/scripting/TemplateWorkspace/.vscode/tasks.json @@ -2,7 +2,15 @@ "version": "2.0.0", "tasks": [ { - "label": "OpenBrowser", + "label": "OpenContentView", + "command": "${input:openBrowser}", + "presentation": { + "reveal": "never", + "close": true + } + }, + { + "label": "OpenPreviewView", "command": "${input:openBrowser}", "presentation": { "reveal": "never", @@ -26,6 +34,15 @@ "close": true } }, + { + "label": "ConfigurePreview", + "type": "shell", + "command": "chmod +x ./.vscode/preview.sh; ./.vscode/preview.sh", + "presentation": { + "reveal": "never", + "close": true + } + }, { "label": "CleanUp", "type": "shell", @@ -37,12 +54,7 @@ }, { "label": "Run", - "dependsOn": [ - "ExportEnv", - "OpenBrowser", - "OpenTerminal", - "CleanUp" - ], + "dependsOn": , "dependsOrder": "sequence", "runOptions": { "runOn": "folderOpen" diff --git a/scripting/createWorkspace.sh b/scripting/createWorkspace.sh index 3f6e5b8..bf11c1d 100755 --- a/scripting/createWorkspace.sh +++ b/scripting/createWorkspace.sh @@ -19,6 +19,7 @@ fi SLUG=$(jq -r '.slug' "$CONFIG_FILE") VERSION=$(jq -r '.version' "$CONFIG_FILE") FILES=$(jq -r '.files[]' "$CONFIG_FILE") +PANELS=$(jq -r '.panels[]' "$CONFIG_FILE") # Create files from the "files" array for FILE in $FILES; do @@ -50,4 +51,20 @@ if [ -f "$OFOS_FILE" ]; then echo "Updated $OFOS_FILE with files: $FILES_ARRAY" else echo "$OFOS_FILE not found." -fi \ No newline at end of file +fi + +# Update tasks.json using a temporary file +if echo "${PANELS[@]}" | grep -q "browser"; then + TASKS='["ExportEnv", "OpenContentView", "OpenTerminal", "ConfigurePreview", "OpenPreviewView", "CleanUp"]' +else + TASKS='["ExportEnv", "OpenContentView", "OpenTerminal", "CleanUp"]' +fi + +TASKS_FILE=".vscode/tasks.json" +if [ -f "$TASKS_FILE" ]; then + TEMP_FILE=$(mktemp) + sed "s||$TASKS|" "$TASKS_FILE" > "$TEMP_FILE" && mv "$TEMP_FILE" "$TASKS_FILE" + echo "Updated $TASKS_FILE with tasks: $TASKS" +else + echo "$TASKS_FILE not found." +fi diff --git a/tutorials/messages_api-sms/tutorial-config.json b/tutorials/messages_api-sms/tutorial-config.json index 9451a38..c8fc753 100644 --- a/tutorials/messages_api-sms/tutorial-config.json +++ b/tutorials/messages_api-sms/tutorial-config.json @@ -5,8 +5,7 @@ "send-sms.js" ], "panels": [ - "terminal", "browser" ], - "version": "0.2" + "version": "0.3" } \ No newline at end of file