Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
chore: format generated schema
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Aug 9, 2023
1 parent 339ee9c commit 19792e5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ tests_macros = { path = "./crates/tests_macros" }

# Crates needed in the workspace
bitflags = "2.3.1"
bpaf = { version = "0.9.2", features = ["derive"] }
bpaf = { version = "0.9.3", features = ["derive"] }
countme = "3.0.1"
dashmap = "5.4.0"
indexmap = "1.9.3"
Expand Down Expand Up @@ -98,4 +98,3 @@ opt-level = "s"
[profile.release.package.rome_wasm]
debug = false
opt-level = 3

2 changes: 1 addition & 1 deletion website/src/pages/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ description: Available commands and arguments in the Rome CLI.



## Command summary
# Command summary

* [`rome`](#rome)
* [`rome version`](#rome-version)
Expand Down
3 changes: 2 additions & 1 deletion xtask/codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ case = "1.0.0"
pulldown-cmark = { version = "0.9", default-features = false, optional = true }
fs_extra = "1.3.0"

rome_js_parser = { workspace = true, optional = true }
rome_rowan = { path = "../../crates/rome_rowan", optional = true }
rome_cli = { workspace = true, optional = true }
rome_analyze = { path = "../../crates/rome_analyze", optional = true }
Expand Down Expand Up @@ -47,7 +48,7 @@ configuration = [
"rome_json_syntax",
"pulldown-cmark",
]
website = ["rome_service", "rome_cli/docgen"]
website = ["rome_service", "rome_cli/docgen", "rome_js_parser", "rome_js_formatter", "rome_js_syntax"]
schema = [
"schemars",
"serde_json",
Expand Down
16 changes: 11 additions & 5 deletions xtask/codegen/src/generate_website.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use rome_cli::rome_command;
use rome_js_formatter::context::JsFormatOptions;
use rome_js_formatter::format_node;
use rome_js_parser::{parse_module, JsParserOptions};
use rome_js_syntax::JsFileSource;
use rome_service::VERSION;
use std::fs;
use xtask::{project_root, Result};
Expand Down Expand Up @@ -38,10 +42,6 @@ pub(crate) fn generate_files() -> Result<()> {
if VERSION != "0.0.0" {
let parser = rome_command();
let markdown = parser.render_markdown("rome");
let markdown = markdown
.replace("\n### ", "\n#### ")
.replace("\n## ", "\n### ")
.replace("\n# ", "\n## ");
let mut cli_content = fs::read_to_string(project_root().join("website/src/pages/cli.mdx"))?;

let start = "\n[//]: # (Start-codegen)\n";
Expand Down Expand Up @@ -70,7 +70,13 @@ pub(crate) fn generate_files() -> Result<()> {
fs::remove_dir(schema_version_folder.clone())?;
}
fs::create_dir(schema_version_folder.clone())?;
fs::write(schema_js_file.clone(), SCHEMA_TEMPLATE)?;
let node = parse_module(&SCHEMA_TEMPLATE, JsParserOptions::default());
let result = format_node(
JsFormatOptions::new(JsFileSource::js_module()),
&node.syntax(),
)
.unwrap();
fs::write(schema_js_file.clone(), result.print().unwrap().as_code())?;
}

Ok(())
Expand Down

0 comments on commit 19792e5

Please sign in to comment.