webpipe-js 2.0.48 → 2.0.49
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/dist/index.cjs +47 -15
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +47 -15
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1275,7 +1275,7 @@ var Parser = class {
|
|
|
1275
1275
|
const returnValue = this.parseBacktickString();
|
|
1276
1276
|
this.skipSpaces();
|
|
1277
1277
|
const end = this.pos;
|
|
1278
|
-
return { target, targetStart, returnValue, start, end };
|
|
1278
|
+
return { target, targetStart, returnValue, lineNumber: this.getLineNumber(start), start, end };
|
|
1279
1279
|
}
|
|
1280
1280
|
parseMock() {
|
|
1281
1281
|
return this.parseMockHead("with");
|
|
@@ -1351,6 +1351,7 @@ var Parser = class {
|
|
|
1351
1351
|
name,
|
|
1352
1352
|
value,
|
|
1353
1353
|
format,
|
|
1354
|
+
lineNumber: this.getLineNumber(fullStart),
|
|
1354
1355
|
start: nameStart,
|
|
1355
1356
|
end: nameEnd,
|
|
1356
1357
|
fullStart,
|
|
@@ -1467,6 +1468,7 @@ var Parser = class {
|
|
|
1467
1468
|
headers,
|
|
1468
1469
|
cookies,
|
|
1469
1470
|
conditions,
|
|
1471
|
+
lineNumber: this.getLineNumber(start),
|
|
1470
1472
|
start,
|
|
1471
1473
|
end
|
|
1472
1474
|
};
|
|
@@ -1485,8 +1487,14 @@ var Parser = class {
|
|
|
1485
1487
|
const variables = [];
|
|
1486
1488
|
const mocks = [];
|
|
1487
1489
|
const tests = [];
|
|
1490
|
+
const comments = [];
|
|
1488
1491
|
while (true) {
|
|
1489
1492
|
this.skipSpaces();
|
|
1493
|
+
const comment = this.tryParse(() => this.parseStandaloneComment());
|
|
1494
|
+
if (comment) {
|
|
1495
|
+
comments.push(comment);
|
|
1496
|
+
continue;
|
|
1497
|
+
}
|
|
1490
1498
|
const letBinding = this.tryParse(() => this.parseLetBinding());
|
|
1491
1499
|
if (letBinding) {
|
|
1492
1500
|
variables.push(letBinding);
|
|
@@ -1511,7 +1519,7 @@ var Parser = class {
|
|
|
1511
1519
|
}
|
|
1512
1520
|
this.currentDescribeName = null;
|
|
1513
1521
|
const end = this.pos;
|
|
1514
|
-
return { name, variables, mocks, tests, inlineComment: inlineComment || void 0, start, end };
|
|
1522
|
+
return { name, variables, mocks, tests, comments, inlineComment: inlineComment || void 0, start, end };
|
|
1515
1523
|
}
|
|
1516
1524
|
};
|
|
1517
1525
|
function parseProgram(text) {
|
|
@@ -1740,22 +1748,46 @@ function printDescribe(describe) {
|
|
|
1740
1748
|
} else {
|
|
1741
1749
|
lines.push(describeLine);
|
|
1742
1750
|
}
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
});
|
|
1748
|
-
lines.push("");
|
|
1749
|
-
}
|
|
1751
|
+
const items = [];
|
|
1752
|
+
describe.variables.forEach((variable) => {
|
|
1753
|
+
items.push({ type: "variable", item: variable, lineNumber: variable.lineNumber || 0 });
|
|
1754
|
+
});
|
|
1750
1755
|
describe.mocks.forEach((mock) => {
|
|
1751
|
-
|
|
1756
|
+
items.push({ type: "mock", item: mock, lineNumber: mock.lineNumber || 0 });
|
|
1757
|
+
});
|
|
1758
|
+
describe.comments.forEach((comment) => {
|
|
1759
|
+
items.push({ type: "comment", item: comment, lineNumber: comment.lineNumber || 0 });
|
|
1752
1760
|
});
|
|
1753
|
-
if (describe.mocks.length > 0) {
|
|
1754
|
-
lines.push("");
|
|
1755
|
-
}
|
|
1756
1761
|
describe.tests.forEach((test) => {
|
|
1757
|
-
|
|
1758
|
-
|
|
1762
|
+
items.push({ type: "test", item: test, lineNumber: test.lineNumber || 0 });
|
|
1763
|
+
});
|
|
1764
|
+
items.sort((a, b) => a.lineNumber - b.lineNumber);
|
|
1765
|
+
let lastType = null;
|
|
1766
|
+
items.forEach((entry) => {
|
|
1767
|
+
if (lastType === "variable" && entry.type !== "variable") {
|
|
1768
|
+
lines.push("");
|
|
1769
|
+
}
|
|
1770
|
+
switch (entry.type) {
|
|
1771
|
+
case "variable":
|
|
1772
|
+
const variable = entry.item;
|
|
1773
|
+
const formattedValue = variable.format === "quoted" ? `"${variable.value}"` : variable.format === "backtick" ? `\`${variable.value}\`` : variable.value;
|
|
1774
|
+
lines.push(` let ${variable.name} = ${formattedValue}`);
|
|
1775
|
+
break;
|
|
1776
|
+
case "mock":
|
|
1777
|
+
lines.push(printMock(entry.item));
|
|
1778
|
+
break;
|
|
1779
|
+
case "comment":
|
|
1780
|
+
lines.push(` ${printComment(entry.item)}`);
|
|
1781
|
+
break;
|
|
1782
|
+
case "test":
|
|
1783
|
+
if (lastType && lastType !== "test") {
|
|
1784
|
+
lines.push("");
|
|
1785
|
+
}
|
|
1786
|
+
lines.push(printTest(entry.item));
|
|
1787
|
+
lines.push("");
|
|
1788
|
+
break;
|
|
1789
|
+
}
|
|
1790
|
+
lastType = entry.type;
|
|
1759
1791
|
});
|
|
1760
1792
|
return lines.join("\n").replace(/\n\n$/, "\n");
|
|
1761
1793
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -125,6 +125,7 @@ interface LetVariable {
|
|
|
125
125
|
name: string;
|
|
126
126
|
value: string;
|
|
127
127
|
format: LetValueFormat;
|
|
128
|
+
lineNumber?: number;
|
|
128
129
|
start: number;
|
|
129
130
|
end: number;
|
|
130
131
|
fullStart: number;
|
|
@@ -215,6 +216,7 @@ interface Describe {
|
|
|
215
216
|
variables: LetVariable[];
|
|
216
217
|
mocks: Mock[];
|
|
217
218
|
tests: It[];
|
|
219
|
+
comments: Comment[];
|
|
218
220
|
lineNumber?: number;
|
|
219
221
|
inlineComment?: Comment;
|
|
220
222
|
start: number;
|
|
@@ -224,6 +226,7 @@ interface Mock {
|
|
|
224
226
|
target: string;
|
|
225
227
|
targetStart: number;
|
|
226
228
|
returnValue: string;
|
|
229
|
+
lineNumber?: number;
|
|
227
230
|
start: number;
|
|
228
231
|
end: number;
|
|
229
232
|
}
|
|
@@ -237,6 +240,7 @@ interface It {
|
|
|
237
240
|
headers?: string;
|
|
238
241
|
cookies?: string;
|
|
239
242
|
conditions: Condition[];
|
|
243
|
+
lineNumber?: number;
|
|
240
244
|
start: number;
|
|
241
245
|
end: number;
|
|
242
246
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -125,6 +125,7 @@ interface LetVariable {
|
|
|
125
125
|
name: string;
|
|
126
126
|
value: string;
|
|
127
127
|
format: LetValueFormat;
|
|
128
|
+
lineNumber?: number;
|
|
128
129
|
start: number;
|
|
129
130
|
end: number;
|
|
130
131
|
fullStart: number;
|
|
@@ -215,6 +216,7 @@ interface Describe {
|
|
|
215
216
|
variables: LetVariable[];
|
|
216
217
|
mocks: Mock[];
|
|
217
218
|
tests: It[];
|
|
219
|
+
comments: Comment[];
|
|
218
220
|
lineNumber?: number;
|
|
219
221
|
inlineComment?: Comment;
|
|
220
222
|
start: number;
|
|
@@ -224,6 +226,7 @@ interface Mock {
|
|
|
224
226
|
target: string;
|
|
225
227
|
targetStart: number;
|
|
226
228
|
returnValue: string;
|
|
229
|
+
lineNumber?: number;
|
|
227
230
|
start: number;
|
|
228
231
|
end: number;
|
|
229
232
|
}
|
|
@@ -237,6 +240,7 @@ interface It {
|
|
|
237
240
|
headers?: string;
|
|
238
241
|
cookies?: string;
|
|
239
242
|
conditions: Condition[];
|
|
243
|
+
lineNumber?: number;
|
|
240
244
|
start: number;
|
|
241
245
|
end: number;
|
|
242
246
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1222,7 +1222,7 @@ var Parser = class {
|
|
|
1222
1222
|
const returnValue = this.parseBacktickString();
|
|
1223
1223
|
this.skipSpaces();
|
|
1224
1224
|
const end = this.pos;
|
|
1225
|
-
return { target, targetStart, returnValue, start, end };
|
|
1225
|
+
return { target, targetStart, returnValue, lineNumber: this.getLineNumber(start), start, end };
|
|
1226
1226
|
}
|
|
1227
1227
|
parseMock() {
|
|
1228
1228
|
return this.parseMockHead("with");
|
|
@@ -1298,6 +1298,7 @@ var Parser = class {
|
|
|
1298
1298
|
name,
|
|
1299
1299
|
value,
|
|
1300
1300
|
format,
|
|
1301
|
+
lineNumber: this.getLineNumber(fullStart),
|
|
1301
1302
|
start: nameStart,
|
|
1302
1303
|
end: nameEnd,
|
|
1303
1304
|
fullStart,
|
|
@@ -1414,6 +1415,7 @@ var Parser = class {
|
|
|
1414
1415
|
headers,
|
|
1415
1416
|
cookies,
|
|
1416
1417
|
conditions,
|
|
1418
|
+
lineNumber: this.getLineNumber(start),
|
|
1417
1419
|
start,
|
|
1418
1420
|
end
|
|
1419
1421
|
};
|
|
@@ -1432,8 +1434,14 @@ var Parser = class {
|
|
|
1432
1434
|
const variables = [];
|
|
1433
1435
|
const mocks = [];
|
|
1434
1436
|
const tests = [];
|
|
1437
|
+
const comments = [];
|
|
1435
1438
|
while (true) {
|
|
1436
1439
|
this.skipSpaces();
|
|
1440
|
+
const comment = this.tryParse(() => this.parseStandaloneComment());
|
|
1441
|
+
if (comment) {
|
|
1442
|
+
comments.push(comment);
|
|
1443
|
+
continue;
|
|
1444
|
+
}
|
|
1437
1445
|
const letBinding = this.tryParse(() => this.parseLetBinding());
|
|
1438
1446
|
if (letBinding) {
|
|
1439
1447
|
variables.push(letBinding);
|
|
@@ -1458,7 +1466,7 @@ var Parser = class {
|
|
|
1458
1466
|
}
|
|
1459
1467
|
this.currentDescribeName = null;
|
|
1460
1468
|
const end = this.pos;
|
|
1461
|
-
return { name, variables, mocks, tests, inlineComment: inlineComment || void 0, start, end };
|
|
1469
|
+
return { name, variables, mocks, tests, comments, inlineComment: inlineComment || void 0, start, end };
|
|
1462
1470
|
}
|
|
1463
1471
|
};
|
|
1464
1472
|
function parseProgram(text) {
|
|
@@ -1687,22 +1695,46 @@ function printDescribe(describe) {
|
|
|
1687
1695
|
} else {
|
|
1688
1696
|
lines.push(describeLine);
|
|
1689
1697
|
}
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
});
|
|
1695
|
-
lines.push("");
|
|
1696
|
-
}
|
|
1698
|
+
const items = [];
|
|
1699
|
+
describe.variables.forEach((variable) => {
|
|
1700
|
+
items.push({ type: "variable", item: variable, lineNumber: variable.lineNumber || 0 });
|
|
1701
|
+
});
|
|
1697
1702
|
describe.mocks.forEach((mock) => {
|
|
1698
|
-
|
|
1703
|
+
items.push({ type: "mock", item: mock, lineNumber: mock.lineNumber || 0 });
|
|
1704
|
+
});
|
|
1705
|
+
describe.comments.forEach((comment) => {
|
|
1706
|
+
items.push({ type: "comment", item: comment, lineNumber: comment.lineNumber || 0 });
|
|
1699
1707
|
});
|
|
1700
|
-
if (describe.mocks.length > 0) {
|
|
1701
|
-
lines.push("");
|
|
1702
|
-
}
|
|
1703
1708
|
describe.tests.forEach((test) => {
|
|
1704
|
-
|
|
1705
|
-
|
|
1709
|
+
items.push({ type: "test", item: test, lineNumber: test.lineNumber || 0 });
|
|
1710
|
+
});
|
|
1711
|
+
items.sort((a, b) => a.lineNumber - b.lineNumber);
|
|
1712
|
+
let lastType = null;
|
|
1713
|
+
items.forEach((entry) => {
|
|
1714
|
+
if (lastType === "variable" && entry.type !== "variable") {
|
|
1715
|
+
lines.push("");
|
|
1716
|
+
}
|
|
1717
|
+
switch (entry.type) {
|
|
1718
|
+
case "variable":
|
|
1719
|
+
const variable = entry.item;
|
|
1720
|
+
const formattedValue = variable.format === "quoted" ? `"${variable.value}"` : variable.format === "backtick" ? `\`${variable.value}\`` : variable.value;
|
|
1721
|
+
lines.push(` let ${variable.name} = ${formattedValue}`);
|
|
1722
|
+
break;
|
|
1723
|
+
case "mock":
|
|
1724
|
+
lines.push(printMock(entry.item));
|
|
1725
|
+
break;
|
|
1726
|
+
case "comment":
|
|
1727
|
+
lines.push(` ${printComment(entry.item)}`);
|
|
1728
|
+
break;
|
|
1729
|
+
case "test":
|
|
1730
|
+
if (lastType && lastType !== "test") {
|
|
1731
|
+
lines.push("");
|
|
1732
|
+
}
|
|
1733
|
+
lines.push(printTest(entry.item));
|
|
1734
|
+
lines.push("");
|
|
1735
|
+
break;
|
|
1736
|
+
}
|
|
1737
|
+
lastType = entry.type;
|
|
1706
1738
|
});
|
|
1707
1739
|
return lines.join("\n").replace(/\n\n$/, "\n");
|
|
1708
1740
|
}
|