inline-sql-toolkit 0.5.0 → 0.5.2
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/CHANGELOG.md +18 -0
- package/dist/cli.js +39 -3
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.2 - 2026-10-09
|
|
4
|
+
|
|
5
|
+
- Fixed: with `inlineSql.format.commaPosition: "before"`, the rest of a
|
|
6
|
+
multi-line item (`CASE … END`, a subquery, a wrapped function call) now
|
|
7
|
+
moves right with its leading `, `, so `END` and the closing `)` no longer
|
|
8
|
+
line up with the comma. Only lines up to the `)` / `]` / `END` that closes
|
|
9
|
+
the item move; a following `JOIN` or statement stays put. Nested items add
|
|
10
|
+
up; lines that continue a string or block comment are left untouched.
|
|
11
|
+
|
|
12
|
+
## 0.5.1 - 2026-10-02
|
|
13
|
+
|
|
14
|
+
- Security: pins patched versions of OSV-flagged transitive dependencies
|
|
15
|
+
(`brace-expansion` 5.0.12, `fast-uri` 3.1.8, `undici` 7.29.1) and refreshes
|
|
16
|
+
`markdown-it` to 14.3.2, clearing the 17 advisories that failed the scheduled
|
|
17
|
+
OSV scan on main.
|
|
18
|
+
- No formatting behavior changes: the shipped runtime dependency
|
|
19
|
+
(`sql-formatter`) is unchanged.
|
|
20
|
+
|
|
3
21
|
## 0.5.0 - 2026-10-01
|
|
4
22
|
|
|
5
23
|
- Changed: `inlineSql.format.replaceOrdinals` now defaults to `false`, since it
|
package/dist/cli.js
CHANGED
|
@@ -1907,8 +1907,9 @@ function wrappingComma(line) {
|
|
|
1907
1907
|
if (comma < 0) return -1;
|
|
1908
1908
|
return /^[ \t]*(?:--.*)?$/.test(line.slice(comma + 1)) ? comma : -1;
|
|
1909
1909
|
}
|
|
1910
|
-
function moveCommasToLineStarts(text) {
|
|
1910
|
+
function moveCommasToLineStarts(text, dialect) {
|
|
1911
1911
|
const lines = text.split("\n");
|
|
1912
|
+
const inserts = /* @__PURE__ */ new Map();
|
|
1912
1913
|
for (let index = 0; index + 1 < lines.length; index++) {
|
|
1913
1914
|
const line = lines[index] ?? "";
|
|
1914
1915
|
const next = lines[index + 1] ?? "";
|
|
@@ -1920,8 +1921,43 @@ function moveCommasToLineStarts(text) {
|
|
|
1920
1921
|
const content = nextParts?.[2] ?? "";
|
|
1921
1922
|
lines[index] = `${line.slice(0, comma)}${line.slice(comma + 1)}`.trimEnd();
|
|
1922
1923
|
lines[index + 1] = `${indent}, ${content}`;
|
|
1924
|
+
inserts.set(index + 1, indent.length);
|
|
1923
1925
|
}
|
|
1924
|
-
|
|
1926
|
+
if (inserts.size === 0) return text;
|
|
1927
|
+
return shiftMovedItems(lines, inserts, dialect).join("\n");
|
|
1928
|
+
}
|
|
1929
|
+
function shiftMovedItems(lines, inserts, dialect) {
|
|
1930
|
+
const starts = [];
|
|
1931
|
+
let offset = 0;
|
|
1932
|
+
for (const line of lines) {
|
|
1933
|
+
starts.push(offset);
|
|
1934
|
+
offset += line.length + 1;
|
|
1935
|
+
}
|
|
1936
|
+
const tokens = lexSql(lines.join("\n"), dialect);
|
|
1937
|
+
const textLines = /* @__PURE__ */ new Set();
|
|
1938
|
+
for (const token of tokens) {
|
|
1939
|
+
if (token.kind === "space" || !token.text.includes("\n")) continue;
|
|
1940
|
+
starts.forEach((start, line) => {
|
|
1941
|
+
if (start > token.start && start < token.end) textLines.add(line);
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
const shifts = new Array(lines.length).fill(0);
|
|
1945
|
+
for (const [target, column] of inserts) {
|
|
1946
|
+
for (let index = target + 1; index < lines.length; index++) {
|
|
1947
|
+
const line = lines[index] ?? "";
|
|
1948
|
+
const indent = line.length - line.trimStart().length;
|
|
1949
|
+
if (indent === line.length || textLines.has(index)) continue;
|
|
1950
|
+
if (indent < column) break;
|
|
1951
|
+
if (indent === column && !/^(?:[)\]]|END\b)/i.test(line.slice(indent))) break;
|
|
1952
|
+
shifts[index] = (shifts[index] ?? 0) + 2;
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
return lines.map((line, index) => {
|
|
1956
|
+
const shift = shifts[index] ?? 0;
|
|
1957
|
+
if (shift === 0) return line;
|
|
1958
|
+
const indent = line.length - line.trimStart().length;
|
|
1959
|
+
return `${line.slice(0, indent)}${" ".repeat(shift)}${line.slice(indent)}`;
|
|
1960
|
+
});
|
|
1925
1961
|
}
|
|
1926
1962
|
var DOLLAR_QUOTE = /\$[A-Za-z_][A-Za-z0-9_]*\$|\$\$/y;
|
|
1927
1963
|
function rejoinFunctionCalls(text) {
|
|
@@ -2047,7 +2083,7 @@ function formatOnce(analysis, literal, detection, options, nonce, sqlFormatter,
|
|
|
2047
2083
|
formatted = rejoinFunctionCalls(formatted);
|
|
2048
2084
|
}
|
|
2049
2085
|
if (options.commaPosition === "before") {
|
|
2050
|
-
formatted = moveCommasToLineStarts(formatted);
|
|
2086
|
+
formatted = moveCommasToLineStarts(formatted, options.dialect);
|
|
2051
2087
|
}
|
|
2052
2088
|
formatted = breakTrailingDistributeLines(formatted, options.dialect);
|
|
2053
2089
|
const difference = sqlTokenDifference(plan.protectedSql, formatted, options.dialect);
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/hidenobunagai/inline-sql-toolkit/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "0.5.
|
|
14
|
+
"version": "0.5.2",
|
|
15
15
|
"icon": "icon.png",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"bin": {
|
|
@@ -176,12 +176,12 @@
|
|
|
176
176
|
"yaml": "2.9.0"
|
|
177
177
|
},
|
|
178
178
|
"overrides": {
|
|
179
|
-
"brace-expansion": "5.0.
|
|
180
|
-
"fast-uri": "3.1.
|
|
179
|
+
"brace-expansion": "5.0.12",
|
|
180
|
+
"fast-uri": "3.1.8",
|
|
181
181
|
"js-yaml": "4.3.2",
|
|
182
182
|
"nanoid": "3.3.18",
|
|
183
183
|
"postcss": "8.5.23",
|
|
184
184
|
"qs": "6.16.0",
|
|
185
|
-
"undici": "7.29.
|
|
185
|
+
"undici": "7.29.1"
|
|
186
186
|
}
|
|
187
187
|
}
|