mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-19 23:05:36 +08:00
8 lines
13 KiB
JavaScript
8 lines
13 KiB
JavaScript
|
|
import{B as e,Ct as t,Et as n,F as r,G as i,H as a,I as o,L as s,P as c,V as l,W as u,X as d,at as f,j as p,mt as ee,q as m,st as h,vt as g,xt as _,yt as v}from"./framework.DrNIf5Lg.js";import{t as y}from"./extensions.data.jgJx1dMD.js";var te={key:0,class:`warning custom-block`,style:{"margin-bottom":`16px`}},ne={class:`option-line`},re=[`id`,`value`],ie=[`for`],ae={class:`option-line`},oe=[`disabled`],se={class:`box`},ce=[`placeholder`],le=[`id`,`value`],ue=[`for`],de={style:{color:`orangered`,"font-weight":`bolder`}},fe={class:`box`},pe=[`id`,`value`],me=[`for`],he={key:3,class:`warning custom-block`},ge={value:`spc`},_e={value:`native`},ve=[`value`],ye={value:``},be={for:`zts-yes`},xe={for:`zts-no`},Se={for:`pre-built-yes`},Ce={for:`pre-built-no`},we={key:0},Te={for:`upx-yes`},Ee={for:`upx-no`},De={for:`nostrip-yes`},Oe={for:`nostrip-no`},b=[`placeholder`],x={key:4,class:`command-container`},S={key:0,class:`command-preview`},C={class:`command-content`},w={key:1},T={class:`warning custom-block`},ke={class:`command-container`},Ae={class:`command-preview`},je={class:`command-content`},Me={class:`command-container`},Ne={class:`command-preview`},Pe={class:`command-content`},Fe={class:`command-container`},Ie={class:`command-preview pre`},Le={class:`command-content`},E=p(d({name:`CliGenerator`,props:{lang:{type:String,default:`zh`}},setup(d){let p=[`cli`,`fpm`,`micro`,`embed`,`frankenphp`,`cgi`],E=[`8.0`,`8.1`,`8.2`,`8.3`,`8.4`,`8.5`],Re=y.missing??!1,D=y.extensions??[],O=t(``),k=t([]),A=t([`cli`]),j=t(`spc`),M=t(`8.4`),N=t(`linux`),P=t(`x86_64`),F=t(``),I=t(!1),L=t(!0),R=t(!1),z=t(!1),B=t(10),V=t(5),H=t(``),U=t({spcDownload:!1,doctor:!1,build:!1,craft:!1}),ze=[{os:`linux`,label:`Linux`},{os:`macos`,label:`macOS`},{os:`windows`,label:`Windows`}],W=l(()=>D.filter(e=>N.value===`linux`?e.linux:N.value===`macos`?e.macos:N.value!==`windows`||e.windows).map(e=>e.name)),G=l(()=>[...k.value].sort().join(`,`)),K=l(()=>j.value===`native`?`bin/spc`:N.value===`windows`?`.\\spc.exe`:`./spc`),q=l(()=>`curl -#fSL https://dl.static-php.dev/v3/spc-bin/nightly/spc-${N.value===`macos`?`macos`:`linux`}-${P.value} -o spc && chmod +x spc`),J=l(()=>`${K.value} doctor --auto-fix`),Be=l(()=>{let e=H.value.split(`
|
|||
|
|
`).filter(e=>e.indexOf(`=`)>=1);return e.length>0?` `+e.map(e=>`-I "${e}"`).join(` `):``}),Y=l(()=>{let e=A.value.map(e=>`--build-${e}`).join(` `),t=` --dl-with-php=${M.value}`,n=` --dl-parallel=${B.value}`,r=` --dl-retry=${V.value}`,i=L.value?` --dl-prefer-binary`:``,a=z.value?` --no-strip`:``,o=R.value?` --with-upx-pack`:``,s=I.value?` --enable-zts`:``,c=F.value?` ${F.value}`:``;return`${K.value} build:php "${G.value}" ${e}${t}${n}${r} --dl-ignore-cache=php-src${i}${a}${o}${s}${Be.value}${c}`}),X=l(()=>{let e=`php-version: ${M.value}\n`;e+=`extensions: "${G.value}"\n`,A.value.length===1?e+=`sapi:\n - ${A.value[0]}\n`:(e+=`sapi:
|
|||
|
|
`,A.value.forEach(t=>{e+=` - ${t}\n`}));let t={"-v":64,"-vv":128,"-vvv":256};F.value&&t[F.value]&&(e+=`verbosity: ${t[F.value]}\n`),e+=`download-options:
|
|||
|
|
`,e+=` parallel: ${B.value}\n`,e+=` retry: ${V.value}\n`,e+=` ignore-cache: php-src
|
|||
|
|
`,L.value&&(e+=` prefer-binary: true
|
|||
|
|
`);let n=[];z.value&&n.push(` no-strip: true`),R.value&&n.push(` with-upx-pack: true`),I.value&&n.push(` enable-zts: true`);let r=H.value.split(`
|
|||
|
|
`).filter(e=>e.indexOf(`=`)>=1);return r.length>0&&(n.push(` with-hardcoded-ini:`),r.forEach(e=>n.push(` - "${e}"`))),n.length>0&&(e+=`build-options:\n${n.join(`
|
|||
|
|
`)}\n`),e}),Ve=()=>{let e=`apcu.bcmath.calendar.ctype.curl.dba.dom.exif.filter.fileinfo.gd.iconv.intl.mbstring.mbregex.mysqli.mysqlnd.openssl.opcache.pcntl.pdo.pdo_mysql.pdo_sqlite.pdo_pgsql.pgsql.phar.posix.readline.redis.session.simplexml.sockets.sodium.sqlite3.tokenizer.xml.xmlreader.xmlwriter.xsl.zip.zlib`.split(`.`),t=new Set(W.value);k.value=e.filter(e=>t.has(e))},He=()=>{k.value=[...W.value]},Z=(e,t)=>{if(!O.value||!e.includes(O.value))return t===0?e:``;let n=e.indexOf(O.value);switch(t){case 0:return e.substring(0,n);case 1:return O.value;case 2:return e.substring(n+O.value.length);default:return``}},Q=async(e,t)=>{try{await navigator.clipboard.writeText(e),U.value[t]=!0,setTimeout(()=>{U.value[t]=!1},2e3)}catch{let t=document.createElement(`textarea`);t.value=e,document.body.appendChild(t),t.select(),document.execCommand(`copy`),document.body.removeChild(t)}};ee(N,()=>{N.value===`windows`&&(P.value=`x86_64`,R.value=!1),k.value=[]});let $={zh:{selectExt:`选择扩展`,buildTarget:`选择编译目标`,buildOptions:`编译选项`,buildEnvironment:`编译环境`,buildEnvNative:`本地构建(Git 源码)`,buildEnvSpc:`本地构建(独立 spc 二进制)`,useVerbose:`是否输出详细日志`,verboseNone:`不输出(默认)`,yes:`是`,no:`否`,resultShow:`结果展示`,selectCommon:`选择常用扩展`,selectAll:`选择全部`,selectNone:`全部取消选择`,useZTS:`是否编译线程安全版`,hardcodedINI:`硬编码 INI 选项`,hardcodedINIPlaceholder:`如需要硬编码 ini,每行写一个,例如:memory_limit=2G`,compileCommand:`编译命令`,downloadPhpVersion:`下载 PHP 版本`,downloadSPCBinaryCommand:`下载 spc 二进制命令`,selectedSystem:`选择操作系统`,windowsSAPIUnavailable:`Windows 目前不支持 fpm 构建!`,useUPX:`是否开启 UPX 压缩(减小二进制体积)`,windowsDownSPCWarning:`Windows 下请手动下载 spc.exe 二进制文件!`,usePreBuilt:`如果可能,使用预编译的依赖库(减少编译时间)`,searchPlaceholder:`搜索扩展...`,copy:`复制`,copied:`已复制`,doctorCommand:`自动检查和准备构建环境命令`,dlParallel:`并行下载数(1-50)`,dlRetry:`失败重试次数`,noStrip:`保留调试符号(--no-strip)`},en:{selectExt:`Select Extensions`,buildTarget:`Build Target`,buildOptions:`Build Options`,buildEnvironment:`Build Environment`,buildEnvNative:`Native build (Git source code)`,buildEnvSpc:`Native build (standalone spc binary)`,useVerbose:`Verbose log output`,verboseNone:`None (default)`,yes:`Yes`,no:`No`,resultShow:`Result`,selectCommon:`Select common extensions`,selectAll:`Select all`,selectNone:`Unselect all`,useZTS:`Enable ZTS (thread-safe)`,hardcodedINI:`Hardcoded INI options`,hardcodedINIPlaceholder:`If you need to hardcode ini, write one per line, for example: memory_limit=2G`,compileCommand:`Build command`,downloadPhpVersion:`PHP version`,downloadSPCBinaryCommand:`Download spc binary`,selectedSystem:`Select OS`,windowsSAPIUnavailable:`Windows does not support fpm build!`,useUPX:`Enable UPX compression (reduce binary size)`,windowsDownSPCWarning:`Please download the spc.exe binary manually on Windows!`,usePreBuilt:`Use pre-built dependencies where available (reduce compile time)`,searchPlaceholder:`Search extensions...`,copy:`Copy`,copied:`Copied`,doctorCommand:`Auto-check and prepare build environment`,dlParallel:`Parallel downloads (1-50)`,dlRetry:`Retry count on failure`,noStrip:`Keep debug symbols (--no-strip)`}};return(t,l)=>(f(),i(`div`,null,[n(Re)?(f(),i(`div`,te,[...l[24]||=[a(`p`,{class:`custom-block-title`},`WARNING`,-1),a(`p`,null,[m(`Extension list is not generated yet. Run `),a(`code`,null,`bin/spc dev:gen-ext-docs`),m(` to generate it.`)],-1)]])):u(``,!0),a(`h2`,null,_($[d.lang].selectedSystem),1),a(`div`,ne,[(f(),i(e,null,h(ze,(e,t)=>a(`span`,{key:t,style:{"margin-right":`8px`}},[g(a(`input`,{type:`radio`,id:`os-`+e.os,value:e.os,"onUpdate:modelValue":l[0]||=e=>N.value=e},null,8,re),[[r,N.value]]),a(`label`,{for:`os-`+e.os},_(e.label),9,ie)])),64))]),a(`div`,ae,[g(a(`select`,{"onUpdate:modelValue":l[1]||
|