From eaaac54bc4021e9e19e3db050f8692ea531b9a79 Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Thu, 25 May 2023 08:21:41 -0700 Subject: [PATCH] Manifest as template Summary: The file manifest.json is injected with the auth token and it happens with every launch. Because the file is tracked, these changes will always get picked no matter what the .gitignore file specifies, because is a tracked file. So, the solution is to have a template with a different name, that gets copied into the right location during build time. Reviewed By: LukeDefeo Differential Revision: D46184772 fbshipit-source-id: 938b9433045485d9846a6a50c1c955ebe7925581 --- desktop/scripts/build-flipper-server-release.tsx | 8 +++++++- desktop/scripts/start-flipper-server-dev.tsx | 14 ++++++++++++-- .../{manifest.json => manifest.template.json} | 0 3 files changed, 19 insertions(+), 3 deletions(-) rename desktop/static/{manifest.json => manifest.template.json} (100%) diff --git a/desktop/scripts/build-flipper-server-release.tsx b/desktop/scripts/build-flipper-server-release.tsx index bfce3f987..05256d4aa 100644 --- a/desktop/scripts/build-flipper-server-release.tsx +++ b/desktop/scripts/build-flipper-server-release.tsx @@ -225,7 +225,6 @@ async function copyStaticResources(outDir: string, versionNumber: string) { 'icons.json', 'index.web.dev.html', 'index.web.html', - 'manifest.json', 'offline.html', 'service-worker.js', 'style.css', @@ -239,6 +238,13 @@ async function copyStaticResources(outDir: string, versionNumber: string) { fs.copy(path.join(staticDir, e), path.join(outDir, 'static', e)), ), ); + + // Manifest needs to be copied over to static folder with the correct name. + await fs.copy( + path.join(staticDir, 'manifest.template.json'), + path.join(outDir, 'static', 'manifest.json'), + ); + console.log('✅ Copied static resources.'); } diff --git a/desktop/scripts/start-flipper-server-dev.tsx b/desktop/scripts/start-flipper-server-dev.tsx index 9e9623cb4..fd407495d 100644 --- a/desktop/scripts/start-flipper-server-dev.tsx +++ b/desktop/scripts/start-flipper-server-dev.tsx @@ -19,6 +19,7 @@ import isFB from './isFB'; import yargs from 'yargs'; import ensurePluginFoldersWatchable from './ensurePluginFoldersWatchable'; import {Watchman} from 'flipper-pkg-lib'; +import fs from 'fs-extra'; const argv = yargs .usage('yarn flipper-server [args]') @@ -94,6 +95,16 @@ if (argv['enabled-plugins'] !== undefined) { let startCount = 0; +async function copyStaticResources() { + console.log(`⚙️ Copying necessary static resources`); + const staticDir = path.resolve(__dirname, '..', 'static'); + + await fs.copy( + path.join(staticDir, 'manifest.template.json'), + path.join(staticDir, 'manifest.json'), + ); +} + async function restartServer() { try { await compileServerMain(true); @@ -156,9 +167,8 @@ async function startWatchChanges() { process.env.FLIPPER_RELEASE_CHANNEL === 'insiders', ); + await copyStaticResources(); await ensurePluginFoldersWatchable(); - // builds and starts await restartServer(); - // watch await startWatchChanges(); })(); diff --git a/desktop/static/manifest.json b/desktop/static/manifest.template.json similarity index 100% rename from desktop/static/manifest.json rename to desktop/static/manifest.template.json