@tailor-platform/sdk-codemod 0.6.0 → 0.7.0
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
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @tailor-platform/sdk-codemod
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#2088](https://github.com/tailor-platform/sdk/pull/2088) [`c9f91d9`](https://github.com/tailor-platform/sdk/commit/c9f91d944e4b041250979ec4438c36cabf818e14) Thanks [@dqn](https://github.com/dqn)! - The `--branch` option of `tailor setup branch` is renamed to `--target`, so it no longer collides with the subcommand name. The old spelling keeps working as a deprecated alias until v3 and prints a deprecation warning when used; `tailor upgrade` offers the `v3/setup-branch-flag-rename` codemod to rewrite `setup branch --branch` invocations across package.json scripts, shell and Windows scripts, YAML, Markdown, and JavaScript/TypeScript sources. The `--branch` option of `setup tag`, `setup preview`, and `setup coordinate` is unchanged.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#2137](https://github.com/tailor-platform/sdk/pull/2137) [`d38497a`](https://github.com/tailor-platform/sdk/commit/d38497ac214f547483028e2622d53dbf1414ecb2) Thanks [@dqn](https://github.com/dqn)! - Keep LLM review detection working in multi-major upgrades: each codemod's review detector and suspicious patterns now inspect the file as of that codemod's position in the transform chain, so a later codemod's rewrite can no longer silently hide an earlier codemod's review findings.
|
|
12
|
+
|
|
13
|
+
- [#2138](https://github.com/tailor-platform/sdk/pull/2138) [`870c8cd`](https://github.com/tailor-platform/sdk/commit/870c8cdaa007adcbb8f565fe9b4d238d98c00e6d) Thanks [@dqn](https://github.com/dqn)! - Stop exporting internal declarations that were only used within their own module.
|
|
14
|
+
|
|
15
|
+
- [#2089](https://github.com/tailor-platform/sdk/pull/2089) [`90948e6`](https://github.com/tailor-platform/sdk/commit/90948e6f6e1f3624a9c30595b3ff3a46ffbbced0) Thanks [@toiroakr](https://github.com/toiroakr)! - Add a targeted hint to the `Remote schema drift detected` error when every reported drift is a missing script hash — the pattern left by an environment last deployed with the pre-v2 CLI, which never wrote script hashes. The hint points at `migration sync <N>`, which is already listed as one of the general resolution options. The v2 migration guide (`docs/migration/v2.md`) now also documents that the first `tailor deploy` against such an environment needs a `migration sync` first.
|
|
16
|
+
|
|
3
17
|
## 0.6.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as path from "pathe";
|
|
2
|
+
//#region codemods/v3/setup-branch-flag-rename/scripts/transform.ts
|
|
3
|
+
const TOKEN_SEPARATOR = "(?:[ \\t]|\\\\\\r?\\n)+";
|
|
4
|
+
const COMMAND_START = new RegExp(`(?<![\\w.-])tailor(?:-sdk)?(?:\\.(?:cmd|ps1|exe))?${TOKEN_SEPARATOR}setup${TOKEN_SEPARATOR}branch(?![\\w.-])`, "g");
|
|
5
|
+
const NEXT_TOKEN = new RegExp(`${TOKEN_SEPARATOR}("[^"\\n]*"|'[^'\\n]*'|[^\\s;&|]+)`, "y");
|
|
6
|
+
function replaceCommand(value) {
|
|
7
|
+
let result = "";
|
|
8
|
+
let cursor = 0;
|
|
9
|
+
COMMAND_START.lastIndex = 0;
|
|
10
|
+
for (let match = COMMAND_START.exec(value); match; match = COMMAND_START.exec(value)) {
|
|
11
|
+
let pos = COMMAND_START.lastIndex;
|
|
12
|
+
result += value.slice(cursor, pos);
|
|
13
|
+
NEXT_TOKEN.lastIndex = pos;
|
|
14
|
+
for (let token = NEXT_TOKEN.exec(value); token; token = NEXT_TOKEN.exec(value)) {
|
|
15
|
+
const chunk = token[0];
|
|
16
|
+
const word = token[1];
|
|
17
|
+
if (word.startsWith("#")) break;
|
|
18
|
+
const quoted = /^(['"])(--branch(?:=.*)?)\1$/.exec(word);
|
|
19
|
+
const quote = quoted ? quoted[1] : "";
|
|
20
|
+
const bare = quoted ? quoted[2] : word;
|
|
21
|
+
if (bare === "--branch" || bare.startsWith("--branch=")) {
|
|
22
|
+
const separator = chunk.slice(0, chunk.length - word.length);
|
|
23
|
+
result += `${separator}${quote}--target${bare.slice(8)}${quote}`;
|
|
24
|
+
} else result += chunk;
|
|
25
|
+
pos = NEXT_TOKEN.lastIndex;
|
|
26
|
+
if (/\$\(|`|<\(|>\(/.test(word)) break;
|
|
27
|
+
}
|
|
28
|
+
cursor = pos;
|
|
29
|
+
COMMAND_START.lastIndex = pos;
|
|
30
|
+
}
|
|
31
|
+
result += value.slice(cursor);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
function transformText(source) {
|
|
35
|
+
const updated = replaceCommand(source);
|
|
36
|
+
return updated === source ? null : updated;
|
|
37
|
+
}
|
|
38
|
+
function transformPackageJson(source) {
|
|
39
|
+
let parsed;
|
|
40
|
+
try {
|
|
41
|
+
parsed = JSON.parse(source);
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
let modified = false;
|
|
46
|
+
const scripts = parsed.scripts;
|
|
47
|
+
if (typeof scripts === "object" && scripts != null && !Array.isArray(scripts)) for (const [name, value] of Object.entries(scripts)) {
|
|
48
|
+
if (typeof value !== "string") continue;
|
|
49
|
+
const updated = replaceCommand(value);
|
|
50
|
+
if (updated !== value) {
|
|
51
|
+
scripts[name] = updated;
|
|
52
|
+
modified = true;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!modified) return null;
|
|
56
|
+
const trailing = source.endsWith("\n") ? "\n" : "";
|
|
57
|
+
return JSON.stringify(parsed, null, 2) + trailing;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Rename the `--branch` option of `tailor setup branch` invocations to
|
|
61
|
+
* `--target`.
|
|
62
|
+
*
|
|
63
|
+
* `--branch` remains as a deprecated alias until v3, where only
|
|
64
|
+
* `--target` is recognized. `setup tag`, `setup preview`, and
|
|
65
|
+
* `setup coordinate` keep their own `--branch` option unchanged.
|
|
66
|
+
* @param source - File contents
|
|
67
|
+
* @param filePath - Absolute path to the file (used to dispatch package.json vs text)
|
|
68
|
+
* @returns Transformed source or null when nothing matched.
|
|
69
|
+
*/
|
|
70
|
+
function transform(source, filePath) {
|
|
71
|
+
if (!source.includes("--branch")) return null;
|
|
72
|
+
if (path.extname(filePath).toLowerCase() === ".json") return transformPackageJson(source);
|
|
73
|
+
return transformText(source);
|
|
74
|
+
}
|
|
75
|
+
//#endregion
|
|
76
|
+
export { transform as default };
|
package/dist/index.js
CHANGED
|
@@ -123,6 +123,7 @@ const V2_NEXT_6 = "2.0.0-next.6";
|
|
|
123
123
|
const V2_NEXT_7 = "2.0.0-next.7";
|
|
124
124
|
const V2_NEXT_9 = "2.0.0-next.9";
|
|
125
125
|
const V2_NEXT_11 = "2.0.0-next.11";
|
|
126
|
+
const SETUP_BRANCH_RESIDUAL_FLAG = /(?:(?<![\w.-])tailor(?:-sdk)?(?:\.(?:cmd|ps1|exe))?|@tailor-platform\/sdk(?:@\S{1,32})?)[\s\\^`]{1,16}setup[\s\\^`]{1,16}branch\b(?:'[^'\n]*'|"[^"\n]*"|[^\n;&|'"#]|[\\^`]\r?\n)*(?:[ \t]|[\\^`]\r?\n)--branch(?![\w-])/;
|
|
126
127
|
/** All registered codemods, in registration order. */
|
|
127
128
|
const allCodemods = [
|
|
128
129
|
{
|
|
@@ -816,7 +817,11 @@ const allCodemods = [
|
|
|
816
817
|
" them to StartWorkflowOptions / ExecJobFunctionOptions.",
|
|
817
818
|
"- An invoker option passed via a variable or spread (not a literal object) —",
|
|
818
819
|
" the codemod only inspects literal object arguments; rename the invoker key",
|
|
819
|
-
" to authInvoker in the options object's own definition."
|
|
820
|
+
" to authInvoker in the options object's own definition.",
|
|
821
|
+
"- A renamed triggerJobFunction call whose target is another workflow job —",
|
|
822
|
+
" rewrite it further to that job's own .start() method (e.g. worker.start(args)).",
|
|
823
|
+
" Calling execJobFunction directly is not detected as a build-time dependency",
|
|
824
|
+
" and fails the build."
|
|
820
825
|
].join("\n")
|
|
821
826
|
},
|
|
822
827
|
{
|
|
@@ -849,7 +854,45 @@ const allCodemods = [
|
|
|
849
854
|
"- mockWorkflow().startJobFunction in tests — assert on the execJobFunction vi.fn",
|
|
850
855
|
" instead; the alias was the same mock function.",
|
|
851
856
|
"- A file that already imports ExecJobFunctionOptions alongside the removed type —",
|
|
852
|
-
" rename the remaining references by hand and drop the duplicate specifier."
|
|
857
|
+
" rename the remaining references by hand and drop the duplicate specifier.",
|
|
858
|
+
"- A renamed call whose target is another workflow job — rewrite it further to",
|
|
859
|
+
" that job's own .start() method (e.g. worker.start(args)). Calling",
|
|
860
|
+
" execJobFunction directly is not detected as a build-time dependency and fails",
|
|
861
|
+
" the build."
|
|
862
|
+
].join("\n")
|
|
863
|
+
},
|
|
864
|
+
{
|
|
865
|
+
id: "v3/remove-workflow-exec-job-function",
|
|
866
|
+
name: "workflow.execJobFunction (imported) removed — use job.start()",
|
|
867
|
+
description: "`execJobFunction` on the `workflow` value imported from @tailor-platform/sdk/runtime(/workflow) is removed in v3. Calling it directly from a workflow job body to reach another job is not detected as a build-time dependency and has no working use; the target job's own `.start()` method is the only supported way to call it. This does not affect the ambient `tailor.workflow.execJobFunction` global — that's what `.start()` itself compiles down to at build time, and it remains fully supported.",
|
|
868
|
+
since: "1.0.0",
|
|
869
|
+
until: "3.0.0",
|
|
870
|
+
filePatterns: ["**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}"],
|
|
871
|
+
suspiciousPatterns: ["execJobFunction"],
|
|
872
|
+
examples: [{
|
|
873
|
+
before: "import { workflow } from \"@tailor-platform/sdk/runtime\";\n\nawait workflow.execJobFunction(\"worker\", { id: 1 });",
|
|
874
|
+
after: "import { worker } from \"./jobs/worker\";\n\nawait worker.start({ id: 1 });"
|
|
875
|
+
}],
|
|
876
|
+
prompt: [
|
|
877
|
+
"workflow.execJobFunction — the value imported from",
|
|
878
|
+
"@tailor-platform/sdk/runtime or @tailor-platform/sdk/runtime/workflow — is",
|
|
879
|
+
"removed in v3. Replace each call with the target job's own .start() method:",
|
|
880
|
+
"import the WorkflowJob the call names and call <job>.start(args, options)",
|
|
881
|
+
"instead of workflow.execJobFunction(\"<job-name>\", args, options).",
|
|
882
|
+
"",
|
|
883
|
+
"This only removes the re-export from @tailor-platform/sdk/runtime. It does",
|
|
884
|
+
"not affect the ambient tailor.workflow.execJobFunction global, which stays",
|
|
885
|
+
"fully supported and is what .start() itself compiles down to at build time.",
|
|
886
|
+
"This codemod does not rewrite ambient tailor.workflow.execJobFunction(...)",
|
|
887
|
+
"call sites, since removing the import re-export does not affect them — but",
|
|
888
|
+
"if such a call site sits inside workflow job source and calls another job",
|
|
889
|
+
"by name, a separate build-time check already rejects it; migrate that call",
|
|
890
|
+
"to the target job's own .start() method too.",
|
|
891
|
+
"",
|
|
892
|
+
"If the job name passed to execJobFunction is not a string literal (a truly",
|
|
893
|
+
"dynamic dispatch), there is currently no supported replacement — .start()",
|
|
894
|
+
"only targets a statically known job. Flag this case for a human instead of",
|
|
895
|
+
"guessing a rewrite."
|
|
853
896
|
].join("\n")
|
|
854
897
|
},
|
|
855
898
|
{
|
|
@@ -1450,7 +1493,7 @@ const allCodemods = [
|
|
|
1450
1493
|
{
|
|
1451
1494
|
id: "v2/node-minimum-22-15-0",
|
|
1452
1495
|
name: "Node.js minimum version raised to 22.15.0",
|
|
1453
|
-
description: "v2 requires Node.js **22.15.0** or later. This is the first version that includes `module.registerHooks()`, which the SDK uses to register its TypeScript loader hook synchronously in the main thread. The actual floor is now **22.18.0**: Node 22.15.0–22.17.x has a bug
|
|
1496
|
+
description: "v2 requires Node.js **22.15.0** or later. This is the first version that includes `module.registerHooks()`, which the SDK uses to register its TypeScript loader hook synchronously in the main thread. The actual floor is now **22.18.0**: Node 22.15.0–22.17.x has a bug that crashes `tailor seed validate` when requiring `node:`-scheme-only builtins such as `node:sqlite`, fixed upstream by [nodejs/node#58612](https://github.com/nodejs/node/pull/58612) in 22.18.0. No source change is required; ensure your environment runs Node.js 22.18.0+.",
|
|
1454
1497
|
since: "1.0.0",
|
|
1455
1498
|
until: "2.0.0",
|
|
1456
1499
|
notice: true
|
|
@@ -1463,6 +1506,14 @@ const allCodemods = [
|
|
|
1463
1506
|
until: "2.0.0",
|
|
1464
1507
|
notice: true
|
|
1465
1508
|
},
|
|
1509
|
+
{
|
|
1510
|
+
id: "v2/tailordb-script-hash-migration-sync",
|
|
1511
|
+
name: "First v2 deploy to a v1-deployed environment needs migration sync",
|
|
1512
|
+
description: "The pre-v2 CLI never wrote a script hash into deployed schemas, so the first `tailor deploy` against an environment last deployed with it reports `Remote schema drift detected` with every scripted type showing `has no script hash on remote`. Run `tailor tailordb migration sync <current migration number>` once for that environment to write the missing hashes, then `tailor deploy` as usual. Preview/PR workspaces don't hit this, since they're built with v2 from the start. No source change is required.",
|
|
1513
|
+
since: "1.0.0",
|
|
1514
|
+
until: "2.0.0",
|
|
1515
|
+
notice: true
|
|
1516
|
+
},
|
|
1466
1517
|
{
|
|
1467
1518
|
id: "v2/dts-env-value-types",
|
|
1468
1519
|
name: "tailor.d.ts Env uses value types instead of literal values",
|
|
@@ -1525,6 +1576,36 @@ const allCodemods = [
|
|
|
1525
1576
|
"`function run`. Leave prose that merely mentions the old subcommand name",
|
|
1526
1577
|
"unchanged unless it documents a command to type."
|
|
1527
1578
|
].join("\n")
|
|
1579
|
+
},
|
|
1580
|
+
{
|
|
1581
|
+
id: "v3/setup-branch-flag-rename",
|
|
1582
|
+
name: "setup branch --branch → --target",
|
|
1583
|
+
description: "Rename the `--branch` option of `tailor setup branch` invocations to `--target`. `--branch` remains as a deprecated alias until it is removed in v3. The `--branch` option of `setup tag`, `setup preview`, and `setup coordinate` is unchanged.",
|
|
1584
|
+
since: "1.72.0",
|
|
1585
|
+
until: "3.0.0",
|
|
1586
|
+
scriptPath: "v3/setup-branch-flag-rename/scripts/transform.js",
|
|
1587
|
+
filePatterns: [
|
|
1588
|
+
"**/package.json",
|
|
1589
|
+
"**/*.{sh,bash,zsh,ps1,cmd,bat,yml,yaml}",
|
|
1590
|
+
"**/*.md",
|
|
1591
|
+
"**/*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}"
|
|
1592
|
+
],
|
|
1593
|
+
legacyPatterns: [SETUP_BRANCH_RESIDUAL_FLAG],
|
|
1594
|
+
sourceStringLegacyPatterns: [SETUP_BRANCH_RESIDUAL_FLAG],
|
|
1595
|
+
examples: [{
|
|
1596
|
+
lang: "sh",
|
|
1597
|
+
before: "tailor setup branch --name my-app-stg --branch main",
|
|
1598
|
+
after: "tailor setup branch --name my-app-stg --target main"
|
|
1599
|
+
}],
|
|
1600
|
+
prompt: [
|
|
1601
|
+
"The `--branch` option of `tailor setup branch` is renamed to `--target`;",
|
|
1602
|
+
"the old spelling is removed in v3. Replace any remaining `--branch` options of",
|
|
1603
|
+
"`setup branch` invocations the codemod did not rewrite (e.g. wrapped across",
|
|
1604
|
+
"lines or invoked through a package runner such as `npx @tailor-platform/sdk`)",
|
|
1605
|
+
"with `--target`. Do not touch the `--branch` option of `setup tag`,",
|
|
1606
|
+
"`setup preview`, or `setup coordinate`, which keeps its name, and leave prose",
|
|
1607
|
+
"that merely mentions the option unchanged unless it documents a command to type."
|
|
1608
|
+
].join("\n")
|
|
1528
1609
|
}
|
|
1529
1610
|
];
|
|
1530
1611
|
/**
|
|
@@ -2025,6 +2106,27 @@ function legacyPatternWarnings(relative, content, sourceStringContent, sourceTex
|
|
|
2025
2106
|
return [`${relative}: contains ${Array.from(found).join(", ")} but was not migrated automatically (rule: ${lt.id}). Manual migration may be needed.`];
|
|
2026
2107
|
});
|
|
2027
2108
|
}
|
|
2109
|
+
function lineRemapper(before, after) {
|
|
2110
|
+
const hunks = structuredPatch("", "", before, after, "", "", { context: 0 }).hunks;
|
|
2111
|
+
const lastLine = Math.max(1, after.split("\n").length - (after.endsWith("\n") ? 1 : 0));
|
|
2112
|
+
const map = (line) => {
|
|
2113
|
+
let offset = 0;
|
|
2114
|
+
for (const hunk of hunks) {
|
|
2115
|
+
if (line < hunk.oldStart) break;
|
|
2116
|
+
if (hunk.oldLines === 0) {
|
|
2117
|
+
offset += hunk.newLines;
|
|
2118
|
+
continue;
|
|
2119
|
+
}
|
|
2120
|
+
if (line < hunk.oldStart + hunk.oldLines) {
|
|
2121
|
+
if (hunk.newLines === 0) return hunk.newStart;
|
|
2122
|
+
return Math.min(hunk.newStart + (line - hunk.oldStart), hunk.newStart + hunk.newLines - 1);
|
|
2123
|
+
}
|
|
2124
|
+
offset += hunk.newLines - hunk.oldLines;
|
|
2125
|
+
}
|
|
2126
|
+
return line + offset;
|
|
2127
|
+
};
|
|
2128
|
+
return (line) => Math.min(lastLine, Math.max(1, map(line)));
|
|
2129
|
+
}
|
|
2028
2130
|
function compareReviewFindings(a, b) {
|
|
2029
2131
|
return a.file.localeCompare(b.file) || a.line - b.line || a.message.localeCompare(b.message) || a.excerpt.localeCompare(b.excerpt);
|
|
2030
2132
|
}
|
|
@@ -2032,6 +2134,9 @@ function compareReviewFindings(a, b) {
|
|
|
2032
2134
|
* Run multiple codemods on a project directory using in-memory chaining.
|
|
2033
2135
|
* Each file is processed through all transforms whose filePatterns match it.
|
|
2034
2136
|
* Later transforms see earlier transforms' output — even in dry-run mode.
|
|
2137
|
+
* Review detection (reviewFindings and suspicious patterns) runs against each
|
|
2138
|
+
* codemod's own position in the transform chain, so a later codemod's rewrite
|
|
2139
|
+
* cannot hide an earlier codemod's findings.
|
|
2035
2140
|
*
|
|
2036
2141
|
* In dry-run mode, colorized diffs are printed to stderr.
|
|
2037
2142
|
* @param codemods - Codemod packages to run (with resolved script paths)
|
|
@@ -2077,25 +2182,41 @@ async function runCodemods(codemods, targetPath, dryRun) {
|
|
|
2077
2182
|
continue;
|
|
2078
2183
|
}
|
|
2079
2184
|
let current = original;
|
|
2185
|
+
const reviewTargets = [];
|
|
2080
2186
|
for (const lt of matchedTransforms) {
|
|
2081
|
-
if (
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2187
|
+
if (lt.transform) {
|
|
2188
|
+
const result = await lt.transform(current, absolute);
|
|
2189
|
+
if (result != null) {
|
|
2190
|
+
current = result;
|
|
2191
|
+
appliedCodemodIds.add(lt.id);
|
|
2192
|
+
}
|
|
2086
2193
|
}
|
|
2194
|
+
if (lt.prompt) reviewTargets.push({
|
|
2195
|
+
lt,
|
|
2196
|
+
snapshot: current
|
|
2197
|
+
});
|
|
2087
2198
|
}
|
|
2088
2199
|
if (current !== original) {
|
|
2089
2200
|
filesModified.push(absolute);
|
|
2090
2201
|
if (dryRun) printDiff(absolute, original, current);
|
|
2091
2202
|
else await fs.promises.writeFile(absolute, current, "utf-8");
|
|
2092
2203
|
}
|
|
2093
|
-
const
|
|
2094
|
-
const
|
|
2204
|
+
const residualBySnapshot = /* @__PURE__ */ new Map();
|
|
2205
|
+
const residualFor = (content) => {
|
|
2206
|
+
let entry = residualBySnapshot.get(content);
|
|
2207
|
+
if (!entry) {
|
|
2208
|
+
entry = {
|
|
2209
|
+
residual: contentForResidualMatching(relative, content),
|
|
2210
|
+
sourceString: sourceStringContentForResidualMatching(relative, content)
|
|
2211
|
+
};
|
|
2212
|
+
residualBySnapshot.set(content, entry);
|
|
2213
|
+
}
|
|
2214
|
+
return entry;
|
|
2215
|
+
};
|
|
2216
|
+
const { residual: residualContent, sourceString: sourceStringContent } = residualFor(current);
|
|
2095
2217
|
const sourceTextContent = sourceTextContentForResidualMatching(relative, current);
|
|
2096
2218
|
warnings.push(...legacyPatternWarnings(relative, residualContent, sourceStringContent, sourceTextContent, matchedTransforms));
|
|
2097
|
-
for (const lt of
|
|
2098
|
-
if (!lt.prompt) continue;
|
|
2219
|
+
for (const { lt, snapshot } of reviewTargets) {
|
|
2099
2220
|
const filesForReview = () => {
|
|
2100
2221
|
let files = suspiciousByCodemod.get(lt.id);
|
|
2101
2222
|
if (!files) {
|
|
@@ -2105,7 +2226,14 @@ async function runCodemods(codemods, targetPath, dryRun) {
|
|
|
2105
2226
|
return files;
|
|
2106
2227
|
};
|
|
2107
2228
|
if (lt.reviewFindings) {
|
|
2108
|
-
|
|
2229
|
+
let findings = await lt.reviewFindings(snapshot, absolute, relative);
|
|
2230
|
+
if (snapshot !== current && findings.length > 0) {
|
|
2231
|
+
const remap = lineRemapper(snapshot, current);
|
|
2232
|
+
findings = findings.map((finding) => ({
|
|
2233
|
+
...finding,
|
|
2234
|
+
line: remap(finding.line)
|
|
2235
|
+
}));
|
|
2236
|
+
}
|
|
2109
2237
|
if (findings.length > 0) {
|
|
2110
2238
|
const files = filesForReview();
|
|
2111
2239
|
for (const finding of findings) files.add(finding.file);
|
|
@@ -2117,7 +2245,9 @@ async function runCodemods(codemods, targetPath, dryRun) {
|
|
|
2117
2245
|
existing.push(...findings);
|
|
2118
2246
|
}
|
|
2119
2247
|
}
|
|
2120
|
-
if (lt.suspiciousPatterns.
|
|
2248
|
+
if (lt.suspiciousPatterns.length === 0 && lt.sourceStringSuspiciousPatterns.length === 0) continue;
|
|
2249
|
+
const { residual, sourceString } = residualFor(snapshot);
|
|
2250
|
+
if (lt.suspiciousPatterns.some((p) => matchResidualPattern(residual, p) !== null) || sourceString != null && lt.sourceStringSuspiciousPatterns.some((p) => matchResidualPattern(sourceString, p) !== null)) filesForReview().add(relative);
|
|
2121
2251
|
}
|
|
2122
2252
|
}
|
|
2123
2253
|
const llmReviews = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/sdk-codemod",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Codemod runner for Tailor Platform SDK upgrades",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"@types/picomatch": "4.0.3",
|
|
31
31
|
"@types/semver": "7.8.0",
|
|
32
32
|
"eslint-plugin-zod": "4.9.1",
|
|
33
|
-
"oxlint": "1.
|
|
33
|
+
"oxlint": "1.78.0",
|
|
34
|
+
"oxlint-tsgolint": "7.0.2001",
|
|
34
35
|
"tsdown": "0.22.14",
|
|
35
36
|
"typescript": "6.0.3",
|
|
36
37
|
"vitest": "4.1.10",
|
|
@@ -42,8 +43,9 @@
|
|
|
42
43
|
},
|
|
43
44
|
"scripts": {
|
|
44
45
|
"build": "tsdown",
|
|
45
|
-
"lint": "oxlint .",
|
|
46
|
-
"lint:fix": "oxlint . --fix",
|
|
46
|
+
"lint": "oxlint --type-aware .",
|
|
47
|
+
"lint:fix": "oxlint --type-aware . --fix",
|
|
48
|
+
"knip": "knip",
|
|
47
49
|
"typecheck": "tsc --noEmit",
|
|
48
50
|
"test": "vitest",
|
|
49
51
|
"prepublish": "pnpm run build",
|