From 8ee788239b13132567ef14e4d8e0cbed7326a4c0 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Mon, 28 Feb 2022 03:50:34 -0800 Subject: [PATCH] Update version number for default plugins Summary: Prior to this fix, plugins were copied with verion 0.0.0 which forced them to be updated with "newer" versions from marketplace Reviewed By: nikoant Differential Revision: D34457087 fbshipit-source-id: a3242578c570447f8ecf9c62bcaa69e5d9688c42 --- .../scripts/build-flipper-server-release.tsx | 17 ++++++++++------- desktop/scripts/build-utils.tsx | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/desktop/scripts/build-flipper-server-release.tsx b/desktop/scripts/build-flipper-server-release.tsx index 020189604..5492611bc 100644 --- a/desktop/scripts/build-flipper-server-release.tsx +++ b/desktop/scripts/build-flipper-server-release.tsx @@ -142,7 +142,7 @@ if (argv['default-plugins-dir']) { process.env.FLIPPER_DEFAULT_PLUGINS_DIR = argv['default-plugins-dir']; } -async function copyStaticResources(outDir: string) { +async function copyStaticResources(outDir: string, versionNumber: string) { console.log(`⚙️ Copying default plugins...`); const plugins = await fs.readdir(defaultPluginsDir); @@ -166,12 +166,15 @@ async function copyStaticResources(outDir: string) { continue; } - // for plugins, only copy package.json & dist, to keep impact minimal - await fs.copy( - path.join(source, 'package.json'), - path.join(target, 'package.json'), - ); + // Update version number of the default plugins to prevent them from updating from marketplace + // Preserve current plugin versions if plugins were previously downloaded from marketplace during the build on Sandcastle. + // See build-utils:prepareDefaultPlugins + packageJson.version = + packageJson.version === '0.0.0' ? versionNumber : packageJson.version; + + // for plugins, only keep package.json & dist, to keep impact minimal await fs.copy(path.join(source, 'dist'), path.join(target, 'dist')); + await fs.writeJSON(path.join(target, 'package.json'), packageJson); } else { await fs.copy(source, target); } @@ -300,7 +303,7 @@ async function buildServerRelease() { await compileServerMain(false); await prepareDefaultPlugins(argv.channel === 'insiders'); - await copyStaticResources(dir); + await copyStaticResources(dir, versionNumber); await downloadIcons(path.join(dir, 'static')); await buildBrowserBundle(path.join(dir, 'static'), false); await modifyPackageManifest(dir, versionNumber, hgRevision, argv.channel); diff --git a/desktop/scripts/build-utils.tsx b/desktop/scripts/build-utils.tsx index 4ed5d0bbe..ec08c1e32 100644 --- a/desktop/scripts/build-utils.tsx +++ b/desktop/scripts/build-utils.tsx @@ -82,6 +82,7 @@ export async function prepareDefaultPlugins(isInsidersBuild: boolean = false) { await fs.emptyDir(defaultPluginsDir); const forcedDefaultPluginsDir = process.env.FLIPPER_DEFAULT_PLUGINS_DIR; if (forcedDefaultPluginsDir) { + // Used for internal builds. Sandcastle downloads plugins from the marketplace to preserve their versions if they are not updated. console.log( `⚙️ Copying the provided default plugins dir "${forcedDefaultPluginsDir}"...`, );