@php-wasm/cli-util 3.1.20 → 3.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -1,25 +1,28 @@
1
- "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:`
2
- `}});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"?>
1
+ "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}
2
+ `)}printError(e){this.writeStream.write(`${this.red("Error:")} ${e}
3
+ `)}printWarning(e){this.isQuiet||this.writeStream.write(`${this.yellow("Warning:")} ${e}
4
+ `)}}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:`
5
+ `}});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"?>
3
6
  <project version="4">
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"?>
7
+ </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"?>
5
8
  <project version="4">
6
- </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,`{
9
+ </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,`{
7
10
  "configurations": []
8
- }`);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"?>
11
+ }`);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"?>
9
12
  <project version="4">
10
13
  <component name="PhpServers">
11
14
  <servers></servers>
12
15
  </component>
13
- </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"?>
16
+ </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"?>
14
17
  <project version="4">
15
- </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:`
16
- `}}),g=N(o,a);g===`{
18
+ </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:`
19
+ `}}),g=A(r,p);g===`{
17
20
  "configurations": []
18
- }`?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.
21
+ }`?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.
19
22
 
20
23
  Applied edits: ${h.join(`
21
24
  `)}
22
25
 
23
- The errors are: ${u.join(`
24
- `)}`)}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;
26
+ The errors are: ${d.join(`
27
+ `)}`)}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;
25
28
  //# sourceMappingURL=index.cjs.map
package/index.cjs.map CHANGED
@@ -1 +1 @@
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,kBACTG,EAAG,WAAWH,CAAW,CAE3B,MAAQ,CAER,CACD,CAOA,SAASK,EAAkBC,EAAaC,EAAiB,CACxD,OAAOA,EAAO,OAAQC,GAAU,CAC/B,MAAMC,EAAmBC,EAAK,QAAQF,EAAM,QAAQ,EAC9CG,EAAiBD,EAAK,KAAKJ,EAAKI,EAAK,GAAG,EAC9C,OAGCD,IAAqBH,GACrBG,EAAiB,WAAWE,CAAc,CAE5C,CAAC,CACF,CA0GA,MAAMC,EAA+B,CACpC,iBAAkB,GAClB,oBAAqB,GACrB,cAAe,GACf,cAAe,UACf,gBAAiB,eACjB,uBAAwB,GACxB,WAAY,EACb,EACMC,EAAuC,CAC5C,iBAAkBD,EAAiB,iBACnC,oBAAqBA,EAAiB,oBACtC,cAAeA,EAAiB,cAChC,cAAeA,EAAiB,cAChC,gBAAiBA,EAAiB,gBA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K,EACvCqB,IAAS;AAAA;AAAA,GACZ3E,EAAG,WAAWuE,CAAoB,EAElCvE,EAAG,cAAcuE,EAAsBI,CAAI,CAE7C,CACD,CACD,CAUO,SAASC,EAAiB,CAChC,IAAAzE,EACA,OAAAC,EACA,cAAAuC,CACD,EAAgC,CAI/B,MAAO,CAAE,aAFRxC,GAAOC,EAASF,EAAkBC,EAAKC,CAAM,EAAI,OAE3B,cAAAuC,CAAA,CACxB,CAEA,SAASiB,EAAgBV,EAAiBI,EAAqB,CAC9D,MAAML,EAA6B,CAAA,EAC7B0B,EAAOvB,EAAM,WAAWF,EAASI,CAAK,EAM5C,GAJAL,EAAO,OAAS,EAEhBG,EAAM,UAAUuB,EAAM1B,EAAQtC,CAAiB,EAE3CsC,EAAO,OAAQ,CAClB,MAAM4B,EAAkB5B,EACtB,IAAK6B,IACE,CACN,QAAS1B,EAAM,oBAAoB0B,EAAM,KAAK,EAC9C,OAAQA,EAAM,OACd,OAAQA,EAAM,OACd,SAAUH,EAAK,MACd,KAAK,IAAI,EAAGG,EAAM,OAAS,EAAE,EAC7B,KAAK,IAAIH,EAAK,OAAQG,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"}
1
+ {"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,CAC/C,CAEA,IAAIA,EAAsB,CACzB,OAAO,KAAK,MAAQ,WAAWA,CAAI,UAAYA,CAChD,CAEA,MAAMA,EAAsB,CAC3B,OAAO,KAAK,MAAQ,WAAWA,CAAI,UAAYA,CAChD,CAEA,OAAOA,EAAsB,CAC5B,OAAO,KAAK,MAAQ,WAAWA,CAAI,UAAYA,CAChD,CAEA,KAAKA,EAAsB,CAC1B,OAAO,KAAK,MAAQ,WAAWA,CAAI,UAAYA,CAChD,CAEA,UAAUA,EAAsB,CAC/B,OAAO,KAAK,OAAOA,CAAI,CACxB,CAEA,MAAMC,EAAuB,CACxB,KAAK,SACT,KAAK,YAAY,MAAM,GAAGA,CAAO;AAAA,CAAI,CACtC,CAEA,WAAWA,EAAuB,CACjC,KAAK,YAAY,MAAM,GAAG,KAAK,IAAI,QAAQ,CAAC,IAAIA,CAAO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