@mastra/deployer-vercel 0.0.0-storage-20250225005900 → 0.0.0-taofeeqInngest-20250603090617
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/{LICENSE → LICENSE.md} +3 -1
- package/README.md +4 -2
- package/dist/_tsup-dts-rollup.d.cts +23 -0
- package/dist/_tsup-dts-rollup.d.ts +7 -5
- package/dist/index.cjs +242 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.js +117 -44
- package/package.json +30 -15
- package/.turbo/turbo-build.log +0 -19
- package/CHANGELOG.md +0 -917
- package/src/index.ts +0 -176
- package/tsconfig.json +0 -5
- package/vitest.config.ts +0 -8
package/{LICENSE → LICENSE.md}
RENAMED
package/README.md
CHANGED
|
@@ -25,8 +25,9 @@ import { Mastra } from '@mastra/core';
|
|
|
25
25
|
import { VercelDeployer } from '@mastra/deployer-vercel';
|
|
26
26
|
|
|
27
27
|
const deployer = new VercelDeployer({
|
|
28
|
-
|
|
28
|
+
teamSlug: 'your-team-slug',
|
|
29
29
|
projectName: 'your-project-name',
|
|
30
|
+
token: 'your-vercel-token',
|
|
30
31
|
});
|
|
31
32
|
|
|
32
33
|
const mastra = new Mastra({
|
|
@@ -39,8 +40,9 @@ const mastra = new Mastra({
|
|
|
39
40
|
|
|
40
41
|
### Constructor Options
|
|
41
42
|
|
|
42
|
-
- `
|
|
43
|
+
- `teamSlug` (required): Your Vercel team slug
|
|
43
44
|
- `projectName`: Name of your Vercel project (will be created if it doesn't exist)
|
|
45
|
+
- `token`: Your Vercel API token (required for authentication)
|
|
44
46
|
|
|
45
47
|
## Project Structure
|
|
46
48
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Deployer } from '@mastra/deployer';
|
|
2
|
+
|
|
3
|
+
export declare class VercelDeployer extends Deployer {
|
|
4
|
+
private teamSlug;
|
|
5
|
+
private projectName;
|
|
6
|
+
private token;
|
|
7
|
+
constructor({ teamSlug, projectName, token }: {
|
|
8
|
+
teamSlug: string;
|
|
9
|
+
projectName: string;
|
|
10
|
+
token: string;
|
|
11
|
+
});
|
|
12
|
+
private getProjectId;
|
|
13
|
+
private getTeamId;
|
|
14
|
+
private syncEnv;
|
|
15
|
+
prepare(outputDirectory: string): Promise<void>;
|
|
16
|
+
private getEntry;
|
|
17
|
+
private writeVercelJSON;
|
|
18
|
+
bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
19
|
+
deploy(outputDirectory: string): Promise<void>;
|
|
20
|
+
lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { }
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { Deployer } from '@mastra/deployer';
|
|
2
2
|
|
|
3
3
|
export declare class VercelDeployer extends Deployer {
|
|
4
|
-
private
|
|
4
|
+
private teamSlug;
|
|
5
5
|
private projectName;
|
|
6
6
|
private token;
|
|
7
|
-
constructor({
|
|
8
|
-
|
|
7
|
+
constructor({ teamSlug, projectName, token }: {
|
|
8
|
+
teamSlug: string;
|
|
9
9
|
projectName: string;
|
|
10
10
|
token: string;
|
|
11
11
|
});
|
|
12
|
-
writeFiles(outputDirectory: string): void;
|
|
13
12
|
private getProjectId;
|
|
13
|
+
private getTeamId;
|
|
14
14
|
private syncEnv;
|
|
15
15
|
prepare(outputDirectory: string): Promise<void>;
|
|
16
16
|
private getEntry;
|
|
17
|
-
|
|
17
|
+
private writeVercelJSON;
|
|
18
|
+
bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
18
19
|
deploy(outputDirectory: string): Promise<void>;
|
|
20
|
+
lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export { }
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var child_process = require('child_process');
|
|
4
|
+
var fs = require('fs');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var process = require('process');
|
|
7
|
+
var deployer = require('@mastra/deployer');
|
|
8
|
+
|
|
9
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var child_process__namespace = /*#__PURE__*/_interopNamespace(child_process);
|
|
30
|
+
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
31
|
+
|
|
32
|
+
// src/index.ts
|
|
33
|
+
var VercelDeployer = class extends deployer.Deployer {
|
|
34
|
+
teamSlug;
|
|
35
|
+
projectName;
|
|
36
|
+
token;
|
|
37
|
+
constructor({ teamSlug, projectName, token }) {
|
|
38
|
+
super({ name: "VERCEL" });
|
|
39
|
+
this.teamSlug = teamSlug;
|
|
40
|
+
this.projectName = projectName;
|
|
41
|
+
this.token = token;
|
|
42
|
+
}
|
|
43
|
+
getProjectId({ dir }) {
|
|
44
|
+
const projectJsonPath = path.join(dir, "output", ".vercel", "project.json");
|
|
45
|
+
try {
|
|
46
|
+
const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, "utf-8"));
|
|
47
|
+
return projectJson.projectId;
|
|
48
|
+
} catch {
|
|
49
|
+
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
async getTeamId() {
|
|
53
|
+
const response = await fetch(`https://api.vercel.com/v2/teams`, {
|
|
54
|
+
headers: {
|
|
55
|
+
Authorization: `Bearer ${this.token}`
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const res = await response.json();
|
|
59
|
+
const teams = res.teams;
|
|
60
|
+
return teams.find((team) => team.slug === this.teamSlug)?.id;
|
|
61
|
+
}
|
|
62
|
+
async syncEnv(envVars, { outputDirectory }) {
|
|
63
|
+
console.log("Syncing environment variables...");
|
|
64
|
+
const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
|
|
65
|
+
if (!key || !value) {
|
|
66
|
+
throw new Error(`Invalid environment variable format: ${key || value}`);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
key,
|
|
70
|
+
value,
|
|
71
|
+
target: ["production", "preview", "development"],
|
|
72
|
+
type: "plain"
|
|
73
|
+
};
|
|
74
|
+
});
|
|
75
|
+
try {
|
|
76
|
+
const projectId = this.getProjectId({ dir: outputDirectory });
|
|
77
|
+
const teamId = await this.getTeamId();
|
|
78
|
+
const response = await fetch(
|
|
79
|
+
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
|
|
80
|
+
{
|
|
81
|
+
method: "POST",
|
|
82
|
+
headers: {
|
|
83
|
+
Authorization: `Bearer ${this.token}`,
|
|
84
|
+
"Content-Type": "application/json"
|
|
85
|
+
},
|
|
86
|
+
body: JSON.stringify(vercelEnvVars)
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
if (!response.ok) {
|
|
90
|
+
const error = await response.json();
|
|
91
|
+
throw new Error(`Failed to sync environment variables: ${error.message}`);
|
|
92
|
+
}
|
|
93
|
+
console.log("\u2713 Successfully synced environment variables");
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (error instanceof Error) {
|
|
96
|
+
console.error("Failed to sync environment variables:", error.message);
|
|
97
|
+
} else {
|
|
98
|
+
console.error("Failed to sync environment variables:", error);
|
|
99
|
+
}
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async prepare(outputDirectory) {
|
|
104
|
+
await super.prepare(outputDirectory);
|
|
105
|
+
}
|
|
106
|
+
getEntry() {
|
|
107
|
+
return `
|
|
108
|
+
import { handle } from 'hono/vercel'
|
|
109
|
+
import { mastra } from '#mastra';
|
|
110
|
+
import { createHonoServer } from '#server';
|
|
111
|
+
import { evaluate } from '@mastra/core/eval';
|
|
112
|
+
import { AvailableHooks, registerHook } from '@mastra/core/hooks';
|
|
113
|
+
import { TABLE_EVALS } from '@mastra/core/storage';
|
|
114
|
+
import { checkEvalStorageFields } from '@mastra/core/utils';
|
|
115
|
+
|
|
116
|
+
registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
|
|
117
|
+
evaluate({
|
|
118
|
+
agentName,
|
|
119
|
+
input,
|
|
120
|
+
metric,
|
|
121
|
+
output,
|
|
122
|
+
runId,
|
|
123
|
+
globalRunId: runId,
|
|
124
|
+
instructions,
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
129
|
+
const storage = mastra.getStorage();
|
|
130
|
+
if (storage) {
|
|
131
|
+
// Check for required fields
|
|
132
|
+
const logger = mastra?.getLogger();
|
|
133
|
+
const areFieldsValid = checkEvalStorageFields(traceObject, logger);
|
|
134
|
+
if (!areFieldsValid) return;
|
|
135
|
+
|
|
136
|
+
await storage.insert({
|
|
137
|
+
tableName: TABLE_EVALS,
|
|
138
|
+
record: {
|
|
139
|
+
input: traceObject.input,
|
|
140
|
+
output: traceObject.output,
|
|
141
|
+
result: JSON.stringify(traceObject.result || {}),
|
|
142
|
+
agent_name: traceObject.agentName,
|
|
143
|
+
metric_name: traceObject.metricName,
|
|
144
|
+
instructions: traceObject.instructions,
|
|
145
|
+
test_info: null,
|
|
146
|
+
global_run_id: traceObject.globalRunId,
|
|
147
|
+
run_id: traceObject.runId,
|
|
148
|
+
created_at: new Date().toISOString(),
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const app = await createHonoServer(mastra);
|
|
155
|
+
|
|
156
|
+
export const GET = handle(app);
|
|
157
|
+
export const POST = handle(app);
|
|
158
|
+
export const PUT = handle(app);
|
|
159
|
+
export const DELETE = handle(app);
|
|
160
|
+
export const OPTIONS = handle(app);
|
|
161
|
+
export const HEAD = handle(app);
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
writeVercelJSON(outputDirectory, files = ["./*"]) {
|
|
165
|
+
fs.writeFileSync(
|
|
166
|
+
path.join(outputDirectory, this.outputDir, "vercel.json"),
|
|
167
|
+
JSON.stringify(
|
|
168
|
+
{
|
|
169
|
+
version: 2,
|
|
170
|
+
installCommand: "npm install --omit=dev",
|
|
171
|
+
builds: [
|
|
172
|
+
{
|
|
173
|
+
src: "index.mjs",
|
|
174
|
+
use: "@vercel/node",
|
|
175
|
+
config: { includeFiles: files }
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
routes: [
|
|
179
|
+
{
|
|
180
|
+
src: "/(.*)",
|
|
181
|
+
dest: "index.mjs"
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
null,
|
|
186
|
+
2
|
|
187
|
+
)
|
|
188
|
+
);
|
|
189
|
+
}
|
|
190
|
+
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
191
|
+
const result = await this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
|
|
192
|
+
const files = fs.readdirSync(path.join(outputDirectory, this.outputDir), {
|
|
193
|
+
recursive: true
|
|
194
|
+
});
|
|
195
|
+
const filesWithoutNodeModules = files.filter(
|
|
196
|
+
(file) => typeof file === "string" && !file.startsWith("node_modules")
|
|
197
|
+
);
|
|
198
|
+
this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
|
|
199
|
+
return result;
|
|
200
|
+
}
|
|
201
|
+
async deploy(outputDirectory) {
|
|
202
|
+
const envVars = await this.loadEnvVars();
|
|
203
|
+
const commandArgs = [
|
|
204
|
+
"--scope",
|
|
205
|
+
this.teamSlug,
|
|
206
|
+
"--cwd",
|
|
207
|
+
path.join(outputDirectory, this.outputDir),
|
|
208
|
+
"--token",
|
|
209
|
+
this.token,
|
|
210
|
+
"deploy",
|
|
211
|
+
"--yes",
|
|
212
|
+
...this.projectName ? ["--name", this.projectName] : []
|
|
213
|
+
];
|
|
214
|
+
child_process__namespace.execSync(`npx vercel ${commandArgs.join(" ")}`, {
|
|
215
|
+
cwd: path.join(outputDirectory, this.outputDir),
|
|
216
|
+
env: {
|
|
217
|
+
PATH: process__default.default.env.PATH
|
|
218
|
+
},
|
|
219
|
+
stdio: "inherit"
|
|
220
|
+
});
|
|
221
|
+
this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
|
|
222
|
+
if (envVars.size > 0) {
|
|
223
|
+
await this.syncEnv(envVars, { outputDirectory });
|
|
224
|
+
} else {
|
|
225
|
+
this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
229
|
+
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
230
|
+
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
231
|
+
const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
|
|
232
|
+
if (hasLibsql) {
|
|
233
|
+
this.logger.error(
|
|
234
|
+
`Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
|
|
235
|
+
Use other Mastra Storage options instead e.g @mastra/pg`
|
|
236
|
+
);
|
|
237
|
+
process__default.default.exit(1);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
exports.VercelDeployer = VercelDeployer;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { VercelDeployer } from './_tsup-dts-rollup.cjs';
|
package/dist/index.js
CHANGED
|
@@ -1,58 +1,40 @@
|
|
|
1
|
-
import { Deployer } from '@mastra/deployer';
|
|
2
|
-
import '@mastra/deployer/build';
|
|
3
|
-
import '@rollup/plugin-virtual';
|
|
4
1
|
import * as child_process from 'child_process';
|
|
5
|
-
import { writeFileSync,
|
|
2
|
+
import { readFileSync, writeFileSync, readdirSync } from 'fs';
|
|
6
3
|
import { join } from 'path';
|
|
7
4
|
import process from 'process';
|
|
5
|
+
import { Deployer } from '@mastra/deployer';
|
|
8
6
|
|
|
9
7
|
// src/index.ts
|
|
10
8
|
var VercelDeployer = class extends Deployer {
|
|
11
|
-
|
|
9
|
+
teamSlug;
|
|
12
10
|
projectName;
|
|
13
11
|
token;
|
|
14
|
-
constructor({
|
|
12
|
+
constructor({ teamSlug, projectName, token }) {
|
|
15
13
|
super({ name: "VERCEL" });
|
|
16
|
-
this.
|
|
14
|
+
this.teamSlug = teamSlug;
|
|
17
15
|
this.projectName = projectName;
|
|
18
16
|
this.token = token;
|
|
19
17
|
}
|
|
20
|
-
writeFiles(outputDirectory) {
|
|
21
|
-
writeFileSync(
|
|
22
|
-
join(outputDirectory, this.outputDir, "vercel.json"),
|
|
23
|
-
JSON.stringify(
|
|
24
|
-
{
|
|
25
|
-
version: 2,
|
|
26
|
-
installCommand: "npm install --omit=dev",
|
|
27
|
-
builds: [
|
|
28
|
-
{
|
|
29
|
-
src: "index.mjs",
|
|
30
|
-
use: "@vercel/node",
|
|
31
|
-
config: { includeFiles: ["**"] }
|
|
32
|
-
}
|
|
33
|
-
],
|
|
34
|
-
routes: [
|
|
35
|
-
{
|
|
36
|
-
src: "/(.*)",
|
|
37
|
-
dest: "index.mjs"
|
|
38
|
-
}
|
|
39
|
-
]
|
|
40
|
-
},
|
|
41
|
-
null,
|
|
42
|
-
2
|
|
43
|
-
)
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
18
|
getProjectId({ dir }) {
|
|
47
|
-
const projectJsonPath = join(dir, ".vercel", "project.json");
|
|
19
|
+
const projectJsonPath = join(dir, "output", ".vercel", "project.json");
|
|
48
20
|
try {
|
|
49
21
|
const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
|
|
50
22
|
return projectJson.projectId;
|
|
51
|
-
} catch
|
|
23
|
+
} catch {
|
|
52
24
|
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
53
25
|
}
|
|
54
26
|
}
|
|
55
|
-
async
|
|
27
|
+
async getTeamId() {
|
|
28
|
+
const response = await fetch(`https://api.vercel.com/v2/teams`, {
|
|
29
|
+
headers: {
|
|
30
|
+
Authorization: `Bearer ${this.token}`
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const res = await response.json();
|
|
34
|
+
const teams = res.teams;
|
|
35
|
+
return teams.find((team) => team.slug === this.teamSlug)?.id;
|
|
36
|
+
}
|
|
37
|
+
async syncEnv(envVars, { outputDirectory }) {
|
|
56
38
|
console.log("Syncing environment variables...");
|
|
57
39
|
const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
|
|
58
40
|
if (!key || !value) {
|
|
@@ -66,9 +48,10 @@ var VercelDeployer = class extends Deployer {
|
|
|
66
48
|
};
|
|
67
49
|
});
|
|
68
50
|
try {
|
|
69
|
-
const projectId = this.getProjectId({ dir:
|
|
51
|
+
const projectId = this.getProjectId({ dir: outputDirectory });
|
|
52
|
+
const teamId = await this.getTeamId();
|
|
70
53
|
const response = await fetch(
|
|
71
|
-
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${
|
|
54
|
+
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
|
|
72
55
|
{
|
|
73
56
|
method: "POST",
|
|
74
57
|
headers: {
|
|
@@ -94,28 +77,107 @@ var VercelDeployer = class extends Deployer {
|
|
|
94
77
|
}
|
|
95
78
|
async prepare(outputDirectory) {
|
|
96
79
|
await super.prepare(outputDirectory);
|
|
97
|
-
await this.writeFiles(outputDirectory);
|
|
98
80
|
}
|
|
99
81
|
getEntry() {
|
|
100
82
|
return `
|
|
101
83
|
import { handle } from 'hono/vercel'
|
|
102
84
|
import { mastra } from '#mastra';
|
|
103
85
|
import { createHonoServer } from '#server';
|
|
86
|
+
import { evaluate } from '@mastra/core/eval';
|
|
87
|
+
import { AvailableHooks, registerHook } from '@mastra/core/hooks';
|
|
88
|
+
import { TABLE_EVALS } from '@mastra/core/storage';
|
|
89
|
+
import { checkEvalStorageFields } from '@mastra/core/utils';
|
|
90
|
+
|
|
91
|
+
registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
|
|
92
|
+
evaluate({
|
|
93
|
+
agentName,
|
|
94
|
+
input,
|
|
95
|
+
metric,
|
|
96
|
+
output,
|
|
97
|
+
runId,
|
|
98
|
+
globalRunId: runId,
|
|
99
|
+
instructions,
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
104
|
+
const storage = mastra.getStorage();
|
|
105
|
+
if (storage) {
|
|
106
|
+
// Check for required fields
|
|
107
|
+
const logger = mastra?.getLogger();
|
|
108
|
+
const areFieldsValid = checkEvalStorageFields(traceObject, logger);
|
|
109
|
+
if (!areFieldsValid) return;
|
|
110
|
+
|
|
111
|
+
await storage.insert({
|
|
112
|
+
tableName: TABLE_EVALS,
|
|
113
|
+
record: {
|
|
114
|
+
input: traceObject.input,
|
|
115
|
+
output: traceObject.output,
|
|
116
|
+
result: JSON.stringify(traceObject.result || {}),
|
|
117
|
+
agent_name: traceObject.agentName,
|
|
118
|
+
metric_name: traceObject.metricName,
|
|
119
|
+
instructions: traceObject.instructions,
|
|
120
|
+
test_info: null,
|
|
121
|
+
global_run_id: traceObject.globalRunId,
|
|
122
|
+
run_id: traceObject.runId,
|
|
123
|
+
created_at: new Date().toISOString(),
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
});
|
|
104
128
|
|
|
105
129
|
const app = await createHonoServer(mastra);
|
|
106
130
|
|
|
107
131
|
export const GET = handle(app);
|
|
108
132
|
export const POST = handle(app);
|
|
133
|
+
export const PUT = handle(app);
|
|
134
|
+
export const DELETE = handle(app);
|
|
135
|
+
export const OPTIONS = handle(app);
|
|
136
|
+
export const HEAD = handle(app);
|
|
109
137
|
`;
|
|
110
138
|
}
|
|
111
|
-
|
|
112
|
-
|
|
139
|
+
writeVercelJSON(outputDirectory, files = ["./*"]) {
|
|
140
|
+
writeFileSync(
|
|
141
|
+
join(outputDirectory, this.outputDir, "vercel.json"),
|
|
142
|
+
JSON.stringify(
|
|
143
|
+
{
|
|
144
|
+
version: 2,
|
|
145
|
+
installCommand: "npm install --omit=dev",
|
|
146
|
+
builds: [
|
|
147
|
+
{
|
|
148
|
+
src: "index.mjs",
|
|
149
|
+
use: "@vercel/node",
|
|
150
|
+
config: { includeFiles: files }
|
|
151
|
+
}
|
|
152
|
+
],
|
|
153
|
+
routes: [
|
|
154
|
+
{
|
|
155
|
+
src: "/(.*)",
|
|
156
|
+
dest: "index.mjs"
|
|
157
|
+
}
|
|
158
|
+
]
|
|
159
|
+
},
|
|
160
|
+
null,
|
|
161
|
+
2
|
|
162
|
+
)
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
166
|
+
const result = await this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
|
|
167
|
+
const files = readdirSync(join(outputDirectory, this.outputDir), {
|
|
168
|
+
recursive: true
|
|
169
|
+
});
|
|
170
|
+
const filesWithoutNodeModules = files.filter(
|
|
171
|
+
(file) => typeof file === "string" && !file.startsWith("node_modules")
|
|
172
|
+
);
|
|
173
|
+
this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
|
|
174
|
+
return result;
|
|
113
175
|
}
|
|
114
176
|
async deploy(outputDirectory) {
|
|
115
177
|
const envVars = await this.loadEnvVars();
|
|
116
178
|
const commandArgs = [
|
|
117
179
|
"--scope",
|
|
118
|
-
this.
|
|
180
|
+
this.teamSlug,
|
|
119
181
|
"--cwd",
|
|
120
182
|
join(outputDirectory, this.outputDir),
|
|
121
183
|
"--token",
|
|
@@ -127,18 +189,29 @@ export const POST = handle(app);
|
|
|
127
189
|
child_process.execSync(`npx vercel ${commandArgs.join(" ")}`, {
|
|
128
190
|
cwd: join(outputDirectory, this.outputDir),
|
|
129
191
|
env: {
|
|
130
|
-
// ...this.env,
|
|
131
192
|
PATH: process.env.PATH
|
|
132
193
|
},
|
|
133
194
|
stdio: "inherit"
|
|
134
195
|
});
|
|
135
196
|
this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
|
|
136
197
|
if (envVars.size > 0) {
|
|
137
|
-
await this.syncEnv(envVars);
|
|
198
|
+
await this.syncEnv(envVars, { outputDirectory });
|
|
138
199
|
} else {
|
|
139
200
|
this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
|
|
140
201
|
}
|
|
141
202
|
}
|
|
203
|
+
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
204
|
+
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
205
|
+
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
206
|
+
const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
|
|
207
|
+
if (hasLibsql) {
|
|
208
|
+
this.logger.error(
|
|
209
|
+
`Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
|
|
210
|
+
Use other Mastra Storage options instead e.g @mastra/pg`
|
|
211
|
+
);
|
|
212
|
+
process.exit(1);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
142
215
|
};
|
|
143
216
|
|
|
144
217
|
export { VercelDeployer };
|
package/package.json
CHANGED
|
@@ -1,37 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-vercel",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-taofeeqInngest-20250603090617",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
6
9
|
"main": "dist/index.js",
|
|
7
10
|
"types": "dist/index.d.ts",
|
|
8
11
|
"exports": {
|
|
9
12
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/index.d.cts",
|
|
19
|
+
"default": "./dist/index.cjs"
|
|
20
|
+
}
|
|
12
21
|
},
|
|
13
22
|
"./package.json": "./package.json"
|
|
14
23
|
},
|
|
15
24
|
"keywords": [],
|
|
16
25
|
"author": "",
|
|
17
|
-
"license": "
|
|
26
|
+
"license": "Elastic-2.0",
|
|
18
27
|
"dependencies": {
|
|
19
28
|
"@rollup/plugin-virtual": "^3.0.2",
|
|
20
|
-
"fs-extra": "^11.
|
|
21
|
-
"@mastra/
|
|
22
|
-
"@mastra/deployer": "^0.0.0-storage-20250225005900"
|
|
29
|
+
"fs-extra": "^11.3.0",
|
|
30
|
+
"@mastra/deployer": "0.0.0-taofeeqInngest-20250603090617"
|
|
23
31
|
},
|
|
24
32
|
"devDependencies": {
|
|
25
|
-
"@microsoft/api-extractor": "^7.
|
|
26
|
-
"@types/node": "^
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
33
|
+
"@microsoft/api-extractor": "^7.52.5",
|
|
34
|
+
"@types/node": "^20.17.27",
|
|
35
|
+
"eslint": "^9.23.0",
|
|
36
|
+
"tsup": "^8.4.0",
|
|
37
|
+
"typescript": "^5.8.2",
|
|
38
|
+
"vercel": "^39.4.2",
|
|
39
|
+
"vitest": "^3.1.2",
|
|
40
|
+
"@mastra/core": "0.0.0-taofeeqInngest-20250603090617",
|
|
41
|
+
"@internal/lint": "0.0.0-taofeeqInngest-20250603090617"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@mastra/core": "^0.10.1-alpha.0"
|
|
31
45
|
},
|
|
32
46
|
"scripts": {
|
|
33
|
-
"build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
|
|
47
|
+
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
|
34
48
|
"build:watch": "pnpm build --watch",
|
|
35
|
-
"test": "vitest run"
|
|
49
|
+
"test": "vitest run",
|
|
50
|
+
"lint": "eslint ."
|
|
36
51
|
}
|
|
37
52
|
}
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
> @mastra/deployer-vercel@0.1.5-alpha.1 build /Users/ward/projects/mastra/mastra/deployers/vercel
|
|
4
|
-
> tsup src/index.ts --format esm --experimental-dts --clean --treeshake
|
|
5
|
-
|
|
6
|
-
[34mCLI[39m Building entry: src/index.ts
|
|
7
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
-
[34mCLI[39m tsup v8.3.6
|
|
9
|
-
[34mTSC[39m Build start
|
|
10
|
-
[32mTSC[39m ⚡️ Build success in 1574ms
|
|
11
|
-
[34mDTS[39m Build start
|
|
12
|
-
[34mCLI[39m Target: es2022
|
|
13
|
-
Analysis will use the bundled TypeScript version 5.7.3
|
|
14
|
-
[36mWriting package typings: /Users/ward/projects/mastra/mastra/deployers/vercel/dist/_tsup-dts-rollup.d.ts[39m
|
|
15
|
-
[32mDTS[39m ⚡️ Build success in 1368ms
|
|
16
|
-
[34mCLI[39m Cleaning output folder
|
|
17
|
-
[34mESM[39m Build start
|
|
18
|
-
[32mESM[39m [1mdist/index.js [22m[32m4.08 KB[39m
|
|
19
|
-
[32mESM[39m ⚡️ Build success in 119ms
|