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

feat: add check command #59

Merged
merged 4 commits into from
Oct 4, 2024
Merged

feat: add check command #59

merged 4 commits into from
Oct 4, 2024

Conversation

AdrianGonz97
Copy link
Member

@AdrianGonz97 AdrianGonz97 commented Oct 3, 2024

closes #39

run with:

pnpx https://pkg.pr.new/sveltejs/cli/sv@59 check

Copy link

pkg-pr-new bot commented Oct 3, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/sveltejs/cli/@svelte-cli/ast-tooling@59
pnpm add https://pkg.pr.new/sveltejs/cli/sv@59
pnpm add https://pkg.pr.new/sveltejs/cli/@svelte-cli/core@59

commit: 8459d7e


// avoids printing the stack trace for `sv` when `svelte-check` exits with an error code
try {
execSync(`npx svelte-check ${args.join(' ')}`, { stdio: 'inherit', cwd });
Copy link
Member

Choose a reason for hiding this comment

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

should we try to use the user's package manager here? while generally unlikely, there's a chance they haven't installed npm and don't have npx. maybe it could happen on a CI where they don't want to install multiple package managers or something

Copy link
Member Author

Choose a reason for hiding this comment

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

yea, i tried doing that butpackage-manager-detector's COMMANDS map doesn't include the commands for executing local packages (e.g. pnpm -> pnpm exec)

Copy link
Member

Choose a reason for hiding this comment

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

it's already installed when you get here at which point npm, pnpm, etc. should work just the same as npx?

Copy link
Member Author

Choose a reason for hiding this comment

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

it works with npx because it's used for both executing local and remote pacakges. however, if we were to use the COMMANDS['execute'] with pnpm, it'll resolve to pnpm dlx svelte-check, which will execute the remote package instead of the local one

Copy link
Member Author

Choose a reason for hiding this comment

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

and i dont know if the case is similar with the other PMs as well (bun, yarn, etc)

Copy link
Member Author

@AdrianGonz97 AdrianGonz97 Oct 3, 2024

Choose a reason for hiding this comment

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

i guess the problem is that COMMANDS['execute'] should really be renamed to COMMANDS['remote'] or COMMANDS['dlx'] to signify that it's only for executing remote packages. then we could reliably use COMMANDS['execute'] for executing local packages

see: https://github.com/antfu-collective/package-manager-detector/blob/main/src/commands.ts

Copy link
Member Author

@AdrianGonz97 AdrianGonz97 Oct 3, 2024

Choose a reason for hiding this comment

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

raised a PR for this change here: antfu-collective/package-manager-detector#15

Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

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

lgtm. I only had one question

the other thing I was wondering for a minute was if we should add svelte-check as an optional peer dependency, but I'm not really sure if there's a benefit to doing so and it looks like npm keeps going back and forth on whether they should be installed by default. I think omitting as done in this PR might be better because we won't install it and the user can if they need to

Copy link
Member

@manuel3108 manuel3108 left a comment

Choose a reason for hiding this comment

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

Apart from this one thing, everything was mentioned or looks good

@AdrianGonz97
Copy link
Member Author

Don't really want to hold off on merging this PR because of antfu-collective/package-manager-detector#15, so I've raised #61 so that we can address it once it does merge

@AdrianGonz97 AdrianGonz97 merged commit c875925 into main Oct 4, 2024
5 checks passed
@AdrianGonz97 AdrianGonz97 deleted the feat/svelte-check branch October 4, 2024 16:19
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.

Add a check command
3 participants