summaryrefslogtreecommitdiff
path: root/extension/src/bridge.ts
diff options
context:
space:
mode:
authorNate Sesti <sestinj@gmail.com>2023-07-24 20:02:43 -0700
committerNate Sesti <sestinj@gmail.com>2023-07-24 20:02:43 -0700
commite788f27ae90ef6b8ff2c5df2cd1ed6e526cb920a (patch)
tree18de611b58f0a793ea402027f92a22672d26f39d /extension/src/bridge.ts
parente6e9655caf982f68d22ceab857cfe692baad922f (diff)
downloadsncontinue-e788f27ae90ef6b8ff2c5df2cd1ed6e526cb920a.tar.gz
sncontinue-e788f27ae90ef6b8ff2c5df2cd1ed6e526cb920a.tar.bz2
sncontinue-e788f27ae90ef6b8ff2c5df2cd1ed6e526cb920a.zip
Removing unnecessary config.jsons
Diffstat (limited to 'extension/src/bridge.ts')
-rw-r--r--extension/src/bridge.ts73
1 files changed, 0 insertions, 73 deletions
diff --git a/extension/src/bridge.ts b/extension/src/bridge.ts
index d614ace4..0d665826 100644
--- a/extension/src/bridge.ts
+++ b/extension/src/bridge.ts
@@ -1,44 +1,5 @@
-import fetch from "node-fetch";
-import * as path from "path";
import * as vscode from "vscode";
-import { Configuration, DebugApi, UnittestApi } from "./client";
-import { convertSingleToDoubleQuoteJSON } from "./util/util";
-import { getExtensionUri } from "./util/vscode";
import { extensionContext } from "./activation/activate";
-const util = require("util");
-const exec = util.promisify(require("child_process").exec);
-
-const configuration = new Configuration({
- basePath: get_api_url(),
- fetchApi: fetch as any,
- middleware: [
- {
- pre: async (context) => {
- // If there is a SerializedDebugContext in the body, add the files for the filesystem
- context.init.body;
-
- // Add the VS Code Machine Code Header
- context.init.headers = {
- ...context.init.headers,
- "x-vsc-machine-id": vscode.env.machineId,
- };
- },
- },
- ],
-});
-export const debugApi = new DebugApi(configuration);
-export const unittestApi = new UnittestApi(configuration);
-
-export function get_api_url() {
- const extensionUri = getExtensionUri();
- const configFile = path.join(extensionUri.fsPath, "config/config.json");
- const config = require(configFile);
-
- if (config.API_URL) {
- return config.API_URL;
- }
- return "http://localhost:65432";
-}
export function getContinueServerUrl() {
// If in debug mode, always use 8001
@@ -53,37 +14,3 @@ export function getContinueServerUrl() {
"http://localhost:65432"
);
}
-
-function listToCmdLineArgs(list: string[]): string {
- return list.map((el) => `"$(echo "${el}")"`).join(" ");
-}
-
-export async function runPythonScript(
- scriptName: string,
- args: string[]
-): Promise<any> {
- // TODO: Need to make sure that the path to poetry is in the PATH and that it is installed in the first place. Realistically also need to install npm in some cases.
- const command = `export PATH="$PATH:/opt/homebrew/bin" && cd ${path.join(
- getExtensionUri().fsPath,
- "scripts"
- )} && source env/bin/activate && python3 ${scriptName} ${listToCmdLineArgs(
- args
- )}`;
-
- const { stdout, stderr } = await exec(command);
-
- try {
- let jsonString = stdout.substring(
- stdout.indexOf("{"),
- stdout.lastIndexOf("}") + 1
- );
- jsonString = convertSingleToDoubleQuoteJSON(jsonString);
- return JSON.parse(jsonString);
- } catch (e) {
- if (stderr) {
- throw new Error(stderr);
- } else {
- throw new Error("Failed to parse JSON: " + e);
- }
- }
-}