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