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

move require to update #20

Merged
merged 1 commit into from
Jan 18, 2024
Merged
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
14 changes: 8 additions & 6 deletions scripts/release_workspace.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,30 @@ function getWorkspaceVersion(workspaceDirectory) {
* Each object in the return value contains the relative path to the workspace
* directory, along with the full package.json file contents.
*
* @returns {Array<{ dir: string, packageJSON: Record<string, any>}>}
* @returns {Promise<Array<{ dir: string, packageJSON: Record<string, any>}>>}
*/
function getAllWorkspaces() {
async function getAllWorkspaces() {
const possibleWorkspaceDirectories = ["./langgraph"];
const allWorkspaces = possibleWorkspaceDirectories.flatMap((workspaceDirectory) => {
const allWorkspacesPromise = possibleWorkspaceDirectories.flatMap(async (workspaceDirectory) => {
if (workspaceDirectory.endsWith("*")) {
// List all folders inside directory, require, and return the package.json.
const allDirs = fs.readdirSync(path.join(process.cwd(), workspaceDirectory.replace("*", "")));
const packageJSON = await import(path.join(process.cwd(), `${workspaceDirectory.replace("*", "")}${dir}`, "package.json"))
const subDirs = allDirs.map((dir) => {
return {
dir: `${workspaceDirectory.replace("*", "")}${dir}`,
packageJSON: require(path.join(process.cwd(), `${workspaceDirectory.replace("*", "")}${dir}`, "package.json"))
packageJSON: packageJSON
}
});
return subDirs;
}
const packageJSON = require(path.join(process.cwd(), workspaceDirectory, "package.json"));
const packageJSON = await import(path.join(process.cwd(), workspaceDirectory, "package.json"))
return {
dir: workspaceDirectory,
packageJSON,
};
});
const allWorkspaces = await Promise.all(allWorkspacesPromise);
return allWorkspaces;
}

Expand Down Expand Up @@ -265,7 +267,7 @@ async function main() {
}

// Find the workspace package.json's.
const allWorkspaces = getAllWorkspaces();
const allWorkspaces = await getAllWorkspaces();
const matchingWorkspace = allWorkspaces.find(({ packageJSON }) => packageJSON.name === options.workspace);

if (!matchingWorkspace) {
Expand Down
Loading