Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't include private packages in canary install list #1866

Merged
merged 1 commit into from Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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