@@ -211,37 +211,44 @@ async function createLandscapeSample({
211
211
timestampModifier,
212
212
initializer,
213
213
} ) {
214
- let structureData ;
215
- let dynamicData ;
216
- let timestampData ;
214
+ let structureData , dynamicData , timestampData ;
215
+
217
216
try {
218
217
structureData = JSON . parse ( await readFile ( `demo-data/${ folder } /structure.json` ) ) ;
219
- dynamicData = JSON . parse ( await readFile ( `demo-data/${ folder } /dynamic.json` ) ) ;
220
- timestampData = JSON . parse ( await readFile ( `demo-data/${ folder } /timestamps.json` ) ) ;
221
218
} catch {
222
- console . error ( "Could not read files for folder:" , folder ) ;
223
- return ;
219
+ structureData = { landscapeToken : token , nodes : [ ] } ;
220
+ console . error ( "Could not read structure data for:" , folder ) ;
224
221
}
225
222
226
223
const landscapeToken = token ? token : structureData . landscapeToken ;
227
224
228
- landscapes . push ( {
229
- value : landscapeToken ,
230
- ownerId : "github|123456" ,
231
- created : timestampData . length > 0 ? timestampData [ 0 ] . epochMilli : 0 ,
232
- alias : alias ? alias : folder ,
233
- sharedUsersIds : [ ] ,
234
- } ) ;
235
-
236
- initializer ?. ( structureData , dynamicData ) ;
237
-
238
225
spanApp . get ( `${ spanRootUrl } /${ landscapeToken } /structure` , ( req , res ) =>
239
226
res . json ( structureModifier ? structureModifier ( structureData ) : structureData )
240
227
) ;
241
228
229
+ try {
230
+ dynamicData = JSON . parse ( await readFile ( `demo-data/${ folder } /dynamic.json` ) ) ;
231
+ } catch {
232
+ dynamicData = [ ] ;
233
+ console . error ( "Could not read dynamic data for:" , folder ) ;
234
+ }
235
+
242
236
spanApp . get ( `${ spanRootUrl } /${ landscapeToken } /dynamic` , ( req , res ) =>
243
237
res . json ( traceModifier ? traceModifier ( dynamicData ) : dynamicData )
244
238
) ;
239
+ initializer ?. ( structureData , dynamicData ) ;
240
+
241
+ try {
242
+ timestampData = JSON . parse ( await readFile ( `demo-data/${ folder } /timestamps.json` ) ) ;
243
+ } catch {
244
+ timestampData = [
245
+ {
246
+ epochMilli : 0 ,
247
+ spanCount : 0 ,
248
+ } ,
249
+ ] ;
250
+ console . error ( "Could not read timestamps for:" , folder ) ;
251
+ }
245
252
246
253
spanApp . get ( `${ spanRootUrl } /${ landscapeToken } /timestamps` , ( req , res ) => {
247
254
const potentialLatestTimestamp = req . query . newest ;
@@ -258,4 +265,12 @@ async function createLandscapeSample({
258
265
res . json ( timestampData ) ;
259
266
}
260
267
} ) ;
268
+
269
+ landscapes . push ( {
270
+ value : landscapeToken ,
271
+ ownerId : "github|123456" ,
272
+ created : timestampData && timestampData . length > 0 ? timestampData [ 0 ] . epochMilli : 0 ,
273
+ alias : alias ? alias : folder ,
274
+ sharedUsersIds : [ ] ,
275
+ } ) ;
261
276
}
0 commit comments