Skip to content

Commit 768a06d

Browse files
authored
[pub_formats] Generate package_config.json API (#2461)
1 parent b51036a commit 768a06d

File tree

6 files changed

+760
-1
lines changed

6 files changed

+760
-1
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$ref": "#/definitions/PackageConfigFile",
4+
"title": "Package Config File Schema",
5+
"description": "Schema for a Dart .dart_tool/package_config.json file. Note that this is reverse engineered and not the source of truth.",
6+
"definitions": {
7+
"PackageConfigEntry": {
8+
"type": "object",
9+
"properties": {
10+
"languageVersion": {
11+
"description": "The minimum Dart language version required by this package (e.g., '2.12', '3.0').",
12+
"type": "string",
13+
"pattern": "^[0-9]+\\.[0-9]+$"
14+
},
15+
"name": {
16+
"description": "The name of the package.",
17+
"type": "string",
18+
"pattern": "^[a-zA-Z_]\\w*$"
19+
},
20+
"packageUri": {
21+
"description": "The URI relative to rootUri where Dart files for this package are found (typically 'lib/').",
22+
"type": "string"
23+
},
24+
"rootUri": {
25+
"description": "The root URI of the package, where its pubspec.yaml file is located. Can be a file URI or relative path.",
26+
"type": "string",
27+
"format": "uri"
28+
}
29+
},
30+
"required": [
31+
"languageVersion",
32+
"name",
33+
"packageUri",
34+
"rootUri"
35+
],
36+
"additionalProperties": false
37+
},
38+
"PackageConfigFile": {
39+
"type": "object",
40+
"properties": {
41+
"configVersion": {
42+
"description": "The version of the package configuration format.",
43+
"type": "integer"
44+
},
45+
"flutterRoot": {
46+
"description": "The root URI of the Flutter SDK (if applicable).",
47+
"type": "string",
48+
"format": "uri"
49+
},
50+
"flutterVersion": {
51+
"description": "The version of the Flutter SDK (if applicable).",
52+
"type": "string"
53+
},
54+
"generator": {
55+
"description": "The tool that generated this package configuration (e.g., 'pub').",
56+
"type": "string"
57+
},
58+
"generatorVersion": {
59+
"description": "The version of the generator tool.",
60+
"type": "string"
61+
},
62+
"packages": {
63+
"description": "A list of package configurations.",
64+
"type": "array",
65+
"items": {
66+
"$ref": "#/definitions/PackageConfigEntry"
67+
}
68+
},
69+
"pubCache": {
70+
"description": "The URI of the Pub cache directory.",
71+
"type": "string",
72+
"format": "uri"
73+
}
74+
},
75+
"required": [
76+
"configVersion",
77+
"packages"
78+
],
79+
"additionalProperties": false
80+
}
81+
}
82+
}

pkgs/pub_formats/lib/pubspec_formats.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/// SDK, so when doing breaking changes please roll ASAP to the Dart SDK.
99
library;
1010

11+
export 'src/package_config_syntax.g.dart' hide JsonObjectSyntax;
1112
export 'src/package_graph_syntax.g.dart' hide JsonObjectSyntax;
1213
export 'src/pubspec_lock_syntax.g.dart' hide JsonObjectSyntax;
1314
export 'src/pubspec_syntax.g.dart' hide JsonObjectSyntax;

0 commit comments

Comments
 (0)