Skip to content

Commit

Permalink
Merge pull request #8
Browse files Browse the repository at this point in the history
Handled default domain iniit better on a fresh project
  • Loading branch information
leonardosahon authored Dec 24, 2023
2 parents 77f3244 + 749c34a commit 84fc26d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
15 changes: 8 additions & 7 deletions src/BobDBuilder/Cmd/Traits/Make/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public function domain(): void
new LayCopyDir($this->internal_dir . "Domain", $domain_dir);

$talk("- Copying default files");
$this->domain_default_files($domain, $domain_dir);
$this->domain_default_files($domain, $domain_id, $domain_dir);

$talk("- Linking .htaccess *{$this->plug->server->web}*");
new BobExec("link:htaccess $domain --silent");
new BobExec("link:h taccess $domain --silent");

$talk("- Linking shared directory *{$this->plug->server->shared}*");
new BobExec("link:dir web{$this->plug->s}shared web{$this->plug->s}domains{$this->plug->s}$domain{$this->plug->s}shared --silent");
Expand All @@ -80,7 +80,7 @@ public function domain(): void
$this->update_general_domain_entry($domain, $domain_id, $pattern);
}

public function domain_default_files(string $domain_name, string $domain_dir): void
public function domain_default_files(string $domain_name, string $domain_id, string $domain_dir): void
{
file_put_contents(
$domain_dir . $this->plug->s . "index.php",
Expand All @@ -93,7 +93,7 @@ public function domain_default_files(string $domain_name, string $domain_dir): v
include_once __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "index.php";
Domain::new()->create(
id: "default",
id: "$domain_id",
builder: new \web\domains\\$domain_name\Plaster(),
);
Expand Down Expand Up @@ -219,12 +219,13 @@ public function update_general_domain_entry(string $domain, string $domain_id, s
$page_index++;
}

$default_domain = [];
$default_domain = [''];

if(!$this->plug->is_internal) {
if(!$this->plug->is_internal)
$default_domain = end($domains);

if($domains > 1)
array_pop($domains);
}

if($existing_domain_key)
unset($domains[$existing_domain_key]);
Expand Down
2 changes: 1 addition & 1 deletion src/BobDBuilder/Cmd/Traits/Symlink/Dir.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private function dir(): void
. "***### Take Note:: You will be deleting the former directory if you decide to pass the flag --force"
);

unlink($dest);
@unlink($dest);
symlink($src, $dest);

$this->plug->write_success(
Expand Down
2 changes: 1 addition & 1 deletion src/BobDBuilder/Cmd/Traits/Symlink/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private function file(): void
. "***### Take Note:: You will be deleting the former file if you decide to pass the flag --force"
);

unlink($dest);
@unlink($dest);
symlink($src, $dest);

$this->plug->write_success(
Expand Down
19 changes: 8 additions & 11 deletions src/BobDBuilder/Cmd/Traits/Symlink/Htaccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,14 @@ private function htaccess(): void

$dest .= ".htaccess";

if (file_exists($dest)) {
if (!$plug->force)
$plug->write_warn(
"htaccess exists already at: $dest"
. "If you want to REPLACE!! it, pass the flag --force\n"
. "***### Take Note:: You will be deleting the former htaccess if you decide to pass the flag --force"
);

unlink($dest);
}

if (file_exists($dest) && !$plug->force)
$plug->write_warn(
"htaccess exists already at: $dest"
. "If you want to REPLACE!! it, pass the flag --force\n"
. "***### Take Note:: You will be deleting the former htaccess if you decide to pass the flag --force"
);

@unlink($dest);
symlink($plug->server->web . ".htaccess", $dest);

$plug->write_success("htaccess successfully linked to: $dest");
Expand Down
2 changes: 1 addition & 1 deletion src/BobDBuilder/EnginePlug.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function write(string $message, ?CmdOutType $type = null, array $opts = [
if ($open_talk && !$this->silent)
Console::log("(^_^) Bob is Building --::--", Foreground::light_gray);

if (!$hide_cur_cmd && !empty($current_cmd)) {
if (!$this->silent && $hide_cur_cmd && !empty($current_cmd)) {
print " CURRENT COMMAND ";
Console::log(
" $current_cmd ",
Expand Down

0 comments on commit 84fc26d

Please sign in to comment.