Skip to content

Commit cc5539f

Browse files
authored
[pub_formats] Generate pubspec.lock API (#2427)
1 parent 70937eb commit cc5539f

File tree

10 files changed

+1458
-0
lines changed

10 files changed

+1458
-0
lines changed

.github/pr-title-checker-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"[native_test_helpers] ",
1616
"[native_toolchain_c] ",
1717
"[objective_c] ",
18+
"[pub_formats] ",
1819
"[swift2objc] ",
1920
"[swiftgen] "
2021
],
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"title": "Pubspec Lock File Schema",
4+
"description": "Schema for a Dart pubspec.lock file. Note that this is reverse engineered and not the source of truth for pubspec locks.",
5+
"$ref": "#/definitions/PubspecLockFile",
6+
"definitions": {
7+
"PubspecLockFile": {
8+
"type": "object",
9+
"required": [
10+
"sdks"
11+
],
12+
"properties": {
13+
"packages": {
14+
"type": "object",
15+
"description": "Details of the locked packages.",
16+
"additionalProperties": {
17+
"$ref": "#/definitions/Package"
18+
}
19+
},
20+
"sdks": {
21+
"$ref": "#/definitions/SDKs"
22+
}
23+
},
24+
"additionalProperties": false
25+
},
26+
"Package": {
27+
"type": "object",
28+
"required": [
29+
"dependency",
30+
"description",
31+
"source",
32+
"version"
33+
],
34+
"properties": {
35+
"dependency": {
36+
"$ref": "#/definitions/DependencyType"
37+
},
38+
"description": {
39+
"$ref": "#/definitions/PackageDescription"
40+
},
41+
"source": {
42+
"$ref": "#/definitions/PackageSource"
43+
},
44+
"version": {
45+
"$ref": "#/definitions/PackageVersion"
46+
}
47+
},
48+
"additionalProperties": false
49+
},
50+
"DependencyType": {
51+
"type": "string",
52+
"description": "The type of dependency.",
53+
"anyOf": [
54+
{
55+
"enum": [
56+
"transitive",
57+
"direct main"
58+
]
59+
},
60+
{
61+
"type": "string"
62+
}
63+
]
64+
},
65+
"PackageDescription": {
66+
"type": "object",
67+
"description": "Description of the package source."
68+
},
69+
"HostedPackageDescription": {
70+
"description": "For hosted packages.",
71+
"type": "object",
72+
"allOf": [
73+
{
74+
"$ref": "#/definitions/PackageDescription"
75+
}
76+
],
77+
"required": [
78+
"name",
79+
"sha256",
80+
"url"
81+
],
82+
"properties": {
83+
"name": {
84+
"type": "string",
85+
"description": "Name of the package."
86+
},
87+
"sha256": {
88+
"type": "string",
89+
"description": "SHA256 checksum of the package."
90+
},
91+
"url": {
92+
"type": "string",
93+
"format": "uri",
94+
"description": "URL of the package host."
95+
}
96+
},
97+
"additionalProperties": false
98+
},
99+
"GitPackageDescription": {
100+
"description": "For git packages.",
101+
"type": "object",
102+
"allOf": [
103+
{
104+
"$ref": "#/definitions/PackageDescription"
105+
}
106+
],
107+
"required": [
108+
"path",
109+
"ref",
110+
"resolved-ref",
111+
"url"
112+
],
113+
"properties": {
114+
"path": {
115+
"type": "string",
116+
"description": "Path within the git repository (if applicable)."
117+
},
118+
"ref": {
119+
"type": "string",
120+
"description": "Git reference (e.g., branch, tag, or commit hash)."
121+
},
122+
"resolved-ref": {
123+
"type": "string",
124+
"description": "Resolved git commit hash."
125+
},
126+
"url": {
127+
"type": "string",
128+
"format": "uri",
129+
"description": "URL of the git repository."
130+
}
131+
},
132+
"additionalProperties": false
133+
},
134+
"PathPackageDescription": {
135+
"description": "For path packages.",
136+
"type": "object",
137+
"allOf": [
138+
{
139+
"$ref": "#/definitions/PackageDescription"
140+
}
141+
],
142+
"required": [
143+
"path",
144+
"relative"
145+
],
146+
"properties": {
147+
"path": {
148+
"type": "string",
149+
"description": "Absolute or relative path to the package."
150+
},
151+
"relative": {
152+
"type": "boolean",
153+
"description": "Indicates if the path is relative to the lockfile."
154+
}
155+
},
156+
"additionalProperties": false
157+
},
158+
"PackageSource": {
159+
"type": "string",
160+
"description": "The source of the package.",
161+
"anyOf": [
162+
{
163+
"enum": [
164+
"hosted",
165+
"git",
166+
"path"
167+
]
168+
},
169+
{
170+
"type": "string"
171+
}
172+
]
173+
},
174+
"PackageVersion": {
175+
"type": "string",
176+
"description": "The locked version of the package."
177+
},
178+
"SDKs": {
179+
"type": "object",
180+
"description": "Details of the SDKs used.",
181+
"required": [
182+
"dart"
183+
],
184+
"properties": {
185+
"dart": {
186+
"$ref": "#/definitions/DartSDKVersion"
187+
}
188+
},
189+
"additionalProperties": false
190+
},
191+
"DartSDKVersion": {
192+
"type": "string",
193+
"description": "The Dart SDK version constraint."
194+
}
195+
}
196+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// An internal library containing file formats for the pub client. This library
6+
/// is not meant to have a stable API and might break at any point when
7+
/// `package:json_syntax_generator` is updated. This API is used in the Dart
8+
/// SDK, so when doing breaking changes please roll ASAP to the Dart SDK.
9+
library;
10+
11+
export 'src/pubspec_lock_syntax.g.dart';

0 commit comments

Comments
 (0)