@tailor-platform/sdk-codemod 0.1.0 → 0.1.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 +17 -0
- package/LICENSE +21 -0
- package/dist/index.js +22 -12
- package/package.json +21 -21
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @tailor-platform/sdk-codemod
|
|
2
|
+
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1001](https://github.com/tailor-platform/sdk/pull/1001) [`2fd4b33`](https://github.com/tailor-platform/sdk/commit/2fd4b33c3c4a02e7adc4b1f52d716a1a97ffb7ec) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): pin dependency @ast-grep/napi to 0.42.1
|
|
8
|
+
|
|
9
|
+
- [#1003](https://github.com/tailor-platform/sdk/pull/1003) [`66eed51`](https://github.com/tailor-platform/sdk/commit/66eed51a93eec10898250ec625953a5c5a3ec7a1) Thanks [@renovate](https://github.com/apps/renovate)! - chore(deps): update dependency @types/picomatch to v4.0.3
|
|
10
|
+
|
|
11
|
+
- [#1009](https://github.com/tailor-platform/sdk/pull/1009) [`874d709`](https://github.com/tailor-platform/sdk/commit/874d70949c35283e6a015725434cf9a799439e96) Thanks [@renovate](https://github.com/apps/renovate)! - fix(deps): update dependency diff to v9
|
|
12
|
+
|
|
13
|
+
## 0.1.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#941](https://github.com/tailor-platform/sdk/pull/941) [`0a1b538`](https://github.com/tailor-platform/sdk/commit/0a1b53886ac738347e0e7fcb4f94e4c713fad316) Thanks [@toiroakr](https://github.com/toiroakr)! - Add `upgrade` command with codemod.com-based architecture for automated SDK version migrations. Codemod execution is handled by the new `@tailor-platform/sdk-codemod` package.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2025 Tailor Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,8 @@ const allCodemods = [{
|
|
|
19
19
|
description: "Migrate defineGenerators() tuple syntax to definePlugins() with explicit plugin imports",
|
|
20
20
|
since: "1.0.0",
|
|
21
21
|
until: "2.0.0",
|
|
22
|
-
scriptPath: "v2/define-generators-to-plugins/scripts/transform.js"
|
|
22
|
+
scriptPath: "v2/define-generators-to-plugins/scripts/transform.js",
|
|
23
|
+
legacyPatterns: ["defineGenerators"]
|
|
23
24
|
}];
|
|
24
25
|
/**
|
|
25
26
|
* Resolve the absolute path to a codemod script.
|
|
@@ -98,13 +99,15 @@ async function runCodemods(codemods, targetPath, dryRun) {
|
|
|
98
99
|
loaded.push({
|
|
99
100
|
id: codemod.id,
|
|
100
101
|
transform: await loadTransform(scriptPath),
|
|
101
|
-
matches: picomatch(patterns)
|
|
102
|
+
matches: picomatch(patterns),
|
|
103
|
+
legacyPatterns: codemod.legacyPatterns ?? []
|
|
102
104
|
});
|
|
103
105
|
}
|
|
104
106
|
const allPatterns = /* @__PURE__ */ new Set();
|
|
105
107
|
for (const { codemod } of codemods) for (const p of codemod.filePatterns ?? DEFAULT_FILE_PATTERNS) allPatterns.add(p);
|
|
106
108
|
const filesModified = [];
|
|
107
109
|
const warnings = [];
|
|
110
|
+
const appliedCodemodIds = /* @__PURE__ */ new Set();
|
|
108
111
|
const seen = /* @__PURE__ */ new Set();
|
|
109
112
|
for (const pattern of allPatterns) for await (const relative of glob(pattern, {
|
|
110
113
|
cwd: targetPath,
|
|
@@ -120,23 +123,30 @@ async function runCodemods(codemods, targetPath, dryRun) {
|
|
|
120
123
|
continue;
|
|
121
124
|
}
|
|
122
125
|
let current = original;
|
|
123
|
-
const
|
|
124
|
-
for (const
|
|
125
|
-
if (!matches(relative)) continue;
|
|
126
|
-
|
|
127
|
-
const result = await transform(current, absolute);
|
|
128
|
-
if (result != null)
|
|
126
|
+
const matchedTransforms = [];
|
|
127
|
+
for (const lt of loaded) {
|
|
128
|
+
if (!lt.matches(relative)) continue;
|
|
129
|
+
matchedTransforms.push(lt);
|
|
130
|
+
const result = await lt.transform(current, absolute);
|
|
131
|
+
if (result != null) {
|
|
132
|
+
current = result;
|
|
133
|
+
appliedCodemodIds.add(lt.id);
|
|
134
|
+
}
|
|
129
135
|
}
|
|
130
136
|
if (current !== original) {
|
|
131
137
|
filesModified.push(absolute);
|
|
132
138
|
if (dryRun) printDiff(absolute, original, current);
|
|
133
139
|
else await fs.promises.writeFile(absolute, current, "utf-8");
|
|
134
|
-
} else
|
|
140
|
+
} else for (const lt of matchedTransforms) {
|
|
141
|
+
const found = lt.legacyPatterns.filter((p) => original.includes(p));
|
|
142
|
+
if (found.length > 0) warnings.push(`${relative}: contains ${found.join(", ")} but was not migrated automatically (rule: ${lt.id}). Manual migration may be needed.`);
|
|
143
|
+
}
|
|
135
144
|
}
|
|
136
145
|
return {
|
|
137
146
|
changed: filesModified.length > 0,
|
|
138
147
|
filesModified,
|
|
139
|
-
warnings
|
|
148
|
+
warnings,
|
|
149
|
+
appliedCodemodIds
|
|
140
150
|
};
|
|
141
151
|
}
|
|
142
152
|
//#endregion
|
|
@@ -176,8 +186,8 @@ runMain(defineCommand({
|
|
|
176
186
|
for (const { codemod } of codemodEntries) process.stderr.write(`Running: ${codemod.name} - ${codemod.description}\n`);
|
|
177
187
|
try {
|
|
178
188
|
const result = await runCodemods(codemodEntries, targetPath, dryRun);
|
|
179
|
-
output.codemodsApplied = result.
|
|
180
|
-
output.codemodsSkipped =
|
|
189
|
+
output.codemodsApplied = result.appliedCodemodIds.size;
|
|
190
|
+
output.codemodsSkipped = codemods.length - result.appliedCodemodIds.size;
|
|
181
191
|
output.filesModified = result.filesModified;
|
|
182
192
|
output.warnings = result.warnings;
|
|
183
193
|
if (result.changed) process.stderr.write(` ${result.filesModified.length} file(s) modified\n`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tailor-platform/sdk-codemod",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Codemod runner for Tailor Platform SDK upgrades",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,37 +16,37 @@
|
|
|
16
16
|
"README.md"
|
|
17
17
|
],
|
|
18
18
|
"type": "module",
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsdown",
|
|
21
|
-
"lint": "oxlint . && eslint --cache .",
|
|
22
|
-
"lint:fix": "oxlint --fix . && eslint --cache --fix .",
|
|
23
|
-
"typecheck": "tsc --noEmit",
|
|
24
|
-
"test": "vitest",
|
|
25
|
-
"prepublish": "pnpm run build",
|
|
26
|
-
"publint": "publint --strict"
|
|
27
|
-
},
|
|
28
19
|
"dependencies": {
|
|
29
|
-
"@ast-grep/napi": "
|
|
20
|
+
"@ast-grep/napi": "0.42.1",
|
|
30
21
|
"chalk": "5.6.2",
|
|
31
|
-
"diff": "
|
|
22
|
+
"diff": "9.0.0",
|
|
32
23
|
"pathe": "2.0.3",
|
|
33
24
|
"picomatch": "4.0.4",
|
|
34
25
|
"pkg-types": "2.3.0",
|
|
35
|
-
"politty": "0.4.
|
|
26
|
+
"politty": "0.4.13",
|
|
36
27
|
"semver": "7.7.4",
|
|
37
28
|
"zod": "4.3.6"
|
|
38
29
|
},
|
|
39
30
|
"devDependencies": {
|
|
40
31
|
"@eslint/js": "10.0.1",
|
|
41
|
-
"@types/node": "24.12.
|
|
42
|
-
"@types/picomatch": "4.0.
|
|
32
|
+
"@types/node": "24.12.2",
|
|
33
|
+
"@types/picomatch": "4.0.3",
|
|
43
34
|
"@types/semver": "7.7.1",
|
|
44
|
-
"eslint": "10.
|
|
45
|
-
"eslint-plugin-oxlint": "1.
|
|
46
|
-
"oxlint": "1.
|
|
47
|
-
"tsdown": "0.21.
|
|
35
|
+
"eslint": "10.2.0",
|
|
36
|
+
"eslint-plugin-oxlint": "1.60.0",
|
|
37
|
+
"oxlint": "1.60.0",
|
|
38
|
+
"tsdown": "0.21.8",
|
|
48
39
|
"typescript": "5.9.3",
|
|
49
|
-
"typescript-eslint": "8.
|
|
40
|
+
"typescript-eslint": "8.58.2",
|
|
50
41
|
"vitest": "4.1.2"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsdown",
|
|
45
|
+
"lint": "oxlint . && eslint --cache .",
|
|
46
|
+
"lint:fix": "oxlint --fix . && eslint --cache --fix .",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"test": "vitest",
|
|
49
|
+
"prepublish": "pnpm run build",
|
|
50
|
+
"publint": "publint --strict"
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
}
|