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

Refactor with vinyl-prepare #230

Merged
merged 3 commits into from
May 3, 2017
Merged

Refactor with vinyl-prepare #230

merged 3 commits into from
May 3, 2017

Conversation

phated
Copy link
Member

@phated phated commented Apr 26, 2017

This is the WIP branch using vinyl-prepare. I might also try to land #139 (including sourcemap support) in this changeset (separate commits).

@erikkemperman
Copy link
Member

Thanks for untangling this @phated! I'll try to keep things more cleanly separated in future.

About #139, on the src side, I believe every option except sourcemaps now supports function values, passing the Files as argument. Well, and passthrough isn't called per file, obviously.

I was wondering if it makes sense to also rename our read option so it no longer collides with through2?

@phated
Copy link
Member Author

phated commented Apr 27, 2017

@erikkemperman no problem. I would typically just squash your stuff with the github UI but I wanted to document the extra features.

I need to review all the options stuff (I want to try to centralize it in some manner) before I close that issue. I think you landed a rename (to readFile) in one of your commits. However, I'm going to be removing the ability to pass options to through2 because it was a hacky solution to us not using streams properly (now fixed).

@erikkemperman
Copy link
Member

I looked at centralizing them when I was looking at this, figuring prepare would be the place for it. But I got stuck, mostly because you preferred glob (well, file operations) stay at vinyl-fs. Perhaps a separate module used by vinyl-fs and vinyl-prepare?

Yeah, I renamed the option to readFile internally because we now need it later than we did before (per file instead of once up front) and as such it would have clashed with through2.

@phated phated force-pushed the prepare-stream branch 2 times, most recently from b3666b3 to f39023f Compare May 2, 2017 17:00
@phated
Copy link
Member Author

phated commented May 2, 2017

@erikkemperman I've added the sourcemap(write) stuff into my first commit (since I'm no longer putting it in vinyl-prepare). Can you take a look and give me feedback? I'm going to be applying similar logic into your commit for src

@erikkemperman
Copy link
Member

Sure, I'll take a look. One potential downside, I guess, to not having this in prepare is that the sourcemaps will be excluded in the "dry run" scenario that got all this started...

@phated
Copy link
Member Author

phated commented May 2, 2017

@erikkemperman that is one of my goals. @doowb didn't need sourcemaps in his request but I was trying to over-engineer (as I do).

@erikkemperman
Copy link
Member

@phated Fair enough, it's just that I would have expected a dry run to include them (especially when they're to be written separately).

Reading through the original issue, it also mentioned moving the mkdirp call into write-contents. Not sure why it would matter, but doing that would get rid of the save-file.js stage, which as it stands does nothing else.

And actually, didn't you consider making mkdirp a stream, at one point?

@phated
Copy link
Member Author

phated commented May 2, 2017

The mkdirp feels messy in write-contents/ so I made it a separate stream step. I think it's probably better to have a mkdirp-stream utility but I don't know the best way to do it. I really need to find the proper abstraction levels before I split things up (and take on the maintenance responsibility). The original issue was about removing all fs.* calls from the preparation logic so putting sourcemaps into vinyl-prepare breaks that contract.

@erikkemperman
Copy link
Member

Right. It'd be slightly messy in write-contents, that's true.

I don't know enough about the original use case to judge, but my understanding is they wanted to be able to reconstruct the directory structure as it would be created by dest. But perhaps it's alright if that does not include the (possibly distinct, I imagine) location of sourcemaps.

So far this looks good, but I'd need more time than I have right now to try this in an actual project.

@phated
Copy link
Member Author

phated commented May 2, 2017

@erikkemperman that's actually the opposite of what they wanted. haha. Thanks for taking a look; I'm working on the src stuff now.

@doowb
Copy link
Member

doowb commented May 2, 2017

Our main goal is to be able to use vinyl-prepare to calculate the correct destination for a file without doing any of the file system parts. This would include not creating the directory structure. We want to be able to setup the file's path properties before we do something like render templates so those properties can be used inside the templates for linking between pages.

I'll take a closer look at this when I get a chance and provide some feedback (if necessary). It might be a couple of days so don't wait on me when you're ready to merge :).

@phated
Copy link
Member Author

phated commented May 3, 2017

@erikkemperman I'm sticking a bunch of stuff in this PR that is related to the prepare stream changes but I'm not sure how I'm going rebase/merge them into master.

@erikkemperman
Copy link
Member

@phated The opposite? Maybe I should have said "predict" rather than "reconstruct" but I wasn't that far off, Shirley :-)

@erikkemperman
Copy link
Member

I think the gulp-sourcemaps dependency can now go away, right?

I'll link this into an actual project or two tonight (GMT+2) and let you know how that goes!

@phated
Copy link
Member Author

phated commented May 3, 2017

@erikkemperman I think there are a bunch of deps I need to remove with these changes. I'll double check.

@phated phated dismissed a stale review May 3, 2017 16:12

Doesn't seem to make sense?

@phated phated force-pushed the prepare-stream branch 2 times, most recently from 6e90324 to 3b2df28 Compare May 3, 2017 16:50
@phated phated force-pushed the prepare-stream branch from 3b2df28 to 01af622 Compare May 3, 2017 17:22
@phated
Copy link
Member Author

phated commented May 3, 2017

As soon as these tests finish running, I'm going to call this PR done. There are still things to do but I don't want to keep lumping them in here.

@phated phated force-pushed the prepare-stream branch from 01af622 to 28d3ba0 Compare May 3, 2017 18:15
@phated phated merged commit 28d3ba0 into master May 3, 2017
@phated phated deleted the prepare-stream branch May 3, 2017 19:38
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.

3 participants