Update tutorial to reflect changes in plugin packaging format

Summary: Tutorial updated to reflect changes in plugin packaging format

Reviewed By: passy

Differential Revision: D21161268

fbshipit-source-id: b7c6d272be8dd56b76a0af87acdc347df4216f6c
This commit is contained in:
Anton Nikolaev
2020-04-23 05:55:19 -07:00
committed by Facebook GitHub Bot
parent e165c2cd95
commit fe09dae237
5 changed files with 68 additions and 24 deletions

View File

@@ -27,6 +27,10 @@ export interface Workspaces {
packages: Package[];
}
function isPlugin(dir: string) {
return dir.startsWith(pluginsDir);
}
export async function getWorkspaces(): Promise<Workspaces> {
const rootPackageJson = await fs.readJson(path.join(rootDir, 'package.json'));
const packageGlobs = rootPackageJson.workspaces.packages as string[];
@@ -37,9 +41,7 @@ export async function getWorkspaces(): Promise<Workspaces> {
glob(path.join(rootDir, pattern, '')),
)),
),
async (dir) =>
!dir.startsWith(pluginsDir) &&
(await fs.pathExists(path.join(dir, 'package.json'))),
async (dir) => await fs.pathExists(path.join(dir, 'package.json')),
),
async (dir) => {
const json = await fs.readJson(path.join(dir, 'package.json'));
@@ -95,11 +97,13 @@ async function bumpWorkspaceVersions(
): Promise<string> {
newVersion = newVersion || (rootPackage.json.version as string);
const allPackages = [rootPackage, ...packages];
const localPackageNames = packages.map(({json}) => json.name as string);
const localPackageNames = packages
.filter((pkg) => !isPlugin(pkg.dir))
.map(({json}) => json.name as string);
for (const pkg of allPackages) {
const json = pkg.json;
const {dir, json} = pkg;
let changed = false;
if (json.version !== newVersion) {
if (json.version !== newVersion && !isPlugin(dir)) {
json.version = newVersion;
changed = true;
}