@@ -45,9 +45,15 @@ export async function createAndPublishDownloadCenterConfig(
45
45
accessKeyId : awsAccessKeyId ,
46
46
secretAccessKey : awsSecretAccessKey ,
47
47
} ) ;
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
+ }
51
57
52
58
const getVersionConfig = ( ) =>
53
59
createVersionConfig ( packageInformation , publicArtifactBaseUrl ) ;
@@ -59,7 +65,7 @@ export async function createAndPublishDownloadCenterConfig(
59
65
: createDownloadCenterConfig ( getVersionConfig ) ;
60
66
61
67
console . warn ( 'Created download center config:' ) ;
62
- // console.dir(config, { depth: Infinity });
68
+ console . dir ( config , { depth : Infinity } ) ;
63
69
64
70
validateConfigSchema ( config ) ;
65
71
@@ -69,13 +75,20 @@ export async function createAndPublishDownloadCenterConfig(
69
75
secretAccessKey : awsSecretAccessKey ,
70
76
} ) ;
71
77
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
76
89
? JSON . parse ( existingJsonFeedText . toString ( ) )
77
90
: undefined ;
78
- const injectedJsonFeed = injectedJsonFeedFile
91
+ const injectedJsonFeed : JsonFeed | undefined = injectedJsonFeedFile
79
92
? JSON . parse ( await fs . readFile ( injectedJsonFeedFile , 'utf8' ) )
80
93
: undefined ;
81
94
const currentJsonFeedEntry = await createJsonFeedEntry (
@@ -86,7 +99,7 @@ export async function createAndPublishDownloadCenterConfig(
86
99
versions : [ currentJsonFeedEntry ] ,
87
100
} ;
88
101
console . warn ( 'Adding new JSON feed entry:' ) ;
89
- // console.dir(currentJsonFeedEntry, { depth: Infinity });
102
+ console . dir ( currentJsonFeedEntry , { depth : Infinity } ) ;
90
103
91
104
const newJsonFeed = mergeFeeds (
92
105
existingJsonFeed ,
@@ -227,7 +240,7 @@ export async function createJsonFeedEntry(
227
240
} ;
228
241
}
229
242
230
- function mergeFeeds ( ...args : JsonFeed [ ] ) : JsonFeed {
243
+ function mergeFeeds ( ...args : ( JsonFeed | undefined ) [ ] ) : JsonFeed {
231
244
const newFeed : JsonFeed = {
232
245
versions : [ ] ,
233
246
} ;
0 commit comments