This repository was archived by the owner on May 15, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -48,3 +48,20 @@ module "vscode-web" {
4848 accept_license = true
4949}
5050```
51+
52+ ### Pre-configure Settings
53+
54+ Configure VS Code's [ settings.json] ( https://code.visualstudio.com/docs/getstarted/settings#_settingsjson ) file:
55+
56+ ``` tf
57+ module "vscode-web" {
58+ source = "registry.coder.com/modules/vscode-web/coder"
59+ version = "1.0.8"
60+ agent_id = coder_agent.example.id
61+ extensions = ["dracula-theme.theme-dracula"]
62+ settings = {
63+ "workbench.colorTheme" = "Dracula"
64+ }
65+ accept_license = true
66+ }
67+ ```
Original file line number Diff line number Diff line change @@ -91,6 +91,12 @@ variable "order" {
9191 default = null
9292}
9393
94+ variable "settings" {
95+ type = map (string )
96+ description = " A map of settings to apply to VS Code web."
97+ default = {}
98+ }
99+
94100resource "coder_script" "vscode-web" {
95101 agent_id = var. agent_id
96102 display_name = " VS Code Web"
@@ -101,6 +107,8 @@ resource "coder_script" "vscode-web" {
101107 INSTALL_PREFIX : var.install_prefix,
102108 EXTENSIONS : join (" ," , var. extensions ),
103109 TELEMETRY_LEVEL : var.telemetry_level,
110+ // This is necessary otherwise the quotes are stripped!
111+ SETTINGS : replace (jsonencode (var. settings ), " \" " , " \\\" " ),
104112 })
105113 run_on_start = true
106114}
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ case "$ARCH" in
1919 ;;
2020esac
2121
22- HASH=$( curl https://update.code.visualstudio.com/api/commits/stable/server-linux-$ARCH -web | cut -d ' "' -f 2)
23- output=$( curl -sL https://vscode.download.prss.microsoft.com/dbazure/download/stable/$HASH /vscode-server-linux-$ARCH -web.tar.gz | tar -xz -C ${INSTALL_PREFIX} --strip-components 1)
22+ HASH=$( curl -fsSL https://update.code.visualstudio.com/api/commits/stable/server-linux-$ARCH -web | cut -d ' "' -f 2)
23+ output=$( curl -fsSL https://vscode.download.prss.microsoft.com/dbazure/download/stable/$HASH /vscode-server-linux-$ARCH -web.tar.gz | tar -xz -C ${INSTALL_PREFIX} --strip-components 1)
2424
2525if [ $? -ne 0 ]; then
2626 echo " Failed to install Microsoft Visual Studio Code Server: $output "
@@ -44,6 +44,13 @@ for extension in "$${EXTENSIONLIST[@]}"; do
4444 fi
4545done
4646
47+ # Check if the settings file exists...
48+ if [ ! -f ~ /.vscode-server/data/Machine/settings.json ]; then
49+ echo " ⚙️ Creating settings file..."
50+ mkdir -p ~ /.vscode-server/data/Machine
51+ echo " ${SETTINGS} " > ~ /.vscode-server/data/Machine/settings.json
52+ fi
53+
4754echo " 👷 Running ${INSTALL_PREFIX} /bin/code-server serve-local --port ${PORT} --accept-server-license-terms serve-local --without-connection-token --telemetry-level ${TELEMETRY_LEVEL} in the background..."
4855echo " Check logs at ${LOG_PATH} !"
4956" ${INSTALL_PREFIX} /bin/code-server" serve-local --port " ${PORT} " --accept-server-license-terms serve-local --without-connection-token --telemetry-level " ${TELEMETRY_LEVEL} " > " ${LOG_PATH} " 2>&1 &
You can’t perform that action at this time.
0 commit comments