E

Challenges with SAVE ARTIFACT AS LOCAL feature

Summary

The user is facing challenges with the "SAVE ARTIFACT AS LOCAL" feature in their code generation process, as it only allows saving one file at a time when there is directory nesting. This leads to a brittle setup that could break with future changes in the generators. They also have to manually add files to .earthlyignore due to the lack of negative matching support. The user expresses a desire for a simpler solution, such as a command that could merge files more efficiently, and shares their current code setup, which involves multiple individual save commands that are tedious to manage. They are seeking better solutions to streamline this process.

Status
open
Tags
  • SAVE ARTIFACT AS LOCAL
  • Earthly
  • Feature Request
  • Code Management
  • User Feedback
Source
#earthly
    b

    brandon356

    8/14/2024

    Question: The docs recommend SAVE ARTIFACT AS LOCAL for generated code. The problem is, I can only do this one file at a time if there is any nesting as earthly replaces directories. I need generated code locally so I don't have 3K IDE errors. The problem is this is brittle and could break if the generators create more files than enumerated here after some refactoring. I also have to add these files individually to .earthlyignore because it doesn't support negative matching. For instance the second line here is ignored by earthly:

    !pkg/grpc/protoc/v2/options.pb.go```
    Here is one of my targets. I wish it could be much simpler, like `SAVE ARTIFACT internal as LOCAL --merge internal`
    ```static:
        DO +GO_PREPARE_A
        RUN go install <http://github.com/rakyll/statik@v0.1.7|github.com/rakyll/statik@v0.1.7>
        COPY +sass/dart-sass /usr/local/bin
        COPY --keep-ts internal/api/ui/login/static internal/api/ui/login/static
        COPY --keep-ts internal/api/ui/login/statik internal/api/ui/login/statik
        COPY --keep-ts internal/notification/static internal/notification/static
        COPY --keep-ts internal/notification/statik internal/notification/statik
        COPY --keep-ts internal/static internal/static
        COPY --keep-ts internal/statik internal/statik
        # Generate files
        RUN touch /tmp/timestamp &amp;&amp; go generate internal/api/ui/login/static/resources/generate.go &amp;&amp; \
    	    go generate internal/api/ui/login/statik/generate.go &amp;&amp; \
    	    go generate internal/notification/statik/generate.go &amp;&amp; \
    	    go generate internal/statik/generate.go
        # Save the files back for local development. I wish this could be much cleaner
        SAVE ARTIFACT ./internal/api/ui/login/static/resources/themes/accounts/css/accounts.css.map AS LOCAL ./internal/api/ui/login/static/resources/themes/accounts/css/accounts.css.map
        SAVE ARTIFACT ./internal/api/ui/login/static/resources/themes/accounts/css/accounts.css AS LOCAL ./internal/api/ui/login/static/resources/themes/accounts/css/accounts.css
        SAVE ARTIFACT ./internal/api/ui/login/statik/statik.go AS LOCAL ./internal/api/ui/login/statik/statik.go
        SAVE ARTIFACT ./internal/notification/statik/statik.go AS LOCAL ./internal/notification/statik/statik.go
        SAVE ARTIFACT ./internal/statik/statik.go AS LOCAL ./internal/statik/statik.go
        # Now save the parent folder for other targets because this is getting tedious
        SAVE ARTIFACT internal```
    Has anyone found a better solution