-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfruga.php
65 lines (49 loc) · 2.07 KB
/
fruga.php
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
<?php
/*
Copyright (C) 2024 Yoan De Macedo <mail@yoandm.com>
web : http://yoandm.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require 'autoload.php';
require 'vendor/autoload.php';
use Yoandm\Fruga\Generation\Generator;
use Yoandm\Fruga\Deployment\Deployer;
if($argc < 3){
die('*** Sorry, you must specify a command and a website name ***' . "\n");
}
if(! in_array($argv[1], array('generate', 'deploy'))){
die('*** Sorry, you must specify an existing command : generate, deploy ***' . "\n");
}
if(! file_exists(__DIR__ . '/sites/' . $argv[2])){
die('*** Sorry, you must specify an existing website ***' . "\n");
}
if($argv[1] === 'generate'){
$profile = 'site';
if(isset($argv[3]))
$profile = trim($argv[3]);
$gen = new Generator($argv[2], $profile);
if(! $gen->generate()){
die('*** Error during generation ***' . "\n");
} else {
echo 'Website ' . $argv[2] . ' successfully generated !' . "\n";
}
} else if($argv[1] === 'deploy'){
if($argc < 4){
die('*** Sorry, you must specify a deployment method ***' . "\n");
}
$d = new Deployer($argv[2], $argv[3]);
if(! $d->deploy()){
die('*** Error during deployment ***' . "\n");
} else {
echo 'Website ' . $argv[2] . ' successfully deployed !' . "\n";
}
}