@@ -45,9 +45,15 @@ export async function createAndPublishDownloadCenterConfig(
4545 accessKeyId : awsAccessKeyId ,
4646 secretAccessKey : awsSecretAccessKey ,
4747 } ) ;
48- const existingDownloadCenterConfig = await dlcenter . downloadConfig (
49- CONFIGURATION_KEY
50- ) ;
48+ let existingDownloadCenterConfig : DownloadCenterConfig | undefined ;
49+ try {
50+ existingDownloadCenterConfig = await dlcenter . downloadConfig (
51+ CONFIGURATION_KEY
52+ ) ;
53+ } catch ( err : any ) {
54+ console . warn ( 'Failed to get existing download center config' , err ) ;
55+ if ( err ?. code !== 'NoSuchKey' ) throw err ;
56+ }
5157
5258 const getVersionConfig = ( ) =>
5359 createVersionConfig ( packageInformation , publicArtifactBaseUrl ) ;
@@ -59,7 +65,7 @@ export async function createAndPublishDownloadCenterConfig(
5965 : createDownloadCenterConfig ( getVersionConfig ) ;
6066
6167 console . warn ( 'Created download center config:' ) ;
62- // console.dir(config, { depth: Infinity });
68+ console . dir ( config , { depth : Infinity } ) ;
6369
6470 validateConfigSchema ( config ) ;
6571
@@ -69,13 +75,20 @@ export async function createAndPublishDownloadCenterConfig(
6975 secretAccessKey : awsSecretAccessKey ,
7076 } ) ;
7177 const jsonFeedArtifactkey = `${ ARTIFACTS_FOLDER } /mongosh.json` ;
72- const existingJsonFeedText = await dlcenterArtifacts . downloadAsset (
73- jsonFeedArtifactkey
74- ) ;
75- const existingJsonFeed = existingJsonFeedText
78+ let existingJsonFeedText ;
79+ try {
80+ existingJsonFeedText = await dlcenterArtifacts . downloadAsset (
81+ jsonFeedArtifactkey
82+ ) ;
83+ } catch ( err : any ) {
84+ console . warn ( 'Failed to get existing JSON feed text' , err ) ;
85+ if ( err ?. code !== 'NoSuchKey' ) throw err ;
86+ }
87+
88+ const existingJsonFeed : JsonFeed | undefined = existingJsonFeedText
7689 ? JSON . parse ( existingJsonFeedText . toString ( ) )
7790 : undefined ;
78- const injectedJsonFeed = injectedJsonFeedFile
91+ const injectedJsonFeed : JsonFeed | undefined = injectedJsonFeedFile
7992 ? JSON . parse ( await fs . readFile ( injectedJsonFeedFile , 'utf8' ) )
8093 : undefined ;
8194 const currentJsonFeedEntry = await createJsonFeedEntry (
@@ -86,7 +99,7 @@ export async function createAndPublishDownloadCenterConfig(
8699 versions : [ currentJsonFeedEntry ] ,
87100 } ;
88101 console . warn ( 'Adding new JSON feed entry:' ) ;
89- // console.dir(currentJsonFeedEntry, { depth: Infinity });
102+ console . dir ( currentJsonFeedEntry , { depth : Infinity } ) ;
90103
91104 const newJsonFeed = mergeFeeds (
92105 existingJsonFeed ,
@@ -227,7 +240,7 @@ export async function createJsonFeedEntry(
227240 } ;
228241}
229242
230- function mergeFeeds ( ...args : JsonFeed [ ] ) : JsonFeed {
243+ function mergeFeeds ( ...args : ( JsonFeed | undefined ) [ ] ) : JsonFeed {
231244 const newFeed : JsonFeed = {
232245 versions : [ ] ,
233246 } ;
0 commit comments