fern-api / fern

Input OpenAPI. Output SDKs and Docs.
https://buildwithfern.com
Apache License 2.0
2.6k stars 139 forks source link

[Feature] Fern CLI shouldn't require login #2003

Open dsinghvi opened 1 year ago

dsinghvi commented 1 year ago

Fern requires login to generate code, which prevents usage in large open source repos where there may be several contributors or in organizations that don't want to share information/rely on our servers.

Why did we require login?

  1. Identify verification: If you want to publish your SDK to a registry (e.g. npm.buildwithfern.com), mirror code to Github or generate a docs website then Fern needs to make sure that you are indeed the person that is allowed to publish to that location.
  2. Support: If a user runs into an error, we are easily able to reach out and help them troubleshoot.

Proposal: Don't require login when generating code locally

Fern supports an entirely local mode to generate code where we spin up the generator as a docker and output files to disk. There's no reason to require login for this mode.

If you do fern add <generator> --mode docker or add the mode: docker field to your generator, then fern will run locally and not require login.

groups: 
  server: 
    - name: fernapi/fern-fastapi-server
       version: 0.3.8
       mode: docker # <-------------
       output: 
         location: local-file-system
         path: ../a/bc

Note that if the mode is docker but the output is npm or pypi, then the CLI will throw an error.

With this command we will also deprecate fern generate --local

SebastianStehle commented 1 year ago

I don't get the first point. How do you verify that the NPM token is from me.

dsinghvi commented 1 year ago

I don't get the first point. How do you verify that the NPM token is from me.

There are folks that will publish private packages to npm.buildwithfern.com. We need to verify that not anyone can publish over their packages. (For npmjs you are right)

Similarly, there are folks that use fern's github app to publish to a specific Github repo and we need to make sure that not anyone can publish to that github repo.

The same goes with docs -- if a user publishes to mycompany.docs.buildwithfern.com we need to make sure noone else can come and publish.

SebastianStehle commented 1 year ago

Sure, but were is the difference between a npm token and a fern token? If it is needed for an action you have to add the token, otherwise not. There might be even 2 tokens for your 2 services.

kiikoh commented 1 year ago

Why is docker needed?

aevitas commented 1 year ago

Why is docker needed?

Because the generators are written in the language they produce, and requiring a fully fledged development environments for each language is less ideal than simply running the generator in a container.

dsinghvi commented 1 year ago

+1. At some point we will support mode: native where you can just run the generators as a CLI so the python generator may require python 3.7 being present, the typescript one may require node v18, etc.

That is not going to be something we support in the next 3 months so docker will be the only way to run the generators locally.

cgddrd-gardin commented 1 year ago

As I understand, the current enforcement of fern login makes it impossible to integrate fern as part of a CICD pipeline (e.g. Github Actions)?

If so, this is a massive problem for us.

aevitas commented 1 year ago

As I understand, the current enforcement of fern login makes it impossible to integrate fern as part of a CICD pipeline (e.g. Github Actions)?

If so, this is a massive problem for us.

You can also use a Fern token instead of logging in, allowing you to use it in your pipelines. @dsinghvi can help you get one.

cgddrd-gardin commented 1 year ago

As I understand, the current enforcement of fern login makes it impossible to integrate fern as part of a CICD pipeline (e.g. Github Actions)? If so, this is a massive problem for us.

You can also use a Fern token instead of logging in, allowing you to use it in your pipelines. @dsinghvi can help you get one.

That would be super useful!

dsinghvi commented 1 year ago

As I understand, the current enforcement of fern login makes it impossible to integrate fern as part of a CICD pipeline (e.g. Github Actions)? If so, this is a massive problem for us.

You can also use a Fern token instead of logging in, allowing you to use it in your pipelines. @dsinghvi can help you get one.

That would be super useful!

@cgddrd-gardin if you join our discord i can send you a fern token! or you can email me at deep@buildwithfern.com!

Danwakeem commented 7 months ago

I had the same question and apparently you can generate a fern token via the CLI. Here are the docs for this 😎

sidpan1 commented 6 months ago

What if I just need to use the open source version for generating clients. Why do I need to login to do that?

Login should be optional for folks who want to use your cloud product.