Skip to content

fix(scripts): disable downleveling for private workspaces #3304

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scripts/downlevel-dts/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import yargs from "yargs";

import { downlevelWorkspace } from "./downlevelWorkspace.mjs";
import { getWorkspaces } from "./getWorkspaces.mjs";
import { isPrivateWorkspace } from "./isPrivateWorkspace.mjs";

// ToDo: Write downlevel-dts as a yargs command, and import yargs in scripts instead.
yargs
Expand All @@ -16,7 +17,9 @@ yargs
.help()
.alias("h", "help").argv;

const workspaces = getWorkspaces(process.cwd());
const workspaces = getWorkspaces(process.cwd()).filter(
({ workspacesDir, workspaceName }) => !isPrivateWorkspace(workspacesDir, workspaceName)
);
const tasks = workspaces.map(({ workspacesDir, workspaceName }) => async () => {
await downlevelWorkspace(workspacesDir, workspaceName);
});
Expand Down
8 changes: 8 additions & 0 deletions scripts/downlevel-dts/isPrivateWorkspace.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { readFileSync } from "fs";
import { join } from "path";

export const isPrivateWorkspace = (workspacesDir, workspaceName) => {
const packageJsonPath = join(workspacesDir, workspaceName, "package.json");
const packageJson = JSON.parse(readFileSync(packageJsonPath).toString());
return packageJson.private && packageJson.private === true;
};