-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Continue replacing Layer trait with Struct API and using bullet stream (
#334) * Remove section logger from bundle list * Change top level bullet to a noun * Refactor command to functional style * Move logic to function * Replace section logger with bullet stream * Replace logging with bullet stream * Remove SectionLogger guard * Remove SectionLogger guard * Replace section logger with bullet stream * Wire bullet stream input and output * Replace section log with bullet stream * Replace section log with bullet stream * Replace section log with bullet stream * Pluralize word * Replace section log with bullet stream * Move associated function to function * Wire up bullet stream * Use bullet stream for `rake -p` * Wire bullet stream * Replace section logger with bullet stream * Replace section logger with bullet stream * Replace section logger with bullet stream * Inline AppCacheCollection logic This is a pretty useless struct that hides the underlying logic I want to deprecate it. * Remove output fmt module import * Inline command call * Replace section log with bullet stream * Use value directly instead of making a variable * Inline command creation * Use value directly * Remove log_* calls in favor of bullet stream * Revert changes to AppCacheCollection * Deprecate AppCacheCollection * Remove commons output imports * Remove commons output imports * Remove unused * Remove clippy allow * Update buildpacks/ruby/src/steps/rake_assets_install.rs Co-authored-by: Rune Soerensen <rsoerensen@salesforce.com> * Changelog entry --------- Co-authored-by: Rune Soerensen <rsoerensen@salesforce.com>
- Loading branch information
1 parent
c8cdfd0
commit cc50d62
Showing
9 changed files
with
259 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,80 @@ | ||
use commons::output::{ | ||
fmt::{self, HELP}, | ||
section_log::{log_step, SectionLogger}, | ||
}; | ||
|
||
use crate::gem_list::GemList; | ||
use crate::rake_status::{check_rake_ready, RakeStatus}; | ||
use crate::rake_task_detect::RakeDetect; | ||
use crate::rake_task_detect::{self, RakeDetect}; | ||
use crate::RubyBuildpack; | ||
use crate::RubyBuildpackError; | ||
use bullet_stream::state::SubBullet; | ||
use bullet_stream::{style, Print}; | ||
use libcnb::build::BuildContext; | ||
use libcnb::Env; | ||
use std::io::Stdout; | ||
|
||
pub(crate) fn detect_rake_tasks( | ||
logger: &dyn SectionLogger, | ||
bullet: Print<SubBullet<Stdout>>, | ||
gem_list: &GemList, | ||
context: &BuildContext<RubyBuildpack>, | ||
env: &Env, | ||
) -> Result<Option<RakeDetect>, RubyBuildpackError> { | ||
let rake = fmt::value("rake"); | ||
let gemfile = fmt::value("Gemfile"); | ||
let rakefile = fmt::value("Rakefile"); | ||
) -> Result<(Print<SubBullet<Stdout>>, Option<RakeDetect>), RubyBuildpackError> { | ||
let help = style::important("HELP"); | ||
let rake = style::value("rake"); | ||
let gemfile = style::value("Gemfile"); | ||
let rakefile = style::value("Rakefile"); | ||
|
||
match check_rake_ready( | ||
&context.app_dir, | ||
gem_list, | ||
[".sprockets-manifest-*.json", "manifest-*.json"], | ||
) { | ||
RakeStatus::MissingRakeGem => { | ||
log_step(format!( | ||
"Skipping rake tasks {}", | ||
fmt::details(format!("no {rake} gem in {gemfile}")) | ||
)); | ||
|
||
log_step(format!( | ||
"{HELP} Add {gem} to your {gemfile} to enable", | ||
gem = fmt::value("gem 'rake'") | ||
)); | ||
|
||
Ok(None) | ||
} | ||
RakeStatus::MissingRakefile => { | ||
log_step(format!( | ||
"Skipping rake tasks {}", | ||
fmt::details(format!("no {rakefile}")) | ||
)); | ||
log_step(format!("{HELP} Add {rakefile} to your project to enable",)); | ||
|
||
Ok(None) | ||
} | ||
RakeStatus::MissingRakeGem => Ok(( | ||
bullet | ||
.sub_bullet(format!( | ||
"Skipping rake tasks ({rake} gem not found in {gemfile})" | ||
)) | ||
.sub_bullet(format!( | ||
"{help} Add {gem} to your {gemfile} to enable", | ||
gem = style::value("gem 'rake'") | ||
)), | ||
None, | ||
)), | ||
RakeStatus::MissingRakefile => Ok(( | ||
bullet | ||
.sub_bullet(format!("Skipping rake tasks ({rakefile} not found)",)) | ||
.sub_bullet(format!("{help} Add {rakefile} to your project to enable",)), | ||
None, | ||
)), | ||
RakeStatus::SkipManifestFound(paths) => { | ||
let files = paths | ||
let manifest_files = paths | ||
.iter() | ||
.map(|path| fmt::value(path.to_string_lossy())) | ||
.map(|path| style::value(path.to_string_lossy())) | ||
.collect::<Vec<_>>() | ||
.join(", "); | ||
|
||
log_step(format!( | ||
"Skipping rake tasks {}", | ||
fmt::details(format!("Manifest files found {files}")) | ||
)); | ||
log_step(format!("{HELP} Delete files to enable running rake tasks")); | ||
|
||
Ok(None) | ||
Ok(( | ||
bullet | ||
.sub_bullet(format!( | ||
"Skipping rake tasks (Manifest {files} found {manifest_files})", | ||
files = if manifest_files.len() > 1 { | ||
"files" | ||
} else { | ||
"file" | ||
} | ||
)) | ||
.sub_bullet(format!("{help} Delete files to enable running rake tasks")), | ||
None, | ||
)) | ||
} | ||
RakeStatus::Ready(path) => { | ||
log_step(format!( | ||
"Detected rake ({rake} gem found, {rakefile} found at {path})", | ||
path = fmt::value(path.to_string_lossy()) | ||
)); | ||
|
||
let rake_detect = RakeDetect::from_rake_command(logger, env, true) | ||
.map_err(RubyBuildpackError::RakeDetectError)?; | ||
let (bullet, rake_detect) = rake_task_detect::call( | ||
bullet.sub_bullet(format!( | ||
"Detected rake ({rake} gem found, {rakefile} found at {path})", | ||
path = style::value(path.to_string_lossy()) | ||
)), | ||
env, | ||
true, | ||
) | ||
.map_err(RubyBuildpackError::RakeDetectError)?; | ||
|
||
Ok(Some(rake_detect)) | ||
Ok((bullet, Some(rake_detect))) | ||
} | ||
} | ||
} |
Oops, something went wrong.