Closed timo-reymann closed 2 years ago
Hey folks,
While we could add the writing-to-file bit to the SDK, this would be a Node-exclusive feature, preventing us from using the SDK in the browser. The SDK is responsible for generating the config as a library but I think it may need to be on the user to decide what to do with that data, of course most users will in fact be writing to a file.
Heya @KyleTryon,
understand that making it only work for Node might be only half of a solution.
Might it be a thing to also add some logic like "if running in browser, use FileSystem API"? Just thinking this could also be a nice feature for e.g. the visual config editor.
Imho it would be a really valuable feature. But if you don't see any value in also adding it for the browser world, lets close this request :)
Cheers, Timo
A solution has been prepared. Thanks for the tip @timo-reymann ! https://github.com/CircleCI-Public/circleci-config-sdk-ts/pull/157
Awesome, thank you @KyleTryon! 🚀
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
To use the SDK together with the continuation orb, you need a configuration file written to disk. This also stated in the README and getting started guide.
Saving the file to disk is something that I think a lot (if not most) of the users would find useful.
Describe the solution you'd like
Provide a way to save to disk with a method directly on the CircleCI configuration object.
The ideal solution would look like this:
Under the hood, it just uses the
fs
module from Node.js to write the file to disk and wrapping the logic into a promise, making it easy to use.Teachability, documentation, adoption, migration strategy
When the functionality is implemented, adjusting the getting started guide and the example should be sufficient.
What is the motivation / use case for changing the behavior?
Currently, it is required to copy & paste the logic block to all projects where dynamic pipelines are used, or otherwise an internal library is required.
To reduce this effort, it would be convenient to include this in the regular SDK.
Additional information
If the feature is something you folks from CircleCI see as useful and worth to include into the SDK, I would also happily create a PR :)