Skip to content

Commit

Permalink
Merge pull request #1866 from intuit/private-lerna-packages
Browse files Browse the repository at this point in the history
don't include private packages in canary install list
  • Loading branch information
hipstersmoothie committed Mar 12, 2021
2 parents 8a5b878 + 3b29236 commit fe12724
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
22 changes: 22 additions & 0 deletions 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",
},
]);
});
20 changes: 13 additions & 7 deletions packages/core/src/utils/get-lerna-packages.ts
Expand Up @@ -10,11 +10,17 @@ export interface LernaPackage {
}

/** Get all of the packages in the lerna monorepo */
export default async function getLernaPackages(): Promise<LernaPackage[]> {
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;
}
6 changes: 4 additions & 2 deletions plugins/npm/src/index.ts
Expand Up @@ -1053,7 +1053,7 @@ export default class NPMPlugin implements IPlugin {
"--exact",
"--ignore-scripts",
"--preid",
canaryIdentifier.replace(/^-/, ''),
canaryIdentifier.replace(/^-/, ""),
...verboseArgs,
]);

Expand All @@ -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,
]);

Expand Down

0 comments on commit fe12724

Please sign in to comment.