Skip to content

Commit 41eb98d

Browse files
author
Abdulhakim Ajetunmobi
authored
preview banner scripting (#3)
1 parent 5f33d9f commit 41eb98d

File tree

5 files changed

+52
-10
lines changed

5 files changed

+52
-10
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/sh
2+
3+
# Change VS Browser Column to "Three" and URL for 2nd Browser
4+
SETTINGSFILE="./.vscode/settings.json"
5+
if [ -f "$SETTINGSFILE" ]; then
6+
sed -i.bak \
7+
-e 's/"Two"/"Three"/g' \
8+
-e 's|"vs-browser\.url": ".*"|"vs-browser.url": "https://www.example.com"|' \
9+
"$SETTINGSFILE"
10+
rm -f "${SETTINGSFILE}.bak"
11+
else
12+
echo "File not found: $SETTINGSFILE"
13+
fi

scripting/TemplateWorkspace/.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"vcr.yml": true,
77
},
88
"vs-browser.url": "<URL>",
9+
"vs-browser.columnToShowIn": "Two",
910
"vs-browser.reload.onSave": false,
1011
"workbench.startupEditor": "none"
1112
}

scripting/TemplateWorkspace/.vscode/tasks.json

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22
"version": "2.0.0",
33
"tasks": [
44
{
5-
"label": "OpenBrowser",
5+
"label": "OpenContentView",
6+
"command": "${input:openBrowser}",
7+
"presentation": {
8+
"reveal": "never",
9+
"close": true
10+
}
11+
},
12+
{
13+
"label": "OpenPreviewView",
614
"command": "${input:openBrowser}",
715
"presentation": {
816
"reveal": "never",
@@ -26,6 +34,15 @@
2634
"close": true
2735
}
2836
},
37+
{
38+
"label": "ConfigurePreview",
39+
"type": "shell",
40+
"command": "chmod +x ./.vscode/preview.sh; ./.vscode/preview.sh",
41+
"presentation": {
42+
"reveal": "never",
43+
"close": true
44+
}
45+
},
2946
{
3047
"label": "CleanUp",
3148
"type": "shell",
@@ -37,12 +54,7 @@
3754
},
3855
{
3956
"label": "Run",
40-
"dependsOn": [
41-
"ExportEnv",
42-
"OpenBrowser",
43-
"OpenTerminal",
44-
"CleanUp"
45-
],
57+
"dependsOn": <TASKS>,
4658
"dependsOrder": "sequence",
4759
"runOptions": {
4860
"runOn": "folderOpen"

scripting/createWorkspace.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fi
1919
SLUG=$(jq -r '.slug' "$CONFIG_FILE")
2020
VERSION=$(jq -r '.version' "$CONFIG_FILE")
2121
FILES=$(jq -r '.files[]' "$CONFIG_FILE")
22+
PANELS=$(jq -r '.panels[]' "$CONFIG_FILE")
2223

2324
# Create files from the "files" array
2425
for FILE in $FILES; do
@@ -50,4 +51,20 @@ if [ -f "$OFOS_FILE" ]; then
5051
echo "Updated $OFOS_FILE with files: $FILES_ARRAY"
5152
else
5253
echo "$OFOS_FILE not found."
53-
fi
54+
fi
55+
56+
# Update tasks.json using a temporary file
57+
if echo "${PANELS[@]}" | grep -q "browser"; then
58+
TASKS='["ExportEnv", "OpenContentView", "OpenTerminal", "ConfigurePreview", "OpenPreviewView", "CleanUp"]'
59+
else
60+
TASKS='["ExportEnv", "OpenContentView", "OpenTerminal", "CleanUp"]'
61+
fi
62+
63+
TASKS_FILE=".vscode/tasks.json"
64+
if [ -f "$TASKS_FILE" ]; then
65+
TEMP_FILE=$(mktemp)
66+
sed "s|<TASKS>|$TASKS|" "$TASKS_FILE" > "$TEMP_FILE" && mv "$TEMP_FILE" "$TASKS_FILE"
67+
echo "Updated $TASKS_FILE with tasks: $TASKS"
68+
else
69+
echo "$TASKS_FILE not found."
70+
fi

tutorials/messages_api-sms/tutorial-config.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"send-sms.js"
66
],
77
"panels": [
8-
"terminal",
98
"browser"
109
],
11-
"version": "0.2"
10+
"version": "0.3"
1211
}

0 commit comments

Comments
 (0)