Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: factor out fs calls into axoasset #229

Closed
wants to merge 3 commits into from

Conversation

shadows-withal
Copy link
Contributor

@shadows-withal shadows-withal commented Apr 27, 2023

Culmination of the work that started with the 0.2.0 release of axoasset, which is to remove straight fs i/o calls from cargo-dist and put them in axoasset instead. Omits the templating things for now until we have a consensus on that.

Closes #221.

Needs testing, I haven't had enough time for that yet.

Copy link
Contributor

@Gankra Gankra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the installer code seems a bit messed up but i'm liking the changes elsewhere

@@ -48,6 +44,7 @@ parse-changelog = { version = "0.5.3", default-features = false }
newline-converter = "0.2.2"
axoproject = { version = "0.3.0", default-features = false, features = ["cargo-projects"] }
dialoguer = "0.10.4"
axoasset = "0.2.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my ideal world we have some pretty fine-grained feature flags on axoasset to toggle the various compression formats on, to avoid all our projects getting bloated with unused dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a good idea!

Comment on lines 24 to 28
// Unwrapping here because the path is basically guaranteed to have a parent at this point
let dest_dir = installer_file.parent().unwrap();
// Potential FIXME: Have an axoasset method that _just_ creates a file, without writing
// anything (think `File::create`)
LocalAsset::write_new("", installer_file.as_str(), dest_dir.as_str())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm interesting, we ultimately buffer up the entire result before writing to the file anyway (to do newline cleanups), and presumably the more transactional you can make "create a file, write its contents to completion" the better, right? So maybe we should just move the file creation to the end?

Might make it harder to test this code later though...?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I forget, what's the significance of making us pass the file path and the dir path?

Or wait, I think this is maybe just incorrect code, and you should be getting installer_file.filename() or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is incorrect, good catch! I'll move the write calls to the end of the function, I think when testing those functions, we might want to structure them somewhat differently anyways, so I don't think that's necessarily a huge blocker.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As for why we pass filename and directory name separately, I have no idea, that's what the signature already looked like when I came upon it. We could probably squash those arguments, though.

cargo-dist/src/installer.rs Outdated Show resolved Hide resolved
@Gankra
Copy link
Contributor

Gankra commented May 11, 2023

I'm taking over responsibility for completing this PR. As far as I'm concerned it's "merged" and rebasing it is my problem.

Likely won't ship for 0.1.0 but that's fine, this is ostensibly a non-functional change.

@Gankra
Copy link
Contributor

Gankra commented Jul 31, 2023

Closing in favour of #295, thanks again for doing this all!

(Some fs calls will remain, but they're in components that are getting rewritten anyway with #283 and axodotdev/axoproject#26)

@Gankra Gankra closed this Jul 31, 2023
@mistydemeo mistydemeo deleted the feat/use-more-axoasset branch September 13, 2023 22:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

factor out more fs code to axoasset
2 participants