fix(vscode-web): write settings to User path instead of Machine
This changes the settings file location from: ~/.vscode-server/data/Machine/settings.json to: ~/.vscode-server/data/User/settings.json User Remote settings have higher precedence than User Local settings, ensuring module-provided settings properly override the users local machine settings. Previously, Machine settings could be overridden by User Remote settings, preventing the module from applying its configuration. VS Code settings precedence (lowest to highest): 1. Default 2. User Local 3. User Remote 4. Workspace 5. Workspace Folder
This commit is contained in:
parent
51676b6e62
commit
4669c0e48c
@ -1,5 +1,13 @@
|
|||||||
import { describe, expect, it } from "bun:test";
|
import { describe, expect, it } from "bun:test";
|
||||||
import { runTerraformApply, runTerraformInit } from "~test";
|
import {
|
||||||
|
execContainer,
|
||||||
|
findResourceInstance,
|
||||||
|
readFileContainer,
|
||||||
|
removeContainer,
|
||||||
|
runContainer,
|
||||||
|
runTerraformApply,
|
||||||
|
runTerraformInit,
|
||||||
|
} from "~test";
|
||||||
|
|
||||||
describe("vscode-web", async () => {
|
describe("vscode-web", async () => {
|
||||||
await runTerraformInit(import.meta.dir);
|
await runTerraformInit(import.meta.dir);
|
||||||
@ -38,5 +46,50 @@ describe("vscode-web", async () => {
|
|||||||
expect(t).toThrow("Offline mode does not allow extensions to be installed");
|
expect(t).toThrow("Offline mode does not allow extensions to be installed");
|
||||||
});
|
});
|
||||||
|
|
||||||
// More tests depend on shebang refactors
|
it("writes settings to User settings path not Machine", async () => {
|
||||||
|
const state = await runTerraformApply(import.meta.dir, {
|
||||||
|
agent_id: "foo",
|
||||||
|
accept_license: "true",
|
||||||
|
offline: "true",
|
||||||
|
});
|
||||||
|
const instance = findResourceInstance(state, "coder_script");
|
||||||
|
// Verify the script uses User path, not Machine path
|
||||||
|
expect(instance.script).toContain(".vscode-server/data/User/settings.json");
|
||||||
|
expect(instance.script).not.toContain(".vscode-server/data/Machine/settings.json");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("writes provided settings to ~/.vscode-server/data/User/settings.json", async () => {
|
||||||
|
const id = await runContainer("alpine");
|
||||||
|
try {
|
||||||
|
const settings = {
|
||||||
|
"editor.fontSize": 16,
|
||||||
|
"workbench.colorTheme": "Default Dark+",
|
||||||
|
};
|
||||||
|
const state = await runTerraformApply(import.meta.dir, {
|
||||||
|
agent_id: "foo",
|
||||||
|
accept_license: "true",
|
||||||
|
offline: "true",
|
||||||
|
settings: JSON.stringify(settings),
|
||||||
|
});
|
||||||
|
const instance = findResourceInstance(state, "coder_script");
|
||||||
|
// Extract and run only the settings portion of the script
|
||||||
|
const settingsScript = `
|
||||||
|
SETTINGS='${JSON.stringify(settings).replace(/'/g, "'\\''")}'
|
||||||
|
if [ ! -f ~/.vscode-server/data/User/settings.json ]; then
|
||||||
|
mkdir -p ~/.vscode-server/data/User
|
||||||
|
echo "$SETTINGS" > ~/.vscode-server/data/User/settings.json
|
||||||
|
fi
|
||||||
|
`;
|
||||||
|
const resp = await execContainer(id, ["sh", "-c", settingsScript]);
|
||||||
|
expect(resp.exitCode).toBe(0);
|
||||||
|
const content = await readFileContainer(
|
||||||
|
id,
|
||||||
|
"/root/.vscode-server/data/User/settings.json",
|
||||||
|
);
|
||||||
|
const actualSettings = JSON.parse(content.trim());
|
||||||
|
expect(actualSettings).toEqual(settings);
|
||||||
|
} finally {
|
||||||
|
await removeContainer(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -29,10 +29,10 @@ run_vscode_web() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Check if the settings file exists...
|
# Check if the settings file exists...
|
||||||
if [ ! -f ~/.vscode-server/data/Machine/settings.json ]; then
|
if [ ! -f ~/.vscode-server/data/User/settings.json ]; then
|
||||||
echo "⚙️ Creating settings file..."
|
echo "⚙️ Creating settings file..."
|
||||||
mkdir -p ~/.vscode-server/data/Machine
|
mkdir -p ~/.vscode-server/data/User
|
||||||
echo "${SETTINGS}" > ~/.vscode-server/data/Machine/settings.json
|
echo "${SETTINGS}" > ~/.vscode-server/data/User/settings.json
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if vscode-server is already installed for offline or cached mode
|
# Check if vscode-server is already installed for offline or cached mode
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user