summaryrefslogtreecommitdiff
path: root/extension
diff options
context:
space:
mode:
authorNate Sesti <33237525+sestinj@users.noreply.github.com>2023-08-07 15:09:15 -0700
committerGitHub <noreply@github.com>2023-08-07 15:09:15 -0700
commit863b483259ae404d1071bfd1d640e9fbd94c64eb (patch)
treeec816a427171ad7c02adc8bee6e6da93487dfc8a /extension
parente8f06f81a00c05b2d2c93d614666b2298a1273a5 (diff)
parent0d1963628c7a5f998aeaf1cf63d8abab2e8923ea (diff)
downloadsncontinue-863b483259ae404d1071bfd1d640e9fbd94c64eb.tar.gz
sncontinue-863b483259ae404d1071bfd1d640e9fbd94c64eb.tar.bz2
sncontinue-863b483259ae404d1071bfd1d640e9fbd94c64eb.zip
Merge pull request #352 from bra1nDump/setup-experience
Improved 2 click setup experience for new devs
Diffstat (limited to 'extension')
-rw-r--r--extension/manual-testing-sandbox/example.ts3
-rw-r--r--extension/manual-testing-sandbox/readme.md3
-rw-r--r--extension/package.json14
-rw-r--r--extension/scripts/install_from_source.py35
-rw-r--r--extension/src/activation/environmentSetup.ts23
-rw-r--r--extension/src/bridge.ts11
6 files changed, 45 insertions, 44 deletions
diff --git a/extension/manual-testing-sandbox/example.ts b/extension/manual-testing-sandbox/example.ts
new file mode 100644
index 00000000..0633beaf
--- /dev/null
+++ b/extension/manual-testing-sandbox/example.ts
@@ -0,0 +1,3 @@
+function mergeSortAlgorithm() {
+ // TODO: implement
+} \ No newline at end of file
diff --git a/extension/manual-testing-sandbox/readme.md b/extension/manual-testing-sandbox/readme.md
new file mode 100644
index 00000000..5b25d31e
--- /dev/null
+++ b/extension/manual-testing-sandbox/readme.md
@@ -0,0 +1,3 @@
+The sole purpose of this folder is to open it when debugging the extension.
+It is not used by the extension itself.
+You can add more files that can be useful when manually testing the extension. \ No newline at end of file
diff --git a/extension/package.json b/extension/package.json
index 06957198..a1be66e1 100644
--- a/extension/package.json
+++ b/extension/package.json
@@ -183,19 +183,19 @@
]
},
"scripts": {
+ "esbuild-base": "rm -rf ./out && node esbuild.mjs",
"vscode:prepublish": "npm run esbuild-base -- --minify",
- "esbuild-base": "rm -rf ./out && esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
- "esbuild": "rm -rf ./out && node esbuild.mjs",
+ "esbuild": "npm run esbuild-base -- --sourcemap",
"esbuild-watch": "npm run esbuild-base -- --sourcemap --watch",
- "test-compile": "tsc -p ./",
+ "tsc": "tsc -p ./",
+ "tsc-watch": "tsc -watch -p ./",
+ "typegen": "node scripts/typegen.js",
"clientgen": "rm -rf src/client/ && npx @openapitools/openapi-generator-cli generate -i ../schema/openapi.json -g typescript-fetch -o src/client/ --additional-properties=supportsES6=true,npmVersion=8.19.2,typescriptThreePlus=true",
"rebuild": "electron-rebuild -v 19.1.8 node-pty",
- "watch": "tsc -watch -p ./",
- "pretest": "npm run compile && npm run lint",
+ "pretest": "npm run tsc && npm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js",
"jest": "jest --config ./jest.config.js",
- "typegen": "node scripts/typegen.js",
"package": "npm install && npm run typegen && npm run clientgen && cd react-app && npm install && npm run build && cd .. && mkdir -p ./build && vsce package --out ./build"
},
"devDependencies": {
@@ -244,4 +244,4 @@
"optionalDependencies": {
"@esbuild/android-arm": "^0.18.17"
}
-}
+} \ No newline at end of file
diff --git a/extension/scripts/install_from_source.py b/extension/scripts/install_from_source.py
index 5e16bf21..cd8f5cde 100644
--- a/extension/scripts/install_from_source.py
+++ b/extension/scripts/install_from_source.py
@@ -1,3 +1,5 @@
+# Run from extension/scripts directory
+
import os
import subprocess
@@ -5,23 +7,22 @@ import subprocess
def run(cmd: str):
return subprocess.run(cmd, shell=True, capture_output=False)
-
def get_latest_version() -> str:
- latest = None
- latest_major = 0
- latest_minor = 0
- latest_patch = 0
- for file in os.listdir("../build"):
- if file.endswith(".vsix"):
- version = file.split("-")[1].split(".vsix")[0]
- major, minor, patch = list(
- map(lambda x: int(x), version.split(".")))
- if latest is None or (major >= latest_major and minor >= latest_minor and patch > latest_patch):
- latest = file
- latest_major = major
- latest_minor = minor
- latest_patch = patch
-
+ # Ensure build directory exists
+ if not os.path.exists("../build"):
+ os.mkdir("../build")
+
+ def version_tuple(filename):
+ version = filename.split("-")[1].split(".vsix")[0]
+ return tuple(map(int, version.split(".")))
+
+ versions = [file for file in os.listdir("../build") if file.endswith(".vsix")]
+
+ # Ensure we have at least one version
+ if len(versions) == 0:
+ return None
+
+ return max(versions, key=version_tuple)
def main():
# Clear out old stuff
@@ -62,7 +63,7 @@ def main():
latest = get_latest_version()
resp = run(f"cd ..; code --install-extension ./build/{latest}")
-
+
print("Continue VS Code extension installed successfully. Please restart VS Code to use it.")
diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts
index 3c8220c0..81d58afe 100644
--- a/extension/src/activation/environmentSetup.ts
+++ b/extension/src/activation/environmentSetup.ts
@@ -1,7 +1,7 @@
import { getExtensionUri } from "../util/vscode";
-const util = require("util");
-const exec = util.promisify(require("child_process").exec);
-const { spawn } = require("child_process");
+import { promisify } from "util";
+import { exec as execCb } from "child_process";
+import { spawn } from "child_process";
import * as path from "path";
import * as fs from "fs";
import { getContinueServerUrl } from "../bridge";
@@ -10,11 +10,13 @@ import * as vscode from "vscode";
import * as os from "os";
import fkill from "fkill";
import { finished } from "stream/promises";
-const request = require("request");
+import request = require("request");
+
+const exec = promisify(execCb);
async function runCommand(cmd: string): Promise<[string, string | undefined]> {
- var stdout: any = "";
- var stderr: any = "";
+ var stdout = "";
+ var stderr = "";
try {
var { stdout, stderr } = await exec(cmd, {
shell: process.platform === "win32" ? "powershell.exe" : undefined,
@@ -23,14 +25,9 @@ async function runCommand(cmd: string): Promise<[string, string | undefined]> {
stderr = e.stderr;
stdout = e.stdout;
}
- if (stderr === "") {
- stderr = undefined;
- }
- if (typeof stdout === "undefined") {
- stdout = "";
- }
- return [stdout, stderr];
+ const stderrOrUndefined = stderr === "" ? undefined : stderr;
+ return [stdout, stderrOrUndefined];
}
async function checkServerRunning(serverUrl: string): Promise<boolean> {
diff --git a/extension/src/bridge.ts b/extension/src/bridge.ts
index 0d665826..e4c74771 100644
--- a/extension/src/bridge.ts
+++ b/extension/src/bridge.ts
@@ -1,14 +1,11 @@
import * as vscode from "vscode";
-import { extensionContext } from "./activation/activate";
export function getContinueServerUrl() {
- // If in debug mode, always use 8001
- if (
- extensionContext &&
- extensionContext.extensionMode === vscode.ExtensionMode.Development
- ) {
- return "http://localhost:8001";
+ // Passed in from launch.json
+ if (process.env.CONTINUE_SERVER_URL) {
+ return process.env.CONTINUE_SERVER_URL;
}
+
return (
vscode.workspace.getConfiguration("continue").get<string>("serverUrl") ||
"http://localhost:65432"