Skip to content

Commit

Permalink
refactor: remove no longer required TomlValue struct
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeStanger committed May 27, 2023
1 parent c4cd6a8 commit 5d2b7c8
Show file tree
Hide file tree
Showing 30 changed files with 121 additions and 132 deletions.
53 changes: 51 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion assets/inputs/readme_example.corn
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ let {

config.port = 8080
config.hostname = null
}
}
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion assets/outputs/toml/basic.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
foo = 'bar'
foo = "bar"

2 changes: 1 addition & 1 deletion assets/outputs/toml/basic_empty_let.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
foo = 'bar'
foo = "bar"

2 changes: 1 addition & 1 deletion assets/outputs/toml/chained.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[foo]
bar = 'baz'
bar = "baz"

6 changes: 3 additions & 3 deletions assets/outputs/toml/chained_complex.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[foo]
qux = true
quux = [
'green eggs',
'ham',
"green eggs",
"ham",
]
qux = true

[foo.bar]
baz = 42
Expand Down
2 changes: 1 addition & 1 deletion assets/outputs/toml/char.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
foo = 'a'
foo = "a"

2 changes: 1 addition & 1 deletion assets/outputs/toml/comment.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
foo = 'bar'
foo = "bar"

18 changes: 9 additions & 9 deletions assets/outputs/toml/compact.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
eight = [
'foo',
'bar',
"foo",
"bar",
]
eleven = [
[],
Expand All @@ -10,11 +10,6 @@ nine = [
true,
false,
]
ten = []

[[twelve]]

[[twelve]]

[five]

Expand All @@ -23,12 +18,13 @@ bar = false
foo = true

[one]
bar = 'foo'
foo = 'bar'
bar = "foo"
foo = "bar"

[seven]
bar = []
foo = []

[six.bar]

[six.foo]
Expand All @@ -37,6 +33,10 @@ foo = []
bar = 2.0
foo = 1.0

[[twelve]]

[[twelve]]

[two]
bar = 2
foo = 1
Expand Down
29 changes: 12 additions & 17 deletions assets/outputs/toml/complex.toml
Original file line number Diff line number Diff line change
@@ -1,37 +1,32 @@
age = 32
gender = 'M'
empty2 = []
favourites = [
'blue',
'fish',
'egg',
'Postman',
"blue",
"fish",
"egg",
"Postman",
4.73753,
false
[[favourites]]
hello = 'world'

[favourites.food]
favourite = 'egg'
hated = 'beef'
,
false,
{ hello = "world" },
]
gender = "M"

[employment]
employed = true
name = 'Postman'
name = "Postman"
sinceYear = 2019

[empty1]

[name]
first = 'John'
full = '$firstName $lastName'
last = 'Smith'
first = "John"
full = "$firstName $lastName"
last = "Smith"

[negative]
float = -34.34
int = -34

[parents.father.birthday]
day = 3
month = 2
Expand Down
4 changes: 2 additions & 2 deletions assets/outputs/toml/complex_keys.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ with_underscore = 0
"with_🌽" = 2

[apple-pie]
crust = 'yum'
crust = "yum"

[foo]
bar-baz = 'hello'
bar-baz = "hello"

2 changes: 1 addition & 1 deletion assets/outputs/toml/environment_variable.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
foo = 'bar'
foo = "bar"

4 changes: 2 additions & 2 deletions assets/outputs/toml/input.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ month = 1
year = 1970

[name]
first = 'John'
last = 'Smith'
first = "John"
last = "Smith"

2 changes: 1 addition & 1 deletion assets/outputs/toml/input_references_input.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
foo = 'bar'
foo = "bar"

Empty file.
Empty file.
2 changes: 1 addition & 1 deletion assets/outputs/toml/mixed_array.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
foo = [
1,
'two',
"two",
false,
]

30 changes: 15 additions & 15 deletions assets/outputs/toml/readme_example.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
main = 'dist/index.js'
name = 'example-package'
main = "dist/index.js"
name = "example-package"
private = false
version = '1.0.0'

[[contributors]]
email = 'mail@example.com'
name = 'John Smith'
version = "1.0.0"

[author]
email = 'mail@example.com'
name = 'John Smith'
url = 'https://example.com'
email = "mail@example.com"
name = "John Smith"
url = "https://example.com"

[bin]
filebrowser = 'dist/index.js'
filebrowser = "dist/index.js"

[config]
port = 8080

[[contributors]]
email = "mail@example.com"
name = "John Smith"

[dependencies]
dotenv = '^8.2.0'
dotenv = "^8.2.0"

[devDependencies]
typescript = '^4.5'
typescript = "^4.5"

[scripts]
build = 'tsc'
run = 'node dist'
build = "tsc"
run = "node dist"

4 changes: 2 additions & 2 deletions assets/outputs/toml/spread.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
bar = 'baz'
hello = 'world'
bar = "baz"
hello = "world"
nums = [
1,
2,
Expand Down
2 changes: 1 addition & 1 deletion assets/outputs/toml/string.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
foo = 'bar'
foo = "bar"

18 changes: 9 additions & 9 deletions assets/outputs/toml/very_compact.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
eight = [
'foo',
'bar',
"foo",
"bar",
]
eleven = [
[],
Expand All @@ -10,11 +10,6 @@ nine = [
true,
false,
]
ten = []

[[twelve]]

[[twelve]]

[five]

Expand All @@ -23,12 +18,13 @@ bar = false
foo = true

[one]
bar = 'foo'
foo = 'bar'
bar = "foo"
foo = "bar"

[seven]
bar = []
foo = []

[six.bar]

[six.foo]
Expand All @@ -37,6 +33,10 @@ foo = []
bar = 2.0
foo = 1.0

[[twelve]]

[[twelve]]

[two]
bar = 2
foo = 1
Expand Down
Empty file.
Empty file.
2 changes: 1 addition & 1 deletion corn-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ colored = "2.0.0"
serde = { version = "1.0.133", features = ["derive"] }
serde_json = "1.0.75"
serde_yaml = "0.9.11"
toml = "0.5.9"
toml = "0.7.4"
pest = "2.3.0"
5 changes: 2 additions & 3 deletions corn-cli/src/bin/corn.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use corn_cli::error::{print_err, Error, ExitCode};
use libcorn::{parse, TomlValue, Value};
use libcorn::{parse, Value};
use std::fs::read_to_string;
use std::path::Path;
use std::process::exit;
Expand Down Expand Up @@ -88,8 +88,7 @@ fn serialize(config: Value, output_type: OutputType) -> Result<String, Error> {
}
}
OutputType::Toml => {
let toml_value = TomlValue::from(config);
let res = toml::to_string_pretty(&toml_value);
let res = toml::to_string_pretty(&config);
match res {
Ok(str) => Ok(str),
Err(err) => Err(Error::Serializing(err.to_string())),
Expand Down
2 changes: 1 addition & 1 deletion libcorn/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pest_derive = "2.6.0"
cfg-if = "1.0.0"
serde = { version = "1.0.133", features = ["derive"] }
thiserror = "1.0.40"
toml = "0.5.9" # currently required to work around toml serializing
wasm-bindgen = { version = "0.2.83", optional = true }
serde-wasm-bindgen = { version = "0.4.5", optional = true }
console_error_panic_hook = { version = "0.1.7", optional = true }
Expand All @@ -31,3 +30,4 @@ wasm-bindgen-test = { version = "0.3.29" }
# required for testing
serde_json = "1.0.75"
serde_yaml = "0.9.11"
toml = "0.7.4"
Loading

0 comments on commit 5d2b7c8

Please sign in to comment.