Clean-up deps, fix vscode ext, refactor linter (#697)

* replace `atty` with std::io::IsTerminal; MSRV 1.70

* Hide linter behind feature, enabled by default

- make `lint` subcommand a feature-gated, enabled
  by default; only available to build, it will not
  be distributed by default, if it introduces a
  regression, it will be reverted; closes #694

- clean-up code a bit, make `lsp` subcommand fail
  properly as no subcommand found since the errors
  are swallowed somewhere before reaching stderr

- remove references to `reqwest::Url`, use
  `url::Url` exclusively

* update rustls

* update wasm-bindgen

* update indexmap

* fix wasm panic in vscode extension
This commit is contained in:
Jakub Panek 2024-11-04 17:25:08 +01:00 committed by GitHub
parent db31b2b1e3
commit 9acabdf72e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 881 additions and 731 deletions

26
Cargo.lock generated
View file

@ -182,17 +182,6 @@ dependencies = [
"bytemuck",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi 0.1.19",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.1.0"
@ -862,15 +851,6 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "hermit-abi"
version = "0.3.6"
@ -1020,7 +1000,7 @@ version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f23ff5ef2b80d608d61efee834934d862cd92461afc0560dedf493e4c033738b"
dependencies = [
"hermit-abi 0.3.6",
"hermit-abi",
"libc",
"windows-sys 0.52.0",
]
@ -1424,7 +1404,7 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
dependencies = [
"hermit-abi 0.3.6",
"hermit-abi",
"libc",
]
@ -2208,7 +2188,6 @@ dependencies = [
"ansi_term",
"anyhow",
"async-ctrlc",
"atty",
"clap",
"codespan-reporting",
"futures",
@ -2243,7 +2222,6 @@ dependencies = [
"arc-swap",
"async-recursion",
"async-trait",
"atty",
"futures",
"glob",
"globset",

View file

@ -12,11 +12,12 @@ license = { workspace = true }
repository = { workspace = true }
[features]
default = ["lsp", "rustls-tls", "toml-test"]
lsp = ["async-ctrlc", "taplo-lsp"]
default = ["lint", "lsp", "rustls-tls", "toml-test"]
lint = ["taplo-common/schema", "taplo-common/reqwest", "reqwest"]
lsp = ["async-ctrlc", "taplo-lsp", "lint"]
native-tls = ["taplo-common/native-tls", "taplo-lsp?/native-tls"]
rustls-tls = ["taplo-common/rustls-tls", "taplo-lsp?/rustls-tls"]
toml-test = []
toml-test = ["lint"]
[dependencies]
taplo = { path = "../taplo", features = ["serde"] }
@ -32,7 +33,7 @@ hex = { workspace = true }
itertools = { workspace = true }
once_cell = { workspace = true }
regex = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
reqwest = { workspace = true, features = ["json"], optional = true }
schemars = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
@ -45,7 +46,6 @@ url = { workspace = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
ansi_term = { version = "0.12" }
async-ctrlc = { version = "1.2.0", features = ["stream"], optional = true }
atty = { version = "0.2.14" }
lsp-async-stub = { path = "../lsp-async-stub", features = ["tokio-tcp", "tokio-stdio"] }
# `prettydiff` is also a CLI that pulls in `clap` by default
prettydiff = { version = "0.6.1", default-features = false }

View file

@ -1,5 +1,6 @@
use clap::{crate_version, Args, Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[cfg(feature = "lint")]
use url::Url;
#[derive(Clone, Parser)]
@ -48,25 +49,32 @@ pub enum Colors {
pub enum TaploCommand {
/// Lint TOML documents.
#[clap(visible_aliases = &["check", "validate"])]
#[cfg(feature = "lint")]
Lint(LintCommand),
/// Format TOML documents.
///
/// Files are modified in-place unless the input comes from the standard input, in which case the formatted result is printed to the standard output.
#[clap(visible_aliases = &["fmt"])]
Format(FormatCommand),
/// Language server operations.
#[cfg(feature = "lsp")]
Lsp {
#[clap(flatten)]
cmd: LspCommand,
},
/// Operations with the Taplo config file.
#[clap(visible_aliases = &["cfg"])]
Config {
#[clap(subcommand)]
cmd: ConfigCommand,
},
/// Extract a value from the given TOML document.
Get(GetCommand),
/// Start a decoder for `toml-test` (https://github.com/BurntSushi/toml-test).
#[cfg(feature = "toml-test")]
TomlTest {},
@ -108,6 +116,7 @@ pub struct FormatCommand {
pub stdin_filepath: Option<String>,
}
#[cfg(feature = "lsp")]
#[derive(Clone, Args)]
pub struct LspCommand {
#[clap(flatten)]
@ -117,6 +126,7 @@ pub struct LspCommand {
pub io: LspCommandIo,
}
#[cfg(feature = "lsp")]
#[derive(Clone, Subcommand)]
pub enum LspCommandIo {
/// Run the language server and listen on a TCP address.
@ -137,6 +147,7 @@ pub enum ConfigCommand {
Schema,
}
#[cfg(feature = "lint")]
#[derive(Clone, Args)]
pub struct LintCommand {
#[clap(flatten)]

View file

@ -7,6 +7,7 @@ use crate::{
mod config;
mod format;
#[cfg(feature = "lint")]
mod lint;
#[cfg(feature = "lsp")]
mod lsp;
@ -24,24 +25,15 @@ impl<E: Environment> Taplo<E> {
};
match taplo.cmd {
TaploCommand::Config { cmd } => self.execute_config(cmd).await,
TaploCommand::Format(fmt) => self.execute_format(fmt).await,
TaploCommand::Lsp { cmd } => {
#[cfg(feature = "lsp")]
{
self.execute_lsp(cmd).await
}
#[cfg(not(feature = "lsp"))]
{
let _ = cmd;
Err(anyhow::anyhow!("the LSP is not part of this build, please consult the documentation about enabling the functionality"))
}
}
TaploCommand::Get(cmd) => self.execute_get(cmd).await,
#[cfg(feature = "lint")]
TaploCommand::Lint(cmd) => self.execute_lint(cmd).await,
#[cfg(feature = "lsp")]
TaploCommand::Lsp { cmd } => self.execute_lsp(cmd).await,
#[cfg(feature = "toml-test")]
TaploCommand::TomlTest {} => self.execute_toml_test().await,
TaploCommand::Lint(cmd) => self.execute_lint(cmd).await,
TaploCommand::Config { cmd } => self.execute_config(cmd).await,
TaploCommand::Get(cmd) => self.execute_get(cmd).await,
}
}
}

View file

@ -6,7 +6,9 @@ use std::{
str,
sync::Arc,
};
use taplo_common::{config::Config, environment::Environment, schema::Schemas, util::Normalize};
#[cfg(feature = "lint")]
use taplo_common::schema::Schemas;
use taplo_common::{config::Config, environment::Environment, util::Normalize};
pub mod args;
pub mod commands;
@ -15,20 +17,22 @@ pub mod printing;
pub struct Taplo<E: Environment> {
env: E,
colors: bool,
#[cfg(feature = "lint")]
schemas: Schemas<E>,
config: Option<Arc<Config>>,
}
impl<E: Environment> Taplo<E> {
pub fn new(env: E) -> Self {
#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "lint"))]
let http =
taplo_common::util::get_reqwest_client(std::time::Duration::from_secs(5)).unwrap();
#[cfg(target_arch = "wasm32")]
#[cfg(all(target_arch = "wasm32", feature = "lint"))]
let http = reqwest::Client::default();
Self {
#[cfg(feature = "lint")]
schemas: Schemas::new(env.clone(), http),
colors: env.atty_stderr(),
config: None,

View file

@ -10,7 +10,9 @@ use codespan_reporting::{
use itertools::Itertools;
use std::ops::Range;
use taplo::{dom, parser, rowan::TextRange};
use taplo_common::{environment::Environment, schema::NodeValidationError};
use taplo_common::environment::Environment;
#[cfg(feature = "lint")]
use taplo_common::schema::NodeValidationError;
use tokio::io::AsyncWriteExt;
impl<E: Environment> Taplo<E> {
@ -113,6 +115,7 @@ impl<E: Environment> Taplo<E> {
Ok(())
}
#[cfg(feature = "lint")]
pub(crate) async fn print_schema_errors(
&self,
file: &SimpleFile<&str, &str>,

View file

@ -11,6 +11,13 @@ repository = { workspace = true }
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
# default-tls enables native-tls but without enabling native-tls specific features.
native-tls = ["reqwest/default-tls"]
rustls-tls = ["reqwest/rustls-tls"]
schema = []
reqwest = ["dep:reqwest"]
[dependencies]
taplo = { path = "../taplo", features = ["schema"] }
@ -19,7 +26,6 @@ anyhow = { workspace = true, features = ["backtrace"] }
arc-swap = { workspace = true }
async-recursion = { version = "1.0.0" }
async-trait = { workspace = true }
atty = { version = "0.2.14" }
futures = { workspace = true }
glob = { workspace = true }
globset = { workspace = true }
@ -32,7 +38,7 @@ lru = { version = "0.11.1" }
parking_lot = { workspace = true }
percent-encoding = { version = "2.1.0" }
regex = { workspace = true }
reqwest = { workspace = true, features = ["json"] }
reqwest = { workspace = true, features = ["json"], optional = true }
schemars = { workspace = true, features = ["url"] }
semver = { version = "1.0.5", features = ["serde"] }
serde = { workspace = true, features = ["derive"] }
@ -51,10 +57,5 @@ tokio = { workspace = true, features = ["sync", "fs", "time", "io-std", "parking
[target.'cfg(target_arch = "wasm32")'.dependencies]
tokio = { workspace = true, features = ["sync", "parking_lot", "io-util"] }
[features]
# default-tls enables native-tls but without enabling native-tls specific features.
native-tls = ["reqwest/default-tls"]
rustls-tls = ["reqwest/rustls-tls"]
[package.metadata.auto-tag]
enabled = true

View file

@ -60,7 +60,8 @@ impl Environment for NativeEnvironment {
}
fn atty_stderr(&self) -> bool {
atty::is(atty::Stream::Stderr)
use std::io::IsTerminal;
std::io::stderr().is_terminal()
}
fn stdin(&self) -> Self::Stdin {
@ -94,7 +95,7 @@ impl Environment for NativeEnvironment {
Ok(tokio::fs::write(path, bytes).await?)
}
fn to_file_path(&self, url: &reqwest::Url) -> Option<std::path::PathBuf> {
fn to_file_path(&self, url: &url::Url) -> Option<std::path::PathBuf> {
url.to_file_path().ok()
}

View file

@ -16,6 +16,7 @@ pub mod config;
pub mod convert;
pub mod environment;
pub mod log;
#[cfg(feature = "schema")]
pub mod schema;
pub mod util;

View file

@ -23,9 +23,9 @@ pub mod cache;
pub mod ext;
pub mod builtins {
use reqwest::Url;
use serde_json::Value;
use std::sync::Arc;
use url::Url;
pub const TAPLO_CONFIG_URL: &str = "taplo://taplo.toml";

View file

@ -120,7 +120,7 @@ pub(crate) fn normalize_str(s: &str) -> Cow<str> {
}
}
#[cfg(not(target_arch = "wasm32"))]
#[cfg(all(not(target_arch = "wasm32"), feature = "reqwest"))]
#[tracing::instrument]
pub fn get_reqwest_client(timeout: std::time::Duration) -> Result<reqwest::Client, reqwest::Error> {
#[cfg(any(feature = "native-tls", feature = "rustls-tls"))]

View file

@ -20,7 +20,7 @@ rustls-tls = ["taplo-common/rustls-tls"]
[dependencies]
lsp-async-stub = { path = "../lsp-async-stub" }
taplo = { path = "../taplo", features = ["serde"] }
taplo-common = { path = "../taplo-common" }
taplo-common = { path = "../taplo-common", features = ["schema", "reqwest"] }
anyhow = { workspace = true }
arc-swap = { workspace = true }

View file

@ -150,17 +150,6 @@ dependencies = [
"bytemuck",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi 0.1.19",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.1.0"
@ -649,19 +638,13 @@ dependencies = [
"futures-sink",
"futures-util",
"http",
"indexmap 2.2.3",
"indexmap",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]]
name = "hashbrown"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
[[package]]
name = "hashbrown"
version = "0.14.3"
@ -672,21 +655,18 @@ dependencies = [
"allocator-api2",
]
[[package]]
name = "hashbrown"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "hermit-abi"
version = "0.3.6"
@ -783,22 +763,12 @@ dependencies = [
[[package]]
name = "indexmap"
version = "1.6.2"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
dependencies = [
"autocfg",
"hashbrown 0.9.1",
]
[[package]]
name = "indexmap"
version = "2.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "233cf39063f058ea2caae4091bf4a3ef70a653afbc026f5c4a4135d114e3c177"
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
dependencies = [
"equivalent",
"hashbrown 0.14.3",
"hashbrown 0.15.0",
"rayon",
"serde",
]
@ -841,9 +811,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "js-sys"
version = "0.3.69"
version = "0.3.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d"
checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9"
dependencies = [
"wasm-bindgen",
]
@ -1143,7 +1113,7 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
dependencies = [
"hermit-abi 0.3.6",
"hermit-abi",
"libc",
]
@ -1407,9 +1377,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustls"
version = "0.21.10"
version = "0.21.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba"
checksum = "3f56a14d1f48b391359b22f731fd4bd7e43c97f3c50eee276f3aa09c94784d3e"
dependencies = [
"log",
"ring",
@ -1540,7 +1510,7 @@ version = "1.0.113"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69801b70b1c3dac963ecb03a364ba0ceda9cf60c71cfe475e99864759c8b8a79"
dependencies = [
"indexmap 2.2.3",
"indexmap",
"itoa",
"ryu",
"serde",
@ -1716,7 +1686,6 @@ version = "0.9.3"
dependencies = [
"ansi_term",
"anyhow",
"atty",
"clap",
"codespan-reporting",
"futures",
@ -1727,7 +1696,6 @@ dependencies = [
"once_cell",
"prettydiff",
"regex",
"reqwest",
"schemars",
"serde",
"serde_json",
@ -1750,12 +1718,11 @@ dependencies = [
"arc-swap",
"async-recursion",
"async-trait",
"atty",
"futures",
"glob",
"globset",
"hex",
"indexmap 2.2.3",
"indexmap",
"itertools",
"json_value_merge",
"jsonschema",
@ -1788,7 +1755,7 @@ dependencies = [
"either",
"figment",
"futures",
"indexmap 2.2.3",
"indexmap",
"itertools",
"lsp-async-stub",
"lsp-types",
@ -1817,7 +1784,7 @@ dependencies = [
"console_error_panic_hook",
"futures",
"getrandom",
"indexmap 1.6.2",
"indexmap",
"js-sys",
"lsp-async-stub",
"serde",
@ -2006,7 +1973,7 @@ version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap 2.2.3",
"indexmap",
"serde",
"serde_spanned",
"toml_datetime",
@ -2187,19 +2154,20 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"
version = "0.2.92"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8"
checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e"
dependencies = [
"cfg-if",
"once_cell",
"wasm-bindgen-macro",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.92"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da"
checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358"
dependencies = [
"bumpalo",
"log",
@ -2212,9 +2180,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-futures"
version = "0.4.41"
version = "0.4.45"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97"
checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b"
dependencies = [
"cfg-if",
"js-sys",
@ -2224,9 +2192,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.92"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726"
checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
@ -2234,9 +2202,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.92"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7"
checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
dependencies = [
"proc-macro2",
"quote",
@ -2247,9 +2215,9 @@ dependencies = [
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.92"
version = "0.2.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96"
checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d"
[[package]]
name = "web-sys"

View file

@ -14,7 +14,7 @@ crate-type = ["cdylib"]
lsp-async-stub = { path = "../lsp-async-stub" }
taplo = { path = "../taplo" }
taplo-cli = { path = "../taplo-cli", optional = true, default-features = false }
taplo-common = { path = "../taplo-common", default-features = false, features = ["rustls-tls"] }
taplo-common = { path = "../taplo-common", default-features = false, features = ["rustls-tls", "schema", "reqwest"] }
taplo-lsp = { path = "../taplo-lsp", optional = true, default-features = false }
anyhow = { version = "1.0.57" }
@ -23,8 +23,7 @@ clap = { version = "4.5.8", features = ["derive"] }
console_error_panic_hook = { version = "0.1.7" }
futures = { version = "0.3.21" }
getrandom = { version = "0.2.15", features = ["js"] }
indexmap = { version = "~1.6" }
js-sys = { version = "0.3.69" }
indexmap = { version = "2.6.0" }
serde = { version = "1.0.137", features = ["derive"] }
serde-wasm-bindgen = { version = "0.6.5" }
serde_json = { version = "1.0.81" }
@ -32,8 +31,11 @@ time = { version = "0.3.9", features = ["parsing"] }
tokio = { version = "1.19.2", default-features = false }
tracing = { version = "0.1.35" }
url = { version = "2.2.2" }
wasm-bindgen = { version = "0.2.92" }
wasm-bindgen-futures = { version = "0.4.40" }
# Bump all together since it's a monorepo
js-sys = { version = "0.3.72" }
wasm-bindgen = { version = "0.2.95" }
wasm-bindgen-futures = { version = "0.4.45" }
[features]
cli = ["taplo-cli"]

View file

@ -15,3 +15,4 @@ node_modules
.yarn/**
.yarnrc.yml
rollup-config.js
scripts/

View file

@ -33,12 +33,7 @@
"Other"
],
"activationEvents": [
"onLanguage:toml",
"onLanguage:cargoLock",
"onCommand:evenBetterToml.pasteAsJson",
"onCommand:evenBetterToml.copyAsJson",
"onCommand:evenBetterToml.pasteAsToml",
"onCommand:evenBetterToml.copyAsToml"
"onLanguage:cargoLock"
],
"keywords": [
"toml",
@ -408,16 +403,16 @@
"build:browser-extension": "rollup -c rollup.config.browser-extension.mjs",
"build:browser-server": "rollup -c rollup.config.browser-server.mjs",
"build:node": "rollup -c rollup.config.mjs",
"build": "rm -rf dist && yarn build:syntax && yarn build:node && yarn build:browser-extension && yarn build:browser-server"
"build": "node scripts/build.mjs"
},
"dependencies": {
"@taplo/lsp": "^0.6.1",
"@taplo/lsp": "^0.8.0",
"deep-equal": "^2.2.3",
"encoding": "^0.1.13",
"fast-glob": "^3.3.2",
"node-fetch": "^3.3.2",
"vscode-languageclient": "^9.0.1",
"which": "^4.0.0"
"which": "^5.0.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",

View file

@ -0,0 +1,9 @@
#!/usr/bin/env node
import { exec, unlink } from "../../../scripts/utils.mjs";
unlink("./dist");
exec("yarn", ["build:syntax"]);
exec("yarn", ["build:node"]);
exec("yarn", ["build:browser-extension"]);
exec("yarn", ["build:browser-server"]);

File diff suppressed because it is too large Load diff

33
scripts/utils.mjs Normal file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env node
import { rmSync } from "node:fs";
import { spawn } from "node:child_process";
function exec(argv0, argv) {
const proc = spawn(argv0, argv, {
stdio: ["ignore", "inherit", "inherit"],
shell: true,
});
proc.on("close", (code) => {
if (code != 0) {
console.error(`exit code: ${code}`);
}
});
}
function unlink(path) {
try {
rmSync(path, { recursive: true, force: true });
} catch (e) {
switch (e.code) {
case "ENOENT":
break;
default:
console.error(e);
break;
}
}
}
export { exec, unlink };