add download step
This commit is contained in:
parent
1a85fd61f7
commit
dc1eff8e8a
|
@ -1 +1 @@
|
|||
Continue IntelliJ Extension
|
||||
continue-intellij-extension
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
|
@ -276,6 +276,7 @@ async function installNodeModuleInTempDirAndCopyToCurrent(packageName, toCopy) {
|
|||
`node_modules/${targetToLanceDb[target]}/index.node`,
|
||||
`${targetDir}/index.node`,
|
||||
);
|
||||
}
|
||||
|
||||
const pathsToVerify = [];
|
||||
for (target of targets) {
|
||||
|
|
|
@ -49,6 +49,8 @@ import {
|
|||
getConfigJsonPathForRemote,
|
||||
getConfigTsPath,
|
||||
getContinueDotEnv,
|
||||
getContinueUtilsPath,
|
||||
getEsbuildBinaryPath,
|
||||
readAllGlobalPromptFiles,
|
||||
} from "../util/paths.js";
|
||||
import {
|
||||
|
@ -62,6 +64,7 @@ import {
|
|||
getPromptFiles,
|
||||
slashCommandFromPromptFile,
|
||||
} from "./promptFile.js";
|
||||
import { GlobalContext } from "../util/GlobalContext.js";
|
||||
|
||||
function resolveSerializedConfig(filepath: string): SerializedContinueConfig {
|
||||
let content = fs.readFileSync(filepath, "utf8");
|
||||
|
@ -525,46 +528,103 @@ function escapeSpacesInPath(p: string): string {
|
|||
return p.replace(/ /g, "\\ ");
|
||||
}
|
||||
|
||||
async function buildConfigTs() {
|
||||
if (!fs.existsSync(getConfigTsPath())) {
|
||||
async function buildConfigTs(ide: IDE, ideType: IdeType) {
|
||||
const configTsPath = getConfigTsPath();
|
||||
|
||||
if (!fs.existsSync(configTsPath)) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
try {
|
||||
if (process.env.IS_BINARY === "true") {
|
||||
execSync(
|
||||
`${escapeSpacesInPath(path.dirname(process.execPath))}/esbuild${
|
||||
getTarget().startsWith("win32") ? ".exe" : ""
|
||||
} ${escapeSpacesInPath(
|
||||
getConfigTsPath(),
|
||||
)} --bundle --outfile=${escapeSpacesInPath(
|
||||
getConfigJsPath(),
|
||||
)} --platform=node --format=cjs --sourcemap --external:fetch --external:fs --external:path --external:os --external:child_process`,
|
||||
);
|
||||
} else {
|
||||
// Dynamic import esbuild so potentially disastrous errors can be caught
|
||||
const esbuild = await import("esbuild");
|
||||
const defaultContent = `export function modifyConfig(config: Config): Config {
|
||||
return config;
|
||||
}`;
|
||||
|
||||
await esbuild.build({
|
||||
entryPoints: [getConfigTsPath()],
|
||||
bundle: true,
|
||||
platform: "node",
|
||||
format: "cjs",
|
||||
outfile: getConfigJsPath(),
|
||||
external: ["fetch", "fs", "path", "os", "child_process"],
|
||||
sourcemap: true,
|
||||
});
|
||||
// Read the current content of config.ts
|
||||
const currentContent = fs.readFileSync(configTsPath, "utf8");
|
||||
|
||||
// Check if the current content matches the default content
|
||||
if (currentContent.trim() !== defaultContent.trim()) {
|
||||
// Config.ts has been modified
|
||||
const esbuildPath = getEsbuildBinaryPath();
|
||||
const globalContext = new GlobalContext();
|
||||
|
||||
if (
|
||||
ideType === "jetbrains" &&
|
||||
!globalContext.get("hasReceivedConfigTsNoticeJetBrains")
|
||||
) {
|
||||
try {
|
||||
fs.accessSync(esbuildPath);
|
||||
} catch (error) {
|
||||
globalContext.update("hasReceivedConfigTsNoticeJetBrains", true);
|
||||
|
||||
const actionMsg = "Install esbuild";
|
||||
|
||||
const res = await ide.showToast(
|
||||
"info",
|
||||
"You're using a custom 'config.ts' file, which requires 'esbuild' to be installed. Would you like to install it now?",
|
||||
actionMsg,
|
||||
);
|
||||
|
||||
if (res === actionMsg) {
|
||||
const url = "https://esbuild.github.io/dl/v0.19.11";
|
||||
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const binaryData = await response.arrayBuffer();
|
||||
|
||||
fs.writeFileSync(
|
||||
esbuildPath,
|
||||
new Uint8Array(binaryData as ArrayBuffer),
|
||||
);
|
||||
|
||||
fs.chmodSync(esbuildPath, 0o755);
|
||||
|
||||
await ide.showToast(
|
||||
"info",
|
||||
`'esbuild' successfully installed to ${esbuildPath}`,
|
||||
);
|
||||
} catch (error) {
|
||||
console.debug("Error downloading or saving esbuild binary:", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (process.env.IS_BINARY === "true") {
|
||||
execSync(
|
||||
`${escapeSpacesInPath(getEsbuildBinaryPath())} ${escapeSpacesInPath(
|
||||
getConfigTsPath(),
|
||||
)} --bundle --outfile=${escapeSpacesInPath(
|
||||
getConfigJsPath(),
|
||||
)} --platform=node --format=cjs --sourcemap --external:fetch --external:fs --external:path --external:os --external:child_process`,
|
||||
);
|
||||
} else {
|
||||
// Dynamic import esbuild so potentially disastrous errors can be caught
|
||||
const { build } = await import("esbuild");
|
||||
|
||||
await build({
|
||||
entryPoints: [getConfigTsPath()],
|
||||
bundle: true,
|
||||
platform: "node",
|
||||
format: "cjs",
|
||||
outfile: getConfigJsPath(),
|
||||
external: ["fetch", "fs", "path", "os", "child_process"],
|
||||
sourcemap: true,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(
|
||||
`Build error. Please check your ~/.continue/config.ts file: ${e}`,
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(
|
||||
`Build error. Please check your ~/.continue/config.ts file: ${e}`,
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (!fs.existsSync(getConfigJsPath())) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return fs.readFileSync(getConfigJsPath(), "utf8");
|
||||
}
|
||||
|
||||
|
@ -590,7 +650,7 @@ async function loadFullConfigNode(
|
|||
let intermediate = await serializedToIntermediateConfig(serialized, ide);
|
||||
|
||||
// Apply config.ts to modify intermediate config
|
||||
const configJsContents = await buildConfigTs();
|
||||
const configJsContents = await buildConfigTs(ide, ideType);
|
||||
if (configJsContents) {
|
||||
try {
|
||||
// Try config.ts first
|
||||
|
|
|
@ -13,6 +13,7 @@ export type GlobalContextType = {
|
|||
* For VS Code users, it is unnecessary since we use transformers.js by default.
|
||||
*/
|
||||
curEmbeddingsProviderId: EmbeddingsProvider["id"];
|
||||
hasReceivedConfigTsNoticeJetBrains: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,10 @@ dotenv.config();
|
|||
const CONTINUE_GLOBAL_DIR =
|
||||
process.env.CONTINUE_GLOBAL_DIR ?? path.join(os.homedir(), ".continue");
|
||||
|
||||
export const DEFAULT_CONFIG_TS_CONTENTS = `export function modifyConfig(config: Config): Config {
|
||||
return config;
|
||||
}`;
|
||||
|
||||
export function getChromiumPath(): string {
|
||||
return path.join(getContinueUtilsPath(), ".chromium-browser-snapshots");
|
||||
}
|
||||
|
@ -80,12 +84,7 @@ export function getConfigJsonPath(ideType: IdeType = "vscode"): string {
|
|||
export function getConfigTsPath(): string {
|
||||
const p = path.join(getContinueGlobalPath(), "config.ts");
|
||||
if (!fs.existsSync(p)) {
|
||||
fs.writeFileSync(
|
||||
p,
|
||||
`export function modifyConfig(config: Config): Config {
|
||||
return config;
|
||||
}`,
|
||||
);
|
||||
fs.writeFileSync(p, DEFAULT_CONFIG_TS_CONTENTS);
|
||||
}
|
||||
|
||||
const typesPath = path.join(getContinueGlobalPath(), "types");
|
||||
|
@ -345,3 +344,7 @@ export function readAllGlobalPromptFiles(
|
|||
export function getRepoMapFilePath(): string {
|
||||
return path.join(getContinueUtilsPath(), "repo_map.txt");
|
||||
}
|
||||
|
||||
export function getEsbuildBinaryPath(): string {
|
||||
return path.join(getContinueUtilsPath(), "esbuild");
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ pluginSinceBuild=223
|
|||
#pluginUntilBuild = 232.*
|
||||
# IntelliJ Platform Properties -> https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html#configuration-intellij-extension
|
||||
platformType=IC
|
||||
platformVersion=2023.2
|
||||
platformVersion=2022.3.3
|
||||
#platformVersion = LATEST-EAP-SNAPSHOT
|
||||
# Plugin Dependencies -> https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html
|
||||
# Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
|
||||
|
@ -23,4 +23,4 @@ org.gradle.configuration-cache=true
|
|||
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
|
||||
org.gradle.caching=true
|
||||
# Enable Gradle Kotlin DSL Lazy Property Assignment -> https://docs.gradle.org/current/userguide/kotlin_dsl.html#kotdsl:assignment
|
||||
systemProp.org.gradle.unsafe.kotlin.assignment=true
|
||||
systemProp.org.gradle.unsafe.kotlin.assignment=true
|
|
@ -1,5 +1,4 @@
|
|||
const fs = require("fs");
|
||||
const os = require("os");
|
||||
const { execSync } = require("child_process");
|
||||
|
||||
function execCmdSync(cmd) {
|
||||
|
@ -91,7 +90,9 @@ function validateFilesPresent(pathsToVerify) {
|
|||
|
||||
if (missingFiles.length > 0 || emptyFiles.length > 0) {
|
||||
throw new Error(
|
||||
`The following files were missing:\n- ${missingFiles.join("\n- ")}\n\nThe following files were empty:\n- ${emptyFiles.join("\n- ")}`,
|
||||
`The following files were missing:\n- ${missingFiles.join(
|
||||
"\n- ",
|
||||
)}\n\nThe following files were empty:\n- ${emptyFiles.join("\n- ")}`,
|
||||
);
|
||||
} else {
|
||||
console.log("All paths exist");
|
||||
|
|
Loading…
Reference in New Issue