-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenphar
63 lines (54 loc) · 1.54 KB
/
genphar
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
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
/**
* php -d phar.readonly=0 genphar pack -o swagphp.phar
*/
$input = new \Inhere\Console\IO\Input();
$output = new \Inhere\Console\IO\Output();
$ctrl = new \Inhere\Console\BuiltIn\PharController($input, $output);
$ctrl->setExecutionAlone();
// config
$ctrl->setCompilerConfiger(function (\Inhere\Console\Components\PharCompiler $compiler) {
$compiler
// ->stripComments(false)
->setShebang(true)
->addExclude([
'doc',
'docs',
'demo',
'demos',
'node_modules',
'test',
'tests',
'Tests',
'example',
'examples',
'tmp',
])
->notName([
])
->addFile([
'LICENSE',
'composer.json',
'README.md'
])
->setCliIndex('bin/swagphp')
// ->setWebIndex('web/index.php')
// ->setVersionFile('config/config.php')
;
// Command 下的命令类不去除注释,注释上是命令帮助信息
$compiler->setStripFilter(function ($file) {
/** @var \SplFileInfo $file */
$name = $file->getFilename();
return false === strpos($name, 'Command.php');
});
});
try {
exit($ctrl->run($input->getCommand()));
} catch (\Exception $e) {
$message = \Toolkit\Cli\Color::apply('error', $e->getMessage());
echo sprintf("%s\nFile %s:%d\nTrace:\n%s\n",
$message, $e->getFile(), $e->getLine(), $e->getTraceAsString()
);
}