walkwright 0.0.1
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/LICENSE +21 -0
- package/README.md +276 -0
- package/bin/walkwright.js +3 -0
- package/build/aria.d.ts +92 -0
- package/build/aria.js +215 -0
- package/build/aria.js.map +1 -0
- package/build/browser.d.ts +3 -0
- package/build/browser.js +18 -0
- package/build/browser.js.map +1 -0
- package/build/chunk-5CHKYNP7.js +507 -0
- package/build/chunk-5CHKYNP7.js.map +1 -0
- package/build/chunk-6YRKPGUO.js +1197 -0
- package/build/chunk-6YRKPGUO.js.map +1 -0
- package/build/chunk-A452S7R3.js +35 -0
- package/build/chunk-A452S7R3.js.map +1 -0
- package/build/chunk-BODO6HIH.js +60 -0
- package/build/chunk-BODO6HIH.js.map +1 -0
- package/build/chunk-FJI2CMCE.js +439 -0
- package/build/chunk-FJI2CMCE.js.map +1 -0
- package/build/chunk-JYHZVRB2.js +80 -0
- package/build/chunk-JYHZVRB2.js.map +1 -0
- package/build/chunk-KQN5IYN6.js +97 -0
- package/build/chunk-KQN5IYN6.js.map +1 -0
- package/build/chunk-KTXNERHT.js +72 -0
- package/build/chunk-KTXNERHT.js.map +1 -0
- package/build/chunk-MFTC7XL2.js +141 -0
- package/build/chunk-MFTC7XL2.js.map +1 -0
- package/build/chunk-N4SSLHMP.js +108 -0
- package/build/chunk-N4SSLHMP.js.map +1 -0
- package/build/chunk-RNNW7OW2.js +270 -0
- package/build/chunk-RNNW7OW2.js.map +1 -0
- package/build/chunk-UAWBPTDW.js +51 -0
- package/build/chunk-UAWBPTDW.js.map +1 -0
- package/build/chunk-Z7CW5CAY.js +64 -0
- package/build/chunk-Z7CW5CAY.js.map +1 -0
- package/build/cli.d.ts +1 -0
- package/build/cli.js +253 -0
- package/build/cli.js.map +1 -0
- package/build/config.d.ts +13 -0
- package/build/config.js +15 -0
- package/build/config.js.map +1 -0
- package/build/descriptor.d.ts +96 -0
- package/build/descriptor.js +27 -0
- package/build/descriptor.js.map +1 -0
- package/build/device-auth.d.ts +6 -0
- package/build/device-auth.js +11 -0
- package/build/device-auth.js.map +1 -0
- package/build/locator.d.ts +140 -0
- package/build/locator.js +92 -0
- package/build/locator.js.map +1 -0
- package/build/paths.d.ts +11 -0
- package/build/paths.js +22 -0
- package/build/paths.js.map +1 -0
- package/build/pom-kcSMxwX2.d.ts +349 -0
- package/build/pom.d.ts +6 -0
- package/build/pom.js +37 -0
- package/build/pom.js.map +1 -0
- package/build/project.d.ts +13 -0
- package/build/project.js +19 -0
- package/build/project.js.map +1 -0
- package/build/provisioner.d.ts +34 -0
- package/build/provisioner.js +14 -0
- package/build/provisioner.js.map +1 -0
- package/build/recorder.d.ts +6 -0
- package/build/recorder.js +15 -0
- package/build/recorder.js.map +1 -0
- package/build/reporter.d.ts +16 -0
- package/build/reporter.js +426 -0
- package/build/reporter.js.map +1 -0
- package/build/schema.d.ts +49 -0
- package/build/schema.js +16 -0
- package/build/schema.js.map +1 -0
- package/build/storage-state.d.ts +22 -0
- package/build/storage-state.js +42 -0
- package/build/storage-state.js.map +1 -0
- package/build/store.d.ts +17 -0
- package/build/store.js +9 -0
- package/build/store.js.map +1 -0
- package/build/ui.d.ts +49 -0
- package/build/ui.js +56 -0
- package/build/ui.js.map +1 -0
- package/build/upload.d.ts +10 -0
- package/build/upload.js +8 -0
- package/build/upload.js.map +1 -0
- package/build/wait.d.ts +14 -0
- package/build/wait.js +50 -0
- package/build/wait.js.map +1 -0
- package/package.json +52 -0
- package/src/aria.ts +326 -0
- package/src/browser.ts +15 -0
- package/src/cli.ts +295 -0
- package/src/config.ts +16 -0
- package/src/descriptor.ts +179 -0
- package/src/device-auth.ts +188 -0
- package/src/locator.ts +683 -0
- package/src/paths.ts +70 -0
- package/src/pom.ts +2363 -0
- package/src/project.ts +77 -0
- package/src/provisioner.ts +183 -0
- package/src/recorder.ts +877 -0
- package/src/reporter.ts +561 -0
- package/src/schema.ts +37 -0
- package/src/storage-state.ts +71 -0
- package/src/store.ts +96 -0
- package/src/ui.ts +333 -0
- package/src/upload.ts +116 -0
- package/src/wait.ts +63 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// src/ui.ts
|
|
2
|
+
var dark = {
|
|
3
|
+
accent: { hex: "#b8943a", index: 178 },
|
|
4
|
+
text: { hex: "#bcac8f", index: 180 },
|
|
5
|
+
dim: { hex: "#8d8972", index: 102 },
|
|
6
|
+
faint: { hex: "#6b6858", index: 59 },
|
|
7
|
+
ok: { hex: "#8fa85e", index: 107 },
|
|
8
|
+
warn: { hex: "#e08542", index: 173 },
|
|
9
|
+
fail: { hex: "#d66848", index: 167 },
|
|
10
|
+
code: { hex: "#cc7f66", index: 173 },
|
|
11
|
+
border: { hex: "#333333", index: 236 }
|
|
12
|
+
};
|
|
13
|
+
var light = {
|
|
14
|
+
accent: { hex: "#9a7820", index: 136 },
|
|
15
|
+
text: { hex: "#3a3828", index: 237 },
|
|
16
|
+
dim: { hex: "#625e55", index: 240 },
|
|
17
|
+
faint: { hex: "#948e80", index: 246 },
|
|
18
|
+
ok: { hex: "#5f8a3a", index: 64 },
|
|
19
|
+
warn: { hex: "#c0741e", index: 172 },
|
|
20
|
+
fail: { hex: "#b8442c", index: 130 },
|
|
21
|
+
code: { hex: "#a85030", index: 130 },
|
|
22
|
+
border: { hex: "#c9bfa6", index: 250 }
|
|
23
|
+
};
|
|
24
|
+
var glyph = {
|
|
25
|
+
ok: "\u2713",
|
|
26
|
+
fail: "\u2717",
|
|
27
|
+
carried: "\u21BA",
|
|
28
|
+
unseen: "\u25CF",
|
|
29
|
+
open: "\u25BE",
|
|
30
|
+
closed: "\u25B8",
|
|
31
|
+
branch: "\u251C",
|
|
32
|
+
last: "\u2514",
|
|
33
|
+
cursor: "\u258C",
|
|
34
|
+
prompt: ">",
|
|
35
|
+
filled: "\u25B0",
|
|
36
|
+
empty: "\u25B1",
|
|
37
|
+
dot: "\xB7",
|
|
38
|
+
bar: "\u2502"
|
|
39
|
+
};
|
|
40
|
+
process.stdout.on("error", (error) => {
|
|
41
|
+
if (error.code !== "EPIPE") {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
var depth = detectDepth();
|
|
46
|
+
var palette = detectLight() ? light : dark;
|
|
47
|
+
var esc = "\x1B";
|
|
48
|
+
var escapePattern = new RegExp(`${esc}\\[[\\d;]*m`, "g");
|
|
49
|
+
var escapeSplit = new RegExp(`(${esc}\\[[\\d;]*m)`);
|
|
50
|
+
var escapeOnly = new RegExp(`^${esc}\\[[\\d;]*m$`);
|
|
51
|
+
function detectDepth() {
|
|
52
|
+
const env = process.env;
|
|
53
|
+
if ((env["NO_COLOR"] ?? "") !== "" || env["FORCE_COLOR"] === "0") {
|
|
54
|
+
return "none";
|
|
55
|
+
}
|
|
56
|
+
const forced = (env["FORCE_COLOR"] ?? "") !== "";
|
|
57
|
+
if (!forced && !process.stdout.isTTY) {
|
|
58
|
+
return "none";
|
|
59
|
+
}
|
|
60
|
+
const colorterm = env["COLORTERM"] ?? "";
|
|
61
|
+
if (colorterm === "truecolor" || colorterm === "24bit") {
|
|
62
|
+
return "truecolor";
|
|
63
|
+
}
|
|
64
|
+
const term = env["TERM"] ?? "";
|
|
65
|
+
if (term === "dumb" || term === "" && !forced) {
|
|
66
|
+
return "none";
|
|
67
|
+
}
|
|
68
|
+
return "256";
|
|
69
|
+
}
|
|
70
|
+
function detectLight() {
|
|
71
|
+
const theme = process.env["WALKWRIGHT_THEME"];
|
|
72
|
+
if (theme === "light" || theme === "dark") {
|
|
73
|
+
return theme === "light";
|
|
74
|
+
}
|
|
75
|
+
const fgbg = process.env["COLORFGBG"];
|
|
76
|
+
if (fgbg === void 0) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
const background = Number(fgbg.split(";").at(-1));
|
|
80
|
+
return background === 7 || background >= 9 && background <= 15;
|
|
81
|
+
}
|
|
82
|
+
function open(swatch) {
|
|
83
|
+
if (depth === "truecolor") {
|
|
84
|
+
const value = Number.parseInt(swatch.hex.slice(1), 16);
|
|
85
|
+
return `\x1B[38;2;${String(value >> 16)};${String(value >> 8 & 255)};${String(value & 255)}m`;
|
|
86
|
+
}
|
|
87
|
+
return `\x1B[38;5;${String(swatch.index)}m`;
|
|
88
|
+
}
|
|
89
|
+
function paint(tone, value) {
|
|
90
|
+
if (depth === "none" || value === "") {
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
return `${open(palette[tone])}${value}\x1B[39m`;
|
|
94
|
+
}
|
|
95
|
+
function bold(value) {
|
|
96
|
+
return depth === "none" ? value : `\x1B[1m${value}\x1B[22m`;
|
|
97
|
+
}
|
|
98
|
+
function plain(value) {
|
|
99
|
+
return value.replace(escapePattern, "");
|
|
100
|
+
}
|
|
101
|
+
function width(value) {
|
|
102
|
+
return plain(value).length;
|
|
103
|
+
}
|
|
104
|
+
function columns() {
|
|
105
|
+
return process.stdout.isTTY ? process.stdout.columns : 100;
|
|
106
|
+
}
|
|
107
|
+
function pad(value, to) {
|
|
108
|
+
return value + " ".repeat(Math.max(0, to - width(value)));
|
|
109
|
+
}
|
|
110
|
+
function clip(value, to) {
|
|
111
|
+
if (width(value) <= to) {
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
let seen = 0;
|
|
115
|
+
let out = "";
|
|
116
|
+
for (const part of value.split(escapeSplit)) {
|
|
117
|
+
if (escapeOnly.test(part)) {
|
|
118
|
+
out += part;
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
for (const char of part) {
|
|
122
|
+
if (seen === to - 1) {
|
|
123
|
+
return `${out}\u2026${depth === "none" ? "" : "\x1B[0m"}`;
|
|
124
|
+
}
|
|
125
|
+
out += char;
|
|
126
|
+
seen += 1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return out;
|
|
130
|
+
}
|
|
131
|
+
function line(...parts) {
|
|
132
|
+
process.stdout.write(`${parts.join("")}
|
|
133
|
+
`);
|
|
134
|
+
}
|
|
135
|
+
function blank() {
|
|
136
|
+
process.stdout.write("\n");
|
|
137
|
+
}
|
|
138
|
+
function status(...segments) {
|
|
139
|
+
return ` ${segments.filter((segment) => segment !== "").join(paint("faint", ` ${glyph.bar} `))}`;
|
|
140
|
+
}
|
|
141
|
+
function badge(count2, tone = "dim") {
|
|
142
|
+
return paint(tone, `[${String(count2)}]`);
|
|
143
|
+
}
|
|
144
|
+
function key(name) {
|
|
145
|
+
return paint("accent", `[${name}]`);
|
|
146
|
+
}
|
|
147
|
+
function action(verb) {
|
|
148
|
+
return paint("accent", `[${verb}]`);
|
|
149
|
+
}
|
|
150
|
+
function prompt(text) {
|
|
151
|
+
return `${paint("accent", glyph.prompt)} ${text}`;
|
|
152
|
+
}
|
|
153
|
+
function dashed(inner) {
|
|
154
|
+
return paint("border", "\u254C".repeat(inner));
|
|
155
|
+
}
|
|
156
|
+
function box(rows, options) {
|
|
157
|
+
const outer = Math.min(columns() - 1, 100);
|
|
158
|
+
const min = Math.max(options.min ?? 44, width(options.legend) + 10);
|
|
159
|
+
const widest = rows.reduce((max, row) => Math.max(max, width(row)), 0);
|
|
160
|
+
const inner = Math.max(min - 4, Math.min(widest, outer - 4));
|
|
161
|
+
const edge = (value) => paint("border", value);
|
|
162
|
+
const legend = paint(
|
|
163
|
+
options.primary === true ? "accent" : "dim",
|
|
164
|
+
options.legend.toUpperCase()
|
|
165
|
+
);
|
|
166
|
+
const heading = options.title === void 0 ? `${edge("\u2500 ")}${legend}${edge(" ")}` : `${edge("\u2500 ")}${legend}${edge(" \u2500 ")}${paint("text", options.title)}${edge(" ")}`;
|
|
167
|
+
const top = `${edge("\u250C")}${clip(heading, inner + 2)}${edge("\u2500".repeat(Math.max(0, inner + 2 - width(heading))))}${edge("\u2510")}`;
|
|
168
|
+
const bottom = `${edge("\u2514")}${edge("\u2500".repeat(inner + 2))}${edge("\u2518")}`;
|
|
169
|
+
const body = rows.map(
|
|
170
|
+
(row) => `${edge("\u2502")} ${pad(clip(row === "" ? dashed(inner) : row, inner), inner)} ${edge("\u2502")}`
|
|
171
|
+
);
|
|
172
|
+
return [top, ...body, bottom];
|
|
173
|
+
}
|
|
174
|
+
function progress(done, total, cells = 5) {
|
|
175
|
+
const filled = total === 0 ? cells : Math.round(done / total * cells);
|
|
176
|
+
return paint(
|
|
177
|
+
"accent",
|
|
178
|
+
glyph.filled.repeat(filled) + glyph.empty.repeat(cells - filled)
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
function duration(ms) {
|
|
182
|
+
if (ms < 1e3) {
|
|
183
|
+
return `${String(Math.round(ms))}ms`;
|
|
184
|
+
}
|
|
185
|
+
const seconds = Math.round(ms / 1e3);
|
|
186
|
+
if (seconds < 60) {
|
|
187
|
+
return `${String(seconds)}s`;
|
|
188
|
+
}
|
|
189
|
+
return `${String(Math.floor(seconds / 60))}m${String(seconds % 60).padStart(2, "0")}s`;
|
|
190
|
+
}
|
|
191
|
+
function count(value, noun) {
|
|
192
|
+
return `${String(value)} ${noun}${value === 1 ? "" : "s"}`;
|
|
193
|
+
}
|
|
194
|
+
function failure(message, hint) {
|
|
195
|
+
process.stderr.write(`${paint("fail", `${glyph.fail} ${message}`)}
|
|
196
|
+
`);
|
|
197
|
+
if (hint !== void 0) {
|
|
198
|
+
process.stderr.write(`${paint("dim", ` ${hint}`)}
|
|
199
|
+
`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function transient(text) {
|
|
203
|
+
if (!process.stdout.isTTY) {
|
|
204
|
+
return () => void 0;
|
|
205
|
+
}
|
|
206
|
+
process.stdout.write(`\r\x1B[2K${clip(text, columns() - 1)}`);
|
|
207
|
+
return () => {
|
|
208
|
+
process.stdout.write("\r\x1B[2K");
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function pulse(text, intervalMs = 500) {
|
|
212
|
+
if (!process.stdout.isTTY) {
|
|
213
|
+
line(text);
|
|
214
|
+
return () => void 0;
|
|
215
|
+
}
|
|
216
|
+
let on = true;
|
|
217
|
+
const draw = () => {
|
|
218
|
+
process.stdout.write(
|
|
219
|
+
`\r\x1B[2K${clip(`${text} ${on ? paint("accent", glyph.cursor) : " "}`, columns() - 1)}`
|
|
220
|
+
);
|
|
221
|
+
on = !on;
|
|
222
|
+
};
|
|
223
|
+
draw();
|
|
224
|
+
const timer = setInterval(draw, intervalMs);
|
|
225
|
+
return () => {
|
|
226
|
+
clearInterval(timer);
|
|
227
|
+
process.stdout.write("\r\x1B[2K");
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
function wordmark() {
|
|
231
|
+
return bold(`${paint("accent", "MAP")}${paint("text", "WRIGHT")}`);
|
|
232
|
+
}
|
|
233
|
+
function logo() {
|
|
234
|
+
const mark = (value) => paint("accent", value);
|
|
235
|
+
return [
|
|
236
|
+
mark(" \u250C\u2500\u25A0\u2500\u2510"),
|
|
237
|
+
`${mark(" \u25A0 \u25A0")} ${wordmark()}`,
|
|
238
|
+
mark(" \u250C\u2534\u2510"),
|
|
239
|
+
mark(" \u25A0 \u25A0")
|
|
240
|
+
];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export {
|
|
244
|
+
glyph,
|
|
245
|
+
paint,
|
|
246
|
+
bold,
|
|
247
|
+
plain,
|
|
248
|
+
width,
|
|
249
|
+
columns,
|
|
250
|
+
pad,
|
|
251
|
+
clip,
|
|
252
|
+
line,
|
|
253
|
+
blank,
|
|
254
|
+
status,
|
|
255
|
+
badge,
|
|
256
|
+
key,
|
|
257
|
+
action,
|
|
258
|
+
prompt,
|
|
259
|
+
dashed,
|
|
260
|
+
box,
|
|
261
|
+
progress,
|
|
262
|
+
duration,
|
|
263
|
+
count,
|
|
264
|
+
failure,
|
|
265
|
+
transient,
|
|
266
|
+
pulse,
|
|
267
|
+
wordmark,
|
|
268
|
+
logo
|
|
269
|
+
};
|
|
270
|
+
//# sourceMappingURL=chunk-RNNW7OW2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui.ts"],"sourcesContent":["export type Tone =\n | \"accent\"\n | \"text\"\n | \"dim\"\n | \"faint\"\n | \"ok\"\n | \"warn\"\n | \"fail\"\n | \"code\"\n | \"border\";\n\ntype Depth = \"truecolor\" | \"256\" | \"none\";\n\ninterface Swatch {\n hex: string;\n index: number;\n}\n\nconst dark: Record<Tone, Swatch> = {\n accent: { hex: \"#b8943a\", index: 178 },\n text: { hex: \"#bcac8f\", index: 180 },\n dim: { hex: \"#8d8972\", index: 102 },\n faint: { hex: \"#6b6858\", index: 59 },\n ok: { hex: \"#8fa85e\", index: 107 },\n warn: { hex: \"#e08542\", index: 173 },\n fail: { hex: \"#d66848\", index: 167 },\n code: { hex: \"#cc7f66\", index: 173 },\n border: { hex: \"#333333\", index: 236 },\n};\n\nconst light: Record<Tone, Swatch> = {\n accent: { hex: \"#9a7820\", index: 136 },\n text: { hex: \"#3a3828\", index: 237 },\n dim: { hex: \"#625e55\", index: 240 },\n faint: { hex: \"#948e80\", index: 246 },\n ok: { hex: \"#5f8a3a\", index: 64 },\n warn: { hex: \"#c0741e\", index: 172 },\n fail: { hex: \"#b8442c\", index: 130 },\n code: { hex: \"#a85030\", index: 130 },\n border: { hex: \"#c9bfa6\", index: 250 },\n};\n\nexport const glyph = {\n ok: \"✓\",\n fail: \"✗\",\n carried: \"↺\",\n unseen: \"●\",\n open: \"▾\",\n closed: \"▸\",\n branch: \"├\",\n last: \"└\",\n cursor: \"▌\",\n prompt: \">\",\n filled: \"▰\",\n empty: \"▱\",\n dot: \"·\",\n bar: \"│\",\n} as const;\n\nprocess.stdout.on(\"error\", (error: NodeJS.ErrnoException) => {\n if (error.code !== \"EPIPE\") {\n throw error;\n }\n});\n\nconst depth = detectDepth();\nconst palette = detectLight() ? light : dark;\nconst esc = \"\\u001b\";\nconst escapePattern = new RegExp(`${esc}\\\\[[\\\\d;]*m`, \"g\");\nconst escapeSplit = new RegExp(`(${esc}\\\\[[\\\\d;]*m)`);\nconst escapeOnly = new RegExp(`^${esc}\\\\[[\\\\d;]*m$`);\n\nfunction detectDepth(): Depth {\n const env = process.env;\n\n if ((env[\"NO_COLOR\"] ?? \"\") !== \"\" || env[\"FORCE_COLOR\"] === \"0\") {\n return \"none\";\n }\n\n const forced = (env[\"FORCE_COLOR\"] ?? \"\") !== \"\";\n\n if (!forced && !process.stdout.isTTY) {\n return \"none\";\n }\n\n const colorterm = env[\"COLORTERM\"] ?? \"\";\n\n if (colorterm === \"truecolor\" || colorterm === \"24bit\") {\n return \"truecolor\";\n }\n\n const term = env[\"TERM\"] ?? \"\";\n\n if (term === \"dumb\" || (term === \"\" && !forced)) {\n return \"none\";\n }\n\n return \"256\";\n}\n\nfunction detectLight(): boolean {\n const theme = process.env[\"WALKWRIGHT_THEME\"];\n\n if (theme === \"light\" || theme === \"dark\") {\n return theme === \"light\";\n }\n\n const fgbg = process.env[\"COLORFGBG\"];\n\n if (fgbg === undefined) {\n return false;\n }\n\n const background = Number(fgbg.split(\";\").at(-1));\n\n return background === 7 || (background >= 9 && background <= 15);\n}\n\nfunction open(swatch: Swatch): string {\n if (depth === \"truecolor\") {\n const value = Number.parseInt(swatch.hex.slice(1), 16);\n\n return `\\u001b[38;2;${String(value >> 16)};${String((value >> 8) & 255)};${String(value & 255)}m`;\n }\n\n return `\\u001b[38;5;${String(swatch.index)}m`;\n}\n\nexport function paint(tone: Tone, value: string): string {\n if (depth === \"none\" || value === \"\") {\n return value;\n }\n\n return `${open(palette[tone])}${value}\\u001b[39m`;\n}\n\nexport function bold(value: string): string {\n return depth === \"none\" ? value : `\\u001b[1m${value}\\u001b[22m`;\n}\n\nexport function plain(value: string): string {\n return value.replace(escapePattern, \"\");\n}\n\nexport function width(value: string): number {\n return plain(value).length;\n}\n\nexport function columns(): number {\n return process.stdout.isTTY ? process.stdout.columns : 100;\n}\n\nexport function pad(value: string, to: number): string {\n return value + \" \".repeat(Math.max(0, to - width(value)));\n}\n\nexport function clip(value: string, to: number): string {\n if (width(value) <= to) {\n return value;\n }\n\n let seen = 0;\n let out = \"\";\n\n for (const part of value.split(escapeSplit)) {\n if (escapeOnly.test(part)) {\n out += part;\n continue;\n }\n\n for (const char of part) {\n if (seen === to - 1) {\n return `${out}…${depth === \"none\" ? \"\" : \"\\u001b[0m\"}`;\n }\n\n out += char;\n seen += 1;\n }\n }\n\n return out;\n}\n\nexport function line(...parts: string[]): void {\n process.stdout.write(`${parts.join(\"\")}\\n`);\n}\n\nexport function blank(): void {\n process.stdout.write(\"\\n\");\n}\n\nexport function status(...segments: string[]): string {\n return ` ${segments.filter((segment) => segment !== \"\").join(paint(\"faint\", ` ${glyph.bar} `))}`;\n}\n\nexport function badge(count: number, tone: Tone = \"dim\"): string {\n return paint(tone, `[${String(count)}]`);\n}\n\nexport function key(name: string): string {\n return paint(\"accent\", `[${name}]`);\n}\n\nexport function action(verb: string): string {\n return paint(\"accent\", `[${verb}]`);\n}\n\nexport function prompt(text: string): string {\n return `${paint(\"accent\", glyph.prompt)} ${text}`;\n}\n\nexport function dashed(inner: number): string {\n return paint(\"border\", \"╌\".repeat(inner));\n}\n\nexport interface BoxOptions {\n legend: string;\n title?: string;\n primary?: boolean;\n min?: number;\n}\n\nexport function box(rows: string[], options: BoxOptions): string[] {\n const outer = Math.min(columns() - 1, 100);\n const min = Math.max(options.min ?? 44, width(options.legend) + 10);\n const widest = rows.reduce((max, row) => Math.max(max, width(row)), 0);\n const inner = Math.max(min - 4, Math.min(widest, outer - 4));\n\n const edge = (value: string): string => paint(\"border\", value);\n\n const legend = paint(\n options.primary === true ? \"accent\" : \"dim\",\n options.legend.toUpperCase(),\n );\n const heading =\n options.title === undefined\n ? `${edge(\"─ \")}${legend}${edge(\" \")}`\n : `${edge(\"─ \")}${legend}${edge(\" ─ \")}${paint(\"text\", options.title)}${edge(\" \")}`;\n const top = `${edge(\"┌\")}${clip(heading, inner + 2)}${edge(\"─\".repeat(Math.max(0, inner + 2 - width(heading))))}${edge(\"┐\")}`;\n const bottom = `${edge(\"└\")}${edge(\"─\".repeat(inner + 2))}${edge(\"┘\")}`;\n\n const body = rows.map(\n (row) =>\n `${edge(\"│\")} ${pad(clip(row === \"\" ? dashed(inner) : row, inner), inner)} ${edge(\"│\")}`,\n );\n\n return [top, ...body, bottom];\n}\n\nexport function progress(done: number, total: number, cells = 5): string {\n const filled = total === 0 ? cells : Math.round((done / total) * cells);\n\n return paint(\n \"accent\",\n glyph.filled.repeat(filled) + glyph.empty.repeat(cells - filled),\n );\n}\n\nexport function duration(ms: number): string {\n if (ms < 1000) {\n return `${String(Math.round(ms))}ms`;\n }\n\n const seconds = Math.round(ms / 1000);\n\n if (seconds < 60) {\n return `${String(seconds)}s`;\n }\n\n return `${String(Math.floor(seconds / 60))}m${String(seconds % 60).padStart(2, \"0\")}s`;\n}\n\nexport function count(value: number, noun: string): string {\n return `${String(value)} ${noun}${value === 1 ? \"\" : \"s\"}`;\n}\n\nexport function failure(message: string, hint?: string): void {\n process.stderr.write(`${paint(\"fail\", `${glyph.fail} ${message}`)}\\n`);\n\n if (hint !== undefined) {\n process.stderr.write(`${paint(\"dim\", ` ${hint}`)}\\n`);\n }\n}\n\nexport function transient(text: string): () => void {\n if (!process.stdout.isTTY) {\n return () => undefined;\n }\n\n process.stdout.write(`\\r\\u001b[2K${clip(text, columns() - 1)}`);\n\n return () => {\n process.stdout.write(\"\\r\\u001b[2K\");\n };\n}\n\nexport function pulse(text: string, intervalMs = 500): () => void {\n if (!process.stdout.isTTY) {\n line(text);\n return () => undefined;\n }\n\n let on = true;\n const draw = (): void => {\n process.stdout.write(\n `\\r\\u001b[2K${clip(`${text} ${on ? paint(\"accent\", glyph.cursor) : \" \"}`, columns() - 1)}`,\n );\n on = !on;\n };\n\n draw();\n const timer = setInterval(draw, intervalMs);\n\n return () => {\n clearInterval(timer);\n process.stdout.write(\"\\r\\u001b[2K\");\n };\n}\n\nexport function wordmark(): string {\n return bold(`${paint(\"accent\", \"MAP\")}${paint(\"text\", \"WRIGHT\")}`);\n}\n\nexport function logo(): string[] {\n const mark = (value: string): string => paint(\"accent\", value);\n\n return [\n mark(\" ┌─■─┐\"),\n `${mark(\" ■ ■\")} ${wordmark()}`,\n mark(\" ┌┴┐\"),\n mark(\" ■ ■\"),\n ];\n}\n"],"mappings":";AAkBA,IAAM,OAA6B;AAAA,EACjC,QAAQ,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACrC,MAAM,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACnC,KAAK,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EAClC,OAAO,EAAE,KAAK,WAAW,OAAO,GAAG;AAAA,EACnC,IAAI,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACjC,MAAM,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACnC,MAAM,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACnC,MAAM,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACnC,QAAQ,EAAE,KAAK,WAAW,OAAO,IAAI;AACvC;AAEA,IAAM,QAA8B;AAAA,EAClC,QAAQ,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACrC,MAAM,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACnC,KAAK,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EAClC,OAAO,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACpC,IAAI,EAAE,KAAK,WAAW,OAAO,GAAG;AAAA,EAChC,MAAM,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACnC,MAAM,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACnC,MAAM,EAAE,KAAK,WAAW,OAAO,IAAI;AAAA,EACnC,QAAQ,EAAE,KAAK,WAAW,OAAO,IAAI;AACvC;AAEO,IAAM,QAAQ;AAAA,EACnB,IAAI;AAAA,EACJ,MAAM;AAAA,EACN,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MA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Aa;AAAA,EACpC;AACF;AAEO,SAAS,WAAmB;AACjC,SAAO,KAAK,GAAG,MAAM,UAAU,KAAK,CAAC,GAAG,MAAM,QAAQ,QAAQ,CAAC,EAAE;AACnE;AAEO,SAAS,OAAiB;AAC/B,QAAM,OAAO,CAAC,UAA0B,MAAM,UAAU,KAAK;AAE7D,SAAO;AAAA,IACL,KAAK,mCAAU;AAAA,IACf,GAAG,KAAK,oBAAU,CAAC,SAAS,SAAS,CAAC;AAAA,IACtC,KAAK,0BAAW;AAAA,IAChB,KAAK,qBAAW;AAAA,EAClB;AACF;","names":["count"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for("Symbol." + name);
|
|
2
|
+
var __typeError = (msg) => {
|
|
3
|
+
throw TypeError(msg);
|
|
4
|
+
};
|
|
5
|
+
var __using = (stack, value, async) => {
|
|
6
|
+
if (value != null) {
|
|
7
|
+
if (typeof value !== "object" && typeof value !== "function") __typeError("Object expected");
|
|
8
|
+
var dispose, inner;
|
|
9
|
+
if (async) dispose = value[__knownSymbol("asyncDispose")];
|
|
10
|
+
if (dispose === void 0) {
|
|
11
|
+
dispose = value[__knownSymbol("dispose")];
|
|
12
|
+
if (async) inner = dispose;
|
|
13
|
+
}
|
|
14
|
+
if (typeof dispose !== "function") __typeError("Object not disposable");
|
|
15
|
+
if (inner) dispose = function() {
|
|
16
|
+
try {
|
|
17
|
+
inner.call(this);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
return Promise.reject(e);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
stack.push([async, dispose, value]);
|
|
23
|
+
} else if (async) {
|
|
24
|
+
stack.push([async]);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
};
|
|
28
|
+
var __callDispose = (stack, error, hasError) => {
|
|
29
|
+
var E = typeof SuppressedError === "function" ? SuppressedError : function(e, s, m, _) {
|
|
30
|
+
return _ = Error(m), _.name = "SuppressedError", _.error = e, _.suppressed = s, _;
|
|
31
|
+
};
|
|
32
|
+
var fail = (e) => error = hasError ? new E(e, error, "An error was suppressed during disposal") : (hasError = true, e);
|
|
33
|
+
var next = (it) => {
|
|
34
|
+
while (it = stack.pop()) {
|
|
35
|
+
try {
|
|
36
|
+
var result = it[1] && it[1].call(it[2]);
|
|
37
|
+
if (it[0]) return Promise.resolve(result).then(next, (e) => (fail(e), next()));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
fail(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (hasError) throw error;
|
|
43
|
+
};
|
|
44
|
+
return next();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
__using,
|
|
49
|
+
__callDispose
|
|
50
|
+
};
|
|
51
|
+
//# sourceMappingURL=chunk-UAWBPTDW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configPath,
|
|
3
|
+
ensureWalkwrightDir,
|
|
4
|
+
projectDir,
|
|
5
|
+
tryGit
|
|
6
|
+
} from "./chunk-BODO6HIH.js";
|
|
7
|
+
|
|
8
|
+
// src/project.ts
|
|
9
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
10
|
+
import { basename, relative } from "path";
|
|
11
|
+
var defaultReportsUrl = "https://app.walkwright.dev";
|
|
12
|
+
function describeConfigPath(cwd = process.cwd()) {
|
|
13
|
+
return relative(cwd, configPath(cwd)) || configPath(cwd);
|
|
14
|
+
}
|
|
15
|
+
function readWalkwrightConfig(cwd = process.cwd()) {
|
|
16
|
+
const path = configPath(cwd);
|
|
17
|
+
if (!existsSync(path)) {
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
const raw = JSON.parse(
|
|
21
|
+
readFileSync(path, "utf8")
|
|
22
|
+
);
|
|
23
|
+
if (typeof raw.project !== "string" || typeof raw.token !== "string") {
|
|
24
|
+
throw new Error(`${path} is missing "project" or "token"`);
|
|
25
|
+
}
|
|
26
|
+
if (raw.url !== void 0 && typeof raw.url !== "string") {
|
|
27
|
+
throw new Error(`${path} has a non-string "url"`);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
url: raw.url ?? defaultReportsUrl,
|
|
31
|
+
project: raw.project,
|
|
32
|
+
token: raw.token
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function writeWalkwrightConfig(config, cwd = process.cwd()) {
|
|
36
|
+
ensureWalkwrightDir(cwd);
|
|
37
|
+
const path = configPath(cwd);
|
|
38
|
+
writeFileSync(path, `${JSON.stringify(config, null, 2)}
|
|
39
|
+
`);
|
|
40
|
+
return path;
|
|
41
|
+
}
|
|
42
|
+
function currentBranch(cwd = process.cwd()) {
|
|
43
|
+
const override = process.env["WALKWRIGHT_BRANCH"];
|
|
44
|
+
if (override !== void 0 && override !== "") {
|
|
45
|
+
return override;
|
|
46
|
+
}
|
|
47
|
+
const branch = tryGit(cwd, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
48
|
+
return branch === void 0 || branch === "HEAD" ? "unknown" : branch;
|
|
49
|
+
}
|
|
50
|
+
function repoName(cwd = process.cwd()) {
|
|
51
|
+
const url = tryGit(cwd, ["remote", "get-url", "origin"]);
|
|
52
|
+
const match = url === void 0 ? null : /([^/:]+?)(\.git)?\/?$/.exec(url);
|
|
53
|
+
return match?.[1] !== void 0 && match[1] !== "" ? match[1] : basename(projectDir(cwd));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
defaultReportsUrl,
|
|
58
|
+
describeConfigPath,
|
|
59
|
+
readWalkwrightConfig,
|
|
60
|
+
writeWalkwrightConfig,
|
|
61
|
+
currentBranch,
|
|
62
|
+
repoName
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=chunk-Z7CW5CAY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/project.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { basename, relative } from \"node:path\";\n\nimport { configPath, ensureWalkwrightDir, projectDir, tryGit } from \"./paths.js\";\n\nexport const defaultReportsUrl = \"https://app.walkwright.dev\";\n\nexport interface WalkwrightConfig {\n url: string;\n project: string;\n token: string;\n}\n\nexport function describeConfigPath(cwd = process.cwd()): string {\n return relative(cwd, configPath(cwd)) || configPath(cwd);\n}\n\nexport function readWalkwrightConfig(\n cwd = process.cwd(),\n): WalkwrightConfig | undefined {\n const path = configPath(cwd);\n\n if (!existsSync(path)) {\n return undefined;\n }\n\n const raw = JSON.parse(\n readFileSync(path, \"utf8\"),\n ) as Partial<WalkwrightConfig>;\n\n if (typeof raw.project !== \"string\" || typeof raw.token !== \"string\") {\n throw new Error(`${path} is missing \"project\" or \"token\"`);\n }\n\n if (raw.url !== undefined && typeof raw.url !== \"string\") {\n throw new Error(`${path} has a non-string \"url\"`);\n }\n\n return {\n url: raw.url ?? defaultReportsUrl,\n project: raw.project,\n token: raw.token,\n };\n}\n\nexport function writeWalkwrightConfig(\n config: WalkwrightConfig,\n cwd = process.cwd(),\n): string {\n ensureWalkwrightDir(cwd);\n\n const path = configPath(cwd);\n writeFileSync(path, `${JSON.stringify(config, null, 2)}\\n`);\n\n return path;\n}\n\nexport function currentBranch(cwd = process.cwd()): string {\n const override = process.env[\"WALKWRIGHT_BRANCH\"];\n\n if (override !== undefined && override !== \"\") {\n return override;\n }\n\n const branch = tryGit(cwd, [\"rev-parse\", \"--abbrev-ref\", \"HEAD\"]);\n\n return branch === undefined || branch === \"HEAD\" ? \"unknown\" : branch;\n}\n\nexport function repoName(cwd = process.cwd()): string {\n const url = tryGit(cwd, [\"remote\", \"get-url\", \"origin\"]);\n const match = url === undefined ? null : /([^/:]+?)(\\.git)?\\/?$/.exec(url);\n\n return match?.[1] !== undefined && match[1] !== \"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AAEO,SAAS,SAAS,MAAM,QAAQ,IAAI,GAAW;AACpD,QAAM,MAAM,OAAO,KAAK,CAAC,UAAU,WAAW,QAAQ,CAAC;AACvD,QAAM,QAAQ,QAAQ,SAAY,OAAO,wBAAwB,KAAK,GAAG;AAEzE,SAAO,QAAQ,CAAC,MAAM,UAAa,MAAM,CAAC,MAAM,KAC5C,MAAM,CAAC,IACP,SAAS,WAAW,GAAG,CAAC;AAC9B;","names":[]}
|
package/build/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/build/cli.js
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
defaultReportsUrl,
|
|
4
|
+
describeConfigPath,
|
|
5
|
+
readWalkwrightConfig,
|
|
6
|
+
repoName,
|
|
7
|
+
writeWalkwrightConfig
|
|
8
|
+
} from "./chunk-Z7CW5CAY.js";
|
|
9
|
+
import {
|
|
10
|
+
ensureProject,
|
|
11
|
+
login
|
|
12
|
+
} from "./chunk-MFTC7XL2.js";
|
|
13
|
+
import {
|
|
14
|
+
blank,
|
|
15
|
+
bold,
|
|
16
|
+
failure,
|
|
17
|
+
glyph,
|
|
18
|
+
line,
|
|
19
|
+
logo,
|
|
20
|
+
paint,
|
|
21
|
+
wordmark
|
|
22
|
+
} from "./chunk-RNNW7OW2.js";
|
|
23
|
+
import "./chunk-BODO6HIH.js";
|
|
24
|
+
import "./chunk-UAWBPTDW.js";
|
|
25
|
+
|
|
26
|
+
// src/cli.ts
|
|
27
|
+
import { spawn } from "child_process";
|
|
28
|
+
import { createRequire } from "module";
|
|
29
|
+
import { join } from "path";
|
|
30
|
+
var [command, ...args] = process.argv.slice(2);
|
|
31
|
+
switch (command) {
|
|
32
|
+
case "walk":
|
|
33
|
+
await walkCommand(args);
|
|
34
|
+
break;
|
|
35
|
+
case "login":
|
|
36
|
+
await loginCommand(args);
|
|
37
|
+
break;
|
|
38
|
+
case "--version":
|
|
39
|
+
case "-v":
|
|
40
|
+
banner();
|
|
41
|
+
break;
|
|
42
|
+
case void 0:
|
|
43
|
+
case "--help":
|
|
44
|
+
case "-h":
|
|
45
|
+
case "?":
|
|
46
|
+
help();
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
fail(`unknown command ${command}`, "walkwright --help lists the commands");
|
|
50
|
+
}
|
|
51
|
+
function version() {
|
|
52
|
+
const { version: value } = createRequire(import.meta.url)(
|
|
53
|
+
"../package.json"
|
|
54
|
+
);
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
function banner() {
|
|
58
|
+
blank();
|
|
59
|
+
for (const row of logo()) {
|
|
60
|
+
line(row);
|
|
61
|
+
}
|
|
62
|
+
blank();
|
|
63
|
+
line(paint("dim", ` walkwright ${version()}`));
|
|
64
|
+
blank();
|
|
65
|
+
}
|
|
66
|
+
function help() {
|
|
67
|
+
const flag = (name, text) => ` ${paint("code", name.padEnd(20))}${paint("dim", text)}`;
|
|
68
|
+
const header = (text) => paint("accent", text);
|
|
69
|
+
blank();
|
|
70
|
+
line(`${wordmark()} ${paint("dim", version())}`);
|
|
71
|
+
blank();
|
|
72
|
+
line(header("USAGE"));
|
|
73
|
+
line(
|
|
74
|
+
` ${paint("text", "walkwright walk")} ${paint("dim", "[flags] [playwright args...]")}`
|
|
75
|
+
);
|
|
76
|
+
line(
|
|
77
|
+
` ${paint("text", "walkwright login")} ${paint("dim", "[--force] [--url <server>]")}`
|
|
78
|
+
);
|
|
79
|
+
blank();
|
|
80
|
+
line(header("WALK"));
|
|
81
|
+
line(
|
|
82
|
+
flag(
|
|
83
|
+
"--upload-on-fail",
|
|
84
|
+
"upload the passing lanes even though the walk failed"
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
line(flag("--no-upload", "skip the upload"));
|
|
88
|
+
line(flag("--branch <name>", "report under this branch instead of git's"));
|
|
89
|
+
line(
|
|
90
|
+
flag("--project <name>", "the playwright project to run (default walk)")
|
|
91
|
+
);
|
|
92
|
+
line(flag("--", "everything after goes to playwright"));
|
|
93
|
+
blank();
|
|
94
|
+
line(header("LOGIN"));
|
|
95
|
+
line(flag("--force", "log in again"));
|
|
96
|
+
line(
|
|
97
|
+
flag("--url <server>", `the review console (default ${defaultReportsUrl})`)
|
|
98
|
+
);
|
|
99
|
+
blank();
|
|
100
|
+
line(header("ALSO"));
|
|
101
|
+
line(flag("--version", "the banner"));
|
|
102
|
+
line(flag("--help, -h, ?", "this"));
|
|
103
|
+
blank();
|
|
104
|
+
}
|
|
105
|
+
async function loginCommand(args2) {
|
|
106
|
+
if (args2.includes("--help") || args2.includes("-h") || args2.includes("?")) {
|
|
107
|
+
help();
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const existing = readWalkwrightConfig();
|
|
111
|
+
const configFile = describeConfigPath();
|
|
112
|
+
if (existing !== void 0 && !args2.includes("--force")) {
|
|
113
|
+
line(
|
|
114
|
+
paint("ok", glyph.ok),
|
|
115
|
+
` already set up ${paint("dim", glyph.dot)} project ${bold(existing.project)}`
|
|
116
|
+
);
|
|
117
|
+
line(paint("dim", ` ${configFile} ${glyph.dot} --force to log in again`));
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const url = urlArg(args2) ?? defaultReportsUrl;
|
|
121
|
+
try {
|
|
122
|
+
const sessionToken = await login(url);
|
|
123
|
+
const project = await ensureProject(url, sessionToken, repoName());
|
|
124
|
+
writeWalkwrightConfig({ url, ...project });
|
|
125
|
+
line(
|
|
126
|
+
paint("ok", glyph.ok),
|
|
127
|
+
` wrote ${paint("code", configFile)} ${paint("dim", glyph.dot)} project ${bold(project.project)}`
|
|
128
|
+
);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
failure(describe(error), "run walkwright login again");
|
|
131
|
+
process.exit(1);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async function walkCommand(args2) {
|
|
135
|
+
let uploadOnFail = false;
|
|
136
|
+
let noUpload = false;
|
|
137
|
+
let branch;
|
|
138
|
+
let project;
|
|
139
|
+
const forwarded = [];
|
|
140
|
+
let index = 0;
|
|
141
|
+
let own = true;
|
|
142
|
+
while (index < args2.length) {
|
|
143
|
+
const arg = args2[index];
|
|
144
|
+
if (arg === void 0) {
|
|
145
|
+
break;
|
|
146
|
+
}
|
|
147
|
+
if (!own) {
|
|
148
|
+
forwarded.push(arg);
|
|
149
|
+
index += 1;
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
switch (arg) {
|
|
153
|
+
case "--":
|
|
154
|
+
own = false;
|
|
155
|
+
index += 1;
|
|
156
|
+
break;
|
|
157
|
+
case "--help":
|
|
158
|
+
case "-h":
|
|
159
|
+
case "?":
|
|
160
|
+
help();
|
|
161
|
+
return;
|
|
162
|
+
case "--upload-on-fail":
|
|
163
|
+
uploadOnFail = true;
|
|
164
|
+
index += 1;
|
|
165
|
+
break;
|
|
166
|
+
case "--no-upload":
|
|
167
|
+
noUpload = true;
|
|
168
|
+
index += 1;
|
|
169
|
+
break;
|
|
170
|
+
case "--branch":
|
|
171
|
+
branch = requiredValue(args2, index, arg);
|
|
172
|
+
index += 2;
|
|
173
|
+
break;
|
|
174
|
+
case "--project":
|
|
175
|
+
project = requiredValue(args2, index, arg);
|
|
176
|
+
index += 2;
|
|
177
|
+
break;
|
|
178
|
+
default:
|
|
179
|
+
forwarded.push(arg);
|
|
180
|
+
index += 1;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (uploadOnFail && noUpload) {
|
|
184
|
+
fail(
|
|
185
|
+
"--upload-on-fail and --no-upload cannot be used together",
|
|
186
|
+
"pick one"
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
const resolver = createRequire(join(process.cwd(), "package.json"));
|
|
190
|
+
let playwrightCli;
|
|
191
|
+
try {
|
|
192
|
+
playwrightCli = resolver.resolve("@playwright/test/cli");
|
|
193
|
+
} catch {
|
|
194
|
+
fail(
|
|
195
|
+
"@playwright/test is not installed in this project",
|
|
196
|
+
"pnpm add -D @playwright/test, then run walkwright walk again"
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
const env = { ...process.env };
|
|
200
|
+
env["WALK_RECORDING"] = "1";
|
|
201
|
+
if (uploadOnFail) {
|
|
202
|
+
env["WALKWRIGHT_UPLOAD_ON_FAIL"] = "1";
|
|
203
|
+
}
|
|
204
|
+
if (noUpload) {
|
|
205
|
+
env["WALKWRIGHT_NO_UPLOAD"] = "1";
|
|
206
|
+
}
|
|
207
|
+
if (branch !== void 0) {
|
|
208
|
+
env["WALKWRIGHT_BRANCH"] = branch;
|
|
209
|
+
}
|
|
210
|
+
const exitCode = await runPlaywright(playwrightCli, project, forwarded, env);
|
|
211
|
+
process.exit(exitCode);
|
|
212
|
+
}
|
|
213
|
+
function requiredValue(args2, index, flag) {
|
|
214
|
+
const value = args2[index + 1];
|
|
215
|
+
if (value === void 0 || value.startsWith("--")) {
|
|
216
|
+
fail(`${flag} needs a value`, `walkwright walk ${flag} <value>`);
|
|
217
|
+
}
|
|
218
|
+
return value;
|
|
219
|
+
}
|
|
220
|
+
async function runPlaywright(playwrightCli, project, forwarded, env) {
|
|
221
|
+
return await new Promise((resolve, reject) => {
|
|
222
|
+
const child = spawn(
|
|
223
|
+
process.execPath,
|
|
224
|
+
[playwrightCli, "test", `--project=${project ?? "walk"}`, ...forwarded],
|
|
225
|
+
{ stdio: "inherit", env, cwd: process.cwd() }
|
|
226
|
+
);
|
|
227
|
+
child.on("error", (error) => {
|
|
228
|
+
reject(error);
|
|
229
|
+
});
|
|
230
|
+
child.on("exit", (exitCode) => {
|
|
231
|
+
resolve(exitCode ?? 1);
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function urlArg(args2) {
|
|
236
|
+
const index = args2.indexOf("--url");
|
|
237
|
+
if (index === -1) {
|
|
238
|
+
return void 0;
|
|
239
|
+
}
|
|
240
|
+
const value = args2[index + 1];
|
|
241
|
+
if (value === void 0 || value.startsWith("--")) {
|
|
242
|
+
fail("--url needs a value", "walkwright login --url https://\u2026");
|
|
243
|
+
}
|
|
244
|
+
return value;
|
|
245
|
+
}
|
|
246
|
+
function describe(error) {
|
|
247
|
+
return error instanceof Error ? error.message : String(error);
|
|
248
|
+
}
|
|
249
|
+
function fail(message, hint) {
|
|
250
|
+
failure(message, hint);
|
|
251
|
+
process.exit(1);
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=cli.js.map
|