summaryrefslogtreecommitdiff
path: root/extension/src/bridge.ts
diff options
context:
space:
mode:
authorNate Sesti <33237525+sestinj@users.noreply.github.com>2023-07-26 00:56:29 -0700
committerGitHub <noreply@github.com>2023-07-26 00:56:29 -0700
commitdef8e5612cd4c889a2e26d4152fffcf3d694abdf (patch)
treeca423625619b9d628651bcc9a395ba8f47fa03a6 /extension/src/bridge.ts
parentb759e2dbfe36b3e8873527b9736d64866da9b604 (diff)
parentd9a4ed993aad36464776c093333af1a310e5a492 (diff)
downloadsncontinue-def8e5612cd4c889a2e26d4152fffcf3d694abdf.tar.gz
sncontinue-def8e5612cd4c889a2e26d4152fffcf3d694abdf.tar.bz2
sncontinue-def8e5612cd4c889a2e26d4152fffcf3d694abdf.zip
Merge pull request #297 from continuedev/merge-config-py-TO-main
Merge config py to main
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);
- }
- }
-}