@@ -151,8 +151,12 @@ export const getLocalApplicationTransporter = (
151151 const asset = document as AssetDTO | FontDTO ;
152152 if ( ! asset . publicUrl ) return ;
153153
154- const fileData = existsSync ( asset . publicUrl )
155- ? await readFile ( asset . publicUrl ) // is local asset
154+ const assetPath = join (
155+ existingAppMetadata . projectPath ,
156+ asset . publicUrl ,
157+ ) ;
158+ const fileData = existsSync ( assetPath )
159+ ? await readFile ( assetPath ) // is local asset
156160 : await fetchFileData ( asset . publicUrl ) ; // is cloud asset
157161 const fontData =
158162 document . type === EnsembleDocumentType . Font
@@ -233,11 +237,15 @@ export const localStoreAsset = async (
233237) : Promise < { relativePath : string ; assetDocument : EnsembleDocument } > => {
234238 const appsMetadata = await getGlobalMetadata ( ) ;
235239 const existingAppMetadata = appsMetadata [ appId ] ;
236- const appMetadata =
237- options ?. existingAppMetadata ||
238- ( existingAppMetadata &&
239- ( await getAppManifest ( existingAppMetadata . projectPath ) ) ) ;
240- if ( ! appMetadata ) {
240+ let appMetadata : ApplicationLocalMeta ;
241+ if ( options ?. existingAppMetadata ) {
242+ appMetadata = options . existingAppMetadata ;
243+ } else if ( existingAppMetadata ) {
244+ appMetadata = {
245+ ...( await getAppManifest ( existingAppMetadata . projectPath ) ) ,
246+ projectPath : existingAppMetadata . projectPath ,
247+ } ;
248+ } else {
241249 throw new Error ( `App ${ appId } not found in local metadata` ) ;
242250 }
243251
@@ -257,7 +265,7 @@ export const localStoreAsset = async (
257265 ? EnsembleDocumentType . Font
258266 : EnsembleDocumentType . Asset ,
259267 content : "" ,
260- publicUrl : assetPath ,
268+ publicUrl : `/ ${ ! isEmpty ( font ) ? FOLDER_MAP [ EnsembleDocumentType . Font ] : FOLDER_MAP [ EnsembleDocumentType . Asset ] } / ${ fileName } ` ,
261269 ...font ,
262270 } as EnsembleDocument ;
263271
@@ -409,7 +417,8 @@ const setAppManifest = async (
409417
410418 const filePath = join ( projectPath , APP_MANIFEST_FILE ) ;
411419
412- await writeJsonData ( filePath , appMetadata , true ) ;
420+ const omitProjectPath = omit ( appMetadata , "projectPath" ) ;
421+ await writeJsonData ( filePath , omitProjectPath , true ) ;
413422} ;
414423
415424const readJsonFile = async < T > ( filePath : string ) : Promise < T > => {
@@ -428,7 +437,7 @@ const writeJsonData = async (
428437 data : unknown ,
429438 hideFile = false ,
430439) : Promise < void > => {
431- await writeFile ( filePath , JSON . stringify ( data ) , "utf-8" ) ;
440+ await writeFile ( filePath , JSON . stringify ( data , null , 2 ) , "utf-8" ) ;
432441
433442 if ( hideFile ) hideOnWindow ( filePath ) ;
434443} ;
0 commit comments