Link shared libs to allow re-using them in both in public and fb-internal plugins
Summary: Link plugin shared libraries to the "plugins/node_modules" dir so they can be used as peer dependencies by both public and fb-internal plugins. ``` plugins - node_modules -- fb_shared_lib (symlink pointing to "plugins/fb/fb_shared_lib") -- public_shared_lib (symlink pointing to "plugins/public/public_shared_lib") - fb -- fb_shared_lib -- fb_plugin (can now use both fb_shared_lib and public_shared_lib as peer dependencies) - public -- public_shared_lib -- public_plugin (can now use both public_shared_lib and fb_shared_lib (optionally if it's an fb-internal repo) as peer dependencies) ``` Reviewed By: passy Differential Revision: D27034936 fbshipit-source-id: 68ee5312060ff57649ae061dd7dd14f8beb6d4a1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4997cb9847
commit
e5261967cb
@@ -7,7 +7,8 @@
|
|||||||
"url": "https://fb.workplace.com/groups/flippersupport/"
|
"url": "https://fb.workplace.com/groups/flippersupport/"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"fs-extra": "^9.0.1"
|
"fs-extra": "^9.0.1",
|
||||||
|
"p-map": "^4.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "../ts-node ./postinstall.ts"
|
"postinstall": "../ts-node ./postinstall.ts"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
import {execSync} from 'child_process';
|
import {execSync} from 'child_process';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
|
import pmap from 'p-map';
|
||||||
|
|
||||||
async function postinstall() {
|
async function postinstall() {
|
||||||
const publicPluginsDir = path.join(__dirname, 'public');
|
const publicPluginsDir = path.join(__dirname, 'public');
|
||||||
@@ -24,6 +25,42 @@ async function postinstall() {
|
|||||||
stdio: 'inherit',
|
stdio: 'inherit',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const [publicPackages, fbPackages] = await Promise.all([
|
||||||
|
fs.readdir(publicPluginsDir),
|
||||||
|
fs.readdir(fbPluginsDir).catch(() => [] as string[]),
|
||||||
|
]);
|
||||||
|
const packages = [
|
||||||
|
...publicPackages.map((p) => path.join(publicPluginsDir, p)),
|
||||||
|
...fbPackages.map((p) => path.join(fbPluginsDir, p)),
|
||||||
|
];
|
||||||
|
const modulesDir = path.join(__dirname, 'node_modules');
|
||||||
|
await pmap(packages, async (packageDir) => {
|
||||||
|
const packageJsonPath = path.join(packageDir, 'package.json');
|
||||||
|
if (!(await fs.pathExists(packageJsonPath))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const packageJson = await fs.readJson(
|
||||||
|
path.join(packageDir, 'package.json'),
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
packageJson.keywords &&
|
||||||
|
packageJson.keywords.includes('flipper-plugin')
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const destPath = path.join(modulesDir, packageJson.name);
|
||||||
|
console.log(
|
||||||
|
`linking ${path.relative(__dirname, destPath)} to ${path.relative(
|
||||||
|
__dirname,
|
||||||
|
packageDir,
|
||||||
|
)}`,
|
||||||
|
);
|
||||||
|
if (await fs.pathExists(destPath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await fs.ensureDir(path.dirname(destPath));
|
||||||
|
await fs.symlink(packageDir, destPath, 'junction');
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
postinstall()
|
postinstall()
|
||||||
|
|||||||
@@ -2,11 +2,24 @@
|
|||||||
# yarn lockfile v1
|
# yarn lockfile v1
|
||||||
|
|
||||||
|
|
||||||
|
aggregate-error@^3.0.0:
|
||||||
|
version "3.1.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a"
|
||||||
|
integrity sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==
|
||||||
|
dependencies:
|
||||||
|
clean-stack "^2.0.0"
|
||||||
|
indent-string "^4.0.0"
|
||||||
|
|
||||||
at-least-node@^1.0.0:
|
at-least-node@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
|
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
|
||||||
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
|
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
|
||||||
|
|
||||||
|
clean-stack@^2.0.0:
|
||||||
|
version "2.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
|
||||||
|
integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==
|
||||||
|
|
||||||
fs-extra@^9.0.1:
|
fs-extra@^9.0.1:
|
||||||
version "9.0.1"
|
version "9.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.1.tgz#910da0062437ba4c39fedd863f1675ccfefcb9fc"
|
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.1.tgz#910da0062437ba4c39fedd863f1675ccfefcb9fc"
|
||||||
@@ -22,6 +35,11 @@ graceful-fs@^4.1.6, graceful-fs@^4.2.0:
|
|||||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
|
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb"
|
||||||
integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
|
integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==
|
||||||
|
|
||||||
|
indent-string@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-4.0.0.tgz#624f8f4497d619b2d9768531d58f4122854d7251"
|
||||||
|
integrity sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==
|
||||||
|
|
||||||
jsonfile@^6.0.1:
|
jsonfile@^6.0.1:
|
||||||
version "6.0.1"
|
version "6.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.0.1.tgz#98966cba214378c8c84b82e085907b40bf614179"
|
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.0.1.tgz#98966cba214378c8c84b82e085907b40bf614179"
|
||||||
@@ -31,6 +49,13 @@ jsonfile@^6.0.1:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
graceful-fs "^4.1.6"
|
graceful-fs "^4.1.6"
|
||||||
|
|
||||||
|
p-map@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/p-map/-/p-map-4.0.0.tgz#bb2f95a5eda2ec168ec9274e06a747c3e2904d2b"
|
||||||
|
integrity sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==
|
||||||
|
dependencies:
|
||||||
|
aggregate-error "^3.0.0"
|
||||||
|
|
||||||
universalify@^1.0.0:
|
universalify@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d"
|
resolved "https://registry.yarnpkg.com/universalify/-/universalify-1.0.0.tgz#b61a1da173e8435b2fe3c67d29b9adf8594bd16d"
|
||||||
|
|||||||
Reference in New Issue
Block a user