Skip to content

Commit 46d50ec

Browse files
mho22brandonpaytonadamziel
authored
[ xdebug ] Add --experimental-unsafe-ide-integration option in Playground CLI (#2777)
## Motivation for the change, related issues Based on issue #2763 The current pain we have when we run a Playground CLI command with Xdebug enabled is the absence of the files located in the VFS in our IDE. This pull request gives visibility to the VFS files with the help of a `.playground-xdebug-root` symlink and the generation of path mappings inside the developer's IDE. Only the mounts from inside the current working directory are mapped. ## Implementation details 1. Symlinking > `.playground-xdebug-root` - It first removes a possibly existing symlink with name `.playground-xdebug-root` in the current working directory. - If `--xdebug` and `--experimental-unsafe-ide-integration` options are present, we symlink the temporary playground cli directory inside the current working directory. 2. Path mapping in IDEs - It first clears all the configs named `WP Playground CLI - Listen for Xdebug` in VSCode and PHPStorm config files. - If `--xdebug` and `--experimental-unsafe-ide-integration` options are present, we add IDE configs and path mappings in the related configs. - PHPStorm : it adds a new `server` with name `WP Playground CLI - Listen for Xdebug` in `.idea/workspace.xml`. - VSCode : it adds a new `configuration` with name `WP Playground CLI - Listen for Xdebug` in `.vscode/launch.json`. Next steps are reported in the [Xdebug Follow-up issue](#2315). ## Testing Instructions (or ideally a Blueprint) Run as follows: ```sh node --no-warnings=ExperimentalWarning --experimental-strip-types --experimental-transform-types --import ./pac kages/meta/src/node-es-module-loader/register.mts ./packages/playground/cli/src/cli.ts server --xdebug --experimental-unsafe-ide-integration ``` --------- Co-authored-by: Brandon Payton <[email protected]> Co-authored-by: Adam Zieliński <[email protected]>
1 parent 2e39067 commit 46d50ec

File tree

14 files changed

+6238
-4979
lines changed

14 files changed

+6238
-4979
lines changed

.vscode/launch.json

Lines changed: 168 additions & 156 deletions
Original file line numberDiff line numberDiff line change
@@ -1,161 +1,173 @@
11
{
2-
// Use IntelliSense to learn about possible attributes.
3-
// Hover to view descriptions of existing attributes.
4-
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5-
"version": "0.2.0",
6-
"configurations": [
7-
{
8-
"name": "Debug PHP-WASM CLI",
9-
"request": "launch",
10-
"type": "node",
11-
"runtimeVersion": "23",
12-
"runtimeExecutable": "npx",
13-
"runtimeArgs": [
14-
"nx",
15-
"debug",
16-
"php-wasm-cli",
17-
"${input:phpWasmCliArg1}",
18-
"${input:phpWasmCliArg2}",
19-
"${input:phpWasmCliArg3}",
20-
"${input:phpWasmCliArg4}"
21-
],
22-
"cwd": "${workspaceFolder}",
23-
"autoAttachChildProcesses": true,
24-
"env": {
25-
"PHP": "${input:phpVersion}"
26-
},
27-
"enableDWARF": false
28-
},
29-
{
30-
"name": "Debug PHP-WASM CLI with DWARF Symbols",
31-
"request": "launch",
32-
"type": "node",
33-
"runtimeVersion": "23",
34-
"runtimeExecutable": "npx",
35-
"runtimeArgs": [
36-
"nx",
37-
"debug",
38-
"php-wasm-cli",
39-
"${input:phpWasmCliArg1}",
40-
"${input:phpWasmCliArg2}",
41-
"${input:phpWasmCliArg3}",
42-
"${input:phpWasmCliArg4}"
43-
],
44-
"cwd": "${workspaceFolder}",
45-
"autoAttachChildProcesses": true,
46-
"env": {
47-
"PHP": "${input:phpVersion}"
48-
},
49-
"enableDWARF": true
50-
},
51-
{
52-
"name": "Debug Playground CLI",
53-
"request": "launch",
54-
"type": "node",
55-
"runtimeVersion": "23",
56-
"runtimeExecutable": "npx",
57-
"runtimeArgs": [
58-
"nx",
59-
"debug",
60-
"playground-cli",
61-
"server",
62-
],
63-
"args": "${input:playgroundCliCommand}",
64-
"cwd": "${workspaceFolder}",
65-
"autoAttachChildProcesses": true
66-
},
67-
{
68-
"name": "Debug Playground CLI with DWARF Symbols",
69-
"request": "launch",
70-
"type": "node",
71-
"runtimeVersion": "23",
72-
"runtimeExecutable": "npx",
73-
"runtimeArgs": [
74-
"nx",
75-
"debug",
76-
"playground-cli",
77-
"server",
78-
],
79-
"args": "${input:playgroundCliCommand}",
80-
"cwd": "${workspaceFolder}",
81-
"autoAttachChildProcesses": true,
82-
"enableDWARF": true
83-
},
84-
{
85-
"name": "Launch Chrome",
86-
"request": "launch",
87-
"type": "chrome",
88-
"url": "http://localhost:5400/website-server/",
89-
"webRoot": "${workspaceFolder}"
90-
},
91-
{
92-
"name": "Test playground sync",
93-
"request": "launch",
94-
"runtimeArgs": [
95-
"run",
96-
"playground-sync:test"
97-
],
98-
"runtimeExecutable": "nx",
99-
"skipFiles": [
100-
"<node_internals>/**"
101-
],
102-
"type": "node"
103-
},
104-
{
105-
"name": "Heap Profiler",
106-
"type": "node",
107-
"request": "launch",
108-
"program": "${workspaceFolder}/test2.mjs",
109-
"cwd": "${workspaceFolder}",
110-
"runtimeArgs": ["--inspect-brk", "--loader=${workspaceFolder}/packages/nx-extensions/src/executors/built-script/loader.mjs"]
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "WP Playground CLI - Listen for Xdebug",
9+
"type": "php",
10+
"request": "launch",
11+
"port": 9003,
12+
"pathMappings": {
13+
"/": "${workspaceFolder}/.playground-xdebug-root"
11114
}
112-
],
113-
"inputs": [
114-
{
115-
"type": "pickString",
116-
"id": "phpVersion",
117-
"description": "PHP Version",
118-
"default": "8.0",
119-
"options": [
120-
"7.2",
121-
"7.3",
122-
"7.4",
123-
"8.0",
124-
"8.1",
125-
"8.2",
126-
"8.3",
127-
"8.4",
128-
]
129-
},
130-
{
131-
"type": "promptString",
132-
"id": "phpWasmCliArg1",
133-
"description": "First argument",
134-
"default": "-r"
135-
},
136-
{
137-
"type": "promptString",
138-
"id": "phpWasmCliArg2",
139-
"description": "Second argument",
140-
"default": "echo 'Hello, Debugger!';"
15+
},
16+
{
17+
"name": "Debug PHP-WASM CLI",
18+
"request": "launch",
19+
"type": "node",
20+
"runtimeVersion": "23",
21+
"runtimeExecutable": "npx",
22+
"runtimeArgs": [
23+
"nx",
24+
"debug",
25+
"php-wasm-cli",
26+
"${input:phpWasmCliArg1}",
27+
"${input:phpWasmCliArg2}",
28+
"${input:phpWasmCliArg3}",
29+
"${input:phpWasmCliArg4}"
30+
],
31+
"cwd": "${workspaceFolder}",
32+
"autoAttachChildProcesses": true,
33+
"env": {
34+
"PHP": "${input:phpVersion}"
14135
},
142-
{
143-
"type": "promptString",
144-
"id": "phpWasmCliArg3",
145-
"description": "Third argument or empty",
146-
"default": ""
36+
"enableDWARF": false
37+
},
38+
{
39+
"name": "Debug PHP-WASM CLI with DWARF Symbols",
40+
"request": "launch",
41+
"type": "node",
42+
"runtimeVersion": "23",
43+
"runtimeExecutable": "npx",
44+
"runtimeArgs": [
45+
"nx",
46+
"debug",
47+
"php-wasm-cli",
48+
"${input:phpWasmCliArg1}",
49+
"${input:phpWasmCliArg2}",
50+
"${input:phpWasmCliArg3}",
51+
"${input:phpWasmCliArg4}"
52+
],
53+
"cwd": "${workspaceFolder}",
54+
"autoAttachChildProcesses": true,
55+
"env": {
56+
"PHP": "${input:phpVersion}"
14757
},
148-
{
149-
"type": "promptString",
150-
"id": "phpWasmCliArg4",
151-
"description": "Fourth argument or empty -- for more, edit launch.json.",
152-
"default": ""
153-
},
154-
{
155-
"type": "promptString",
156-
"id": "playgroundCliCommand",
157-
"description": "Playground CLI Command",
158-
"default": "server"
159-
}
160-
]
58+
"enableDWARF": true
59+
},
60+
{
61+
"name": "Debug Playground CLI",
62+
"request": "launch",
63+
"type": "node",
64+
"runtimeVersion": "23",
65+
"runtimeExecutable": "npx",
66+
"runtimeArgs": [
67+
"nx",
68+
"debug",
69+
"playground-cli",
70+
"server",
71+
],
72+
"args": "${input:playgroundCliCommand}",
73+
"cwd": "${workspaceFolder}",
74+
"autoAttachChildProcesses": true
75+
},
76+
{
77+
"name": "Debug Playground CLI with DWARF Symbols",
78+
"request": "launch",
79+
"type": "node",
80+
"runtimeVersion": "23",
81+
"runtimeExecutable": "npx",
82+
"runtimeArgs": [
83+
"nx",
84+
"debug",
85+
"playground-cli",
86+
"server",
87+
],
88+
"args": "${input:playgroundCliCommand}",
89+
"cwd": "${workspaceFolder}",
90+
"autoAttachChildProcesses": true,
91+
"enableDWARF": true
92+
},
93+
{
94+
"name": "Launch Chrome",
95+
"request": "launch",
96+
"type": "chrome",
97+
"url": "http://localhost:5400/website-server/",
98+
"webRoot": "${workspaceFolder}"
99+
},
100+
{
101+
"name": "Test playground sync",
102+
"request": "launch",
103+
"runtimeArgs": [
104+
"run",
105+
"playground-sync:test"
106+
],
107+
"runtimeExecutable": "nx",
108+
"skipFiles": [
109+
"<node_internals>/**"
110+
],
111+
"type": "node"
112+
},
113+
{
114+
"name": "Heap Profiler",
115+
"type": "node",
116+
"request": "launch",
117+
"program": "${workspaceFolder}/test2.mjs",
118+
"cwd": "${workspaceFolder}",
119+
"runtimeArgs": [
120+
"--inspect-brk",
121+
"--loader=${workspaceFolder}/packages/nx-extensions/src/executors/built-script/loader.mjs"
122+
]
123+
}
124+
],
125+
"inputs": [
126+
{
127+
"type": "pickString",
128+
"id": "phpVersion",
129+
"description": "PHP Version",
130+
"default": "8.0",
131+
"options": [
132+
"7.2",
133+
"7.3",
134+
"7.4",
135+
"8.0",
136+
"8.1",
137+
"8.2",
138+
"8.3",
139+
"8.4",
140+
]
141+
},
142+
{
143+
"type": "promptString",
144+
"id": "phpWasmCliArg1",
145+
"description": "First argument",
146+
"default": "-r"
147+
},
148+
{
149+
"type": "promptString",
150+
"id": "phpWasmCliArg2",
151+
"description": "Second argument",
152+
"default": "echo 'Hello, Debugger!';"
153+
},
154+
{
155+
"type": "promptString",
156+
"id": "phpWasmCliArg3",
157+
"description": "Third argument or empty",
158+
"default": ""
159+
},
160+
{
161+
"type": "promptString",
162+
"id": "phpWasmCliArg4",
163+
"description": "Fourth argument or empty -- for more, edit launch.json.",
164+
"default": ""
165+
},
166+
{
167+
"type": "promptString",
168+
"id": "playgroundCliCommand",
169+
"description": "Playground CLI Command",
170+
"default": "server"
171+
}
172+
]
161173
}

0 commit comments

Comments
 (0)