-
Notifications
You must be signed in to change notification settings - Fork 2
/
build
57 lines (47 loc) · 1.6 KB
/
build
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
#!/usr/bin/env php
<?php
$filename = 'floyer.phar';
$output_dir = __DIR__ . '/dist/';
$output_file = $output_dir . $filename;
// Remove existing file, recursively create directories if needed
@unlink($output_file);
@mkdir($output_dir, 0755, true);
// If vendors directory doesn't exist, try to install with composer
if (! is_dir(__DIR__ . '/vendor')) {
@shell_exec('composer --working-dir="' . __DIR__ . '" install');
}
// Start phar
$phar = new Phar(
$output_file,
FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME,
$filename
);
$phar->startBuffering();
// Adding folders
// https://bugs.php.net/bug.php?id=58169
$phar->buildFromDirectory(
dirname(__FILE__),
'/(vendor\/composer|vendor\/league|vendor\/psr|vendor\/symfony|vendor\/phpseclib)\/.*/'
);
// Adding main file
$phar->addFile('floyer.php');
$phar->addFile('floyer-sample.ini');
$phar->addFile('src/Commands/Deploy.php');
$phar->addFile('src/Connectors/FTP.php');
$phar->addFile('src/Connectors/SFTP.php');
$phar->addFile('src/Contracts/ConnectorInterface.php');
$phar->addFile('src/Contracts/DriverInterface.php');
$phar->addFile('src/Drivers/Base.php');
$phar->addFile('src/Drivers/Git.php');
$phar->addFile('src/Drivers/Svn.php');
$phar->addFile('src/Traits/IO.php');
$phar->addFile('src/Traits/Options.php');
$phar->addFile('vendor/autoload.php');
// Create a stub and add the shebang
$default = $phar->createDefaultStub('floyer.php');
$stub = "#!/usr/bin/env php \n" . $default;
$phar->setStub($stub);
$phar->compressFiles(Phar::GZ);
$phar->stopBuffering();
// Set file permissions
chmod($output_file, 0755);