@php-wasm/cli-util 3.1.18 → 3.1.19
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 +14 -10
- package/index.cjs.map +1 -1
- package/index.js +343 -209
- package/index.js.map +1 -1
- package/lib/xdebug-path-mappings.d.ts +23 -5
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1,35 +1,41 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import { toPosixPath as
|
|
4
|
-
import { XMLParser as
|
|
5
|
-
import * as
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import a from "fs";
|
|
2
|
+
import w from "path";
|
|
3
|
+
import { toPosixPath as $ } from "@php-wasm/util";
|
|
4
|
+
import { XMLParser as F, XMLBuilder as b } from "fast-xml-parser";
|
|
5
|
+
import * as x from "jsonc-parser";
|
|
6
|
+
const N = "PHPWASMCLI", U = [
|
|
7
|
+
"/dev/",
|
|
8
|
+
"/home/",
|
|
9
|
+
"/internal/",
|
|
10
|
+
"/request/",
|
|
11
|
+
"/proc/"
|
|
12
|
+
];
|
|
13
|
+
async function W(u, f, l) {
|
|
14
|
+
const d = l === "win32" ? (
|
|
9
15
|
// On Windows, creating a 'dir' symlink can require elevated permissions.
|
|
10
16
|
// In this case, let's make junction points because they function like
|
|
11
17
|
// symlinks and do not require elevated permissions.
|
|
12
18
|
"junction"
|
|
13
19
|
) : "dir";
|
|
14
|
-
|
|
20
|
+
a.symlinkSync(u, f, d);
|
|
15
21
|
}
|
|
16
|
-
async function
|
|
22
|
+
async function q(u) {
|
|
17
23
|
try {
|
|
18
|
-
|
|
24
|
+
a.lstatSync(u).isSymbolicLink() && a.unlinkSync(u);
|
|
19
25
|
} catch {
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
|
-
function
|
|
23
|
-
return
|
|
24
|
-
const
|
|
28
|
+
function D(u, f) {
|
|
29
|
+
return f.filter((l) => {
|
|
30
|
+
const d = w.resolve(l.hostPath), c = w.join(u, w.sep);
|
|
25
31
|
return (
|
|
26
32
|
// If auto-mounting from the current directory,
|
|
27
33
|
// the entire project directory can be mapped.
|
|
28
|
-
|
|
34
|
+
d === u || d.startsWith(c)
|
|
29
35
|
);
|
|
30
36
|
});
|
|
31
37
|
}
|
|
32
|
-
const
|
|
38
|
+
const E = {
|
|
33
39
|
ignoreAttributes: !1,
|
|
34
40
|
attributeNamePrefix: "",
|
|
35
41
|
preserveOrder: !0,
|
|
@@ -37,100 +43,104 @@ const x = {
|
|
|
37
43
|
commentPropName: "__xmlComment",
|
|
38
44
|
allowBooleanAttributes: !0,
|
|
39
45
|
trimValues: !0
|
|
40
|
-
},
|
|
41
|
-
ignoreAttributes:
|
|
42
|
-
attributeNamePrefix:
|
|
43
|
-
preserveOrder:
|
|
44
|
-
cdataPropName:
|
|
45
|
-
commentPropName:
|
|
46
|
-
suppressBooleanAttributes: !
|
|
46
|
+
}, I = {
|
|
47
|
+
ignoreAttributes: E.ignoreAttributes,
|
|
48
|
+
attributeNamePrefix: E.attributeNamePrefix,
|
|
49
|
+
preserveOrder: E.preserveOrder,
|
|
50
|
+
cdataPropName: E.cdataPropName,
|
|
51
|
+
commentPropName: E.commentPropName,
|
|
52
|
+
suppressBooleanAttributes: !E.allowBooleanAttributes,
|
|
47
53
|
format: !0,
|
|
48
54
|
indentBy: " "
|
|
49
|
-
},
|
|
55
|
+
}, k = {
|
|
50
56
|
allowEmptyContent: !0,
|
|
51
57
|
allowTrailingComma: !0
|
|
52
58
|
};
|
|
53
|
-
function
|
|
54
|
-
var
|
|
55
|
-
const { name:
|
|
59
|
+
function X(u, f) {
|
|
60
|
+
var S, C, L, T, _, M;
|
|
61
|
+
const { name: l, host: d, port: c, pathMappings: h, ideKey: t } = f, P = new F(E), v = (() => {
|
|
56
62
|
try {
|
|
57
|
-
return
|
|
63
|
+
return P.parse(u, !0);
|
|
58
64
|
} catch {
|
|
59
65
|
throw new Error("PhpStorm configuration file is not valid XML.");
|
|
60
66
|
}
|
|
61
|
-
})(),
|
|
67
|
+
})(), y = {
|
|
62
68
|
server: [{}],
|
|
63
69
|
":@": {
|
|
64
|
-
name:
|
|
70
|
+
name: l,
|
|
65
71
|
// NOTE: PhpStorm quirk: Xdebug only works when the full URL (including port)
|
|
66
72
|
// is provided in `host`. The separate `port` field is ignored or misinterpreted,
|
|
67
73
|
// so we rely solely on host: "host:port".
|
|
68
|
-
host: `${
|
|
74
|
+
host: `${d}:${c}`,
|
|
69
75
|
use_path_mappings: "true"
|
|
70
76
|
}
|
|
71
77
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
78
|
+
h && h.length && (y.server[0].path_mappings = h.map(
|
|
79
|
+
(n) => ({
|
|
80
|
+
mapping: [],
|
|
81
|
+
":@": {
|
|
82
|
+
"local-root": `$PROJECT_DIR$/${$(
|
|
83
|
+
w.relative(f.projectDir, n.hostPath)
|
|
84
|
+
)}`,
|
|
85
|
+
"remote-root": n.vfsPath
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
));
|
|
89
|
+
let p = v == null ? void 0 : v.find(
|
|
90
|
+
(n) => !!(n != null && n.project)
|
|
91
|
+
);
|
|
92
|
+
if (p) {
|
|
93
|
+
const n = (S = p[":@"]) == null ? void 0 : S.version;
|
|
94
|
+
if (n === void 0)
|
|
85
95
|
throw new Error(
|
|
86
96
|
'PhpStorm IDE integration only supports <project version="4"> in workspace.xml, but the <project> configuration has no version number.'
|
|
87
97
|
);
|
|
88
|
-
if (
|
|
98
|
+
if (n !== "4")
|
|
89
99
|
throw new Error(
|
|
90
|
-
`PhpStorm IDE integration only supports <project version="4"> in workspace.xml, but we found a <project> configuration with version "${
|
|
100
|
+
`PhpStorm IDE integration only supports <project version="4"> in workspace.xml, but we found a <project> configuration with version "${n}".`
|
|
91
101
|
);
|
|
92
102
|
}
|
|
93
|
-
|
|
103
|
+
p === void 0 && (p = {
|
|
94
104
|
project: [],
|
|
95
105
|
":@": { version: "4" }
|
|
96
|
-
},
|
|
97
|
-
let o = (
|
|
98
|
-
(
|
|
99
|
-
var
|
|
100
|
-
return !!(
|
|
106
|
+
}, v.push(p));
|
|
107
|
+
let o = (C = p.project) == null ? void 0 : C.find(
|
|
108
|
+
(n) => {
|
|
109
|
+
var j;
|
|
110
|
+
return !!(n != null && n.component) && ((j = n == null ? void 0 : n[":@"]) == null ? void 0 : j.name) === "PhpServers";
|
|
101
111
|
}
|
|
102
112
|
);
|
|
103
113
|
o === void 0 && (o = {
|
|
104
114
|
component: [],
|
|
105
115
|
":@": { name: "PhpServers" }
|
|
106
|
-
},
|
|
107
|
-
let
|
|
108
|
-
(
|
|
116
|
+
}, p.project === void 0 && (p.project = []), p.project.push(o));
|
|
117
|
+
let i = (L = o.component) == null ? void 0 : L.find(
|
|
118
|
+
(n) => !!(n != null && n.servers)
|
|
109
119
|
);
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
(
|
|
113
|
-
var
|
|
114
|
-
return !!(
|
|
120
|
+
i === void 0 && (i = { servers: [] }, o.component === void 0 && (o.component = []), o.component.push(i));
|
|
121
|
+
const r = (T = i.servers) == null ? void 0 : T.findIndex(
|
|
122
|
+
(n) => {
|
|
123
|
+
var j;
|
|
124
|
+
return !!(n != null && n.server) && ((j = n == null ? void 0 : n[":@"]) == null ? void 0 : j.name) === l;
|
|
115
125
|
}
|
|
116
126
|
);
|
|
117
|
-
(
|
|
118
|
-
let
|
|
119
|
-
(
|
|
120
|
-
var
|
|
121
|
-
return !!(
|
|
127
|
+
(r === void 0 || r < 0) && (i.servers === void 0 && (i.servers = []), i.servers.push(y));
|
|
128
|
+
let e = (_ = p.project) == null ? void 0 : _.find(
|
|
129
|
+
(n) => {
|
|
130
|
+
var j;
|
|
131
|
+
return !!(n != null && n.component) && ((j = n == null ? void 0 : n[":@"]) == null ? void 0 : j.name) === "RunManager";
|
|
122
132
|
}
|
|
123
133
|
);
|
|
124
|
-
if (
|
|
134
|
+
if (e === void 0 && (e = {
|
|
125
135
|
component: [],
|
|
126
136
|
":@": { name: "RunManager" }
|
|
127
|
-
},
|
|
128
|
-
(
|
|
129
|
-
var
|
|
130
|
-
return !!(
|
|
137
|
+
}, p.project === void 0 && (p.project = []), p.project.push(e)), (((M = e.component) == null ? void 0 : M.findIndex(
|
|
138
|
+
(n) => {
|
|
139
|
+
var j;
|
|
140
|
+
return !!(n != null && n.configuration) && ((j = n == null ? void 0 : n[":@"]) == null ? void 0 : j.name) === l;
|
|
131
141
|
}
|
|
132
142
|
)) ?? -1) < 0) {
|
|
133
|
-
const
|
|
143
|
+
const n = {
|
|
134
144
|
configuration: [
|
|
135
145
|
{
|
|
136
146
|
method: [],
|
|
@@ -138,59 +148,126 @@ function _(c, a) {
|
|
|
138
148
|
}
|
|
139
149
|
],
|
|
140
150
|
":@": {
|
|
141
|
-
name:
|
|
151
|
+
name: l,
|
|
142
152
|
type: "PhpRemoteDebugRunConfigurationType",
|
|
143
153
|
factoryName: "PHP Remote Debug",
|
|
144
154
|
filter_connections: "FILTER",
|
|
145
|
-
server_name:
|
|
155
|
+
server_name: l,
|
|
146
156
|
session_id: t
|
|
147
157
|
}
|
|
148
158
|
};
|
|
149
|
-
|
|
159
|
+
e.component === void 0 && (e.component = []), e.component.push(n);
|
|
150
160
|
}
|
|
151
|
-
const
|
|
161
|
+
const m = new b(I).build(v);
|
|
152
162
|
try {
|
|
153
|
-
|
|
163
|
+
P.parse(m, !0);
|
|
154
164
|
} catch {
|
|
155
165
|
throw new Error(
|
|
156
166
|
"The resulting PhpStorm configuration file is not valid XML."
|
|
157
167
|
);
|
|
158
168
|
}
|
|
159
|
-
return
|
|
169
|
+
return m;
|
|
160
170
|
}
|
|
161
|
-
function B(
|
|
162
|
-
var
|
|
163
|
-
const {
|
|
164
|
-
|
|
165
|
-
|
|
171
|
+
function B(u, f) {
|
|
172
|
+
var p, o, i, r;
|
|
173
|
+
const { pathSkippings: l } = f, d = new F(E), c = (() => {
|
|
174
|
+
try {
|
|
175
|
+
return d.parse(u, !0);
|
|
176
|
+
} catch {
|
|
177
|
+
throw new Error(
|
|
178
|
+
"PhpStorm PHP configuration file is not valid XML."
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
})();
|
|
182
|
+
let h = c == null ? void 0 : c.find(
|
|
183
|
+
(e) => !!(e != null && e.project)
|
|
184
|
+
);
|
|
185
|
+
if (h) {
|
|
186
|
+
const e = (p = h[":@"]) == null ? void 0 : p.version;
|
|
187
|
+
if (e === void 0)
|
|
188
|
+
throw new Error(
|
|
189
|
+
'PhpStorm IDE integration only supports <project version="4"> in php.xml, but the <project> configuration has no version number.'
|
|
190
|
+
);
|
|
191
|
+
if (e !== "4")
|
|
192
|
+
throw new Error(
|
|
193
|
+
`PhpStorm IDE integration only supports <project version="4"> in php.xml, but we found a <project> configuration with version "${e}".`
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
h === void 0 && (h = {
|
|
197
|
+
project: [],
|
|
198
|
+
":@": { version: "4" }
|
|
199
|
+
}, c.push(h));
|
|
200
|
+
let t = (o = h.project) == null ? void 0 : o.find(
|
|
201
|
+
(e) => {
|
|
202
|
+
var s;
|
|
203
|
+
return !!(e != null && e.component) && ((s = e == null ? void 0 : e[":@"]) == null ? void 0 : s.name) === "PhpStepFilterConfiguration";
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
t === void 0 && (t = {
|
|
207
|
+
component: [],
|
|
208
|
+
":@": { name: "PhpStepFilterConfiguration" }
|
|
209
|
+
}, h.project === void 0 && (h.project = []), h.project.push(t));
|
|
210
|
+
let P = (i = t.component) == null ? void 0 : i.find(
|
|
211
|
+
(e) => !!(e != null && e.skipped_files)
|
|
212
|
+
);
|
|
213
|
+
if (P === void 0 && (P = { skipped_files: [] }, t.component === void 0 && (t.component = []), t.component.push(P)), l && l.length)
|
|
214
|
+
for (const e of l) {
|
|
215
|
+
const g = `$PROJECT_DIR$${e.endsWith("/") ? e.slice(0, -1) : e}`;
|
|
216
|
+
((r = P.skipped_files) == null ? void 0 : r.some(
|
|
217
|
+
(S) => {
|
|
218
|
+
var C;
|
|
219
|
+
return !!(S != null && S.skipped_file) && ((C = S == null ? void 0 : S[":@"]) == null ? void 0 : C.file) === g;
|
|
220
|
+
}
|
|
221
|
+
)) || (P.skipped_files === void 0 && (P.skipped_files = []), P.skipped_files.push({
|
|
222
|
+
skipped_file: [],
|
|
223
|
+
":@": { file: g }
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
const y = new b(I).build(c);
|
|
227
|
+
try {
|
|
228
|
+
d.parse(y, !0);
|
|
229
|
+
} catch {
|
|
230
|
+
throw new Error(
|
|
231
|
+
"The resulting PhpStorm PHP configuration file is not valid XML."
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
return y;
|
|
235
|
+
}
|
|
236
|
+
function O(u, f) {
|
|
237
|
+
var p, o;
|
|
238
|
+
const { name: l, pathMappings: d, pathSkippings: c } = f, h = [];
|
|
239
|
+
let t = u, P = x.parseTree(t, h, k);
|
|
240
|
+
if (P === void 0 || h.length)
|
|
166
241
|
throw new Error("VS Code configuration file is not valid JSON.");
|
|
167
|
-
let
|
|
168
|
-
if (
|
|
169
|
-
const
|
|
170
|
-
|
|
242
|
+
let v = x.findNodeAtLocation(P, ["configurations"]);
|
|
243
|
+
if (v === void 0 || v.children === void 0) {
|
|
244
|
+
const i = x.modify(t, ["configurations"], [], {});
|
|
245
|
+
t = x.applyEdits(t, i), P = x.parseTree(t, [], k), v = x.findNodeAtLocation(P, [
|
|
171
246
|
"configurations"
|
|
172
247
|
]);
|
|
173
248
|
}
|
|
174
|
-
const
|
|
175
|
-
(
|
|
176
|
-
var
|
|
177
|
-
return ((
|
|
249
|
+
const y = (p = v == null ? void 0 : v.children) == null ? void 0 : p.findIndex(
|
|
250
|
+
(i) => {
|
|
251
|
+
var r;
|
|
252
|
+
return ((r = x.findNodeAtLocation(i, ["name"])) == null ? void 0 : r.value) === l;
|
|
178
253
|
}
|
|
179
254
|
);
|
|
180
|
-
if (
|
|
181
|
-
const
|
|
182
|
-
name:
|
|
255
|
+
if (y === void 0 || y < 0) {
|
|
256
|
+
const i = {
|
|
257
|
+
name: l,
|
|
183
258
|
type: "php",
|
|
184
259
|
request: "launch",
|
|
185
260
|
port: 9003
|
|
186
261
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
)}`,
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
262
|
+
d && d.length && (i.pathMappings = d.reduce((s, g) => (s[g.vfsPath] = `\${workspaceFolder}/${$(
|
|
263
|
+
w.relative(f.workspaceDir, g.hostPath)
|
|
264
|
+
)}`, s), {})), c && c.length && (i.skipFiles = c.map(
|
|
265
|
+
(s) => s.endsWith("/") ? `${s}**` : s
|
|
266
|
+
));
|
|
267
|
+
const r = ((o = v == null ? void 0 : v.children) == null ? void 0 : o.length) || 0, e = x.modify(
|
|
268
|
+
t,
|
|
269
|
+
["configurations", r],
|
|
270
|
+
i,
|
|
194
271
|
{
|
|
195
272
|
formattingOptions: {
|
|
196
273
|
insertSpaces: !0,
|
|
@@ -200,141 +277,196 @@ function B(c, a) {
|
|
|
200
277
|
}
|
|
201
278
|
}
|
|
202
279
|
);
|
|
203
|
-
|
|
280
|
+
t = A(t, e);
|
|
204
281
|
}
|
|
205
|
-
return
|
|
282
|
+
return t;
|
|
206
283
|
}
|
|
207
|
-
async function
|
|
208
|
-
name:
|
|
209
|
-
ides:
|
|
210
|
-
host:
|
|
211
|
-
port:
|
|
212
|
-
cwd:
|
|
213
|
-
mounts:
|
|
214
|
-
|
|
284
|
+
async function z({
|
|
285
|
+
name: u,
|
|
286
|
+
ides: f,
|
|
287
|
+
host: l,
|
|
288
|
+
port: d,
|
|
289
|
+
cwd: c,
|
|
290
|
+
mounts: h,
|
|
291
|
+
pathSkippings: t,
|
|
292
|
+
ideKey: P = N
|
|
215
293
|
}) {
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
const
|
|
219
|
-
|
|
220
|
-
|
|
294
|
+
const v = h ? D(c, h) : [], y = {};
|
|
295
|
+
if (f.includes("phpstorm")) {
|
|
296
|
+
const p = ".idea/workspace.xml", o = w.join(
|
|
297
|
+
c,
|
|
298
|
+
p
|
|
221
299
|
);
|
|
222
|
-
if (!
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
|
|
300
|
+
if (!a.existsSync(o)) {
|
|
301
|
+
if (a.existsSync(w.dirname(o)))
|
|
302
|
+
a.writeFileSync(
|
|
303
|
+
o,
|
|
226
304
|
`<?xml version="1.0" encoding="UTF-8"?>
|
|
227
305
|
<project version="4">
|
|
228
306
|
</project>`
|
|
229
307
|
);
|
|
230
|
-
else if (
|
|
308
|
+
else if (f.length == 1)
|
|
231
309
|
throw new Error(
|
|
232
310
|
"PhpStorm IDE integration requested, but no '.idea' directory was found in the current working directory."
|
|
233
311
|
);
|
|
234
312
|
}
|
|
235
|
-
if (
|
|
236
|
-
const
|
|
237
|
-
name:
|
|
238
|
-
host:
|
|
239
|
-
port:
|
|
240
|
-
projectDir:
|
|
241
|
-
|
|
242
|
-
ideKey:
|
|
313
|
+
if (a.existsSync(o)) {
|
|
314
|
+
const i = a.readFileSync(o, "utf8"), r = X(i, {
|
|
315
|
+
name: u,
|
|
316
|
+
host: l,
|
|
317
|
+
port: d,
|
|
318
|
+
projectDir: c,
|
|
319
|
+
pathMappings: v,
|
|
320
|
+
ideKey: P
|
|
243
321
|
});
|
|
244
|
-
|
|
322
|
+
a.writeFileSync(o, r), y.phpstorm = p;
|
|
323
|
+
}
|
|
324
|
+
if (t && t.length) {
|
|
325
|
+
const i = ".idea/php.xml", r = w.join(
|
|
326
|
+
c,
|
|
327
|
+
i
|
|
328
|
+
);
|
|
329
|
+
if (a.existsSync(r) || a.existsSync(w.dirname(r)) && a.writeFileSync(
|
|
330
|
+
r,
|
|
331
|
+
`<?xml version="1.0" encoding="UTF-8"?>
|
|
332
|
+
<project version="4">
|
|
333
|
+
</project>`
|
|
334
|
+
), a.existsSync(r)) {
|
|
335
|
+
const e = a.readFileSync(
|
|
336
|
+
r,
|
|
337
|
+
"utf8"
|
|
338
|
+
), s = B(e, {
|
|
339
|
+
pathSkippings: t
|
|
340
|
+
});
|
|
341
|
+
a.writeFileSync(r, s), y["phpstorm-php"] = i;
|
|
342
|
+
}
|
|
245
343
|
}
|
|
246
344
|
}
|
|
247
|
-
if (
|
|
248
|
-
const
|
|
249
|
-
|
|
250
|
-
|
|
345
|
+
if (f.includes("vscode")) {
|
|
346
|
+
const p = ".vscode/launch.json", o = w.join(
|
|
347
|
+
c,
|
|
348
|
+
p
|
|
251
349
|
);
|
|
252
|
-
if (!
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
350
|
+
if (!a.existsSync(o)) {
|
|
351
|
+
if (a.existsSync(w.dirname(o)))
|
|
352
|
+
a.writeFileSync(
|
|
353
|
+
o,
|
|
256
354
|
`{
|
|
257
355
|
"configurations": []
|
|
258
356
|
}`
|
|
259
357
|
);
|
|
260
|
-
else if (
|
|
358
|
+
else if (f.length == 1)
|
|
261
359
|
throw new Error(
|
|
262
360
|
"VS Code IDE integration requested, but no '.vscode' directory was found in the current working directory."
|
|
263
361
|
);
|
|
264
362
|
}
|
|
265
|
-
if (
|
|
266
|
-
const
|
|
267
|
-
name:
|
|
268
|
-
workspaceDir:
|
|
269
|
-
|
|
363
|
+
if (a.existsSync(o)) {
|
|
364
|
+
const i = a.readFileSync(o, "utf-8"), r = O(i, {
|
|
365
|
+
name: u,
|
|
366
|
+
workspaceDir: c,
|
|
367
|
+
pathMappings: v,
|
|
368
|
+
pathSkippings: t
|
|
270
369
|
});
|
|
271
|
-
|
|
370
|
+
r !== i && (a.writeFileSync(o, r), y.vscode = p);
|
|
272
371
|
}
|
|
273
372
|
}
|
|
274
|
-
return
|
|
373
|
+
return y;
|
|
275
374
|
}
|
|
276
|
-
async function
|
|
277
|
-
var h,
|
|
278
|
-
const
|
|
279
|
-
if (
|
|
280
|
-
const
|
|
375
|
+
async function K(u, f) {
|
|
376
|
+
var h, t, P, v, y;
|
|
377
|
+
const l = w.join(f, ".idea/workspace.xml");
|
|
378
|
+
if (a.existsSync(l)) {
|
|
379
|
+
const p = a.readFileSync(l, "utf8"), o = new F(E), i = (() => {
|
|
281
380
|
try {
|
|
282
|
-
return
|
|
381
|
+
return o.parse(p, !0);
|
|
283
382
|
} catch {
|
|
284
383
|
throw new Error(
|
|
285
384
|
"PhpStorm configuration file is not valid XML."
|
|
286
385
|
);
|
|
287
386
|
}
|
|
288
|
-
})(),
|
|
289
|
-
(
|
|
290
|
-
),
|
|
291
|
-
(
|
|
292
|
-
var
|
|
293
|
-
return !!(
|
|
387
|
+
})(), r = i.find(
|
|
388
|
+
(m) => !!(m != null && m.project)
|
|
389
|
+
), e = (h = r == null ? void 0 : r.project) == null ? void 0 : h.find(
|
|
390
|
+
(m) => {
|
|
391
|
+
var S;
|
|
392
|
+
return !!(m != null && m.component) && ((S = m == null ? void 0 : m[":@"]) == null ? void 0 : S.name) === "PhpServers";
|
|
294
393
|
}
|
|
295
|
-
),
|
|
296
|
-
(
|
|
297
|
-
),
|
|
298
|
-
(
|
|
299
|
-
var
|
|
300
|
-
return !!(
|
|
394
|
+
), s = (t = e == null ? void 0 : e.component) == null ? void 0 : t.find(
|
|
395
|
+
(m) => !!(m != null && m.servers)
|
|
396
|
+
), g = (P = s == null ? void 0 : s.servers) == null ? void 0 : P.findIndex(
|
|
397
|
+
(m) => {
|
|
398
|
+
var S;
|
|
399
|
+
return !!(m != null && m.server) && ((S = m == null ? void 0 : m[":@"]) == null ? void 0 : S.name) === u;
|
|
301
400
|
}
|
|
302
401
|
);
|
|
303
|
-
if (
|
|
304
|
-
|
|
305
|
-
const
|
|
402
|
+
if (g !== void 0 && g >= 0) {
|
|
403
|
+
s.servers.splice(g, 1);
|
|
404
|
+
const S = new b(I).build(i);
|
|
306
405
|
try {
|
|
307
|
-
|
|
406
|
+
o.parse(S, !0);
|
|
308
407
|
} catch {
|
|
309
408
|
throw new Error(
|
|
310
409
|
"The resulting PhpStorm configuration file is not valid XML."
|
|
311
410
|
);
|
|
312
411
|
}
|
|
313
|
-
|
|
412
|
+
S === `<?xml version="1.0" encoding="UTF-8"?>
|
|
314
413
|
<project version="4">
|
|
315
414
|
<component name="PhpServers">
|
|
316
415
|
<servers></servers>
|
|
317
416
|
</component>
|
|
318
|
-
</project>` ?
|
|
417
|
+
</project>` ? a.unlinkSync(l) : a.writeFileSync(l, S);
|
|
319
418
|
}
|
|
320
419
|
}
|
|
321
|
-
const
|
|
322
|
-
if (
|
|
323
|
-
const
|
|
324
|
-
|
|
420
|
+
const d = w.join(f, ".idea/php.xml");
|
|
421
|
+
if (a.existsSync(d)) {
|
|
422
|
+
const p = a.readFileSync(d, "utf8"), o = new F(E), i = (() => {
|
|
423
|
+
try {
|
|
424
|
+
return o.parse(p, !0);
|
|
425
|
+
} catch {
|
|
426
|
+
throw new Error(
|
|
427
|
+
"PhpStorm PHP configuration file is not valid XML."
|
|
428
|
+
);
|
|
429
|
+
}
|
|
430
|
+
})(), r = i.find(
|
|
431
|
+
(s) => !!(s != null && s.project)
|
|
432
|
+
), e = (v = r == null ? void 0 : r.project) == null ? void 0 : v.findIndex(
|
|
433
|
+
(s) => {
|
|
434
|
+
var g;
|
|
435
|
+
return !!(s != null && s.component) && ((g = s == null ? void 0 : s[":@"]) == null ? void 0 : g.name) === "PhpStepFilterConfiguration";
|
|
436
|
+
}
|
|
437
|
+
);
|
|
438
|
+
if (e !== void 0 && e >= 0) {
|
|
439
|
+
r.project.splice(e, 1);
|
|
440
|
+
const g = new b(I).build(i);
|
|
441
|
+
try {
|
|
442
|
+
o.parse(g, !0);
|
|
443
|
+
} catch {
|
|
444
|
+
throw new Error(
|
|
445
|
+
"The resulting PhpStorm PHP configuration file is not valid XML."
|
|
446
|
+
);
|
|
447
|
+
}
|
|
448
|
+
g === `<?xml version="1.0" encoding="UTF-8"?>
|
|
449
|
+
<project version="4">
|
|
450
|
+
</project>` ? a.unlinkSync(d) : a.writeFileSync(d, g);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
const c = w.join(f, ".vscode/launch.json");
|
|
454
|
+
if (a.existsSync(c)) {
|
|
455
|
+
const p = [], o = a.readFileSync(c, "utf-8"), i = x.parseTree(o, p, k);
|
|
456
|
+
if (i === void 0 || p.length)
|
|
325
457
|
throw new Error("VS Code configuration file is not valid JSON.");
|
|
326
|
-
const
|
|
458
|
+
const r = x.findNodeAtLocation(i, [
|
|
327
459
|
"configurations"
|
|
328
|
-
]),
|
|
329
|
-
(
|
|
330
|
-
var
|
|
331
|
-
return ((
|
|
460
|
+
]), e = (y = r == null ? void 0 : r.children) == null ? void 0 : y.findIndex(
|
|
461
|
+
(s) => {
|
|
462
|
+
var g;
|
|
463
|
+
return ((g = x.findNodeAtLocation(s, ["name"])) == null ? void 0 : g.value) === u;
|
|
332
464
|
}
|
|
333
465
|
);
|
|
334
|
-
if (
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
["configurations",
|
|
466
|
+
if (e !== void 0 && e >= 0) {
|
|
467
|
+
const s = x.modify(
|
|
468
|
+
o,
|
|
469
|
+
["configurations", e],
|
|
338
470
|
void 0,
|
|
339
471
|
{
|
|
340
472
|
formattingOptions: {
|
|
@@ -344,58 +476,60 @@ async function W(c, a) {
|
|
|
344
476
|
`
|
|
345
477
|
}
|
|
346
478
|
}
|
|
347
|
-
),
|
|
348
|
-
|
|
479
|
+
), g = A(o, s);
|
|
480
|
+
g === `{
|
|
349
481
|
"configurations": []
|
|
350
|
-
}` ?
|
|
482
|
+
}` ? a.unlinkSync(c) : a.writeFileSync(c, g);
|
|
351
483
|
}
|
|
352
484
|
}
|
|
353
485
|
}
|
|
354
|
-
function
|
|
355
|
-
cwd:
|
|
356
|
-
mounts:
|
|
357
|
-
pathSkippings:
|
|
486
|
+
function G({
|
|
487
|
+
cwd: u,
|
|
488
|
+
mounts: f,
|
|
489
|
+
pathSkippings: l
|
|
358
490
|
}) {
|
|
359
|
-
return { pathMappings:
|
|
491
|
+
return { pathMappings: u && f ? D(u, f) : void 0, pathSkippings: l };
|
|
360
492
|
}
|
|
361
|
-
function
|
|
362
|
-
const
|
|
363
|
-
if (
|
|
364
|
-
const
|
|
365
|
-
message:
|
|
493
|
+
function A(u, f) {
|
|
494
|
+
const l = [], d = x.applyEdits(u, f);
|
|
495
|
+
if (l.length = 0, x.parseTree(d, l, k), l.length) {
|
|
496
|
+
const c = l.map((t) => ({
|
|
497
|
+
message: x.printParseErrorCode(t.error),
|
|
366
498
|
offset: t.offset,
|
|
367
499
|
length: t.length,
|
|
368
|
-
fragment:
|
|
500
|
+
fragment: d.slice(
|
|
369
501
|
Math.max(0, t.offset - 20),
|
|
370
|
-
Math.min(
|
|
502
|
+
Math.min(d.length, t.offset + t.length + 10)
|
|
371
503
|
)
|
|
372
504
|
})).map(
|
|
373
505
|
(t) => `${t.message} at ${t.offset}:${t.length} (${t.fragment})`
|
|
374
|
-
),
|
|
506
|
+
), h = f.map(
|
|
375
507
|
(t) => `At ${t.offset}:${t.length} - (${t.content})`
|
|
376
508
|
);
|
|
377
509
|
throw new Error(
|
|
378
510
|
`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.
|
|
379
511
|
|
|
380
|
-
Applied edits: ${
|
|
512
|
+
Applied edits: ${h.join(
|
|
381
513
|
`
|
|
382
514
|
`
|
|
383
515
|
)}
|
|
384
516
|
|
|
385
|
-
The errors are: ${
|
|
517
|
+
The errors are: ${c.join(`
|
|
386
518
|
`)}`
|
|
387
519
|
);
|
|
388
520
|
}
|
|
389
|
-
return
|
|
521
|
+
return d;
|
|
390
522
|
}
|
|
391
523
|
export {
|
|
392
|
-
|
|
393
|
-
U as
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
B as
|
|
524
|
+
N as DEFAULT_IDE_KEY,
|
|
525
|
+
U as DEFAULT_PATH_SKIPPINGS,
|
|
526
|
+
z as addXdebugIDEConfig,
|
|
527
|
+
K as clearXdebugIDEConfig,
|
|
528
|
+
W as createTempDirSymlink,
|
|
529
|
+
G as makeXdebugConfig,
|
|
530
|
+
q as removeTempDirSymlink,
|
|
531
|
+
B as updatePhpStormPHPConfig,
|
|
532
|
+
X as updatePhpStormWorkspaceConfig,
|
|
533
|
+
O as updateVSCodeConfig
|
|
400
534
|
};
|
|
401
535
|
//# sourceMappingURL=index.js.map
|