@tailor-platform/sdk-codemod 0.4.1 → 0.4.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 +12 -0
- package/dist/index.js +52 -8
- package/package.json +8 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @tailor-platform/sdk-codemod
|
|
2
2
|
|
|
3
|
+
## 0.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1934](https://github.com/tailor-platform/sdk/pull/1934) [`2a3ec7b`](https://github.com/tailor-platform/sdk/commit/2a3ec7b108275410bf5b35d23784b07aa147c5ea) Thanks [@toiroakr](https://github.com/toiroakr)! - Drop the `chalk` dependency in favor of Node's built-in styling, and decide color support per output stream. Diagnostics on stderr now keep their colors when you redirect stdout (`tailor executor list > out.txt`), and stop writing escape codes into the file when you redirect stderr (`tailor deploy 2> log.txt`). `NO_COLOR`, `FORCE_COLOR` and non-TTY detection keep working as before.
|
|
8
|
+
|
|
9
|
+
`@tailor-platform/sdk-codemod`, `@tailor-platform/sdk-plugin-seed` and `@tailor-platform/sdk-plugin-tailordb-erd` now declare the Node and Bun versions they need (`node >=22.15.0`, `bun >=1.2.0`), matching `@tailor-platform/sdk`. Installing them on an older runtime reports the mismatch instead of failing once the CLI runs.
|
|
10
|
+
|
|
11
|
+
- [#2008](https://github.com/tailor-platform/sdk/pull/2008) [`f2135ab`](https://github.com/tailor-platform/sdk/commit/f2135ab6dd3d130d88803b9829a26024de930ed3) Thanks [@toiroakr](https://github.com/toiroakr)! - Consistently call a TailorDB schema definition a "table" instead of a "type" across the docs, matching the `db.type()` → `db.table()` rename. Also fix three leftover `db.type(...)` code samples in `docs/services/tailordb.md` that should have read `db.table(...)`.
|
|
12
|
+
|
|
13
|
+
Update the `v2/idp-publish-events-rename` codemod registry description to say "tables" instead of "types", matching the same wording fix.
|
|
14
|
+
|
|
3
15
|
## 0.4.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { gte, lt, parse, valid } from "semver";
|
|
|
9
9
|
import * as fs from "node:fs";
|
|
10
10
|
import { realpathSync } from "node:fs";
|
|
11
11
|
import { Lang, parse as parse$1 } from "@ast-grep/napi";
|
|
12
|
-
import
|
|
12
|
+
import { stripVTControlCharacters, styleText } from "node:util";
|
|
13
13
|
import { structuredPatch } from "diff";
|
|
14
14
|
import picomatch from "picomatch";
|
|
15
15
|
import { execFileSync } from "node:child_process";
|
|
@@ -683,7 +683,7 @@ const allCodemods = [
|
|
|
683
683
|
{
|
|
684
684
|
id: "v2/idp-publish-events-rename",
|
|
685
685
|
name: "defineIdp publishUserEvents → publishEvents",
|
|
686
|
-
description: "Rename the `defineIdp` option `publishUserEvents` to `publishEvents`, matching the field name TailorDB
|
|
686
|
+
description: "Rename the `defineIdp` option `publishUserEvents` to `publishEvents`, matching the field name that TailorDB tables, resolvers, and workflows already use.",
|
|
687
687
|
since: "1.5.0",
|
|
688
688
|
until: "2.0.0",
|
|
689
689
|
prereleaseUntil: V2_NEXT_11,
|
|
@@ -1521,6 +1521,46 @@ function getApplicableCodemods(fromVersion, toVersion) {
|
|
|
1521
1521
|
return allCodemods.filter((codemod) => gte(fromVersion, codemod.since) && lt(fromVersion, effectiveCodemodBoundary(codemod)) && reachesCodemodBoundary(toVersion, codemod));
|
|
1522
1522
|
}
|
|
1523
1523
|
//#endregion
|
|
1524
|
+
//#region ../shared/src/color.ts
|
|
1525
|
+
const style = (name) => (text) => styleText(name, text, { validateStream: false });
|
|
1526
|
+
/**
|
|
1527
|
+
* Style functions by name, so call sites read `color.bold(text)`. Styling is
|
|
1528
|
+
* always applied; `renderFor` drops it again when the destination stream has no
|
|
1529
|
+
* color support. Add a name here when a package needs one that is not listed.
|
|
1530
|
+
*/
|
|
1531
|
+
const color = {
|
|
1532
|
+
bold: style("bold"),
|
|
1533
|
+
dim: style("dim"),
|
|
1534
|
+
italic: style("italic"),
|
|
1535
|
+
gray: style("gray"),
|
|
1536
|
+
white: style("white"),
|
|
1537
|
+
red: style("red"),
|
|
1538
|
+
green: style("green"),
|
|
1539
|
+
yellow: style("yellow"),
|
|
1540
|
+
cyan: style("cyan"),
|
|
1541
|
+
magenta: style("magenta"),
|
|
1542
|
+
redBright: style("redBright"),
|
|
1543
|
+
greenBright: style("greenBright"),
|
|
1544
|
+
cyanBright: style("cyanBright")
|
|
1545
|
+
};
|
|
1546
|
+
const supportsColor = (stream) => {
|
|
1547
|
+
const forced = process.env.FORCE_COLOR;
|
|
1548
|
+
if (forced !== void 0) return forced !== "0" && forced !== "false";
|
|
1549
|
+
if (process.env.NODE_DISABLE_COLORS !== void 0) return false;
|
|
1550
|
+
if ((process.env.NO_COLOR ?? "") !== "") return false;
|
|
1551
|
+
if (process.env.TERM === "dumb") return false;
|
|
1552
|
+
return stream.isTTY === true;
|
|
1553
|
+
};
|
|
1554
|
+
/**
|
|
1555
|
+
* Prepares styled text for the stream it is written to.
|
|
1556
|
+
* @param stream - Stream the text is written to
|
|
1557
|
+
* @param text - Styled text
|
|
1558
|
+
* @returns Text with styling removed when the stream has no color support
|
|
1559
|
+
*/
|
|
1560
|
+
function renderFor(stream, text) {
|
|
1561
|
+
return supportsColor(stream) ? text : stripVTControlCharacters(text);
|
|
1562
|
+
}
|
|
1563
|
+
//#endregion
|
|
1524
1564
|
//#region src/runner.ts
|
|
1525
1565
|
/** Default file patterns for TypeScript files. */
|
|
1526
1566
|
const DEFAULT_FILE_PATTERNS = ["**/*.{ts,tsx,mts,cts}"];
|
|
@@ -1592,6 +1632,9 @@ async function* walkFiles(root, relativeDir = "") {
|
|
|
1592
1632
|
if (entry.isFile()) yield relative;
|
|
1593
1633
|
}
|
|
1594
1634
|
}
|
|
1635
|
+
function writeDiffLine(line, style) {
|
|
1636
|
+
process.stderr.write(renderFor(process.stderr, `${style ? style(line) : line}\n`));
|
|
1637
|
+
}
|
|
1595
1638
|
/**
|
|
1596
1639
|
* Print a colorized unified diff for a single file to stderr.
|
|
1597
1640
|
* @param filePath - Absolute path to the file
|
|
@@ -1601,13 +1644,14 @@ async function* walkFiles(root, relativeDir = "") {
|
|
|
1601
1644
|
function printDiff(filePath, before, after) {
|
|
1602
1645
|
const patch = structuredPatch(filePath, filePath, before, after, "", "", { context: 3 });
|
|
1603
1646
|
if (patch.hunks.length === 0) return;
|
|
1604
|
-
|
|
1605
|
-
|
|
1647
|
+
writeDiffLine("");
|
|
1648
|
+
writeDiffLine(`--- ${filePath}`, color.bold);
|
|
1649
|
+
writeDiffLine(`+++ ${filePath}`, color.bold);
|
|
1606
1650
|
for (const hunk of patch.hunks) {
|
|
1607
|
-
|
|
1608
|
-
for (const line of hunk.lines) if (line.startsWith("+"))
|
|
1609
|
-
else if (line.startsWith("-"))
|
|
1610
|
-
else
|
|
1651
|
+
writeDiffLine(`@@ -${hunk.oldStart},${hunk.oldLines} +${hunk.newStart},${hunk.newLines} @@`, color.cyan);
|
|
1652
|
+
for (const line of hunk.lines) if (line.startsWith("+")) writeDiffLine(line, color.green);
|
|
1653
|
+
else if (line.startsWith("-")) writeDiffLine(line, color.red);
|
|
1654
|
+
else writeDiffLine(line);
|
|
1611
1655
|
}
|
|
1612
1656
|
}
|
|
1613
1657
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/sdk-codemod",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Codemod runner for Tailor Platform SDK upgrades",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"type": "module",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@ast-grep/napi": "0.45.0",
|
|
20
|
-
"chalk": "5.6.2",
|
|
21
20
|
"diff": "9.0.0",
|
|
22
21
|
"pathe": "2.0.3",
|
|
23
22
|
"picomatch": "4.0.5",
|
|
@@ -29,12 +28,17 @@
|
|
|
29
28
|
"devDependencies": {
|
|
30
29
|
"@types/node": "24.13.3",
|
|
31
30
|
"@types/picomatch": "4.0.3",
|
|
32
|
-
"@types/semver": "7.
|
|
31
|
+
"@types/semver": "7.8.0",
|
|
33
32
|
"eslint-plugin-zod": "4.9.0",
|
|
34
33
|
"oxlint": "1.76.0",
|
|
35
34
|
"tsdown": "0.22.14",
|
|
36
35
|
"typescript": "6.0.3",
|
|
37
|
-
"vitest": "4.1.10"
|
|
36
|
+
"vitest": "4.1.10",
|
|
37
|
+
"@tailor-platform/shared": "^0.0.0"
|
|
38
|
+
},
|
|
39
|
+
"engines": {
|
|
40
|
+
"bun": ">=1.2.0",
|
|
41
|
+
"node": ">=22.15.0"
|
|
38
42
|
},
|
|
39
43
|
"scripts": {
|
|
40
44
|
"build": "tsdown",
|