@@ -7,7 +7,7 @@ import put from '../../utils/put';
77import settings from '../../resources/settings' ;
88import * as urlBuilder from '../../registry/domain/url-builder' ;
99import * as urlParser from '../domain/url-parser' ;
10- import { RegistryCli } from '../../types' ;
10+ import { Component } from '../../types' ;
1111
1212const getOcVersion = ( ) : string => {
1313 const ocPackagePath = path . join ( __dirname , '../../../package.json' ) ;
@@ -20,15 +20,15 @@ interface RegistryOptions {
2020 registry ?: string ;
2121}
2222
23- export default function registry ( opts : RegistryOptions = { } ) : RegistryCli {
23+ export default function registry ( opts : RegistryOptions = { } ) {
2424 let requestsHeaders = {
2525 'user-agent' : `oc-cli-${ getOcVersion ( ) } /${ process . version } -${
2626 process . platform
2727 } -${ process . arch } `
2828 } ;
2929
3030 return {
31- async add ( registry : string ) {
31+ async add ( registry : string ) : Promise < void > {
3232 if ( registry . slice ( registry . length - 1 ) !== '/' ) {
3333 registry += '/' ;
3434 }
@@ -57,7 +57,7 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli {
5757 throw 'oc registry not available' ;
5858 }
5959 } ,
60- async get ( ) {
60+ async get ( ) : Promise < string [ ] > {
6161 if ( opts . registry ) {
6262 return [ opts . registry ] ;
6363 }
@@ -73,12 +73,12 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli {
7373 throw 'No oc registries' ;
7474 }
7575 } ,
76- getApiComponentByHref ( href : string ) {
76+ getApiComponentByHref ( href : string ) : Promise < Component > {
7777 return got ( href + settings . registry . componentInfoPath , {
7878 headers : requestsHeaders
7979 } ) . json ( ) ;
8080 } ,
81- async getComponentPreviewUrlByUrl ( componentHref : string ) {
81+ async getComponentPreviewUrlByUrl ( componentHref : string ) : Promise < string > {
8282 const res : { requestVersion : string ; href : string } = await got (
8383 componentHref ,
8484 { headers : requestsHeaders }
@@ -93,7 +93,7 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli {
9393 password ?: string ;
9494 route : string ;
9595 path : string ;
96- } ) {
96+ } ) : Promise < void > {
9797 if ( ! ! options . username && ! ! options . password ) {
9898 requestsHeaders = Object . assign ( requestsHeaders , {
9999 Authorization :
@@ -129,7 +129,7 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli {
129129 throw errMsg ;
130130 }
131131 } ,
132- async remove ( registry : string ) {
132+ async remove ( registry : string ) : Promise < void > {
133133 if ( registry . slice ( registry . length - 1 ) !== '/' ) {
134134 registry += '/' ;
135135 }
@@ -143,3 +143,5 @@ export default function registry(opts: RegistryOptions = {}): RegistryCli {
143143 }
144144 } ;
145145}
146+
147+ export type RegistryCli = ReturnType < typeof registry > ;
0 commit comments