Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

add scaffold_worker method to Site, use all the PathBufs #851

Merged
merged 7 commits into from
Nov 8, 2019

Conversation

ashleymichal
Copy link
Contributor

@ashleymichal ashleymichal commented Nov 6, 2019

fixes #622
fixes #643 by moving logic to scaffold a site worker out of wranglerjs and onto the site struct.

also some 💅:

  • change entry_point to Option<PathBuf> instead of Option<String>
  • organize/tidy use statements in build/wranglerjs
  • info! -> log::info!
  • log before running generate, remove name argument to generate::command that was purely for logging
  • use mut Site::default() for bucket tests, set variable fields
  • rename site.build_dir() -> site.entry_point(), don't pass 'current_dir''

Happy to extract any controversial refactors to a separate PR, but I think this is all pretty tame.

@EverlastingBugstopper
Copy link
Contributor

change entry_point to Option instead of Option

🤔

@ashleymichal
Copy link
Contributor Author

change entry_point to Option instead of Option

🤔

oh wow. github markdown made that weird. updated the comment.

Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper left a comment

Choose a reason for hiding this comment

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

_greatjob

@ashleymichal ashleymichal changed the title add scaffold_worker method to Site add scaffold_worker method to Site, use all the PathBufs Nov 6, 2019
Copy link
Contributor

@EverlastingBugstopper EverlastingBugstopper left a comment

Choose a reason for hiding this comment

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

re-approve


site
}

// if the user has configured `site.entry-point`, use that
// as the build directory. Otherwise use the default const
// SITE_ENTRY_POINT
pub fn build_dir(&self, current_dir: PathBuf) -> Result<PathBuf, std::io::Error> {
pub fn entry_point(&self) -> Result<PathBuf, std::io::Error> {
let current_dir = env::current_dir()?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

eventually methods like these that determine where a file should be found relative to the project root should probably take as an argument the actual project root path, rather than the current directory. for the moment, everything runs relative to root because that is where wrangler.toml is and we assume you are running wrangler adjacent to the toml.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

which makes me want to write a refactor issue

Copy link
Contributor

Choose a reason for hiding this comment

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

^ this would also be a step towards better monorepo support!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and/or just being able to run wrangler from anywhere inside a project. i'll write the issue and merge this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@gabbifish gabbifish left a comment

Choose a reason for hiding this comment

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

Looks great!


site
}

// if the user has configured `site.entry-point`, use that
// as the build directory. Otherwise use the default const
// SITE_ENTRY_POINT
pub fn build_dir(&self, current_dir: PathBuf) -> Result<PathBuf, std::io::Error> {
pub fn entry_point(&self) -> Result<PathBuf, std::io::Error> {
let current_dir = env::current_dir()?;
Copy link
Contributor

Choose a reason for hiding this comment

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

^ this would also be a step towards better monorepo support!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use site.entry_point instead of build_dir for scaffolding sites Site bucket should be PathBuf not String
3 participants