Fix npm publishing script
Summary: Npm publishing script should not attempt to publish plugin packages Reviewed By: mweststrate Differential Revision: D21721175 fbshipit-source-id: 0bf9808339c1177bc9d263ac34d40aa30df08d11
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6005d039f7
commit
8473bc9ecf
@@ -20,6 +20,7 @@ const glob = promisify(globImport);
|
|||||||
export interface Package {
|
export interface Package {
|
||||||
dir: string;
|
dir: string;
|
||||||
json: any;
|
json: any;
|
||||||
|
isPlugin: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Workspaces {
|
export interface Workspaces {
|
||||||
@@ -27,10 +28,6 @@ export interface Workspaces {
|
|||||||
packages: Package[];
|
packages: Package[];
|
||||||
}
|
}
|
||||||
|
|
||||||
function isPlugin(dir: string) {
|
|
||||||
return dir.startsWith(pluginsDir);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getWorkspaces(): Promise<Workspaces> {
|
export async function getWorkspaces(): Promise<Workspaces> {
|
||||||
const rootPackageJson = await fs.readJson(path.join(rootDir, 'package.json'));
|
const rootPackageJson = await fs.readJson(path.join(rootDir, 'package.json'));
|
||||||
const packageGlobs = rootPackageJson.workspaces.packages as string[];
|
const packageGlobs = rootPackageJson.workspaces.packages as string[];
|
||||||
@@ -48,6 +45,7 @@ export async function getWorkspaces(): Promise<Workspaces> {
|
|||||||
return {
|
return {
|
||||||
dir,
|
dir,
|
||||||
json,
|
json,
|
||||||
|
isPlugin: dir.startsWith(pluginsDir),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -55,6 +53,7 @@ export async function getWorkspaces(): Promise<Workspaces> {
|
|||||||
rootPackage: {
|
rootPackage: {
|
||||||
dir: rootDir,
|
dir: rootDir,
|
||||||
json: rootPackageJson,
|
json: rootPackageJson,
|
||||||
|
isPlugin: false,
|
||||||
},
|
},
|
||||||
packages,
|
packages,
|
||||||
};
|
};
|
||||||
@@ -109,14 +108,14 @@ async function bumpWorkspaceVersions(
|
|||||||
newVersion = newVersion || (rootPackage.json.version as string);
|
newVersion = newVersion || (rootPackage.json.version as string);
|
||||||
const allPackages = [rootPackage, ...packages];
|
const allPackages = [rootPackage, ...packages];
|
||||||
const localPackageNames = packages
|
const localPackageNames = packages
|
||||||
.filter((pkg) => !isPlugin(pkg.dir))
|
.filter((pkg) => !pkg.isPlugin)
|
||||||
.map(({json}) => json.name as string);
|
.map(({json}) => json.name as string);
|
||||||
for (const pkg of allPackages) {
|
for (const pkg of allPackages) {
|
||||||
const {dir, json} = pkg;
|
const {json} = pkg;
|
||||||
let changed = false;
|
let changed = false;
|
||||||
if (json.version !== newVersion && !isPlugin(dir)) {
|
if (json.version !== newVersion && !pkg.isPlugin) {
|
||||||
console.log(
|
console.log(
|
||||||
`Bumping version of ${pkg.json.name} from ${json.version} to ${newVersion}`,
|
`Bumping version of ${json.name} from ${json.version} to ${newVersion}`,
|
||||||
);
|
);
|
||||||
json.version = newVersion;
|
json.version = newVersion;
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -180,7 +179,9 @@ export async function publishPackages({
|
|||||||
if (proxy) {
|
if (proxy) {
|
||||||
cmd += ` --http-proxy ${proxy} --https-proxy ${proxy}`;
|
cmd += ` --http-proxy ${proxy} --https-proxy ${proxy}`;
|
||||||
}
|
}
|
||||||
const publicPackages = workspaces.packages.filter((pkg) => !pkg.json.private);
|
const publicPackages = workspaces.packages.filter(
|
||||||
|
(pkg) => !pkg.json.private && !pkg.isPlugin,
|
||||||
|
);
|
||||||
for (const pkg of publicPackages) {
|
for (const pkg of publicPackages) {
|
||||||
if (dryRun) {
|
if (dryRun) {
|
||||||
console.log(`DRYRUN: Skipping npm publishing for ${pkg.json.name}`);
|
console.log(`DRYRUN: Skipping npm publishing for ${pkg.json.name}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user