Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- name: Get changed files
id: get-changed-files
uses: tj-actions/changed-files@2f7c5bf
uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32

- name: Get changed folder
id: get-changed-folder
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- name: Get changed files
id: get-changed-files
uses: tj-actions/changed-files@2f7c5bf
uses: tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32

- name: Get changed folder
id: get-changed-folder
Expand Down
52 changes: 52 additions & 0 deletions scripting/TemplateWorkspace/.vscode/capabilities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const VONAGE_API_KEY = process.env.VONAGE_API_KEY;
const VONAGE_API_SECRET = process.env.VONAGE_API_SECRET;
const VONAGE_APPLICATION = process.env.VONAGE_APPLICATION_ID || '8b6851fe-567c-4e86-adf8-3bea83633c60';

const capabilities = [<CAPABILITIES>];

if (capabilities) {
console.log(`Enabling ${capabilities}`);

// Fetch the application JSON
const response = await fetch(`https://api.nexmo.com/v2/applications/${VONAGE_APPLICATION}`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${Buffer.from(`${VONAGE_API_KEY}:${VONAGE_API_SECRET}`).toString('base64')}`
}
});

const data = await response.json();

// Ensure the capabilities object exists and update it

const capabilitiesObject = {};
capabilities.forEach(capability => {
if (capability === "voice") {
capabilitiesObject.voice = {};
}
});

const updatedData = {
...data,
capabilities: capabilitiesObject
};

// Send the updated JSON back
const updateResponse = await fetch(`https://api.nexmo.com/v2/applications/${VONAGE_APPLICATION}`, {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${Buffer.from(`${VONAGE_API_KEY}:${VONAGE_API_SECRET}`).toString('base64')}`
},
body: JSON.stringify(updatedData)
});

if (updateResponse.ok) {
console.log('Successfully updated the application.');
} else {
console.error('Failed to update the application.');
}
} else {
console.log('No Capabilities, skipping.');
}
9 changes: 9 additions & 0 deletions scripting/TemplateWorkspace/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
"close": true
}
},
{
"label": "EnableCapabilities",
"type": "shell",
"command": "chmod +x ./.vscode/capabilities.sh; ./.vscode/capabilities.sh",
"presentation": {
"reveal": "never",
"close": true
}
},
{
"label": "CleanUp",
"type": "shell",
Expand Down
15 changes: 13 additions & 2 deletions scripting/createWorkspace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fi
SLUG=$(jq -r '.slug' "$CONFIG_FILE")
VERSION=$(jq -r '.version' "$CONFIG_FILE")
FILES=$(jq -r '.files[]' "$CONFIG_FILE")
CAPABILITIES=$(jq -r '.capabilities[]' "$CONFIG_FILE")
PANELS=$(jq -r '.panels[]' "$CONFIG_FILE")

# Create files from the "files" array
Expand Down Expand Up @@ -53,11 +54,21 @@ else
echo "$OFOS_FILE not found."
fi

# Update capabilities.sh using a temporary file
CAPABILITIES_FILE=".vscode/capabilities.js"
if [ -f "$CAPABILITIES_FILE" ]; then
TEMP_FILE=$(mktemp)
sed "s|<CAPABILITIES>|$CAPABILITIES|" "$CAPABILITIES_FILE" > "$TEMP_FILE" && mv "$TEMP_FILE" "$CAPABILITIES_FILE"
echo "Updated $CAPABILITIES_FILE with: $CAPABILITIES"
else
echo "$CAPABILITIES_FILE not found."
fi

# Update tasks.json using a temporary file
if echo "${PANELS[@]}" | grep -q "browser"; then
TASKS='["ExportEnv", "OpenContentView", "ConfigurePreview", "OpenTerminal", "CleanUp", "OpenPreviewView"]'
TASKS='["ExportEnv", "OpenContentView", "ConfigurePreview", "OpenTerminal", "EnableCapabilities", "CleanUp", "OpenPreviewView"]'
else
TASKS='["ExportEnv", "OpenContentView", "OpenTerminal", "CleanUp"]'
TASKS='["ExportEnv", "OpenContentView", "OpenTerminal", "EnableCapabilities", "CleanUp"]'
fi

TASKS_FILE=".vscode/tasks.json"
Expand Down

This file was deleted.

8 changes: 5 additions & 3 deletions tutorials/voice_api-node-outbound/tutorial-config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"files": [
"make-call.js",
"enable-voice.js"
"make-call.js"
],
"panels": [
"terminal"
],
"version": "0.2.0"
"capabilities": [
"voice"
],
"version": "0.3.0"
}