Skip to content

Commit

Permalink
feat: add options_schema field
Browse files Browse the repository at this point in the history
  • Loading branch information
qwqcode committed Oct 22, 2024
1 parent bac049d commit c2e2f80
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions scripts/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface RegistryEntry {
npm_name: string
source: string
integrity: string
options_schema: string
verified: boolean
version: string
updated_at: string
Expand Down
7 changes: 6 additions & 1 deletion scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* This script is used to generate the `registry.json` file.
*/
import path from 'node:path'
import fs from 'fs-extra'
import axios from 'axios'
import crypto from 'crypto'
Expand Down Expand Up @@ -114,6 +115,7 @@ const buildRegistryEntry = async (
version: cacheEntry?.version || '',
source: cacheEntry?.source || '',
integrity: cacheEntry?.integrity || '',
options_schema: cacheEntry?.options_schema || '',
updated_at: cacheEntry?.updated_at || '',
min_artalk_version: cacheEntry?.min_artalk_version || '',
}
Expand All @@ -133,7 +135,9 @@ const buildRegistryEntry = async (
)
return null
}
const source = `https://cdn.jsdelivr.net/npm/${srcEntry.npm_package}@${version}/${mainFile}`

const cdnBase = `https://cdn.jsdelivr.net/npm/${srcEntry.npm_package}@${version}`
const source = `${cdnBase}/${mainFile}`
const integrity = await generateSRIFromURL(source)
if (!integrity) return null

Expand All @@ -144,6 +148,7 @@ const buildRegistryEntry = async (
integrity,
updated_at: npmInfo['time'][version],
min_artalk_version: extractMinArtalkClientVersion(npmPkgData),
options_schema: `${cdnBase}/${path.dirname(mainFile)}/artalk-plugin-options.schema.json`,
}
}

Expand Down

0 comments on commit c2e2f80

Please sign in to comment.