Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
},
"devDependencies": {
"@anthropic-ai/claude-code": "2.1.92",
"@sinclair/typebox": "0.34.49",
"@babel/generator": "7.28.5",
"@babel/parser": "7.26.3",
"@babel/traverse": "7.26.4",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions scripts/xport-emit-schema.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @fileoverview Emit `xport.schema.json` from the TypeBox schema.
*
* The TypeBox schema in `scripts/xport-schema.mts` is the source of truth.
* TypeBox schemas are JSON Schema natively — no conversion library needed,
* just serialize the schema object and add the draft-2020-12 meta headers.
*
* Run via `pnpm run xport:emit-schema` when the schema changes.
*/

import { writeFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'

import { getDefaultLogger } from '@socketsecurity/lib/logger'

import { XportManifestSchema } from './xport-schema.mts'

const logger = getDefaultLogger()

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const rootDir = path.resolve(__dirname, '..')
const outPath = path.join(rootDir, 'xport.schema.json')

// TypeBox schemas carry JSON Schema shape directly, plus a Symbol-keyed
// [Kind] marker that JSON.stringify drops. Spreading the schema first
// then layering the canonical $schema / $id / title on top gives a clean
// draft-2020-12 document with the Socket-specific headers.
const enriched = {
$schema: 'https://json-schema.org/draft/2020-12/schema',
$id: 'https://github.com/SocketDev/xport.schema.json',
title: 'xport lock-step manifest',
...XportManifestSchema,
}

writeFileSync(outPath, JSON.stringify(enriched, null, 2) + '\n', 'utf8')
logger.success(`wrote ${path.relative(rootDir, outPath)}`)
Loading