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

Knarwani/fix workspace resolution issue #2550

Conversation

krishna8770
Copy link

Description

  • What issue are you trying to solve?
    Please check this issue for details

  • How does this change address the issue?
    This change will make sure that if align-deps is being run by a Monorepo then it will consider the workspaces else it will directly check inside node_modules.

  • If applicable, can you attach screenshots of before and after your
    change?

Test plan

The feature added is not big, so no extra test has been added but all the available test suites are passed.

}

export async function cli({ packages, ...args }: Args): Promise<void> {
const command = await makeCommand(args);
const allPackages = getPackageInfos(process.cwd());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for working on this. I think it's a good start, but I have several issues with this:

  1. We're scanning the whole monorepo and reading all packages before the command has been created. This work may be thrown away if we exit early here.
  2. By introducing this call, we're now doing two scans instead of one. See getManifests().
  3. getPackageInfos eagerly reads all packages to return PackageInfos. We may not even need them. This should be done lazily.
  4. We don't want to introduce new dependencies, i.e. we cannot add parse-package-name and workspace-tools. If we're missing anything, we should consider adding them to tools-node or tools-workspaces instead.

Keep in mind that we have users running align-deps as a Git hook. This command cannot be reading the whole monorepo before the checks even start. We need to postpone work as much as possible until we actually need them.

We should be passing the list of manifests to the command itself and then to loadPreset. loadPreset will try finding the package from the monorepo if it's there. This result should be cached so that we only perform this once. If we are passing a "context" object with all the information, we can easily add caching to it. This will require us to modify the signature of commands, but we should be able to make it backwards compatible:

 export function checkPackageManifest(
-  manifestPath: string,
+  context: string | {
+    manifestPath: string;
+    manifests: string[];
+    "$cache": Record<string, string>
+  },
   options: Options,
   inputConfig = loadConfig(manifestPath, options),
   logError = error
 ): ErrorCode {

@microsoft-github-policy-service
Copy link
Contributor

This pull request has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 14 days. It will be closed if no further activity occurs within 14 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants