-
Notifications
You must be signed in to change notification settings - Fork 338
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
refactor: move createFromString and resource from Prism Http to CLI #1009
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like a change is happening to http-client which is actually something we’ve advertised as useable in the docs. If documented package API is changing then it’ll need to be a major version.
I don’t have many opinions on heather you should bundle other major changes in here. It does make sense to do various necessary breaks in one go, but keep in mind hosted mocking will also need to change and that’s need more QA time, and they’re already fairly busy. If you consider that sort of stuff and make a decision then I support it either way! 🙌🏻
Co-Authored-By: Phil Sturgeon <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The is a movement in a good direction!
Since we somehow have a green light to break things why not move getHttpOperations(string)
to http-spec
? The spec type detection (which will be more and more complex over time, see https://github.com/stoplightio/prism/blob/feat/postman-collection/packages/http/src/getHttpOperations.ts#L48) is a good candidate for being shared.
The only problem I see with such an approach is that a folk wanting to put some operations programmatically into prism will need to import http-spec
package. But we can do it for him and reexport getHttpOperations
in prism. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I said "green light to break things" haha just, please use cautious and common sense. No leroy jenkins here.
Since we're going to ship this as a breaking change I think I will tweak a little bit the function names (the current one might not exactly make that much sense) as well as maybe rearrange the parameters. I'll look into this later today and put something online. |
Just my two cents here. I think if we are going to need a major bump we should take the time to really define what our public API is. Merely renaming the directory to Let's take a step back, decide what the goal is for each of the packages (in terms of external use), and what are the key APIs we'd like to offer to the public to achieve them. Then put these files into somewhere (lib folder, index.ts export / top level files / whatever we decide on), keep the rest where it is, and clearly document what is part of our API and what is not. |
cbbc1b8
to
805af10
Compare
@marcelltoth I understand where you're coming from and I would love to do that, but I do not think we can now. The public JS API will probably be done (if done) once we'll gather from more feedback from hosted Prism, Mocking Tab usage and all these product using the package. On the other hand, we need to make Prism Http browser-compatible as soon as possible since it's blocking some stuff we're doing — and I took the occasion of the breaking change to do propose some other reorganisation — among these the idea of using |
@XVincentX Then I propose to keep it that way and import from That pushes the "risk" to the consuming packages if they import from However if we publish a major version where everything is public, how are we going to support that? Do we release a new major every 2 days? Do we break semver? In my eyes either of these are worse than just keeping it in |
We'll keep the That said, we still need this change for our platform and so apparently this change is unenviable unless we publish this as a 4 beta and use it internally, which might be ok with me and with platform. |
9c115c8
to
4894178
Compare
98414a7
to
6f488e4
Compare
6eb0688
to
71f6fc1
Compare
71f6fc1
to
08d82f4
Compare
9e8816b
to
168cb80
Compare
8cd51a4
to
90d60b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have two concerns:
- Publicly teaching users that it is OK to import stuff from
/dist
is not great. It'd be OK if we bundled stuff but as we are not, this makes it very difficult to define correct semver versioning. import
ing a package called cli feels weird. Acli
feels like it is intended to be an end-user thing that you run, not something you use in other packages, right?
I understand that this is something you want to work on later separately however, so this one is good to go. It is definitely a great improvement and does what it promises.
@@ -4,7 +4,7 @@ import { Scope as NockScope } from 'nock'; | |||
import * as nock from 'nock'; | |||
import { basename, resolve } from 'path'; | |||
import { createInstance, IHttpProxyConfig, IHttpRequest, IHttpResponse, ProblemJsonError } from '../'; | |||
import { getHttpOperationsFromResource } from '../getHttpOperations'; | |||
import { getHttpOperationsFromResource } from '@stoplight/prism-cli/src/operations'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is /src/
in the bundle? Should it?
In the example (README.md) you are importing it from /dist/
which looks more appropriate.
This applies to ~10 other places as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
I'll address all the comments here:
That is very correct, and it was a mistake, I admit it. We aren't going to release this breaking change soon; most likely we'll be still on 3.x for a while. The idea is to accumulate all the breaking changes (included your very good ideas on defining a public API) and then release. So at the moment, no harms has been done
It is a bit weird, but I really do not see any good reason to create a
Eheheh ok this is complicated — essentially is a trick to use TypeScript in VSCode without having to compile the code first. I agree that's not great, but
|
In stoplightio#1009 the getHttpOperationsFromSpec moved to the prism-cli package. The documentation needs to be updated accordingly
…#1820) * Update Http-server doc with new location of getHttpOperationsFromSpec In #1009 the getHttpOperationsFromSpec moved to the prism-cli package. The documentation needs to be updated accordingly * Update packages/http-server/README.md Co-authored-by: Thomas Pytleski <[email protected]>
This PR is a proposal of moving the methods
createClientFromResource
andcreateClientFromSpec
from theprism-http
package toprism-cli
packageThe main rationale behind this is that the dependencies of such feature (json-ref-resolver, json-ref-readers) have an hard dependency on the
fs
package that makes prism-http a little bit harder to embed in the browser (you need to configure web pack to mock thefs
module to empty)This is technically a breaking change since we're removing a function although we have never "marketed" our client API — I'm summoning @philsturgeon to get his opinion.
If we're going to take this as a breaking change (Prism 4), then I'd take the occasion to also
dist
tolib
— it makes more sense and does not make you feel bad when importing stuff // cc @marcelltoth — we had such discussion some time agoCloses #1008
Closes stoplightio/elements/issues/261