mirror of
https://github.com/SkyfallWasTaken/dinopkg.git
synced 2024-11-22 09:23:41 +00:00
Add fields to package.json
This commit is contained in:
parent
b729259092
commit
4d4223acdc
3 changed files with 29 additions and 2 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -238,6 +238,10 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "dinopkg-package-json"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
|
|
|
@ -4,3 +4,5 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0.204", features = ["derive"] }
|
||||
serde_json = "1.0.120"
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use std::collections::HashMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PackageJson {
|
||||
pub name: String,
|
||||
pub version: String,
|
||||
pub description: Option<String>,
|
||||
pub main: Option<String>,
|
||||
pub scripts: Option<Scripts>,
|
||||
pub dependencies: Option<Dependencies>,
|
||||
pub dev_dependencies: Option<Dependencies>,
|
||||
}
|
||||
|
||||
pub type Scripts = HashMap<String, String>;
|
||||
pub type Dependencies = HashMap<String, String>;
|
||||
|
||||
impl PackageJson {
|
||||
pub fn parse(json: &str) -> Result<Self, serde_json::Error> {
|
||||
serde_json::from_str(json)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue