Skip to content

Commit

Permalink
add capability to skip domain name in /etc/hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
zamronypj committed Sep 20, 2020
1 parent 319f042 commit d8d0d7c
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ implementation
ApacheReloadWebServerTaskImpl,
NginxReloadWebServerTaskImpl,
AddDomainToEtcHostTaskImpl,
WithSkipEtcHostTaskImpl,
RootCheckTaskImpl,
InFanoProjectDirCheckTaskImpl,
WebServerTaskImpl,
Expand Down Expand Up @@ -190,7 +191,12 @@ implementation
//so it automatically enabled
TNullTask.create()
),
TAddDomainToEtcHostTask.create(fReader, fWriter),
//wrap to allow skip domain name creation in /etc/host with
//--skip-etc-hosts parameter
TWithSkipEtcHostTask.create(
TNullTask.create(),
TAddDomainToEtcHostTask.create(fReader, fWriter)
),
TWebServerTask.create(
TApacheReloadWebServerTask.create(),
TNginxReloadWebServerTask.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ implementation
ApacheEnableVhostTaskImpl,
ApacheReloadWebServerTaskImpl,
AddDomainToEtcHostTaskImpl,
WithSkipEtcHostTaskImpl,
RootCheckTaskImpl,
InFanoProjectDirCheckTaskImpl,
WebServerTaskImpl,
Expand Down Expand Up @@ -123,7 +124,12 @@ implementation
//do nothing as nginx does not support CGI
TNullTask.create()
),
TAddDomainToEtcHostTask.create(fReader, fWriter),
//wrap to allow skip domain name creation in /etc/host with
//--skip-etc-hosts parameter
TWithSkipEtcHostTask.create(
TNullTask.create(),
TAddDomainToEtcHostTask.create(fReader, fWriter)
),
TWebServerTask.create(
TApacheReloadWebServerTask.create(),
//do nothing as nginx does not support CGI
Expand Down
52 changes: 52 additions & 0 deletions src/Tasks/Implementations/Deploy/Core/WithSkipEtcHostTaskImpl.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
(*!------------------------------------------------------------
* Fano CLI Application (https://fanoframework.github.io)
*
* @link https://github.com/fanoframework/fano-cli
* @copyright Copyright (c) 2018 - 2020 Zamrony P. Juhara
* @license https://github.com/fanoframework/fano-cli/blob/master/LICENSE (MIT)
*------------------------------------------------------------- *)
unit WithSkipEtcHostTaskImpl;

interface

{$MODE OBJFPC}
{$H+}

uses

TaskOptionsIntf,
TaskIntf,
ConditionalCompositeTaskImpl;

type

(*!--------------------------------------
* Task that run first task if --skip-etc-hosts
* parameter to skip domain entry creation
* in /etc/hosts or second task if default behavior
*----------------------------------------
* @author Zamrony P. Juhara <zamronypj@yahoo.com>
*---------------------------------------*)
TWithSkipEtcHostTask = class(TConditionalCompositeTask)
protected
function condition(
const opt : ITaskOptions;
const longOpt : shortstring
) : boolean; override;
end;

implementation

uses

sysutils;

function TWithSkipEtcHostTask.condition(
const opt : ITaskOptions;
const longOpt : shortstring
) : boolean;
var routeMethods : TStringArray;
begin
result := opt.hasOption('skip-etc-hosts');
end;
end.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ implementation
ApacheReloadWebServerTaskImpl,
NginxReloadWebServerTaskImpl,
AddDomainToEtcHostTaskImpl,
WithSkipEtcHostTaskImpl,
RootCheckTaskImpl,
InFanoProjectDirCheckTaskImpl,
WebServerTaskImpl,
Expand Down Expand Up @@ -167,7 +168,12 @@ implementation
//so it automatically enabled
TNullTask.create()
),
TAddDomainToEtcHostTask.create(fReader, fWriter),
//wrap to allow skip domain name creation in /etc/host with
//--skip-etc-hosts parameter
TWithSkipEtcHostTask.create(
TNullTask.create(),
TAddDomainToEtcHostTask.create(fReader, fWriter)
),
TWebServerTask.create(
TApacheReloadWebServerTask.create(),
TNginxReloadWebServerTask.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ implementation
ApacheEnableVhostTaskImpl,
ApacheReloadWebServerTaskImpl,
AddDomainToEtcHostTaskImpl,
WithSkipEtcHostTaskImpl,
RootCheckTaskImpl,
InFanoProjectDirCheckTaskImpl,
WebServerTaskImpl,
Expand Down Expand Up @@ -125,7 +126,12 @@ implementation
//nginx does not support so do nothing
TNullTask.create()
),
TAddDomainToEtcHostTask.create(fReader, fWriter),
//wrap to allow skip domain name creation in /etc/host with
//--skip-etc-hosts parameter
TWithSkipEtcHostTask.create(
TNullTask.create(),
TAddDomainToEtcHostTask.create(fReader, fWriter)
),
TWebServerTask.create(
TApacheReloadWebServerTask.create(),
//nginx does not support so do nothing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ implementation
ApacheReloadWebServerTaskImpl,
NginxReloadWebServerTaskImpl,
AddDomainToEtcHostTaskImpl,
WithSkipEtcHostTaskImpl,
RootCheckTaskImpl,
InFanoProjectDirCheckTaskImpl,
WebServerTaskImpl,
Expand Down Expand Up @@ -168,7 +169,12 @@ implementation
//so it automatically enabled
TNullTask.create()
),
TAddDomainToEtcHostTask.create(fReader, fWriter),
//wrap to allow skip domain name creation in /etc/host with
//--skip-etc-hosts parameter
TWithSkipEtcHostTask.create(
TNullTask.create(),
TAddDomainToEtcHostTask.create(fReader, fWriter)
),
TWebServerTask.create(
TApacheReloadWebServerTask.create(),
TNginxReloadWebServerTask.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ implementation
ApacheReloadWebServerTaskImpl,
NginxReloadWebServerTaskImpl,
AddDomainToEtcHostTaskImpl,
WithSkipEtcHostTaskImpl,
RootCheckTaskImpl,
InFanoProjectDirCheckTaskImpl,
WebServerTaskImpl,
Expand Down Expand Up @@ -170,7 +171,12 @@ implementation
//so it automatically enabled
TNullTask.create()
),
TAddDomainToEtcHostTask.create(fReader, fWriter),
//wrap to allow skip domain name creation in /etc/host with
//--skip-etc-hosts parameter
TWithSkipEtcHostTask.create(
TNullTask.create(),
TAddDomainToEtcHostTask.create(fReader, fWriter)
),
TWebServerTask.create(
TApacheReloadWebServerTask.create(),
TNginxReloadWebServerTask.create()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ implementation
ApacheReloadWebServerTaskImpl,
NginxReloadWebServerTaskImpl,
AddDomainToEtcHostTaskImpl,
WithSkipEtcHostTaskImpl,
RootCheckTaskImpl,
InFanoProjectDirCheckTaskImpl,
WebServerTaskImpl,
Expand Down Expand Up @@ -167,7 +168,12 @@ implementation
//so it automatically enabled
TNullTask.create()
),
TAddDomainToEtcHostTask.create(fReader, fWriter),
//wrap to allow skip domain name creation in /etc/host with
//--skip-etc-hosts parameter
TWithSkipEtcHostTask.create(
TNullTask.create(),
TAddDomainToEtcHostTask.create(fReader, fWriter)
),
TWebServerTask.create(
TApacheReloadWebServerTask.create(),
TNginxReloadWebServerTask.create()
Expand Down

0 comments on commit d8d0d7c

Please sign in to comment.