@mastra/codemod 0.0.0-span-scorring-test-20251124132129 → 0.0.0-top-level-fix-20251211103030
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 -1
- package/README.md +1 -0
- package/dist/codemods/v1/not-implemented/mastra-required-id.js +49 -66
- package/dist/codemods/v1/not-implemented/mastra-required-id.js.map +1 -1
- package/dist/codemods/v1/workflow-stream-vnext.js +36 -0
- package/dist/codemods/v1/workflow-stream-vnext.js.map +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @mastra/codemod
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-top-level-fix-20251211103030
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -8,12 +8,28 @@
|
|
|
8
8
|
|
|
9
9
|
### Patch Changes
|
|
10
10
|
|
|
11
|
+
- Fixed a bug where `[native code]` was incorrectly added to the output ([#10971](https://github.com/mastra-ai/mastra/pull/10971))
|
|
12
|
+
|
|
13
|
+
- Add `v1/workflow-stream-vnext` codemod. This codemod renames `streamVNext()`, `resumeStreamVNext()`, and `observeStreamVNext()` to their "non-VNext" counterparts. ([#10802](https://github.com/mastra-ai/mastra/pull/10802))
|
|
14
|
+
|
|
11
15
|
- Fix `mastra-required-id`, `mcp-get-toolsets`, and `mcp-get-tools` codemods to add missing imports and instances. ([#10221](https://github.com/mastra-ai/mastra/pull/10221))
|
|
12
16
|
|
|
13
17
|
- - Improve existing codemods ([#9959](https://github.com/mastra-ai/mastra/pull/9959))
|
|
14
18
|
- Make package ESM-only
|
|
15
19
|
- Add new codemods
|
|
16
20
|
|
|
21
|
+
## 0.1.0-beta.4
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Fixed a bug where `[native code]` was incorrectly added to the output ([#10971](https://github.com/mastra-ai/mastra/pull/10971))
|
|
26
|
+
|
|
27
|
+
## 0.1.0-beta.3
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Add `v1/workflow-stream-vnext` codemod. This codemod renames `streamVNext()`, `resumeStreamVNext()`, and `observeStreamVNext()` to their "non-VNext" counterparts. ([#10802](https://github.com/mastra-ai/mastra/pull/10802))
|
|
32
|
+
|
|
17
33
|
## 0.1.0-beta.2
|
|
18
34
|
|
|
19
35
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -70,6 +70,7 @@ npx @mastra/codemod@beta v1/mastra-core-imports .
|
|
|
70
70
|
| `v1/workflow-create-run-async` | Renames `workflow.createRunAsync()` → `workflow.createRun()` |
|
|
71
71
|
| `v1/workflow-list-runs` | Renames `workflow.getWorkflowRuns()` → `workflow.listWorkflowRuns()` |
|
|
72
72
|
| `v1/workflow-run-count` | Renames `context.runCount` → `context.retryCount` in step execution functions |
|
|
73
|
+
| `v1/workflow-stream-vnext` | Renames `streamVNext()`, `resumeStreamVNext()`, and `observeStreamVNext()` |
|
|
73
74
|
|
|
74
75
|
## CLI Options
|
|
75
76
|
|
|
@@ -9,6 +9,14 @@ import {
|
|
|
9
9
|
var mastra_required_id_default = createTransformer((fileInfo, api, options, context) => {
|
|
10
10
|
const { j, root } = context;
|
|
11
11
|
const COMMENT_MESSAGE = "FIXME(mastra): Add a unique `id` parameter. See: https://mastra.ai/guides/v1/migrations/upgrade-to-v1/mastra#required-id-parameter-for-all-mastra-primitives";
|
|
12
|
+
const STATEMENT_TYPES = /* @__PURE__ */ new Set([
|
|
13
|
+
"VariableDeclaration",
|
|
14
|
+
"ExpressionStatement",
|
|
15
|
+
"ReturnStatement",
|
|
16
|
+
"ExportDefaultDeclaration",
|
|
17
|
+
"ExportNamedDeclaration",
|
|
18
|
+
"Program"
|
|
19
|
+
]);
|
|
12
20
|
const storageClasses = [
|
|
13
21
|
"LibSQLStore",
|
|
14
22
|
"PostgresStore",
|
|
@@ -25,81 +33,56 @@ var mastra_required_id_default = createTransformer((fileInfo, api, options, cont
|
|
|
25
33
|
"MCPServer"
|
|
26
34
|
];
|
|
27
35
|
const createFunctions = ["createWorkflow", "createTool", "createScorer"];
|
|
36
|
+
function hasIdProperty(args) {
|
|
37
|
+
return args.some((arg) => {
|
|
38
|
+
if (arg.type === "ObjectExpression") {
|
|
39
|
+
return arg.properties?.some(
|
|
40
|
+
(prop) => (prop.type === "Property" || prop.type === "ObjectProperty") && prop.key?.type === "Identifier" && prop.key.name === "id"
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function addCommentToAppropriateNode(path) {
|
|
47
|
+
let parent = path.parent;
|
|
48
|
+
if (parent?.value && (parent.value.type === "Property" || parent.value.type === "ObjectProperty")) {
|
|
49
|
+
if (insertCommentOnce(parent.value, j, COMMENT_MESSAGE)) {
|
|
50
|
+
context.hasChanges = true;
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (parent?.value?.type === "ArrayExpression") {
|
|
55
|
+
if (insertCommentOnce(path.value, j, COMMENT_MESSAGE)) {
|
|
56
|
+
context.hasChanges = true;
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
while (parent && !STATEMENT_TYPES.has(parent.value.type)) {
|
|
61
|
+
parent = parent.parent;
|
|
62
|
+
}
|
|
63
|
+
if (parent?.value) {
|
|
64
|
+
let targetNode = parent.value;
|
|
65
|
+
if (targetNode.type !== "ExportDefaultDeclaration" && targetNode.type !== "ExportNamedDeclaration" && parent.parent && (parent.parent.value.type === "ExportDefaultDeclaration" || parent.parent.value.type === "ExportNamedDeclaration")) {
|
|
66
|
+
targetNode = parent.parent.value;
|
|
67
|
+
}
|
|
68
|
+
if (insertCommentOnce(targetNode, j, COMMENT_MESSAGE)) {
|
|
69
|
+
context.hasChanges = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
28
73
|
root.find(j.NewExpression).forEach((path) => {
|
|
29
74
|
if (path.value.callee.type === "Identifier") {
|
|
30
75
|
const className = path.value.callee.name;
|
|
31
|
-
if (storageClasses.includes(className)) {
|
|
32
|
-
|
|
33
|
-
if (arg.type === "ObjectExpression") {
|
|
34
|
-
return arg.properties?.some(
|
|
35
|
-
(prop) => (prop.type === "Property" || prop.type === "ObjectProperty") && prop.key?.type === "Identifier" && prop.key.name === "id"
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
return false;
|
|
39
|
-
});
|
|
40
|
-
if (!hasId) {
|
|
41
|
-
let parent = path.parent;
|
|
42
|
-
const statementTypes = /* @__PURE__ */ new Set([
|
|
43
|
-
"VariableDeclaration",
|
|
44
|
-
"ExpressionStatement",
|
|
45
|
-
"ReturnStatement",
|
|
46
|
-
"ExportDefaultDeclaration",
|
|
47
|
-
"ExportNamedDeclaration",
|
|
48
|
-
"Program"
|
|
49
|
-
]);
|
|
50
|
-
while (parent && !statementTypes.has(parent.value.type)) {
|
|
51
|
-
parent = parent.parent;
|
|
52
|
-
}
|
|
53
|
-
if (parent && parent.value) {
|
|
54
|
-
let targetNode = parent.value;
|
|
55
|
-
if (targetNode.type !== "ExportDefaultDeclaration" && targetNode.type !== "ExportNamedDeclaration" && parent.parent && (parent.parent.value.type === "ExportDefaultDeclaration" || parent.parent.value.type === "ExportNamedDeclaration")) {
|
|
56
|
-
targetNode = parent.parent.value;
|
|
57
|
-
}
|
|
58
|
-
const added = insertCommentOnce(targetNode, j, COMMENT_MESSAGE);
|
|
59
|
-
if (added) {
|
|
60
|
-
context.hasChanges = true;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
76
|
+
if (storageClasses.includes(className) && !hasIdProperty(path.value.arguments)) {
|
|
77
|
+
addCommentToAppropriateNode(path);
|
|
64
78
|
}
|
|
65
79
|
}
|
|
66
80
|
});
|
|
67
81
|
root.find(j.CallExpression).forEach((path) => {
|
|
68
82
|
if (path.value.callee.type === "Identifier") {
|
|
69
83
|
const functionName = path.value.callee.name;
|
|
70
|
-
if (createFunctions.includes(functionName)) {
|
|
71
|
-
|
|
72
|
-
if (arg.type === "ObjectExpression") {
|
|
73
|
-
return arg.properties?.some(
|
|
74
|
-
(prop) => (prop.type === "Property" || prop.type === "ObjectProperty") && prop.key?.type === "Identifier" && prop.key.name === "id"
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
return false;
|
|
78
|
-
});
|
|
79
|
-
if (!hasId) {
|
|
80
|
-
let parent = path.parent;
|
|
81
|
-
const statementTypes = /* @__PURE__ */ new Set([
|
|
82
|
-
"VariableDeclaration",
|
|
83
|
-
"ExpressionStatement",
|
|
84
|
-
"ReturnStatement",
|
|
85
|
-
"ExportDefaultDeclaration",
|
|
86
|
-
"ExportNamedDeclaration",
|
|
87
|
-
"Program"
|
|
88
|
-
]);
|
|
89
|
-
while (parent && !statementTypes.has(parent.value.type)) {
|
|
90
|
-
parent = parent.parent;
|
|
91
|
-
}
|
|
92
|
-
if (parent && parent.value) {
|
|
93
|
-
let targetNode = parent.value;
|
|
94
|
-
if (targetNode.type !== "ExportDefaultDeclaration" && targetNode.type !== "ExportNamedDeclaration" && parent.parent && (parent.parent.value.type === "ExportDefaultDeclaration" || parent.parent.value.type === "ExportNamedDeclaration")) {
|
|
95
|
-
targetNode = parent.parent.value;
|
|
96
|
-
}
|
|
97
|
-
const added = insertCommentOnce(targetNode, j, COMMENT_MESSAGE);
|
|
98
|
-
if (added) {
|
|
99
|
-
context.hasChanges = true;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
84
|
+
if (createFunctions.includes(functionName) && !hasIdProperty(path.value.arguments)) {
|
|
85
|
+
addCommentToAppropriateNode(path);
|
|
103
86
|
}
|
|
104
87
|
}
|
|
105
88
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/codemods/v1/not-implemented/mastra-required-id.ts"],"sourcesContent":["/* eslint-disable no-warning-comments */\nimport { insertCommentOnce } from '../../lib/add-comment';\nimport { createTransformer } from '../../lib/create-transformer';\n\n/**\n * Adds FIXME comments to Mastra primitives that now require an `id` parameter.\n * This includes storages, vector stores, agents, workflows, tools, scorers, and MCP servers.\n *\n * Before:\n * const agent = new Agent({ name: 'Support Agent' });\n * const tool = createTool({ description: 'Get weather' });\n *\n * After:\n * /* FIXME(mastra): Add a unique `id` parameter. See: ... *\\/\n * const agent = new Agent({ name: 'Support Agent' });\n * /* FIXME(mastra): Add a unique `id` parameter. See: ... *\\/\n * const tool = createTool({ description: 'Get weather' });\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n const COMMENT_MESSAGE =\n 'FIXME(mastra): Add a unique `id` parameter. See: https://mastra.ai/guides/v1/migrations/upgrade-to-v1/mastra#required-id-parameter-for-all-mastra-primitives';\n\n // List of class names that require id\n const storageClasses = [\n 'LibSQLStore',\n 'PostgresStore',\n 'D1Store',\n 'MongoDBStore',\n 'DynamoDBStore',\n 'LibSQLVector',\n 'PgVector',\n 'ChromaVector',\n 'PineconeVector',\n 'QdrantVector',\n 'LanceVector',\n 'Agent',\n 'MCPServer',\n ];\n\n // List of function names that require id\n const createFunctions = ['createWorkflow', 'createTool', 'createScorer'];\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../src/codemods/v1/not-implemented/mastra-required-id.ts"],"sourcesContent":["/* eslint-disable no-warning-comments */\nimport type { ASTPath } from 'jscodeshift';\n\nimport { insertCommentOnce } from '../../lib/add-comment';\nimport { createTransformer } from '../../lib/create-transformer';\n\n/**\n * Adds FIXME comments to Mastra primitives that now require an `id` parameter.\n * This includes storages, vector stores, agents, workflows, tools, scorers, and MCP servers.\n *\n * Before:\n * const agent = new Agent({ name: 'Support Agent' });\n * const tool = createTool({ description: 'Get weather' });\n *\n * After:\n * /* FIXME(mastra): Add a unique `id` parameter. See: ... *\\/\n * const agent = new Agent({ name: 'Support Agent' });\n * /* FIXME(mastra): Add a unique `id` parameter. See: ... *\\/\n * const tool = createTool({ description: 'Get weather' });\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n const COMMENT_MESSAGE =\n 'FIXME(mastra): Add a unique `id` parameter. See: https://mastra.ai/guides/v1/migrations/upgrade-to-v1/mastra#required-id-parameter-for-all-mastra-primitives';\n\n const STATEMENT_TYPES = new Set([\n 'VariableDeclaration',\n 'ExpressionStatement',\n 'ReturnStatement',\n 'ExportDefaultDeclaration',\n 'ExportNamedDeclaration',\n 'Program',\n ]);\n\n // List of class names that require id\n const storageClasses = [\n 'LibSQLStore',\n 'PostgresStore',\n 'D1Store',\n 'MongoDBStore',\n 'DynamoDBStore',\n 'LibSQLVector',\n 'PgVector',\n 'ChromaVector',\n 'PineconeVector',\n 'QdrantVector',\n 'LanceVector',\n 'Agent',\n 'MCPServer',\n ];\n\n // List of function names that require id\n const createFunctions = ['createWorkflow', 'createTool', 'createScorer'];\n\n /**\n * Checks if an expression's arguments contain an object with an 'id' property\n */\n function hasIdProperty(args: ASTPath<any>['value']['arguments']): boolean {\n return args.some((arg: ASTPath<any>['value']) => {\n if (arg.type === 'ObjectExpression') {\n return arg.properties?.some(\n (prop: ASTPath<any>['value']) =>\n (prop.type === 'Property' || prop.type === 'ObjectProperty') &&\n prop.key?.type === 'Identifier' &&\n prop.key.name === 'id',\n );\n }\n return false;\n });\n }\n\n /**\n * Adds a FIXME comment to the appropriate node based on the expression's context.\n * - If nested in an object property, adds comment to the property\n * - If nested in an array, adds comment to the expression itself\n * - Otherwise, walks up to find the parent statement and adds comment there\n */\n function addCommentToAppropriateNode(path: ASTPath<any>): void {\n let parent = path.parent;\n\n // If the direct parent is an object property, add comment to that property\n if (parent?.value && (parent.value.type === 'Property' || parent.value.type === 'ObjectProperty')) {\n if (insertCommentOnce(parent.value, j, COMMENT_MESSAGE)) {\n context.hasChanges = true;\n }\n return;\n }\n\n // If the parent is an array, add comment directly to the expression\n if (parent?.value?.type === 'ArrayExpression') {\n if (insertCommentOnce(path.value, j, COMMENT_MESSAGE)) {\n context.hasChanges = true;\n }\n return;\n }\n\n // Find the parent statement to add comment\n while (parent && !STATEMENT_TYPES.has(parent.value.type)) {\n parent = parent.parent;\n }\n\n if (parent?.value) {\n // For export declarations, add comment to the export itself\n let targetNode = parent.value;\n if (\n targetNode.type !== 'ExportDefaultDeclaration' &&\n targetNode.type !== 'ExportNamedDeclaration' &&\n parent.parent &&\n (parent.parent.value.type === 'ExportDefaultDeclaration' ||\n parent.parent.value.type === 'ExportNamedDeclaration')\n ) {\n targetNode = parent.parent.value;\n }\n\n if (insertCommentOnce(targetNode, j, COMMENT_MESSAGE)) {\n context.hasChanges = true;\n }\n }\n }\n\n // Find NewExpression for classes\n root.find(j.NewExpression).forEach(path => {\n if (path.value.callee.type === 'Identifier') {\n const className = path.value.callee.name;\n\n if (storageClasses.includes(className) && !hasIdProperty(path.value.arguments)) {\n addCommentToAppropriateNode(path);\n }\n }\n });\n\n // Find CallExpression for create functions\n root.find(j.CallExpression).forEach(path => {\n if (path.value.callee.type === 'Identifier') {\n const functionName = path.value.callee.name;\n\n if (createFunctions.includes(functionName) && !hasIdProperty(path.value.arguments)) {\n addCommentToAppropriateNode(path);\n }\n }\n });\n\n if (context.hasChanges) {\n context.messages.push(`Not Implemented ${fileInfo.path}: Mastra primitives now require a unique id parameter.`);\n }\n});\n"],"mappings":";;;;;;;;AAoBA,IAAO,6BAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAEpB,QAAM,kBACJ;AAEF,QAAM,kBAAkB,oBAAI,IAAI;AAAA,IAC9B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAGD,QAAM,iBAAiB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA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AE,QAAQ,UAAQ;AACzC,QAAI,KAAK,MAAM,OAAO,SAAS,cAAc;AAC3C,YAAM,YAAY,KAAK,MAAM,OAAO;AAEpC,UAAI,eAAe,SAAS,SAAS,KAAK,CAAC,cAAc,KAAK,MAAM,SAAS,GAAG;AAC9E,oCAA4B,IAAI;AAAA,MAClC;AAAA,IACF;AAAA,EACF,CAAC;AAGD,OAAK,KAAK,EAAE,cAAc,EAAE,QAAQ,UAAQ;AAC1C,QAAI,KAAK,MAAM,OAAO,SAAS,cAAc;AAC3C,YAAM,eAAe,KAAK,MAAM,OAAO;AAEvC,UAAI,gBAAgB,SAAS,YAAY,KAAK,CAAC,cAAc,KAAK,MAAM,SAAS,GAAG;AAClF,oCAA4B,IAAI;AAAA,MAClC;AAAA,IACF;AAAA,EACF,CAAC;AAED,MAAI,QAAQ,YAAY;AACtB,YAAQ,SAAS,KAAK,mBAAmB,SAAS,IAAI,wDAAwD;AAAA,EAChH;AACF,CAAC;","names":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransformer
|
|
3
|
+
} from "../chunk-JNFQ6J6B.js";
|
|
4
|
+
|
|
5
|
+
// src/codemods/v1/workflow-stream-vnext.ts
|
|
6
|
+
var workflow_stream_vnext_default = createTransformer((fileInfo, api, options, context) => {
|
|
7
|
+
const { j, root } = context;
|
|
8
|
+
const methodRenames = {
|
|
9
|
+
streamVNext: "stream",
|
|
10
|
+
resumeStreamVNext: "resumeStream",
|
|
11
|
+
observeStreamVNext: "observeStream"
|
|
12
|
+
};
|
|
13
|
+
let count = 0;
|
|
14
|
+
root.find(j.CallExpression).forEach((path) => {
|
|
15
|
+
const { callee } = path.value;
|
|
16
|
+
if (callee.type !== "MemberExpression") return;
|
|
17
|
+
if (callee.property.type !== "Identifier") return;
|
|
18
|
+
const oldName = callee.property.name;
|
|
19
|
+
if (!Object.hasOwn(methodRenames, oldName)) return;
|
|
20
|
+
const newName = methodRenames[oldName];
|
|
21
|
+
if (newName) {
|
|
22
|
+
callee.property.name = newName;
|
|
23
|
+
count++;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
if (count > 0) {
|
|
27
|
+
context.hasChanges = true;
|
|
28
|
+
context.messages.push(
|
|
29
|
+
`Renamed workflow run VNext methods: streamVNext/resumeStreamVNext/observeStreamVNext \u2192 stream/resumeStream/observeStream`
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
export {
|
|
34
|
+
workflow_stream_vnext_default as default
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=workflow-stream-vnext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/codemods/v1/workflow-stream-vnext.ts"],"sourcesContent":["import { createTransformer } from '../lib/create-transformer';\n\n/**\n * Transforms workflow run VNext methods to their standard names:\n * - run.streamVNext() → run.stream()\n * - run.resumeStreamVNext() → run.resumeStream()\n * - run.observeStreamVNext() → run.observeStream()\n *\n * These methods are called on the result of workflow.createRun().\n */\nexport default createTransformer((fileInfo, api, options, context) => {\n const { j, root } = context;\n\n // Map of old method names to new method names\n const methodRenames: Record<string, string> = {\n streamVNext: 'stream',\n resumeStreamVNext: 'resumeStream',\n observeStreamVNext: 'observeStream',\n };\n\n let count = 0;\n\n // Find all call expressions and rename VNext methods\n // These method names are unique enough to Mastra workflow runs\n // that we can safely rename them globally\n root.find(j.CallExpression).forEach(path => {\n const { callee } = path.value;\n if (callee.type !== 'MemberExpression') return;\n if (callee.property.type !== 'Identifier') return;\n\n const oldName = callee.property.name;\n if (!Object.hasOwn(methodRenames, oldName)) return;\n\n const newName = methodRenames[oldName];\n if (newName) {\n callee.property.name = newName;\n count++;\n }\n });\n\n if (count > 0) {\n context.hasChanges = true;\n context.messages.push(\n `Renamed workflow run VNext methods: streamVNext/resumeStreamVNext/observeStreamVNext → stream/resumeStream/observeStream`,\n );\n }\n});\n"],"mappings":";;;;;AAUA,IAAO,gCAAQ,kBAAkB,CAAC,UAAU,KAAK,SAAS,YAAY;AACpE,QAAM,EAAE,GAAG,KAAK,IAAI;AAGpB,QAAM,gBAAwC;AAAA,IAC5C,aAAa;AAAA,IACb,mBAAmB;AAAA,IACnB,oBAAoB;AAAA,EACtB;AAEA,MAAI,QAAQ;AAKZ,OAAK,KAAK,EAAE,cAAc,EAAE,QAAQ,UAAQ;AAC1C,UAAM,EAAE,OAAO,IAAI,KAAK;AACxB,QAAI,OAAO,SAAS,mBAAoB;AACxC,QAAI,OAAO,SAAS,SAAS,aAAc;AAE3C,UAAM,UAAU,OAAO,SAAS;AAChC,QAAI,CAAC,OAAO,OAAO,eAAe,OAAO,EAAG;AAE5C,UAAM,UAAU,cAAc,OAAO;AACrC,QAAI,SAAS;AACX,aAAO,SAAS,OAAO;AACvB;AAAA,IACF;AAAA,EACF,CAAC;AAED,MAAI,QAAQ,GAAG;AACb,YAAQ,aAAa;AACrB,YAAQ,SAAS;AAAA,MACf;AAAA,IACF;AAAA,EACF;AACF,CAAC;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import debug from 'debug';
|
|
4
|
-
import fs from 'fs';
|
|
5
4
|
import child_process from 'child_process';
|
|
5
|
+
import fs from 'fs';
|
|
6
|
+
import path from 'path';
|
|
6
7
|
import { fileURLToPath } from 'url';
|
|
7
8
|
import util from 'util';
|
|
8
|
-
import path from 'path';
|
|
9
9
|
import { intro, spinner, outro } from '@clack/prompts';
|
|
10
10
|
|
|
11
11
|
var exec = util.promisify(child_process.exec);
|
|
@@ -116,6 +116,7 @@ var BUNDLE = [
|
|
|
116
116
|
"v1/workflow-create-run-async",
|
|
117
117
|
"v1/workflow-run-count",
|
|
118
118
|
"v1/workflow-list-runs",
|
|
119
|
+
"v1/workflow-stream-vnext",
|
|
119
120
|
"v1/memory-query-to-recall",
|
|
120
121
|
"v1/memory-vector-search-param",
|
|
121
122
|
"v1/memory-message-v2-type",
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/transform.ts","../src/lib/bundle.ts","../src/lib/upgrade.ts","../src/index.ts"],"names":["transform","log","debug","error"],"mappings":";;;;;;;;;;AAOA,IAAM,IAAA,GAAO,IAAA,CAAK,SAAA,CAAU,aAAA,CAAc,IAAI,CAAA;AAS9C,IAAM,GAAA,GAAM,MAAM,mBAAmB,CAAA;AACrC,IAAM,KAAA,GAAQ,MAAM,yBAAyB,CAAA;AAC7C,IAAM,UAAA,GAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAChD,IAAM,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,UAAU,CAAA;AAEzC,SAAS,cAAA,GAAyB;AAChC,EAAA,MAAM,gBAAA,GAAmB,IAAA,CAAK,OAAA,CAAQ,SAAA,EAAW,kCAAkC,CAAA;AACnF,EAAA,OAAO,EAAA,CAAG,UAAA,CAAW,gBAAgB,CAAA,GAAI,gBAAA,GAAmB,aAAA;AAC9D;AAEA,SAAS,YAAA,CAAa,WAAA,EAAqB,UAAA,EAAoB,WAAA,EAAqB,OAAA,EAAmC;AAGrH,EAAA,IAAI,UAAU,CAAA,EAAG,WAAW,CAAA,IAAA,EAAO,WAAW,IAAI,UAAU,CAAA,yOAAA,CAAA;AAS5D,EAAA,IAAI,QAAQ,GAAA,EAAK;AACf,IAAA,OAAA,IAAW,QAAA;AAAA,EACb;AAEA,EAAA,IAAI,QAAQ,KAAA,EAAO;AACjB,IAAA,OAAA,IAAW,UAAA;AAAA,EACb;AAEA,EAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,IAAA,OAAA,IAAW,YAAA;AAAA,EACb;AAEA,EAAA,IAAI,QAAQ,WAAA,EAAa;AACvB,IAAA,OAAA,IAAW,CAAA,CAAA,EAAI,QAAQ,WAAW,CAAA,CAAA;AAAA,EACpC;AAEA,EAAA,OAAO,O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AA,EAAa,mDAAmD,CAAA,CACvE,MAAA,CAAO,+BAA+B,sCAAsC,CAAA,CAC5E,MAAA,CAAO,OAAM,OAAA,KAAW;AACvB,EAAA,IAAI;AACF,IAAA,MAAM,UAAU,OAAO,CAAA;AAAA,EACzB,SAAS,GAAA,EAAU;AACjB,IAAAA,MAAAA,CAAM,CAAA,oBAAA,EAAuB,GAAG,CAAA,CAAE,CAAA;AAClC,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAC,CAAA;AAEH,OAAA,CAAQ,KAAA,CAAM,QAAQ,IAAI,CAAA","file":"index.js","sourcesContent":["import fs from 'fs';\nimport child_process from 'node:child_process';\nimport { fileURLToPath } from 'node:url';\nimport util from 'node:util';\nimport path from 'path';\nimport debug from 'debug';\n\nconst exec = util.promisify(child_process.exec);\n\ninterface TransformOptions {\n dry?: boolean;\n print?: boolean;\n verbose?: boolean;\n jscodeshift?: string;\n}\n\nconst log = debug('codemod:transform');\nconst error = debug('codemod:transform:error');\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nfunction getJscodeshift(): string {\n const localJscodeshift = path.resolve(__dirname, '../node_modules/.bin/jscodeshift');\n return fs.existsSync(localJscodeshift) ? localJscodeshift : 'jscodeshift';\n}\n\nfunction buildCommand(codemodPath: string, targetPath: string, jscodeshift: string, options: TransformOptions): string {\n // Ignoring everything under `.*/` covers `.mastra/` along with any other\n // framework build related or otherwise intended-to-be-hidden directories.\n let command = `${jscodeshift} -t ${codemodPath} ${targetPath} \\\n --parser tsx \\\n --ignore-pattern=\"**/node_modules/**\" \\\n --ignore-pattern=\"**/.*/**\" \\\n --ignore-pattern=\"**/dist/**\" \\\n --ignore-pattern=\"**/build/**\" \\\n --ignore-pattern=\"**/*.min.js\" \\\n --ignore-pattern=\"**/*.bundle.js\"`;\n\n if (options.dry) {\n command += ' --dry';\n }\n\n if (options.print) {\n command += ' --print';\n }\n\n if (options.verbose) {\n command += ' --verbose';\n }\n\n if (options.jscodeshift) {\n command += ` ${options.jscodeshift}`;\n }\n\n return command;\n}\n\nexport type TransformErrors = {\n transform: string;\n filename: string;\n summary: string;\n}[];\n\nfunction parseErrors(transform: string, output: string): TransformErrors {\n const errors: TransformErrors = [];\n const errorRegex = /ERR (.+) Transformation error/g;\n const syntaxErrorRegex = /SyntaxError: .+/g;\n\n let match;\n while ((match = errorRegex.exec(output)) !== null) {\n const filename = match[1]!;\n const syntaxErrorMatch = syntaxErrorRegex.exec(output);\n if (syntaxErrorMatch) {\n const summary = syntaxErrorMatch[0];\n errors.push({ transform, filename, summary });\n }\n }\n\n return errors;\n}\n\nfunction parseNotImplementedErrors(transform: string, output: string): TransformErrors {\n const notImplementedErrors: TransformErrors = [];\n const notImplementedRegex = /Not Implemented (.+): (.+)/g;\n\n let match;\n while ((match = notImplementedRegex.exec(output)) !== null) {\n const filename = match[1]!;\n const summary = match[2]!;\n notImplementedErrors.push({ transform, filename, summary });\n }\n\n return notImplementedErrors;\n}\n\nexport async function transform(\n codemod: string,\n source: string,\n transformOptions: TransformOptions,\n options: { logStatus: boolean } = { logStatus: true },\n): Promise<{ errors: TransformErrors; notImplementedErrors: TransformErrors }> {\n if (options.logStatus) {\n log(`Applying codemod '${codemod}': ${source}`);\n }\n const codemodPath = path.resolve(__dirname, `./codemods/${codemod}.js`);\n const targetPath = path.resolve(source);\n const jscodeshift = getJscodeshift();\n const command = buildCommand(codemodPath, targetPath, jscodeshift, transformOptions);\n const { stdout } = await exec(command, { encoding: 'utf8' });\n const errors = parseErrors(codemod, stdout);\n const notImplementedErrors = parseNotImplementedErrors(codemod, stdout);\n if (options.logStatus) {\n if (errors.length > 0) {\n errors.forEach(({ transform, filename, summary }) => {\n error(`Error applying codemod [codemod=${transform}, path=${filename}, summary=${summary}]`);\n });\n }\n\n if (notImplementedErrors.length > 0) {\n log(\n `Some files require manual changes. Please search your codebase for \\`FIXME(mastra): \\` comments and follow the instructions to complete the upgrade.`,\n );\n notImplementedErrors.forEach(({ transform, filename, summary }) => {\n log(`Not Implemented [codemod=${transform}, path=${filename}, summary=${summary}]`);\n });\n }\n }\n\n return { errors, notImplementedErrors };\n}\n","// List of all codemods\nexport const BUNDLE = [\n 'v1/mastra-core-imports',\n 'v1/runtime-context',\n 'v1/not-implemented/mastra-memory',\n 'v1/mastra-plural-apis',\n 'v1/not-implemented/mastra-required-id',\n 'v1/agent-property-access',\n 'v1/agent-voice',\n 'v1/agent-processor-methods',\n 'v1/agent-generate-stream-v-next',\n 'v1/agent-abort-signal',\n 'v1/not-implemented/agent-format-parameter',\n 'v1/not-implemented/agent-to-step',\n 'v1/voice-property-names',\n 'v1/mcp-get-tools',\n 'v1/mcp-get-toolsets',\n 'v1/client-sdk-types',\n 'v1/client-to-ai-sdk-format',\n 'v1/client-offset-limit',\n 'v1/client-get-memory-thread',\n 'v1/experimental-auth',\n 'v1/evals-run-experiment',\n 'v1/evals-scorer-by-name',\n 'v1/evals-prebuilt-imports',\n 'v1/workflow-create-run-async',\n 'v1/workflow-run-count',\n 'v1/workflow-list-runs',\n 'v1/memory-query-to-recall',\n 'v1/memory-vector-search-param',\n 'v1/memory-message-v2-type',\n 'v1/storage-get-threads-by-resource',\n 'v1/storage-list-messages-by-id',\n 'v1/storage-postgres-schema-name',\n 'v1/storage-get-messages-paginated',\n 'v1/storage-list-workflow-runs',\n 'v1/vector-pg-constructor',\n];\n","import { spinner, intro, outro } from '@clack/prompts';\nimport debug from 'debug';\nimport { BUNDLE } from './bundle';\nimport type { TransformErrors } from './transform';\nimport { transform } from './transform';\n\ninterface TransformOptions {\n dry?: true;\n print?: true;\n verbose?: true;\n jscodeshift?: string;\n}\n\nconst log = debug('codemod:upgrade');\nconst error = debug('codemod:upgrade:error');\n\n// Extract v1 codemods from the bundle\nconst v1Bundle = BUNDLE.filter(codemod => codemod.startsWith('v1/'));\n\nasync function runCodemods(codemods: string[], options: TransformOptions, versionLabel: string) {\n const cwd = process.cwd();\n intro(`Starting ${versionLabel} codemods`);\n const modCount = codemods.length;\n const s = spinner();\n\n s.start(`Running ${modCount} ${versionLabel} codemods`);\n\n const allErrors: TransformErrors = [];\n let notImplementedAvailable = false;\n let count = 0;\n for (const [_, codemod] of codemods.entries()) {\n const { errors, notImplementedErrors } = await transform(codemod, cwd, options, {\n logStatus: false,\n });\n allErrors.push(...errors);\n if (notImplementedErrors.length > 0) {\n notImplementedAvailable = true;\n }\n count++;\n s.message(`Codemod ${count}/${modCount} (${codemod})`);\n }\n s.stop(`Ran ${count}/${modCount} codemods.`);\n\n if (allErrors.length > 0) {\n log(`Some ${versionLabel} codemods did not apply successfully to all files. Details:`);\n allErrors.forEach(({ transform, filename, summary }) => {\n error(`codemod=${transform}, path=${filename}, summary=${summary}`);\n });\n }\n\n if (notImplementedAvailable) {\n log(\n `Some ${versionLabel} codemods require manual changes. Please search your codebase for \\`FIXME(mastra): \\` comments and follow the instructions to complete the upgrade.`,\n );\n }\n\n outro(`${versionLabel} codemods complete.`);\n}\n\nexport async function upgradeV1(options: TransformOptions) {\n await runCodemods(v1Bundle, options, 'v1');\n}\n","#! /usr/bin/env node\n\nimport { Command } from 'commander';\nimport debug from 'debug';\nimport { transform } from './lib/transform';\nimport { upgradeV1 } from './lib/upgrade';\n\nconst error = debug('codemod:error');\ndebug.enable('codemod:*');\n\nconst program = new Command();\n\nprogram\n .name('codemod')\n .description('CLI for running Mastra codemods')\n .argument('<codemod>', 'Codemod to run')\n .argument('<source>', 'Path to source files or directory')\n .option('-d, --dry', 'Dry run (no changes are made to files)')\n .option('-p, --print', 'Print transformed files to stdout')\n .option('--verbose', 'Show more information about the transform process')\n .option('-j, --jscodeshift <options>', 'Pass options directly to jscodeshift')\n .action(async (codemod, source, options) => {\n try {\n await transform(codemod, source, options);\n } catch (err: any) {\n error(`Error transforming: ${err}`);\n process.exit(1);\n }\n });\n\nprogram\n .command('v1')\n .description('Apply all v1 codemods (v0.x to v1)')\n .option('-d, --dry', 'Dry run (no changes are made to files)')\n .option('-p, --print', 'Print transformed files to stdout')\n .option('--verbose', 'Show more information about the transform process')\n .option('-j, --jscodeshift <options>', 'Pass options directly to jscodeshift')\n .action(async options => {\n try {\n await upgradeV1(options);\n } catch (err: any) {\n error(`Error transforming: ${err}`);\n process.exit(1);\n }\n });\n\nprogram.parse(process.argv);\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/lib/transform.ts","../src/lib/bundle.ts","../src/lib/upgrade.ts","../src/index.ts"],"names":["transform","log","debug","error"],"mappings":";;;;;;;;;;AAOA,IAAM,IAAA,GAAO,IAAA,CAAK,SAAA,CAAU,aAAA,CAAc,IAAI,CAAA;AAS9C,IAAM,GAAA,GAAM,MAAM,mBAAmB,CAAA;AACrC,IAAM,KAAA,GAAQ,MAAM,yBAAyB,CAAA;AAC7C,IAAM,UAAA,GAAa,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAA;AAChD,IAAM,SAAA,GAAY,IAAA,CAAK,OAAA,CAAQ,UAAU,CAAA;AAEzC,SAAS,cAAA,GAAyB;AAChC,EAAA,MAAM,gBAAA,GAAmB,IAAA,CAAK,OAAA,CAAQ,SAAA,EAAW,kCAAkC,CAAA;AACnF,EAAA,OAAO,EAAA,CAAG,UAAA,CAAW,gBAAgB,CAAA,GAAI,gBAAA,GAAmB,aAAA;AAC9D;AAEA,SAAS,YAAA,CAAa,WAAA,EAAqB,UAAA,EAAoB,WAAA,EAAqB,OAAA,EAAmC;AAGrH,EAAA,IAAI,UAAU,CAAA,EAAG,WAAW,CAAA,IAAA,EAAO,WAAW,IAAI,UAAU,CAAA,yOAAA,CAAA;AAS5D,EAAA,IAAI,QAAQ,GAAA,EAAK;AACf,IAAA,OAAA,IAAW,QAAA;AAAA,EACb;AAEA,EAAA,IAAI,QAAQ,KAAA,EAAO;AACjB,IAAA,OAAA,IAAW,UAAA;AAAA,EACb;AAEA,EAAA,IAAI,QAAQ,OAAA,EAAS;AACnB,IAAA,OAAA,IAAW,YAAA;AAAA,EACb;AAEA,EA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I,CAAA,CACZ,WAAA,CAAY,oCAAoC,EAChD,MAAA,CAAO,WAAA,EAAa,wCAAwC,CAAA,CAC5D,MAAA,CAAO,aAAA,EAAe,mCAAmC,CAAA,CACzD,MAAA,CAAO,WAAA,EAAa,mDAAmD,CAAA,CACvE,MAAA,CAAO,+BAA+B,sCAAsC,CAAA,CAC5E,MAAA,CAAO,OAAM,OAAA,KAAW;AACvB,EAAA,IAAI;AACF,IAAA,MAAM,UAAU,OAAO,CAAA;AAAA,EACzB,SAAS,GAAA,EAAU;AACjB,IAAAA,MAAAA,CAAM,CAAA,oBAAA,EAAuB,GAAG,CAAA,CAAE,CAAA;AAClC,IAAA,OAAA,CAAQ,KAAK,CAAC,CAAA;AAAA,EAChB;AACF,CAAC,CAAA;AAEH,OAAA,CAAQ,KAAA,CAAM,QAAQ,IAAI,CAAA","file":"index.js","sourcesContent":["import child_process from 'node:child_process';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport util from 'node:util';\nimport debug from 'debug';\n\nconst exec = util.promisify(child_process.exec);\n\ninterface TransformOptions {\n dry?: boolean;\n print?: boolean;\n verbose?: boolean;\n jscodeshift?: string;\n}\n\nconst log = debug('codemod:transform');\nconst error = debug('codemod:transform:error');\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\nfunction getJscodeshift(): string {\n const localJscodeshift = path.resolve(__dirname, '../node_modules/.bin/jscodeshift');\n return fs.existsSync(localJscodeshift) ? localJscodeshift : 'jscodeshift';\n}\n\nfunction buildCommand(codemodPath: string, targetPath: string, jscodeshift: string, options: TransformOptions): string {\n // Ignoring everything under `.*/` covers `.mastra/` along with any other\n // framework build related or otherwise intended-to-be-hidden directories.\n let command = `${jscodeshift} -t ${codemodPath} ${targetPath} \\\n --parser tsx \\\n --ignore-pattern=\"**/node_modules/**\" \\\n --ignore-pattern=\"**/.*/**\" \\\n --ignore-pattern=\"**/dist/**\" \\\n --ignore-pattern=\"**/build/**\" \\\n --ignore-pattern=\"**/*.min.js\" \\\n --ignore-pattern=\"**/*.bundle.js\"`;\n\n if (options.dry) {\n command += ' --dry';\n }\n\n if (options.print) {\n command += ' --print';\n }\n\n if (options.verbose) {\n command += ' --verbose';\n }\n\n if (options.jscodeshift) {\n command += ` ${options.jscodeshift}`;\n }\n\n return command;\n}\n\nexport type TransformErrors = {\n transform: string;\n filename: string;\n summary: string;\n}[];\n\nfunction parseErrors(transform: string, output: string): TransformErrors {\n const errors: TransformErrors = [];\n const errorRegex = /ERR (.+) Transformation error/g;\n const syntaxErrorRegex = /SyntaxError: .+/g;\n\n let match;\n while ((match = errorRegex.exec(output)) !== null) {\n const filename = match[1]!;\n const syntaxErrorMatch = syntaxErrorRegex.exec(output);\n if (syntaxErrorMatch) {\n const summary = syntaxErrorMatch[0];\n errors.push({ transform, filename, summary });\n }\n }\n\n return errors;\n}\n\nfunction parseNotImplementedErrors(transform: string, output: string): TransformErrors {\n const notImplementedErrors: TransformErrors = [];\n const notImplementedRegex = /Not Implemented (.+): (.+)/g;\n\n let match;\n while ((match = notImplementedRegex.exec(output)) !== null) {\n const filename = match[1]!;\n const summary = match[2]!;\n notImplementedErrors.push({ transform, filename, summary });\n }\n\n return notImplementedErrors;\n}\n\nexport async function transform(\n codemod: string,\n source: string,\n transformOptions: TransformOptions,\n options: { logStatus: boolean } = { logStatus: true },\n): Promise<{ errors: TransformErrors; notImplementedErrors: TransformErrors }> {\n if (options.logStatus) {\n log(`Applying codemod '${codemod}': ${source}`);\n }\n const codemodPath = path.resolve(__dirname, `./codemods/${codemod}.js`);\n const targetPath = path.resolve(source);\n const jscodeshift = getJscodeshift();\n const command = buildCommand(codemodPath, targetPath, jscodeshift, transformOptions);\n const { stdout } = await exec(command, { encoding: 'utf8' });\n const errors = parseErrors(codemod, stdout);\n const notImplementedErrors = parseNotImplementedErrors(codemod, stdout);\n if (options.logStatus) {\n if (errors.length > 0) {\n errors.forEach(({ transform, filename, summary }) => {\n error(`Error applying codemod [codemod=${transform}, path=${filename}, summary=${summary}]`);\n });\n }\n\n if (notImplementedErrors.length > 0) {\n log(\n `Some files require manual changes. Please search your codebase for \\`FIXME(mastra): \\` comments and follow the instructions to complete the upgrade.`,\n );\n notImplementedErrors.forEach(({ transform, filename, summary }) => {\n log(`Not Implemented [codemod=${transform}, path=${filename}, summary=${summary}]`);\n });\n }\n }\n\n return { errors, notImplementedErrors };\n}\n","// List of all codemods\nexport const BUNDLE = [\n 'v1/mastra-core-imports',\n 'v1/runtime-context',\n 'v1/not-implemented/mastra-memory',\n 'v1/mastra-plural-apis',\n 'v1/not-implemented/mastra-required-id',\n 'v1/agent-property-access',\n 'v1/agent-voice',\n 'v1/agent-processor-methods',\n 'v1/agent-generate-stream-v-next',\n 'v1/agent-abort-signal',\n 'v1/not-implemented/agent-format-parameter',\n 'v1/not-implemented/agent-to-step',\n 'v1/voice-property-names',\n 'v1/mcp-get-tools',\n 'v1/mcp-get-toolsets',\n 'v1/client-sdk-types',\n 'v1/client-to-ai-sdk-format',\n 'v1/client-offset-limit',\n 'v1/client-get-memory-thread',\n 'v1/experimental-auth',\n 'v1/evals-run-experiment',\n 'v1/evals-scorer-by-name',\n 'v1/evals-prebuilt-imports',\n 'v1/workflow-create-run-async',\n 'v1/workflow-run-count',\n 'v1/workflow-list-runs',\n 'v1/workflow-stream-vnext',\n 'v1/memory-query-to-recall',\n 'v1/memory-vector-search-param',\n 'v1/memory-message-v2-type',\n 'v1/storage-get-threads-by-resource',\n 'v1/storage-list-messages-by-id',\n 'v1/storage-postgres-schema-name',\n 'v1/storage-get-messages-paginated',\n 'v1/storage-list-workflow-runs',\n 'v1/vector-pg-constructor',\n];\n","import { spinner, intro, outro } from '@clack/prompts';\nimport debug from 'debug';\nimport { BUNDLE } from './bundle';\nimport type { TransformErrors } from './transform';\nimport { transform } from './transform';\n\ninterface TransformOptions {\n dry?: true;\n print?: true;\n verbose?: true;\n jscodeshift?: string;\n}\n\nconst log = debug('codemod:upgrade');\nconst error = debug('codemod:upgrade:error');\n\n// Extract v1 codemods from the bundle\nconst v1Bundle = BUNDLE.filter(codemod => codemod.startsWith('v1/'));\n\nasync function runCodemods(codemods: string[], options: TransformOptions, versionLabel: string) {\n const cwd = process.cwd();\n intro(`Starting ${versionLabel} codemods`);\n const modCount = codemods.length;\n const s = spinner();\n\n s.start(`Running ${modCount} ${versionLabel} codemods`);\n\n const allErrors: TransformErrors = [];\n let notImplementedAvailable = false;\n let count = 0;\n for (const [_, codemod] of codemods.entries()) {\n const { errors, notImplementedErrors } = await transform(codemod, cwd, options, {\n logStatus: false,\n });\n allErrors.push(...errors);\n if (notImplementedErrors.length > 0) {\n notImplementedAvailable = true;\n }\n count++;\n s.message(`Codemod ${count}/${modCount} (${codemod})`);\n }\n s.stop(`Ran ${count}/${modCount} codemods.`);\n\n if (allErrors.length > 0) {\n log(`Some ${versionLabel} codemods did not apply successfully to all files. Details:`);\n allErrors.forEach(({ transform, filename, summary }) => {\n error(`codemod=${transform}, path=${filename}, summary=${summary}`);\n });\n }\n\n if (notImplementedAvailable) {\n log(\n `Some ${versionLabel} codemods require manual changes. Please search your codebase for \\`FIXME(mastra): \\` comments and follow the instructions to complete the upgrade.`,\n );\n }\n\n outro(`${versionLabel} codemods complete.`);\n}\n\nexport async function upgradeV1(options: TransformOptions) {\n await runCodemods(v1Bundle, options, 'v1');\n}\n","#! /usr/bin/env node\n\nimport { Command } from 'commander';\nimport debug from 'debug';\nimport { transform } from './lib/transform';\nimport { upgradeV1 } from './lib/upgrade';\n\nconst error = debug('codemod:error');\ndebug.enable('codemod:*');\n\nconst program = new Command();\n\nprogram\n .name('codemod')\n .description('CLI for running Mastra codemods')\n .argument('<codemod>', 'Codemod to run')\n .argument('<source>', 'Path to source files or directory')\n .option('-d, --dry', 'Dry run (no changes are made to files)')\n .option('-p, --print', 'Print transformed files to stdout')\n .option('--verbose', 'Show more information about the transform process')\n .option('-j, --jscodeshift <options>', 'Pass options directly to jscodeshift')\n .action(async (codemod, source, options) => {\n try {\n await transform(codemod, source, options);\n } catch (err: any) {\n error(`Error transforming: ${err}`);\n process.exit(1);\n }\n });\n\nprogram\n .command('v1')\n .description('Apply all v1 codemods (v0.x to v1)')\n .option('-d, --dry', 'Dry run (no changes are made to files)')\n .option('-p, --print', 'Print transformed files to stdout')\n .option('--verbose', 'Show more information about the transform process')\n .option('-j, --jscodeshift <options>', 'Pass options directly to jscodeshift')\n .action(async options => {\n try {\n await upgradeV1(options);\n } catch (err: any) {\n error(`Error transforming: ${err}`);\n process.exit(1);\n }\n });\n\nprogram.parse(process.argv);\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/codemod",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-
|
|
4
|
+
"version": "0.0.0-top-level-fix-20251211103030",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Codemod CLI for Mastra",
|
|
7
7
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"tsup": "^8.5.0",
|
|
35
35
|
"typescript": "^5.8.3",
|
|
36
36
|
"vitest": "4.0.12",
|
|
37
|
-
"@internal/lint": "0.0.0-
|
|
37
|
+
"@internal/lint": "0.0.0-top-level-fix-20251211103030"
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://mastra.ai",
|
|
40
40
|
"repository": {
|