Build script updated to allow specifying directory with default plugins
Summary: This change allows passing a directory containing plugin packages to include them into Flipper distributive. This is used by release command on Sandcastle (see D28626715). Reviewed By: passy Differential Revision: D28628425 fbshipit-source-id: 9c5d7527721f99b43991bace0b5e2f3a4ede0d13
This commit is contained in:
committed by
Facebook GitHub Bot
parent
313baafded
commit
8d508c8634
@@ -88,6 +88,11 @@ const argv = yargs
|
||||
'Enables rebuilding of default plugins on Flipper build. Only make sense in conjunction with "--no-bundled-plugins". Enabled by default, but if disabled using "--no-plugin-rebuild", then plugins are just released as is without rebuilding. This can save some time if you know plugin bundles are already up-to-date.',
|
||||
type: 'boolean',
|
||||
},
|
||||
'default-plugins-dir': {
|
||||
describe:
|
||||
'Directory with prepared list of default plugins which will be included into the Flipper distribution as "defaultPlugins" dir',
|
||||
type: 'string',
|
||||
},
|
||||
})
|
||||
.help()
|
||||
.strict()
|
||||
@@ -124,6 +129,10 @@ if (argv['rebuild-plugins'] === false) {
|
||||
delete process.env.FLIPPER_NO_REBUILD_PLUGINS;
|
||||
}
|
||||
|
||||
if (argv['default-plugins-dir']) {
|
||||
process.env.FLIPPER_DEFAULT_PLUGINS_DIR = argv['default-plugins-dir'];
|
||||
}
|
||||
|
||||
async function generateManifest(versionNumber: string) {
|
||||
await fs.writeFile(
|
||||
path.join(distDir, 'manifest.json'),
|
||||
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
import {
|
||||
appDir,
|
||||
staticDir,
|
||||
defaultPluginsIndexDir,
|
||||
defaultPluginsDir,
|
||||
babelTransformationsDir,
|
||||
} from './paths';
|
||||
|
||||
@@ -55,7 +55,7 @@ const hardcodedPlugins = new Set<string>([
|
||||
]);
|
||||
|
||||
export function die(err: Error) {
|
||||
console.error(err);
|
||||
console.error('Script termnated.', err);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -63,24 +63,42 @@ export async function prepareDefaultPlugins(isInsidersBuild: boolean = false) {
|
||||
console.log(
|
||||
`⚙️ Preparing default plugins (isInsidersBuild=${isInsidersBuild})...`,
|
||||
);
|
||||
await fs.emptyDir(defaultPluginsIndexDir);
|
||||
const sourcePlugins = process.env.FLIPPER_NO_DEFAULT_PLUGINS
|
||||
? []
|
||||
: await getSourcePlugins();
|
||||
const defaultPlugins = sourcePlugins
|
||||
// we only include predefined set of plugins into insiders release
|
||||
.filter((p) => !isInsidersBuild || hardcodedPlugins.has(p.id));
|
||||
if (isInsidersBuild || process.env.FLIPPER_NO_BUNDLED_PLUGINS) {
|
||||
await buildDefaultPlugins(defaultPlugins);
|
||||
await fs.emptyDir(defaultPluginsDir);
|
||||
const forcedDefaultPluginsDir = process.env.FLIPPER_DEFAULT_PLUGINS_DIR;
|
||||
if (forcedDefaultPluginsDir) {
|
||||
console.log(
|
||||
`⚙️ Copying the provided default plugins dir "${forcedDefaultPluginsDir}"...`,
|
||||
);
|
||||
await fs.copy(forcedDefaultPluginsDir, defaultPluginsDir, {
|
||||
recursive: true,
|
||||
overwrite: true,
|
||||
dereference: true,
|
||||
});
|
||||
console.log('✅ Copied the provided default plugins dir.');
|
||||
await generateDefaultPluginEntryPoints([]); // calling it here just to generate empty indexes
|
||||
} else {
|
||||
await generateDefaultPluginEntryPoints(defaultPlugins);
|
||||
const sourcePlugins = process.env.FLIPPER_NO_DEFAULT_PLUGINS
|
||||
? []
|
||||
: await getSourcePlugins();
|
||||
const defaultPlugins = sourcePlugins
|
||||
// we only include predefined set of plugins into insiders release
|
||||
.filter((p) => !isInsidersBuild || hardcodedPlugins.has(p.id));
|
||||
if (process.env.FLIPPER_NO_BUNDLED_PLUGINS) {
|
||||
await buildDefaultPlugins(defaultPlugins);
|
||||
await generateDefaultPluginEntryPoints([]); // calling it here just to generate empty indexes
|
||||
} else {
|
||||
await generateDefaultPluginEntryPoints(defaultPlugins);
|
||||
}
|
||||
}
|
||||
console.log('✅ Prepared default plugins.');
|
||||
}
|
||||
|
||||
async function generateDefaultPluginEntryPoints(
|
||||
defaultPlugins: InstalledPluginDetails[],
|
||||
) {
|
||||
console.log(
|
||||
`⚙️ Generating entry points for ${defaultPlugins.length} bundled plugins...`,
|
||||
);
|
||||
const bundledPlugins = defaultPlugins.map(
|
||||
(p) =>
|
||||
({
|
||||
@@ -94,7 +112,7 @@ async function generateDefaultPluginEntryPoints(
|
||||
} as BundledPluginDetails),
|
||||
);
|
||||
await fs.writeJSON(
|
||||
path.join(defaultPluginsIndexDir, 'bundled.json'),
|
||||
path.join(defaultPluginsDir, 'bundled.json'),
|
||||
bundledPlugins,
|
||||
);
|
||||
const pluginRequres = bundledPlugins
|
||||
@@ -110,7 +128,7 @@ async function generateDefaultPluginEntryPoints(
|
||||
path.join(appDir, 'src', 'defaultPlugins', 'index.tsx'),
|
||||
generatedIndex,
|
||||
);
|
||||
console.log('✅ Generated plugin entry points.');
|
||||
console.log('✅ Generated bundled plugin entry points.');
|
||||
}
|
||||
|
||||
async function buildDefaultPlugins(defaultPlugins: InstalledPluginDetails[]) {
|
||||
@@ -133,7 +151,7 @@ async function buildDefaultPlugins(defaultPlugins: InstalledPluginDetails[]) {
|
||||
}
|
||||
await fs.ensureSymlink(
|
||||
plugin.dir,
|
||||
path.join(defaultPluginsIndexDir, plugin.name),
|
||||
path.join(defaultPluginsDir, plugin.name),
|
||||
'junction',
|
||||
);
|
||||
} catch (err) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import isFB from './isFB';
|
||||
export const rootDir = path.resolve(__dirname, '..');
|
||||
export const appDir = path.join(rootDir, 'app');
|
||||
export const staticDir = path.join(rootDir, 'static');
|
||||
export const defaultPluginsIndexDir = path.join(staticDir, 'defaultPlugins');
|
||||
export const defaultPluginsDir = path.join(staticDir, 'defaultPlugins');
|
||||
export const pluginsDir = path.join(rootDir, 'plugins');
|
||||
export const fbPluginsDir = path.join(pluginsDir, 'fb');
|
||||
export const publicPluginsDir = path.join(pluginsDir, 'public');
|
||||
|
||||
Reference in New Issue
Block a user