Skip to content

Commit b60b248

Browse files
ObserverOfTimeamaanq
authored andcommitted
feat(bindings): remove dsl types file
1 parent 072865e commit b60b248

File tree

4 files changed

+1
-36
lines changed

4 files changed

+1
-36
lines changed

cli/src/generate/grammar_files.rs

-33
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
use super::write_file;
22
use anyhow::{anyhow, Context, Result};
3-
use filetime::FileTime;
43
use heck::{ToKebabCase, ToShoutySnakeCase, ToSnakeCase, ToUpperCamelCase};
54
use serde::Deserialize;
65
use serde_json::{json, Map, Value};
76
use std::fs::File;
87
use std::io::BufReader;
98
use std::path::{Path, PathBuf};
10-
use std::time::{Duration, SystemTime};
119
use std::{fs, str};
1210

13-
const BUILD_TIME: &str = env!("BUILD_TIME");
14-
1511
const CLI_VERSION: &str = env!("CARGO_PKG_VERSION");
1612
const CLI_VERSION_PLACEHOLDER: &str = "CLI_VERSION";
1713

@@ -20,7 +16,6 @@ const CAMEL_PARSER_NAME_PLACEHOLDER: &str = "CAMEL_PARSER_NAME";
2016
const UPPER_PARSER_NAME_PLACEHOLDER: &str = "UPPER_PARSER_NAME";
2117
const LOWER_PARSER_NAME_PLACEHOLDER: &str = "LOWER_PARSER_NAME";
2218

23-
const DSL_D_TS_FILE: &str = include_str!("../../npm/dsl.d.ts");
2419
const GRAMMAR_JS_TEMPLATE: &str = include_str!("./templates/grammar.js");
2520
const PACKAGE_JSON_TEMPLATE: &str = include_str!("./templates/package.json");
2621
const GITIGNORE_TEMPLATE: &str = include_str!("./templates/gitignore");
@@ -209,7 +204,6 @@ pub fn generate_grammar_files(
209204
json!([
210205
"grammar.js",
211206
"binding.gyp",
212-
"types/dsl.d.ts",
213207
"prebuilds/**",
214208
"bindings/node/*",
215209
"queries/*",
@@ -244,33 +238,6 @@ pub fn generate_grammar_files(
244238
return Ok(());
245239
}
246240

247-
// Rewrite dsl.d.ts only if its mtime differs from what was set on its creation
248-
missing_path(repo_path.join("types"), create_dir)?.apply(|path| {
249-
missing_path(path.join("dsl.d.ts"), |path| {
250-
write_file(path, DSL_D_TS_FILE)
251-
})?
252-
.apply_state(|state| {
253-
let build_time =
254-
SystemTime::UNIX_EPOCH + Duration::from_secs_f64(BUILD_TIME.parse::<f64>()?);
255-
256-
match state {
257-
PathState::Exists(path) => {
258-
let mtime = fs::metadata(path)?.modified()?;
259-
if mtime != build_time {
260-
write_file(path, DSL_D_TS_FILE)?;
261-
filetime::set_file_mtime(path, FileTime::from_system_time(build_time))?;
262-
}
263-
}
264-
PathState::Missing(path) => {
265-
filetime::set_file_mtime(path, FileTime::from_system_time(build_time))?;
266-
}
267-
}
268-
269-
Ok(())
270-
})?;
271-
Ok(())
272-
})?;
273-
274241
// Write .gitignore file
275242
missing_path(repo_path.join(".gitignore"), |path| {
276243
generate_file(path, GITIGNORE_TEMPLATE, language_name)

cli/src/generate/templates/gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ dist/
3333
/examples/*/
3434

3535
# Grammar volatiles
36-
dsl.d.ts
3736
*.wasm
3837
*.obj
3938
*.o

cli/src/generate/templates/grammar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference types="./types/dsl" />
1+
/// <reference types="tree-sitter-cli/dsl" />
22
// @ts-check
33

44
module.exports = grammar({

cli/src/generate/templates/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"files": [
1616
"grammar.js",
1717
"binding.gyp",
18-
"types/dsl.d.ts",
1918
"prebuilds/**",
2019
"bindings/node/*",
2120
"queries/*",

0 commit comments

Comments
 (0)