Skip to content
Merged

Dev #83

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
2 changes: 2 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
},
"vscode": {
"settings": {
// Use the local build of the CodeChat Editor, instead of the one packaged with the
// VSCode extension.
"CodeChatEditor.Server.Command": "/workspaces/CodeChat_Editor/server/target/debug/codechat-editor-server"
},
"extensions": [
Expand Down
6 changes: 2 additions & 4 deletions .devcontainer/postStartCommand.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

cd server
# TODO: this doesn't open a file from the codespace, unfortunately.
cargo run -- start ../README.md
#
# Currently, nothing needs to be done after the build completes.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ Changelog

* No changes.

Version 0.1.35 -- 2025-Sep-12
-----------------------------

* Embed the CodeChat Editor Server inside the VSCode extension, rather than
running it as a standalone binary.
* Fixes to the build process.

Version 0.1.34 -- 2025-Sep-08
-----------------------------

Expand Down
4 changes: 2 additions & 2 deletions builder/Cargo.lock

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

70 changes: 52 additions & 18 deletions builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ fn quick_copy_dir<P: AsRef<Path>>(src: P, dest: P, files: Option<P>) -> io::Resu
}
}

fn copy_file<P: AsRef<Path> + std::fmt::Debug>(src: P, dest: P) -> io::Result<()> {
println!("copy {src:?} -> {dest:?}");
fs::copy(src, dest).map(|_| ())
}

fn remove_dir_all_if_exists<P: AsRef<Path> + std::fmt::Display>(path: P) -> io::Result<()> {
if Path::new(path.as_ref()).try_exists().unwrap() {
fs::remove_dir_all(path.as_ref())?;
Expand Down Expand Up @@ -357,6 +362,8 @@ fn run_install(dev: bool) -> io::Result<()> {
run_cmd!(
info "Builder: cargo fetch";
cargo fetch --manifest-path=../builder/Cargo.toml;
info "VSCode extension: cargo fetch";
cargo fetch --manifest-path=../extensions/VSCode/Cargo.toml;
info "cargo fetch";
cargo fetch;
)?;
Expand Down Expand Up @@ -387,6 +394,8 @@ fn run_update() -> io::Result<()> {
run_cmd!(
info "Builder: cargo update";
cargo update --manifest-path=../builder/Cargo.toml;
info "VSCoe extension: cargo update";
cargo update --manifest-path=../extensions/VSCode/Cargo.toml;
info "cargo update";
cargo update;
)?;
Expand All @@ -396,6 +405,8 @@ fn run_update() -> io::Result<()> {
run_cmd!(
info "Builder: cargo outdated";
cargo outdated --manifest-path=../builder/Cargo.toml;
info "VSCode extension: cargo outdated";
cargo outdated --manifest-path=../extensions/VSCode/Cargo.toml;
info "cargo outdated";
cargo outdated;
)?;
Expand All @@ -412,11 +423,17 @@ fn run_test() -> io::Result<()> {
info "Builder: cargo clippy and fmt";
cargo clippy --all-targets --manifest-path=../builder/Cargo.toml -- -D warnings;
cargo fmt --check --manifest-path=../builder/Cargo.toml;
info "VSCode extension: cargo clippy and fmt";
cargo clippy --all-targets --manifest-path=../extensions/VSCode/Cargo.toml -- -D warnings;
cargo fmt --check --manifest-path=../extensions/VSCode/Cargo.toml;
info "cargo sort";
cargo sort --check;
cd ../builder;
info "Builder: cargo sort";
cargo sort --check;
cd ../extensions/VSCode;
info "VSCode extension: cargo sort";
cargo sort --check;
)?;
run_build()?;
// Verify that compiling for release produces no errors.
Expand All @@ -428,6 +445,8 @@ fn run_test() -> io::Result<()> {
run_cmd!(
info "Builder: cargo test";
cargo test --manifest-path=../builder/Cargo.toml;
info "VSCode extension: cargo test";
cargo test --manifest-path=../extensions/VSCode/Cargo.toml;
info "cargo test";
cargo test;
)?;
Expand Down Expand Up @@ -458,6 +477,12 @@ fn run_client_build(
// checks.
skip_check_errors: bool,
) -> io::Result<()> {
// Ensure the JavaScript data structured generated from Rust are up to date.
run_cmd!(
info "cargo test export_bindings";
cargo test export_bindings;
)?;

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/`
Expand Down Expand Up @@ -549,6 +574,13 @@ fn run_extensions_build(
// directories.
let rel_path = "../extensions/VSCode";

// The NAPI build.
let mut napi_args = vec!["napi", "build", "--platform", "--output-dir", "src"];
if dist {
napi_args.push("--release");
}
run_script("npx", &napi_args, rel_path, true)?;

// The main build for the Client.
run_script(
&esbuild,
Expand All @@ -561,6 +593,11 @@ fn run_extensions_build(
"--external:vscode",
"--outdir=./out",
distflag,
// The binaries produced by NAPI-RS should be copied over.
"--loader:.node=copy",
// Avoid the default of adding hash names to the `.node` file
// generated.
"--asset-names=[name]",
],
rel_path,
true,
Expand All @@ -578,10 +615,12 @@ fn run_extensions_build(
}

fn run_change_version(new_version: &String) -> io::Result<()> {
let cargo_regex = r#"(\r?\nversion = ")[\d.]+("\r?\n)"#;
let replacement_string = format!("${{1}}{new_version}${{2}}");
search_and_replace_file("Cargo.toml", cargo_regex, &replacement_string)?;
search_and_replace_file(
"Cargo.toml",
r#"(\r?\nversion = ")[\d.]+("\r?\n)"#,
"../extensions/VSCode/Cargo.toml",
cargo_regex,
&replacement_string,
)?;
search_and_replace_file(
Expand All @@ -601,18 +640,20 @@ fn run_prerelease() -> io::Result<()> {
// Clean out all bundled files before the rebuild.
remove_dir_all_if_exists("../client/static/bundled")?;
run_install(true)?;
run_cmd!(
info "cargo test export_bindings";
cargo test export_bindings;
)?;
run_script("pnpm", &["run", "dist"], "../client", true)?;
Ok(())
run_client_build(true, false)
}

fn run_postrelease(target: &str) -> io::Result<()> {
let server_dir = "../extensions/VSCode/server";
// Only clean the `server/` directory if it exists.
remove_dir_all_if_exists(server_dir)?;
// Copy all the Client static files needed by the embedded Server to the
// VSCode extension.
let client_static_dir = "../extensions/VSCode/static";
remove_dir_all_if_exists(client_static_dir)?;
quick_copy_dir("../client/static/", client_static_dir, None)?;
copy_file("log4rs.yml", "../extensions/VSCode/log4rs.yml")?;
copy_file(
"hashLocations.json",
"../extensions/VSCode/hashLocations.json",
)?;

// Translate from the target triple to VSCE's target parameter.
let vsce_target = match target {
Expand All @@ -622,13 +663,6 @@ fn run_postrelease(target: &str) -> io::Result<()> {
"aarch64-apple-darwin" => "darwin-arm64",
_ => panic!("Unsupported platform {target}."),
};

let src_name = format!("codechat-editor-server-{target}");
quick_copy_dir(
format!("../target/distrib/{src_name}/").as_str(),
"../extensions/VSCode/server",
None,
)?;
run_script(
"npx",
&[
Expand Down
8 changes: 4 additions & 4 deletions client/package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
url: 'https://github.com/bjones1/CodeChat_editor',
},
type: 'module',
version: '0.1.34',
version: '0.1.35',
dependencies: {
'@codemirror/commands': '^6.8.1',
'@codemirror/lang-cpp': '^6.0.3',
'@codemirror/lang-css': '^6.3.1',
'@codemirror/lang-go': '^6.0.1',
'@codemirror/lang-html': '^6.4.9',
'@codemirror/lang-html': '^6.4.10',
'@codemirror/lang-java': '^6.0.2',
'@codemirror/lang-javascript': '^6.2.4',
'@codemirror/lang-json': '^6.0.2',
Expand All @@ -65,7 +65,7 @@
'graphviz-webcomponent': 'github:bjones1/graphviz-webcomponent#dist',
mathjax: '4.0.0',
mermaid: '^11.11.0',
'npm-check-updates': '^18.1.0',
'npm-check-updates': '^18.1.1',
'pdfjs-dist': '^5.4.149',
tinymce: '^8.0.2',
'toastify-js': '^1.12.0',
Expand All @@ -74,7 +74,7 @@
'@types/chai': '^5.2.2',
'@types/js-beautify': '^1.14.3',
'@types/mocha': '^10.0.10',
'@types/node': '^24.3.1',
'@types/node': '^24.3.3',
'@types/toastify-js': '^1.12.4',
'@typescript-eslint/eslint-plugin': '^8.43.0',
'@typescript-eslint/parser': '^8.43.0',
Expand Down
Loading
Loading