@mastra/deployer-vercel 0.0.0-separate-trace-data-from-component-20250501042644 → 0.0.0-share-agent-metadata-with-cloud-20250718110128
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.md +11 -42
- package/dist/_tsup-dts-rollup.d.cts +3 -12
- package/dist/_tsup-dts-rollup.d.ts +3 -12
- package/dist/index.cjs +51 -139
- package/dist/index.js +52 -121
- package/package.json +15 -12
package/LICENSE.md
CHANGED
|
@@ -1,46 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Apache License 2.0
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
17
|
-
|
|
18
|
-
**Patents**
|
|
19
|
-
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
20
|
-
|
|
21
|
-
**Notices**
|
|
22
|
-
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
23
|
-
|
|
24
|
-
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
25
|
-
|
|
26
|
-
**No Other Rights**
|
|
27
|
-
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
28
|
-
|
|
29
|
-
**Termination**
|
|
30
|
-
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
31
|
-
|
|
32
|
-
**No Liability**
|
|
33
|
-
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
34
|
-
|
|
35
|
-
**Definitions**
|
|
36
|
-
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
|
|
37
|
-
|
|
38
|
-
_you_ refers to the individual or entity agreeing to these terms.
|
|
39
|
-
|
|
40
|
-
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
41
|
-
|
|
42
|
-
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
43
|
-
|
|
44
|
-
_use_ means anything you do with the software requiring one of your licenses.
|
|
45
|
-
|
|
46
|
-
_trademark_ means trademarks, service marks, and similar rights.
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
@@ -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
|
-
private getProjectId;
|
|
13
|
-
private getTeamId;
|
|
14
|
-
private syncEnv;
|
|
4
|
+
constructor();
|
|
15
5
|
prepare(outputDirectory: string): Promise<void>;
|
|
16
6
|
private getEntry;
|
|
17
7
|
private writeVercelJSON;
|
|
18
8
|
bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
19
|
-
deploy(
|
|
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
|
-
private getProjectId;
|
|
13
|
-
private getTeamId;
|
|
14
|
-
private syncEnv;
|
|
4
|
+
constructor();
|
|
15
5
|
prepare(outputDirectory: string): Promise<void>;
|
|
16
6
|
private getEntry;
|
|
17
7
|
private writeVercelJSON;
|
|
18
8
|
bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
|
|
19
|
-
deploy(
|
|
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,107 +1,24 @@
|
|
|
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
|
-
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
|
-
}
|
|
17
|
+
this.outputDir = path.join(".vercel", "output", "functions", "index.func");
|
|
102
18
|
}
|
|
103
19
|
async prepare(outputDirectory) {
|
|
104
20
|
await super.prepare(outputDirectory);
|
|
21
|
+
this.writeVercelJSON(path.join(outputDirectory, this.outputDir, "..", ".."));
|
|
105
22
|
}
|
|
106
23
|
getEntry() {
|
|
107
24
|
return `
|
|
@@ -125,11 +42,6 @@ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agen
|
|
|
125
42
|
});
|
|
126
43
|
});
|
|
127
44
|
|
|
128
|
-
if (mastra.getStorage()) {
|
|
129
|
-
// start storage init in the background
|
|
130
|
-
mastra.getStorage().init();
|
|
131
|
-
}
|
|
132
|
-
|
|
133
45
|
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
134
46
|
const storage = mastra.getStorage();
|
|
135
47
|
if (storage) {
|
|
@@ -160,65 +72,65 @@ const app = await createHonoServer(mastra);
|
|
|
160
72
|
|
|
161
73
|
export const GET = handle(app);
|
|
162
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);
|
|
163
79
|
`;
|
|
164
80
|
}
|
|
165
|
-
writeVercelJSON(outputDirectory
|
|
81
|
+
writeVercelJSON(outputDirectory) {
|
|
166
82
|
fs.writeFileSync(
|
|
167
|
-
path.join(outputDirectory,
|
|
83
|
+
path.join(outputDirectory, "config.json"),
|
|
84
|
+
JSON.stringify({
|
|
85
|
+
version: 3,
|
|
86
|
+
routes: [
|
|
87
|
+
{
|
|
88
|
+
src: "/(.*)",
|
|
89
|
+
dest: "/"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
}
|
|
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"),
|
|
168
106
|
JSON.stringify(
|
|
169
107
|
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
src: "index.mjs",
|
|
175
|
-
use: "@vercel/node",
|
|
176
|
-
config: { includeFiles: files }
|
|
177
|
-
}
|
|
178
|
-
],
|
|
179
|
-
routes: [
|
|
180
|
-
{
|
|
181
|
-
src: "/(.*)",
|
|
182
|
-
dest: "index.mjs"
|
|
183
|
-
}
|
|
184
|
-
]
|
|
108
|
+
handler: "index.mjs",
|
|
109
|
+
launcherType: "Nodejs",
|
|
110
|
+
runtime: `nodejs${nodeVersion}.x`,
|
|
111
|
+
shouldAddHelpers: true
|
|
185
112
|
},
|
|
186
113
|
null,
|
|
187
114
|
2
|
|
188
115
|
)
|
|
189
116
|
);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const files = fs.readdirSync(path.join(outputDirectory, this.outputDir));
|
|
194
|
-
this.writeVercelJSON(outputDirectory, files);
|
|
117
|
+
await esm.move(path.join(outputDirectory, ".vercel", "output"), path.join(process__default.default.cwd(), ".vercel", "output"), {
|
|
118
|
+
overwrite: true
|
|
119
|
+
});
|
|
195
120
|
return result;
|
|
196
121
|
}
|
|
197
|
-
async deploy(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
];
|
|
210
|
-
child_process__namespace.execSync(`npx vercel ${commandArgs.join(" ")}`, {
|
|
211
|
-
cwd: path.join(outputDirectory, this.outputDir),
|
|
212
|
-
env: {
|
|
213
|
-
PATH: process__default.default.env.PATH
|
|
214
|
-
},
|
|
215
|
-
stdio: "inherit"
|
|
216
|
-
});
|
|
217
|
-
this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
|
|
218
|
-
if (envVars.size > 0) {
|
|
219
|
-
await this.syncEnv(envVars, { outputDirectory });
|
|
220
|
-
} else {
|
|
221
|
-
this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
|
|
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);
|
|
222
134
|
}
|
|
223
135
|
}
|
|
224
136
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,82 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { readFileSync, writeFileSync, readdirSync } 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
|
-
getProjectId({ dir }) {
|
|
19
|
-
const projectJsonPath = join(dir, "output", ".vercel", "project.json");
|
|
20
|
-
try {
|
|
21
|
-
const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
|
|
22
|
-
return projectJson.projectId;
|
|
23
|
-
} catch {
|
|
24
|
-
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
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 }) {
|
|
38
|
-
console.log("Syncing environment variables...");
|
|
39
|
-
const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
|
|
40
|
-
if (!key || !value) {
|
|
41
|
-
throw new Error(`Invalid environment variable format: ${key || value}`);
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
key,
|
|
45
|
-
value,
|
|
46
|
-
target: ["production", "preview", "development"],
|
|
47
|
-
type: "plain"
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
try {
|
|
51
|
-
const projectId = this.getProjectId({ dir: outputDirectory });
|
|
52
|
-
const teamId = await this.getTeamId();
|
|
53
|
-
const response = await fetch(
|
|
54
|
-
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
|
|
55
|
-
{
|
|
56
|
-
method: "POST",
|
|
57
|
-
headers: {
|
|
58
|
-
Authorization: `Bearer ${this.token}`,
|
|
59
|
-
"Content-Type": "application/json"
|
|
60
|
-
},
|
|
61
|
-
body: JSON.stringify(vercelEnvVars)
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
if (!response.ok) {
|
|
65
|
-
const error = await response.json();
|
|
66
|
-
throw new Error(`Failed to sync environment variables: ${error.message}`);
|
|
67
|
-
}
|
|
68
|
-
console.log("\u2713 Successfully synced environment variables");
|
|
69
|
-
} catch (error) {
|
|
70
|
-
if (error instanceof Error) {
|
|
71
|
-
console.error("Failed to sync environment variables:", error.message);
|
|
72
|
-
} else {
|
|
73
|
-
console.error("Failed to sync environment variables:", error);
|
|
74
|
-
}
|
|
75
|
-
throw error;
|
|
76
|
-
}
|
|
11
|
+
this.outputDir = join(".vercel", "output", "functions", "index.func");
|
|
77
12
|
}
|
|
78
13
|
async prepare(outputDirectory) {
|
|
79
14
|
await super.prepare(outputDirectory);
|
|
15
|
+
this.writeVercelJSON(join(outputDirectory, this.outputDir, "..", ".."));
|
|
80
16
|
}
|
|
81
17
|
getEntry() {
|
|
82
18
|
return `
|
|
@@ -100,11 +36,6 @@ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agen
|
|
|
100
36
|
});
|
|
101
37
|
});
|
|
102
38
|
|
|
103
|
-
if (mastra.getStorage()) {
|
|
104
|
-
// start storage init in the background
|
|
105
|
-
mastra.getStorage().init();
|
|
106
|
-
}
|
|
107
|
-
|
|
108
39
|
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
109
40
|
const storage = mastra.getStorage();
|
|
110
41
|
if (storage) {
|
|
@@ -135,65 +66,65 @@ const app = await createHonoServer(mastra);
|
|
|
135
66
|
|
|
136
67
|
export const GET = handle(app);
|
|
137
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);
|
|
138
73
|
`;
|
|
139
74
|
}
|
|
140
|
-
writeVercelJSON(outputDirectory
|
|
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
|
+
);
|
|
88
|
+
}
|
|
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";
|
|
141
98
|
writeFileSync(
|
|
142
|
-
join(outputDirectory, this.outputDir, "
|
|
99
|
+
join(outputDirectory, this.outputDir, ".vc-config.json"),
|
|
143
100
|
JSON.stringify(
|
|
144
101
|
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
src: "index.mjs",
|
|
150
|
-
use: "@vercel/node",
|
|
151
|
-
config: { includeFiles: files }
|
|
152
|
-
}
|
|
153
|
-
],
|
|
154
|
-
routes: [
|
|
155
|
-
{
|
|
156
|
-
src: "/(.*)",
|
|
157
|
-
dest: "index.mjs"
|
|
158
|
-
}
|
|
159
|
-
]
|
|
102
|
+
handler: "index.mjs",
|
|
103
|
+
launcherType: "Nodejs",
|
|
104
|
+
runtime: `nodejs${nodeVersion}.x`,
|
|
105
|
+
shouldAddHelpers: true
|
|
160
106
|
},
|
|
161
107
|
null,
|
|
162
108
|
2
|
|
163
109
|
)
|
|
164
110
|
);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
const files = readdirSync(join(outputDirectory, this.outputDir));
|
|
169
|
-
this.writeVercelJSON(outputDirectory, files);
|
|
111
|
+
await move(join(outputDirectory, ".vercel", "output"), join(process.cwd(), ".vercel", "output"), {
|
|
112
|
+
overwrite: true
|
|
113
|
+
});
|
|
170
114
|
return result;
|
|
171
115
|
}
|
|
172
|
-
async deploy(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
];
|
|
185
|
-
child_process.execSync(`npx vercel ${commandArgs.join(" ")}`, {
|
|
186
|
-
cwd: join(outputDirectory, this.outputDir),
|
|
187
|
-
env: {
|
|
188
|
-
PATH: process.env.PATH
|
|
189
|
-
},
|
|
190
|
-
stdio: "inherit"
|
|
191
|
-
});
|
|
192
|
-
this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
|
|
193
|
-
if (envVars.size > 0) {
|
|
194
|
-
await this.syncEnv(envVars, { outputDirectory });
|
|
195
|
-
} else {
|
|
196
|
-
this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
|
|
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);
|
|
197
128
|
}
|
|
198
129
|
}
|
|
199
130
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-vercel",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-share-agent-metadata-with-cloud-20250718110128",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -23,22 +23,25 @@
|
|
|
23
23
|
},
|
|
24
24
|
"keywords": [],
|
|
25
25
|
"author": "",
|
|
26
|
-
"license": "
|
|
26
|
+
"license": "Apache-2.0",
|
|
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-separate-trace-data-from-component-20250501042644"
|
|
30
|
+
"@mastra/deployer": "0.0.0-share-agent-metadata-with-cloud-20250718110128"
|
|
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.30.1",
|
|
37
|
+
"tsup": "^8.5.0",
|
|
38
|
+
"typescript": "^5.8.3",
|
|
39
|
+
"vitest": "^3.2.4",
|
|
40
|
+
"@internal/lint": "0.0.0-share-agent-metadata-with-cloud-20250718110128",
|
|
41
|
+
"@mastra/core": "0.0.0-share-agent-metadata-with-cloud-20250718110128"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@mastra/core": "0.0.0-share-agent-metadata-with-cloud-20250718110128"
|
|
42
45
|
},
|
|
43
46
|
"scripts": {
|
|
44
47
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|