This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 659
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rome_service): add
$schema
to configuration (#3738)
- Loading branch information
Showing
19 changed files
with
2,968 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
use crate::configs::{CONFIG_INIT_DEFAULT, CONFIG_INIT_DEFAULT_WHEN_INSTALLED}; | ||
use crate::run_cli; | ||
use crate::snap_test::{assert_cli_snapshot, SnapshotPayload}; | ||
use pico_args::Arguments; | ||
use rome_console::BufferConsole; | ||
use rome_fs::{FileSystemExt, MemoryFileSystem}; | ||
use rome_service::DynRef; | ||
use std::ffi::OsString; | ||
use std::path::Path; | ||
|
||
#[test] | ||
fn creates_config_file() { | ||
let mut fs = MemoryFileSystem::default(); | ||
let mut console = BufferConsole::default(); | ||
|
||
let result = run_cli( | ||
DynRef::Borrowed(&mut fs), | ||
DynRef::Borrowed(&mut console), | ||
Arguments::from_vec(vec![OsString::from("init")]), | ||
); | ||
assert!(result.is_ok(), "run_cli returned {result:?}"); | ||
|
||
let file_path = Path::new("rome.json"); | ||
|
||
let mut file = fs | ||
.open(file_path) | ||
.expect("configuration file was not written on disk"); | ||
|
||
let mut content = String::new(); | ||
file.read_to_string(&mut content) | ||
.expect("failed to read file from memory FS"); | ||
assert_eq!(content, CONFIG_INIT_DEFAULT); | ||
|
||
drop(file); | ||
|
||
assert_cli_snapshot(SnapshotPayload::new( | ||
module_path!(), | ||
"creates_config_file", | ||
fs, | ||
console, | ||
result, | ||
)); | ||
} | ||
|
||
#[test] | ||
fn creates_config_file_when_rome_installed_via_package_manager() { | ||
let mut fs = MemoryFileSystem::default(); | ||
let mut console = BufferConsole::default(); | ||
|
||
let file_path = Path::new("./") | ||
.join("node_modules") | ||
.join("rome") | ||
.join("configuration_schema.json"); | ||
fs.insert(file_path, *b"{}"); | ||
|
||
let result = run_cli( | ||
DynRef::Borrowed(&mut fs), | ||
DynRef::Borrowed(&mut console), | ||
Arguments::from_vec(vec![OsString::from("init")]), | ||
); | ||
assert!(result.is_ok(), "run_cli returned {result:?}"); | ||
|
||
let file_path = Path::new("rome.json"); | ||
|
||
let mut file = fs | ||
.open(file_path) | ||
.expect("configuration file was not written on disk"); | ||
|
||
let mut content = String::new(); | ||
file.read_to_string(&mut content) | ||
.expect("failed to read file from memory FS"); | ||
assert_eq!(content, CONFIG_INIT_DEFAULT_WHEN_INSTALLED); | ||
|
||
drop(file); | ||
|
||
assert_cli_snapshot(SnapshotPayload::new( | ||
module_path!(), | ||
"creates_config_file_when_rome_installed_via_package_manager", | ||
fs, | ||
console, | ||
result, | ||
)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
mod check; | ||
mod ci; | ||
mod format; | ||
mod init; | ||
mod rage; | ||
mod version; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
51 changes: 51 additions & 0 deletions
51
...shots/main_commands_init/creates_config_file_when_rome_installed_via_package_manager.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
source: crates/rome_cli/tests/snap_test.rs | ||
expression: content | ||
--- | ||
## `rome.json` | ||
|
||
```json | ||
{ | ||
"$schema": "./node_modules/rome/configuration_schema.json", | ||
"linter": { | ||
"enabled": true, | ||
"rules": { | ||
"recommended": true | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## `./node_modules/rome/configuration_schema.json` | ||
|
||
```json | ||
{} | ||
``` | ||
|
||
# Emitted Messages | ||
|
||
```block | ||
Welcome to Rome! Let's get you started... | ||
Files created ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
- rome.json: Your project configuration. Documentation: https://rome.tools/configuration | ||
Next Steps ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ||
1. Setup an editor extension | ||
Get live errors as you type and format when you save. Learn more: https://rome.tools/editors | ||
2. Try a command | ||
rome ci checks for lint errors and verifies formatting. Run rome --help for a full list of commands and options. | ||
3. Read the documentation | ||
Our website serves as a comprehensive source of guides and documentation: https://docs.rome.tools | ||
4. Get involved in the community | ||
Ask questions, get support, or contribute by participating on GitHub (https://github.com/rome/tools), | ||
or join our community Discord (https://discord.gg/rome) | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.