import * as path from 'path' ; import * as fs from 'fs-extra' ; import { Docset } from './docsets' ; import { logger } from './logger' ; export interface Metadata { feed_url : string ; urls : string [ ] ; name : string ; title : string ; version : string ; } export const availableMirrors = [ 'sanfrancisco' , 'newyork' , 'london' , 'frankfurt' ] ; export function getMetadata ( docset , mirror ? ) { const mirrors = mirror !== undefined ? [ mirror ] : availableMirrors ; const mirrorUrls = mirrors . map ( m => { return `https://${ m }.kapeli.com/feeds/zzz/user_contributed/build/${ docset . id }/${ docset . archive }` ; } ) ; return { feed_url : `https://zealusercontributions.now.sh/api/docsets/${ docset . id }.xml` , urls : mirrorUrls , name : docset . id , title : docset . name , version : docset . version , } ; } export function saveMetadata ( metadata , docsetDirectory ) { const metaPath = path . resolve ( docsetDirectory , 'meta.json' ) ; logger . info ( `Writing metadata to ${ metaPath }` ) ; fs . writeFileSync ( metaPath , JSON . stringify ( metadata , null , 2 ) ) ; }