ory / sdk

The place where ORY's SDKs are being auto-generated
Apache License 2.0
139 stars 86 forks source link

[Dart] Publish generated files #232

Closed jonas-jonas closed 1 year ago

jonas-jonas commented 1 year ago

Preflight checklist

Describe the bug

The generated files of the dart client (*.g.dart) are currently not published to pub, because we don't seem to generate them as part of the pipeline.

The recommendation is to publish these files, but not to commit them to the repository: https://pub.dev/packages/built_value_generator#should-i-check-in-andor-publish-in-the-generated-gdart-files

I think our pipeline can only do both, atm. We might need to adjust that so that we can generate the files in the publishing pipeline, without committing them to the repository.

Reproducing the bug

-

Relevant log output

No response

Relevant configuration

No response

Version

v1.0.0

On which operating system are you observing this issue?

No response

In which environment are you deploying?

No response

Additional Context

See also https://pub.dev/packages/ory_client/score and specifically section "Pass static analysis"

image
mkbehbehani commented 1 year ago

👍 for this issue, ran into this and had a rough experience attempting to use the official dart package. No worries though, I did see the experimental warning. @jonas-jonas please feel free to reuse this for the fix, may just be a few copy-pastes into the publishing pipeline. Temporary workaround I used:

If successful you will see:

[INFO] Generating build script...
[INFO] Generating build script completed, took 371ms

[INFO] Precompiling build script......
[INFO] Precompiling build script... completed, took 6.0s

[INFO] Initializing inputs
[INFO] Building new asset graph...
[INFO] Building new asset graph completed, took 685ms

[INFO] Checking for unexpected pre-existing outputs....
[INFO] Checking for unexpected pre-existing outputs. completed, took 1ms

[INFO] Running build...
[INFO] Generating SDK summary...
[INFO] 2.1s elapsed, 0/16 actions completed.
[INFO] 3.7s elapsed, 0/16 actions completed.
[INFO] Generating SDK summary completed, took 4.4s

[INFO] 7.1s elapsed, 0/16 actions completed.
[INFO] 8.1s elapsed, 64/80 actions completed.
[INFO] 9.1s elapsed, 96/112 actions completed.
[INFO] 10.5s elapsed, 108/124 actions completed.
[INFO] 11.6s elapsed, 173/187 actions completed.
[INFO] 12.7s elapsed, 314/330 actions completed.
[INFO] Running build completed, took 13.2s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 69ms

[INFO] Succeeded after 13.2s with 194 outputs (519 actions)

and the .g.dart files like these will be created:

    lib/src/model/authenticator_assurance_level.g.dart
    lib/src/model/courier_message_status.g.dart
    lib/src/model/courier_message_type.g.dart
    lib/src/model/create_identity_body.g.dart
...
    lib/src/model/verifiable_identity_address.g.dart
    lib/src/model/verification_flow.g.dart
    lib/src/model/verification_flow_state.g.dart
    lib/src/model/version.g.dart
    lib/src/serializers.g.dart

@jonas-jonas please let the other Ory developers know this idea to auto-generate code from the API docs is good and Ory should keep doing it. Even if it's not perfectly working, being able to look at the generated output code is a massive time-saver.

jonas-jonas commented 1 year ago

Hi @mkbehbehani, thanks for your insight. I figured that the Dart SDK needs generated files as well, but I wasn't sure if it's best to also release those to the pub. Did I understand correctly, that you'd expect the generated files (*.g.dart) files to be present in the package published to pub? If so, we'll do the change relatively soon (after a few other QOL changes to our pipeline) and this should be solved. In the meantime, people can use your workaround, so thank you very much for that! :)

please let the other Ory developers know this idea to auto-generate code from the API docs is good and Ory should keep doing it. Even if it's not perfectly working, being able to look at the generated output code is a massive time-saver.

That is amazing to hear! I'll definitely forward that. :)

timaebi commented 1 year ago

As written in the built_value FAQ the *.g.dart files should be present in the published package.

Should I check in and/or publish in the generated .g.dart files?

See the build_runner docs. You usually should not check in generated files, but you do need to publish them.

MichaelMarner commented 1 year ago

Hey @jonas-jonas any progress on this? We are migrating our Flutter app to Kratos and would like to use the official SDK.

The generated g.dart files need to be generated and published to pub.dev for the package to work. It should just be a matter of editing publish.sh to run:

flutter pub get
flutter pub run build_runner build

before running pub publish.

I'm happy to make a PR to resolve this issue, but you mentioned waiting on some QOL changes to the pipeline, so I don't want to step on anybody's toes.

Cheers!

Sese-Schneider commented 1 year ago

+1 on this. Without the generated files the published package is useless. Had to create a fork and commit the generated files.

Workaround for now:

ory_client:
  git:
    url: "https://github.com/simpleclub-extended/ory-sdk"
    ref: "dart-code-generated"
    path: "clients/client/dart"
jonas-jonas commented 1 year ago

The files will be included with the next release of the @ory/client SDK, which will probably be in the coming days.

IchordeDionysos commented 1 year ago

@jonas-jonas I think it would be helpful if Ory would create it's own publisher with the domain ory.sh, which adds credibility to the packages you upload to pub.dev: https://pub.dev/create-publisher This allows you to better manage the packages and makes it possible to invite others to manage the packages as well.

It will also make it easier to discover other packages that you upload and show that it's officially uploaded by Ory next to the package name. Example: https://pub.dev/packages/math_keyboard image https://pub.dev/publishers/simpleclub.com/packages

cairin commented 1 year ago

@IchordeDionysos https://pub.dev/publishers/ory.sh/packages

jonas-jonas commented 1 year ago

Yes, we already have that, but for some reason the ory/client package is not published under that. I'll take a look. Thanks for the suggestion @IchordeDionysos and @cairin :)

IchordeDionysos commented 1 year ago

@jonas-jonas you can transfer the ownership: image

jonas-jonas commented 1 year ago

@IchordeDionysos thanks for the hints. We transferred the package. One step closer to those 100 pub points ;)