代码拉取完成,页面将自动刷新
#!/usr/bin/env php
<?php declare(strict_types=1);
class App
{
const VERSION = '0.1';
public function run()
{
Arguments::read();
}
}
final class Arguments
{
public static function read()
{
global $argv;
while ($row = next($argv)) {
if(preg_match('/^(-{1,2})[hH]([eE][lL][pP])?$/', $row)) {
self::help();
} elseif(preg_match('/^(-{1,2})[vV]$/', $row)) {
self::version();
}
}
// var_dump($argv);
}
private static function help()
{
$version = App::VERSION;
echo <<<EOT
Autopack Version ${version}
-h show this document (显示此文档)
-v show this script version (显示当前版本)
EOT;
exit(0);
}
private static function version()
{
echo App::VERSION;
exit(0);
}
}
(new App())->run();
//exit();
function wait_user_input()
{
$handle = fopen('php://stdin', 'r');
$line = trim(fgets($handle));
fclose($handle);
return $line;
}
exec('node -v', $_output, $error);
echo 'node version '.$_output[0]."\n";
unset($_output);
exec('npm -v', $_output);
echo 'npm version '.$_output[0]."\n";
unset($_output);
exec('php -v', $_output, $error);
preg_match('/[0-9]+\.[0-9]+\.[0-9]+ \([a-zA-Z]*\)/', $_output[0], $matches);
echo 'php version '.$matches[0]."\n";
unset($matches);
unset($_output);
// exec('composer -V', $_output, $error);
// preg_match('/[0-9]+\.[0-9]+\.[0-9]+/', $_output[0], $matches);
// echo 'composer version '.$matches[0]."\n";
//var_dump($_output);
unset($matches);
unset($_output);
//@exec('compose -V', $_output, $error);
//if($error !== 0) {
// echo "\e[35mexit\e[0m\n";
// exit($error);
//}
//unset($_output);
$defaultUIDir = '../Erp_3.0_4.0_UI';
if(!is_dir($defaultUIDir)) {
echo "\e[31mUI directory $defaultUIDir not exists.\e[0m";
exit(0);
}
chdir($defaultUIDir);
$currentDir = getcwd();
echo "> move current dir to $currentDir\n";
system('npm run build:prod', $error);
if($error != 0) {
echo "error\n";
exit($error);
}
chdir(__DIR__);
exec('php artisan vue list', $_output);
foreach($_output as $k => $v) {
echo "[{$k}] $v\n";
}
unset($k, $v);
echo 'Input the index forward,default[0]:';
$input = wait_user_input() ?: 0;
$selected = $_output[$input] ?? $_output[0];
preg_match('/\d{14}/', $selected, $matches);
$selected = $matches[0];
echo "\e[33mSelected $selected.\e[0m\n";
unset($_output);
unset($matches);
// 错误码
system('php artisan vue ' . $selected, $error);
//
//var_dump($error);
exit(0);
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。