mirror of
https://github.com/danbulant/oxc
synced 2026-05-24 12:21:58 +00:00
refactor(ast_tools): add CI filter file to outputs (#6946)
Generate CI filter file as a `RawOutput`, same as the rest, rather than specific code to write it to a file.
This commit is contained in:
parent
87db9eeeed
commit
11539e61fd
1 changed files with 14 additions and 16 deletions
|
|
@ -26,7 +26,7 @@ use generators::{
|
||||||
AssertLayouts, AstBuilderGenerator, AstKindGenerator, Generator, TypescriptGenerator,
|
AssertLayouts, AstBuilderGenerator, AstKindGenerator, Generator, TypescriptGenerator,
|
||||||
VisitGenerator, VisitMutGenerator,
|
VisitGenerator, VisitMutGenerator,
|
||||||
};
|
};
|
||||||
use output::write_all_to;
|
use output::{write_all_to, RawOutput};
|
||||||
use passes::{CalcLayout, Linker};
|
use passes::{CalcLayout, Linker};
|
||||||
use util::NormalizeError;
|
use util::NormalizeError;
|
||||||
|
|
||||||
|
|
@ -45,6 +45,7 @@ static SOURCE_PATHS: &[&str] = &[
|
||||||
|
|
||||||
const AST_CRATE: &str = "crates/oxc_ast";
|
const AST_CRATE: &str = "crates/oxc_ast";
|
||||||
const TYPESCRIPT_PACKAGE: &str = "npm/oxc-types";
|
const TYPESCRIPT_PACKAGE: &str = "npm/oxc-types";
|
||||||
|
const GITHUB_WATCH_LIST_PATH: &str = ".github/.generated_ast_watch_list.yml";
|
||||||
|
|
||||||
type Result<R> = std::result::Result<R, String>;
|
type Result<R> = std::result::Result<R, String>;
|
||||||
type TypeId = usize;
|
type TypeId = usize;
|
||||||
|
|
@ -67,7 +68,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||||
logger::quiet().normalize_with("Failed to set logger to `quiet` mode.")?;
|
logger::quiet().normalize_with("Failed to set logger to `quiet` mode.")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let AstCodegenResult { outputs, schema } = SOURCE_PATHS
|
let AstCodegenResult { mut outputs, schema } = SOURCE_PATHS
|
||||||
.iter()
|
.iter()
|
||||||
.fold(AstCodegen::default(), AstCodegen::add_file)
|
.fold(AstCodegen::default(), AstCodegen::add_file)
|
||||||
.pass(Linker)
|
.pass(Linker)
|
||||||
|
|
@ -86,15 +87,12 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||||
.generate(TypescriptGenerator)
|
.generate(TypescriptGenerator)
|
||||||
.run()?;
|
.run()?;
|
||||||
|
|
||||||
|
outputs.push(generate_ci_filter(&outputs));
|
||||||
|
|
||||||
if !cli_options.dry_run {
|
if !cli_options.dry_run {
|
||||||
let paths = outputs
|
for output in outputs {
|
||||||
.into_iter()
|
output.write_to_file()?;
|
||||||
.map(|output| {
|
}
|
||||||
output.write_to_file().unwrap();
|
|
||||||
output.path
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
write_ci_filter(SOURCE_PATHS, paths, ".github/.generated_ast_watch_list.yml")?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let CliOptions { schema: Some(schema_path), dry_run: false, .. } = cli_options {
|
if let CliOptions { schema: Some(schema_path), dry_run: false, .. } = cli_options {
|
||||||
|
|
@ -105,7 +103,7 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_ci_filter(inputs: &[&str], paths: Vec<String>, output_path: &str) -> std::io::Result<()> {
|
fn generate_ci_filter(outputs: &[RawOutput]) -> RawOutput {
|
||||||
let file = file!().replace('\\', "/");
|
let file = file!().replace('\\', "/");
|
||||||
let mut output = format!(
|
let mut output = format!(
|
||||||
"\
|
"\
|
||||||
|
|
@ -115,18 +113,18 @@ fn write_ci_filter(inputs: &[&str], paths: Vec<String>, output_path: &str) -> st
|
||||||
);
|
);
|
||||||
let mut push_item = |path: &str| output.push_str(format!(" - '{path}'\n").as_str());
|
let mut push_item = |path: &str| output.push_str(format!(" - '{path}'\n").as_str());
|
||||||
|
|
||||||
for input in inputs {
|
for input in SOURCE_PATHS {
|
||||||
push_item(input);
|
push_item(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
for path in paths {
|
for output in outputs {
|
||||||
push_item(path.as_str());
|
push_item(output.path.as_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
push_item("tasks/ast_tools/src/**");
|
push_item("tasks/ast_tools/src/**");
|
||||||
push_item(output_path);
|
push_item(GITHUB_WATCH_LIST_PATH);
|
||||||
|
|
||||||
write_all_to(output.as_bytes(), output_path)
|
RawOutput { path: GITHUB_WATCH_LIST_PATH.to_string(), content: output.into_bytes() }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue