Skip to content
Merged

Dev #76

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 75 additions & 17 deletions builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,9 @@ enum Commands {
/// Build everything.
Build,
/// Build the Client.
ClientBuild {
/// True to build for distribution, instead of development.
#[arg(short, long, default_value_t = false)]
dist: bool,
/// True to skip checks for TypeScript errors in the Client.
#[arg(short, long, default_value_t = false)]
skip_check_errors: bool,
},
ClientBuild(TypeScriptBuildOptions),
/// Build the extensions.
ExtBuild(TypeScriptBuildOptions),
/// Change the version for the client, server, and extensions.
ChangeVersion {
/// The new version number, such as "0.1.1".
Expand All @@ -107,6 +102,16 @@ enum Commands {
},
}

#[derive(Parser)]
struct TypeScriptBuildOptions {
/// True to build for distribution, instead of development.
#[arg(short, long, default_value_t = false)]
dist: bool,
/// True to skip checks for TypeScript errors in the Client.
#[arg(short, long, default_value_t = false)]
skip_check_errors: bool,
}

// Code
// ----
//
Expand Down Expand Up @@ -340,7 +345,7 @@ fn run_install(dev: bool) -> io::Result<()> {
// of `--no-frozen-lockfile`.
run_script("pnpm", &["install"], "../client", true)?;
patch_client_libs()?;
run_script("npm", &["install"], "../extensions/VSCode", true)?;
run_script("pnpm", &["install"], "../extensions/VSCode", true)?;
run_cmd!(
cargo fetch --manifest-path=../builder/Cargo.toml;
cargo fetch;
Expand All @@ -361,14 +366,14 @@ fn run_install(dev: bool) -> io::Result<()> {
fn run_update() -> io::Result<()> {
run_script("pnpm", &["update"], "../client", true)?;
patch_client_libs()?;
run_script("npm", &["update"], "../extensions/VSCode", true)?;
run_script("pnpm", &["update"], "../extensions/VSCode", true)?;
run_cmd!(
cargo update --manifest-path=../builder/Cargo.toml;
cargo update;
)?;
// Simply display outdated dependencies, but don't consider them an error.
run_script("pnpm", &["outdated"], "../client", false)?;
run_script("npm", &["outdated"], "../extensions/VSCode", false)?;
run_script("pnpm", &["outdated"], "../extensions/VSCode", false)?;
run_cmd!(
cargo outdated --manifest-path=../builder/Cargo.toml;
cargo outdated;
Expand Down Expand Up @@ -411,7 +416,7 @@ fn run_build() -> io::Result<()> {
// Clean out all bundled files before the rebuild.
remove_dir_all_if_exists("../client/static/bundled")?;
run_client_build(false, false)?;
run_script("npm", &["run", "compile"], "../extensions/VSCode", true)?;
run_extensions_build(false, false)?;
Ok(())
}

Expand Down Expand Up @@ -500,6 +505,48 @@ fn run_client_build(
Ok(())
}

// Build the CodeChat Editor extensions.
fn run_extensions_build(
// True to build for distribution, not development.
dist: bool,
// True to skip checking for TypeScript errors; false to perform these
// checks.
skip_check_errors: bool,
) -> io::Result<()> {
let esbuild = PathBuf::from_slash("node_modules/.bin/esbuild");
let distflag = if dist { "--minify" } else { "--sourcemap" };
// This makes the program work from either the `server/` or `client/`
// directories.
let rel_path = "../extensions/VSCode";

// The main build for the Client.
run_script(
&esbuild,
&[
"src/extension.ts",
"--platform=node",
"--format=cjs",
"--bundle",
// Don't bundle the VSCode library, since it's built in.
"--external:vscode",
"--outdir=./out",
distflag,
],
rel_path,
true,
)?;
// Finally, check the TypeScript with the (slow) TypeScript compiler.
if !skip_check_errors {
run_script(
PathBuf::from_slash("node_modules/.bin/tsc"),
&["-noEmit"],
rel_path,
true,
)?;
}
Ok(())
}

fn run_change_version(new_version: &String) -> io::Result<()> {
let replacement_string = format!("${{1}}{new_version}${{2}}");
search_and_replace_file(
Expand Down Expand Up @@ -553,7 +600,16 @@ fn run_postrelease(target: &str) -> io::Result<()> {
)?;
run_script(
"npx",
&["vsce", "package", "--target", vsce_target],
&[
"vsce",
"package",
// We use esbuild to package; therefore, tell `vsce` not to package.
"--no-dependencies",
// Since we include the server as a binary, package for the
// architecture the binary was build for.
"--target",
vsce_target,
],
"../extensions/VSCode",
true,
)?;
Expand All @@ -573,10 +629,12 @@ impl Cli {
Commands::Update => run_update(),
Commands::Test => run_test(),
Commands::Build => run_build(),
Commands::ClientBuild {
dist,
skip_check_errors,
} => run_client_build(*dist, *skip_check_errors),
Commands::ClientBuild(build_options) => {
run_client_build(build_options.dist, build_options.skip_check_errors)
}
Commands::ExtBuild(build_options) => {
run_extensions_build(build_options.dist, build_options.skip_check_errors)
}
Commands::ChangeVersion { new_version } => run_change_version(new_version),
Commands::Prerelease => run_prerelease(),
Commands::Postrelease { target, .. } => run_postrelease(target),
Expand Down
5 changes: 3 additions & 2 deletions client/package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
type: 'module',
version: '0.1.31',
dependencies: {
'@codemirror/commands': '^6.8.1',
'@codemirror/lang-cpp': '^6.0.3',
'@codemirror/lang-css': '^6.3.1',
'@codemirror/lang-go': '^6.0.1',
Expand All @@ -58,7 +59,7 @@
'@codemirror/lang-rust': '^6.0.2',
'@codemirror/lang-xml': '^6.1.0',
'@codemirror/state': '^6.5.2',
'@codemirror/view': '^6.38.1',
'@codemirror/view': '^6.38.2',
'@mathjax/mathjax-newcm-font': '4.0.0',
codemirror: '^6.0.2',
'graphviz-webcomponent': '^2.0.0',
Expand All @@ -83,7 +84,7 @@
'eslint-config-prettier': '^10.1.8',
'eslint-plugin-import': '^2.32.0',
'eslint-plugin-prettier': '^5.5.4',
mocha: '^11.7.1',
mocha: '^11.7.2',
prettier: '^3.6.2',
typescript: '^5.9.2',
},
Expand Down
43 changes: 23 additions & 20 deletions client/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/src/CodeChatEditorFramework.mts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
// The max length of a message to show in the console.
const MAX_MESSAGE_LENGTH = 200;
// The timeout for a websocket `Response`, in ms.
const RESPONSE_TIMEOUT_MS = 1500000;
const RESPONSE_TIMEOUT_MS = 15000;

// An instance of the websocket communication class.
let webSocketComm: WebSocketComm;
Expand Down
Loading
Loading