inline-sql-toolkit 0.4.9 → 0.4.11
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 +42 -0
- package/README.md +6 -1
- package/dist/cli.js +44 -4
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.11 - 2026-09-24
|
|
4
|
+
|
|
5
|
+
- Feature: added the `inlineSql.format.commaPosition` setting (`after` |
|
|
6
|
+
`before`, default `after`) for codebases that want a wrapped item's comma at
|
|
7
|
+
the start of the next line instead of the end of the previous one. The
|
|
8
|
+
default reproduces the previous output byte for byte, so existing files do
|
|
9
|
+
not move until the setting is turned on; `before` emits the comma at the
|
|
10
|
+
next line's indent in front of the item, and a trailing `-- comment` stays
|
|
11
|
+
with its own column (`order_id -- note` followed by `, order_date -- note`)
|
|
12
|
+
rather than pinning the comma behind it.
|
|
13
|
+
- The same choice is exposed everywhere the other options are: the VS Code
|
|
14
|
+
setting, the CLI flag `--comma-position after|before`, and
|
|
15
|
+
`"commaPosition"` in `.inline-sql.json`, under the unchanged CLI flags >
|
|
16
|
+
configuration file > defaults precedence.
|
|
17
|
+
- Safety: `sql-formatter` removed its own `commaPosition` option long ago, so
|
|
18
|
+
the move is a small post-pass over its output. A scanner locates the
|
|
19
|
+
wrapping separator comma and never moves one from inside a quoted string
|
|
20
|
+
(`'...'`, `"..."`, backticks) or from after a `--` line comment, and a
|
|
21
|
+
candidate whose output still fails to converge to a fixed point is skipped
|
|
22
|
+
untouched as before, so no file can be rewritten with corrupted SQL.
|
|
23
|
+
|
|
24
|
+
## 0.4.10 - 2026-09-19
|
|
25
|
+
|
|
26
|
+
- CI: the npm publish job is now OIDC-only. The dormant `NPM_TOKEN` path that was
|
|
27
|
+
kept for the one-time 0.4.7 bootstrap is gone, so a stray token secret can no
|
|
28
|
+
longer silently take precedence over trusted publishing — one did, and it would
|
|
29
|
+
have expired a week later. npm exchanges the GitHub OIDC token for a
|
|
30
|
+
short-lived publish credential and attaches provenance attestations, matching
|
|
31
|
+
the setup already used by `sql-template-formatter`.
|
|
32
|
+
- Documentation: `docs/releasing.md` now records the bootstrap as a one-time
|
|
33
|
+
local publish that is needed only for a brand-new package name: install with
|
|
34
|
+
`bun install --frozen-lockfile --ignore-scripts`, build with `bun run build`,
|
|
35
|
+
then `npm publish`. It also states that dispatching the workflow can no longer
|
|
36
|
+
verify OIDC, because the publish is skipped when the version is already on npm:
|
|
37
|
+
the next release is the first real test of the credential exchange.
|
|
38
|
+
- Documentation: the tarball check now requires `dist/cli.js` and
|
|
39
|
+
`dist/package.json` together: the latter marks `dist/` as CommonJS, and 0.4.7
|
|
40
|
+
shipped without it, so the published CLI died with the error
|
|
41
|
+
`module is not defined in ES module scope`.
|
|
42
|
+
- No formatting behavior changes and no code changes: this release is publish
|
|
43
|
+
workflow and release-documentation only.
|
|
44
|
+
|
|
3
45
|
## 0.4.9 - 2026-09-18
|
|
4
46
|
|
|
5
47
|
- CI: the Open VSX publish step now retries up to four times with a 30-second
|
package/README.md
CHANGED
|
@@ -110,6 +110,9 @@ later atomic precondition.
|
|
|
110
110
|
aliases (default `true`).
|
|
111
111
|
- `inlineSql.format.dialect`: SQL dialect used by the formatter (`sql`,
|
|
112
112
|
`mysql`, `postgresql`, or `sqlite`; default `postgresql`).
|
|
113
|
+
- `inlineSql.format.commaPosition`: `after` (default) keeps a wrapping comma at
|
|
114
|
+
the end of the previous line; `before` moves it to the start of the next
|
|
115
|
+
line.
|
|
113
116
|
|
|
114
117
|
The extension highlights inline SQL with an injected TextMate grammar: SQL
|
|
115
118
|
strings that start with `-- sql` (or a leading SQL keyword) are embedded as
|
|
@@ -144,6 +147,7 @@ When run without file arguments, the CLI reads Python source from standard input
|
|
|
144
147
|
| `--wrap-after <20-500>` | Preferred expression line width | `88` |
|
|
145
148
|
| `--no-space-around-operators` | Keep dense operators | spaced |
|
|
146
149
|
| `--no-ordinals` | Do not replace `GROUP BY` / `ORDER BY` ordinals with column names | replace |
|
|
150
|
+
| `--comma-position <pos>` | Where a wrapping comma sits: `after` or `before` | `after` |
|
|
147
151
|
| `-c, --config <file>` | Configuration JSON file | Nearest `.inline-sql.json` |
|
|
148
152
|
| `-h, --help` | Show usage help | |
|
|
149
153
|
| `--version` | Show version number | |
|
|
@@ -162,7 +166,8 @@ The CLI automatically searches for a `.inline-sql.json` file in the current work
|
|
|
162
166
|
"wrapAfter": 88,
|
|
163
167
|
"useSpaceAroundOperators": true,
|
|
164
168
|
"replaceOrdinals": true,
|
|
165
|
-
"dialect": "postgresql"
|
|
169
|
+
"dialect": "postgresql",
|
|
170
|
+
"commaPosition": "after"
|
|
166
171
|
}
|
|
167
172
|
}
|
|
168
173
|
```
|
package/dist/cli.js
CHANGED
|
@@ -494,7 +494,8 @@ function resolveFormatOptions(raw) {
|
|
|
494
494
|
const useSpaceAroundOperators = raw.useSpaceAroundOperators === void 0 ? true : raw.useSpaceAroundOperators;
|
|
495
495
|
const replaceOrdinals2 = raw.replaceOrdinals === void 0 ? true : raw.replaceOrdinals;
|
|
496
496
|
const dialect = raw.dialect === void 0 ? "postgresql" : raw.dialect;
|
|
497
|
-
|
|
497
|
+
const commaPosition = raw.commaPosition === void 0 ? "after" : raw.commaPosition;
|
|
498
|
+
if (keywordCase !== "upper" && keywordCase !== "lower" && keywordCase !== "preserve" || !integerBetween(indentWidth, 1, 8) || !integerBetween(wrapAfter, 20, 500) || typeof useSpaceAroundOperators !== "boolean" || typeof replaceOrdinals2 !== "boolean" || dialect !== "sql" && dialect !== "mysql" && dialect !== "postgresql" && dialect !== "sqlite" || commaPosition !== "after" && commaPosition !== "before") {
|
|
498
499
|
return { ok: false, reason: "INVALID_CONFIGURATION" };
|
|
499
500
|
}
|
|
500
501
|
return {
|
|
@@ -505,7 +506,8 @@ function resolveFormatOptions(raw) {
|
|
|
505
506
|
wrapAfter,
|
|
506
507
|
useSpaceAroundOperators,
|
|
507
508
|
replaceOrdinals: replaceOrdinals2,
|
|
508
|
-
dialect
|
|
509
|
+
dialect,
|
|
510
|
+
commaPosition
|
|
509
511
|
}
|
|
510
512
|
};
|
|
511
513
|
}
|
|
@@ -1584,6 +1586,38 @@ function breakTrailingDistributeLines(text) {
|
|
|
1584
1586
|
${indent}${rest}`
|
|
1585
1587
|
);
|
|
1586
1588
|
}
|
|
1589
|
+
function wrappingComma(line) {
|
|
1590
|
+
let comma = -1;
|
|
1591
|
+
for (let index = 0; index < line.length; index++) {
|
|
1592
|
+
const char = line[index];
|
|
1593
|
+
if (char === "'" || char === '"' || char === "`") {
|
|
1594
|
+
for (index += 1; index < line.length && line[index] !== char; index++) {
|
|
1595
|
+
if (line[index] === "\\") index += 1;
|
|
1596
|
+
}
|
|
1597
|
+
continue;
|
|
1598
|
+
}
|
|
1599
|
+
if (char === "-" && line[index + 1] === "-") break;
|
|
1600
|
+
if (char === ",") comma = index;
|
|
1601
|
+
}
|
|
1602
|
+
if (comma < 0) return -1;
|
|
1603
|
+
return /^[ \t]*(?:--.*)?$/.test(line.slice(comma + 1)) ? comma : -1;
|
|
1604
|
+
}
|
|
1605
|
+
function moveCommasToLineStarts(text) {
|
|
1606
|
+
const lines = text.split("\n");
|
|
1607
|
+
for (let index = 0; index + 1 < lines.length; index++) {
|
|
1608
|
+
const line = lines[index] ?? "";
|
|
1609
|
+
const next = lines[index + 1] ?? "";
|
|
1610
|
+
if (next.trim() === "") continue;
|
|
1611
|
+
const comma = wrappingComma(line);
|
|
1612
|
+
if (comma < 0 || line.slice(0, comma).trim() === "") continue;
|
|
1613
|
+
const nextParts = /^([ \t]*)([\s\S]*)$/.exec(next);
|
|
1614
|
+
const indent = nextParts?.[1] ?? "";
|
|
1615
|
+
const content = nextParts?.[2] ?? "";
|
|
1616
|
+
lines[index] = `${line.slice(0, comma)}${line.slice(comma + 1)}`.trimEnd();
|
|
1617
|
+
lines[index + 1] = `${indent}, ${content}`;
|
|
1618
|
+
}
|
|
1619
|
+
return lines.join("\n");
|
|
1620
|
+
}
|
|
1587
1621
|
function formatOnce(analysis, literal, detection, options, nonce, sqlFormatter) {
|
|
1588
1622
|
const plan = buildProtectionPlan(analysis.sourceMap, literal, detection, nonce);
|
|
1589
1623
|
let formatted = sqlFormatter(plan.protectedSql, {
|
|
@@ -1598,6 +1632,9 @@ function formatOnce(analysis, literal, detection, options, nonce, sqlFormatter)
|
|
|
1598
1632
|
}
|
|
1599
1633
|
formatted = breakTrailingFieldMarkers(formatted);
|
|
1600
1634
|
formatted = moveCommasBeforeLineComments(formatted);
|
|
1635
|
+
if (options.commaPosition === "before") {
|
|
1636
|
+
formatted = moveCommasToLineStarts(formatted);
|
|
1637
|
+
}
|
|
1601
1638
|
formatted = breakTrailingDistributeLines(formatted);
|
|
1602
1639
|
const restored = restoreProtected(formatted, plan);
|
|
1603
1640
|
const resolved = options.replaceOrdinals ? replaceOrdinals(restored) : restored;
|
|
@@ -1824,7 +1861,7 @@ function formatDocument(source, options, target, nonce, sqlFormatter, logger) {
|
|
|
1824
1861
|
};
|
|
1825
1862
|
if (logger !== void 0) {
|
|
1826
1863
|
logger(
|
|
1827
|
-
`format: dialect=${options.dialect} keywordCase=${options.keywordCase} indentWidth=${options.indentWidth} wrapAfter=${options.wrapAfter} useSpaceAroundOperators=${options.useSpaceAroundOperators} replaceOrdinals=${options.replaceOrdinals} discovered=${summary.discovered} selected=${summary.selected} changed=${summary.changed} unchanged=${summary.unchanged} skipped=${summary.skipped}${skipReasons.length > 0 ? ` reasons=[${skipReasons.join(", ")}]` : ""}`
|
|
1864
|
+
`format: dialect=${options.dialect} keywordCase=${options.keywordCase} indentWidth=${options.indentWidth} wrapAfter=${options.wrapAfter} useSpaceAroundOperators=${options.useSpaceAroundOperators} replaceOrdinals=${options.replaceOrdinals} commaPosition=${options.commaPosition} discovered=${summary.discovered} selected=${summary.selected} changed=${summary.changed} unchanged=${summary.unchanged} skipped=${summary.skipped}${skipReasons.length > 0 ? ` reasons=[${skipReasons.join(", ")}]` : ""}`
|
|
1828
1865
|
);
|
|
1829
1866
|
}
|
|
1830
1867
|
return {
|
|
@@ -22476,6 +22513,7 @@ var USAGE = `Usage: inline-sql-toolkit [options] [files...]
|
|
|
22476
22513
|
--wrap-after <20-500> (default: 88)
|
|
22477
22514
|
--no-space-around-operators keep dense operators (default: spaced)
|
|
22478
22515
|
--no-ordinals do not replace GROUP BY / ORDER BY ordinals
|
|
22516
|
+
--comma-position <pos> after | before (default: after)
|
|
22479
22517
|
-c, --config <file> config JSON (default: nearest .inline-sql.json)
|
|
22480
22518
|
-h, --help / --version`;
|
|
22481
22519
|
function printError(message) {
|
|
@@ -22534,7 +22572,8 @@ function buildRawOptions(fileOptions, cliValues) {
|
|
|
22534
22572
|
indentWidth: cliValues["indent-width"] !== void 0 ? Number(cliValues["indent-width"]) : fileOptions.indentWidth,
|
|
22535
22573
|
wrapAfter: cliValues["wrap-after"] !== void 0 ? Number(cliValues["wrap-after"]) : fileOptions.wrapAfter,
|
|
22536
22574
|
useSpaceAroundOperators: cliValues["no-space-around-operators"] ? false : fileOptions.useSpaceAroundOperators,
|
|
22537
|
-
replaceOrdinals: cliValues["no-ordinals"] ? false : fileOptions.replaceOrdinals
|
|
22575
|
+
replaceOrdinals: cliValues["no-ordinals"] ? false : fileOptions.replaceOrdinals,
|
|
22576
|
+
commaPosition: cliValues["comma-position"] ?? fileOptions.commaPosition
|
|
22538
22577
|
};
|
|
22539
22578
|
}
|
|
22540
22579
|
function formatPythonSource(text, options, logger) {
|
|
@@ -22570,6 +22609,7 @@ function runCli(argv) {
|
|
|
22570
22609
|
"wrap-after": { type: "string" },
|
|
22571
22610
|
"no-space-around-operators": { type: "boolean", default: false },
|
|
22572
22611
|
"no-ordinals": { type: "boolean", default: false },
|
|
22612
|
+
"comma-position": { type: "string" },
|
|
22573
22613
|
config: { type: "string", short: "c" },
|
|
22574
22614
|
help: { type: "boolean", short: "h", default: false },
|
|
22575
22615
|
version: { type: "boolean", default: false }
|
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.4.
|
|
14
|
+
"version": "0.4.11",
|
|
15
15
|
"icon": "icon.png",
|
|
16
16
|
"type": "module",
|
|
17
17
|
"bin": {
|
|
@@ -104,6 +104,16 @@
|
|
|
104
104
|
"default": "postgresql",
|
|
105
105
|
"scope": "resource",
|
|
106
106
|
"description": "%configuration.format.dialect.description%"
|
|
107
|
+
},
|
|
108
|
+
"inlineSql.format.commaPosition": {
|
|
109
|
+
"type": "string",
|
|
110
|
+
"enum": [
|
|
111
|
+
"after",
|
|
112
|
+
"before"
|
|
113
|
+
],
|
|
114
|
+
"default": "after",
|
|
115
|
+
"scope": "resource",
|
|
116
|
+
"description": "%configuration.format.commaPosition.description%"
|
|
107
117
|
}
|
|
108
118
|
}
|
|
109
119
|
},
|