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
This commit is contained in:
Lorenzo Blasa
2023-05-25 08:21:41 -07:00
committed by Facebook GitHub Bot
parent 76fbaf245c
commit eaaac54bc4
3 changed files with 19 additions and 3 deletions

View File

@@ -225,7 +225,6 @@ async function copyStaticResources(outDir: string, versionNumber: string) {
'icons.json', 'icons.json',
'index.web.dev.html', 'index.web.dev.html',
'index.web.html', 'index.web.html',
'manifest.json',
'offline.html', 'offline.html',
'service-worker.js', 'service-worker.js',
'style.css', 'style.css',
@@ -239,6 +238,13 @@ async function copyStaticResources(outDir: string, versionNumber: string) {
fs.copy(path.join(staticDir, e), path.join(outDir, 'static', e)), 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.'); console.log('✅ Copied static resources.');
} }

View File

@@ -19,6 +19,7 @@ import isFB from './isFB';
import yargs from 'yargs'; import yargs from 'yargs';
import ensurePluginFoldersWatchable from './ensurePluginFoldersWatchable'; import ensurePluginFoldersWatchable from './ensurePluginFoldersWatchable';
import {Watchman} from 'flipper-pkg-lib'; import {Watchman} from 'flipper-pkg-lib';
import fs from 'fs-extra';
const argv = yargs const argv = yargs
.usage('yarn flipper-server [args]') .usage('yarn flipper-server [args]')
@@ -94,6 +95,16 @@ if (argv['enabled-plugins'] !== undefined) {
let startCount = 0; 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() { async function restartServer() {
try { try {
await compileServerMain(true); await compileServerMain(true);
@@ -156,9 +167,8 @@ async function startWatchChanges() {
process.env.FLIPPER_RELEASE_CHANNEL === 'insiders', process.env.FLIPPER_RELEASE_CHANNEL === 'insiders',
); );
await copyStaticResources();
await ensurePluginFoldersWatchable(); await ensurePluginFoldersWatchable();
// builds and starts
await restartServer(); await restartServer();
// watch
await startWatchChanges(); await startWatchChanges();
})(); })();