fern-api / fern

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

[Bug] fernapi/fern-typescript-browser-sdk does not generate project files #3257

Open mstade opened 6 months ago

mstade commented 6 months ago

Describe the Bug

Output from running the TypeScript generator with output local-file-system does not include package.json and other project files. While this can be useful in so far as allowing greater project customization than the npm output target, it makes it much harder to keep up with things like managing the dependencies the SDK requires.

Information to Reproduce

CLI Version

0.19.18

Generator Version

fernapi/fern-typescript-browser-sdk@0.12.7

Full generators.yml:

default-group: local
groups:
  local:
    generators:
      - name: fernapi/fern-typescript-browser-sdk
        version: 0.12.7
        output:
          location: local-file-system
          path: ../generated/sdk-typescript

API Definition

The minimal OpenAPI specification or Fern definition required to reproduce the bug.

types:
  Pet:
    name: string
    age: double

Actual SDK

Only source files are included.

Expected SDK

Expected project files like package.json as well as the generated source code.

Additional Context

If this behaviour is intentional, it should probably be documented here: https://docs.buildwithfern.com/generate-sd-ks/generators/type-script-node-js-sdk#local

dsinghvi commented 6 months ago

Hey @mstade, we're going to deprecate fernapi/fern-typescript-browser-sdk, our typescript sdk generator is universal so you should be able to use the node one just fine.

Try fernapi/fern-typescript-node-sdk

mstade commented 6 months ago

Thanks @dsinghvi – that was another question I had actually!

I changed to fernapi/fern-typescript-node-sdk but alas, it's still only outputting the source code.

To be honest only having the code is probably fine for our needs because we need to package our project slightly differently from how Fern does it anyway, but not having access to that metadata does make it more error prone of course.

If getting the generated files isn't possible, is it possible to otherwise export the project data Fern uses to generate these files?

mstade commented 4 months ago

Any updates on this? I can see the files being generated in the Docker container, and I've been retriveing details from them that way, but it'd be nice to not have to do this dance. Or if maybe the dependencies of the generated library can be documented somehwere.

mstade commented 3 months ago

Any updates on this?

mstade commented 1 month ago

Any updates? 🦗

mstade commented 2 weeks ago

@dsinghvi @dannysheridan I think this is where the issue lies: https://github.com/fern-api/fern/blob/27fb37831c91a466bb75e952b8c3a886f2efeb64/generators/typescript/utils/abstract-generator-cli/src/AbstractGeneratorCli.ts#L117-L129

As far as I can tell, the outputSourceFiles option will literally do just that, output everything in src. The only other option seems to be outputting what's in dist – again, no project files like package.json etc. There is a copyProjectAsZipTo function, which seems to package the whole project as output as opposed to just the src or dist directories, however this does not seem to be an option at all with local generation.

Can you confirm whether generating files locally will ever support also including package.json? Without this the local generation option of the TS generator is basically a blind goose chase trying to figure out which dependencies the SDK requires, as this is not listed anywhere. Presumably this changes with the generator versions as well, which makes it a moving target, so even if you get it right for one version it won't necessarily apply for another?