Skip to content

Commit b84a20b

Browse files
committed
fix: normalize checksums to platform-keyed { asset, sha256 } format
1 parent 5b306d2 commit b84a20b

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

packages/build-infra/lib/external-tools-schema.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,24 @@
2525
"tag": { "type": "string" },
2626
"checksums": {
2727
"type": "object",
28-
"additionalProperties": { "type": "string" }
28+
"additionalProperties": {
29+
"oneOf": [
30+
{
31+
"type": "object",
32+
"properties": {
33+
"asset": { "type": "string" },
34+
"sha256": { "type": "string" }
35+
},
36+
"required": ["asset", "sha256"]
37+
},
38+
{ "type": "string" }
39+
]
40+
}
2941
}
3042
},
3143
"additionalProperties": true
3244
}
3345
}
3446
},
35-
"required": ["tools"]
47+
"additionalProperties": true
3648
}

packages/build-infra/lib/external-tools-schema.mjs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,20 @@ const toolSchema = z
4444
.optional()
4545
.describe('Release tag (when different from version)'),
4646
checksums: z
47-
.record(z.string(), z.string())
47+
.record(
48+
z.string(),
49+
z.union([
50+
// Platform-keyed: { "darwin-arm64": { "asset": "file.tar.gz", "sha256": "abc..." } }
51+
z.object({
52+
asset: z.string(),
53+
sha256: z.string(),
54+
}),
55+
// Flat: { "file.tar.gz": "abc..." } (legacy/simple)
56+
z.string(),
57+
]),
58+
)
4859
.optional()
49-
.describe('SHA-256 checksums keyed by asset filename'),
60+
.describe('Checksums keyed by platform or asset filename'),
5061

5162
// npm package fields (socket-cli bundle-tools).
5263
integrity: z
@@ -76,9 +87,10 @@ export const externalToolsSchema = z
7687
.describe('Path to a base external-tools.json to inherit tools from'),
7788
tools: z
7889
.record(z.string(), toolSchema)
90+
.optional()
7991
.describe('Map of tool name to tool configuration'),
8092
})
81-
.strict()
93+
.passthrough()
8294

8395
/**
8496
* Validate an external-tools.json object against the schema.

0 commit comments

Comments
 (0)