fix(cli): generate the parser version from the config as well

This commit is contained in:
Amaan Qureshi 2024-09-30 13:10:42 -04:00
parent ea3846a2c5
commit 2e3504a422
No known key found for this signature in database
GPG key ID: E67890ADC4227273
6 changed files with 16 additions and 9 deletions

8
Cargo.lock generated
View file

@ -156,9 +156,9 @@ checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3"
[[package]]
name = "cc"
version = "1.1.22"
version = "1.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9540e661f81799159abee814118cc139a2004b3a3aa3ea37724a1b66530b90e0"
checksum = "3bbb537bb4a30b90362caddba8f360c0a56bc13d3a5570028e7197204cb54a17"
dependencies = [
"jobserver",
"libc",
@ -1155,9 +1155,9 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.5.6"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "355ae415ccd3a04315d3f8246e86d67689ea74d88d915576e1589a351062a13b"
checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f"
dependencies = [
"bitflags",
]

View file

@ -31,6 +31,7 @@ const PARSER_DESCRIPTION_PLACEHOLDER: &str = "PARSER_DESCRIPTION";
const PARSER_LICENSE_PLACEHOLDER: &str = "PARSER_LICENSE";
const PARSER_URL_PLACEHOLDER: &str = "PARSER_URL";
const PARSER_URL_STRIPPED_PLACEHOLDER: &str = "PARSER_URL_STRIPPED";
const PARSER_VERSION_PLACEHOLDER: &str = "PARSER_VERSION";
const AUTHOR_NAME_PLACEHOLDER: &str = "PARSER_AUTHOR_NAME";
const AUTHOR_EMAIL_PLACEHOLDER: &str = "PARSER_AUTHOR_EMAIL";
@ -210,6 +211,7 @@ struct GenerateOpts<'a> {
license: Option<&'a str>,
description: Option<&'a str>,
repository: Option<&'a str>,
version: &'a Version,
}
// TODO: remove in 0.25
@ -423,6 +425,7 @@ pub fn generate_grammar_files(
.links
.as_ref()
.map(|l| l.repository.as_str()),
version: &tree_sitter_config.metadata.version,
};
// Create or update package.json
@ -950,7 +953,11 @@ fn generate_file(
)
.replace(PARSER_NAME_PLACEHOLDER, language_name)
.replace(CLI_VERSION_PLACEHOLDER, CLI_VERSION)
.replace(RUST_BINDING_VERSION_PLACEHOLDER, RUST_BINDING_VERSION);
.replace(RUST_BINDING_VERSION_PLACEHOLDER, RUST_BINDING_VERSION)
.replace(
PARSER_VERSION_PLACEHOLDER,
&generate_opts.version.to_string(),
);
if let Some(name) = generate_opts.author_name {
replacement = replacement.replace(AUTHOR_NAME_PLACEHOLDER, name);

View file

@ -1,7 +1,7 @@
[package]
name = "tree-sitter-PARSER_NAME"
description = "PARSER_DESCRIPTION"
version = "0.0.1"
version = "PARSER_VERSION"
authors = ["PARSER_AUTHOR_NAME PARSER_AUTHOR_EMAIL"]
license = "PARSER_LICENSE"
readme = "README.md"

View file

@ -2,7 +2,7 @@ ifeq ($(OS),Windows_NT)
$(error Windows is not supported)
endif
VERSION := 0.0.1
VERSION := PARSER_VERSION
LANGUAGE_NAME := tree-sitter-PARSER_NAME

View file

@ -1,6 +1,6 @@
{
"name": "tree-sitter-PARSER_NAME",
"version": "0.0.1",
"version": "PARSER_VERSION",
"description": "PARSER_DESCRIPTION",
"repository": "github:tree-sitter/tree-sitter-PARSER_NAME",
"license": "PARSER_LICENSE",

View file

@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "tree-sitter-PARSER_NAME"
description = "PARSER_DESCRIPTION"
version = "0.0.1"
version = "PARSER_VERSION"
keywords = ["incremental", "parsing", "tree-sitter", "PARSER_NAME"]
classifiers = [
"Intended Audience :: Developers",