Repository navigation
Expand file tree
/
Copy pathinit.php
More file actions
executable file
·74 lines (56 loc) · 2.81 KB
/
Copy pathinit.php
File metadata and controls
executable file
·74 lines (56 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env php
<?php
use BrickLayer\Lay\BobDBuilder\Helper\Console\Console;
use BrickLayer\Lay\BobDBuilder\Helper\Console\Format\Foreground;
use BrickLayer\Lay\Core\LayConfig;
use BrickLayer\Lay\Libs\Dir\LayDir;
use BrickLayer\Lay\Libs\LayFn;
use BrickLayer\Lay\Libs\Primitives\Enums\LayLoop;
const SAFE_TO_INIT_LAY = true;
include_once __DIR__ . "/../../../foundation.php";
$domain = $argv[1] ?? null;
$overwrite_file = LayFn::extract_cli_tag("--force", false) ?? false;
$overwrite_layout = LayFn::extract_cli_tag("--overwrite-layout", false) ?? false;
if(!$domain){
Console::log("[!] Specify the domain you want to install Elevator frontend into", Foreground::yellow);
Console::bell();
die;
}
$GLOBALS['domain'] = LayConfig::server_data()->domains . $domain . DIRECTORY_SEPARATOR;
$GLOBALS['overwrite_file'] = $overwrite_file;
function copy_dir ($src, $dest, $overwrite_file = false) {
LayDir::read($src, function ($file, $dir, DirectoryIterator $handler, $entry) use ($dest, $overwrite_file) {
if(str_starts_with($file, ".")) return LayLoop::CONTINUE;
$from = $entry['full_path'];
$to = rtrim($dest, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $file ;
if($handler->isDir()) {
LayDir::make($to, 0777, true);
copy_dir($from, $to, $overwrite_file);
return LayLoop::CONTINUE;
}
if(!$overwrite_file && file_exists($to)) {
Console::log("Exists already: $to", Foreground::yellow);
Console::log("Use [ --force || --overwrite-layout ] tag to overwrite static files or layout files", Foreground::purple);
return LayLoop::CONTINUE;
}
if(copy($from, $to)) {
Console::log("[✔︎] Copied", Foreground::light_green);
Console::log(" From: $from");
Console::log(" To: $to");
}
});
}
Console::log("[+] Attempting to copy layout", Foreground::light_cyan);
copy_dir(__DIR__ . "/src/Domain/layout", $domain . "layout", $overwrite_layout);
Console::log("[+] Attempting to copy plasters", Foreground::light_cyan);
copy_dir(__DIR__ . "/src/Domain/plaster", $domain . "plaster", $overwrite_file);
Console::log("[+] Attempting to copy ui-kits", Foreground::light_cyan);
copy_dir(__DIR__ . "/src/Domain/static/ui-kit", $domain . "static/dev/ui/ui-kit", $overwrite_file);
Console::log("[+] Attempting to copy custom assets", Foreground::light_cyan);
copy_dir(__DIR__ . "/src/Domain/static/custom", $domain . "static/dev", $overwrite_file);
if(!file_exists($domain . "static/dev/js/foundation.js")) {
Console::log("[+] Making assets foundation file", Foreground::light_cyan);
file_put_contents($domain . "static/dev/js/foundation.js", file_get_contents(__DIR__ . "/default-foundation.js"));
}
Console::log("Operation complete!", Foreground::blue);
Console::bell();