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

Use correct pkg runner to run pkgs #1181

Closed
wants to merge 16 commits into from
Closed

Use correct pkg runner to run pkgs #1181

wants to merge 16 commits into from

Conversation

diksipav
Copy link
Contributor

No description provided.

@diksipav diksipav requested a review from scotttrinh January 21, 2025 15:12
Comment on lines +157 to +162
export class ProjectManager {
public packageManager: PackageManager;

constructor() {
this.packageManager = getPackageManager();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

There are two ways we can go here, and I'm fine with either, with a slight preference for the first:

Return a ProjectManager instance in _base/index.ts

So, roughly:

const packageManager = new PackageManager();

Only instantiate this class when needed

Remove all of the packageManager stuff from BaseOptions and the base recipe, and update any recipes that use the packageManager option to instantiate it themselves.


Either way we will want to stop exporting the type PackageManager (let's rename it or inline it so it doesn't conflict with the class PackageManager) and the function getPackageManager. We probably want to add a toString method to the class to maybe return the package manager string, too. Just to make it cleaner when logging.

  public toString(): string {
    return this.packageManager;
  }

this.packageManager = getPackageManager();
}

private getPackageRunner(): string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Small nit: since this value isn't actually dynamic, we can move this to the constructor:

const PM_TO_RUNNER_MAP = {
  "yarn": "yarn dlx",
  // etc.
} as const;

// in constructor: 
this.runner = PM_TO_RUNNER_MAP[this.packageManager];

Or something like that. Then just ${this.runner} in your string builder.

@diksipav
Copy link
Contributor Author

Too many conflicts after renaming packages/driver to packages/gel. It is easier to create a new PR.

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

Successfully merging this pull request may close these issues.

2 participants