@php-wasm/cli-util
Advanced tools
| /// <reference types="node" /> | ||
| interface CLIOutputOptions { | ||
| /** Verbosity level: 'quiet', 'normal', or 'debug' */ | ||
| verbosity: string; | ||
| /** Output stream to write to. Defaults to process.stdout */ | ||
| writeStream?: NodeJS.WriteStream; | ||
| } | ||
| export declare class CLIOutput { | ||
| private verbosity; | ||
| protected writeStream: NodeJS.WriteStream; | ||
| constructor(options: CLIOutputOptions); | ||
| get isTTY(): boolean; | ||
| get isQuiet(): boolean; | ||
| /** | ||
| * ANSI formatting helpers. | ||
| * | ||
| * These only apply color codes when outputting to a terminal (TTY). | ||
| * When piped to files or non-TTY streams, they return plain text to | ||
| * avoid polluting logs with escape sequences. | ||
| */ | ||
| bold(text: string): string; | ||
| dim(text: string): string; | ||
| italic(text: string): string; | ||
| red(text: string): string; | ||
| green(text: string): string; | ||
| yellow(text: string): string; | ||
| cyan(text: string): string; | ||
| highlight(text: string): string; | ||
| print(message: string): void; | ||
| printError(message: string): void; | ||
| printWarning(message: string): void; | ||
| } | ||
| export {}; |
+14
-11
@@ -1,9 +0,12 @@ | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("fs"),w=require("path"),D=require("@php-wasm/util"),C=require("fast-xml-parser"),B=require("jsonc-parser");function H(c){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const r in c)if(r!=="default"){const d=Object.getOwnPropertyDescriptor(c,r);Object.defineProperty(f,r,d.get?d:{enumerable:!0,get:()=>c[r]})}}return f.default=c,Object.freeze(f)}const x=H(B),M="PHPWASMCLI",R=["/dev/","/home/","/internal/","/request/","/proc/"];async function q(c,f,r){const d=r==="win32"?"junction":"dir";p.symlinkSync(c,f,d)}async function V(c){try{p.lstatSync(c).isSymbolicLink()&&p.unlinkSync(c)}catch{}}function X(c,f){return f.filter(r=>{const d=w.resolve(r.hostPath),u=w.join(c,w.sep);return d===c||d.startsWith(u)})}const E={ignoreAttributes:!1,attributeNamePrefix:"",preserveOrder:!0,cdataPropName:"__cdata",commentPropName:"__xmlComment",allowBooleanAttributes:!0,trimValues:!0},F={ignoreAttributes:E.ignoreAttributes,attributeNamePrefix:E.attributeNamePrefix,preserveOrder:E.preserveOrder,cdataPropName:E.cdataPropName,commentPropName:E.commentPropName,suppressBooleanAttributes:!E.allowBooleanAttributes,format:!0,indentBy:" "},I={allowEmptyContent:!0,allowTrailingComma:!0};function $(c,f){var S,b,k,L,T,_;const{name:r,host:d,port:u,pathMappings:h,ideKey:t}=f,P=new C.XMLParser(E),v=(()=>{try{return P.parse(c,!0)}catch{throw new Error("PhpStorm configuration file is not valid XML.")}})(),y={server:[{}],":@":{name:r,host:`${d}:${u}`,use_path_mappings:"true"}};h&&h.length&&(y.server[0].path_mappings=h.map(n=>({mapping:[],":@":{"local-root":`$PROJECT_DIR$/${D.toPosixPath(w.relative(f.projectDir,n.hostPath))}`,"remote-root":n.vfsPath}})));let l=v==null?void 0:v.find(n=>!!(n!=null&&n.project));if(l){const n=(S=l[":@"])==null?void 0:S.version;if(n===void 0)throw new Error('PhpStorm IDE integration only supports <project version="4"> in workspace.xml, but the <project> configuration has no version number.');if(n!=="4")throw new Error(`PhpStorm IDE integration only supports <project version="4"> in workspace.xml, but we found a <project> configuration with version "${n}".`)}l===void 0&&(l={project:[],":@":{version:"4"}},v.push(l));let o=(b=l.project)==null?void 0:b.find(n=>{var j;return!!(n!=null&&n.component)&&((j=n==null?void 0:n[":@"])==null?void 0:j.name)==="PhpServers"});o===void 0&&(o={component:[],":@":{name:"PhpServers"}},l.project===void 0&&(l.project=[]),l.project.push(o));let i=(k=o.component)==null?void 0:k.find(n=>!!(n!=null&&n.servers));i===void 0&&(i={servers:[]},o.component===void 0&&(o.component=[]),o.component.push(i));const s=(L=i.servers)==null?void 0:L.findIndex(n=>{var j;return!!(n!=null&&n.server)&&((j=n==null?void 0:n[":@"])==null?void 0:j.name)===r});(s===void 0||s<0)&&(i.servers===void 0&&(i.servers=[]),i.servers.push(y));let e=(T=l.project)==null?void 0:T.find(n=>{var j;return!!(n!=null&&n.component)&&((j=n==null?void 0:n[":@"])==null?void 0:j.name)==="RunManager"});if(e===void 0&&(e={component:[],":@":{name:"RunManager"}},l.project===void 0&&(l.project=[]),l.project.push(e)),(((_=e.component)==null?void 0:_.findIndex(n=>{var j;return!!(n!=null&&n.configuration)&&((j=n==null?void 0:n[":@"])==null?void 0:j.name)===r}))??-1)<0){const n={configuration:[{method:[],":@":{v:"2"}}],":@":{name:r,type:"PhpRemoteDebugRunConfigurationType",factoryName:"PHP Remote Debug",filter_connections:"FILTER",server_name:r,session_id:t}};e.component===void 0&&(e.component=[]),e.component.push(n)}const m=new C.XMLBuilder(F).build(v);try{P.parse(m,!0)}catch{throw new Error("The resulting PhpStorm configuration file is not valid XML.")}return m}function A(c,f){var l,o,i,s;const{pathSkippings:r}=f,d=new C.XMLParser(E),u=(()=>{try{return d.parse(c,!0)}catch{throw new Error("PhpStorm PHP configuration file is not valid XML.")}})();let h=u==null?void 0:u.find(e=>!!(e!=null&&e.project));if(h){const e=(l=h[":@"])==null?void 0:l.version;if(e===void 0)throw new Error('PhpStorm IDE integration only supports <project version="4"> in php.xml, but the <project> configuration has no version number.');if(e!=="4")throw new Error(`PhpStorm IDE integration only supports <project version="4"> in php.xml, but we found a <project> configuration with version "${e}".`)}h===void 0&&(h={project:[],":@":{version:"4"}},u.push(h));let t=(o=h.project)==null?void 0:o.find(e=>{var a;return!!(e!=null&&e.component)&&((a=e==null?void 0:e[":@"])==null?void 0:a.name)==="PhpStepFilterConfiguration"});t===void 0&&(t={component:[],":@":{name:"PhpStepFilterConfiguration"}},h.project===void 0&&(h.project=[]),h.project.push(t));let P=(i=t.component)==null?void 0:i.find(e=>!!(e!=null&&e.skipped_files));if(P===void 0&&(P={skipped_files:[]},t.component===void 0&&(t.component=[]),t.component.push(P)),r&&r.length)for(const e of r){const g=`$PROJECT_DIR$${e.endsWith("/")?e.slice(0,-1):e}`;((s=P.skipped_files)==null?void 0:s.some(S=>{var b;return!!(S!=null&&S.skipped_file)&&((b=S==null?void 0:S[":@"])==null?void 0:b.file)===g}))||(P.skipped_files===void 0&&(P.skipped_files=[]),P.skipped_files.push({skipped_file:[],":@":{file:g}}))}const y=new C.XMLBuilder(F).build(u);try{d.parse(y,!0)}catch{throw new Error("The resulting PhpStorm PHP configuration file is not valid XML.")}return y}function O(c,f){var l,o;const{name:r,pathMappings:d,pathSkippings:u}=f,h=[];let t=c,P=x.parseTree(t,h,I);if(P===void 0||h.length)throw new Error("VS Code configuration file is not valid JSON.");let v=x.findNodeAtLocation(P,["configurations"]);if(v===void 0||v.children===void 0){const i=x.modify(t,["configurations"],[],{});t=x.applyEdits(t,i),P=x.parseTree(t,[],I),v=x.findNodeAtLocation(P,["configurations"])}const y=(l=v==null?void 0:v.children)==null?void 0:l.findIndex(i=>{var s;return((s=x.findNodeAtLocation(i,["name"]))==null?void 0:s.value)===r});if(y===void 0||y<0){const i={name:r,type:"php",request:"launch",port:9003};d&&d.length&&(i.pathMappings=d.reduce((a,g)=>(a[g.vfsPath]=`\${workspaceFolder}/${D.toPosixPath(w.relative(f.workspaceDir,g.hostPath))}`,a),{})),u&&u.length&&(i.skipFiles=u.map(a=>a.endsWith("/")?`${a}**`:a));const s=((o=v==null?void 0:v.children)==null?void 0:o.length)||0,e=x.modify(t,["configurations",s],i,{formattingOptions:{insertSpaces:!0,tabSize:4,eol:` | ||
| `}});t=N(t,e)}return t}async function J({name:c,ides:f,host:r,port:d,cwd:u,mounts:h,pathSkippings:t,ideKey:P=M}){const v=h?X(u,h):[],y={};if(f.includes("phpstorm")){const l=".idea/workspace.xml",o=w.join(u,l);if(!p.existsSync(o)){if(p.existsSync(w.dirname(o)))p.writeFileSync(o,`<?xml version="1.0" encoding="UTF-8"?> | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("fs"),x=require("path"),B=require("@php-wasm/util"),C=require("fast-xml-parser"),N=require("jsonc-parser");function H(c){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const i in c)if(i!=="default"){const u=Object.getOwnPropertyDescriptor(c,i);Object.defineProperty(e,i,u.get?u:{enumerable:!0,get:()=>c[i]})}}return e.default=c,Object.freeze(e)}const w=H(N);class R{constructor(e){this.verbosity=e.verbosity,this.writeStream=e.writeStream||process.stdout}get isTTY(){return!!this.writeStream.isTTY}get isQuiet(){return this.verbosity==="quiet"}bold(e){return this.isTTY?`\x1B[1m${e}\x1B[0m`:e}dim(e){return this.isTTY?`\x1B[2m${e}\x1B[0m`:e}italic(e){return this.isTTY?`\x1B[3m${e}\x1B[0m`:e}red(e){return this.isTTY?`\x1B[31m${e}\x1B[0m`:e}green(e){return this.isTTY?`\x1B[32m${e}\x1B[0m`:e}yellow(e){return this.isTTY?`\x1B[33m${e}\x1B[0m`:e}cyan(e){return this.isTTY?`\x1B[36m${e}\x1B[0m`:e}highlight(e){return this.yellow(e)}print(e){this.isQuiet||this.writeStream.write(`${e} | ||
| `)}printError(e){this.writeStream.write(`${this.red("Error:")} ${e} | ||
| `)}printWarning(e){this.isQuiet||this.writeStream.write(`${this.yellow("Warning:")} ${e} | ||
| `)}}const _="PHPWASMCLI",Y=["/dev/","/home/","/internal/","/request/","/proc/"];async function q(c,e,i){const u=i==="win32"?"junction":"dir";l.symlinkSync(c,e,u)}async function V(c){try{l.lstatSync(c).isSymbolicLink()&&l.unlinkSync(c)}catch{}}function D(c,e){return e.filter(i=>{const u=x.resolve(i.hostPath),d=x.join(c,x.sep);return u===c||u.startsWith(d)})}const E={ignoreAttributes:!1,attributeNamePrefix:"",preserveOrder:!0,cdataPropName:"__cdata",commentPropName:"__xmlComment",allowBooleanAttributes:!0,trimValues:!0},b={ignoreAttributes:E.ignoreAttributes,attributeNamePrefix:E.attributeNamePrefix,preserveOrder:E.preserveOrder,cdataPropName:E.cdataPropName,commentPropName:E.commentPropName,suppressBooleanAttributes:!E.allowBooleanAttributes,format:!0,indentBy:" "},F={allowEmptyContent:!0,allowTrailingComma:!0};function M(c,e){var S,T,I,L,$,k;const{name:i,host:u,port:d,pathMappings:h,ideKey:o}=e,P=new C.XMLParser(E),v=(()=>{try{return P.parse(c,!0)}catch{throw new Error("PhpStorm configuration file is not valid XML.")}})(),y={server:[{}],":@":{name:i,host:`${u}:${d}`,use_path_mappings:"true"}};h&&h.length&&(y.server[0].path_mappings=h.map(n=>({mapping:[],":@":{"local-root":`$PROJECT_DIR$/${B.toPosixPath(x.relative(e.projectDir,n.hostPath))}`,"remote-root":n.vfsPath}})));let f=v==null?void 0:v.find(n=>!!(n!=null&&n.project));if(f){const n=(S=f[":@"])==null?void 0:S.version;if(n===void 0)throw new Error('PhpStorm IDE integration only supports <project version="4"> in workspace.xml, but the <project> configuration has no version number.');if(n!=="4")throw new Error(`PhpStorm IDE integration only supports <project version="4"> in workspace.xml, but we found a <project> configuration with version "${n}".`)}f===void 0&&(f={project:[],":@":{version:"4"}},v.push(f));let r=(T=f.project)==null?void 0:T.find(n=>{var j;return!!(n!=null&&n.component)&&((j=n==null?void 0:n[":@"])==null?void 0:j.name)==="PhpServers"});r===void 0&&(r={component:[],":@":{name:"PhpServers"}},f.project===void 0&&(f.project=[]),f.project.push(r));let s=(I=r.component)==null?void 0:I.find(n=>!!(n!=null&&n.servers));s===void 0&&(s={servers:[]},r.component===void 0&&(r.component=[]),r.component.push(s));const a=(L=s.servers)==null?void 0:L.findIndex(n=>{var j;return!!(n!=null&&n.server)&&((j=n==null?void 0:n[":@"])==null?void 0:j.name)===i});(a===void 0||a<0)&&(s.servers===void 0&&(s.servers=[]),s.servers.push(y));let t=($=f.project)==null?void 0:$.find(n=>{var j;return!!(n!=null&&n.component)&&((j=n==null?void 0:n[":@"])==null?void 0:j.name)==="RunManager"});if(t===void 0&&(t={component:[],":@":{name:"RunManager"}},f.project===void 0&&(f.project=[]),f.project.push(t)),(((k=t.component)==null?void 0:k.findIndex(n=>{var j;return!!(n!=null&&n.configuration)&&((j=n==null?void 0:n[":@"])==null?void 0:j.name)===i}))??-1)<0){const n={configuration:[{method:[],":@":{v:"2"}}],":@":{name:i,type:"PhpRemoteDebugRunConfigurationType",factoryName:"PHP Remote Debug",filter_connections:"FILTER",server_name:i,session_id:o}};t.component===void 0&&(t.component=[]),t.component.push(n)}const m=new C.XMLBuilder(b).build(v);try{P.parse(m,!0)}catch{throw new Error("The resulting PhpStorm configuration file is not valid XML.")}return m}function X(c,e){var f,r,s,a;const{pathSkippings:i}=e,u=new C.XMLParser(E),d=(()=>{try{return u.parse(c,!0)}catch{throw new Error("PhpStorm PHP configuration file is not valid XML.")}})();let h=d==null?void 0:d.find(t=>!!(t!=null&&t.project));if(h){const t=(f=h[":@"])==null?void 0:f.version;if(t===void 0)throw new Error('PhpStorm IDE integration only supports <project version="4"> in php.xml, but the <project> configuration has no version number.');if(t!=="4")throw new Error(`PhpStorm IDE integration only supports <project version="4"> in php.xml, but we found a <project> configuration with version "${t}".`)}h===void 0&&(h={project:[],":@":{version:"4"}},d.push(h));let o=(r=h.project)==null?void 0:r.find(t=>{var p;return!!(t!=null&&t.component)&&((p=t==null?void 0:t[":@"])==null?void 0:p.name)==="PhpStepFilterConfiguration"});o===void 0&&(o={component:[],":@":{name:"PhpStepFilterConfiguration"}},h.project===void 0&&(h.project=[]),h.project.push(o));let P=(s=o.component)==null?void 0:s.find(t=>!!(t!=null&&t.skipped_files));if(P===void 0&&(P={skipped_files:[]},o.component===void 0&&(o.component=[]),o.component.push(P)),i&&i.length)for(const t of i){const g=`$PROJECT_DIR$${t.endsWith("/")?t.slice(0,-1):t}`;((a=P.skipped_files)==null?void 0:a.some(S=>{var T;return!!(S!=null&&S.skipped_file)&&((T=S==null?void 0:S[":@"])==null?void 0:T.file)===g}))||(P.skipped_files===void 0&&(P.skipped_files=[]),P.skipped_files.push({skipped_file:[],":@":{file:g}}))}const y=new C.XMLBuilder(b).build(d);try{u.parse(y,!0)}catch{throw new Error("The resulting PhpStorm PHP configuration file is not valid XML.")}return y}function O(c,e){var f,r;const{name:i,pathMappings:u,pathSkippings:d}=e,h=[];let o=c,P=w.parseTree(o,h,F);if(P===void 0||h.length)throw new Error("VS Code configuration file is not valid JSON.");let v=w.findNodeAtLocation(P,["configurations"]);if(v===void 0||v.children===void 0){const s=w.modify(o,["configurations"],[],{});o=w.applyEdits(o,s),P=w.parseTree(o,[],F),v=w.findNodeAtLocation(P,["configurations"])}const y=(f=v==null?void 0:v.children)==null?void 0:f.findIndex(s=>{var a;return((a=w.findNodeAtLocation(s,["name"]))==null?void 0:a.value)===i});if(y===void 0||y<0){const s={name:i,type:"php",request:"launch",port:9003};u&&u.length&&(s.pathMappings=u.reduce((p,g)=>(p[g.vfsPath]=`\${workspaceFolder}/${B.toPosixPath(x.relative(e.workspaceDir,g.hostPath))}`,p),{})),d&&d.length&&(s.skipFiles=d.map(p=>p.endsWith("/")?`${p}**`:p));const a=((r=v==null?void 0:v.children)==null?void 0:r.length)||0,t=w.modify(o,["configurations",a],s,{formattingOptions:{insertSpaces:!0,tabSize:4,eol:` | ||
| `}});o=A(o,t)}return o}async function W({name:c,ides:e,host:i,port:u,cwd:d,mounts:h,pathSkippings:o,ideKey:P=_}){const v=h?D(d,h):[],y={};if(e.includes("phpstorm")){const f=".idea/workspace.xml",r=x.join(d,f);if(!l.existsSync(r)){if(l.existsSync(x.dirname(r)))l.writeFileSync(r,`<?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| </project>`);else if(f.length==1)throw new Error("PhpStorm IDE integration requested, but no '.idea' directory was found in the current working directory.")}if(p.existsSync(o)){const i=p.readFileSync(o,"utf8"),s=$(i,{name:c,host:r,port:d,projectDir:u,pathMappings:v,ideKey:P});p.writeFileSync(o,s),y.phpstorm=l}if(t&&t.length){const i=".idea/php.xml",s=w.join(u,i);if(p.existsSync(s)||p.existsSync(w.dirname(s))&&p.writeFileSync(s,`<?xml version="1.0" encoding="UTF-8"?> | ||
| </project>`);else if(e.length==1)throw new Error("PhpStorm IDE integration requested, but no '.idea' directory was found in the current working directory.")}if(l.existsSync(r)){const s=l.readFileSync(r,"utf8"),a=M(s,{name:c,host:i,port:u,projectDir:d,pathMappings:v,ideKey:P});l.writeFileSync(r,a),y.phpstorm=f}if(o&&o.length){const s=".idea/php.xml",a=x.join(d,s);if(l.existsSync(a)||l.existsSync(x.dirname(a))&&l.writeFileSync(a,`<?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| </project>`),p.existsSync(s)){const e=p.readFileSync(s,"utf8"),a=A(e,{pathSkippings:t});p.writeFileSync(s,a),y["phpstorm-php"]=i}}}if(f.includes("vscode")){const l=".vscode/launch.json",o=w.join(u,l);if(!p.existsSync(o)){if(p.existsSync(w.dirname(o)))p.writeFileSync(o,`{ | ||
| </project>`),l.existsSync(a)){const t=l.readFileSync(a,"utf8"),p=X(t,{pathSkippings:o});l.writeFileSync(a,p),y["phpstorm-php"]=s}}}if(e.includes("vscode")){const f=".vscode/launch.json",r=x.join(d,f);if(!l.existsSync(r)){if(l.existsSync(x.dirname(r)))l.writeFileSync(r,`{ | ||
| "configurations": [] | ||
| }`);else if(f.length==1)throw new Error("VS Code IDE integration requested, but no '.vscode' directory was found in the current working directory.")}if(p.existsSync(o)){const i=p.readFileSync(o,"utf-8"),s=O(i,{name:c,workspaceDir:u,pathMappings:v,pathSkippings:t});s!==i&&(p.writeFileSync(o,s),y.vscode=l)}}return y}async function U(c,f){var h,t,P,v,y;const r=w.join(f,".idea/workspace.xml");if(p.existsSync(r)){const l=p.readFileSync(r,"utf8"),o=new C.XMLParser(E),i=(()=>{try{return o.parse(l,!0)}catch{throw new Error("PhpStorm configuration file is not valid XML.")}})(),s=i.find(m=>!!(m!=null&&m.project)),e=(h=s==null?void 0:s.project)==null?void 0:h.find(m=>{var S;return!!(m!=null&&m.component)&&((S=m==null?void 0:m[":@"])==null?void 0:S.name)==="PhpServers"}),a=(t=e==null?void 0:e.component)==null?void 0:t.find(m=>!!(m!=null&&m.servers)),g=(P=a==null?void 0:a.servers)==null?void 0:P.findIndex(m=>{var S;return!!(m!=null&&m.server)&&((S=m==null?void 0:m[":@"])==null?void 0:S.name)===c});if(g!==void 0&&g>=0){a.servers.splice(g,1);const S=new C.XMLBuilder(F).build(i);try{o.parse(S,!0)}catch{throw new Error("The resulting PhpStorm configuration file is not valid XML.")}S===`<?xml version="1.0" encoding="UTF-8"?> | ||
| }`);else if(e.length==1)throw new Error("VS Code IDE integration requested, but no '.vscode' directory was found in the current working directory.")}if(l.existsSync(r)){const s=l.readFileSync(r,"utf-8"),a=O(s,{name:c,workspaceDir:d,pathMappings:v,pathSkippings:o});a!==s&&(l.writeFileSync(r,a),y.vscode=f)}}return y}async function J(c,e){var h,o,P,v,y;const i=x.join(e,".idea/workspace.xml");if(l.existsSync(i)){const f=l.readFileSync(i,"utf8"),r=new C.XMLParser(E),s=(()=>{try{return r.parse(f,!0)}catch{throw new Error("PhpStorm configuration file is not valid XML.")}})(),a=s.find(m=>!!(m!=null&&m.project)),t=(h=a==null?void 0:a.project)==null?void 0:h.find(m=>{var S;return!!(m!=null&&m.component)&&((S=m==null?void 0:m[":@"])==null?void 0:S.name)==="PhpServers"}),p=(o=t==null?void 0:t.component)==null?void 0:o.find(m=>!!(m!=null&&m.servers)),g=(P=p==null?void 0:p.servers)==null?void 0:P.findIndex(m=>{var S;return!!(m!=null&&m.server)&&((S=m==null?void 0:m[":@"])==null?void 0:S.name)===c});if(g!==void 0&&g>=0){p.servers.splice(g,1);const S=new C.XMLBuilder(b).build(s);try{r.parse(S,!0)}catch{throw new Error("The resulting PhpStorm configuration file is not valid XML.")}S===`<?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
@@ -13,8 +16,8 @@ <component name="PhpServers"> | ||
| </component> | ||
| </project>`?p.unlinkSync(r):p.writeFileSync(r,S)}}const d=w.join(f,".idea/php.xml");if(p.existsSync(d)){const l=p.readFileSync(d,"utf8"),o=new C.XMLParser(E),i=(()=>{try{return o.parse(l,!0)}catch{throw new Error("PhpStorm PHP configuration file is not valid XML.")}})(),s=i.find(a=>!!(a!=null&&a.project)),e=(v=s==null?void 0:s.project)==null?void 0:v.findIndex(a=>{var g;return!!(a!=null&&a.component)&&((g=a==null?void 0:a[":@"])==null?void 0:g.name)==="PhpStepFilterConfiguration"});if(e!==void 0&&e>=0){s.project.splice(e,1);const g=new C.XMLBuilder(F).build(i);try{o.parse(g,!0)}catch{throw new Error("The resulting PhpStorm PHP configuration file is not valid XML.")}g===`<?xml version="1.0" encoding="UTF-8"?> | ||
| </project>`?l.unlinkSync(i):l.writeFileSync(i,S)}}const u=x.join(e,".idea/php.xml");if(l.existsSync(u)){const f=l.readFileSync(u,"utf8"),r=new C.XMLParser(E),s=(()=>{try{return r.parse(f,!0)}catch{throw new Error("PhpStorm PHP configuration file is not valid XML.")}})(),a=s.find(p=>!!(p!=null&&p.project)),t=(v=a==null?void 0:a.project)==null?void 0:v.findIndex(p=>{var g;return!!(p!=null&&p.component)&&((g=p==null?void 0:p[":@"])==null?void 0:g.name)==="PhpStepFilterConfiguration"});if(t!==void 0&&t>=0){a.project.splice(t,1);const g=new C.XMLBuilder(b).build(s);try{r.parse(g,!0)}catch{throw new Error("The resulting PhpStorm PHP configuration file is not valid XML.")}g===`<?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| </project>`?p.unlinkSync(d):p.writeFileSync(d,g)}}const u=w.join(f,".vscode/launch.json");if(p.existsSync(u)){const l=[],o=p.readFileSync(u,"utf-8"),i=x.parseTree(o,l,I);if(i===void 0||l.length)throw new Error("VS Code configuration file is not valid JSON.");const s=x.findNodeAtLocation(i,["configurations"]),e=(y=s==null?void 0:s.children)==null?void 0:y.findIndex(a=>{var g;return((g=x.findNodeAtLocation(a,["name"]))==null?void 0:g.value)===c});if(e!==void 0&&e>=0){const a=x.modify(o,["configurations",e],void 0,{formattingOptions:{insertSpaces:!0,tabSize:4,eol:` | ||
| `}}),g=N(o,a);g===`{ | ||
| </project>`?l.unlinkSync(u):l.writeFileSync(u,g)}}const d=x.join(e,".vscode/launch.json");if(l.existsSync(d)){const f=[],r=l.readFileSync(d,"utf-8"),s=w.parseTree(r,f,F);if(s===void 0||f.length)throw new Error("VS Code configuration file is not valid JSON.");const a=w.findNodeAtLocation(s,["configurations"]),t=(y=a==null?void 0:a.children)==null?void 0:y.findIndex(p=>{var g;return((g=w.findNodeAtLocation(p,["name"]))==null?void 0:g.value)===c});if(t!==void 0&&t>=0){const p=w.modify(r,["configurations",t],void 0,{formattingOptions:{insertSpaces:!0,tabSize:4,eol:` | ||
| `}}),g=A(r,p);g===`{ | ||
| "configurations": [] | ||
| }`?p.unlinkSync(u):p.writeFileSync(u,g)}}}function W({cwd:c,mounts:f,pathSkippings:r}){return{pathMappings:c&&f?X(c,f):void 0,pathSkippings:r}}function N(c,f){const r=[],d=x.applyEdits(c,f);if(r.length=0,x.parseTree(d,r,I),r.length){const u=r.map(t=>({message:x.printParseErrorCode(t.error),offset:t.offset,length:t.length,fragment:d.slice(Math.max(0,t.offset-20),Math.min(d.length,t.offset+t.length+10))})).map(t=>`${t.message} at ${t.offset}:${t.length} (${t.fragment})`),h=f.map(t=>`At ${t.offset}:${t.length} - (${t.content})`);throw new Error(`VS Code configuration file (.vscode/launch.json) is not valid a JSONC after CLI modifications. This is likely a CLI bug. Please report it at https://github.com/WordPress/wordpress-playground/issues and include the contents of your ".vscode/launch.json" file. | ||
| }`?l.unlinkSync(d):l.writeFileSync(d,g)}}}function U({cwd:c,mounts:e,pathSkippings:i}){return{pathMappings:c&&e?D(c,e):void 0,pathSkippings:i}}function A(c,e){const i=[],u=w.applyEdits(c,e);if(i.length=0,w.parseTree(u,i,F),i.length){const d=i.map(o=>({message:w.printParseErrorCode(o.error),offset:o.offset,length:o.length,fragment:u.slice(Math.max(0,o.offset-20),Math.min(u.length,o.offset+o.length+10))})).map(o=>`${o.message} at ${o.offset}:${o.length} (${o.fragment})`),h=e.map(o=>`At ${o.offset}:${o.length} - (${o.content})`);throw new Error(`VS Code configuration file (.vscode/launch.json) is not valid a JSONC after CLI modifications. This is likely a CLI bug. Please report it at https://github.com/WordPress/wordpress-playground/issues and include the contents of your ".vscode/launch.json" file. | ||
@@ -24,4 +27,4 @@ Applied edits: ${h.join(` | ||
| The errors are: ${u.join(` | ||
| `)}`)}return d}exports.DEFAULT_IDE_KEY=M;exports.DEFAULT_PATH_SKIPPINGS=R;exports.addXdebugIDEConfig=J;exports.clearXdebugIDEConfig=U;exports.createTempDirSymlink=q;exports.makeXdebugConfig=W;exports.removeTempDirSymlink=V;exports.updatePhpStormPHPConfig=A;exports.updatePhpStormWorkspaceConfig=$;exports.updateVSCodeConfig=O; | ||
| The errors are: ${d.join(` | ||
| `)}`)}return u}exports.CLIOutput=R;exports.DEFAULT_IDE_KEY=_;exports.DEFAULT_PATH_SKIPPINGS=Y;exports.addXdebugIDEConfig=W;exports.clearXdebugIDEConfig=J;exports.createTempDirSymlink=q;exports.makeXdebugConfig=U;exports.removeTempDirSymlink=V;exports.updatePhpStormPHPConfig=X;exports.updatePhpStormWorkspaceConfig=M;exports.updateVSCodeConfig=O; | ||
| //# sourceMappingURL=index.cjs.map |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.cjs","sources":["../../../../packages/php-wasm/cli-util/src/lib/xdebug-path-mappings.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { toPosixPath } from '@php-wasm/util';\nimport type { Mount } from './mounts';\nimport {\n\ttype X2jOptions,\n\ttype XmlBuilderOptions,\n\tXMLParser,\n\tXMLBuilder,\n} from 'fast-xml-parser';\nimport * as JSONC from 'jsonc-parser';\n\nexport interface XdebugOptions {\n\tideKey?: string;\n\tpathMappings?: Mount[];\n\tpathSkippings?: string[];\n}\n\nexport const DEFAULT_IDE_KEY = 'PHPWASMCLI';\nexport const DEFAULT_PATH_SKIPPINGS = [\n\t'/dev/',\n\t'/home/',\n\t'/internal/',\n\t'/request/',\n\t'/proc/',\n];\n\n/**\n * Create a symlink to a tempory directory.\n *\n * The symlink is created to access the system temp dir\n * inside the current debugging directory.\n *\n * @param nativeDirPath The system temp dir path.\n * @param symlinkPath The symlink name.\n */\nexport async function createTempDirSymlink(\n\tnativeDirPath: string,\n\tsymlinkPath: string,\n\tplatform: string\n) {\n\tconst type =\n\t\tplatform === 'win32'\n\t\t\t? // On Windows, creating a 'dir' symlink can require elevated permissions.\n\t\t\t\t// In this case, let's make junction points because they function like\n\t\t\t\t// symlinks and do not require elevated permissions.\n\t\t\t\t'junction'\n\t\t\t: 'dir';\n\tfs.symlinkSync(nativeDirPath, symlinkPath, type);\n}\n\n/**\n * Remove the given temporary directory symlink if it exists.\n *\n * @param symlinkPath The symlink path.\n */\nexport async function removeTempDirSymlink(symlinkPath: string) {\n\ttry {\n\t\tconst stats = fs.lstatSync(symlinkPath);\n\t\tif (stats.isSymbolicLink()) {\n\t\t\tfs.unlinkSync(symlinkPath);\n\t\t}\n\t} catch {\n\t\t// Symlink does not exist or cannot be accessed, nothing to remove\n\t}\n}\n\n/**\n * Filters out mounts that are not in the current working directory\n *\n * @param mounts The mounts list.\n */\nfunction filterLocalMounts(cwd: string, mounts: Mount[]) {\n\treturn mounts.filter((mount) => {\n\t\tconst absoluteHostPath = path.resolve(mount.hostPath);\n\t\tconst cwdChildPrefix = path.join(cwd, path.sep);\n\t\treturn (\n\t\t\t// If auto-mounting from the current directory,\n\t\t\t// the entire project directory can be mapped.\n\t\t\tabsoluteHostPath === cwd ||\n\t\t\tabsoluteHostPath.startsWith(cwdChildPrefix)\n\t\t);\n\t});\n}\n\nexport type XdebugConfig = {\n\t/**\n\t * The current working directory to consider for debugger path mapping.\n\t */\n\tcwd?: string;\n\t/**\n\t * The mounts to consider for debugger path mapping.\n\t */\n\tmounts?: Mount[];\n\t/**\n\t * The paths to consider for debugger path skipping.\n\t */\n\tpathSkippings?: string[];\n};\n\nexport type IDEConfig = {\n\t/**\n\t * The name of the configuration within the IDE configuration.\n\t */\n\tname: string;\n\t/**\n\t * The IDEs to configure.\n\t */\n\tides: string[];\n\t/**\n\t * The web server host.\n\t */\n\thost: string;\n\t/**\n\t * The web server port.\n\t */\n\tport: number;\n\t/**\n\t * The current working directory to consider for debugger path mapping.\n\t */\n\tcwd: string;\n\t/**\n\t * The mounts to consider for debugger path mapping.\n\t */\n\tmounts?: Mount[];\n\t/**\n\t * The paths to skip when debugging.\n\t */\n\tpathSkippings?: string[];\n\t/**\n\t * The IDE key to use for the debug configuration. Defaults to 'PHPWASMCLI'.\n\t */\n\tideKey?: string;\n};\n\ntype PhpStormWorkspaceConfigMetaData = {\n\tname?: string;\n\tversion?: string;\n\thost?: string;\n\tuse_path_mappings?: string;\n\t'local-root'?: string;\n\t'remote-root'?: string;\n\ttype?: 'PhpRemoteDebugRunConfigurationType';\n\tfactoryName?: string;\n\tfilter_connections?: 'FILTER';\n\tserver_name?: string;\n\tsession_id?: string;\n\tv?: string;\n};\n\ntype PhpStormWorkspaceConfigNode = {\n\t':@'?: PhpStormWorkspaceConfigMetaData;\n\tproject?: PhpStormWorkspaceConfigNode[];\n\tcomponent?: PhpStormWorkspaceConfigNode[];\n\tservers?: PhpStormWorkspaceConfigNode[];\n\tserver?: PhpStormWorkspaceConfigNode[];\n\tpath_mappings?: PhpStormWorkspaceConfigNode[];\n\tmapping?: PhpStormWorkspaceConfigNode[];\n\tconfiguration?: PhpStormWorkspaceConfigNode[];\n\tmethod?: PhpStormWorkspaceConfigNode[];\n};\n\ntype PhpStormPHPConfigMetaData = {\n\tname?: string;\n\tversion?: string;\n\tfile?: string;\n};\n\ntype PhpStormPHPConfigNode = {\n\t':@'?: PhpStormPHPConfigMetaData;\n\tproject?: PhpStormPHPConfigNode[];\n\tcomponent?: PhpStormPHPConfigNode[];\n\tskipped_files?: PhpStormPHPConfigNode[];\n\tskipped_file?: PhpStormPHPConfigNode[];\n};\n\ntype VSCodeConfigMetaData = {\n\t[key: string]: string;\n};\n\ntype VSCodeConfigNode = {\n\tname: string;\n\ttype: string;\n\trequest: string;\n\tport: number;\n\tpathMappings?: VSCodeConfigMetaData;\n\tskipFiles?: string[];\n};\n\nconst xmlParserOptions: X2jOptions = {\n\tignoreAttributes: false,\n\tattributeNamePrefix: '',\n\tpreserveOrder: true,\n\tcdataPropName: '__cdata',\n\tcommentPropName: '__xmlComment',\n\tallowBooleanAttributes: true,\n\ttrimValues: true,\n};\nconst xmlBuilderOptions: XmlBuilderOptions = {\n\tignoreAttributes: xmlParserOptions.ignoreAttributes,\n\tattributeNamePrefix: xmlParserOptions.attributeNamePrefix,\n\tpreserveOrder: xmlParserOptions.preserveOrder,\n\tcdataPropName: xmlParserOptions.cdataPropName,\n\tcommentPropName: xmlParserOptions.commentPropName,\n\tsuppressBooleanAttributes: !xmlParserOptions.allowBooleanAttributes,\n\tformat: true,\n\tindentBy: '\\t',\n};\n\nconst jsoncParseOptions: JSONC.ParseOptions = {\n\tallowEmptyContent: true,\n\tallowTrailingComma: true,\n};\n\nexport type PhpStormWorkspaceConfigOptions = {\n\tname: string;\n\thost: string;\n\tport: number;\n\tprojectDir: string;\n\tpathMappings?: Mount[];\n\tideKey: string;\n};\n\n/**\n * Pure function to update PHPStorm XML config with Xdebug server and run configuration.\n *\n * @param xmlContent The original XML content of workspace.xml\n * @param options Configuration options for the server\n * @returns Updated XML content\n * @throws Error if XML is invalid or configuration is incompatible\n */\nexport function updatePhpStormWorkspaceConfig(\n\txmlContent: string,\n\toptions: PhpStormWorkspaceConfigOptions\n): string {\n\tconst { name, host, port, pathMappings, ideKey } = options;\n\n\tconst xmlParser = new XMLParser(xmlParserOptions);\n\n\t// Parse the XML\n\tconst config: PhpStormWorkspaceConfigNode[] = (() => {\n\t\ttry {\n\t\t\treturn xmlParser.parse(xmlContent, true);\n\t\t} catch {\n\t\t\tthrow new Error('PhpStorm configuration file is not valid XML.');\n\t\t}\n\t})();\n\n\t// Create the server element with path mappings\n\tconst serverElement: PhpStormWorkspaceConfigNode = {\n\t\tserver: [{}],\n\t\t':@': {\n\t\t\tname,\n\t\t\t// NOTE: PhpStorm quirk: Xdebug only works when the full URL (including port)\n\t\t\t// is provided in `host`. The separate `port` field is ignored or misinterpreted,\n\t\t\t// so we rely solely on host: \"host:port\".\n\t\t\thost: `${host}:${port}`,\n\t\t\tuse_path_mappings: 'true',\n\t\t},\n\t};\n\n\tif (pathMappings && pathMappings.length) {\n\t\tserverElement.server![0].path_mappings = pathMappings.map(\n\t\t\t(pathMapping) => ({\n\t\t\t\tmapping: [],\n\t\t\t\t':@': {\n\t\t\t\t\t'local-root': `$PROJECT_DIR$/${toPosixPath(\n\t\t\t\t\t\tpath.relative(options.projectDir, pathMapping.hostPath)\n\t\t\t\t\t)}`,\n\t\t\t\t\t'remote-root': pathMapping.vfsPath,\n\t\t\t\t},\n\t\t\t})\n\t\t);\n\t}\n\n\t// Find or create project element\n\tlet projectElement = config?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.project\n\t);\n\tif (projectElement) {\n\t\tconst projectVersion = projectElement[':@']?.version;\n\t\tif (projectVersion === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports <project version=\"4\"> in workspace.xml, ' +\n\t\t\t\t\t'but the <project> configuration has no version number.'\n\t\t\t);\n\t\t} else if (projectVersion !== '4') {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports <project version=\"4\"> in workspace.xml, ' +\n\t\t\t\t\t`but we found a <project> configuration with version \"${projectVersion}\".`\n\t\t\t);\n\t\t}\n\t}\n\tif (projectElement === undefined) {\n\t\tprojectElement = {\n\t\t\tproject: [],\n\t\t\t':@': { version: '4' },\n\t\t};\n\t\tconfig.push(projectElement);\n\t}\n\n\t// Find or create PhpServers component\n\tlet componentElement = projectElement.project?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'PhpServers'\n\t);\n\tif (componentElement === undefined) {\n\t\tcomponentElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'PhpServers' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(componentElement);\n\t}\n\n\t// Find or create servers element\n\tlet serversElement = componentElement.component?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.servers\n\t);\n\tif (serversElement === undefined) {\n\t\tserversElement = { servers: [] };\n\n\t\tif (componentElement.component === undefined) {\n\t\t\tcomponentElement.component = [];\n\t\t}\n\n\t\tcomponentElement.component.push(serversElement);\n\t}\n\n\t// Check if server already exists\n\tconst serverElementIndex = serversElement.servers?.findIndex(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.server && c?.[':@']?.name === name\n\t);\n\n\t// Only add server if it doesn't exist\n\tif (serverElementIndex === undefined || serverElementIndex < 0) {\n\t\tif (serversElement.servers === undefined) {\n\t\t\tserversElement.servers = [];\n\t\t}\n\n\t\tserversElement.servers.push(serverElement);\n\t}\n\n\t// Find or create RunManager component\n\tlet runManagerElement = projectElement.project?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'RunManager'\n\t);\n\tif (runManagerElement === undefined) {\n\t\trunManagerElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'RunManager' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(runManagerElement);\n\t}\n\n\t// Check if run configuration already exists\n\tconst existingConfigIndex =\n\t\trunManagerElement.component?.findIndex(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.configuration && c?.[':@']?.name === name\n\t\t) ?? -1;\n\n\t// Only add run configuration if it doesn't exist\n\tif (existingConfigIndex < 0) {\n\t\tconst runConfigElement: PhpStormWorkspaceConfigNode = {\n\t\t\tconfiguration: [\n\t\t\t\t{\n\t\t\t\t\tmethod: [],\n\t\t\t\t\t':@': { v: '2' },\n\t\t\t\t},\n\t\t\t],\n\t\t\t':@': {\n\t\t\t\tname: name,\n\t\t\t\ttype: 'PhpRemoteDebugRunConfigurationType',\n\t\t\t\tfactoryName: 'PHP Remote Debug',\n\t\t\t\tfilter_connections: 'FILTER',\n\t\t\t\tserver_name: name,\n\t\t\t\tsession_id: ideKey,\n\t\t\t},\n\t\t};\n\n\t\tif (runManagerElement.component === undefined) {\n\t\t\trunManagerElement.component = [];\n\t\t}\n\n\t\trunManagerElement.component.push(runConfigElement);\n\t}\n\n\t// Build the updated XML\n\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\tconst xml = xmlBuilder.build(config);\n\n\t// Validate the generated XML\n\ttry {\n\t\txmlParser.parse(xml, true);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'The resulting PhpStorm configuration file is not valid XML.'\n\t\t);\n\t}\n\n\treturn xml;\n}\n\nexport type PhpStormPHPConfigOptions = {\n\tpathSkippings?: string[];\n};\n\n/**\n * Pure function to update PhpStorm php.xml config with skipped files.\n *\n * @param xmlContent The original XML content of php.xml\n * @param options Configuration options for skipped files\n * @returns Updated XML content\n * @throws Error if XML is invalid or configuration is incompatible\n */\nexport function updatePhpStormPHPConfig(\n\txmlContent: string,\n\toptions: PhpStormPHPConfigOptions\n): string {\n\tconst { pathSkippings } = options;\n\n\tconst xmlParser = new XMLParser(xmlParserOptions);\n\n\tconst config: PhpStormPHPConfigNode[] = (() => {\n\t\ttry {\n\t\t\treturn xmlParser.parse(xmlContent, true);\n\t\t} catch {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm PHP configuration file is not valid XML.'\n\t\t\t);\n\t\t}\n\t})();\n\n\t// Find or create project element\n\tlet projectElement = config?.find(\n\t\t(c: PhpStormPHPConfigNode) => !!c?.project\n\t);\n\tif (projectElement) {\n\t\tconst projectVersion = projectElement[':@']?.version;\n\t\tif (projectVersion === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports ' +\n\t\t\t\t\t'<project version=\"4\"> in php.xml, ' +\n\t\t\t\t\t'but the <project> configuration has no version number.'\n\t\t\t);\n\t\t} else if (projectVersion !== '4') {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports ' +\n\t\t\t\t\t'<project version=\"4\"> in php.xml, ' +\n\t\t\t\t\t`but we found a <project> configuration ` +\n\t\t\t\t\t`with version \"${projectVersion}\".`\n\t\t\t);\n\t\t}\n\t}\n\tif (projectElement === undefined) {\n\t\tprojectElement = {\n\t\t\tproject: [],\n\t\t\t':@': { version: '4' },\n\t\t};\n\t\tconfig.push(projectElement);\n\t}\n\n\t// Find or create PhpStepFilterConfiguration component\n\tlet componentElement = projectElement.project?.find(\n\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'PhpStepFilterConfiguration'\n\t);\n\tif (componentElement === undefined) {\n\t\tcomponentElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'PhpStepFilterConfiguration' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(componentElement);\n\t}\n\n\t// Find or create skipped_files element\n\tlet skippedFilesElement = componentElement.component?.find(\n\t\t(c: PhpStormPHPConfigNode) => !!c?.skipped_files\n\t);\n\tif (skippedFilesElement === undefined) {\n\t\tskippedFilesElement = { skipped_files: [] };\n\n\t\tif (componentElement.component === undefined) {\n\t\t\tcomponentElement.component = [];\n\t\t}\n\n\t\tcomponentElement.component.push(skippedFilesElement);\n\t}\n\n\t// Add skipped files\n\tif (pathSkippings && pathSkippings.length) {\n\t\tfor (const skippedPath of pathSkippings) {\n\t\t\tconst normalizedPath = skippedPath.endsWith('/')\n\t\t\t\t? skippedPath.slice(0, -1)\n\t\t\t\t: skippedPath;\n\t\t\tconst filePath = `$PROJECT_DIR$${normalizedPath}`;\n\n\t\t\t// Check if already exists\n\t\t\tconst exists = skippedFilesElement.skipped_files?.some(\n\t\t\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t\t\t!!c?.skipped_file && c?.[':@']?.file === filePath\n\t\t\t);\n\n\t\t\tif (!exists) {\n\t\t\t\tif (skippedFilesElement.skipped_files === undefined) {\n\t\t\t\t\tskippedFilesElement.skipped_files = [];\n\t\t\t\t}\n\n\t\t\t\tskippedFilesElement.skipped_files.push({\n\t\t\t\t\tskipped_file: [],\n\t\t\t\t\t':@': { file: filePath },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Build the updated XML\n\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\tconst xml = xmlBuilder.build(config);\n\n\t// Validate the generated XML\n\ttry {\n\t\txmlParser.parse(xml, true);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'The resulting PhpStorm PHP configuration file ' +\n\t\t\t\t'is not valid XML.'\n\t\t);\n\t}\n\n\treturn xml;\n}\n\nexport type VSCodeConfigOptions = {\n\tname: string;\n\tworkspaceDir: string;\n\tpathMappings?: Mount[];\n\tpathSkippings?: string[];\n};\n\n/**\n * Pure function to update VS Code JSON config with Xdebug configuration.\n *\n * @param jsonContent The original JSON content of launch.json\n * @param options Configuration options\n * @returns Updated JSON content\n * @throws Error if JSON is invalid\n */\nexport function updateVSCodeConfig(\n\tjsonContent: string,\n\toptions: VSCodeConfigOptions\n): string {\n\tconst { name, pathMappings, pathSkippings } = options;\n\n\tconst errors: JSONC.ParseError[] = [];\n\n\tlet content = jsonContent;\n\tlet root = JSONC.parseTree(content, errors, jsoncParseOptions);\n\n\tif (root === undefined || errors.length) {\n\t\tthrow new Error('VS Code configuration file is not valid JSON.');\n\t}\n\n\t// Find or create configurations array\n\tlet configurationsNode = JSONC.findNodeAtLocation(root, ['configurations']);\n\n\tif (\n\t\tconfigurationsNode === undefined ||\n\t\tconfigurationsNode.children === undefined\n\t) {\n\t\tconst edits = JSONC.modify(content, ['configurations'], [], {});\n\t\tcontent = JSONC.applyEdits(content, edits);\n\n\t\troot = JSONC.parseTree(content, [], jsoncParseOptions);\n\t\tconfigurationsNode = JSONC.findNodeAtLocation(root!, [\n\t\t\t'configurations',\n\t\t]);\n\t}\n\n\t// Check if configuration already exists\n\tconst configurationIndex = configurationsNode?.children?.findIndex(\n\t\t(child: any) =>\n\t\t\tJSONC.findNodeAtLocation(child, ['name'])?.value === name\n\t);\n\n\t// Only add configuration if it doesn't exist\n\tif (configurationIndex === undefined || configurationIndex < 0) {\n\t\tconst configuration: VSCodeConfigNode = {\n\t\t\tname: name,\n\t\t\ttype: 'php',\n\t\t\trequest: 'launch',\n\t\t\tport: 9003,\n\t\t};\n\n\t\tif (pathMappings && pathMappings.length) {\n\t\t\tconfiguration.pathMappings = pathMappings.reduce((acc, mount) => {\n\t\t\t\tacc[mount.vfsPath] = `\\${workspaceFolder}/${toPosixPath(\n\t\t\t\t\tpath.relative(options.workspaceDir, mount.hostPath)\n\t\t\t\t)}`;\n\t\t\t\treturn acc;\n\t\t\t}, {} as VSCodeConfigMetaData);\n\t\t}\n\n\t\tif (pathSkippings && pathSkippings.length) {\n\t\t\tconfiguration.skipFiles = pathSkippings.map((skippedPath) =>\n\t\t\t\tskippedPath.endsWith('/') ? `${skippedPath}**` : skippedPath\n\t\t\t);\n\t\t}\n\n\t\t// Get the current length to append at the end\n\t\tconst currentLength = configurationsNode?.children?.length || 0;\n\n\t\tconst edits = JSONC.modify(\n\t\t\tcontent,\n\t\t\t['configurations', currentLength],\n\t\t\tconfiguration,\n\t\t\t{\n\t\t\t\tformattingOptions: {\n\t\t\t\t\tinsertSpaces: true,\n\t\t\t\t\ttabSize: 4,\n\t\t\t\t\teol: '\\n',\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\n\t\tcontent = jsoncApplyEdits(content, edits);\n\t}\n\n\treturn content;\n}\n\n/**\n * Implement necessary parameters and path mappings in IDE configuration files.\n *\n * @param name The configuration name.\n * @param mounts The mounts options.\n */\nexport async function addXdebugIDEConfig({\n\tname,\n\tides,\n\thost,\n\tport,\n\tcwd,\n\tmounts,\n\tpathSkippings,\n\tideKey = DEFAULT_IDE_KEY,\n}: IDEConfig) {\n\tconst pathMappings = mounts ? filterLocalMounts(cwd, mounts) : [];\n\tconst modifiedConfig: Record<string, string> = {};\n\n\t// PHPstorm\n\tif (ides.includes('phpstorm')) {\n\t\tconst phpStormRelativeConfigFilePath = '.idea/workspace.xml';\n\t\tconst phpStormConfigFilePath = path.join(\n\t\t\tcwd,\n\t\t\tphpStormRelativeConfigFilePath\n\t\t);\n\n\t\t// Create a template config file if the IDE directory exists,\n\t\t// or throw an error if IDE integration is requested but the directory is missing.\n\t\tif (!fs.existsSync(phpStormConfigFilePath)) {\n\t\t\tif (fs.existsSync(path.dirname(phpStormConfigFilePath))) {\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tphpStormConfigFilePath,\n\t\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t\t);\n\t\t\t} else if (ides.length == 1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`PhpStorm IDE integration requested, but no '.idea' directory was found in the current working directory.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (fs.existsSync(phpStormConfigFilePath)) {\n\t\t\tconst contents = fs.readFileSync(phpStormConfigFilePath, 'utf8');\n\t\t\tconst updatedXml = updatePhpStormWorkspaceConfig(contents, {\n\t\t\t\tname,\n\t\t\t\thost,\n\t\t\t\tport,\n\t\t\t\tprojectDir: cwd,\n\t\t\t\tpathMappings,\n\t\t\t\tideKey,\n\t\t\t});\n\t\t\tfs.writeFileSync(phpStormConfigFilePath, updatedXml);\n\t\t\tmodifiedConfig['phpstorm'] = phpStormRelativeConfigFilePath;\n\t\t}\n\n\t\t// PhpStorm php.xml (path skippings)\n\t\tif (pathSkippings && pathSkippings.length) {\n\t\t\tconst phpStormRelativePHPConfigFilePath = '.idea/php.xml';\n\t\t\tconst phpStormPHPConfigFilePath = path.join(\n\t\t\t\tcwd,\n\t\t\t\tphpStormRelativePHPConfigFilePath\n\t\t\t);\n\n\t\t\tif (!fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\t\t\tif (fs.existsSync(path.dirname(phpStormPHPConfigFilePath))) {\n\t\t\t\t\tfs.writeFileSync(\n\t\t\t\t\t\tphpStormPHPConfigFilePath,\n\t\t\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\t\t\tconst contents = fs.readFileSync(\n\t\t\t\t\tphpStormPHPConfigFilePath,\n\t\t\t\t\t'utf8'\n\t\t\t\t);\n\t\t\t\tconst updatedXml = updatePhpStormPHPConfig(contents, {\n\t\t\t\t\tpathSkippings,\n\t\t\t\t});\n\t\t\t\tfs.writeFileSync(phpStormPHPConfigFilePath, updatedXml);\n\t\t\t\tmodifiedConfig['phpstorm-php'] =\n\t\t\t\t\tphpStormRelativePHPConfigFilePath;\n\t\t\t}\n\t\t}\n\t}\n\n\t// VSCode\n\tif (ides.includes('vscode')) {\n\t\tconst vsCodeRelativeConfigFilePath = '.vscode/launch.json';\n\t\tconst vsCodeConfigFilePath = path.join(\n\t\t\tcwd,\n\t\t\tvsCodeRelativeConfigFilePath\n\t\t);\n\n\t\t// Create a template config file if the IDE directory exists,\n\t\t// or throw an error if IDE integration is requested but the directory is missing.\n\t\tif (!fs.existsSync(vsCodeConfigFilePath)) {\n\t\t\tif (fs.existsSync(path.dirname(vsCodeConfigFilePath))) {\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tvsCodeConfigFilePath,\n\t\t\t\t\t'{\\n \"configurations\": []\\n}'\n\t\t\t\t);\n\t\t\t} else if (ides.length == 1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`VS Code IDE integration requested, but no '.vscode' directory was found in the current working directory.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (fs.existsSync(vsCodeConfigFilePath)) {\n\t\t\tconst content = fs.readFileSync(vsCodeConfigFilePath, 'utf-8');\n\t\t\tconst updatedJson = updateVSCodeConfig(content, {\n\t\t\t\tname,\n\t\t\t\tworkspaceDir: cwd,\n\t\t\t\tpathMappings,\n\t\t\t\tpathSkippings,\n\t\t\t});\n\n\t\t\t// Only write and track the file if changes were made\n\t\t\tif (updatedJson !== content) {\n\t\t\t\tfs.writeFileSync(vsCodeConfigFilePath, updatedJson);\n\t\t\t\tmodifiedConfig['vscode'] = vsCodeRelativeConfigFilePath;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn modifiedConfig;\n}\n\n/**\n * Remove stale parameters and path mappings in IDE configuration files.\n *\n * @param name The configuration name.\n * @param cwd The current working directory.\n */\nexport async function clearXdebugIDEConfig(name: string, cwd: string) {\n\tconst phpStormConfigFilePath = path.join(cwd, '.idea/workspace.xml');\n\t// PhpStorm\n\tif (fs.existsSync(phpStormConfigFilePath)) {\n\t\tconst contents = fs.readFileSync(phpStormConfigFilePath, 'utf8');\n\t\tconst xmlParser = new XMLParser(xmlParserOptions);\n\t\t// NOTE: Using an IIFE so `config` can remain const.\n\t\tconst config: PhpStormWorkspaceConfigNode[] = (() => {\n\t\t\ttry {\n\t\t\t\treturn xmlParser.parse(contents, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'PhpStorm configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\t\t})();\n\n\t\tconst projectElement = config.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.project\n\t\t);\n\t\tconst componentElement = projectElement?.project?.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.component && c?.[':@']?.name === 'PhpServers'\n\t\t);\n\t\tconst serversElement = componentElement?.component?.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.servers\n\t\t);\n\t\tconst serverElementIndex = serversElement?.servers?.findIndex(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.server && c?.[':@']?.name === name\n\t\t);\n\n\t\tif (serverElementIndex !== undefined && serverElementIndex >= 0) {\n\t\t\tserversElement!.servers!.splice(serverElementIndex, 1);\n\n\t\t\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\t\t\tconst xml = xmlBuilder.build(config);\n\n\t\t\ttry {\n\t\t\t\txmlParser.parse(xml, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'The resulting PhpStorm configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\txml ===\n\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n\t<component name=\"PhpServers\">\\n\t\t<servers></servers>\\n\t</component>\\n</project>'\n\t\t\t) {\n\t\t\t\tfs.unlinkSync(phpStormConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(phpStormConfigFilePath, xml);\n\t\t\t}\n\t\t}\n\t}\n\n\t// PhpStorm php.xml (path skippings)\n\tconst phpStormPHPConfigFilePath = path.join(cwd, '.idea/php.xml');\n\tif (fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\tconst contents = fs.readFileSync(phpStormPHPConfigFilePath, 'utf8');\n\t\tconst xmlParser = new XMLParser(xmlParserOptions);\n\t\tconst config: PhpStormPHPConfigNode[] = (() => {\n\t\t\ttry {\n\t\t\t\treturn xmlParser.parse(contents, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'PhpStorm PHP configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\t\t})();\n\n\t\tconst projectElement = config.find(\n\t\t\t(c: PhpStormPHPConfigNode) => !!c?.project\n\t\t);\n\t\tconst componentIndex = projectElement?.project?.findIndex(\n\t\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t\t!!c?.component &&\n\t\t\t\tc?.[':@']?.name === 'PhpStepFilterConfiguration'\n\t\t);\n\n\t\tif (componentIndex !== undefined && componentIndex >= 0) {\n\t\t\tprojectElement!.project!.splice(componentIndex, 1);\n\n\t\t\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\t\t\tconst xml = xmlBuilder.build(config);\n\n\t\t\ttry {\n\t\t\t\txmlParser.parse(xml, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'The resulting PhpStorm PHP configuration file ' +\n\t\t\t\t\t\t'is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\txml ===\n\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t) {\n\t\t\t\tfs.unlinkSync(phpStormPHPConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(phpStormPHPConfigFilePath, xml);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst vsCodeConfigFilePath = path.join(cwd, '.vscode/launch.json');\n\t// VSCode\n\tif (fs.existsSync(vsCodeConfigFilePath)) {\n\t\tconst errors: JSONC.ParseError[] = [];\n\n\t\tconst content = fs.readFileSync(vsCodeConfigFilePath, 'utf-8');\n\t\tconst root = JSONC.parseTree(content, errors, jsoncParseOptions);\n\n\t\tif (root === undefined || errors.length) {\n\t\t\tthrow new Error('VS Code configuration file is not valid JSON.');\n\t\t}\n\n\t\tconst configurationsNode = JSONC.findNodeAtLocation(root, [\n\t\t\t'configurations',\n\t\t]);\n\n\t\tconst configurationIndex = configurationsNode?.children?.findIndex(\n\t\t\t(child: any) =>\n\t\t\t\tJSONC.findNodeAtLocation(child, ['name'])?.value === name\n\t\t);\n\n\t\tif (configurationIndex !== undefined && configurationIndex >= 0) {\n\t\t\tconst edits = JSONC.modify(\n\t\t\t\tcontent,\n\t\t\t\t['configurations', configurationIndex],\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tformattingOptions: {\n\t\t\t\t\t\tinsertSpaces: true,\n\t\t\t\t\t\ttabSize: 4,\n\t\t\t\t\t\teol: '\\n',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst json = jsoncApplyEdits(content, edits);\n\t\t\tif (json === '{\\n \"configurations\": []\\n}') {\n\t\t\t\tfs.unlinkSync(vsCodeConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(vsCodeConfigFilePath, json);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Implement path mapping and path skipping in Xdebug.\n *\n * @param name The configuration name.\n * @param mounts The mounts options.\n * @param pathSkippings The skipping paths options.\n * @returns Xdebug options\n */\nexport function makeXdebugConfig({\n\tcwd,\n\tmounts,\n\tpathSkippings,\n}: XdebugConfig): XdebugOptions {\n\tconst pathMappings =\n\t\tcwd && mounts ? filterLocalMounts(cwd, mounts) : undefined;\n\n\treturn { pathMappings, pathSkippings };\n}\n\nfunction jsoncApplyEdits(content: string, edits: JSONC.Edit[]) {\n\tconst errors: JSONC.ParseError[] = [];\n\tconst json = JSONC.applyEdits(content, edits);\n\n\terrors.length = 0;\n\n\tJSONC.parseTree(json, errors, jsoncParseOptions);\n\n\tif (errors.length) {\n\t\tconst formattedErrors = errors\n\t\t\t.map((error) => {\n\t\t\t\treturn {\n\t\t\t\t\tmessage: JSONC.printParseErrorCode(error.error),\n\t\t\t\t\toffset: error.offset,\n\t\t\t\t\tlength: error.length,\n\t\t\t\t\tfragment: json.slice(\n\t\t\t\t\t\tMath.max(0, error.offset - 20),\n\t\t\t\t\t\tMath.min(json.length, error.offset + error.length + 10)\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.map(\n\t\t\t\t(error) =>\n\t\t\t\t\t`${error.message} at ${error.offset}:${error.length} (${error.fragment})`\n\t\t\t);\n\t\tconst formattedEdits = edits.map(\n\t\t\t(edit) => `At ${edit.offset}:${edit.length} - (${edit.content})`\n\t\t);\n\t\tthrow new Error(\n\t\t\t`VS Code configuration file (.vscode/launch.json) is not valid a JSONC after CLI modifications. This is likely ` +\n\t\t\t\t`a CLI bug. Please report it at https://github.com/WordPress/wordpress-playground/issues and include the contents ` +\n\t\t\t\t`of your \".vscode/launch.json\" file. \\n\\n Applied edits: ${formattedEdits.join(\n\t\t\t\t\t'\\n'\n\t\t\t\t)}\\n\\n The errors are: ${formattedErrors.join('\\n')}`\n\t\t);\n\t}\n\n\treturn json;\n}\n"],"names":["DEFAULT_IDE_KEY","DEFAULT_PATH_SKIPPINGS","createTempDirSymlink","nativeDirPath","symlinkPath","platform","type","fs","removeTempDirSymlink","filterLocalMounts","cwd","mounts","mount","absoluteHostPath","path","cwdChildPrefix","xmlParserOptions","xmlBuilderOptions","jsoncParseOptions","updatePhpStormWorkspaceConfig","xmlContent","options","name","host","port","pathMappings","ideKey","xmlParser","XMLParser","config","serverElement","pathMapping","toPosixPath","projectElement","c","projectVersion","_a","componentElement","_b","serversElement","_c","serverElementIndex","_d","runManagerElement","_e","_f","runConfigElement","xml","XMLBuilder","updatePhpStormPHPConfig","pathSkippings","skippedFilesElement","skippedPath","filePath","updateVSCodeConfig","jsonContent","errors","content","root","JSONC","configurationsNode","edits","configurationIndex","child","configuration","acc","currentLength","jsoncApplyEdits","addXdebugIDEConfig","ides","modifiedConfig","phpStormRelativeConfigFilePath","phpStormConfigFilePath","contents","updatedXml","phpStormRelativePHPConfigFilePath","phpStormPHPConfigFilePath","vsCodeRelativeConfigFilePath","vsCodeConfigFilePath","updatedJson","clearXdebugIDEConfig","componentIndex","json","makeXdebugConfig","formattedErrors","error","formattedEdits","edit"],"mappings":"qeAkBaA,EAAkB,aAClBC,EAAyB,CACrC,QACA,SACA,aACA,YACA,QACD,EAWA,eAAsBC,EACrBC,EACAC,EACAC,EACC,CACD,MAAMC,EACLD,IAAa,QAIX,WACC,MACJE,EAAG,YAAYJ,EAAeC,EAAaE,CAAI,CAChD,CAOA,eAAsBE,EAAqBJ,EAAqB,CAC/D,GAAI,CACWG,EAAG,UAAUH,CAAW,EAC5B,k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G,EAAM,OAASA,EAAM,OAAS,EAAE,CAAA,CACvD,EAED,EACA,IACCA,GACA,GAAGA,EAAM,OAAO,OAAOA,EAAM,MAAM,IAAIA,EAAM,MAAM,KAAKA,EAAM,QAAQ,GAAA,EAEnEC,EAAiBzB,EAAM,IAC3B0B,GAAS,MAAMA,EAAK,MAAM,IAAIA,EAAK,MAAM,OAAOA,EAAK,OAAO,GAAA,EAE9D,MAAM,IAAI,MACT;AAAA;AAAA,kBAE4DD,EAAe,KACzE;AAAA,CAAA,CACA;AAAA;AAAA,mBAAwBF,EAAgB,KAAK;AAAA,CAAI,CAAC,EAAA,CAEtD,CAEA,OAAOF,CACR"} | ||
| {"version":3,"file":"index.cjs","sources":["../../../../packages/php-wasm/cli-util/src/lib/cli-output.ts","../../../../packages/php-wasm/cli-util/src/lib/xdebug-path-mappings.ts"],"sourcesContent":["interface CLIOutputOptions {\n\t/** Verbosity level: 'quiet', 'normal', or 'debug' */\n\tverbosity: string;\n\t/** Output stream to write to. Defaults to process.stdout */\n\twriteStream?: NodeJS.WriteStream;\n}\n\nexport class CLIOutput {\n\tprivate verbosity: string;\n\tprotected writeStream: NodeJS.WriteStream;\n\n\tconstructor(options: CLIOutputOptions) {\n\t\tthis.verbosity = options.verbosity;\n\t\tthis.writeStream = options.writeStream || process.stdout;\n\t}\n\n\tget isTTY(): boolean {\n\t\treturn Boolean(this.writeStream.isTTY);\n\t}\n\n\tget isQuiet(): boolean {\n\t\treturn this.verbosity === 'quiet';\n\t}\n\n\t/**\n\t * ANSI formatting helpers.\n\t *\n\t * These only apply color codes when outputting to a terminal (TTY).\n\t * When piped to files or non-TTY streams, they return plain text to\n\t * avoid polluting logs with escape sequences.\n\t */\n\tbold(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[1m${text}\\x1b[0m` : text;\n\t}\n\n\tdim(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[2m${text}\\x1b[0m` : text;\n\t}\n\n\titalic(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[3m${text}\\x1b[0m` : text;\n\t}\n\n\tred(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[31m${text}\\x1b[0m` : text;\n\t}\n\n\tgreen(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[32m${text}\\x1b[0m` : text;\n\t}\n\n\tyellow(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[33m${text}\\x1b[0m` : text;\n\t}\n\n\tcyan(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[36m${text}\\x1b[0m` : text;\n\t}\n\n\thighlight(text: string): string {\n\t\treturn this.yellow(text);\n\t}\n\n\tprint(message: string): void {\n\t\tif (this.isQuiet) return;\n\t\tthis.writeStream.write(`${message}\\n`);\n\t}\n\n\tprintError(message: string): void {\n\t\tthis.writeStream.write(`${this.red('Error:')} ${message}\\n`);\n\t}\n\n\tprintWarning(message: string): void {\n\t\tif (this.isQuiet) return;\n\t\tthis.writeStream.write(`${this.yellow('Warning:')} ${message}\\n`);\n\t}\n}\n","import fs from 'fs';\nimport path from 'path';\nimport { toPosixPath } from '@php-wasm/util';\nimport type { Mount } from './mounts';\nimport {\n\ttype X2jOptions,\n\ttype XmlBuilderOptions,\n\tXMLParser,\n\tXMLBuilder,\n} from 'fast-xml-parser';\nimport * as JSONC from 'jsonc-parser';\n\nexport interface XdebugOptions {\n\tideKey?: string;\n\tpathMappings?: Mount[];\n\tpathSkippings?: string[];\n}\n\nexport const DEFAULT_IDE_KEY = 'PHPWASMCLI';\nexport const DEFAULT_PATH_SKIPPINGS = [\n\t'/dev/',\n\t'/home/',\n\t'/internal/',\n\t'/request/',\n\t'/proc/',\n];\n\n/**\n * Create a symlink to a tempory directory.\n *\n * The symlink is created to access the system temp dir\n * inside the current debugging directory.\n *\n * @param nativeDirPath The system temp dir path.\n * @param symlinkPath The symlink name.\n */\nexport async function createTempDirSymlink(\n\tnativeDirPath: string,\n\tsymlinkPath: string,\n\tplatform: string\n) {\n\tconst type =\n\t\tplatform === 'win32'\n\t\t\t? // On Windows, creating a 'dir' symlink can require elevated permissions.\n\t\t\t\t// In this case, let's make junction points because they function like\n\t\t\t\t// symlinks and do not require elevated permissions.\n\t\t\t\t'junction'\n\t\t\t: 'dir';\n\tfs.symlinkSync(nativeDirPath, symlinkPath, type);\n}\n\n/**\n * Remove the given temporary directory symlink if it exists.\n *\n * @param symlinkPath The symlink path.\n */\nexport async function removeTempDirSymlink(symlinkPath: string) {\n\ttry {\n\t\tconst stats = fs.lstatSync(symlinkPath);\n\t\tif (stats.isSymbolicLink()) {\n\t\t\tfs.unlinkSync(symlinkPath);\n\t\t}\n\t} catch {\n\t\t// Symlink does not exist or cannot be accessed, nothing to remove\n\t}\n}\n\n/**\n * Filters out mounts that are not in the current working directory\n *\n * @param mounts The mounts list.\n */\nfunction filterLocalMounts(cwd: string, mounts: Mount[]) {\n\treturn mounts.filter((mount) => {\n\t\tconst absoluteHostPath = path.resolve(mount.hostPath);\n\t\tconst cwdChildPrefix = path.join(cwd, path.sep);\n\t\treturn (\n\t\t\t// If auto-mounting from the current directory,\n\t\t\t// the entire project directory can be mapped.\n\t\t\tabsoluteHostPath === cwd ||\n\t\t\tabsoluteHostPath.startsWith(cwdChildPrefix)\n\t\t);\n\t});\n}\n\nexport type XdebugConfig = {\n\t/**\n\t * The current working directory to consider for debugger path mapping.\n\t */\n\tcwd?: string;\n\t/**\n\t * The mounts to consider for debugger path mapping.\n\t */\n\tmounts?: Mount[];\n\t/**\n\t * The paths to consider for debugger path skipping.\n\t */\n\tpathSkippings?: string[];\n};\n\nexport type IDEConfig = {\n\t/**\n\t * The name of the configuration within the IDE configuration.\n\t */\n\tname: string;\n\t/**\n\t * The IDEs to configure.\n\t */\n\tides: string[];\n\t/**\n\t * The web server host.\n\t */\n\thost: string;\n\t/**\n\t * The web server port.\n\t */\n\tport: number;\n\t/**\n\t * The current working directory to consider for debugger path mapping.\n\t */\n\tcwd: string;\n\t/**\n\t * The mounts to consider for debugger path mapping.\n\t */\n\tmounts?: Mount[];\n\t/**\n\t * The paths to skip when debugging.\n\t */\n\tpathSkippings?: string[];\n\t/**\n\t * The IDE key to use for the debug configuration. Defaults to 'PHPWASMCLI'.\n\t */\n\tideKey?: string;\n};\n\ntype PhpStormWorkspaceConfigMetaData = {\n\tname?: string;\n\tversion?: string;\n\thost?: string;\n\tuse_path_mappings?: string;\n\t'local-root'?: string;\n\t'remote-root'?: string;\n\ttype?: 'PhpRemoteDebugRunConfigurationType';\n\tfactoryName?: string;\n\tfilter_connections?: 'FILTER';\n\tserver_name?: string;\n\tsession_id?: string;\n\tv?: string;\n};\n\ntype PhpStormWorkspaceConfigNode = {\n\t':@'?: PhpStormWorkspaceConfigMetaData;\n\tproject?: PhpStormWorkspaceConfigNode[];\n\tcomponent?: PhpStormWorkspaceConfigNode[];\n\tservers?: PhpStormWorkspaceConfigNode[];\n\tserver?: PhpStormWorkspaceConfigNode[];\n\tpath_mappings?: PhpStormWorkspaceConfigNode[];\n\tmapping?: PhpStormWorkspaceConfigNode[];\n\tconfiguration?: PhpStormWorkspaceConfigNode[];\n\tmethod?: PhpStormWorkspaceConfigNode[];\n};\n\ntype PhpStormPHPConfigMetaData = {\n\tname?: string;\n\tversion?: string;\n\tfile?: string;\n};\n\ntype PhpStormPHPConfigNode = {\n\t':@'?: PhpStormPHPConfigMetaData;\n\tproject?: PhpStormPHPConfigNode[];\n\tcomponent?: PhpStormPHPConfigNode[];\n\tskipped_files?: PhpStormPHPConfigNode[];\n\tskipped_file?: PhpStormPHPConfigNode[];\n};\n\ntype VSCodeConfigMetaData = {\n\t[key: string]: string;\n};\n\ntype VSCodeConfigNode = {\n\tname: string;\n\ttype: string;\n\trequest: string;\n\tport: number;\n\tpathMappings?: VSCodeConfigMetaData;\n\tskipFiles?: string[];\n};\n\nconst xmlParserOptions: X2jOptions = {\n\tignoreAttributes: false,\n\tattributeNamePrefix: '',\n\tpreserveOrder: true,\n\tcdataPropName: '__cdata',\n\tcommentPropName: '__xmlComment',\n\tallowBooleanAttributes: true,\n\ttrimValues: true,\n};\nconst xmlBuilderOptions: XmlBuilderOptions = {\n\tignoreAttributes: xmlParserOptions.ignoreAttributes,\n\tattributeNamePrefix: xmlParserOptions.attributeNamePrefix,\n\tpreserveOrder: xmlParserOptions.preserveOrder,\n\tcdataPropName: xmlParserOptions.cdataPropName,\n\tcommentPropName: xmlParserOptions.commentPropName,\n\tsuppressBooleanAttributes: !xmlParserOptions.allowBooleanAttributes,\n\tformat: true,\n\tindentBy: '\\t',\n};\n\nconst jsoncParseOptions: JSONC.ParseOptions = {\n\tallowEmptyContent: true,\n\tallowTrailingComma: true,\n};\n\nexport type PhpStormWorkspaceConfigOptions = {\n\tname: string;\n\thost: string;\n\tport: number;\n\tprojectDir: string;\n\tpathMappings?: Mount[];\n\tideKey: string;\n};\n\n/**\n * Pure function to update PHPStorm XML config with Xdebug server and run configuration.\n *\n * @param xmlContent The original XML content of workspace.xml\n * @param options Configuration options for the server\n * @returns Updated XML content\n * @throws Error if XML is invalid or configuration is incompatible\n */\nexport function updatePhpStormWorkspaceConfig(\n\txmlContent: string,\n\toptions: PhpStormWorkspaceConfigOptions\n): string {\n\tconst { name, host, port, pathMappings, ideKey } = options;\n\n\tconst xmlParser = new XMLParser(xmlParserOptions);\n\n\t// Parse the XML\n\tconst config: PhpStormWorkspaceConfigNode[] = (() => {\n\t\ttry {\n\t\t\treturn xmlParser.parse(xmlContent, true);\n\t\t} catch {\n\t\t\tthrow new Error('PhpStorm configuration file is not valid XML.');\n\t\t}\n\t})();\n\n\t// Create the server element with path mappings\n\tconst serverElement: PhpStormWorkspaceConfigNode = {\n\t\tserver: [{}],\n\t\t':@': {\n\t\t\tname,\n\t\t\t// NOTE: PhpStorm quirk: Xdebug only works when the full URL (including port)\n\t\t\t// is provided in `host`. The separate `port` field is ignored or misinterpreted,\n\t\t\t// so we rely solely on host: \"host:port\".\n\t\t\thost: `${host}:${port}`,\n\t\t\tuse_path_mappings: 'true',\n\t\t},\n\t};\n\n\tif (pathMappings && pathMappings.length) {\n\t\tserverElement.server![0].path_mappings = pathMappings.map(\n\t\t\t(pathMapping) => ({\n\t\t\t\tmapping: [],\n\t\t\t\t':@': {\n\t\t\t\t\t'local-root': `$PROJECT_DIR$/${toPosixPath(\n\t\t\t\t\t\tpath.relative(options.projectDir, pathMapping.hostPath)\n\t\t\t\t\t)}`,\n\t\t\t\t\t'remote-root': pathMapping.vfsPath,\n\t\t\t\t},\n\t\t\t})\n\t\t);\n\t}\n\n\t// Find or create project element\n\tlet projectElement = config?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.project\n\t);\n\tif (projectElement) {\n\t\tconst projectVersion = projectElement[':@']?.version;\n\t\tif (projectVersion === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports <project version=\"4\"> in workspace.xml, ' +\n\t\t\t\t\t'but the <project> configuration has no version number.'\n\t\t\t);\n\t\t} else if (projectVersion !== '4') {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports <project version=\"4\"> in workspace.xml, ' +\n\t\t\t\t\t`but we found a <project> configuration with version \"${projectVersion}\".`\n\t\t\t);\n\t\t}\n\t}\n\tif (projectElement === undefined) {\n\t\tprojectElement = {\n\t\t\tproject: [],\n\t\t\t':@': { version: '4' },\n\t\t};\n\t\tconfig.push(projectElement);\n\t}\n\n\t// Find or create PhpServers component\n\tlet componentElement = projectElement.project?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'PhpServers'\n\t);\n\tif (componentElement === undefined) {\n\t\tcomponentElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'PhpServers' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(componentElement);\n\t}\n\n\t// Find or create servers element\n\tlet serversElement = componentElement.component?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.servers\n\t);\n\tif (serversElement === undefined) {\n\t\tserversElement = { servers: [] };\n\n\t\tif (componentElement.component === undefined) {\n\t\t\tcomponentElement.component = [];\n\t\t}\n\n\t\tcomponentElement.component.push(serversElement);\n\t}\n\n\t// Check if server already exists\n\tconst serverElementIndex = serversElement.servers?.findIndex(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.server && c?.[':@']?.name === name\n\t);\n\n\t// Only add server if it doesn't exist\n\tif (serverElementIndex === undefined || serverElementIndex < 0) {\n\t\tif (serversElement.servers === undefined) {\n\t\t\tserversElement.servers = [];\n\t\t}\n\n\t\tserversElement.servers.push(serverElement);\n\t}\n\n\t// Find or create RunManager component\n\tlet runManagerElement = projectElement.project?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'RunManager'\n\t);\n\tif (runManagerElement === undefined) {\n\t\trunManagerElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'RunManager' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(runManagerElement);\n\t}\n\n\t// Check if run configuration already exists\n\tconst existingConfigIndex =\n\t\trunManagerElement.component?.findIndex(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.configuration && c?.[':@']?.name === name\n\t\t) ?? -1;\n\n\t// Only add run configuration if it doesn't exist\n\tif (existingConfigIndex < 0) {\n\t\tconst runConfigElement: PhpStormWorkspaceConfigNode = {\n\t\t\tconfiguration: [\n\t\t\t\t{\n\t\t\t\t\tmethod: [],\n\t\t\t\t\t':@': { v: '2' },\n\t\t\t\t},\n\t\t\t],\n\t\t\t':@': {\n\t\t\t\tname: name,\n\t\t\t\ttype: 'PhpRemoteDebugRunConfigurationType',\n\t\t\t\tfactoryName: 'PHP Remote Debug',\n\t\t\t\tfilter_connections: 'FILTER',\n\t\t\t\tserver_name: name,\n\t\t\t\tsession_id: ideKey,\n\t\t\t},\n\t\t};\n\n\t\tif (runManagerElement.component === undefined) {\n\t\t\trunManagerElement.component = [];\n\t\t}\n\n\t\trunManagerElement.component.push(runConfigElement);\n\t}\n\n\t// Build the updated XML\n\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\tconst xml = xmlBuilder.build(config);\n\n\t// Validate the generated XML\n\ttry {\n\t\txmlParser.parse(xml, true);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'The resulting PhpStorm configuration file is not valid XML.'\n\t\t);\n\t}\n\n\treturn xml;\n}\n\nexport type PhpStormPHPConfigOptions = {\n\tpathSkippings?: string[];\n};\n\n/**\n * Pure function to update PhpStorm php.xml config with skipped files.\n *\n * @param xmlContent The original XML content of php.xml\n * @param options Configuration options for skipped files\n * @returns Updated XML content\n * @throws Error if XML is invalid or configuration is incompatible\n */\nexport function updatePhpStormPHPConfig(\n\txmlContent: string,\n\toptions: PhpStormPHPConfigOptions\n): string {\n\tconst { pathSkippings } = options;\n\n\tconst xmlParser = new XMLParser(xmlParserOptions);\n\n\tconst config: PhpStormPHPConfigNode[] = (() => {\n\t\ttry {\n\t\t\treturn xmlParser.parse(xmlContent, true);\n\t\t} catch {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm PHP configuration file is not valid XML.'\n\t\t\t);\n\t\t}\n\t})();\n\n\t// Find or create project element\n\tlet projectElement = config?.find(\n\t\t(c: PhpStormPHPConfigNode) => !!c?.project\n\t);\n\tif (projectElement) {\n\t\tconst projectVersion = projectElement[':@']?.version;\n\t\tif (projectVersion === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports ' +\n\t\t\t\t\t'<project version=\"4\"> in php.xml, ' +\n\t\t\t\t\t'but the <project> configuration has no version number.'\n\t\t\t);\n\t\t} else if (projectVersion !== '4') {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports ' +\n\t\t\t\t\t'<project version=\"4\"> in php.xml, ' +\n\t\t\t\t\t`but we found a <project> configuration ` +\n\t\t\t\t\t`with version \"${projectVersion}\".`\n\t\t\t);\n\t\t}\n\t}\n\tif (projectElement === undefined) {\n\t\tprojectElement = {\n\t\t\tproject: [],\n\t\t\t':@': { version: '4' },\n\t\t};\n\t\tconfig.push(projectElement);\n\t}\n\n\t// Find or create PhpStepFilterConfiguration component\n\tlet componentElement = projectElement.project?.find(\n\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'PhpStepFilterConfiguration'\n\t);\n\tif (componentElement === undefined) {\n\t\tcomponentElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'PhpStepFilterConfiguration' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(componentElement);\n\t}\n\n\t// Find or create skipped_files element\n\tlet skippedFilesElement = componentElement.component?.find(\n\t\t(c: PhpStormPHPConfigNode) => !!c?.skipped_files\n\t);\n\tif (skippedFilesElement === undefined) {\n\t\tskippedFilesElement = { skipped_files: [] };\n\n\t\tif (componentElement.component === undefined) {\n\t\t\tcomponentElement.component = [];\n\t\t}\n\n\t\tcomponentElement.component.push(skippedFilesElement);\n\t}\n\n\t// Add skipped files\n\tif (pathSkippings && pathSkippings.length) {\n\t\tfor (const skippedPath of pathSkippings) {\n\t\t\tconst normalizedPath = skippedPath.endsWith('/')\n\t\t\t\t? skippedPath.slice(0, -1)\n\t\t\t\t: skippedPath;\n\t\t\tconst filePath = `$PROJECT_DIR$${normalizedPath}`;\n\n\t\t\t// Check if already exists\n\t\t\tconst exists = skippedFilesElement.skipped_files?.some(\n\t\t\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t\t\t!!c?.skipped_file && c?.[':@']?.file === filePath\n\t\t\t);\n\n\t\t\tif (!exists) {\n\t\t\t\tif (skippedFilesElement.skipped_files === undefined) {\n\t\t\t\t\tskippedFilesElement.skipped_files = [];\n\t\t\t\t}\n\n\t\t\t\tskippedFilesElement.skipped_files.push({\n\t\t\t\t\tskipped_file: [],\n\t\t\t\t\t':@': { file: filePath },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Build the updated XML\n\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\tconst xml = xmlBuilder.build(config);\n\n\t// Validate the generated XML\n\ttry {\n\t\txmlParser.parse(xml, true);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'The resulting PhpStorm PHP configuration file ' +\n\t\t\t\t'is not valid XML.'\n\t\t);\n\t}\n\n\treturn xml;\n}\n\nexport type VSCodeConfigOptions = {\n\tname: string;\n\tworkspaceDir: string;\n\tpathMappings?: Mount[];\n\tpathSkippings?: string[];\n};\n\n/**\n * Pure function to update VS Code JSON config with Xdebug configuration.\n *\n * @param jsonContent The original JSON content of launch.json\n * @param options Configuration options\n * @returns Updated JSON content\n * @throws Error if JSON is invalid\n */\nexport function updateVSCodeConfig(\n\tjsonContent: string,\n\toptions: VSCodeConfigOptions\n): string {\n\tconst { name, pathMappings, pathSkippings } = options;\n\n\tconst errors: JSONC.ParseError[] = [];\n\n\tlet content = jsonContent;\n\tlet root = JSONC.parseTree(content, errors, jsoncParseOptions);\n\n\tif (root === undefined || errors.length) {\n\t\tthrow new Error('VS Code configuration file is not valid JSON.');\n\t}\n\n\t// Find or create configurations array\n\tlet configurationsNode = JSONC.findNodeAtLocation(root, ['configurations']);\n\n\tif (\n\t\tconfigurationsNode === undefined ||\n\t\tconfigurationsNode.children === undefined\n\t) {\n\t\tconst edits = JSONC.modify(content, ['configurations'], [], {});\n\t\tcontent = JSONC.applyEdits(content, edits);\n\n\t\troot = JSONC.parseTree(content, [], jsoncParseOptions);\n\t\tconfigurationsNode = JSONC.findNodeAtLocation(root!, [\n\t\t\t'configurations',\n\t\t]);\n\t}\n\n\t// Check if configuration already exists\n\tconst configurationIndex = configurationsNode?.children?.findIndex(\n\t\t(child: any) =>\n\t\t\tJSONC.findNodeAtLocation(child, ['name'])?.value === name\n\t);\n\n\t// Only add configuration if it doesn't exist\n\tif (configurationIndex === undefined || configurationIndex < 0) {\n\t\tconst configuration: VSCodeConfigNode = {\n\t\t\tname: name,\n\t\t\ttype: 'php',\n\t\t\trequest: 'launch',\n\t\t\tport: 9003,\n\t\t};\n\n\t\tif (pathMappings && pathMappings.length) {\n\t\t\tconfiguration.pathMappings = pathMappings.reduce((acc, mount) => {\n\t\t\t\tacc[mount.vfsPath] = `\\${workspaceFolder}/${toPosixPath(\n\t\t\t\t\tpath.relative(options.workspaceDir, mount.hostPath)\n\t\t\t\t)}`;\n\t\t\t\treturn acc;\n\t\t\t}, {} as VSCodeConfigMetaData);\n\t\t}\n\n\t\tif (pathSkippings && pathSkippings.length) {\n\t\t\tconfiguration.skipFiles = pathSkippings.map((skippedPath) =>\n\t\t\t\tskippedPath.endsWith('/') ? `${skippedPath}**` : skippedPath\n\t\t\t);\n\t\t}\n\n\t\t// Get the current length to append at the end\n\t\tconst currentLength = configurationsNode?.children?.length || 0;\n\n\t\tconst edits = JSONC.modify(\n\t\t\tcontent,\n\t\t\t['configurations', currentLength],\n\t\t\tconfiguration,\n\t\t\t{\n\t\t\t\tformattingOptions: {\n\t\t\t\t\tinsertSpaces: true,\n\t\t\t\t\ttabSize: 4,\n\t\t\t\t\teol: '\\n',\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\n\t\tcontent = jsoncApplyEdits(content, edits);\n\t}\n\n\treturn content;\n}\n\n/**\n * Implement necessary parameters and path mappings in IDE configuration files.\n *\n * @param name The configuration name.\n * @param mounts The mounts options.\n */\nexport async function addXdebugIDEConfig({\n\tname,\n\tides,\n\thost,\n\tport,\n\tcwd,\n\tmounts,\n\tpathSkippings,\n\tideKey = DEFAULT_IDE_KEY,\n}: IDEConfig) {\n\tconst pathMappings = mounts ? filterLocalMounts(cwd, mounts) : [];\n\tconst modifiedConfig: Record<string, string> = {};\n\n\t// PHPstorm\n\tif (ides.includes('phpstorm')) {\n\t\tconst phpStormRelativeConfigFilePath = '.idea/workspace.xml';\n\t\tconst phpStormConfigFilePath = path.join(\n\t\t\tcwd,\n\t\t\tphpStormRelativeConfigFilePath\n\t\t);\n\n\t\t// Create a template config file if the IDE directory exists,\n\t\t// or throw an error if IDE integration is requested but the directory is missing.\n\t\tif (!fs.existsSync(phpStormConfigFilePath)) {\n\t\t\tif (fs.existsSync(path.dirname(phpStormConfigFilePath))) {\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tphpStormConfigFilePath,\n\t\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t\t);\n\t\t\t} else if (ides.length == 1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`PhpStorm IDE integration requested, but no '.idea' directory was found in the current working directory.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (fs.existsSync(phpStormConfigFilePath)) {\n\t\t\tconst contents = fs.readFileSync(phpStormConfigFilePath, 'utf8');\n\t\t\tconst updatedXml = updatePhpStormWorkspaceConfig(contents, {\n\t\t\t\tname,\n\t\t\t\thost,\n\t\t\t\tport,\n\t\t\t\tprojectDir: cwd,\n\t\t\t\tpathMappings,\n\t\t\t\tideKey,\n\t\t\t});\n\t\t\tfs.writeFileSync(phpStormConfigFilePath, updatedXml);\n\t\t\tmodifiedConfig['phpstorm'] = phpStormRelativeConfigFilePath;\n\t\t}\n\n\t\t// PhpStorm php.xml (path skippings)\n\t\tif (pathSkippings && pathSkippings.length) {\n\t\t\tconst phpStormRelativePHPConfigFilePath = '.idea/php.xml';\n\t\t\tconst phpStormPHPConfigFilePath = path.join(\n\t\t\t\tcwd,\n\t\t\t\tphpStormRelativePHPConfigFilePath\n\t\t\t);\n\n\t\t\tif (!fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\t\t\tif (fs.existsSync(path.dirname(phpStormPHPConfigFilePath))) {\n\t\t\t\t\tfs.writeFileSync(\n\t\t\t\t\t\tphpStormPHPConfigFilePath,\n\t\t\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\t\t\tconst contents = fs.readFileSync(\n\t\t\t\t\tphpStormPHPConfigFilePath,\n\t\t\t\t\t'utf8'\n\t\t\t\t);\n\t\t\t\tconst updatedXml = updatePhpStormPHPConfig(contents, {\n\t\t\t\t\tpathSkippings,\n\t\t\t\t});\n\t\t\t\tfs.writeFileSync(phpStormPHPConfigFilePath, updatedXml);\n\t\t\t\tmodifiedConfig['phpstorm-php'] =\n\t\t\t\t\tphpStormRelativePHPConfigFilePath;\n\t\t\t}\n\t\t}\n\t}\n\n\t// VSCode\n\tif (ides.includes('vscode')) {\n\t\tconst vsCodeRelativeConfigFilePath = '.vscode/launch.json';\n\t\tconst vsCodeConfigFilePath = path.join(\n\t\t\tcwd,\n\t\t\tvsCodeRelativeConfigFilePath\n\t\t);\n\n\t\t// Create a template config file if the IDE directory exists,\n\t\t// or throw an error if IDE integration is requested but the directory is missing.\n\t\tif (!fs.existsSync(vsCodeConfigFilePath)) {\n\t\t\tif (fs.existsSync(path.dirname(vsCodeConfigFilePath))) {\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tvsCodeConfigFilePath,\n\t\t\t\t\t'{\\n \"configurations\": []\\n}'\n\t\t\t\t);\n\t\t\t} else if (ides.length == 1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`VS Code IDE integration requested, but no '.vscode' directory was found in the current working directory.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (fs.existsSync(vsCodeConfigFilePath)) {\n\t\t\tconst content = fs.readFileSync(vsCodeConfigFilePath, 'utf-8');\n\t\t\tconst updatedJson = updateVSCodeConfig(content, {\n\t\t\t\tname,\n\t\t\t\tworkspaceDir: cwd,\n\t\t\t\tpathMappings,\n\t\t\t\tpathSkippings,\n\t\t\t});\n\n\t\t\t// Only write and track the file if changes were made\n\t\t\tif (updatedJson !== content) {\n\t\t\t\tfs.writeFileSync(vsCodeConfigFilePath, updatedJson);\n\t\t\t\tmodifiedConfig['vscode'] = vsCodeRelativeConfigFilePath;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn modifiedConfig;\n}\n\n/**\n * Remove stale parameters and path mappings in IDE configuration files.\n *\n * @param name The configuration name.\n * @param cwd The current working directory.\n */\nexport async function clearXdebugIDEConfig(name: string, cwd: string) {\n\tconst phpStormConfigFilePath = path.join(cwd, '.idea/workspace.xml');\n\t// PhpStorm\n\tif (fs.existsSync(phpStormConfigFilePath)) {\n\t\tconst contents = fs.readFileSync(phpStormConfigFilePath, 'utf8');\n\t\tconst xmlParser = new XMLParser(xmlParserOptions);\n\t\t// NOTE: Using an IIFE so `config` can remain const.\n\t\tconst config: PhpStormWorkspaceConfigNode[] = (() => {\n\t\t\ttry {\n\t\t\t\treturn xmlParser.parse(contents, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'PhpStorm configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\t\t})();\n\n\t\tconst projectElement = config.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.project\n\t\t);\n\t\tconst componentElement = projectElement?.project?.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.component && c?.[':@']?.name === 'PhpServers'\n\t\t);\n\t\tconst serversElement = componentElement?.component?.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.servers\n\t\t);\n\t\tconst serverElementIndex = serversElement?.servers?.findIndex(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.server && c?.[':@']?.name === name\n\t\t);\n\n\t\tif (serverElementIndex !== undefined && serverElementIndex >= 0) {\n\t\t\tserversElement!.servers!.splice(serverElementIndex, 1);\n\n\t\t\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\t\t\tconst xml = xmlBuilder.build(config);\n\n\t\t\ttry {\n\t\t\t\txmlParser.parse(xml, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'The resulting PhpStorm configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\txml ===\n\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n\t<component name=\"PhpServers\">\\n\t\t<servers></servers>\\n\t</component>\\n</project>'\n\t\t\t) {\n\t\t\t\tfs.unlinkSync(phpStormConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(phpStormConfigFilePath, xml);\n\t\t\t}\n\t\t}\n\t}\n\n\t// PhpStorm php.xml (path skippings)\n\tconst phpStormPHPConfigFilePath = path.join(cwd, '.idea/php.xml');\n\tif (fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\tconst contents = fs.readFileSync(phpStormPHPConfigFilePath, 'utf8');\n\t\tconst xmlParser = new XMLParser(xmlParserOptions);\n\t\tconst config: PhpStormPHPConfigNode[] = (() => {\n\t\t\ttry {\n\t\t\t\treturn xmlParser.parse(contents, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'PhpStorm PHP configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\t\t})();\n\n\t\tconst projectElement = config.find(\n\t\t\t(c: PhpStormPHPConfigNode) => !!c?.project\n\t\t);\n\t\tconst componentIndex = projectElement?.project?.findIndex(\n\t\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t\t!!c?.component &&\n\t\t\t\tc?.[':@']?.name === 'PhpStepFilterConfiguration'\n\t\t);\n\n\t\tif (componentIndex !== undefined && componentIndex >= 0) {\n\t\t\tprojectElement!.project!.splice(componentIndex, 1);\n\n\t\t\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\t\t\tconst xml = xmlBuilder.build(config);\n\n\t\t\ttry {\n\t\t\t\txmlParser.parse(xml, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'The resulting PhpStorm PHP configuration file ' +\n\t\t\t\t\t\t'is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\txml ===\n\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t) {\n\t\t\t\tfs.unlinkSync(phpStormPHPConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(phpStormPHPConfigFilePath, xml);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst vsCodeConfigFilePath = path.join(cwd, '.vscode/launch.json');\n\t// VSCode\n\tif (fs.existsSync(vsCodeConfigFilePath)) {\n\t\tconst errors: JSONC.ParseError[] = [];\n\n\t\tconst content = fs.readFileSync(vsCodeConfigFilePath, 'utf-8');\n\t\tconst root = JSONC.parseTree(content, errors, jsoncParseOptions);\n\n\t\tif (root === undefined || errors.length) {\n\t\t\tthrow new Error('VS Code configuration file is not valid JSON.');\n\t\t}\n\n\t\tconst configurationsNode = JSONC.findNodeAtLocation(root, [\n\t\t\t'configurations',\n\t\t]);\n\n\t\tconst configurationIndex = configurationsNode?.children?.findIndex(\n\t\t\t(child: any) =>\n\t\t\t\tJSONC.findNodeAtLocation(child, ['name'])?.value === name\n\t\t);\n\n\t\tif (configurationIndex !== undefined && configurationIndex >= 0) {\n\t\t\tconst edits = JSONC.modify(\n\t\t\t\tcontent,\n\t\t\t\t['configurations', configurationIndex],\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tformattingOptions: {\n\t\t\t\t\t\tinsertSpaces: true,\n\t\t\t\t\t\ttabSize: 4,\n\t\t\t\t\t\teol: '\\n',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst json = jsoncApplyEdits(content, edits);\n\t\t\tif (json === '{\\n \"configurations\": []\\n}') {\n\t\t\t\tfs.unlinkSync(vsCodeConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(vsCodeConfigFilePath, json);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Implement path mapping and path skipping in Xdebug.\n *\n * @param name The configuration name.\n * @param mounts The mounts options.\n * @param pathSkippings The skipping paths options.\n * @returns Xdebug options\n */\nexport function makeXdebugConfig({\n\tcwd,\n\tmounts,\n\tpathSkippings,\n}: XdebugConfig): XdebugOptions {\n\tconst pathMappings =\n\t\tcwd && mounts ? filterLocalMounts(cwd, mounts) : undefined;\n\n\treturn { pathMappings, pathSkippings };\n}\n\nfunction jsoncApplyEdits(content: string, edits: JSONC.Edit[]) {\n\tconst errors: JSONC.ParseError[] = [];\n\tconst json = JSONC.applyEdits(content, edits);\n\n\terrors.length = 0;\n\n\tJSONC.parseTree(json, errors, jsoncParseOptions);\n\n\tif (errors.length) {\n\t\tconst formattedErrors = errors\n\t\t\t.map((error) => {\n\t\t\t\treturn {\n\t\t\t\t\tmessage: JSONC.printParseErrorCode(error.error),\n\t\t\t\t\toffset: error.offset,\n\t\t\t\t\tlength: error.length,\n\t\t\t\t\tfragment: json.slice(\n\t\t\t\t\t\tMath.max(0, error.offset - 20),\n\t\t\t\t\t\tMath.min(json.length, error.offset + error.length + 10)\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.map(\n\t\t\t\t(error) =>\n\t\t\t\t\t`${error.message} at ${error.offset}:${error.length} (${error.fragment})`\n\t\t\t);\n\t\tconst formattedEdits = edits.map(\n\t\t\t(edit) => `At ${edit.offset}:${edit.length} - (${edit.content})`\n\t\t);\n\t\tthrow new Error(\n\t\t\t`VS Code configuration file (.vscode/launch.json) is not valid a JSONC after CLI modifications. This is likely ` +\n\t\t\t\t`a CLI bug. Please report it at https://github.com/WordPress/wordpress-playground/issues and include the contents ` +\n\t\t\t\t`of your \".vscode/launch.json\" file. \\n\\n Applied edits: ${formattedEdits.join(\n\t\t\t\t\t'\\n'\n\t\t\t\t)}\\n\\n The errors are: ${formattedErrors.join('\\n')}`\n\t\t);\n\t}\n\n\treturn json;\n}\n"],"names":["CLIOutput","options","text","message","DEFAULT_IDE_KEY","DEFAULT_PATH_SKIPPINGS","createTempDirSymlink","nativeDirPath","symlinkPath","platform","type","fs","removeTempDirSymlink","filterLocalMounts","cwd","mounts","mount","absoluteHostPath","path","cwdChildPrefix","xmlParserOptions","xmlBuilderOptions","jsoncParseOptions","updatePhpStormWorkspaceConfig","xmlContent","name","host","port","pathMappings","ideKey","xmlParser","XMLParser","config","serverElement","pathMapping","toPosixPath","projectElement","c","projectVersion","_a","componentElement","_b","serversElement","_c","serverElementIndex","_d","runManagerElement","_e","_f","runConfigElement","xml","XMLBuilder","updatePhpStormPHPConfig","pathSkippings","skippedFilesElement","skippedPath","filePath","updateVSCodeConfig","jsonContent","errors","content","root","JSONC","configurationsNode","edits","configurationIndex","child","configuration","acc","currentLength","jsoncApplyEdits","addXdebugIDEConfig","ides","modifiedConfig","phpStormRelativeConfigFilePath","phpStormConfigFilePath","contents","updatedXml","phpStormRelativePHPConfigFilePath","phpStormPHPConfigFilePath","vsCodeRelativeConfigFilePath","vsCodeConfigFilePath","updatedJson","clearXdebugIDEConfig","componentIndex","json","makeXdebugConfig","formattedErrors","error","formattedEdits","edit"],"mappings":"qeAOO,MAAMA,CAAU,CAItB,YAAYC,EAA2B,CACtC,KAAK,UAAYA,EAAQ,UACzB,KAAK,YAAcA,EAAQ,aAAe,QAAQ,MACnD,CAEA,IAAI,OAAiB,CACpB,MAAO,EAAQ,KAAK,YAAY,KACjC,CAEA,IAAI,SAAmB,CACtB,OAAO,KAAK,YAAc,OAC3B,CASA,KAAKC,EAAsB,CAC1B,OAAO,KAAK,MAAQ,UAAUA,CAAI,UAAYA,CAC/C,CAEA,IAAIA,EAAsB,CACzB,OAAO,KAAK,MAAQ,UAAUA,CAAI,UAAYA,CAC/C,CAEA,OAAOA,EAAsB,CAC5B,OAAO,KAAK,MAAQ,UAAUA,CAAI,UAAYA,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DD,EAAe,KACzE;AAAA,CAAA,CACA;AAAA;AAAA,mBAAwBF,EAAgB,KAAK;AAAA,CAAI,CAAC,EAAA,CAEtD,CAEA,OAAOF,CACR"} |
+263
-208
@@ -1,7 +0,61 @@ | ||
| import a from "fs"; | ||
| import w from "path"; | ||
| import { toPosixPath as $ } from "@php-wasm/util"; | ||
| import { XMLParser as F, XMLBuilder as b } from "fast-xml-parser"; | ||
| import * as x from "jsonc-parser"; | ||
| const N = "PHPWASMCLI", U = [ | ||
| import p from "fs"; | ||
| import x from "path"; | ||
| import { toPosixPath as _ } from "@php-wasm/util"; | ||
| import { XMLParser as T, XMLBuilder as F } from "fast-xml-parser"; | ||
| import * as w from "jsonc-parser"; | ||
| class W { | ||
| constructor(e) { | ||
| this.verbosity = e.verbosity, this.writeStream = e.writeStream || process.stdout; | ||
| } | ||
| get isTTY() { | ||
| return !!this.writeStream.isTTY; | ||
| } | ||
| get isQuiet() { | ||
| return this.verbosity === "quiet"; | ||
| } | ||
| /** | ||
| * ANSI formatting helpers. | ||
| * | ||
| * These only apply color codes when outputting to a terminal (TTY). | ||
| * When piped to files or non-TTY streams, they return plain text to | ||
| * avoid polluting logs with escape sequences. | ||
| */ | ||
| bold(e) { | ||
| return this.isTTY ? `\x1B[1m${e}\x1B[0m` : e; | ||
| } | ||
| dim(e) { | ||
| return this.isTTY ? `\x1B[2m${e}\x1B[0m` : e; | ||
| } | ||
| italic(e) { | ||
| return this.isTTY ? `\x1B[3m${e}\x1B[0m` : e; | ||
| } | ||
| red(e) { | ||
| return this.isTTY ? `\x1B[31m${e}\x1B[0m` : e; | ||
| } | ||
| green(e) { | ||
| return this.isTTY ? `\x1B[32m${e}\x1B[0m` : e; | ||
| } | ||
| yellow(e) { | ||
| return this.isTTY ? `\x1B[33m${e}\x1B[0m` : e; | ||
| } | ||
| cyan(e) { | ||
| return this.isTTY ? `\x1B[36m${e}\x1B[0m` : e; | ||
| } | ||
| highlight(e) { | ||
| return this.yellow(e); | ||
| } | ||
| print(e) { | ||
| this.isQuiet || this.writeStream.write(`${e} | ||
| `); | ||
| } | ||
| printError(e) { | ||
| this.writeStream.write(`${this.red("Error:")} ${e} | ||
| `); | ||
| } | ||
| printWarning(e) { | ||
| this.isQuiet || this.writeStream.write(`${this.yellow("Warning:")} ${e} | ||
| `); | ||
| } | ||
| } | ||
| const A = "PHPWASMCLI", J = [ | ||
| "/dev/", | ||
@@ -13,4 +67,4 @@ "/home/", | ||
| ]; | ||
| async function W(u, f, l) { | ||
| const d = l === "win32" ? ( | ||
| async function U(u, e, f) { | ||
| const m = f === "win32" ? ( | ||
| // On Windows, creating a 'dir' symlink can require elevated permissions. | ||
@@ -21,17 +75,17 @@ // In this case, let's make junction points because they function like | ||
| ) : "dir"; | ||
| a.symlinkSync(u, f, d); | ||
| p.symlinkSync(u, e, m); | ||
| } | ||
| async function q(u) { | ||
| try { | ||
| a.lstatSync(u).isSymbolicLink() && a.unlinkSync(u); | ||
| p.lstatSync(u).isSymbolicLink() && p.unlinkSync(u); | ||
| } catch { | ||
| } | ||
| } | ||
| function D(u, f) { | ||
| return f.filter((l) => { | ||
| const d = w.resolve(l.hostPath), c = w.join(u, w.sep); | ||
| function M(u, e) { | ||
| return e.filter((f) => { | ||
| const m = x.resolve(f.hostPath), c = x.join(u, x.sep); | ||
| return ( | ||
| // If auto-mounting from the current directory, | ||
| // the entire project directory can be mapped. | ||
| d === u || d.startsWith(c) | ||
| m === u || m.startsWith(c) | ||
| ); | ||
@@ -48,3 +102,3 @@ }); | ||
| trimValues: !0 | ||
| }, I = { | ||
| }, b = { | ||
| ignoreAttributes: E.ignoreAttributes, | ||
@@ -58,9 +112,9 @@ attributeNamePrefix: E.attributeNamePrefix, | ||
| indentBy: " " | ||
| }, k = { | ||
| }, $ = { | ||
| allowEmptyContent: !0, | ||
| allowTrailingComma: !0 | ||
| }; | ||
| function X(u, f) { | ||
| var S, C, L, T, _, M; | ||
| const { name: l, host: d, port: c, pathMappings: h, ideKey: t } = f, P = new F(E), v = (() => { | ||
| function N(u, e) { | ||
| var S, C, I, B, k, L; | ||
| const { name: f, host: m, port: c, pathMappings: h, ideKey: o } = e, P = new T(E), v = (() => { | ||
| try { | ||
@@ -74,7 +128,7 @@ return P.parse(u, !0); | ||
| ":@": { | ||
| name: l, | ||
| name: f, | ||
| // NOTE: PhpStorm quirk: Xdebug only works when the full URL (including port) | ||
| // is provided in `host`. The separate `port` field is ignored or misinterpreted, | ||
| // so we rely solely on host: "host:port". | ||
| host: `${d}:${c}`, | ||
| host: `${m}:${c}`, | ||
| use_path_mappings: "true" | ||
@@ -87,4 +141,4 @@ } | ||
| ":@": { | ||
| "local-root": `$PROJECT_DIR$/${$( | ||
| w.relative(f.projectDir, n.hostPath) | ||
| "local-root": `$PROJECT_DIR$/${_( | ||
| x.relative(e.projectDir, n.hostPath) | ||
| )}`, | ||
@@ -95,7 +149,7 @@ "remote-root": n.vfsPath | ||
| )); | ||
| let p = v == null ? void 0 : v.find( | ||
| let l = v == null ? void 0 : v.find( | ||
| (n) => !!(n != null && n.project) | ||
| ); | ||
| if (p) { | ||
| const n = (S = p[":@"]) == null ? void 0 : S.version; | ||
| if (l) { | ||
| const n = (S = l[":@"]) == null ? void 0 : S.version; | ||
| if (n === void 0) | ||
@@ -110,7 +164,7 @@ throw new Error( | ||
| } | ||
| p === void 0 && (p = { | ||
| l === void 0 && (l = { | ||
| project: [], | ||
| ":@": { version: "4" } | ||
| }, v.push(p)); | ||
| let o = (C = p.project) == null ? void 0 : C.find( | ||
| }, v.push(l)); | ||
| let i = (C = l.project) == null ? void 0 : C.find( | ||
| (n) => { | ||
@@ -121,18 +175,18 @@ var j; | ||
| ); | ||
| o === void 0 && (o = { | ||
| i === void 0 && (i = { | ||
| component: [], | ||
| ":@": { name: "PhpServers" } | ||
| }, p.project === void 0 && (p.project = []), p.project.push(o)); | ||
| let i = (L = o.component) == null ? void 0 : L.find( | ||
| }, l.project === void 0 && (l.project = []), l.project.push(i)); | ||
| let r = (I = i.component) == null ? void 0 : I.find( | ||
| (n) => !!(n != null && n.servers) | ||
| ); | ||
| i === void 0 && (i = { servers: [] }, o.component === void 0 && (o.component = []), o.component.push(i)); | ||
| const r = (T = i.servers) == null ? void 0 : T.findIndex( | ||
| r === void 0 && (r = { servers: [] }, i.component === void 0 && (i.component = []), i.component.push(r)); | ||
| const s = (B = r.servers) == null ? void 0 : B.findIndex( | ||
| (n) => { | ||
| var j; | ||
| return !!(n != null && n.server) && ((j = n == null ? void 0 : n[":@"]) == null ? void 0 : j.name) === l; | ||
| return !!(n != null && n.server) && ((j = n == null ? void 0 : n[":@"]) == null ? void 0 : j.name) === f; | ||
| } | ||
| ); | ||
| (r === void 0 || r < 0) && (i.servers === void 0 && (i.servers = []), i.servers.push(y)); | ||
| let e = (_ = p.project) == null ? void 0 : _.find( | ||
| (s === void 0 || s < 0) && (r.servers === void 0 && (r.servers = []), r.servers.push(y)); | ||
| let t = (k = l.project) == null ? void 0 : k.find( | ||
| (n) => { | ||
@@ -143,9 +197,9 @@ var j; | ||
| ); | ||
| if (e === void 0 && (e = { | ||
| if (t === void 0 && (t = { | ||
| component: [], | ||
| ":@": { name: "RunManager" } | ||
| }, p.project === void 0 && (p.project = []), p.project.push(e)), (((M = e.component) == null ? void 0 : M.findIndex( | ||
| }, l.project === void 0 && (l.project = []), l.project.push(t)), (((L = t.component) == null ? void 0 : L.findIndex( | ||
| (n) => { | ||
| var j; | ||
| return !!(n != null && n.configuration) && ((j = n == null ? void 0 : n[":@"]) == null ? void 0 : j.name) === l; | ||
| return !!(n != null && n.configuration) && ((j = n == null ? void 0 : n[":@"]) == null ? void 0 : j.name) === f; | ||
| } | ||
@@ -161,15 +215,15 @@ )) ?? -1) < 0) { | ||
| ":@": { | ||
| name: l, | ||
| name: f, | ||
| type: "PhpRemoteDebugRunConfigurationType", | ||
| factoryName: "PHP Remote Debug", | ||
| filter_connections: "FILTER", | ||
| server_name: l, | ||
| session_id: t | ||
| server_name: f, | ||
| session_id: o | ||
| } | ||
| }; | ||
| e.component === void 0 && (e.component = []), e.component.push(n); | ||
| t.component === void 0 && (t.component = []), t.component.push(n); | ||
| } | ||
| const m = new b(I).build(v); | ||
| const d = new F(b).build(v); | ||
| try { | ||
| P.parse(m, !0); | ||
| P.parse(d, !0); | ||
| } catch { | ||
@@ -180,9 +234,9 @@ throw new Error( | ||
| } | ||
| return m; | ||
| return d; | ||
| } | ||
| function B(u, f) { | ||
| var p, o, i, r; | ||
| const { pathSkippings: l } = f, d = new F(E), c = (() => { | ||
| function O(u, e) { | ||
| var l, i, r, s; | ||
| const { pathSkippings: f } = e, m = new T(E), c = (() => { | ||
| try { | ||
| return d.parse(u, !0); | ||
| return m.parse(u, !0); | ||
| } catch { | ||
@@ -195,13 +249,13 @@ throw new Error( | ||
| let h = c == null ? void 0 : c.find( | ||
| (e) => !!(e != null && e.project) | ||
| (t) => !!(t != null && t.project) | ||
| ); | ||
| if (h) { | ||
| const e = (p = h[":@"]) == null ? void 0 : p.version; | ||
| if (e === void 0) | ||
| const t = (l = h[":@"]) == null ? void 0 : l.version; | ||
| if (t === void 0) | ||
| throw new Error( | ||
| 'PhpStorm IDE integration only supports <project version="4"> in php.xml, but the <project> configuration has no version number.' | ||
| ); | ||
| if (e !== "4") | ||
| if (t !== "4") | ||
| throw new Error( | ||
| `PhpStorm IDE integration only supports <project version="4"> in php.xml, but we found a <project> configuration with version "${e}".` | ||
| `PhpStorm IDE integration only supports <project version="4"> in php.xml, but we found a <project> configuration with version "${t}".` | ||
| ); | ||
@@ -213,19 +267,19 @@ } | ||
| }, c.push(h)); | ||
| let t = (o = h.project) == null ? void 0 : o.find( | ||
| (e) => { | ||
| var s; | ||
| return !!(e != null && e.component) && ((s = e == null ? void 0 : e[":@"]) == null ? void 0 : s.name) === "PhpStepFilterConfiguration"; | ||
| let o = (i = h.project) == null ? void 0 : i.find( | ||
| (t) => { | ||
| var a; | ||
| return !!(t != null && t.component) && ((a = t == null ? void 0 : t[":@"]) == null ? void 0 : a.name) === "PhpStepFilterConfiguration"; | ||
| } | ||
| ); | ||
| t === void 0 && (t = { | ||
| o === void 0 && (o = { | ||
| component: [], | ||
| ":@": { name: "PhpStepFilterConfiguration" } | ||
| }, h.project === void 0 && (h.project = []), h.project.push(t)); | ||
| let P = (i = t.component) == null ? void 0 : i.find( | ||
| (e) => !!(e != null && e.skipped_files) | ||
| }, h.project === void 0 && (h.project = []), h.project.push(o)); | ||
| let P = (r = o.component) == null ? void 0 : r.find( | ||
| (t) => !!(t != null && t.skipped_files) | ||
| ); | ||
| if (P === void 0 && (P = { skipped_files: [] }, t.component === void 0 && (t.component = []), t.component.push(P)), l && l.length) | ||
| for (const e of l) { | ||
| const g = `$PROJECT_DIR$${e.endsWith("/") ? e.slice(0, -1) : e}`; | ||
| ((r = P.skipped_files) == null ? void 0 : r.some( | ||
| if (P === void 0 && (P = { skipped_files: [] }, o.component === void 0 && (o.component = []), o.component.push(P)), f && f.length) | ||
| for (const t of f) { | ||
| const g = `$PROJECT_DIR$${t.endsWith("/") ? t.slice(0, -1) : t}`; | ||
| ((s = P.skipped_files) == null ? void 0 : s.some( | ||
| (S) => { | ||
@@ -240,5 +294,5 @@ var C; | ||
| } | ||
| const y = new b(I).build(c); | ||
| const y = new F(b).build(c); | ||
| try { | ||
| d.parse(y, !0); | ||
| m.parse(y, !0); | ||
| } catch { | ||
@@ -251,24 +305,24 @@ throw new Error( | ||
| } | ||
| function O(u, f) { | ||
| var p, o; | ||
| const { name: l, pathMappings: d, pathSkippings: c } = f, h = []; | ||
| let t = u, P = x.parseTree(t, h, k); | ||
| function X(u, e) { | ||
| var l, i; | ||
| const { name: f, pathMappings: m, pathSkippings: c } = e, h = []; | ||
| let o = u, P = w.parseTree(o, h, $); | ||
| if (P === void 0 || h.length) | ||
| throw new Error("VS Code configuration file is not valid JSON."); | ||
| let v = x.findNodeAtLocation(P, ["configurations"]); | ||
| let v = w.findNodeAtLocation(P, ["configurations"]); | ||
| if (v === void 0 || v.children === void 0) { | ||
| const i = x.modify(t, ["configurations"], [], {}); | ||
| t = x.applyEdits(t, i), P = x.parseTree(t, [], k), v = x.findNodeAtLocation(P, [ | ||
| const r = w.modify(o, ["configurations"], [], {}); | ||
| o = w.applyEdits(o, r), P = w.parseTree(o, [], $), v = w.findNodeAtLocation(P, [ | ||
| "configurations" | ||
| ]); | ||
| } | ||
| const y = (p = v == null ? void 0 : v.children) == null ? void 0 : p.findIndex( | ||
| (i) => { | ||
| var r; | ||
| return ((r = x.findNodeAtLocation(i, ["name"])) == null ? void 0 : r.value) === l; | ||
| const y = (l = v == null ? void 0 : v.children) == null ? void 0 : l.findIndex( | ||
| (r) => { | ||
| var s; | ||
| return ((s = w.findNodeAtLocation(r, ["name"])) == null ? void 0 : s.value) === f; | ||
| } | ||
| ); | ||
| if (y === void 0 || y < 0) { | ||
| const i = { | ||
| name: l, | ||
| const r = { | ||
| name: f, | ||
| type: "php", | ||
@@ -278,11 +332,11 @@ request: "launch", | ||
| }; | ||
| d && d.length && (i.pathMappings = d.reduce((s, g) => (s[g.vfsPath] = `\${workspaceFolder}/${$( | ||
| w.relative(f.workspaceDir, g.hostPath) | ||
| )}`, s), {})), c && c.length && (i.skipFiles = c.map( | ||
| (s) => s.endsWith("/") ? `${s}**` : s | ||
| m && m.length && (r.pathMappings = m.reduce((a, g) => (a[g.vfsPath] = `\${workspaceFolder}/${_( | ||
| x.relative(e.workspaceDir, g.hostPath) | ||
| )}`, a), {})), c && c.length && (r.skipFiles = c.map( | ||
| (a) => a.endsWith("/") ? `${a}**` : a | ||
| )); | ||
| const r = ((o = v == null ? void 0 : v.children) == null ? void 0 : o.length) || 0, e = x.modify( | ||
| t, | ||
| ["configurations", r], | ||
| i, | ||
| const s = ((i = v == null ? void 0 : v.children) == null ? void 0 : i.length) || 0, t = w.modify( | ||
| o, | ||
| ["configurations", s], | ||
| r, | ||
| { | ||
@@ -297,26 +351,26 @@ formattingOptions: { | ||
| ); | ||
| t = A(t, e); | ||
| o = D(o, t); | ||
| } | ||
| return t; | ||
| return o; | ||
| } | ||
| async function z({ | ||
| name: u, | ||
| ides: f, | ||
| host: l, | ||
| port: d, | ||
| ides: e, | ||
| host: f, | ||
| port: m, | ||
| cwd: c, | ||
| mounts: h, | ||
| pathSkippings: t, | ||
| ideKey: P = N | ||
| pathSkippings: o, | ||
| ideKey: P = A | ||
| }) { | ||
| const v = h ? D(c, h) : [], y = {}; | ||
| if (f.includes("phpstorm")) { | ||
| const p = ".idea/workspace.xml", o = w.join( | ||
| const v = h ? M(c, h) : [], y = {}; | ||
| if (e.includes("phpstorm")) { | ||
| const l = ".idea/workspace.xml", i = x.join( | ||
| c, | ||
| p | ||
| l | ||
| ); | ||
| if (!a.existsSync(o)) { | ||
| if (a.existsSync(w.dirname(o))) | ||
| a.writeFileSync( | ||
| o, | ||
| if (!p.existsSync(i)) { | ||
| if (p.existsSync(x.dirname(i))) | ||
| p.writeFileSync( | ||
| i, | ||
| `<?xml version="1.0" encoding="UTF-8"?> | ||
@@ -326,3 +380,3 @@ <project version="4"> | ||
| ); | ||
| else if (f.length == 1) | ||
| else if (e.length == 1) | ||
| throw new Error( | ||
@@ -332,7 +386,7 @@ "PhpStorm IDE integration requested, but no '.idea' directory was found in the current working directory." | ||
| } | ||
| if (a.existsSync(o)) { | ||
| const i = a.readFileSync(o, "utf8"), r = X(i, { | ||
| if (p.existsSync(i)) { | ||
| const r = p.readFileSync(i, "utf8"), s = N(r, { | ||
| name: u, | ||
| host: l, | ||
| port: d, | ||
| host: f, | ||
| port: m, | ||
| projectDir: c, | ||
@@ -342,34 +396,34 @@ pathMappings: v, | ||
| }); | ||
| a.writeFileSync(o, r), y.phpstorm = p; | ||
| p.writeFileSync(i, s), y.phpstorm = l; | ||
| } | ||
| if (t && t.length) { | ||
| const i = ".idea/php.xml", r = w.join( | ||
| if (o && o.length) { | ||
| const r = ".idea/php.xml", s = x.join( | ||
| c, | ||
| i | ||
| r | ||
| ); | ||
| if (a.existsSync(r) || a.existsSync(w.dirname(r)) && a.writeFileSync( | ||
| r, | ||
| if (p.existsSync(s) || p.existsSync(x.dirname(s)) && p.writeFileSync( | ||
| s, | ||
| `<?xml version="1.0" encoding="UTF-8"?> | ||
| <project version="4"> | ||
| </project>` | ||
| ), a.existsSync(r)) { | ||
| const e = a.readFileSync( | ||
| r, | ||
| ), p.existsSync(s)) { | ||
| const t = p.readFileSync( | ||
| s, | ||
| "utf8" | ||
| ), s = B(e, { | ||
| pathSkippings: t | ||
| ), a = O(t, { | ||
| pathSkippings: o | ||
| }); | ||
| a.writeFileSync(r, s), y["phpstorm-php"] = i; | ||
| p.writeFileSync(s, a), y["phpstorm-php"] = r; | ||
| } | ||
| } | ||
| } | ||
| if (f.includes("vscode")) { | ||
| const p = ".vscode/launch.json", o = w.join( | ||
| if (e.includes("vscode")) { | ||
| const l = ".vscode/launch.json", i = x.join( | ||
| c, | ||
| p | ||
| l | ||
| ); | ||
| if (!a.existsSync(o)) { | ||
| if (a.existsSync(w.dirname(o))) | ||
| a.writeFileSync( | ||
| o, | ||
| if (!p.existsSync(i)) { | ||
| if (p.existsSync(x.dirname(i))) | ||
| p.writeFileSync( | ||
| i, | ||
| `{ | ||
@@ -379,3 +433,3 @@ "configurations": [] | ||
| ); | ||
| else if (f.length == 1) | ||
| else if (e.length == 1) | ||
| throw new Error( | ||
@@ -385,10 +439,10 @@ "VS Code IDE integration requested, but no '.vscode' directory was found in the current working directory." | ||
| } | ||
| if (a.existsSync(o)) { | ||
| const i = a.readFileSync(o, "utf-8"), r = O(i, { | ||
| if (p.existsSync(i)) { | ||
| const r = p.readFileSync(i, "utf-8"), s = X(r, { | ||
| name: u, | ||
| workspaceDir: c, | ||
| pathMappings: v, | ||
| pathSkippings: t | ||
| pathSkippings: o | ||
| }); | ||
| r !== i && (a.writeFileSync(o, r), y.vscode = p); | ||
| s !== r && (p.writeFileSync(i, s), y.vscode = l); | ||
| } | ||
@@ -398,9 +452,9 @@ } | ||
| } | ||
| async function K(u, f) { | ||
| var h, t, P, v, y; | ||
| const l = w.join(f, ".idea/workspace.xml"); | ||
| if (a.existsSync(l)) { | ||
| const p = a.readFileSync(l, "utf8"), o = new F(E), i = (() => { | ||
| async function K(u, e) { | ||
| var h, o, P, v, y; | ||
| const f = x.join(e, ".idea/workspace.xml"); | ||
| if (p.existsSync(f)) { | ||
| const l = p.readFileSync(f, "utf8"), i = new T(E), r = (() => { | ||
| try { | ||
| return o.parse(p, !0); | ||
| return i.parse(l, !0); | ||
| } catch { | ||
@@ -411,22 +465,22 @@ throw new Error( | ||
| } | ||
| })(), r = i.find( | ||
| (m) => !!(m != null && m.project) | ||
| ), e = (h = r == null ? void 0 : r.project) == null ? void 0 : h.find( | ||
| (m) => { | ||
| })(), s = r.find( | ||
| (d) => !!(d != null && d.project) | ||
| ), t = (h = s == null ? void 0 : s.project) == null ? void 0 : h.find( | ||
| (d) => { | ||
| var S; | ||
| return !!(m != null && m.component) && ((S = m == null ? void 0 : m[":@"]) == null ? void 0 : S.name) === "PhpServers"; | ||
| return !!(d != null && d.component) && ((S = d == null ? void 0 : d[":@"]) == null ? void 0 : S.name) === "PhpServers"; | ||
| } | ||
| ), s = (t = e == null ? void 0 : e.component) == null ? void 0 : t.find( | ||
| (m) => !!(m != null && m.servers) | ||
| ), g = (P = s == null ? void 0 : s.servers) == null ? void 0 : P.findIndex( | ||
| (m) => { | ||
| ), a = (o = t == null ? void 0 : t.component) == null ? void 0 : o.find( | ||
| (d) => !!(d != null && d.servers) | ||
| ), g = (P = a == null ? void 0 : a.servers) == null ? void 0 : P.findIndex( | ||
| (d) => { | ||
| var S; | ||
| return !!(m != null && m.server) && ((S = m == null ? void 0 : m[":@"]) == null ? void 0 : S.name) === u; | ||
| return !!(d != null && d.server) && ((S = d == null ? void 0 : d[":@"]) == null ? void 0 : S.name) === u; | ||
| } | ||
| ); | ||
| if (g !== void 0 && g >= 0) { | ||
| s.servers.splice(g, 1); | ||
| const S = new b(I).build(i); | ||
| a.servers.splice(g, 1); | ||
| const S = new F(b).build(r); | ||
| try { | ||
| o.parse(S, !0); | ||
| i.parse(S, !0); | ||
| } catch { | ||
@@ -442,10 +496,10 @@ throw new Error( | ||
| </component> | ||
| </project>` ? a.unlinkSync(l) : a.writeFileSync(l, S); | ||
| </project>` ? p.unlinkSync(f) : p.writeFileSync(f, S); | ||
| } | ||
| } | ||
| const d = w.join(f, ".idea/php.xml"); | ||
| if (a.existsSync(d)) { | ||
| const p = a.readFileSync(d, "utf8"), o = new F(E), i = (() => { | ||
| const m = x.join(e, ".idea/php.xml"); | ||
| if (p.existsSync(m)) { | ||
| const l = p.readFileSync(m, "utf8"), i = new T(E), r = (() => { | ||
| try { | ||
| return o.parse(p, !0); | ||
| return i.parse(l, !0); | ||
| } catch { | ||
@@ -456,15 +510,15 @@ throw new Error( | ||
| } | ||
| })(), r = i.find( | ||
| (s) => !!(s != null && s.project) | ||
| ), e = (v = r == null ? void 0 : r.project) == null ? void 0 : v.findIndex( | ||
| (s) => { | ||
| })(), s = r.find( | ||
| (a) => !!(a != null && a.project) | ||
| ), t = (v = s == null ? void 0 : s.project) == null ? void 0 : v.findIndex( | ||
| (a) => { | ||
| var g; | ||
| return !!(s != null && s.component) && ((g = s == null ? void 0 : s[":@"]) == null ? void 0 : g.name) === "PhpStepFilterConfiguration"; | ||
| return !!(a != null && a.component) && ((g = a == null ? void 0 : a[":@"]) == null ? void 0 : g.name) === "PhpStepFilterConfiguration"; | ||
| } | ||
| ); | ||
| if (e !== void 0 && e >= 0) { | ||
| r.project.splice(e, 1); | ||
| const g = new b(I).build(i); | ||
| if (t !== void 0 && t >= 0) { | ||
| s.project.splice(t, 1); | ||
| const g = new F(b).build(r); | ||
| try { | ||
| o.parse(g, !0); | ||
| i.parse(g, !0); | ||
| } catch { | ||
@@ -477,22 +531,22 @@ throw new Error( | ||
| <project version="4"> | ||
| </project>` ? a.unlinkSync(d) : a.writeFileSync(d, g); | ||
| </project>` ? p.unlinkSync(m) : p.writeFileSync(m, g); | ||
| } | ||
| } | ||
| const c = w.join(f, ".vscode/launch.json"); | ||
| if (a.existsSync(c)) { | ||
| const p = [], o = a.readFileSync(c, "utf-8"), i = x.parseTree(o, p, k); | ||
| if (i === void 0 || p.length) | ||
| const c = x.join(e, ".vscode/launch.json"); | ||
| if (p.existsSync(c)) { | ||
| const l = [], i = p.readFileSync(c, "utf-8"), r = w.parseTree(i, l, $); | ||
| if (r === void 0 || l.length) | ||
| throw new Error("VS Code configuration file is not valid JSON."); | ||
| const r = x.findNodeAtLocation(i, [ | ||
| const s = w.findNodeAtLocation(r, [ | ||
| "configurations" | ||
| ]), e = (y = r == null ? void 0 : r.children) == null ? void 0 : y.findIndex( | ||
| (s) => { | ||
| ]), t = (y = s == null ? void 0 : s.children) == null ? void 0 : y.findIndex( | ||
| (a) => { | ||
| var g; | ||
| return ((g = x.findNodeAtLocation(s, ["name"])) == null ? void 0 : g.value) === u; | ||
| return ((g = w.findNodeAtLocation(a, ["name"])) == null ? void 0 : g.value) === u; | ||
| } | ||
| ); | ||
| if (e !== void 0 && e >= 0) { | ||
| const s = x.modify( | ||
| o, | ||
| ["configurations", e], | ||
| if (t !== void 0 && t >= 0) { | ||
| const a = w.modify( | ||
| i, | ||
| ["configurations", t], | ||
| void 0, | ||
@@ -507,31 +561,31 @@ { | ||
| } | ||
| ), g = A(o, s); | ||
| ), g = D(i, a); | ||
| g === `{ | ||
| "configurations": [] | ||
| }` ? a.unlinkSync(c) : a.writeFileSync(c, g); | ||
| }` ? p.unlinkSync(c) : p.writeFileSync(c, g); | ||
| } | ||
| } | ||
| } | ||
| function G({ | ||
| function Q({ | ||
| cwd: u, | ||
| mounts: f, | ||
| pathSkippings: l | ||
| mounts: e, | ||
| pathSkippings: f | ||
| }) { | ||
| return { pathMappings: u && f ? D(u, f) : void 0, pathSkippings: l }; | ||
| return { pathMappings: u && e ? M(u, e) : void 0, pathSkippings: f }; | ||
| } | ||
| function A(u, f) { | ||
| const l = [], d = x.applyEdits(u, f); | ||
| if (l.length = 0, x.parseTree(d, l, k), l.length) { | ||
| const c = l.map((t) => ({ | ||
| message: x.printParseErrorCode(t.error), | ||
| offset: t.offset, | ||
| length: t.length, | ||
| fragment: d.slice( | ||
| Math.max(0, t.offset - 20), | ||
| Math.min(d.length, t.offset + t.length + 10) | ||
| function D(u, e) { | ||
| const f = [], m = w.applyEdits(u, e); | ||
| if (f.length = 0, w.parseTree(m, f, $), f.length) { | ||
| const c = f.map((o) => ({ | ||
| message: w.printParseErrorCode(o.error), | ||
| offset: o.offset, | ||
| length: o.length, | ||
| fragment: m.slice( | ||
| Math.max(0, o.offset - 20), | ||
| Math.min(m.length, o.offset + o.length + 10) | ||
| ) | ||
| })).map( | ||
| (t) => `${t.message} at ${t.offset}:${t.length} (${t.fragment})` | ||
| ), h = f.map( | ||
| (t) => `At ${t.offset}:${t.length} - (${t.content})` | ||
| (o) => `${o.message} at ${o.offset}:${o.length} (${o.fragment})` | ||
| ), h = e.map( | ||
| (o) => `At ${o.offset}:${o.length} - (${o.content})` | ||
| ); | ||
@@ -550,16 +604,17 @@ throw new Error( | ||
| } | ||
| return d; | ||
| return m; | ||
| } | ||
| export { | ||
| N as DEFAULT_IDE_KEY, | ||
| U as DEFAULT_PATH_SKIPPINGS, | ||
| W as CLIOutput, | ||
| A as DEFAULT_IDE_KEY, | ||
| J as DEFAULT_PATH_SKIPPINGS, | ||
| z as addXdebugIDEConfig, | ||
| K as clearXdebugIDEConfig, | ||
| W as createTempDirSymlink, | ||
| G as makeXdebugConfig, | ||
| U as createTempDirSymlink, | ||
| Q as makeXdebugConfig, | ||
| q as removeTempDirSymlink, | ||
| B as updatePhpStormPHPConfig, | ||
| X as updatePhpStormWorkspaceConfig, | ||
| O as updateVSCodeConfig | ||
| O as updatePhpStormPHPConfig, | ||
| N as updatePhpStormWorkspaceConfig, | ||
| X as updateVSCodeConfig | ||
| }; | ||
| //# sourceMappingURL=index.js.map |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sources":["../../../../packages/php-wasm/cli-util/src/lib/xdebug-path-mappings.ts"],"sourcesContent":["import fs from 'fs';\nimport path from 'path';\nimport { toPosixPath } from '@php-wasm/util';\nimport type { Mount } from './mounts';\nimport {\n\ttype X2jOptions,\n\ttype XmlBuilderOptions,\n\tXMLParser,\n\tXMLBuilder,\n} from 'fast-xml-parser';\nimport * as JSONC from 'jsonc-parser';\n\nexport interface XdebugOptions {\n\tideKey?: string;\n\tpathMappings?: Mount[];\n\tpathSkippings?: string[];\n}\n\nexport const DEFAULT_IDE_KEY = 'PHPWASMCLI';\nexport const DEFAULT_PATH_SKIPPINGS = [\n\t'/dev/',\n\t'/home/',\n\t'/internal/',\n\t'/request/',\n\t'/proc/',\n];\n\n/**\n * Create a symlink to a tempory directory.\n *\n * The symlink is created to access the system temp dir\n * inside the current debugging directory.\n *\n * @param nativeDirPath The system temp dir path.\n * @param symlinkPath The symlink name.\n */\nexport async function createTempDirSymlink(\n\tnativeDirPath: string,\n\tsymlinkPath: string,\n\tplatform: string\n) {\n\tconst type =\n\t\tplatform === 'win32'\n\t\t\t? // On Windows, creating a 'dir' symlink can require elevated permissions.\n\t\t\t\t// In this case, let's make junction points because they function like\n\t\t\t\t// symlinks and do not require elevated permissions.\n\t\t\t\t'junction'\n\t\t\t: 'dir';\n\tfs.symlinkSync(nativeDirPath, symlinkPath, type);\n}\n\n/**\n * Remove the given temporary directory symlink if it exists.\n *\n * @param symlinkPath The symlink path.\n */\nexport async function removeTempDirSymlink(symlinkPath: string) {\n\ttry {\n\t\tconst stats = fs.lstatSync(symlinkPath);\n\t\tif (stats.isSymbolicLink()) {\n\t\t\tfs.unlinkSync(symlinkPath);\n\t\t}\n\t} catch {\n\t\t// Symlink does not exist or cannot be accessed, nothing to remove\n\t}\n}\n\n/**\n * Filters out mounts that are not in the current working directory\n *\n * @param mounts The mounts list.\n */\nfunction filterLocalMounts(cwd: string, mounts: Mount[]) {\n\treturn mounts.filter((mount) => {\n\t\tconst absoluteHostPath = path.resolve(mount.hostPath);\n\t\tconst cwdChildPrefix = path.join(cwd, path.sep);\n\t\treturn (\n\t\t\t// If auto-mounting from the current directory,\n\t\t\t// the entire project directory can be mapped.\n\t\t\tabsoluteHostPath === cwd ||\n\t\t\tabsoluteHostPath.startsWith(cwdChildPrefix)\n\t\t);\n\t});\n}\n\nexport type XdebugConfig = {\n\t/**\n\t * The current working directory to consider for debugger path mapping.\n\t */\n\tcwd?: string;\n\t/**\n\t * The mounts to consider for debugger path mapping.\n\t */\n\tmounts?: Mount[];\n\t/**\n\t * The paths to consider for debugger path skipping.\n\t */\n\tpathSkippings?: string[];\n};\n\nexport type IDEConfig = {\n\t/**\n\t * The name of the configuration within the IDE configuration.\n\t */\n\tname: string;\n\t/**\n\t * The IDEs to configure.\n\t */\n\tides: string[];\n\t/**\n\t * The web server host.\n\t */\n\thost: string;\n\t/**\n\t * The web server port.\n\t */\n\tport: number;\n\t/**\n\t * The current working directory to consider for debugger path mapping.\n\t */\n\tcwd: string;\n\t/**\n\t * The mounts to consider for debugger path mapping.\n\t */\n\tmounts?: Mount[];\n\t/**\n\t * The paths to skip when debugging.\n\t */\n\tpathSkippings?: string[];\n\t/**\n\t * The IDE key to use for the debug configuration. Defaults to 'PHPWASMCLI'.\n\t */\n\tideKey?: string;\n};\n\ntype PhpStormWorkspaceConfigMetaData = {\n\tname?: string;\n\tversion?: string;\n\thost?: string;\n\tuse_path_mappings?: string;\n\t'local-root'?: string;\n\t'remote-root'?: string;\n\ttype?: 'PhpRemoteDebugRunConfigurationType';\n\tfactoryName?: string;\n\tfilter_connections?: 'FILTER';\n\tserver_name?: string;\n\tsession_id?: string;\n\tv?: string;\n};\n\ntype PhpStormWorkspaceConfigNode = {\n\t':@'?: PhpStormWorkspaceConfigMetaData;\n\tproject?: PhpStormWorkspaceConfigNode[];\n\tcomponent?: PhpStormWorkspaceConfigNode[];\n\tservers?: PhpStormWorkspaceConfigNode[];\n\tserver?: PhpStormWorkspaceConfigNode[];\n\tpath_mappings?: PhpStormWorkspaceConfigNode[];\n\tmapping?: PhpStormWorkspaceConfigNode[];\n\tconfiguration?: PhpStormWorkspaceConfigNode[];\n\tmethod?: PhpStormWorkspaceConfigNode[];\n};\n\ntype PhpStormPHPConfigMetaData = {\n\tname?: string;\n\tversion?: string;\n\tfile?: string;\n};\n\ntype PhpStormPHPConfigNode = {\n\t':@'?: PhpStormPHPConfigMetaData;\n\tproject?: PhpStormPHPConfigNode[];\n\tcomponent?: PhpStormPHPConfigNode[];\n\tskipped_files?: PhpStormPHPConfigNode[];\n\tskipped_file?: PhpStormPHPConfigNode[];\n};\n\ntype VSCodeConfigMetaData = {\n\t[key: string]: string;\n};\n\ntype VSCodeConfigNode = {\n\tname: string;\n\ttype: string;\n\trequest: string;\n\tport: number;\n\tpathMappings?: VSCodeConfigMetaData;\n\tskipFiles?: string[];\n};\n\nconst xmlParserOptions: X2jOptions = {\n\tignoreAttributes: false,\n\tattributeNamePrefix: '',\n\tpreserveOrder: true,\n\tcdataPropName: '__cdata',\n\tcommentPropName: '__xmlComment',\n\tallowBooleanAttributes: true,\n\ttrimValues: true,\n};\nconst xmlBuilderOptions: XmlBuilderOptions = {\n\tignoreAttributes: xmlParserOptions.ignoreAttributes,\n\tattributeNamePrefix: xmlParserOptions.attributeNamePrefix,\n\tpreserveOrder: xmlParserOptions.preserveOrder,\n\tcdataPropName: xmlParserOptions.cdataPropName,\n\tcommentPropName: xmlParserOptions.commentPropName,\n\tsuppressBooleanAttributes: !xmlParserOptions.allowBooleanAttributes,\n\tformat: true,\n\tindentBy: '\\t',\n};\n\nconst jsoncParseOptions: JSONC.ParseOptions = {\n\tallowEmptyContent: true,\n\tallowTrailingComma: true,\n};\n\nexport type PhpStormWorkspaceConfigOptions = {\n\tname: string;\n\thost: string;\n\tport: number;\n\tprojectDir: string;\n\tpathMappings?: Mount[];\n\tideKey: string;\n};\n\n/**\n * Pure function to update PHPStorm XML config with Xdebug server and run configuration.\n *\n * @param xmlContent The original XML content of workspace.xml\n * @param options Configuration options for the server\n * @returns Updated XML content\n * @throws Error if XML is invalid or configuration is incompatible\n */\nexport function updatePhpStormWorkspaceConfig(\n\txmlContent: string,\n\toptions: PhpStormWorkspaceConfigOptions\n): string {\n\tconst { name, host, port, pathMappings, ideKey } = options;\n\n\tconst xmlParser = new XMLParser(xmlParserOptions);\n\n\t// Parse the XML\n\tconst config: PhpStormWorkspaceConfigNode[] = (() => {\n\t\ttry {\n\t\t\treturn xmlParser.parse(xmlContent, true);\n\t\t} catch {\n\t\t\tthrow new Error('PhpStorm configuration file is not valid XML.');\n\t\t}\n\t})();\n\n\t// Create the server element with path mappings\n\tconst serverElement: PhpStormWorkspaceConfigNode = {\n\t\tserver: [{}],\n\t\t':@': {\n\t\t\tname,\n\t\t\t// NOTE: PhpStorm quirk: Xdebug only works when the full URL (including port)\n\t\t\t// is provided in `host`. The separate `port` field is ignored or misinterpreted,\n\t\t\t// so we rely solely on host: \"host:port\".\n\t\t\thost: `${host}:${port}`,\n\t\t\tuse_path_mappings: 'true',\n\t\t},\n\t};\n\n\tif (pathMappings && pathMappings.length) {\n\t\tserverElement.server![0].path_mappings = pathMappings.map(\n\t\t\t(pathMapping) => ({\n\t\t\t\tmapping: [],\n\t\t\t\t':@': {\n\t\t\t\t\t'local-root': `$PROJECT_DIR$/${toPosixPath(\n\t\t\t\t\t\tpath.relative(options.projectDir, pathMapping.hostPath)\n\t\t\t\t\t)}`,\n\t\t\t\t\t'remote-root': pathMapping.vfsPath,\n\t\t\t\t},\n\t\t\t})\n\t\t);\n\t}\n\n\t// Find or create project element\n\tlet projectElement = config?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.project\n\t);\n\tif (projectElement) {\n\t\tconst projectVersion = projectElement[':@']?.version;\n\t\tif (projectVersion === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports <project version=\"4\"> in workspace.xml, ' +\n\t\t\t\t\t'but the <project> configuration has no version number.'\n\t\t\t);\n\t\t} else if (projectVersion !== '4') {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports <project version=\"4\"> in workspace.xml, ' +\n\t\t\t\t\t`but we found a <project> configuration with version \"${projectVersion}\".`\n\t\t\t);\n\t\t}\n\t}\n\tif (projectElement === undefined) {\n\t\tprojectElement = {\n\t\t\tproject: [],\n\t\t\t':@': { version: '4' },\n\t\t};\n\t\tconfig.push(projectElement);\n\t}\n\n\t// Find or create PhpServers component\n\tlet componentElement = projectElement.project?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'PhpServers'\n\t);\n\tif (componentElement === undefined) {\n\t\tcomponentElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'PhpServers' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(componentElement);\n\t}\n\n\t// Find or create servers element\n\tlet serversElement = componentElement.component?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.servers\n\t);\n\tif (serversElement === undefined) {\n\t\tserversElement = { servers: [] };\n\n\t\tif (componentElement.component === undefined) {\n\t\t\tcomponentElement.component = [];\n\t\t}\n\n\t\tcomponentElement.component.push(serversElement);\n\t}\n\n\t// Check if server already exists\n\tconst serverElementIndex = serversElement.servers?.findIndex(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.server && c?.[':@']?.name === name\n\t);\n\n\t// Only add server if it doesn't exist\n\tif (serverElementIndex === undefined || serverElementIndex < 0) {\n\t\tif (serversElement.servers === undefined) {\n\t\t\tserversElement.servers = [];\n\t\t}\n\n\t\tserversElement.servers.push(serverElement);\n\t}\n\n\t// Find or create RunManager component\n\tlet runManagerElement = projectElement.project?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'RunManager'\n\t);\n\tif (runManagerElement === undefined) {\n\t\trunManagerElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'RunManager' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(runManagerElement);\n\t}\n\n\t// Check if run configuration already exists\n\tconst existingConfigIndex =\n\t\trunManagerElement.component?.findIndex(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.configuration && c?.[':@']?.name === name\n\t\t) ?? -1;\n\n\t// Only add run configuration if it doesn't exist\n\tif (existingConfigIndex < 0) {\n\t\tconst runConfigElement: PhpStormWorkspaceConfigNode = {\n\t\t\tconfiguration: [\n\t\t\t\t{\n\t\t\t\t\tmethod: [],\n\t\t\t\t\t':@': { v: '2' },\n\t\t\t\t},\n\t\t\t],\n\t\t\t':@': {\n\t\t\t\tname: name,\n\t\t\t\ttype: 'PhpRemoteDebugRunConfigurationType',\n\t\t\t\tfactoryName: 'PHP Remote Debug',\n\t\t\t\tfilter_connections: 'FILTER',\n\t\t\t\tserver_name: name,\n\t\t\t\tsession_id: ideKey,\n\t\t\t},\n\t\t};\n\n\t\tif (runManagerElement.component === undefined) {\n\t\t\trunManagerElement.component = [];\n\t\t}\n\n\t\trunManagerElement.component.push(runConfigElement);\n\t}\n\n\t// Build the updated XML\n\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\tconst xml = xmlBuilder.build(config);\n\n\t// Validate the generated XML\n\ttry {\n\t\txmlParser.parse(xml, true);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'The resulting PhpStorm configuration file is not valid XML.'\n\t\t);\n\t}\n\n\treturn xml;\n}\n\nexport type PhpStormPHPConfigOptions = {\n\tpathSkippings?: string[];\n};\n\n/**\n * Pure function to update PhpStorm php.xml config with skipped files.\n *\n * @param xmlContent The original XML content of php.xml\n * @param options Configuration options for skipped files\n * @returns Updated XML content\n * @throws Error if XML is invalid or configuration is incompatible\n */\nexport function updatePhpStormPHPConfig(\n\txmlContent: string,\n\toptions: PhpStormPHPConfigOptions\n): string {\n\tconst { pathSkippings } = options;\n\n\tconst xmlParser = new XMLParser(xmlParserOptions);\n\n\tconst config: PhpStormPHPConfigNode[] = (() => {\n\t\ttry {\n\t\t\treturn xmlParser.parse(xmlContent, true);\n\t\t} catch {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm PHP configuration file is not valid XML.'\n\t\t\t);\n\t\t}\n\t})();\n\n\t// Find or create project element\n\tlet projectElement = config?.find(\n\t\t(c: PhpStormPHPConfigNode) => !!c?.project\n\t);\n\tif (projectElement) {\n\t\tconst projectVersion = projectElement[':@']?.version;\n\t\tif (projectVersion === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports ' +\n\t\t\t\t\t'<project version=\"4\"> in php.xml, ' +\n\t\t\t\t\t'but the <project> configuration has no version number.'\n\t\t\t);\n\t\t} else if (projectVersion !== '4') {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports ' +\n\t\t\t\t\t'<project version=\"4\"> in php.xml, ' +\n\t\t\t\t\t`but we found a <project> configuration ` +\n\t\t\t\t\t`with version \"${projectVersion}\".`\n\t\t\t);\n\t\t}\n\t}\n\tif (projectElement === undefined) {\n\t\tprojectElement = {\n\t\t\tproject: [],\n\t\t\t':@': { version: '4' },\n\t\t};\n\t\tconfig.push(projectElement);\n\t}\n\n\t// Find or create PhpStepFilterConfiguration component\n\tlet componentElement = projectElement.project?.find(\n\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'PhpStepFilterConfiguration'\n\t);\n\tif (componentElement === undefined) {\n\t\tcomponentElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'PhpStepFilterConfiguration' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(componentElement);\n\t}\n\n\t// Find or create skipped_files element\n\tlet skippedFilesElement = componentElement.component?.find(\n\t\t(c: PhpStormPHPConfigNode) => !!c?.skipped_files\n\t);\n\tif (skippedFilesElement === undefined) {\n\t\tskippedFilesElement = { skipped_files: [] };\n\n\t\tif (componentElement.component === undefined) {\n\t\t\tcomponentElement.component = [];\n\t\t}\n\n\t\tcomponentElement.component.push(skippedFilesElement);\n\t}\n\n\t// Add skipped files\n\tif (pathSkippings && pathSkippings.length) {\n\t\tfor (const skippedPath of pathSkippings) {\n\t\t\tconst normalizedPath = skippedPath.endsWith('/')\n\t\t\t\t? skippedPath.slice(0, -1)\n\t\t\t\t: skippedPath;\n\t\t\tconst filePath = `$PROJECT_DIR$${normalizedPath}`;\n\n\t\t\t// Check if already exists\n\t\t\tconst exists = skippedFilesElement.skipped_files?.some(\n\t\t\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t\t\t!!c?.skipped_file && c?.[':@']?.file === filePath\n\t\t\t);\n\n\t\t\tif (!exists) {\n\t\t\t\tif (skippedFilesElement.skipped_files === undefined) {\n\t\t\t\t\tskippedFilesElement.skipped_files = [];\n\t\t\t\t}\n\n\t\t\t\tskippedFilesElement.skipped_files.push({\n\t\t\t\t\tskipped_file: [],\n\t\t\t\t\t':@': { file: filePath },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Build the updated XML\n\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\tconst xml = xmlBuilder.build(config);\n\n\t// Validate the generated XML\n\ttry {\n\t\txmlParser.parse(xml, true);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'The resulting PhpStorm PHP configuration file ' +\n\t\t\t\t'is not valid XML.'\n\t\t);\n\t}\n\n\treturn xml;\n}\n\nexport type VSCodeConfigOptions = {\n\tname: string;\n\tworkspaceDir: string;\n\tpathMappings?: Mount[];\n\tpathSkippings?: string[];\n};\n\n/**\n * Pure function to update VS Code JSON config with Xdebug configuration.\n *\n * @param jsonContent The original JSON content of launch.json\n * @param options Configuration options\n * @returns Updated JSON content\n * @throws Error if JSON is invalid\n */\nexport function updateVSCodeConfig(\n\tjsonContent: string,\n\toptions: VSCodeConfigOptions\n): string {\n\tconst { name, pathMappings, pathSkippings } = options;\n\n\tconst errors: JSONC.ParseError[] = [];\n\n\tlet content = jsonContent;\n\tlet root = JSONC.parseTree(content, errors, jsoncParseOptions);\n\n\tif (root === undefined || errors.length) {\n\t\tthrow new Error('VS Code configuration file is not valid JSON.');\n\t}\n\n\t// Find or create configurations array\n\tlet configurationsNode = JSONC.findNodeAtLocation(root, ['configurations']);\n\n\tif (\n\t\tconfigurationsNode === undefined ||\n\t\tconfigurationsNode.children === undefined\n\t) {\n\t\tconst edits = JSONC.modify(content, ['configurations'], [], {});\n\t\tcontent = JSONC.applyEdits(content, edits);\n\n\t\troot = JSONC.parseTree(content, [], jsoncParseOptions);\n\t\tconfigurationsNode = JSONC.findNodeAtLocation(root!, [\n\t\t\t'configurations',\n\t\t]);\n\t}\n\n\t// Check if configuration already exists\n\tconst configurationIndex = configurationsNode?.children?.findIndex(\n\t\t(child: any) =>\n\t\t\tJSONC.findNodeAtLocation(child, ['name'])?.value === name\n\t);\n\n\t// Only add configuration if it doesn't exist\n\tif (configurationIndex === undefined || configurationIndex < 0) {\n\t\tconst configuration: VSCodeConfigNode = {\n\t\t\tname: name,\n\t\t\ttype: 'php',\n\t\t\trequest: 'launch',\n\t\t\tport: 9003,\n\t\t};\n\n\t\tif (pathMappings && pathMappings.length) {\n\t\t\tconfiguration.pathMappings = pathMappings.reduce((acc, mount) => {\n\t\t\t\tacc[mount.vfsPath] = `\\${workspaceFolder}/${toPosixPath(\n\t\t\t\t\tpath.relative(options.workspaceDir, mount.hostPath)\n\t\t\t\t)}`;\n\t\t\t\treturn acc;\n\t\t\t}, {} as VSCodeConfigMetaData);\n\t\t}\n\n\t\tif (pathSkippings && pathSkippings.length) {\n\t\t\tconfiguration.skipFiles = pathSkippings.map((skippedPath) =>\n\t\t\t\tskippedPath.endsWith('/') ? `${skippedPath}**` : skippedPath\n\t\t\t);\n\t\t}\n\n\t\t// Get the current length to append at the end\n\t\tconst currentLength = configurationsNode?.children?.length || 0;\n\n\t\tconst edits = JSONC.modify(\n\t\t\tcontent,\n\t\t\t['configurations', currentLength],\n\t\t\tconfiguration,\n\t\t\t{\n\t\t\t\tformattingOptions: {\n\t\t\t\t\tinsertSpaces: true,\n\t\t\t\t\ttabSize: 4,\n\t\t\t\t\teol: '\\n',\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\n\t\tcontent = jsoncApplyEdits(content, edits);\n\t}\n\n\treturn content;\n}\n\n/**\n * Implement necessary parameters and path mappings in IDE configuration files.\n *\n * @param name The configuration name.\n * @param mounts The mounts options.\n */\nexport async function addXdebugIDEConfig({\n\tname,\n\tides,\n\thost,\n\tport,\n\tcwd,\n\tmounts,\n\tpathSkippings,\n\tideKey = DEFAULT_IDE_KEY,\n}: IDEConfig) {\n\tconst pathMappings = mounts ? filterLocalMounts(cwd, mounts) : [];\n\tconst modifiedConfig: Record<string, string> = {};\n\n\t// PHPstorm\n\tif (ides.includes('phpstorm')) {\n\t\tconst phpStormRelativeConfigFilePath = '.idea/workspace.xml';\n\t\tconst phpStormConfigFilePath = path.join(\n\t\t\tcwd,\n\t\t\tphpStormRelativeConfigFilePath\n\t\t);\n\n\t\t// Create a template config file if the IDE directory exists,\n\t\t// or throw an error if IDE integration is requested but the directory is missing.\n\t\tif (!fs.existsSync(phpStormConfigFilePath)) {\n\t\t\tif (fs.existsSync(path.dirname(phpStormConfigFilePath))) {\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tphpStormConfigFilePath,\n\t\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t\t);\n\t\t\t} else if (ides.length == 1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`PhpStorm IDE integration requested, but no '.idea' directory was found in the current working directory.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (fs.existsSync(phpStormConfigFilePath)) {\n\t\t\tconst contents = fs.readFileSync(phpStormConfigFilePath, 'utf8');\n\t\t\tconst updatedXml = updatePhpStormWorkspaceConfig(contents, {\n\t\t\t\tname,\n\t\t\t\thost,\n\t\t\t\tport,\n\t\t\t\tprojectDir: cwd,\n\t\t\t\tpathMappings,\n\t\t\t\tideKey,\n\t\t\t});\n\t\t\tfs.writeFileSync(phpStormConfigFilePath, updatedXml);\n\t\t\tmodifiedConfig['phpstorm'] = phpStormRelativeConfigFilePath;\n\t\t}\n\n\t\t// PhpStorm php.xml (path skippings)\n\t\tif (pathSkippings && pathSkippings.length) {\n\t\t\tconst phpStormRelativePHPConfigFilePath = '.idea/php.xml';\n\t\t\tconst phpStormPHPConfigFilePath = path.join(\n\t\t\t\tcwd,\n\t\t\t\tphpStormRelativePHPConfigFilePath\n\t\t\t);\n\n\t\t\tif (!fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\t\t\tif (fs.existsSync(path.dirname(phpStormPHPConfigFilePath))) {\n\t\t\t\t\tfs.writeFileSync(\n\t\t\t\t\t\tphpStormPHPConfigFilePath,\n\t\t\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\t\t\tconst contents = fs.readFileSync(\n\t\t\t\t\tphpStormPHPConfigFilePath,\n\t\t\t\t\t'utf8'\n\t\t\t\t);\n\t\t\t\tconst updatedXml = updatePhpStormPHPConfig(contents, {\n\t\t\t\t\tpathSkippings,\n\t\t\t\t});\n\t\t\t\tfs.writeFileSync(phpStormPHPConfigFilePath, updatedXml);\n\t\t\t\tmodifiedConfig['phpstorm-php'] =\n\t\t\t\t\tphpStormRelativePHPConfigFilePath;\n\t\t\t}\n\t\t}\n\t}\n\n\t// VSCode\n\tif (ides.includes('vscode')) {\n\t\tconst vsCodeRelativeConfigFilePath = '.vscode/launch.json';\n\t\tconst vsCodeConfigFilePath = path.join(\n\t\t\tcwd,\n\t\t\tvsCodeRelativeConfigFilePath\n\t\t);\n\n\t\t// Create a template config file if the IDE directory exists,\n\t\t// or throw an error if IDE integration is requested but the directory is missing.\n\t\tif (!fs.existsSync(vsCodeConfigFilePath)) {\n\t\t\tif (fs.existsSync(path.dirname(vsCodeConfigFilePath))) {\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tvsCodeConfigFilePath,\n\t\t\t\t\t'{\\n \"configurations\": []\\n}'\n\t\t\t\t);\n\t\t\t} else if (ides.length == 1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`VS Code IDE integration requested, but no '.vscode' directory was found in the current working directory.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (fs.existsSync(vsCodeConfigFilePath)) {\n\t\t\tconst content = fs.readFileSync(vsCodeConfigFilePath, 'utf-8');\n\t\t\tconst updatedJson = updateVSCodeConfig(content, {\n\t\t\t\tname,\n\t\t\t\tworkspaceDir: cwd,\n\t\t\t\tpathMappings,\n\t\t\t\tpathSkippings,\n\t\t\t});\n\n\t\t\t// Only write and track the file if changes were made\n\t\t\tif (updatedJson !== content) {\n\t\t\t\tfs.writeFileSync(vsCodeConfigFilePath, updatedJson);\n\t\t\t\tmodifiedConfig['vscode'] = vsCodeRelativeConfigFilePath;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn modifiedConfig;\n}\n\n/**\n * Remove stale parameters and path mappings in IDE configuration files.\n *\n * @param name The configuration name.\n * @param cwd The current working directory.\n */\nexport async function clearXdebugIDEConfig(name: string, cwd: string) {\n\tconst phpStormConfigFilePath = path.join(cwd, '.idea/workspace.xml');\n\t// PhpStorm\n\tif (fs.existsSync(phpStormConfigFilePath)) {\n\t\tconst contents = fs.readFileSync(phpStormConfigFilePath, 'utf8');\n\t\tconst xmlParser = new XMLParser(xmlParserOptions);\n\t\t// NOTE: Using an IIFE so `config` can remain const.\n\t\tconst config: PhpStormWorkspaceConfigNode[] = (() => {\n\t\t\ttry {\n\t\t\t\treturn xmlParser.parse(contents, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'PhpStorm configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\t\t})();\n\n\t\tconst projectElement = config.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.project\n\t\t);\n\t\tconst componentElement = projectElement?.project?.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.component && c?.[':@']?.name === 'PhpServers'\n\t\t);\n\t\tconst serversElement = componentElement?.component?.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.servers\n\t\t);\n\t\tconst serverElementIndex = serversElement?.servers?.findIndex(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.server && c?.[':@']?.name === name\n\t\t);\n\n\t\tif (serverElementIndex !== undefined && serverElementIndex >= 0) {\n\t\t\tserversElement!.servers!.splice(serverElementIndex, 1);\n\n\t\t\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\t\t\tconst xml = xmlBuilder.build(config);\n\n\t\t\ttry {\n\t\t\t\txmlParser.parse(xml, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'The resulting PhpStorm configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\txml ===\n\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n\t<component name=\"PhpServers\">\\n\t\t<servers></servers>\\n\t</component>\\n</project>'\n\t\t\t) {\n\t\t\t\tfs.unlinkSync(phpStormConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(phpStormConfigFilePath, xml);\n\t\t\t}\n\t\t}\n\t}\n\n\t// PhpStorm php.xml (path skippings)\n\tconst phpStormPHPConfigFilePath = path.join(cwd, '.idea/php.xml');\n\tif (fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\tconst contents = fs.readFileSync(phpStormPHPConfigFilePath, 'utf8');\n\t\tconst xmlParser = new XMLParser(xmlParserOptions);\n\t\tconst config: PhpStormPHPConfigNode[] = (() => {\n\t\t\ttry {\n\t\t\t\treturn xmlParser.parse(contents, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'PhpStorm PHP configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\t\t})();\n\n\t\tconst projectElement = config.find(\n\t\t\t(c: PhpStormPHPConfigNode) => !!c?.project\n\t\t);\n\t\tconst componentIndex = projectElement?.project?.findIndex(\n\t\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t\t!!c?.component &&\n\t\t\t\tc?.[':@']?.name === 'PhpStepFilterConfiguration'\n\t\t);\n\n\t\tif (componentIndex !== undefined && componentIndex >= 0) {\n\t\t\tprojectElement!.project!.splice(componentIndex, 1);\n\n\t\t\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\t\t\tconst xml = xmlBuilder.build(config);\n\n\t\t\ttry {\n\t\t\t\txmlParser.parse(xml, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'The resulting PhpStorm PHP configuration file ' +\n\t\t\t\t\t\t'is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\txml ===\n\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t) {\n\t\t\t\tfs.unlinkSync(phpStormPHPConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(phpStormPHPConfigFilePath, xml);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst vsCodeConfigFilePath = path.join(cwd, '.vscode/launch.json');\n\t// VSCode\n\tif (fs.existsSync(vsCodeConfigFilePath)) {\n\t\tconst errors: JSONC.ParseError[] = [];\n\n\t\tconst content = fs.readFileSync(vsCodeConfigFilePath, 'utf-8');\n\t\tconst root = JSONC.parseTree(content, errors, jsoncParseOptions);\n\n\t\tif (root === undefined || errors.length) {\n\t\t\tthrow new Error('VS Code configuration file is not valid JSON.');\n\t\t}\n\n\t\tconst configurationsNode = JSONC.findNodeAtLocation(root, [\n\t\t\t'configurations',\n\t\t]);\n\n\t\tconst configurationIndex = configurationsNode?.children?.findIndex(\n\t\t\t(child: any) =>\n\t\t\t\tJSONC.findNodeAtLocation(child, ['name'])?.value === name\n\t\t);\n\n\t\tif (configurationIndex !== undefined && configurationIndex >= 0) {\n\t\t\tconst edits = JSONC.modify(\n\t\t\t\tcontent,\n\t\t\t\t['configurations', configurationIndex],\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tformattingOptions: {\n\t\t\t\t\t\tinsertSpaces: true,\n\t\t\t\t\t\ttabSize: 4,\n\t\t\t\t\t\teol: '\\n',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst json = jsoncApplyEdits(content, edits);\n\t\t\tif (json === '{\\n \"configurations\": []\\n}') {\n\t\t\t\tfs.unlinkSync(vsCodeConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(vsCodeConfigFilePath, json);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Implement path mapping and path skipping in Xdebug.\n *\n * @param name The configuration name.\n * @param mounts The mounts options.\n * @param pathSkippings The skipping paths options.\n * @returns Xdebug options\n */\nexport function makeXdebugConfig({\n\tcwd,\n\tmounts,\n\tpathSkippings,\n}: XdebugConfig): XdebugOptions {\n\tconst pathMappings =\n\t\tcwd && mounts ? filterLocalMounts(cwd, mounts) : undefined;\n\n\treturn { pathMappings, pathSkippings };\n}\n\nfunction jsoncApplyEdits(content: string, edits: JSONC.Edit[]) {\n\tconst errors: JSONC.ParseError[] = [];\n\tconst json = JSONC.applyEdits(content, edits);\n\n\terrors.length = 0;\n\n\tJSONC.parseTree(json, errors, jsoncParseOptions);\n\n\tif (errors.length) {\n\t\tconst formattedErrors = errors\n\t\t\t.map((error) => {\n\t\t\t\treturn {\n\t\t\t\t\tmessage: JSONC.printParseErrorCode(error.error),\n\t\t\t\t\toffset: error.offset,\n\t\t\t\t\tlength: error.length,\n\t\t\t\t\tfragment: json.slice(\n\t\t\t\t\t\tMath.max(0, error.offset - 20),\n\t\t\t\t\t\tMath.min(json.length, error.offset + error.length + 10)\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.map(\n\t\t\t\t(error) =>\n\t\t\t\t\t`${error.message} at ${error.offset}:${error.length} (${error.fragment})`\n\t\t\t);\n\t\tconst formattedEdits = edits.map(\n\t\t\t(edit) => `At ${edit.offset}:${edit.length} - (${edit.content})`\n\t\t);\n\t\tthrow new Error(\n\t\t\t`VS Code configuration file (.vscode/launch.json) is not valid a JSONC after CLI modifications. This is likely ` +\n\t\t\t\t`a CLI bug. Please report it at https://github.com/WordPress/wordpress-playground/issues and include the contents ` +\n\t\t\t\t`of your \".vscode/launch.json\" file. \\n\\n Applied edits: ${formattedEdits.join(\n\t\t\t\t\t'\\n'\n\t\t\t\t)}\\n\\n The errors are: ${formattedErrors.join('\\n')}`\n\t\t);\n\t}\n\n\treturn json;\n}\n"],"names":["DEFAULT_IDE_KEY","DEFAULT_PATH_SKIPPINGS","createTempDirSymlink","nativeDirPath","symlinkPath","platform","type","fs","removeTempDirSymlink","filterLocalMounts","cwd","mounts","mount","absoluteHostPath","path","cwdChildPrefix","xmlParserOptions","xmlBuilderOptions","jsoncParseOptions","updatePhpStormWorkspaceConfig","xmlContent","options","name","host","port","pathMappings","ideKey","xmlParser","XMLParser","config","serverElement","pathMapping","toPosixPath","projectElement","c","projectVersion","_a","componentElement","_b","serversElement","_c","serverElementIndex","_d","runManagerElement","_e","_f","runConfigElement","xml","XMLBuilder","updatePhpStormPHPConfig","pathSkippings","skippedFilesElement","skippedPath","filePath","updateVSCodeConfig","jsonContent","errors","content","root","JSONC","configurationsNode","edits","configurationIndex","child","configuration","acc","currentLength","jsoncApplyEdits","addXdebugIDEConfig","ides","modifiedConfig","phpStormRelativeConfigFilePath","phpStormConfigFilePath","contents","updatedXml","phpStormRelativePHPConfigFilePath","phpStormPHPConfigFilePath","vsCodeRelativeConfigFilePath","vsCodeConfigFilePath","updatedJson","clearXdebugIDEConfig","componentIndex","json","makeXdebugConfig","formattedErrors","error","formattedEdits","edit"],"mappings":";;;;;AAkBO,MAAMA,IAAkB,cAClBC,IAAyB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAWA,eAAsBC,EACrBC,GACAC,GACAC,GACC;AACD,QAAMC,IACLD,MAAa;AAAA;AAAA;AAAA;AAAA,IAIX;AAAA,MACC;AACJ,EAAAE,EAAG,YAAYJ,GAAeC,GAAaE,CAAI;AAChD;AAOA,eAAsBE,EAAqBJ,GAAqB;AAC/D,MAAI;AAEH,IADcG,EAAG,UAAUH,CAAW,EAC5B,oBACTG,EAAG,WAAWH,CAAW;AAAA,EAE3B,QAAQ;AAAA,EAER;AACD;AAOA,SAASK,EAAkBC,GAAaC,GAAiB;AACxD,SAAOA,EAAO,OAAO,CAACC,MAAU;AAC/B,UAAMC,IAAmBC,EAAK,QAAQF,EAAM,QAAQ,GAC9CG,IAAiBD,EAAK,KAAKJ,GAAKI,EAAK,GAAG;AAC9C;AAAA;AAAA;AAAA,MAGCD,MAAqBH,KACrBG,EAAiB,WAAWE,CAAc;AAAA;AAAA,EAE5C,CAAC;AACF;AA0GA,MAAMC,IAA+B;AAAA,EACpC,kBAAkB;AAAA,EAClB,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,wBAAwB;AAAA,EACxB,YAAY;AACb,GACMC,IAAuC;AAAA,EAC5C,kBAAkBD,EAAiB;AAAA,EACnC,qBAAqBA,EAAiB;AAAA,EACtC,eAAeA,EAAiB;AAAA,EAChC,eAAeA,EAAiB;AAAA,EAChC,iBAAiBA,EAAiB;AAAA,EAClC,2BAA2B,CAACA,EAAiB;AAA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QAAQG,EAAM,SAASA,EAAM,SAAS,EAAE;AAAA,MAAA;AAAA,IACvD,EAED,EACA;AAAA,MACA,CAACA,MACA,GAAGA,EAAM,OAAO,OAAOA,EAAM,MAAM,IAAIA,EAAM,MAAM,KAAKA,EAAM,QAAQ;AAAA,IAAA,GAEnEC,IAAiBzB,EAAM;AAAA,MAC5B,CAAC0B,MAAS,MAAMA,EAAK,MAAM,IAAIA,EAAK,MAAM,OAAOA,EAAK,OAAO;AAAA,IAAA;AAE9D,UAAM,IAAI;AAAA,MACT;AAAA;AAAA,kBAE4DD,EAAe;AAAA,QACzE;AAAA;AAAA,MAAA,CACA;AAAA;AAAA,mBAAwBF,EAAgB,KAAK;AAAA,CAAI,CAAC;AAAA,IAAA;AAAA,EAEtD;AAEA,SAAOF;AACR;"} | ||
| {"version":3,"file":"index.js","sources":["../../../../packages/php-wasm/cli-util/src/lib/cli-output.ts","../../../../packages/php-wasm/cli-util/src/lib/xdebug-path-mappings.ts"],"sourcesContent":["interface CLIOutputOptions {\n\t/** Verbosity level: 'quiet', 'normal', or 'debug' */\n\tverbosity: string;\n\t/** Output stream to write to. Defaults to process.stdout */\n\twriteStream?: NodeJS.WriteStream;\n}\n\nexport class CLIOutput {\n\tprivate verbosity: string;\n\tprotected writeStream: NodeJS.WriteStream;\n\n\tconstructor(options: CLIOutputOptions) {\n\t\tthis.verbosity = options.verbosity;\n\t\tthis.writeStream = options.writeStream || process.stdout;\n\t}\n\n\tget isTTY(): boolean {\n\t\treturn Boolean(this.writeStream.isTTY);\n\t}\n\n\tget isQuiet(): boolean {\n\t\treturn this.verbosity === 'quiet';\n\t}\n\n\t/**\n\t * ANSI formatting helpers.\n\t *\n\t * These only apply color codes when outputting to a terminal (TTY).\n\t * When piped to files or non-TTY streams, they return plain text to\n\t * avoid polluting logs with escape sequences.\n\t */\n\tbold(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[1m${text}\\x1b[0m` : text;\n\t}\n\n\tdim(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[2m${text}\\x1b[0m` : text;\n\t}\n\n\titalic(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[3m${text}\\x1b[0m` : text;\n\t}\n\n\tred(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[31m${text}\\x1b[0m` : text;\n\t}\n\n\tgreen(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[32m${text}\\x1b[0m` : text;\n\t}\n\n\tyellow(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[33m${text}\\x1b[0m` : text;\n\t}\n\n\tcyan(text: string): string {\n\t\treturn this.isTTY ? `\\x1b[36m${text}\\x1b[0m` : text;\n\t}\n\n\thighlight(text: string): string {\n\t\treturn this.yellow(text);\n\t}\n\n\tprint(message: string): void {\n\t\tif (this.isQuiet) return;\n\t\tthis.writeStream.write(`${message}\\n`);\n\t}\n\n\tprintError(message: string): void {\n\t\tthis.writeStream.write(`${this.red('Error:')} ${message}\\n`);\n\t}\n\n\tprintWarning(message: string): void {\n\t\tif (this.isQuiet) return;\n\t\tthis.writeStream.write(`${this.yellow('Warning:')} ${message}\\n`);\n\t}\n}\n","import fs from 'fs';\nimport path from 'path';\nimport { toPosixPath } from '@php-wasm/util';\nimport type { Mount } from './mounts';\nimport {\n\ttype X2jOptions,\n\ttype XmlBuilderOptions,\n\tXMLParser,\n\tXMLBuilder,\n} from 'fast-xml-parser';\nimport * as JSONC from 'jsonc-parser';\n\nexport interface XdebugOptions {\n\tideKey?: string;\n\tpathMappings?: Mount[];\n\tpathSkippings?: string[];\n}\n\nexport const DEFAULT_IDE_KEY = 'PHPWASMCLI';\nexport const DEFAULT_PATH_SKIPPINGS = [\n\t'/dev/',\n\t'/home/',\n\t'/internal/',\n\t'/request/',\n\t'/proc/',\n];\n\n/**\n * Create a symlink to a tempory directory.\n *\n * The symlink is created to access the system temp dir\n * inside the current debugging directory.\n *\n * @param nativeDirPath The system temp dir path.\n * @param symlinkPath The symlink name.\n */\nexport async function createTempDirSymlink(\n\tnativeDirPath: string,\n\tsymlinkPath: string,\n\tplatform: string\n) {\n\tconst type =\n\t\tplatform === 'win32'\n\t\t\t? // On Windows, creating a 'dir' symlink can require elevated permissions.\n\t\t\t\t// In this case, let's make junction points because they function like\n\t\t\t\t// symlinks and do not require elevated permissions.\n\t\t\t\t'junction'\n\t\t\t: 'dir';\n\tfs.symlinkSync(nativeDirPath, symlinkPath, type);\n}\n\n/**\n * Remove the given temporary directory symlink if it exists.\n *\n * @param symlinkPath The symlink path.\n */\nexport async function removeTempDirSymlink(symlinkPath: string) {\n\ttry {\n\t\tconst stats = fs.lstatSync(symlinkPath);\n\t\tif (stats.isSymbolicLink()) {\n\t\t\tfs.unlinkSync(symlinkPath);\n\t\t}\n\t} catch {\n\t\t// Symlink does not exist or cannot be accessed, nothing to remove\n\t}\n}\n\n/**\n * Filters out mounts that are not in the current working directory\n *\n * @param mounts The mounts list.\n */\nfunction filterLocalMounts(cwd: string, mounts: Mount[]) {\n\treturn mounts.filter((mount) => {\n\t\tconst absoluteHostPath = path.resolve(mount.hostPath);\n\t\tconst cwdChildPrefix = path.join(cwd, path.sep);\n\t\treturn (\n\t\t\t// If auto-mounting from the current directory,\n\t\t\t// the entire project directory can be mapped.\n\t\t\tabsoluteHostPath === cwd ||\n\t\t\tabsoluteHostPath.startsWith(cwdChildPrefix)\n\t\t);\n\t});\n}\n\nexport type XdebugConfig = {\n\t/**\n\t * The current working directory to consider for debugger path mapping.\n\t */\n\tcwd?: string;\n\t/**\n\t * The mounts to consider for debugger path mapping.\n\t */\n\tmounts?: Mount[];\n\t/**\n\t * The paths to consider for debugger path skipping.\n\t */\n\tpathSkippings?: string[];\n};\n\nexport type IDEConfig = {\n\t/**\n\t * The name of the configuration within the IDE configuration.\n\t */\n\tname: string;\n\t/**\n\t * The IDEs to configure.\n\t */\n\tides: string[];\n\t/**\n\t * The web server host.\n\t */\n\thost: string;\n\t/**\n\t * The web server port.\n\t */\n\tport: number;\n\t/**\n\t * The current working directory to consider for debugger path mapping.\n\t */\n\tcwd: string;\n\t/**\n\t * The mounts to consider for debugger path mapping.\n\t */\n\tmounts?: Mount[];\n\t/**\n\t * The paths to skip when debugging.\n\t */\n\tpathSkippings?: string[];\n\t/**\n\t * The IDE key to use for the debug configuration. Defaults to 'PHPWASMCLI'.\n\t */\n\tideKey?: string;\n};\n\ntype PhpStormWorkspaceConfigMetaData = {\n\tname?: string;\n\tversion?: string;\n\thost?: string;\n\tuse_path_mappings?: string;\n\t'local-root'?: string;\n\t'remote-root'?: string;\n\ttype?: 'PhpRemoteDebugRunConfigurationType';\n\tfactoryName?: string;\n\tfilter_connections?: 'FILTER';\n\tserver_name?: string;\n\tsession_id?: string;\n\tv?: string;\n};\n\ntype PhpStormWorkspaceConfigNode = {\n\t':@'?: PhpStormWorkspaceConfigMetaData;\n\tproject?: PhpStormWorkspaceConfigNode[];\n\tcomponent?: PhpStormWorkspaceConfigNode[];\n\tservers?: PhpStormWorkspaceConfigNode[];\n\tserver?: PhpStormWorkspaceConfigNode[];\n\tpath_mappings?: PhpStormWorkspaceConfigNode[];\n\tmapping?: PhpStormWorkspaceConfigNode[];\n\tconfiguration?: PhpStormWorkspaceConfigNode[];\n\tmethod?: PhpStormWorkspaceConfigNode[];\n};\n\ntype PhpStormPHPConfigMetaData = {\n\tname?: string;\n\tversion?: string;\n\tfile?: string;\n};\n\ntype PhpStormPHPConfigNode = {\n\t':@'?: PhpStormPHPConfigMetaData;\n\tproject?: PhpStormPHPConfigNode[];\n\tcomponent?: PhpStormPHPConfigNode[];\n\tskipped_files?: PhpStormPHPConfigNode[];\n\tskipped_file?: PhpStormPHPConfigNode[];\n};\n\ntype VSCodeConfigMetaData = {\n\t[key: string]: string;\n};\n\ntype VSCodeConfigNode = {\n\tname: string;\n\ttype: string;\n\trequest: string;\n\tport: number;\n\tpathMappings?: VSCodeConfigMetaData;\n\tskipFiles?: string[];\n};\n\nconst xmlParserOptions: X2jOptions = {\n\tignoreAttributes: false,\n\tattributeNamePrefix: '',\n\tpreserveOrder: true,\n\tcdataPropName: '__cdata',\n\tcommentPropName: '__xmlComment',\n\tallowBooleanAttributes: true,\n\ttrimValues: true,\n};\nconst xmlBuilderOptions: XmlBuilderOptions = {\n\tignoreAttributes: xmlParserOptions.ignoreAttributes,\n\tattributeNamePrefix: xmlParserOptions.attributeNamePrefix,\n\tpreserveOrder: xmlParserOptions.preserveOrder,\n\tcdataPropName: xmlParserOptions.cdataPropName,\n\tcommentPropName: xmlParserOptions.commentPropName,\n\tsuppressBooleanAttributes: !xmlParserOptions.allowBooleanAttributes,\n\tformat: true,\n\tindentBy: '\\t',\n};\n\nconst jsoncParseOptions: JSONC.ParseOptions = {\n\tallowEmptyContent: true,\n\tallowTrailingComma: true,\n};\n\nexport type PhpStormWorkspaceConfigOptions = {\n\tname: string;\n\thost: string;\n\tport: number;\n\tprojectDir: string;\n\tpathMappings?: Mount[];\n\tideKey: string;\n};\n\n/**\n * Pure function to update PHPStorm XML config with Xdebug server and run configuration.\n *\n * @param xmlContent The original XML content of workspace.xml\n * @param options Configuration options for the server\n * @returns Updated XML content\n * @throws Error if XML is invalid or configuration is incompatible\n */\nexport function updatePhpStormWorkspaceConfig(\n\txmlContent: string,\n\toptions: PhpStormWorkspaceConfigOptions\n): string {\n\tconst { name, host, port, pathMappings, ideKey } = options;\n\n\tconst xmlParser = new XMLParser(xmlParserOptions);\n\n\t// Parse the XML\n\tconst config: PhpStormWorkspaceConfigNode[] = (() => {\n\t\ttry {\n\t\t\treturn xmlParser.parse(xmlContent, true);\n\t\t} catch {\n\t\t\tthrow new Error('PhpStorm configuration file is not valid XML.');\n\t\t}\n\t})();\n\n\t// Create the server element with path mappings\n\tconst serverElement: PhpStormWorkspaceConfigNode = {\n\t\tserver: [{}],\n\t\t':@': {\n\t\t\tname,\n\t\t\t// NOTE: PhpStorm quirk: Xdebug only works when the full URL (including port)\n\t\t\t// is provided in `host`. The separate `port` field is ignored or misinterpreted,\n\t\t\t// so we rely solely on host: \"host:port\".\n\t\t\thost: `${host}:${port}`,\n\t\t\tuse_path_mappings: 'true',\n\t\t},\n\t};\n\n\tif (pathMappings && pathMappings.length) {\n\t\tserverElement.server![0].path_mappings = pathMappings.map(\n\t\t\t(pathMapping) => ({\n\t\t\t\tmapping: [],\n\t\t\t\t':@': {\n\t\t\t\t\t'local-root': `$PROJECT_DIR$/${toPosixPath(\n\t\t\t\t\t\tpath.relative(options.projectDir, pathMapping.hostPath)\n\t\t\t\t\t)}`,\n\t\t\t\t\t'remote-root': pathMapping.vfsPath,\n\t\t\t\t},\n\t\t\t})\n\t\t);\n\t}\n\n\t// Find or create project element\n\tlet projectElement = config?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.project\n\t);\n\tif (projectElement) {\n\t\tconst projectVersion = projectElement[':@']?.version;\n\t\tif (projectVersion === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports <project version=\"4\"> in workspace.xml, ' +\n\t\t\t\t\t'but the <project> configuration has no version number.'\n\t\t\t);\n\t\t} else if (projectVersion !== '4') {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports <project version=\"4\"> in workspace.xml, ' +\n\t\t\t\t\t`but we found a <project> configuration with version \"${projectVersion}\".`\n\t\t\t);\n\t\t}\n\t}\n\tif (projectElement === undefined) {\n\t\tprojectElement = {\n\t\t\tproject: [],\n\t\t\t':@': { version: '4' },\n\t\t};\n\t\tconfig.push(projectElement);\n\t}\n\n\t// Find or create PhpServers component\n\tlet componentElement = projectElement.project?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'PhpServers'\n\t);\n\tif (componentElement === undefined) {\n\t\tcomponentElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'PhpServers' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(componentElement);\n\t}\n\n\t// Find or create servers element\n\tlet serversElement = componentElement.component?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.servers\n\t);\n\tif (serversElement === undefined) {\n\t\tserversElement = { servers: [] };\n\n\t\tif (componentElement.component === undefined) {\n\t\t\tcomponentElement.component = [];\n\t\t}\n\n\t\tcomponentElement.component.push(serversElement);\n\t}\n\n\t// Check if server already exists\n\tconst serverElementIndex = serversElement.servers?.findIndex(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.server && c?.[':@']?.name === name\n\t);\n\n\t// Only add server if it doesn't exist\n\tif (serverElementIndex === undefined || serverElementIndex < 0) {\n\t\tif (serversElement.servers === undefined) {\n\t\t\tserversElement.servers = [];\n\t\t}\n\n\t\tserversElement.servers.push(serverElement);\n\t}\n\n\t// Find or create RunManager component\n\tlet runManagerElement = projectElement.project?.find(\n\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'RunManager'\n\t);\n\tif (runManagerElement === undefined) {\n\t\trunManagerElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'RunManager' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(runManagerElement);\n\t}\n\n\t// Check if run configuration already exists\n\tconst existingConfigIndex =\n\t\trunManagerElement.component?.findIndex(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.configuration && c?.[':@']?.name === name\n\t\t) ?? -1;\n\n\t// Only add run configuration if it doesn't exist\n\tif (existingConfigIndex < 0) {\n\t\tconst runConfigElement: PhpStormWorkspaceConfigNode = {\n\t\t\tconfiguration: [\n\t\t\t\t{\n\t\t\t\t\tmethod: [],\n\t\t\t\t\t':@': { v: '2' },\n\t\t\t\t},\n\t\t\t],\n\t\t\t':@': {\n\t\t\t\tname: name,\n\t\t\t\ttype: 'PhpRemoteDebugRunConfigurationType',\n\t\t\t\tfactoryName: 'PHP Remote Debug',\n\t\t\t\tfilter_connections: 'FILTER',\n\t\t\t\tserver_name: name,\n\t\t\t\tsession_id: ideKey,\n\t\t\t},\n\t\t};\n\n\t\tif (runManagerElement.component === undefined) {\n\t\t\trunManagerElement.component = [];\n\t\t}\n\n\t\trunManagerElement.component.push(runConfigElement);\n\t}\n\n\t// Build the updated XML\n\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\tconst xml = xmlBuilder.build(config);\n\n\t// Validate the generated XML\n\ttry {\n\t\txmlParser.parse(xml, true);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'The resulting PhpStorm configuration file is not valid XML.'\n\t\t);\n\t}\n\n\treturn xml;\n}\n\nexport type PhpStormPHPConfigOptions = {\n\tpathSkippings?: string[];\n};\n\n/**\n * Pure function to update PhpStorm php.xml config with skipped files.\n *\n * @param xmlContent The original XML content of php.xml\n * @param options Configuration options for skipped files\n * @returns Updated XML content\n * @throws Error if XML is invalid or configuration is incompatible\n */\nexport function updatePhpStormPHPConfig(\n\txmlContent: string,\n\toptions: PhpStormPHPConfigOptions\n): string {\n\tconst { pathSkippings } = options;\n\n\tconst xmlParser = new XMLParser(xmlParserOptions);\n\n\tconst config: PhpStormPHPConfigNode[] = (() => {\n\t\ttry {\n\t\t\treturn xmlParser.parse(xmlContent, true);\n\t\t} catch {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm PHP configuration file is not valid XML.'\n\t\t\t);\n\t\t}\n\t})();\n\n\t// Find or create project element\n\tlet projectElement = config?.find(\n\t\t(c: PhpStormPHPConfigNode) => !!c?.project\n\t);\n\tif (projectElement) {\n\t\tconst projectVersion = projectElement[':@']?.version;\n\t\tif (projectVersion === undefined) {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports ' +\n\t\t\t\t\t'<project version=\"4\"> in php.xml, ' +\n\t\t\t\t\t'but the <project> configuration has no version number.'\n\t\t\t);\n\t\t} else if (projectVersion !== '4') {\n\t\t\tthrow new Error(\n\t\t\t\t'PhpStorm IDE integration only supports ' +\n\t\t\t\t\t'<project version=\"4\"> in php.xml, ' +\n\t\t\t\t\t`but we found a <project> configuration ` +\n\t\t\t\t\t`with version \"${projectVersion}\".`\n\t\t\t);\n\t\t}\n\t}\n\tif (projectElement === undefined) {\n\t\tprojectElement = {\n\t\t\tproject: [],\n\t\t\t':@': { version: '4' },\n\t\t};\n\t\tconfig.push(projectElement);\n\t}\n\n\t// Find or create PhpStepFilterConfiguration component\n\tlet componentElement = projectElement.project?.find(\n\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t!!c?.component && c?.[':@']?.name === 'PhpStepFilterConfiguration'\n\t);\n\tif (componentElement === undefined) {\n\t\tcomponentElement = {\n\t\t\tcomponent: [],\n\t\t\t':@': { name: 'PhpStepFilterConfiguration' },\n\t\t};\n\n\t\tif (projectElement.project === undefined) {\n\t\t\tprojectElement.project = [];\n\t\t}\n\n\t\tprojectElement.project.push(componentElement);\n\t}\n\n\t// Find or create skipped_files element\n\tlet skippedFilesElement = componentElement.component?.find(\n\t\t(c: PhpStormPHPConfigNode) => !!c?.skipped_files\n\t);\n\tif (skippedFilesElement === undefined) {\n\t\tskippedFilesElement = { skipped_files: [] };\n\n\t\tif (componentElement.component === undefined) {\n\t\t\tcomponentElement.component = [];\n\t\t}\n\n\t\tcomponentElement.component.push(skippedFilesElement);\n\t}\n\n\t// Add skipped files\n\tif (pathSkippings && pathSkippings.length) {\n\t\tfor (const skippedPath of pathSkippings) {\n\t\t\tconst normalizedPath = skippedPath.endsWith('/')\n\t\t\t\t? skippedPath.slice(0, -1)\n\t\t\t\t: skippedPath;\n\t\t\tconst filePath = `$PROJECT_DIR$${normalizedPath}`;\n\n\t\t\t// Check if already exists\n\t\t\tconst exists = skippedFilesElement.skipped_files?.some(\n\t\t\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t\t\t!!c?.skipped_file && c?.[':@']?.file === filePath\n\t\t\t);\n\n\t\t\tif (!exists) {\n\t\t\t\tif (skippedFilesElement.skipped_files === undefined) {\n\t\t\t\t\tskippedFilesElement.skipped_files = [];\n\t\t\t\t}\n\n\t\t\t\tskippedFilesElement.skipped_files.push({\n\t\t\t\t\tskipped_file: [],\n\t\t\t\t\t':@': { file: filePath },\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t// Build the updated XML\n\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\tconst xml = xmlBuilder.build(config);\n\n\t// Validate the generated XML\n\ttry {\n\t\txmlParser.parse(xml, true);\n\t} catch {\n\t\tthrow new Error(\n\t\t\t'The resulting PhpStorm PHP configuration file ' +\n\t\t\t\t'is not valid XML.'\n\t\t);\n\t}\n\n\treturn xml;\n}\n\nexport type VSCodeConfigOptions = {\n\tname: string;\n\tworkspaceDir: string;\n\tpathMappings?: Mount[];\n\tpathSkippings?: string[];\n};\n\n/**\n * Pure function to update VS Code JSON config with Xdebug configuration.\n *\n * @param jsonContent The original JSON content of launch.json\n * @param options Configuration options\n * @returns Updated JSON content\n * @throws Error if JSON is invalid\n */\nexport function updateVSCodeConfig(\n\tjsonContent: string,\n\toptions: VSCodeConfigOptions\n): string {\n\tconst { name, pathMappings, pathSkippings } = options;\n\n\tconst errors: JSONC.ParseError[] = [];\n\n\tlet content = jsonContent;\n\tlet root = JSONC.parseTree(content, errors, jsoncParseOptions);\n\n\tif (root === undefined || errors.length) {\n\t\tthrow new Error('VS Code configuration file is not valid JSON.');\n\t}\n\n\t// Find or create configurations array\n\tlet configurationsNode = JSONC.findNodeAtLocation(root, ['configurations']);\n\n\tif (\n\t\tconfigurationsNode === undefined ||\n\t\tconfigurationsNode.children === undefined\n\t) {\n\t\tconst edits = JSONC.modify(content, ['configurations'], [], {});\n\t\tcontent = JSONC.applyEdits(content, edits);\n\n\t\troot = JSONC.parseTree(content, [], jsoncParseOptions);\n\t\tconfigurationsNode = JSONC.findNodeAtLocation(root!, [\n\t\t\t'configurations',\n\t\t]);\n\t}\n\n\t// Check if configuration already exists\n\tconst configurationIndex = configurationsNode?.children?.findIndex(\n\t\t(child: any) =>\n\t\t\tJSONC.findNodeAtLocation(child, ['name'])?.value === name\n\t);\n\n\t// Only add configuration if it doesn't exist\n\tif (configurationIndex === undefined || configurationIndex < 0) {\n\t\tconst configuration: VSCodeConfigNode = {\n\t\t\tname: name,\n\t\t\ttype: 'php',\n\t\t\trequest: 'launch',\n\t\t\tport: 9003,\n\t\t};\n\n\t\tif (pathMappings && pathMappings.length) {\n\t\t\tconfiguration.pathMappings = pathMappings.reduce((acc, mount) => {\n\t\t\t\tacc[mount.vfsPath] = `\\${workspaceFolder}/${toPosixPath(\n\t\t\t\t\tpath.relative(options.workspaceDir, mount.hostPath)\n\t\t\t\t)}`;\n\t\t\t\treturn acc;\n\t\t\t}, {} as VSCodeConfigMetaData);\n\t\t}\n\n\t\tif (pathSkippings && pathSkippings.length) {\n\t\t\tconfiguration.skipFiles = pathSkippings.map((skippedPath) =>\n\t\t\t\tskippedPath.endsWith('/') ? `${skippedPath}**` : skippedPath\n\t\t\t);\n\t\t}\n\n\t\t// Get the current length to append at the end\n\t\tconst currentLength = configurationsNode?.children?.length || 0;\n\n\t\tconst edits = JSONC.modify(\n\t\t\tcontent,\n\t\t\t['configurations', currentLength],\n\t\t\tconfiguration,\n\t\t\t{\n\t\t\t\tformattingOptions: {\n\t\t\t\t\tinsertSpaces: true,\n\t\t\t\t\ttabSize: 4,\n\t\t\t\t\teol: '\\n',\n\t\t\t\t},\n\t\t\t}\n\t\t);\n\n\t\tcontent = jsoncApplyEdits(content, edits);\n\t}\n\n\treturn content;\n}\n\n/**\n * Implement necessary parameters and path mappings in IDE configuration files.\n *\n * @param name The configuration name.\n * @param mounts The mounts options.\n */\nexport async function addXdebugIDEConfig({\n\tname,\n\tides,\n\thost,\n\tport,\n\tcwd,\n\tmounts,\n\tpathSkippings,\n\tideKey = DEFAULT_IDE_KEY,\n}: IDEConfig) {\n\tconst pathMappings = mounts ? filterLocalMounts(cwd, mounts) : [];\n\tconst modifiedConfig: Record<string, string> = {};\n\n\t// PHPstorm\n\tif (ides.includes('phpstorm')) {\n\t\tconst phpStormRelativeConfigFilePath = '.idea/workspace.xml';\n\t\tconst phpStormConfigFilePath = path.join(\n\t\t\tcwd,\n\t\t\tphpStormRelativeConfigFilePath\n\t\t);\n\n\t\t// Create a template config file if the IDE directory exists,\n\t\t// or throw an error if IDE integration is requested but the directory is missing.\n\t\tif (!fs.existsSync(phpStormConfigFilePath)) {\n\t\t\tif (fs.existsSync(path.dirname(phpStormConfigFilePath))) {\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tphpStormConfigFilePath,\n\t\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t\t);\n\t\t\t} else if (ides.length == 1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`PhpStorm IDE integration requested, but no '.idea' directory was found in the current working directory.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (fs.existsSync(phpStormConfigFilePath)) {\n\t\t\tconst contents = fs.readFileSync(phpStormConfigFilePath, 'utf8');\n\t\t\tconst updatedXml = updatePhpStormWorkspaceConfig(contents, {\n\t\t\t\tname,\n\t\t\t\thost,\n\t\t\t\tport,\n\t\t\t\tprojectDir: cwd,\n\t\t\t\tpathMappings,\n\t\t\t\tideKey,\n\t\t\t});\n\t\t\tfs.writeFileSync(phpStormConfigFilePath, updatedXml);\n\t\t\tmodifiedConfig['phpstorm'] = phpStormRelativeConfigFilePath;\n\t\t}\n\n\t\t// PhpStorm php.xml (path skippings)\n\t\tif (pathSkippings && pathSkippings.length) {\n\t\t\tconst phpStormRelativePHPConfigFilePath = '.idea/php.xml';\n\t\t\tconst phpStormPHPConfigFilePath = path.join(\n\t\t\t\tcwd,\n\t\t\t\tphpStormRelativePHPConfigFilePath\n\t\t\t);\n\n\t\t\tif (!fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\t\t\tif (fs.existsSync(path.dirname(phpStormPHPConfigFilePath))) {\n\t\t\t\t\tfs.writeFileSync(\n\t\t\t\t\t\tphpStormPHPConfigFilePath,\n\t\t\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\t\t\tconst contents = fs.readFileSync(\n\t\t\t\t\tphpStormPHPConfigFilePath,\n\t\t\t\t\t'utf8'\n\t\t\t\t);\n\t\t\t\tconst updatedXml = updatePhpStormPHPConfig(contents, {\n\t\t\t\t\tpathSkippings,\n\t\t\t\t});\n\t\t\t\tfs.writeFileSync(phpStormPHPConfigFilePath, updatedXml);\n\t\t\t\tmodifiedConfig['phpstorm-php'] =\n\t\t\t\t\tphpStormRelativePHPConfigFilePath;\n\t\t\t}\n\t\t}\n\t}\n\n\t// VSCode\n\tif (ides.includes('vscode')) {\n\t\tconst vsCodeRelativeConfigFilePath = '.vscode/launch.json';\n\t\tconst vsCodeConfigFilePath = path.join(\n\t\t\tcwd,\n\t\t\tvsCodeRelativeConfigFilePath\n\t\t);\n\n\t\t// Create a template config file if the IDE directory exists,\n\t\t// or throw an error if IDE integration is requested but the directory is missing.\n\t\tif (!fs.existsSync(vsCodeConfigFilePath)) {\n\t\t\tif (fs.existsSync(path.dirname(vsCodeConfigFilePath))) {\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\tvsCodeConfigFilePath,\n\t\t\t\t\t'{\\n \"configurations\": []\\n}'\n\t\t\t\t);\n\t\t\t} else if (ides.length == 1) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`VS Code IDE integration requested, but no '.vscode' directory was found in the current working directory.`\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (fs.existsSync(vsCodeConfigFilePath)) {\n\t\t\tconst content = fs.readFileSync(vsCodeConfigFilePath, 'utf-8');\n\t\t\tconst updatedJson = updateVSCodeConfig(content, {\n\t\t\t\tname,\n\t\t\t\tworkspaceDir: cwd,\n\t\t\t\tpathMappings,\n\t\t\t\tpathSkippings,\n\t\t\t});\n\n\t\t\t// Only write and track the file if changes were made\n\t\t\tif (updatedJson !== content) {\n\t\t\t\tfs.writeFileSync(vsCodeConfigFilePath, updatedJson);\n\t\t\t\tmodifiedConfig['vscode'] = vsCodeRelativeConfigFilePath;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn modifiedConfig;\n}\n\n/**\n * Remove stale parameters and path mappings in IDE configuration files.\n *\n * @param name The configuration name.\n * @param cwd The current working directory.\n */\nexport async function clearXdebugIDEConfig(name: string, cwd: string) {\n\tconst phpStormConfigFilePath = path.join(cwd, '.idea/workspace.xml');\n\t// PhpStorm\n\tif (fs.existsSync(phpStormConfigFilePath)) {\n\t\tconst contents = fs.readFileSync(phpStormConfigFilePath, 'utf8');\n\t\tconst xmlParser = new XMLParser(xmlParserOptions);\n\t\t// NOTE: Using an IIFE so `config` can remain const.\n\t\tconst config: PhpStormWorkspaceConfigNode[] = (() => {\n\t\t\ttry {\n\t\t\t\treturn xmlParser.parse(contents, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'PhpStorm configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\t\t})();\n\n\t\tconst projectElement = config.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.project\n\t\t);\n\t\tconst componentElement = projectElement?.project?.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.component && c?.[':@']?.name === 'PhpServers'\n\t\t);\n\t\tconst serversElement = componentElement?.component?.find(\n\t\t\t(c: PhpStormWorkspaceConfigNode) => !!c?.servers\n\t\t);\n\t\tconst serverElementIndex = serversElement?.servers?.findIndex(\n\t\t\t(c: PhpStormWorkspaceConfigNode) =>\n\t\t\t\t!!c?.server && c?.[':@']?.name === name\n\t\t);\n\n\t\tif (serverElementIndex !== undefined && serverElementIndex >= 0) {\n\t\t\tserversElement!.servers!.splice(serverElementIndex, 1);\n\n\t\t\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\t\t\tconst xml = xmlBuilder.build(config);\n\n\t\t\ttry {\n\t\t\t\txmlParser.parse(xml, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'The resulting PhpStorm configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\txml ===\n\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n\t<component name=\"PhpServers\">\\n\t\t<servers></servers>\\n\t</component>\\n</project>'\n\t\t\t) {\n\t\t\t\tfs.unlinkSync(phpStormConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(phpStormConfigFilePath, xml);\n\t\t\t}\n\t\t}\n\t}\n\n\t// PhpStorm php.xml (path skippings)\n\tconst phpStormPHPConfigFilePath = path.join(cwd, '.idea/php.xml');\n\tif (fs.existsSync(phpStormPHPConfigFilePath)) {\n\t\tconst contents = fs.readFileSync(phpStormPHPConfigFilePath, 'utf8');\n\t\tconst xmlParser = new XMLParser(xmlParserOptions);\n\t\tconst config: PhpStormPHPConfigNode[] = (() => {\n\t\t\ttry {\n\t\t\t\treturn xmlParser.parse(contents, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'PhpStorm PHP configuration file is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\t\t})();\n\n\t\tconst projectElement = config.find(\n\t\t\t(c: PhpStormPHPConfigNode) => !!c?.project\n\t\t);\n\t\tconst componentIndex = projectElement?.project?.findIndex(\n\t\t\t(c: PhpStormPHPConfigNode) =>\n\t\t\t\t!!c?.component &&\n\t\t\t\tc?.[':@']?.name === 'PhpStepFilterConfiguration'\n\t\t);\n\n\t\tif (componentIndex !== undefined && componentIndex >= 0) {\n\t\t\tprojectElement!.project!.splice(componentIndex, 1);\n\n\t\t\tconst xmlBuilder = new XMLBuilder(xmlBuilderOptions);\n\t\t\tconst xml = xmlBuilder.build(config);\n\n\t\t\ttry {\n\t\t\t\txmlParser.parse(xml, true);\n\t\t\t} catch {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'The resulting PhpStorm PHP configuration file ' +\n\t\t\t\t\t\t'is not valid XML.'\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\txml ===\n\t\t\t\t'<?xml version=\"1.0\" encoding=\"UTF-8\"?>\\n<project version=\"4\">\\n</project>'\n\t\t\t) {\n\t\t\t\tfs.unlinkSync(phpStormPHPConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(phpStormPHPConfigFilePath, xml);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst vsCodeConfigFilePath = path.join(cwd, '.vscode/launch.json');\n\t// VSCode\n\tif (fs.existsSync(vsCodeConfigFilePath)) {\n\t\tconst errors: JSONC.ParseError[] = [];\n\n\t\tconst content = fs.readFileSync(vsCodeConfigFilePath, 'utf-8');\n\t\tconst root = JSONC.parseTree(content, errors, jsoncParseOptions);\n\n\t\tif (root === undefined || errors.length) {\n\t\t\tthrow new Error('VS Code configuration file is not valid JSON.');\n\t\t}\n\n\t\tconst configurationsNode = JSONC.findNodeAtLocation(root, [\n\t\t\t'configurations',\n\t\t]);\n\n\t\tconst configurationIndex = configurationsNode?.children?.findIndex(\n\t\t\t(child: any) =>\n\t\t\t\tJSONC.findNodeAtLocation(child, ['name'])?.value === name\n\t\t);\n\n\t\tif (configurationIndex !== undefined && configurationIndex >= 0) {\n\t\t\tconst edits = JSONC.modify(\n\t\t\t\tcontent,\n\t\t\t\t['configurations', configurationIndex],\n\t\t\t\tundefined,\n\t\t\t\t{\n\t\t\t\t\tformattingOptions: {\n\t\t\t\t\t\tinsertSpaces: true,\n\t\t\t\t\t\ttabSize: 4,\n\t\t\t\t\t\teol: '\\n',\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst json = jsoncApplyEdits(content, edits);\n\t\t\tif (json === '{\\n \"configurations\": []\\n}') {\n\t\t\t\tfs.unlinkSync(vsCodeConfigFilePath);\n\t\t\t} else {\n\t\t\t\tfs.writeFileSync(vsCodeConfigFilePath, json);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Implement path mapping and path skipping in Xdebug.\n *\n * @param name The configuration name.\n * @param mounts The mounts options.\n * @param pathSkippings The skipping paths options.\n * @returns Xdebug options\n */\nexport function makeXdebugConfig({\n\tcwd,\n\tmounts,\n\tpathSkippings,\n}: XdebugConfig): XdebugOptions {\n\tconst pathMappings =\n\t\tcwd && mounts ? filterLocalMounts(cwd, mounts) : undefined;\n\n\treturn { pathMappings, pathSkippings };\n}\n\nfunction jsoncApplyEdits(content: string, edits: JSONC.Edit[]) {\n\tconst errors: JSONC.ParseError[] = [];\n\tconst json = JSONC.applyEdits(content, edits);\n\n\terrors.length = 0;\n\n\tJSONC.parseTree(json, errors, jsoncParseOptions);\n\n\tif (errors.length) {\n\t\tconst formattedErrors = errors\n\t\t\t.map((error) => {\n\t\t\t\treturn {\n\t\t\t\t\tmessage: JSONC.printParseErrorCode(error.error),\n\t\t\t\t\toffset: error.offset,\n\t\t\t\t\tlength: error.length,\n\t\t\t\t\tfragment: json.slice(\n\t\t\t\t\t\tMath.max(0, error.offset - 20),\n\t\t\t\t\t\tMath.min(json.length, error.offset + error.length + 10)\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t})\n\t\t\t.map(\n\t\t\t\t(error) =>\n\t\t\t\t\t`${error.message} at ${error.offset}:${error.length} (${error.fragment})`\n\t\t\t);\n\t\tconst formattedEdits = edits.map(\n\t\t\t(edit) => `At ${edit.offset}:${edit.length} - (${edit.content})`\n\t\t);\n\t\tthrow new Error(\n\t\t\t`VS Code configuration file (.vscode/launch.json) is not valid a JSONC after CLI modifications. This is likely ` +\n\t\t\t\t`a CLI bug. Please report it at https://github.com/WordPress/wordpress-playground/issues and include the contents ` +\n\t\t\t\t`of your \".vscode/launch.json\" file. \\n\\n Applied edits: ${formattedEdits.join(\n\t\t\t\t\t'\\n'\n\t\t\t\t)}\\n\\n The errors are: ${formattedErrors.join('\\n')}`\n\t\t);\n\t}\n\n\treturn json;\n}\n"],"names":["CLIOutput","options","text","message","DEFAULT_IDE_KEY","DEFAULT_PATH_SKIPPINGS","createTempDirSymlink","nativeDirPath","symlinkPath","platform","type","fs","removeTempDirSymlink","filterLocalMounts","cwd","mounts","mount","absoluteHostPath","path","cwdChildPrefix","xmlParserOptions","xmlBuilderOptions","jsoncParseOptions","updatePhpStormWorkspaceConfig","xmlContent","name","host","port","pathMappings","ideKey","xmlParser","XMLParser","config","serverElement","pathMapping","toPosixPath","projectElement","c","projectVersion","_a","componentElement","_b","serversElement","_c","serverElementIndex","_d","runManagerElement","_e","_f","runConfigElement","xml","XMLBuilder","updatePhpStormPHPConfig","pathSkippings","skippedFilesElement","skippedPath","filePath","updateVSCodeConfig","jsonContent","errors","content","root","JSONC","configurationsNode","edits","configurationIndex","child","configuration","acc","currentLength","jsoncApplyEdits","addXdebugIDEConfig","ides","modifiedConfig","phpStormRelativeConfigFilePath","phpStormConfigFilePath","contents","updatedXml","phpStormRelativePHPConfigFilePath","phpStormPHPConfigFilePath","vsCodeRelativeConfigFilePath","vsCodeConfigFilePath","updatedJson","clearXdebugIDEConfig","componentIndex","json","makeXdebugConfig","formattedErrors","error","formattedEdits","edit"],"mappings":";;;;;AAOO,MAAMA,EAAU;AAAA,EAItB,YAAYC,GAA2B;AACtC,SAAK,YAAYA,EAAQ,WACzB,KAAK,cAAcA,EAAQ,eAAe,QAAQ;AAAA,EACnD;AAAA,EAEA,IAAI,QAAiB;AACpB,WAAO,EAAQ,KAAK,YAAY;AAAA,EACjC;AAAA,EAEA,IAAI,UAAmB;AACtB,WAAO,KAAK,cAAc;AAAA,EAC3B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,KAAKC,GAAsB;AAC1B,WAAO,KAAK,QAAQ,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AAA,EAEtD;AAEA,SAAOF;AACR;"} |
+1
-0
@@ -0,2 +1,3 @@ | ||
| export * from './cli-output'; | ||
| export * from './mounts'; | ||
| export * from './xdebug-path-mappings'; |
+3
-3
| { | ||
| "name": "@php-wasm/cli-util", | ||
| "version": "3.1.21", | ||
| "version": "3.1.22", | ||
| "description": "Utilities for PHP.wasm related CLIs", | ||
@@ -34,3 +34,3 @@ "repository": { | ||
| "license": "GPL-2.0-or-later", | ||
| "gitHead": "5864051cbf4c2a55656112d99a3f1b076bcd67cd", | ||
| "gitHead": "04c986b63dd56fe74e4ed0cf04d00cae7ac050bf", | ||
| "engines": { | ||
@@ -43,3 +43,3 @@ "node": ">=20.10.0", | ||
| "jsonc-parser": "3.3.1", | ||
| "@php-wasm/util": "3.1.21" | ||
| "@php-wasm/util": "3.1.22" | ||
| }, | ||
@@ -46,0 +46,0 @@ "packageManager": "npm@10.9.2", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
146218
6.96%12
9.09%834
12.7%+ Added
- Removed
Updated