Files
static-php-cli/assets/chunks/CliGenerator.D-ObJ0G5.js

19 lines
14 KiB
JavaScript
Raw Normal View History

import{d as ue,x as d,h as f,z as re,c as r,o as c,e as P,j as e,a3 as i,k as ce,a as H,t,G as z,H as B,ak as g,al as A,a4 as D,am as Z,n as R,_ as ve}from"./framework.C2AwuPrQ.js";import{d as F}from"./extensions.data.B9rRhpZ-.js";const pe={key:0,class:"warning custom-block",style:{"margin-bottom":"16px"}},me={class:"option-line"},be=["id","value"],ye=["for"],ge={class:"option-line"},fe=["disabled"],we={class:"box"},he=["placeholder"],xe=["id","value"],Ce=["for"],Se={style:{color:"orangered","font-weight":"bolder"}},ke={class:"box"},Pe=["id","value"],$e=["for"],Ne={key:3,class:"warning custom-block"},Ie={value:"spc"},Ve={value:"native"},Ue=["value"],Ee={value:""},Te={for:"zts-yes"},ze={for:"zts-no"},Be={for:"pre-built-yes"},Ae={for:"pre-built-no"},De={key:0},Re={for:"upx-yes"},Ge={for:"upx-no"},Oe={for:"nostrip-yes"},We={for:"nostrip-no"},qe=["placeholder"],Le={key:4,class:"command-container"},Xe={key:0,class:"command-preview"},je={class:"command-content"},Me={key:1},He={class:"warning custom-block"},Ze={class:"command-container"},Fe={class:"command-preview"},Ke={class:"command-content"},Ye={class:"command-container"},Je={class:"command-preview"},Qe={class:"command-content"},_e={class:"command-container"},el={class:"command-preview pre"},ll={class:"command-content"},nl={name:"CliGenerator"},tl=ue({...nl,props:{lang:{type:String,default:"zh"}},setup(o){const K=["cli","fpm","micro","embed","frankenphp","cgi"],Y=["8.0","8.1","8.2","8.3","8.4","8.5"],J=F.missing??!1,Q=F.extensions??[],w=d(""),m=d([]),b=d(["cli"]),$=d("spc"),N=d("8.4"),u=d("linux"),I=d("x86_64"),h=d(""),C=d(!1),S=d(!0),x=d(!1),k=d(!1),V=d(10),U=d(5),E=d(""),v=d({spcDownload:!1,doctor:!1,build:!1,craft:!1}),_=[{os:"linux",label:"Linux"},{os:"macos",label:"macOS"},{os:"windows",label:"Windows"}],G=f(()=>Q.filter(s=>u.value==="linux"?s.linux:u.value==="macos"?s.macos:u.value==="windows"?s.windows:!0).map(s=>s.name)),W=f(()=>[...m.value].sort().join(",")),q=f(()=>$.value==="native"?"bin/spc":u.value==="windows"?".\\spc.exe":"./spc"),L=f(()=>{const s=u.value==="macos"?"macos":"linux",l=I.value;return`curl -#fSL https://dl.static-php.dev/v3/spc-bin/latest/spc-${s}-${l} -o spc && chmod +x spc`}),X=f(()=>`${q.value} doctor --auto-fix`),ee=f(()=>{const s=E.value.split(`
`).filter(l=>l.indexOf("=")>=1);return s.length>0?" "+s.map(l=>`-I "${l}"`).join(" "):""}),j=f(()=>{const s=b.value.map(de=>`--build-${de}`).join(" "),l=` --dl-with-php=${N.value}`,n=` --dl-parallel=${V.value}`,p=` --dl-retry=${U.value}`,y=" --dl-ignore-cache=php-src",te=S.value?" --dl-prefer-binary":"",oe=k.value?" --no-strip":"",ae=x.value?" --with-upx-pack":"",se=C.value?" --enable-zts":"",ie=h.value?` ${h.value}`:"";return`${q.value} build:php "${W.value}" ${s}${l}${n}${p}${y}${te}${oe}${ae}${se}${ee.value}${ie}`}),M=f(()=>{let s=`php-version: ${N.value}
`;s+=`extensions: "${W.value}"
`,b.value.length===1?s+=`sapi:
- ${b.value[0]}
`:(s+=`sapi:
`,b.value.forEach(y=>{s+=` - ${y}
`}));const l={"-v":64,"-vv":128,"-vvv":256};h.value&&l[h.value]&&(s+=`verbosity: ${l[h.value]}
`),s+=`download-options:
`,s+=` parallel: ${V.value}
`,s+=` retry: ${U.value}
`,s+=` ignore-cache: php-src
`,S.value&&(s+=` prefer-binary: true
`);const n=[];k.value&&n.push(" no-strip: true"),x.value&&n.push(" with-upx-pack: true"),C.value&&n.push(" enable-zts: true");const p=E.value.split(`
`).filter(y=>y.indexOf("=")>=1);return p.length>0&&(n.push(" with-hardcoded-ini:"),p.forEach(y=>n.push(` - "${y}"`))),n.length>0&&(s+=`build-options:
${n.join(`
`)}
`),s}),le=()=>{const s=["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"],l=new Set(G.value);m.value=s.filter(n=>l.has(n))},ne=()=>{m.value=[...G.value]},O=(s,l)=>{if(!w.value||!s.includes(w.value))return l===0?s:"";const n=s.indexOf(w.value);switch(l){case 0:return s.substring(0,n);case 1:return w.value;case 2:return s.substring(n+w.value.length);default:return""}},T=async(s,l)=>{try{await navigator.clipboard.writeText(s),v.value[l]=!0,setTimeout(()=>{v.value[l]=!1},2e3)}catch{const n=document.createElement("textarea");n.value=s,document.body.appendChild(n),n.select(),document.execCommand("copy"),document.body.removeChild(n)}};re(u,()=>{u.value==="windows"&&(I.value="x86_64",x.value=!1),m.value=[]});const a={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、embed、frankenphp 构建!",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, embed and frankenphp 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(s,l)=>(c(),r("div",null,[ce(J)?(c(),r("div",pe,[...l[24]||(l[24]=[e("p",{class:"custom-block-title"},"WARNING",-1),e("p",null,[H("Extension list is not generated yet. Run "),e("code",null,"bin/spc dev:gen-ext-docs"),H(" to generate it.")],-1)])])):P("",!0),e("h2",null,t(a[o.lang].selectedSystem),1),e("div",me,[(c(),r(z,null,B(_,(n,p)=>e("span",{key:p,style:{"margin-right":"8px"}},[i(e("input",{type:"radio",id:"os-"+n.os,value:n.os,"onUpdate:modelValue":l[0]||(l[0]=y=>u.value=y)},null,