11// Refer https://json-schema.org/understanding-json-schema/index.html
22import { HTTP_STATUS_CODES } from "@aicore/libcommonutils" ;
3- import { getRepoDetails , getReleaseDetails , createIssue } from "../github.js" ;
3+ import { getRepoDetails , getReleaseDetails , createIssue , getOrgDetails } from "../github.js" ;
44import db from "../db.js" ;
55import { downloader } from "../utils/downloader.js" ;
66import { ZipUtils } from "../utils/zipUtils.js" ;
@@ -151,7 +151,7 @@ function _validateGitHubReleaseAssets(githubReleaseDetails, issueMessages) {
151151 return extensionZipAsset ;
152152}
153153
154- async function _validateExtensionPackageJson ( githubReleaseTag , packageJSON , issueMessages ) {
154+ async function _validateExtensionPackageJson ( githubReleaseTag , packageJSON , repoDetails , issueMessages ) {
155155 const queryObj = { } ;
156156 const newOwner = `github:${ githubReleaseTag . owner } ` ;
157157 const releaseRef = `${ githubReleaseTag . owner } /${ githubReleaseTag . repo } /${ githubReleaseTag . tag } ` ;
@@ -196,9 +196,33 @@ async function _validateExtensionPackageJson(githubReleaseTag, packageJSON, issu
196196 updatePublishErrors : true ,
197197 error} ;
198198 }
199+ let org = await getOrgDetails ( githubReleaseTag . owner ) ;
200+ let ownershipVerifiedByGitHub = null ;
201+ if ( org && org . is_verified && org . blog ) {
202+ ownershipVerifiedByGitHub = [ org . blog ] ;
203+ }
204+ // now create the new registry package json
205+ registryPKG = registryPKG || {
206+ "versions" : [ ] ,
207+ "totalDownloads" : 0 ,
208+ "recent" : { }
209+ } ;
210+ registryPKG . metadata = packageJSON ;
211+ registryPKG . owner = `github:${ githubReleaseTag . owner } ` ;
212+ registryPKG . gihubStars = repoDetails . stargazers_count ;
213+ registryPKG . ownerRepo = `https://github.com/${ githubReleaseTag . owner } /${ githubReleaseTag . repo } ` ;
214+ registryPKG . ownershipVerifiedByGitHub = ownershipVerifiedByGitHub ;
215+ registryPKG . versions . push ( {
216+ "version" : packageJSON . version ,
217+ "published" : new Date ( ) . toISOString ( ) ,
218+ "brackets" : packageJSON . engines . brackets ,
219+ "downloads" : 0
220+ } ) ;
221+
222+ console . log ( registryPKG ) ;
199223}
200224
201- async function _downloadAndValidateExtensionZip ( githubReleaseTag , extensionZipAsset , issueMessages ) {
225+ async function _downloadAndValidateExtensionZip ( githubReleaseTag , extensionZipAsset , repoDetails , issueMessages ) {
202226 const targetPath = `${ EXTENSION_DOWNLOAD_DIR } /${ githubReleaseTag . owner } _${ githubReleaseTag . repo } _${ githubReleaseTag . tag } _${ extensionZipAsset . name } ` ;
203227 await downloader . downloadFile ( extensionZipAsset . browser_download_url , targetPath ) ;
204228 let { packageJSON, error} = await ZipUtils . getExtensionPackageJSON ( targetPath ) ;
@@ -225,7 +249,7 @@ async function _downloadAndValidateExtensionZip(githubReleaseTag, extensionZipAs
225249 updatePublishErrors : true ,
226250 error} ;
227251 }
228- await _validateExtensionPackageJson ( githubReleaseTag , packageJSON , issueMessages ) ;
252+ await _validateExtensionPackageJson ( githubReleaseTag , packageJSON , repoDetails , issueMessages ) ;
229253 return targetPath ;
230254}
231255
@@ -316,7 +340,7 @@ export async function publishGithubRelease(request, reply) {
316340 error : `Draft or PreRelease builds cannot be published.` } ;
317341 }
318342 const extensionZipAsset = _validateGitHubReleaseAssets ( newGithubReleaseDetails , issueMessages ) ;
319- extensionZipPath = await _downloadAndValidateExtensionZip ( githubReleaseTag , extensionZipAsset , issueMessages ) ;
343+ extensionZipPath = await _downloadAndValidateExtensionZip ( githubReleaseTag , extensionZipAsset , repoDetails , issueMessages ) ;
320344 // we should also in the future do a virus scan, but will rely on av in users machine for the time being
321345 // https://developers.virustotal.com/reference/files-scan by Google Cloud is available for non-commercial apps.
322346 const response = {
0 commit comments