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
Support nanoc environments #859
Support nanoc environments #859
Conversation
56d35ef
to
98d5251
Compare
Is missing:
Might be added:
|
Does it take into account the cascading of configuration files ( |
Is |
Good point regarding |
This looks cool! A couple of things that I spotted so far:
|
@@ -8,8 +8,9 @@ def new_with_config(hash) | |||
site_from_config(Nanoc::Int::Configuration.new(hash).with_defaults) | |||
end | |||
|
|||
def new_from_cwd | |||
site_from_config(Nanoc::Int::ConfigLoader.new.new_from_cwd) | |||
#def new_from_cwd(env = :default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oups... ➡️ will be removed
c6ae4de
to
a1a43d5
Compare
ad17ed7
to
8433fe5
Compare
@ddfreyne do you need me to do any additional changes? |
@barraq I’ll give this a more thorough review soon! |
@@ -47,6 +51,21 @@ def with_defaults | |||
self.class.new(new_wrapped) | |||
end | |||
|
|||
def with_environment(env = nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with_environment
does not appear to be called with an argument except for tests. Make the tests set up the environment, and remove this argument.
@barraq Is this PR still being worked on? I can take over if you wish. |
BTW, how does this feature interact with |
Introduce basic support for nanoc environment: - nanoc command is updated to include --env argument - config are overriden using the active environment if any - unless define in environment, output_dir is {{output_dir}}/{{env_name}} Setting environments is done in nanoc.yaml using the `environments` property. Example usage is: ``` output_dir: output environments: default: &default base_url: ... ... development: <<: *default base_url: ... production: <<: *default base_url: ... yet_another_env: <<: *default base_url: ... output_dir: build ``` Selecting working environment can be done: - using environment variable `NANOC_ENVIRONMENT` - using `nanoc --env=[<value>]`
- Document env attr_reader - Only allow String and nil for environment name - Remove argument for with_environment - Make :environments a constant - Lot of parentheses fix - Renamed NANOC_ENVIRONMENT to NANOC_ENV for consistency with Rails, Rake, etc. - Prefer Fetch(a,b) over a||b - Refactor tmp_path logic into Nanoc::Int::Store - Make -e, --env argument required - Updated test according to previous changes
4a29948
to
8676556
Compare
- add Contracts - rename store to store_name - use named arguments
220fe03
to
e208d05
Compare
e065bf5
to
6e67994
Compare
@ddfreyne I went over all fixes you mentioned. I did small fixup commits to ease the review process. |
Looks good! Thanks for this feature. Merging! |
As much as I like the idea of adding environment support, this change makes certain assumptions that will cause problems with certain filters. For instance, the compass filter creates a .sass-cache folder in the project directory where nanoc compile is run. It's quite possible other filters may create temporary folders where files are cached. As a result, the only safe way to use this feature is to only compile to one environment in a given project folder and not compile different environments in the same project folder. Sure it's possible to configure the sass compiler to cache to a specific location but the setup is complicated because the environment setting needs to be passed to the compass config.rb and used to set the sass :cache_location property. Not only that, the configuration has to be made to config.rb so it's possible to run the compass command by itself outside of nanoc and have it pick up the right environment location. Compass also supports environments so it would be ideal if the environment setting configured for Nanoc could be passed into the compass config.rb but that's a bit beyond the current topic. However, aside from the filters nanoc supports out of the box, even if all of them were reviewed and fixed if necessary, there's no guarantee that third-party filters aren't writing or caching files to the project directory. Even if switching environments to compile into the same folder is not supported, environment support is still very useful when building with one environment configuration such as development in its own folder, then push changes to a Git repository, e.g. github.com, then in a different folder configured as the production environment perform a git pull and recompile. |
Description
Introduce support for nanoc environment and addresses #676.
--env
argumenttmp
directory is updated totmp/{{env_name}}
Setting environments is done in nanoc.yaml using the
environments
property.Example usage is:
Selecting working environment can be done:
NANOC_ENVIRONMENT
nanoc --env=[<value>]
Progress
--env
optionNanoc::Int::Configuration
is updated to providewith_environment(env = nil)
{{output_dir}}/{{env_name}}
, ifenvironments
is not defined thenoutput_dir
remains unchangedtmp
directory is updated totmp/{{env_name}}