Skip to content

VS Code Workflow

I have been trying to switch over to using VS Code for the majority of my workflow lately. It allows me to keep my dev environment contained into a single space and offers visualization that working straight from a terminal cannot provide, especially when working with branches in Git.

thehoneycomb Workspace

Everything related to thehoneycomb.dev is worked on through a workspace in VS Code called thehoneycomb. This workspace has custom settings and is stored in C:\Projects\thehoneycomb\.vscode\ as thehoneycomb.code-workspace.

Workspace settings

Below are the settings within the thehoneycomb.code-workspace file.

thehoneycomb.code-workspace
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
    "settings": {
        "status-bar-button.buttons": [
            {
                "name": "Send Bees",
                "text": "$(cloud-upload) Send Bees",
                "tooltip": "Release the Bees",
                "alignment": "right",
                "priority": 9999,
                "activeColor": "#E5C07B",
                "inactiveColor": "#E5C07B",
                "command": "runTask:Send Bees"
            }
        ],
        "emeraldwalk.runonsave": {
            "commands": [
                {
                    "match": ".*",
                    "isAsync": true,
                    "cmd": "python ${workspaceFolder}/HoneyDocs/sync.py"
                }
            ]
        },
        "folder-color.pathColors": [
            {
                "folderPath": "thehoneycomb\\Honeycomb\\",
                "color": "foldercolorizer.color_ffcc99"
            },
            {
                "folderPath": "thehoneycomb\\HoneyAPI\\",
                "color": "foldercolorizer.color_ffcccc"
            },
/*             {
                "folderPath": ".vscode",
                "color": "foldercolorizer.color_6699cc"
            }, */
            {
                "folderPath": "thehoneycomb\\.bat\\",
                "color": "foldercolorizer.color_888888"
            },
            {
                "folderPath": "thehoneycomb\\HoneyDocs\\",
                "color": "foldercolorizer.color_ccffff"
            }
        ],
        "thunder-client.defaultURL": "https://api.thehoneycomb.dev/commands",
        "thunder-client.defaultHeaders": [
            {
                "name": "Accept",
                "value": "*/*"
            }
        ],
    }

Send Bees

Send Bees is a custom button located in the Status Bar that I created to simplify the deployment process. It exists solely within the thehoneycomb workspace. When clicked, it runs a VS Code task called "Send Bees".

Send Bees

Button in VS Code UI

The Send Bees button currently does 4 main things via the "Send Bees" task:

  1. Access the remote host via SSH.
  2. Switch to the HoneyAPI local repo, git pull, restart the HoneyAPI service via NSSM.
  3. Switch to the Honeycomb local repo, git pull, restart the Honeycomb service via NSSM.
  4. Execute the notify_discord.py script.

Whenever I've pushed updates to the remote repos on GitHub that I'm ready to make live, all I have to do is click the button and run the task.

I never need to open a terminal, remote in, or actually touch the laptop I'm using to host everything at all.

This process can be easily expanded as more is added to theHoneycomb.dev over time.

notify_discord.py script

The Python script uses a Discord webhook to send a message to a channel in my personal Discord server to let me know when the task has finished running.

Beekeeper

Message in Discord

The full Python script (modified for privacy) is included below.

notify_discord.py
1
2
3
4
5
import requests
requests.post(
    "https://discord.com/api/webhooks/.../...",
    json={"content": "🐝 Bees have been released! ✨"}
)

Task code

The "Send Bees" task is stored in C:\Projects\thehoneycomb\.vscode\tasks.json, which contains tasks that only exist within the scope of the thehoneycomb workspace:

tasks.json
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
{
    "label": "Send Bees",
    "type": "shell",
    "command": "ssh",
    "args": [
        "[email protected]",
        "'cd C:/Projects/thehoneycomb/HoneyAPI && git pull && nssm restart HoneyAPI && cd ../Honeycomb && git pull && nssm restart Honeycomb && cd ../HoneyDocs && git pull && nssm restart HoneyDocs && python C:/Projects/thehoneycomb/batch_scripts/notify_discord.py'"
    ],
    "problemMatcher": [],
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false
    }
},

Button code

The Send Bees button is setup in thehoneycomb.code-workspace settings. You can view it under Workspace Settings, within the "status-bar-button.buttons" section.

The button is created via a personally modified version of the status-bar-button extension. The original extension was developed for the web version of VS Code, which doesn't support tasks. The extension was modified to function as a desktop extension and allow buttons to use runTask with the "command" field.

The modified extension has been installed locally to my VS Code.