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

Expose formatters from either a separate package or the CLI package #2467

Closed
sennyeya opened this issue May 11, 2023 · 8 comments · Fixed by #2468
Closed

Expose formatters from either a separate package or the CLI package #2467

sennyeya opened this issue May 11, 2023 · 8 comments · Fixed by #2468
Labels
enhancement New feature or request released

Comments

@sennyeya
Copy link
Contributor

User story.
As a developer who wants to use Spectral in JS/TS, I can do create custom formatting, so that I can format my text output from an internal command without subshelling out to spectral-cli.

Is your feature request related to a problem?
I'm looking to use the existing formatters in sepctral-cli in Javascript but cannot as they are not exported from the cli package.

Describe the solution you'd like
Expose the formatters from their own package @stoplight/spectral-formatters. Alternatively, they could be exposed from the CLI, but would prefer their own package.

Additional context
I'm happy to submit a PR, this should be pretty straightforward.

@P0lip
Copy link
Contributor

P0lip commented May 15, 2023

Hey!
That sounds good to me. I've been thinking about doing that too.
However, there's one potential caveat to watch out for - that package should be isomorphic and work in any modern ES environment. Currently some of the formatters may rely on modules or globals specific to Node.js and that'd have to be addressed beforehand.

Happy to assist if needed. If you're up for that, you could indeed move the formatters into a separate package or maybe make it a part of packages/core. I could take care of the Node.js bit of the issue.

@stoplight-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 6.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@sennyeya
Copy link
Contributor Author

sennyeya commented Jun 6, 2023

@P0lip Sorry for the late follow up on this, I'm trying to use this now and unable to import it in my yarn project. Any advice? Getting a module not found error on a simple import like import { pretty } from '@stoplight/spectral-formatters'; . Tried tweaking with the exports of @stoplight/spectral-formatterss package.json locally, but no luck. My project is using the default classic TypeScript moduleResolution, which doesn't have support for exports.

@P0lip
Copy link
Contributor

P0lip commented Jun 7, 2023

Hey @sennyeya!
I'll take a look at it today.
Could you share your tsconfig.json?

@sennyeya
Copy link
Contributor Author

sennyeya commented Jun 7, 2023 via email

@P0lip
Copy link
Contributor

P0lip commented Jun 9, 2023

@sennyeya old TS moduleResolution will be supported once #2482 is merged

@sennyeya
Copy link
Contributor Author

sennyeya commented Jun 9, 2023

@P0lip Great, thanks for the quick turnaround!

@stoplightio stoplightio deleted a comment from stoplight-bot Jul 6, 2023
@stoplight-bot
Copy link
Collaborator

🎉 This issue has been resolved in version 1.18.1 🎉

The release is available on npm package (@latest dist-tag)

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants