set file permissions using chmod
This commit is contained in:
parent
413c0bb26c
commit
2a6a0e91a4
4 changed files with 29 additions and 10 deletions
|
|
@ -14,6 +14,16 @@ import Types from "../config/types";
|
|||
|
||||
dotenv.config();
|
||||
|
||||
export function setConfigFilePermissions(filePath: string): void {
|
||||
try {
|
||||
if (os.platform() !== "win32") {
|
||||
fs.chmodSync(filePath, 0o600);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Failed to set permissions on ${filePath}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
const CONTINUE_GLOBAL_DIR = (() => {
|
||||
const configPath = process.env.CONTINUE_GLOBAL_DIR;
|
||||
if (configPath) {
|
||||
|
|
@ -113,10 +123,11 @@ export function getConfigYamlPath(ideType?: IdeType): string {
|
|||
// https://github.com/continuedev/continue/pull/7224
|
||||
// This was here because we had different context provider support between jetbrains and vs code
|
||||
// Leaving so we could differentiate later but for now configs are the same between IDEs
|
||||
fs.writeFileSync(p, YAML.stringify(defaultConfig), { mode: 0o600 });
|
||||
fs.writeFileSync(p, YAML.stringify(defaultConfig));
|
||||
} else {
|
||||
fs.writeFileSync(p, YAML.stringify(defaultConfig), { mode: 0o600 });
|
||||
fs.writeFileSync(p, YAML.stringify(defaultConfig));
|
||||
}
|
||||
setConfigFilePermissions(p);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
|
@ -261,7 +272,8 @@ function editConfigYaml(callback: (config: ConfigYaml) => ConfigYaml): void {
|
|||
// Check if it's an object
|
||||
if (typeof configYaml === "object" && configYaml !== null) {
|
||||
configYaml = callback(configYaml as any) as any;
|
||||
fs.writeFileSync(configPath, YAML.stringify(configYaml), { mode: 0o600 });
|
||||
fs.writeFileSync(configPath, YAML.stringify(configYaml));
|
||||
setConfigFilePermissions(configPath);
|
||||
} else {
|
||||
console.warn("config.yaml is not a valid object");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import * as fs from "fs";
|
|||
import * as path from "path";
|
||||
|
||||
import chalk from "chalk";
|
||||
import { setConfigFilePermissions } from "core/util/paths.js";
|
||||
import open from "open";
|
||||
|
||||
import { env } from "./env.js";
|
||||
|
|
@ -31,7 +32,8 @@ async function createOrUpdateConfig(apiKey: string): Promise<void> {
|
|||
: "";
|
||||
|
||||
const updatedContent = updateAnthropicModelInYaml(existingContent, apiKey);
|
||||
fs.writeFileSync(CONFIG_PATH, updatedContent, { mode: 0o600 });
|
||||
fs.writeFileSync(CONFIG_PATH, updatedContent);
|
||||
setConfigFilePermissions(CONFIG_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import * as fs from "fs";
|
|||
import * as path from "path";
|
||||
|
||||
import chalk from "chalk";
|
||||
import { setConfigFilePermissions } from "core/util/paths.js";
|
||||
|
||||
import { AuthConfig, login } from "./auth/workos.js";
|
||||
import { getApiClient } from "./config.js";
|
||||
|
|
@ -43,7 +44,8 @@ export async function createOrUpdateConfig(apiKey: string): Promise<void> {
|
|||
: "";
|
||||
|
||||
const updatedContent = updateAnthropicModelInYaml(existingContent, apiKey);
|
||||
fs.writeFileSync(CONFIG_PATH, updatedContent, { mode: 0o600 });
|
||||
fs.writeFileSync(CONFIG_PATH, updatedContent);
|
||||
setConfigFilePermissions(CONFIG_PATH);
|
||||
}
|
||||
|
||||
export async function runOnboardingFlow(
|
||||
|
|
|
|||
|
|
@ -8,16 +8,20 @@ import { EXTENSION_NAME } from "core/control-plane/env";
|
|||
import { Core } from "core/core";
|
||||
import { walkDirAsync } from "core/indexing/walkDir";
|
||||
import { isModelInstaller } from "core/llm";
|
||||
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
|
||||
import { startLocalLemonade } from "core/util/lemonadeHelper";
|
||||
import { startLocalOllama } from "core/util/ollamaHelper";
|
||||
import { getConfigJsonPath, getConfigYamlPath } from "core/util/paths";
|
||||
import {
|
||||
getConfigJsonPath,
|
||||
getConfigYamlPath,
|
||||
setConfigFilePermissions,
|
||||
} from "core/util/paths";
|
||||
import { Telemetry } from "core/util/posthog";
|
||||
import * as vscode from "vscode";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
import { convertJsonToYamlConfig } from "../../../packages/config-yaml/dist";
|
||||
|
||||
import { NextEditLoggingService } from "core/nextEdit/NextEditLoggingService";
|
||||
import {
|
||||
getAutocompleteStatusBarDescription,
|
||||
getAutocompleteStatusBarTitle,
|
||||
|
|
@ -715,9 +719,8 @@ const getCommandsMap: (
|
|||
const configYaml = convertJsonToYamlConfig(parsed);
|
||||
|
||||
const configYamlPath = getConfigYamlPath();
|
||||
fs.writeFileSync(configYamlPath, YAML.stringify(configYaml), {
|
||||
mode: 0o600,
|
||||
});
|
||||
fs.writeFileSync(configYamlPath, YAML.stringify(configYaml));
|
||||
setConfigFilePermissions(configYamlPath);
|
||||
|
||||
// Open config.yaml
|
||||
await openEditorAndRevealRange(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue