@@ -27,9 +27,14 @@ pub enum Error {
27
27
NotImplemented ,
28
28
}
29
29
30
+ #[ derive( Debug ) ]
31
+ pub struct BunLockfile {
32
+ data : BunLockfileData ,
33
+ }
34
+
30
35
#[ derive( Debug , Deserialize ) ]
31
36
#[ serde( rename_all = "camelCase" ) ]
32
- pub struct BunLockfile {
37
+ pub struct BunLockfileData {
33
38
#[ allow( unused) ]
34
39
lockfile_version : i32 ,
35
40
workspaces : Map < String , WorkspaceEntry > ,
@@ -92,6 +97,7 @@ impl Lockfile for BunLockfile {
92
97
version : & str ,
93
98
) -> Result < Option < crate :: Package > , crate :: Error > {
94
99
let workspace_entry = self
100
+ . data
95
101
. workspaces
96
102
. get ( workspace_path)
97
103
. ok_or_else ( || crate :: Error :: MissingWorkspace ( workspace_path. into ( ) ) ) ?;
@@ -100,7 +106,7 @@ impl Lockfile for BunLockfile {
100
106
if let Some ( ( _key, entry) ) = self . package_entry ( & workspace_key) {
101
107
let mut version = entry. version ( ) . to_string ( ) ;
102
108
// Check for any patches
103
- if let Some ( patch) = self . patched_dependencies . get ( & entry. ident ) {
109
+ if let Some ( patch) = self . data . patched_dependencies . get ( & entry. ident ) {
104
110
version. push ( '+' ) ;
105
111
version. push_str ( patch) ;
106
112
}
@@ -131,6 +137,7 @@ impl Lockfile for BunLockfile {
131
137
key : & str ,
132
138
) -> Result < Option < std:: collections:: HashMap < String , String > > , crate :: Error > {
133
139
let entry = self
140
+ . data
134
141
. packages
135
142
. get ( key)
136
143
. ok_or_else ( || crate :: Error :: MissingPackage ( key. into ( ) ) ) ?;
@@ -173,7 +180,7 @@ impl Lockfile for BunLockfile {
173
180
}
174
181
175
182
fn human_name ( & self , package : & crate :: Package ) -> Option < String > {
176
- let entry = self . packages . get ( & package. key ) ?;
183
+ let entry = self . data . packages . get ( & package. key ) ?;
177
184
Some ( entry. ident . clone ( ) )
178
185
}
179
186
}
@@ -188,7 +195,7 @@ impl BunLockfile {
188
195
// present in the lockfile
189
196
fn package_entry ( & self , key : & str ) -> Option < ( & str , & PackageEntry ) > {
190
197
let ( key, entry) =
191
- PossibleKeyIter :: new ( key) . find_map ( |k| self . packages . get_key_value ( k) ) ?;
198
+ PossibleKeyIter :: new ( key) . find_map ( |k| self . data . packages . get_key_value ( k) ) ?;
192
199
Some ( ( key, entry) )
193
200
}
194
201
}
@@ -217,8 +224,8 @@ impl FromStr for BunLockfile {
217
224
)
218
225
. map_err ( Error :: from) ?;
219
226
let strict_json = format. print ( ) . map_err ( Error :: from) ?;
220
- let this = serde_json:: from_str ( strict_json. as_code ( ) ) ?;
221
- Ok ( this )
227
+ let data = serde_json:: from_str ( strict_json. as_code ( ) ) ?;
228
+ Ok ( Self { data } )
222
229
}
223
230
}
224
231
impl PackageEntry {
0 commit comments