From 5e612219d18ebd75c720c009b0c1fab1b6ccfe90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20F=C3=B6rster?= Date: Tue, 30 Jul 2019 14:05:04 +0200 Subject: [PATCH] Move citeproc into a separate crate --- .build-steps.yml | 5 ----- Cargo.lock | 17 ++++++++++++++++ Cargo.toml | 7 ++++++- README.md | 6 +----- crates/texlab_citeproc/Cargo.toml | 20 +++++++++++++++++++ crates/texlab_citeproc/build.rs | 20 +++++++++++++++++++ .../texlab_citeproc/script}/.gitignore | 0 .../texlab_citeproc/script}/.prettierrc | 0 .../texlab_citeproc/script}/package-lock.json | 0 .../texlab_citeproc/script}/package.json | 0 .../script}/src/citation-js.d.ts | 0 .../texlab_citeproc/script}/src/main.ts | 0 .../texlab_citeproc/script}/tsconfig.json | 0 .../texlab_citeproc/script}/tslint.json | 0 .../texlab_citeproc/script}/webpack.config.ts | 0 .../texlab_citeproc/src/lib.rs | 5 ++++- src/data/mod.rs | 1 - src/hover/latex_citation.rs | 2 +- src/server.rs | 2 +- 19 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 crates/texlab_citeproc/Cargo.toml create mode 100644 crates/texlab_citeproc/build.rs rename {citeproc => crates/texlab_citeproc/script}/.gitignore (100%) rename {citeproc => crates/texlab_citeproc/script}/.prettierrc (100%) rename {citeproc => crates/texlab_citeproc/script}/package-lock.json (100%) rename {citeproc => crates/texlab_citeproc/script}/package.json (100%) rename {citeproc => crates/texlab_citeproc/script}/src/citation-js.d.ts (100%) rename {citeproc => crates/texlab_citeproc/script}/src/main.ts (100%) rename {citeproc => crates/texlab_citeproc/script}/tsconfig.json (100%) rename {citeproc => crates/texlab_citeproc/script}/tslint.json (100%) rename {citeproc => crates/texlab_citeproc/script}/webpack.config.ts (100%) rename src/data/citation.rs => crates/texlab_citeproc/src/lib.rs (96%) diff --git a/.build-steps.yml b/.build-steps.yml index f390db666..39b06d0a8 100644 --- a/.build-steps.yml +++ b/.build-steps.yml @@ -10,11 +10,6 @@ steps: inputs: versionSpec: ">=10.x" displayName: "Install Node.js" - - bash: | - cd citeproc - npm ci - npm run dist - displayName: "Bundle citeproc" - ${{ if eq(parameters.coverage, 'false') }}: - bash: | export RUST_BACKTRACE=1 diff --git a/Cargo.lock b/Cargo.lock index 10d9a0886..4af89d0ef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2057,6 +2057,7 @@ dependencies = [ "serde_repr 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "stderrlog 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "texlab-citeproc 0.1.0", "texlab-syntax 0.1.0", "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", "tokio-codec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2068,6 +2069,22 @@ dependencies = [ "walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "texlab-citeproc" +version = "0.1.0" +dependencies = [ + "futures-preview 0.3.0-alpha.16 (registry+https://github.com/rust-lang/crates.io-index)", + "html2md 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", + "lsp-types 0.57.1 (git+https://github.com/latex-lsp/lsp-types?rev=9fcc5d9b9d3013ce84e20ef566267754d594b268)", + "runtime 0.3.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "runtime-tokio 0.3.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.97 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "texlab-syntax 0.1.0", + "tokio 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-process 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "texlab-syntax" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 19994463f..f7e51adb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,11 @@ authors = [ edition = "2018" [workspace] -members = ["./jsonrpc", "./jsonrpc_derive", "crates/texlab_syntax"] +members = [ + "jsonrpc", + "jsonrpc_derive", + "crates/texlab_citeproc", + "crates/texlab_syntax"] [dependencies] base64 = "0.10.1" @@ -36,6 +40,7 @@ serde_json = "1.0.40" serde_repr = "0.1" stderrlog = "0.4.1" tempfile = "3" +texlab-citeproc = { path = "crates/texlab_citeproc" } texlab-syntax = { path = "crates/texlab_syntax" } tokio = "0.1" tokio-codec = "0.1" diff --git a/README.md b/README.md index c8cb30d0d..5aa9f8329 100644 --- a/README.md +++ b/README.md @@ -21,13 +21,9 @@ You will need to install the following dependencies to compile the server: - [Rust](https://rustup.rs/) - [Node.js](https://nodejs.org/) -Then run the following commands in the project folder: +Then run the following command in the project folder: ```shell -cd citeproc -npm install -npm run dist -cd .. cargo build --release ``` diff --git a/crates/texlab_citeproc/Cargo.toml b/crates/texlab_citeproc/Cargo.toml new file mode 100644 index 000000000..185893155 --- /dev/null +++ b/crates/texlab_citeproc/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "texlab-citeproc" +version = "0.1.0" +authors = [ + "Eric Förster ", + "Patrick Förster "] +edition = "2018" + +[dependencies] +futures-preview = { version = "0.3.0-alpha.15", features = ["compat"] } +html2md = "0.2.9" +lsp-types = { git = "https://github.com/latex-lsp/lsp-types", rev = "9fcc5d9b9d3013ce84e20ef566267754d594b268", features = ["proposed"] } +runtime = "0.3.0-alpha.4" +runtime-tokio = "0.3.0-alpha.4" +serde = { version = "1.0.97", features = ["derive", "rc"] } +tempfile = "3" +texlab-syntax = { path = "../texlab_syntax" } +tokio = "0.1" +tokio-process = "0.2.4" + diff --git a/crates/texlab_citeproc/build.rs b/crates/texlab_citeproc/build.rs new file mode 100644 index 000000000..0e8d0d02c --- /dev/null +++ b/crates/texlab_citeproc/build.rs @@ -0,0 +1,20 @@ +use std::process::Command; + +fn sh(command: &'static str) { + let (executable, args) = if cfg!(windows) { + ("cmd", vec!["/C", command]) + } else { + ("sh", vec!["-c", command]) + }; + + Command::new(executable) + .args(args) + .current_dir("script") + .output() + .expect(&format!("Failed to execute \"{}\"", command)); +} + +fn main() { + sh("npm ci"); + sh("npm run dist"); +} diff --git a/citeproc/.gitignore b/crates/texlab_citeproc/script/.gitignore similarity index 100% rename from citeproc/.gitignore rename to crates/texlab_citeproc/script/.gitignore diff --git a/citeproc/.prettierrc b/crates/texlab_citeproc/script/.prettierrc similarity index 100% rename from citeproc/.prettierrc rename to crates/texlab_citeproc/script/.prettierrc diff --git a/citeproc/package-lock.json b/crates/texlab_citeproc/script/package-lock.json similarity index 100% rename from citeproc/package-lock.json rename to crates/texlab_citeproc/script/package-lock.json diff --git a/citeproc/package.json b/crates/texlab_citeproc/script/package.json similarity index 100% rename from citeproc/package.json rename to crates/texlab_citeproc/script/package.json diff --git a/citeproc/src/citation-js.d.ts b/crates/texlab_citeproc/script/src/citation-js.d.ts similarity index 100% rename from citeproc/src/citation-js.d.ts rename to crates/texlab_citeproc/script/src/citation-js.d.ts diff --git a/citeproc/src/main.ts b/crates/texlab_citeproc/script/src/main.ts similarity index 100% rename from citeproc/src/main.ts rename to crates/texlab_citeproc/script/src/main.ts diff --git a/citeproc/tsconfig.json b/crates/texlab_citeproc/script/tsconfig.json similarity index 100% rename from citeproc/tsconfig.json rename to crates/texlab_citeproc/script/tsconfig.json diff --git a/citeproc/tslint.json b/crates/texlab_citeproc/script/tslint.json similarity index 100% rename from citeproc/tslint.json rename to crates/texlab_citeproc/script/tslint.json diff --git a/citeproc/webpack.config.ts b/crates/texlab_citeproc/script/webpack.config.ts similarity index 100% rename from citeproc/webpack.config.ts rename to crates/texlab_citeproc/script/webpack.config.ts diff --git a/src/data/citation.rs b/crates/texlab_citeproc/src/lib.rs similarity index 96% rename from src/data/citation.rs rename to crates/texlab_citeproc/src/lib.rs index f4d5f37a5..bde33d75f 100644 --- a/src/data/citation.rs +++ b/crates/texlab_citeproc/src/lib.rs @@ -1,3 +1,5 @@ +#![feature(async_await)] + use texlab_syntax::*; use futures::compat::*; use lsp_types::*; @@ -5,6 +7,7 @@ use std::process::{Command, Stdio}; use tempfile::tempdir; use tokio_process::CommandExt; + #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum RenderCitationError { InitializationFailed, @@ -59,7 +62,7 @@ pub async fn render_citation(entry_code: &str) -> Result