Skip to content

Commit 24ef070

Browse files
authored
feat(cargo-util-schemas): Move lockfile schemas (#15980)
### What does this PR try to resolve? As part of cargo plumbing commands, we're trying to make lockfiles more accessible to third-party uses. This change moves the lockfile schemas to `cargo-util-schemas`, where it is previously under `cargo` and are relatively hidden. See also: crate-ci/cargo-plumbing#82 ### How to test and review this PR? Commit by commit to see the changes made. My main concern is performance as the implementation repeatedly calls `SourceId::from_url` and I'm not sure if its negligible. r? @epage
2 parents a4bd03c + 703988f commit 24ef070

File tree

9 files changed

+709
-472
lines changed

9 files changed

+709
-472
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/cargo-util-schemas/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-util-schemas"
3-
version = "0.10.1"
3+
version = "0.10.2"
44
rust-version = "1.89" # MSRV:1
55
edition.workspace = true
66
license.workspace = true
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"title": "TomlLockfile",
4+
"description": "The `Cargo.lock` structure.",
5+
"type": "object",
6+
"properties": {
7+
"version": {
8+
"type": [
9+
"integer",
10+
"null"
11+
],
12+
"format": "uint32",
13+
"minimum": 0
14+
},
15+
"package": {
16+
"type": [
17+
"array",
18+
"null"
19+
],
20+
"items": {
21+
"$ref": "#/$defs/TomlLockfileDependency"
22+
}
23+
},
24+
"root": {
25+
"description": "`root` is optional to allow backward compatibility.",
26+
"anyOf": [
27+
{
28+
"$ref": "#/$defs/TomlLockfileDependency"
29+
},
30+
{
31+
"type": "null"
32+
}
33+
]
34+
},
35+
"metadata": {
36+
"type": [
37+
"object",
38+
"null"
39+
],
40+
"additionalProperties": {
41+
"type": "string"
42+
}
43+
},
44+
"patch": {
45+
"$ref": "#/$defs/TomlLockfilePatch"
46+
}
47+
},
48+
"$defs": {
49+
"TomlLockfileDependency": {
50+
"type": "object",
51+
"properties": {
52+
"name": {
53+
"type": "string"
54+
},
55+
"version": {
56+
"type": "string"
57+
},
58+
"source": {
59+
"type": [
60+
"string",
61+
"null"
62+
]
63+
},
64+
"checksum": {
65+
"type": [
66+
"string",
67+
"null"
68+
]
69+
},
70+
"dependencies": {
71+
"type": [
72+
"array",
73+
"null"
74+
],
75+
"items": {
76+
"$ref": "#/$defs/TomlLockfilePackageId"
77+
}
78+
},
79+
"replace": {
80+
"anyOf": [
81+
{
82+
"$ref": "#/$defs/TomlLockfilePackageId"
83+
},
84+
{
85+
"type": "null"
86+
}
87+
]
88+
}
89+
},
90+
"required": [
91+
"name",
92+
"version"
93+
]
94+
},
95+
"TomlLockfilePackageId": {
96+
"type": "object",
97+
"properties": {
98+
"name": {
99+
"type": "string"
100+
},
101+
"version": {
102+
"type": [
103+
"string",
104+
"null"
105+
]
106+
},
107+
"source": {
108+
"type": [
109+
"string",
110+
"null"
111+
]
112+
}
113+
},
114+
"required": [
115+
"name"
116+
]
117+
},
118+
"TomlLockfilePatch": {
119+
"type": "object",
120+
"properties": {
121+
"unused": {
122+
"type": "array",
123+
"items": {
124+
"$ref": "#/$defs/TomlLockfileDependency"
125+
}
126+
}
127+
},
128+
"required": [
129+
"unused"
130+
]
131+
}
132+
}
133+
}

crates/cargo-util-schemas/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
1111
pub mod core;
1212
pub mod index;
13+
pub mod lockfile;
1314
pub mod manifest;
1415
pub mod messages;
1516
#[cfg(feature = "unstable-schema")]

0 commit comments

Comments
 (0)