@mastra/deployer-vercel 0.0.0-support-monorepos-20250415183219 → 0.0.0-support-d1-client-20250701191943
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/dist/_tsup-dts-rollup.d.cts +5 -14
- package/dist/_tsup-dts-rollup.d.ts +5 -14
- package/dist/index.cjs +101 -140
- package/dist/index.js +102 -122
- package/package.json +14 -11
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { Deployer } from '@mastra/deployer';
|
|
2
2
|
|
|
3
3
|
export declare class VercelDeployer extends Deployer {
|
|
4
|
-
|
|
5
|
-
private projectName;
|
|
6
|
-
private token;
|
|
7
|
-
constructor({ teamSlug, projectName, token }: {
|
|
8
|
-
teamSlug: string;
|
|
9
|
-
projectName: string;
|
|
10
|
-
token: string;
|
|
11
|
-
});
|
|
12
|
-
writeFiles(outputDirectory: string): void;
|
|
13
|
-
private getProjectId;
|
|
14
|
-
private getTeamId;
|
|
15
|
-
private syncEnv;
|
|
4
|
+
constructor();
|
|
16
5
|
prepare(outputDirectory: string): Promise<void>;
|
|
17
6
|
private getEntry;
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
private writeVercelJSON;
|
|
8
|
+
bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
9
|
+
deploy(): Promise<void>;
|
|
10
|
+
lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
20
11
|
}
|
|
21
12
|
|
|
22
13
|
export { }
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import { Deployer } from '@mastra/deployer';
|
|
2
2
|
|
|
3
3
|
export declare class VercelDeployer extends Deployer {
|
|
4
|
-
|
|
5
|
-
private projectName;
|
|
6
|
-
private token;
|
|
7
|
-
constructor({ teamSlug, projectName, token }: {
|
|
8
|
-
teamSlug: string;
|
|
9
|
-
projectName: string;
|
|
10
|
-
token: string;
|
|
11
|
-
});
|
|
12
|
-
writeFiles(outputDirectory: string): void;
|
|
13
|
-
private getProjectId;
|
|
14
|
-
private getTeamId;
|
|
15
|
-
private syncEnv;
|
|
4
|
+
constructor();
|
|
16
5
|
prepare(outputDirectory: string): Promise<void>;
|
|
17
6
|
private getEntry;
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
private writeVercelJSON;
|
|
8
|
+
bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
9
|
+
deploy(): Promise<void>;
|
|
10
|
+
lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
20
11
|
}
|
|
21
12
|
|
|
22
13
|
export { }
|
package/dist/index.cjs
CHANGED
|
@@ -1,175 +1,136 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var child_process = require('child_process');
|
|
4
3
|
var fs = require('fs');
|
|
5
4
|
var path = require('path');
|
|
6
5
|
var process = require('process');
|
|
7
6
|
var deployer = require('@mastra/deployer');
|
|
7
|
+
var esm = require('fs-extra/esm');
|
|
8
8
|
|
|
9
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
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
11
|
var process__default = /*#__PURE__*/_interopDefault(process);
|
|
31
12
|
|
|
32
13
|
// src/index.ts
|
|
33
14
|
var VercelDeployer = class extends deployer.Deployer {
|
|
34
|
-
|
|
35
|
-
projectName;
|
|
36
|
-
token;
|
|
37
|
-
constructor({ teamSlug, projectName, token }) {
|
|
15
|
+
constructor() {
|
|
38
16
|
super({ name: "VERCEL" });
|
|
39
|
-
this.
|
|
40
|
-
this.projectName = projectName;
|
|
41
|
-
this.token = token;
|
|
42
|
-
}
|
|
43
|
-
writeFiles(outputDirectory) {
|
|
44
|
-
fs.writeFileSync(
|
|
45
|
-
path.join(outputDirectory, this.outputDir, "vercel.json"),
|
|
46
|
-
JSON.stringify(
|
|
47
|
-
{
|
|
48
|
-
version: 2,
|
|
49
|
-
installCommand: "npm install --omit=dev",
|
|
50
|
-
builds: [
|
|
51
|
-
{
|
|
52
|
-
src: "index.mjs",
|
|
53
|
-
use: "@vercel/node",
|
|
54
|
-
config: { includeFiles: ["**"] }
|
|
55
|
-
}
|
|
56
|
-
],
|
|
57
|
-
routes: [
|
|
58
|
-
{
|
|
59
|
-
src: "/(.*)",
|
|
60
|
-
dest: "index.mjs"
|
|
61
|
-
}
|
|
62
|
-
]
|
|
63
|
-
},
|
|
64
|
-
null,
|
|
65
|
-
2
|
|
66
|
-
)
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
getProjectId({ dir }) {
|
|
70
|
-
const projectJsonPath = path.join(dir, "output", ".vercel", "project.json");
|
|
71
|
-
try {
|
|
72
|
-
const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, "utf-8"));
|
|
73
|
-
return projectJson.projectId;
|
|
74
|
-
} catch {
|
|
75
|
-
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
async getTeamId() {
|
|
79
|
-
const response = await fetch(`https://api.vercel.com/v2/teams`, {
|
|
80
|
-
headers: {
|
|
81
|
-
Authorization: `Bearer ${this.token}`
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
const res = await response.json();
|
|
85
|
-
const teams = res.teams;
|
|
86
|
-
return teams.find((team) => team.slug === this.teamSlug)?.id;
|
|
87
|
-
}
|
|
88
|
-
async syncEnv(envVars, { outputDirectory }) {
|
|
89
|
-
console.log("Syncing environment variables...");
|
|
90
|
-
const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
|
|
91
|
-
if (!key || !value) {
|
|
92
|
-
throw new Error(`Invalid environment variable format: ${key || value}`);
|
|
93
|
-
}
|
|
94
|
-
return {
|
|
95
|
-
key,
|
|
96
|
-
value,
|
|
97
|
-
target: ["production", "preview", "development"],
|
|
98
|
-
type: "plain"
|
|
99
|
-
};
|
|
100
|
-
});
|
|
101
|
-
try {
|
|
102
|
-
const projectId = this.getProjectId({ dir: outputDirectory });
|
|
103
|
-
const teamId = await this.getTeamId();
|
|
104
|
-
const response = await fetch(
|
|
105
|
-
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
|
|
106
|
-
{
|
|
107
|
-
method: "POST",
|
|
108
|
-
headers: {
|
|
109
|
-
Authorization: `Bearer ${this.token}`,
|
|
110
|
-
"Content-Type": "application/json"
|
|
111
|
-
},
|
|
112
|
-
body: JSON.stringify(vercelEnvVars)
|
|
113
|
-
}
|
|
114
|
-
);
|
|
115
|
-
if (!response.ok) {
|
|
116
|
-
const error = await response.json();
|
|
117
|
-
throw new Error(`Failed to sync environment variables: ${error.message}`);
|
|
118
|
-
}
|
|
119
|
-
console.log("\u2713 Successfully synced environment variables");
|
|
120
|
-
} catch (error) {
|
|
121
|
-
if (error instanceof Error) {
|
|
122
|
-
console.error("Failed to sync environment variables:", error.message);
|
|
123
|
-
} else {
|
|
124
|
-
console.error("Failed to sync environment variables:", error);
|
|
125
|
-
}
|
|
126
|
-
throw error;
|
|
127
|
-
}
|
|
17
|
+
this.outputDir = path.join(".vercel", "output", "functions", "index.func");
|
|
128
18
|
}
|
|
129
19
|
async prepare(outputDirectory) {
|
|
130
20
|
await super.prepare(outputDirectory);
|
|
131
|
-
|
|
21
|
+
this.writeVercelJSON(path.join(outputDirectory, this.outputDir, "..", ".."));
|
|
132
22
|
}
|
|
133
23
|
getEntry() {
|
|
134
24
|
return `
|
|
135
25
|
import { handle } from 'hono/vercel'
|
|
136
26
|
import { mastra } from '#mastra';
|
|
137
27
|
import { createHonoServer } from '#server';
|
|
28
|
+
import { evaluate } from '@mastra/core/eval';
|
|
29
|
+
import { AvailableHooks, registerHook } from '@mastra/core/hooks';
|
|
30
|
+
import { TABLE_EVALS } from '@mastra/core/storage';
|
|
31
|
+
import { checkEvalStorageFields } from '@mastra/core/utils';
|
|
32
|
+
|
|
33
|
+
registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
|
|
34
|
+
evaluate({
|
|
35
|
+
agentName,
|
|
36
|
+
input,
|
|
37
|
+
metric,
|
|
38
|
+
output,
|
|
39
|
+
runId,
|
|
40
|
+
globalRunId: runId,
|
|
41
|
+
instructions,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
46
|
+
const storage = mastra.getStorage();
|
|
47
|
+
if (storage) {
|
|
48
|
+
// Check for required fields
|
|
49
|
+
const logger = mastra?.getLogger();
|
|
50
|
+
const areFieldsValid = checkEvalStorageFields(traceObject, logger);
|
|
51
|
+
if (!areFieldsValid) return;
|
|
52
|
+
|
|
53
|
+
await storage.insert({
|
|
54
|
+
tableName: TABLE_EVALS,
|
|
55
|
+
record: {
|
|
56
|
+
input: traceObject.input,
|
|
57
|
+
output: traceObject.output,
|
|
58
|
+
result: JSON.stringify(traceObject.result || {}),
|
|
59
|
+
agent_name: traceObject.agentName,
|
|
60
|
+
metric_name: traceObject.metricName,
|
|
61
|
+
instructions: traceObject.instructions,
|
|
62
|
+
test_info: null,
|
|
63
|
+
global_run_id: traceObject.globalRunId,
|
|
64
|
+
run_id: traceObject.runId,
|
|
65
|
+
created_at: new Date().toISOString(),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
138
70
|
|
|
139
71
|
const app = await createHonoServer(mastra);
|
|
140
72
|
|
|
141
73
|
export const GET = handle(app);
|
|
142
74
|
export const POST = handle(app);
|
|
75
|
+
export const PUT = handle(app);
|
|
76
|
+
export const DELETE = handle(app);
|
|
77
|
+
export const OPTIONS = handle(app);
|
|
78
|
+
export const HEAD = handle(app);
|
|
143
79
|
`;
|
|
144
80
|
}
|
|
145
|
-
|
|
146
|
-
|
|
81
|
+
writeVercelJSON(outputDirectory) {
|
|
82
|
+
fs.writeFileSync(
|
|
83
|
+
path.join(outputDirectory, "config.json"),
|
|
84
|
+
JSON.stringify({
|
|
85
|
+
version: 3,
|
|
86
|
+
routes: [
|
|
87
|
+
{
|
|
88
|
+
src: "/(.*)",
|
|
89
|
+
dest: "/"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
);
|
|
147
94
|
}
|
|
148
|
-
async
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
path.join(outputDirectory, this.outputDir)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
"
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
95
|
+
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
96
|
+
const result = await this._bundle(
|
|
97
|
+
this.getEntry(),
|
|
98
|
+
entryFile,
|
|
99
|
+
outputDirectory,
|
|
100
|
+
toolsPaths,
|
|
101
|
+
path.join(outputDirectory, this.outputDir)
|
|
102
|
+
);
|
|
103
|
+
const nodeVersion = process__default.default.version?.split(".")?.[0]?.replace("v", "") ?? "22";
|
|
104
|
+
fs.writeFileSync(
|
|
105
|
+
path.join(outputDirectory, this.outputDir, ".vc-config.json"),
|
|
106
|
+
JSON.stringify(
|
|
107
|
+
{
|
|
108
|
+
handler: "index.mjs",
|
|
109
|
+
launcherType: "Nodejs",
|
|
110
|
+
runtime: `nodejs${nodeVersion}.x`,
|
|
111
|
+
shouldAddHelpers: true
|
|
112
|
+
},
|
|
113
|
+
null,
|
|
114
|
+
2
|
|
115
|
+
)
|
|
116
|
+
);
|
|
117
|
+
await esm.move(path.join(outputDirectory, ".vercel", "output"), path.join(process__default.default.cwd(), ".vercel", "output"), {
|
|
118
|
+
overwrite: true
|
|
167
119
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
120
|
+
return result;
|
|
121
|
+
}
|
|
122
|
+
async deploy() {
|
|
123
|
+
this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
|
|
124
|
+
}
|
|
125
|
+
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
126
|
+
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
127
|
+
const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
|
|
128
|
+
if (hasLibsql) {
|
|
129
|
+
this.logger.error(
|
|
130
|
+
`Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
|
|
131
|
+
Use other Mastra Storage options instead e.g @mastra/pg`
|
|
132
|
+
);
|
|
133
|
+
process__default.default.exit(1);
|
|
173
134
|
}
|
|
174
135
|
}
|
|
175
136
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,150 +1,130 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { writeFileSync, readFileSync } from 'fs';
|
|
1
|
+
import { writeFileSync } from 'fs';
|
|
3
2
|
import { join } from 'path';
|
|
4
3
|
import process from 'process';
|
|
5
4
|
import { Deployer } from '@mastra/deployer';
|
|
5
|
+
import { move } from 'fs-extra/esm';
|
|
6
6
|
|
|
7
7
|
// src/index.ts
|
|
8
8
|
var VercelDeployer = class extends Deployer {
|
|
9
|
-
|
|
10
|
-
projectName;
|
|
11
|
-
token;
|
|
12
|
-
constructor({ teamSlug, projectName, token }) {
|
|
9
|
+
constructor() {
|
|
13
10
|
super({ name: "VERCEL" });
|
|
14
|
-
this.
|
|
15
|
-
this.projectName = projectName;
|
|
16
|
-
this.token = token;
|
|
17
|
-
}
|
|
18
|
-
writeFiles(outputDirectory) {
|
|
19
|
-
writeFileSync(
|
|
20
|
-
join(outputDirectory, this.outputDir, "vercel.json"),
|
|
21
|
-
JSON.stringify(
|
|
22
|
-
{
|
|
23
|
-
version: 2,
|
|
24
|
-
installCommand: "npm install --omit=dev",
|
|
25
|
-
builds: [
|
|
26
|
-
{
|
|
27
|
-
src: "index.mjs",
|
|
28
|
-
use: "@vercel/node",
|
|
29
|
-
config: { includeFiles: ["**"] }
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
routes: [
|
|
33
|
-
{
|
|
34
|
-
src: "/(.*)",
|
|
35
|
-
dest: "index.mjs"
|
|
36
|
-
}
|
|
37
|
-
]
|
|
38
|
-
},
|
|
39
|
-
null,
|
|
40
|
-
2
|
|
41
|
-
)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
getProjectId({ dir }) {
|
|
45
|
-
const projectJsonPath = join(dir, "output", ".vercel", "project.json");
|
|
46
|
-
try {
|
|
47
|
-
const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
|
|
48
|
-
return projectJson.projectId;
|
|
49
|
-
} catch {
|
|
50
|
-
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async getTeamId() {
|
|
54
|
-
const response = await fetch(`https://api.vercel.com/v2/teams`, {
|
|
55
|
-
headers: {
|
|
56
|
-
Authorization: `Bearer ${this.token}`
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
const res = await response.json();
|
|
60
|
-
const teams = res.teams;
|
|
61
|
-
return teams.find((team) => team.slug === this.teamSlug)?.id;
|
|
62
|
-
}
|
|
63
|
-
async syncEnv(envVars, { outputDirectory }) {
|
|
64
|
-
console.log("Syncing environment variables...");
|
|
65
|
-
const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
|
|
66
|
-
if (!key || !value) {
|
|
67
|
-
throw new Error(`Invalid environment variable format: ${key || value}`);
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
key,
|
|
71
|
-
value,
|
|
72
|
-
target: ["production", "preview", "development"],
|
|
73
|
-
type: "plain"
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
try {
|
|
77
|
-
const projectId = this.getProjectId({ dir: outputDirectory });
|
|
78
|
-
const teamId = await this.getTeamId();
|
|
79
|
-
const response = await fetch(
|
|
80
|
-
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
|
|
81
|
-
{
|
|
82
|
-
method: "POST",
|
|
83
|
-
headers: {
|
|
84
|
-
Authorization: `Bearer ${this.token}`,
|
|
85
|
-
"Content-Type": "application/json"
|
|
86
|
-
},
|
|
87
|
-
body: JSON.stringify(vercelEnvVars)
|
|
88
|
-
}
|
|
89
|
-
);
|
|
90
|
-
if (!response.ok) {
|
|
91
|
-
const error = await response.json();
|
|
92
|
-
throw new Error(`Failed to sync environment variables: ${error.message}`);
|
|
93
|
-
}
|
|
94
|
-
console.log("\u2713 Successfully synced environment variables");
|
|
95
|
-
} catch (error) {
|
|
96
|
-
if (error instanceof Error) {
|
|
97
|
-
console.error("Failed to sync environment variables:", error.message);
|
|
98
|
-
} else {
|
|
99
|
-
console.error("Failed to sync environment variables:", error);
|
|
100
|
-
}
|
|
101
|
-
throw error;
|
|
102
|
-
}
|
|
11
|
+
this.outputDir = join(".vercel", "output", "functions", "index.func");
|
|
103
12
|
}
|
|
104
13
|
async prepare(outputDirectory) {
|
|
105
14
|
await super.prepare(outputDirectory);
|
|
106
|
-
|
|
15
|
+
this.writeVercelJSON(join(outputDirectory, this.outputDir, "..", ".."));
|
|
107
16
|
}
|
|
108
17
|
getEntry() {
|
|
109
18
|
return `
|
|
110
19
|
import { handle } from 'hono/vercel'
|
|
111
20
|
import { mastra } from '#mastra';
|
|
112
21
|
import { createHonoServer } from '#server';
|
|
22
|
+
import { evaluate } from '@mastra/core/eval';
|
|
23
|
+
import { AvailableHooks, registerHook } from '@mastra/core/hooks';
|
|
24
|
+
import { TABLE_EVALS } from '@mastra/core/storage';
|
|
25
|
+
import { checkEvalStorageFields } from '@mastra/core/utils';
|
|
26
|
+
|
|
27
|
+
registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agentName, instructions }) => {
|
|
28
|
+
evaluate({
|
|
29
|
+
agentName,
|
|
30
|
+
input,
|
|
31
|
+
metric,
|
|
32
|
+
output,
|
|
33
|
+
runId,
|
|
34
|
+
globalRunId: runId,
|
|
35
|
+
instructions,
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
40
|
+
const storage = mastra.getStorage();
|
|
41
|
+
if (storage) {
|
|
42
|
+
// Check for required fields
|
|
43
|
+
const logger = mastra?.getLogger();
|
|
44
|
+
const areFieldsValid = checkEvalStorageFields(traceObject, logger);
|
|
45
|
+
if (!areFieldsValid) return;
|
|
46
|
+
|
|
47
|
+
await storage.insert({
|
|
48
|
+
tableName: TABLE_EVALS,
|
|
49
|
+
record: {
|
|
50
|
+
input: traceObject.input,
|
|
51
|
+
output: traceObject.output,
|
|
52
|
+
result: JSON.stringify(traceObject.result || {}),
|
|
53
|
+
agent_name: traceObject.agentName,
|
|
54
|
+
metric_name: traceObject.metricName,
|
|
55
|
+
instructions: traceObject.instructions,
|
|
56
|
+
test_info: null,
|
|
57
|
+
global_run_id: traceObject.globalRunId,
|
|
58
|
+
run_id: traceObject.runId,
|
|
59
|
+
created_at: new Date().toISOString(),
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
113
64
|
|
|
114
65
|
const app = await createHonoServer(mastra);
|
|
115
66
|
|
|
116
67
|
export const GET = handle(app);
|
|
117
68
|
export const POST = handle(app);
|
|
69
|
+
export const PUT = handle(app);
|
|
70
|
+
export const DELETE = handle(app);
|
|
71
|
+
export const OPTIONS = handle(app);
|
|
72
|
+
export const HEAD = handle(app);
|
|
118
73
|
`;
|
|
119
74
|
}
|
|
120
|
-
|
|
121
|
-
|
|
75
|
+
writeVercelJSON(outputDirectory) {
|
|
76
|
+
writeFileSync(
|
|
77
|
+
join(outputDirectory, "config.json"),
|
|
78
|
+
JSON.stringify({
|
|
79
|
+
version: 3,
|
|
80
|
+
routes: [
|
|
81
|
+
{
|
|
82
|
+
src: "/(.*)",
|
|
83
|
+
dest: "/"
|
|
84
|
+
}
|
|
85
|
+
]
|
|
86
|
+
})
|
|
87
|
+
);
|
|
122
88
|
}
|
|
123
|
-
async
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
join(outputDirectory, this.outputDir)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
89
|
+
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
90
|
+
const result = await this._bundle(
|
|
91
|
+
this.getEntry(),
|
|
92
|
+
entryFile,
|
|
93
|
+
outputDirectory,
|
|
94
|
+
toolsPaths,
|
|
95
|
+
join(outputDirectory, this.outputDir)
|
|
96
|
+
);
|
|
97
|
+
const nodeVersion = process.version?.split(".")?.[0]?.replace("v", "") ?? "22";
|
|
98
|
+
writeFileSync(
|
|
99
|
+
join(outputDirectory, this.outputDir, ".vc-config.json"),
|
|
100
|
+
JSON.stringify(
|
|
101
|
+
{
|
|
102
|
+
handler: "index.mjs",
|
|
103
|
+
launcherType: "Nodejs",
|
|
104
|
+
runtime: `nodejs${nodeVersion}.x`,
|
|
105
|
+
shouldAddHelpers: true
|
|
106
|
+
},
|
|
107
|
+
null,
|
|
108
|
+
2
|
|
109
|
+
)
|
|
110
|
+
);
|
|
111
|
+
await move(join(outputDirectory, ".vercel", "output"), join(process.cwd(), ".vercel", "output"), {
|
|
112
|
+
overwrite: true
|
|
142
113
|
});
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
async deploy() {
|
|
117
|
+
this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
|
|
118
|
+
}
|
|
119
|
+
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
120
|
+
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
121
|
+
const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
|
|
122
|
+
if (hasLibsql) {
|
|
123
|
+
this.logger.error(
|
|
124
|
+
`Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
|
|
125
|
+
Use other Mastra Storage options instead e.g @mastra/pg`
|
|
126
|
+
);
|
|
127
|
+
process.exit(1);
|
|
148
128
|
}
|
|
149
129
|
}
|
|
150
130
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-vercel",
|
|
3
|
-
"version": "0.0.0-support-
|
|
3
|
+
"version": "0.0.0-support-d1-client-20250701191943",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -27,18 +27,21 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@rollup/plugin-virtual": "^3.0.2",
|
|
29
29
|
"fs-extra": "^11.3.0",
|
|
30
|
-
"@mastra/
|
|
31
|
-
"@mastra/deployer": "0.0.0-support-monorepos-20250415183219"
|
|
30
|
+
"@mastra/deployer": "0.0.0-support-d1-client-20250701191943"
|
|
32
31
|
},
|
|
33
32
|
"devDependencies": {
|
|
34
|
-
"@microsoft/api-extractor": "^7.52.
|
|
35
|
-
"@types/
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"vitest": "^3.
|
|
41
|
-
"@internal/lint": "0.0.
|
|
33
|
+
"@microsoft/api-extractor": "^7.52.8",
|
|
34
|
+
"@types/fs-extra": "^11.0.4",
|
|
35
|
+
"@types/node": "^20.19.0",
|
|
36
|
+
"eslint": "^9.29.0",
|
|
37
|
+
"tsup": "^8.5.0",
|
|
38
|
+
"typescript": "^5.8.3",
|
|
39
|
+
"vitest": "^3.2.4",
|
|
40
|
+
"@internal/lint": "0.0.0-support-d1-client-20250701191943",
|
|
41
|
+
"@mastra/core": "0.0.0-support-d1-client-20250701191943"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@mastra/core": "0.0.0-support-d1-client-20250701191943"
|
|
42
45
|
},
|
|
43
46
|
"scripts": {
|
|
44
47
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|