Skip to content

Commit d39a018

Browse files
authored
use relative paths in app's manifest file (#1063)
1 parent d3b9c91 commit d39a018

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

.changeset/modern-points-attack.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ensembleui/js-commons": patch
3+
---
4+
5+
use relative paths in app's manifest file

.github/workflows/firebase-hosting-merge.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
channelId: live
3636
projectId: ensemble-web-studio-dev
3737
entryPoint: ./apps/preview
38+
firebaseToolsVersion: 13.35.1
3839
- name: Build Kitchen Sink
3940
run: pnpm run build
4041
working-directory: ./apps/kitchen-sink
@@ -45,3 +46,4 @@ jobs:
4546
channelId: live
4647
projectId: ensemble-web-studio-dev
4748
entryPoint: ./apps/kitchen-sink
49+
firebaseToolsVersion: 13.35.1

.github/workflows/firebase-hosting-pull-request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ jobs:
3030
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ENSEMBLE_WEB_STUDIO_DEV }}"
3131
projectId: ensemble-web-studio-dev
3232
entryPoint: ./apps/kitchen-sink
33+
firebaseToolsVersion: 13.35.1

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
channelId: live
4343
projectId: ensemble-web-studio
4444
entryPoint: ./apps/preview
45+
firebaseToolsVersion: 13.35.1
4546
- name: Package Starter
4647
working-directory: ./apps/starter
4748
run: |

packages/js-commons/src/core/local-files.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

415424
const 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

Comments
 (0)