diff --git a/crates/rome_service/src/configuration/mod.rs b/crates/rome_service/src/configuration/mod.rs
index c907f2c8bcd..5378a46e7fb 100644
--- a/crates/rome_service/src/configuration/mod.rs
+++ b/crates/rome_service/src/configuration/mod.rs
@@ -3,11 +3,12 @@
//! The configuration is divided by "tool", and then it's possible to further customise it
//! by language. The language might further options divided by tool.
-use crate::{DynRef, WorkspaceError};
+use crate::{DynRef, WorkspaceError, VERSION};
use bpaf::Bpaf;
use rome_fs::{FileSystem, OpenOptions};
use serde::{Deserialize, Serialize};
use std::fmt::Debug;
+use std::fs::DirBuilder;
use std::io::ErrorKind;
use std::num::NonZeroU64;
use std::path::{Path, PathBuf};
@@ -347,11 +348,19 @@ pub fn create_config(
}
})?;
+ dbg!(VERSION);
// we now check if rome is installed inside `node_modules` and if so, we
- let schema_path = Path::new("./node_modules/rome/configuration_schema.json");
- let options = OpenOptions::default().read(true);
- if fs.open_with_options(schema_path, options).is_ok() {
- configuration.schema = schema_path.to_str().map(String::from);
+ if VERSION == "0.0.0" {
+ let schema_path = Path::new("./node_modules/rome/configuration_schema.json");
+ let options = OpenOptions::default().read(true);
+ if fs.open_with_options(schema_path, options).is_ok() {
+ configuration.schema = schema_path.to_str().map(String::from);
+ }
+ } else {
+ configuration.schema = Some(format!(
+ "https://docs.rome.tools/schemas/{}/schema.json",
+ VERSION
+ ));
}
let contents = serde_json::to_string_pretty(&configuration).map_err(|_| {
diff --git a/website/src/pages/configuration.mdx b/website/src/pages/configuration.mdx
index 9ed79dbaa77..e23cde7d7a9 100644
--- a/website/src/pages/configuration.mdx
+++ b/website/src/pages/configuration.mdx
@@ -53,6 +53,17 @@ You can specify a relative path to the schema of the `rome` npm package if `rome
}
```
+If you have problems with resolving the physical file, you can use the one published in this site:
+
+
+
+
+```json
+{
+ "$schema": "https://docs.rome.tools/schemas/12.1.0/schema.json"
+}
+```
+
## `files`
### `files.maxSize`
diff --git a/website/src/pages/schemas/12.1.0/schema.json.js b/website/src/pages/schemas/12.1.0/schema.json.js
new file mode 100644
index 00000000000..4287ccd3dc4
--- /dev/null
+++ b/website/src/pages/schemas/12.1.0/schema.json.js
@@ -0,0 +1,16 @@
+// Run `ROME_VERSION= cargo codegen-website
+// to generate a new schema
+import {readFileSync} from "fs";
+import {join, resolve} from "path"
+
+export function get() {
+ const schemaPath = resolve(join("..", "npm", "rome", "configuration_schema.json"));
+ const schema = readFileSync(schemaPath, "utf8")
+
+ return new Response(schema, {
+ status: 200,
+ headers: {
+ "content-type": "application/json"
+ }
+ })
+}
\ No newline at end of file
diff --git a/xtask/codegen/Cargo.toml b/xtask/codegen/Cargo.toml
index f44810728f7..f93e7442fb7 100644
--- a/xtask/codegen/Cargo.toml
+++ b/xtask/codegen/Cargo.toml
@@ -36,5 +36,5 @@ rome_service = { path = "../../crates/rome_service", features = ["schemars"], op
[features]
configuration = ["rome_analyze", "rome_js_analyze", "rome_js_syntax", "pulldown-cmark"]
-website = []
+website = ["rome_service"]
schema = ["schemars", "serde_json", "rome_rowan", "rome_service", "rome_js_syntax", "rome_js_factory", "rome_js_formatter", "rome_json_formatter", "rome_json_parser", "rome_diagnostics"]
diff --git a/xtask/codegen/src/generate_website.rs b/xtask/codegen/src/generate_website.rs
index 4d9be0c4790..7f5639fb6e3 100644
--- a/xtask/codegen/src/generate_website.rs
+++ b/xtask/codegen/src/generate_website.rs
@@ -1,3 +1,4 @@
+use rome_service::VERSION;
use std::fs;
use xtask::{project_root, Result};
@@ -9,7 +10,36 @@ description: Notes about the Rome's VSCode extension
---
"#;
+const SCHEMA_TEMPLATE: &str = r#"// Run `ROME_VERSION= cargo codegen-website
+// to generate a new schema
+import {readFileSync} from "fs";
+import {join, resolve} from "path"
+
+export function get() {
+ const schemaPath = resolve(join("..", "npm", "rome", "configuration_schema.json"));
+ const schema = readFileSync(schemaPath, "utf8")
+
+ return new Response(schema, {
+ status: 200,
+ headers: {
+ "content-type": "application/json"
+ }
+ })
+}"#;
+
+/// Generates
pub fn generate_website() -> Result<()> {
+ if VERSION != "0.0.0" {
+ let schema_root_folder = project_root().join("website/src/pages/schemas");
+ let schema_version_folder = schema_root_folder.join(VERSION);
+ let schema_js_file = schema_version_folder.join("schema.json.js");
+ if schema_version_folder.exists() {
+ fs::remove_file(schema_js_file.clone())?;
+ fs::remove_dir(schema_version_folder.clone())?;
+ }
+ fs::create_dir(schema_version_folder.clone())?;
+ fs::write(schema_js_file.clone(), SCHEMA_TEMPLATE)?;
+ }
fs::remove_file(project_root().join("website/src/pages/vscode.mdx")).ok();
let readme = fs::read_to_string(project_root().join("editors/vscode/README.md"))?;