Skip to content

Commit

Permalink
thusfar
Browse files Browse the repository at this point in the history
  • Loading branch information
bobmagicii committed Sep 26, 2024
1 parent 8fa6f52 commit 31da14b
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions src/Nether/Common/Phar/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class Builder
public string
$Bin;

public string
$Version;

public Common\Datastore
$Files;

Expand Down Expand Up @@ -91,17 +94,26 @@ public function
return $this;
}

public function
SetVersion(string $Version):
static {

$this->Version = $Version;

return $this;
}

////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////

public function
Build():
Build(?string $Version=NULL):
void {

$this->PrepareForBuild();
$this->DeleteFilesInBuild();
$this->CopyFilesIntoBuild();
$this->CompilePharOfBuild();
$this->CompilePharOfBuild($Version);
$this->InspectPharOfBuild();

return;
Expand Down Expand Up @@ -259,11 +271,34 @@ public function
}

public function
CompilePharOfBuild():
CompilePharOfBuild(?string $Version=NULL):
void {

// if null Version will be pulled from the annotation.
// - if valid string Version will be appended to the file name.
// - if empty string Version will not be appended.

////////

$Version ??= $this->Version;
$Outfile = $this->OutputFile;

////////

if($Version)
$Outfile = str_replace(
sprintf('.%s.phar', $Version),
sprintf('-%s.phar', $Version),
Common\Filesystem\Util::ReplaceFileExtension(
$Outfile,
sprintf('%s.phar', $Version)
)
);

////////

$Files = $this->IndexFilesInBuild();
$Outfile = Common\Filesystem\Util::Pathify($this->BuildDir, $this->OutputFile);
$Outfile = Common\Filesystem\Util::Pathify($this->BuildDir, $Outfile);
$Phar = new Phar($Outfile);

$Phar->StartBuffering();
Expand Down Expand Up @@ -348,14 +383,15 @@ public function
////////////////////////////////////////////////////////////////

static public function
From(string $PharOut, string $Bin, Common\Datastore $Files, ?string $BaseDir=NULL, ?string $BuildDir=NULL, ?Common\Datastore $FileFilters=NULL):
From(string $PharOut, string $Bin, string $Version, Common\Datastore $Files, ?string $BaseDir=NULL, ?string $BuildDir=NULL, ?Common\Datastore $FileFilters=NULL):
static {

$Output = new static;

($Output)
->SetOutputFile($PharOut)
->SetBin($Bin)
->SetVersion($Version)
->SetFileList($Files)
->SetBaseDir($BaseDir)
->SetBuildDir($BuildDir)
Expand Down

0 comments on commit 31da14b

Please sign in to comment.