diff --git a/packages/core/src/utils/__tests__/get-lerna-packages.test.ts b/packages/core/src/utils/__tests__/get-lerna-packages.test.ts new file mode 100644 index 000000000..9f22291dd --- /dev/null +++ b/packages/core/src/utils/__tests__/get-lerna-packages.test.ts @@ -0,0 +1,22 @@ +import endent from "endent"; +import execPromise from "../exec-promise"; +import getLernaPackages from "../get-lerna-packages"; + +const exec = jest.fn(); +jest.mock("../exec-promise"); +// @ts-ignore +execPromise.mockImplementation(exec); + +test("it shouldn't included private packages", async () => { + exec.mockReturnValue(endent` + /dir/a:a:0.3.0--canary.32.d54a0c4.0 + /dir/b:b:MISSING:PRIVATE + `); + expect(await getLernaPackages()).toStrictEqual([ + { + name: "a", + path: "/dir/a", + version: "0.3.0--canary.32.d54a0c4.0", + }, + ]); +}); diff --git a/packages/core/src/utils/get-lerna-packages.ts b/packages/core/src/utils/get-lerna-packages.ts index 65ffdf16a..7d654ce6f 100644 --- a/packages/core/src/utils/get-lerna-packages.ts +++ b/packages/core/src/utils/get-lerna-packages.ts @@ -10,11 +10,17 @@ export interface LernaPackage { } /** Get all of the packages in the lerna monorepo */ -export default async function getLernaPackages(): Promise { - return execPromise("npx", ["lerna", "ls", "-pla"]).then((res) => - res.split("\n").map((packageInfo) => { - const [packagePath, name, version] = packageInfo.split(":"); - return { path: packagePath, name, version }; - }) - ); +export default async function getLernaPackages() { + const packages: LernaPackage[] = []; + const response = await execPromise("npx", ["lerna", "ls", "-pla"]); + + response.split("\n").forEach((packageInfo) => { + const [packagePath, name, version] = packageInfo.split(":"); + + if (version !== "MISSING") { + packages.push({ path: packagePath, name, version }); + } + }); + + return packages; } diff --git a/plugins/npm/src/index.ts b/plugins/npm/src/index.ts index d642a7cc3..0c5e38c3e 100644 --- a/plugins/npm/src/index.ts +++ b/plugins/npm/src/index.ts @@ -1053,7 +1053,7 @@ export default class NPMPlugin implements IPlugin { "--exact", "--ignore-scripts", "--preid", - canaryIdentifier.replace(/^-/, ''), + canaryIdentifier.replace(/^-/, ""), ...verboseArgs, ]); @@ -1078,7 +1078,9 @@ export default class NPMPlugin implements IPlugin { "--no-git-reset", // so we can get the version that just published "--no-git-tag-version", // no need to tag and commit, "--exact", // do not add ^ to canary versions, this can result in `npm i` resolving the wrong canary version - ...(isIndependent ? ["--preid", canaryIdentifier.replace(/^-/, '')] : []), + ...(isIndependent + ? ["--preid", canaryIdentifier.replace(/^-/, "")] + : []), ...verboseArgs, ]);