src/main/scala/s3/website/Push.scala in s3_website-2.4.0 vs src/main/scala/s3/website/Push.scala in s3_website-2.5.0
- old
+ new
@@ -3,11 +3,11 @@
import s3.website.model.Config.S3_website_yml
import s3.website.model.Site._
import scala.concurrent.{ExecutionContextExecutor, Future, Await}
import scala.concurrent.duration._
import scala.language.postfixOps
-import s3.website.Diff.{resolveDeletes, resolveDiff}
+import s3.website.UploadHelper.{resolveDeletes, resolveUploads}
import s3.website.S3._
import scala.concurrent.ExecutionContext.fromExecutor
import java.util.concurrent.Executors.newFixedThreadPool
import java.util.concurrent.ExecutorService
import s3.website.model._
@@ -42,16 +42,18 @@
@Option(defaultToNull = true) def site: String
@Option(longName = Array("config-dir"), defaultToNull = true) def configDir: String
@Option def verbose: Boolean
@Option(longName = Array("dry-run")) def dryRun: Boolean
+ @Option(longName = Array("force")) def force: Boolean
}
def push(implicit cliArgs: CliArgs, s3Settings: S3Setting, cloudFrontSettings: CloudFrontSetting, workingDirectory: File): ExitCode = {
implicit val logger: Logger = new Logger(cliArgs.verbose)
- implicit val pushMode = new PushMode {
+ implicit val pushOptions = new PushOptions {
def dryRun = cliArgs.dryRun
+ def force = cliArgs.force
}
implicit val yamlConfig = S3_website_yml(new File(Option(cliArgs.configDir).getOrElse(workingDirectory.getPath) + "/s3_website.yml"))
val errorOrPushStatus = for (
@@ -73,19 +75,19 @@
implicit site: Site,
executor: ExecutionContextExecutor,
s3Settings: S3Setting,
cloudFrontSettings: CloudFrontSetting,
logger: Logger,
- pushMode: PushMode
+ pushOptions: PushOptions
): ExitCode = {
logger.info(s"${Deploy.renderVerb} ${site.rootDirectory}/* to ${site.config.s3_bucket}")
val redirects = Redirect.resolveRedirects
val s3FilesFuture = resolveS3Files()
val redirectReports: PushReports = redirects.map(S3 uploadRedirect _) map (Right(_))
val pushReports: Future[PushReports] = for {
- errorOrUploads: Either[ErrorReport, Seq[Upload]] <- resolveDiff(s3FilesFuture)
+ errorOrUploads: Either[ErrorReport, Seq[Upload]] <- resolveUploads(s3FilesFuture)
} yield {
val uploadReports: PushReports = errorOrUploads.fold(
error => Left(error) :: Nil,
uploads => {
uploads.map(S3 uploadFile _).map(Right(_))
@@ -106,11 +108,11 @@
afterPushFinished(finishedPushOps, invalidationSucceeded)
}
def invalidateCloudFrontItems
(finishedPushOperations: FinishedPushOperations)
- (implicit config: Config, cloudFrontSettings: CloudFrontSetting, ec: ExecutionContextExecutor, logger: Logger, pushMode: PushMode):
+ (implicit config: Config, cloudFrontSettings: CloudFrontSetting, ec: ExecutionContextExecutor, logger: Logger, pushOptions: PushOptions):
Option[InvalidationSucceeded] =
config.cloudfront_distribution_id.map { distributionId =>
val pushSuccessReports =
finishedPushOperations.map {
ops =>
@@ -139,11 +141,11 @@
}
type InvalidationSucceeded = Boolean
def afterPushFinished(finishedPushOps: FinishedPushOperations, invalidationSucceeded: Option[Boolean])
- (implicit config: Config, logger: Logger, pushMode: PushMode): ExitCode = {
+ (implicit config: Config, logger: Logger, pushOptions: PushOptions): ExitCode = {
val pushCounts = resolvePushCounts(finishedPushOps)
logger.info(s"Summary: ${pushCountsToString(pushCounts)}")
val pushOpExitCode = finishedPushOps.foldLeft(0) { (memo, finishedUpload) =>
memo + finishedUpload.fold(
(error: ErrorReport) => 1,
@@ -156,11 +158,11 @@
)
val exitCode = (pushOpExitCode + cloudFrontInvalidationExitCode) min 1
exitCode match {
- case 0 if !pushMode.dryRun && pushCounts.thereWasSomethingToPush =>
+ case 0 if !pushOptions.dryRun && pushCounts.thereWasSomethingToPush =>
logger.info(s"Successfully pushed the website to http://${config.s3_bucket}.${config.s3_endpoint.s3WebsiteHostname}")
case 1 =>
logger.fail(s"Failed to push the website to http://${config.s3_bucket}.${config.s3_endpoint.s3WebsiteHostname}")
case _ =>
}
@@ -189,10 +191,10 @@
}
)
)
}
- def pushCountsToString(pushCounts: PushCounts)(implicit pushMode: PushMode): String =
+ def pushCountsToString(pushCounts: PushCounts)(implicit pushOptions: PushOptions): String =
pushCounts match {
case PushCounts(updates, newFiles, failures, redirects, deletes, _, _)
if updates == 0 && newFiles == 0 && failures == 0 && redirects == 0 && deletes == 0 =>
PushNothing.renderVerb
case PushCounts(updates, newFiles, failures, redirects, deletes, uploadedBytes, uploadDurations) =>