Check plugin entry points before bundling them stripped
Summary: When packaging plugins into flipper-server package, we assume an idiomatic plugin structure, warn and skip if a plugin doesn't conform to it. Reviewed By: antonk52 Differential Revision: D33308367 fbshipit-source-id: fd6d1dbc66739b0867034930579429e97d9e2bfa
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a3500c453b
commit
521ef9e243
@@ -136,6 +136,18 @@ async function copyStaticResources(outDir: string) {
|
||||
}
|
||||
const target = path.join(outDir, 'static', 'defaultPlugins', plugin);
|
||||
if ((await fs.stat(source)).isDirectory()) {
|
||||
// Verify it safe to strip the package down, does it have the
|
||||
// typical flipper plugin structure?
|
||||
const packageJson = JSON.parse(
|
||||
await fs.readFile(path.join(source, 'package.json'), 'utf8'),
|
||||
);
|
||||
if (packageJson.main !== 'dist/bundle.js') {
|
||||
console.error(
|
||||
`Cannot bundle plugin '${source}', the main entry point is '${packageJson.main}', but expected 'dist/bundle.js'`,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// for plugins, only copy package.json & dist, to keep impact minimal
|
||||
await fs.copy(
|
||||
path.join(source, 'package.json'),
|
||||
|
||||
Reference in New Issue
Block a user