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.',
|
'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',
|
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()
|
.help()
|
||||||
.strict()
|
.strict()
|
||||||
@@ -124,6 +129,10 @@ if (argv['rebuild-plugins'] === false) {
|
|||||||
delete process.env.FLIPPER_NO_REBUILD_PLUGINS;
|
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) {
|
async function generateManifest(versionNumber: string) {
|
||||||
await fs.writeFile(
|
await fs.writeFile(
|
||||||
path.join(distDir, 'manifest.json'),
|
path.join(distDir, 'manifest.json'),
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
appDir,
|
appDir,
|
||||||
staticDir,
|
staticDir,
|
||||||
defaultPluginsIndexDir,
|
defaultPluginsDir,
|
||||||
babelTransformationsDir,
|
babelTransformationsDir,
|
||||||
} from './paths';
|
} from './paths';
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ const hardcodedPlugins = new Set<string>([
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
export function die(err: Error) {
|
export function die(err: Error) {
|
||||||
console.error(err);
|
console.error('Script termnated.', err);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,24 +63,42 @@ export async function prepareDefaultPlugins(isInsidersBuild: boolean = false) {
|
|||||||
console.log(
|
console.log(
|
||||||
`⚙️ Preparing default plugins (isInsidersBuild=${isInsidersBuild})...`,
|
`⚙️ Preparing default plugins (isInsidersBuild=${isInsidersBuild})...`,
|
||||||
);
|
);
|
||||||
await fs.emptyDir(defaultPluginsIndexDir);
|
await fs.emptyDir(defaultPluginsDir);
|
||||||
const sourcePlugins = process.env.FLIPPER_NO_DEFAULT_PLUGINS
|
const forcedDefaultPluginsDir = process.env.FLIPPER_DEFAULT_PLUGINS_DIR;
|
||||||
? []
|
if (forcedDefaultPluginsDir) {
|
||||||
: await getSourcePlugins();
|
console.log(
|
||||||
const defaultPlugins = sourcePlugins
|
`⚙️ Copying the provided default plugins dir "${forcedDefaultPluginsDir}"...`,
|
||||||
// we only include predefined set of plugins into insiders release
|
);
|
||||||
.filter((p) => !isInsidersBuild || hardcodedPlugins.has(p.id));
|
await fs.copy(forcedDefaultPluginsDir, defaultPluginsDir, {
|
||||||
if (isInsidersBuild || process.env.FLIPPER_NO_BUNDLED_PLUGINS) {
|
recursive: true,
|
||||||
await buildDefaultPlugins(defaultPlugins);
|
overwrite: true,
|
||||||
|
dereference: true,
|
||||||
|
});
|
||||||
|
console.log('✅ Copied the provided default plugins dir.');
|
||||||
await generateDefaultPluginEntryPoints([]); // calling it here just to generate empty indexes
|
await generateDefaultPluginEntryPoints([]); // calling it here just to generate empty indexes
|
||||||
} else {
|
} 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(
|
async function generateDefaultPluginEntryPoints(
|
||||||
defaultPlugins: InstalledPluginDetails[],
|
defaultPlugins: InstalledPluginDetails[],
|
||||||
) {
|
) {
|
||||||
|
console.log(
|
||||||
|
`⚙️ Generating entry points for ${defaultPlugins.length} bundled plugins...`,
|
||||||
|
);
|
||||||
const bundledPlugins = defaultPlugins.map(
|
const bundledPlugins = defaultPlugins.map(
|
||||||
(p) =>
|
(p) =>
|
||||||
({
|
({
|
||||||
@@ -94,7 +112,7 @@ async function generateDefaultPluginEntryPoints(
|
|||||||
} as BundledPluginDetails),
|
} as BundledPluginDetails),
|
||||||
);
|
);
|
||||||
await fs.writeJSON(
|
await fs.writeJSON(
|
||||||
path.join(defaultPluginsIndexDir, 'bundled.json'),
|
path.join(defaultPluginsDir, 'bundled.json'),
|
||||||
bundledPlugins,
|
bundledPlugins,
|
||||||
);
|
);
|
||||||
const pluginRequres = bundledPlugins
|
const pluginRequres = bundledPlugins
|
||||||
@@ -110,7 +128,7 @@ async function generateDefaultPluginEntryPoints(
|
|||||||
path.join(appDir, 'src', 'defaultPlugins', 'index.tsx'),
|
path.join(appDir, 'src', 'defaultPlugins', 'index.tsx'),
|
||||||
generatedIndex,
|
generatedIndex,
|
||||||
);
|
);
|
||||||
console.log('✅ Generated plugin entry points.');
|
console.log('✅ Generated bundled plugin entry points.');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function buildDefaultPlugins(defaultPlugins: InstalledPluginDetails[]) {
|
async function buildDefaultPlugins(defaultPlugins: InstalledPluginDetails[]) {
|
||||||
@@ -133,7 +151,7 @@ async function buildDefaultPlugins(defaultPlugins: InstalledPluginDetails[]) {
|
|||||||
}
|
}
|
||||||
await fs.ensureSymlink(
|
await fs.ensureSymlink(
|
||||||
plugin.dir,
|
plugin.dir,
|
||||||
path.join(defaultPluginsIndexDir, plugin.name),
|
path.join(defaultPluginsDir, plugin.name),
|
||||||
'junction',
|
'junction',
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import isFB from './isFB';
|
|||||||
export const rootDir = path.resolve(__dirname, '..');
|
export const rootDir = path.resolve(__dirname, '..');
|
||||||
export const appDir = path.join(rootDir, 'app');
|
export const appDir = path.join(rootDir, 'app');
|
||||||
export const staticDir = path.join(rootDir, 'static');
|
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 pluginsDir = path.join(rootDir, 'plugins');
|
||||||
export const fbPluginsDir = path.join(pluginsDir, 'fb');
|
export const fbPluginsDir = path.join(pluginsDir, 'fb');
|
||||||
export const publicPluginsDir = path.join(pluginsDir, 'public');
|
export const publicPluginsDir = path.join(pluginsDir, 'public');
|
||||||
|
|||||||
Reference in New Issue
Block a user