@mastra/deployer-vercel 0.0.0-storage-20250225005900 → 0.0.0-trigger-playground-ui-package-20250506151043
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 +234 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.js +109 -44
- package/package.json +27 -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,234 @@
|
|
|
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
|
+
if (mastra.getStorage()) {
|
|
129
|
+
// start storage init in the background
|
|
130
|
+
mastra.getStorage().init();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
134
|
+
const storage = mastra.getStorage();
|
|
135
|
+
if (storage) {
|
|
136
|
+
// Check for required fields
|
|
137
|
+
const logger = mastra?.getLogger();
|
|
138
|
+
const areFieldsValid = checkEvalStorageFields(traceObject, logger);
|
|
139
|
+
if (!areFieldsValid) return;
|
|
140
|
+
|
|
141
|
+
await storage.insert({
|
|
142
|
+
tableName: TABLE_EVALS,
|
|
143
|
+
record: {
|
|
144
|
+
input: traceObject.input,
|
|
145
|
+
output: traceObject.output,
|
|
146
|
+
result: JSON.stringify(traceObject.result || {}),
|
|
147
|
+
agent_name: traceObject.agentName,
|
|
148
|
+
metric_name: traceObject.metricName,
|
|
149
|
+
instructions: traceObject.instructions,
|
|
150
|
+
test_info: null,
|
|
151
|
+
global_run_id: traceObject.globalRunId,
|
|
152
|
+
run_id: traceObject.runId,
|
|
153
|
+
created_at: new Date().toISOString(),
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const app = await createHonoServer(mastra);
|
|
160
|
+
|
|
161
|
+
export const GET = handle(app);
|
|
162
|
+
export const POST = handle(app);
|
|
163
|
+
`;
|
|
164
|
+
}
|
|
165
|
+
writeVercelJSON(outputDirectory, files = ["./*"]) {
|
|
166
|
+
fs.writeFileSync(
|
|
167
|
+
path.join(outputDirectory, this.outputDir, "vercel.json"),
|
|
168
|
+
JSON.stringify(
|
|
169
|
+
{
|
|
170
|
+
version: 2,
|
|
171
|
+
installCommand: "npm install --omit=dev",
|
|
172
|
+
builds: [
|
|
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
|
+
]
|
|
185
|
+
},
|
|
186
|
+
null,
|
|
187
|
+
2
|
|
188
|
+
)
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
192
|
+
const result = await this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
|
|
193
|
+
const files = fs.readdirSync(path.join(outputDirectory, this.outputDir), {
|
|
194
|
+
recursive: true
|
|
195
|
+
});
|
|
196
|
+
const filesWithoutNodeModules = files.filter(
|
|
197
|
+
(file) => typeof file === "string" && !file.startsWith("node_modules")
|
|
198
|
+
);
|
|
199
|
+
this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
async deploy(outputDirectory) {
|
|
203
|
+
const envVars = await this.loadEnvVars();
|
|
204
|
+
const commandArgs = [
|
|
205
|
+
"--scope",
|
|
206
|
+
this.teamSlug,
|
|
207
|
+
"--cwd",
|
|
208
|
+
path.join(outputDirectory, this.outputDir),
|
|
209
|
+
"--token",
|
|
210
|
+
this.token,
|
|
211
|
+
"deploy",
|
|
212
|
+
"--yes",
|
|
213
|
+
...this.projectName ? ["--name", this.projectName] : []
|
|
214
|
+
];
|
|
215
|
+
child_process__namespace.execSync(`npx vercel ${commandArgs.join(" ")}`, {
|
|
216
|
+
cwd: path.join(outputDirectory, this.outputDir),
|
|
217
|
+
env: {
|
|
218
|
+
PATH: process__default.default.env.PATH
|
|
219
|
+
},
|
|
220
|
+
stdio: "inherit"
|
|
221
|
+
});
|
|
222
|
+
this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
|
|
223
|
+
if (envVars.size > 0) {
|
|
224
|
+
await this.syncEnv(envVars, { outputDirectory });
|
|
225
|
+
} else {
|
|
226
|
+
this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
230
|
+
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
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,13 +77,59 @@ 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
|
+
if (mastra.getStorage()) {
|
|
104
|
+
// start storage init in the background
|
|
105
|
+
mastra.getStorage().init();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
|
|
109
|
+
const storage = mastra.getStorage();
|
|
110
|
+
if (storage) {
|
|
111
|
+
// Check for required fields
|
|
112
|
+
const logger = mastra?.getLogger();
|
|
113
|
+
const areFieldsValid = checkEvalStorageFields(traceObject, logger);
|
|
114
|
+
if (!areFieldsValid) return;
|
|
115
|
+
|
|
116
|
+
await storage.insert({
|
|
117
|
+
tableName: TABLE_EVALS,
|
|
118
|
+
record: {
|
|
119
|
+
input: traceObject.input,
|
|
120
|
+
output: traceObject.output,
|
|
121
|
+
result: JSON.stringify(traceObject.result || {}),
|
|
122
|
+
agent_name: traceObject.agentName,
|
|
123
|
+
metric_name: traceObject.metricName,
|
|
124
|
+
instructions: traceObject.instructions,
|
|
125
|
+
test_info: null,
|
|
126
|
+
global_run_id: traceObject.globalRunId,
|
|
127
|
+
run_id: traceObject.runId,
|
|
128
|
+
created_at: new Date().toISOString(),
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
104
133
|
|
|
105
134
|
const app = await createHonoServer(mastra);
|
|
106
135
|
|
|
@@ -108,14 +137,48 @@ export const GET = handle(app);
|
|
|
108
137
|
export const POST = handle(app);
|
|
109
138
|
`;
|
|
110
139
|
}
|
|
111
|
-
|
|
112
|
-
|
|
140
|
+
writeVercelJSON(outputDirectory, files = ["./*"]) {
|
|
141
|
+
writeFileSync(
|
|
142
|
+
join(outputDirectory, this.outputDir, "vercel.json"),
|
|
143
|
+
JSON.stringify(
|
|
144
|
+
{
|
|
145
|
+
version: 2,
|
|
146
|
+
installCommand: "npm install --omit=dev",
|
|
147
|
+
builds: [
|
|
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
|
+
]
|
|
160
|
+
},
|
|
161
|
+
null,
|
|
162
|
+
2
|
|
163
|
+
)
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
async bundle(entryFile, outputDirectory, toolsPaths) {
|
|
167
|
+
const result = await this._bundle(this.getEntry(), entryFile, outputDirectory, toolsPaths);
|
|
168
|
+
const files = readdirSync(join(outputDirectory, this.outputDir), {
|
|
169
|
+
recursive: true
|
|
170
|
+
});
|
|
171
|
+
const filesWithoutNodeModules = files.filter(
|
|
172
|
+
(file) => typeof file === "string" && !file.startsWith("node_modules")
|
|
173
|
+
);
|
|
174
|
+
this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
|
|
175
|
+
return result;
|
|
113
176
|
}
|
|
114
177
|
async deploy(outputDirectory) {
|
|
115
178
|
const envVars = await this.loadEnvVars();
|
|
116
179
|
const commandArgs = [
|
|
117
180
|
"--scope",
|
|
118
|
-
this.
|
|
181
|
+
this.teamSlug,
|
|
119
182
|
"--cwd",
|
|
120
183
|
join(outputDirectory, this.outputDir),
|
|
121
184
|
"--token",
|
|
@@ -127,18 +190,20 @@ export const POST = handle(app);
|
|
|
127
190
|
child_process.execSync(`npx vercel ${commandArgs.join(" ")}`, {
|
|
128
191
|
cwd: join(outputDirectory, this.outputDir),
|
|
129
192
|
env: {
|
|
130
|
-
// ...this.env,
|
|
131
193
|
PATH: process.env.PATH
|
|
132
194
|
},
|
|
133
195
|
stdio: "inherit"
|
|
134
196
|
});
|
|
135
197
|
this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
|
|
136
198
|
if (envVars.size > 0) {
|
|
137
|
-
await this.syncEnv(envVars);
|
|
199
|
+
await this.syncEnv(envVars, { outputDirectory });
|
|
138
200
|
} else {
|
|
139
201
|
this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
|
|
140
202
|
}
|
|
141
203
|
}
|
|
204
|
+
async lint(entryFile, outputDirectory, toolsPaths) {
|
|
205
|
+
await super.lint(entryFile, outputDirectory, toolsPaths);
|
|
206
|
+
}
|
|
142
207
|
};
|
|
143
208
|
|
|
144
209
|
export { VercelDeployer };
|
package/package.json
CHANGED
|
@@ -1,37 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/deployer-vercel",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-trigger-playground-ui-package-20250506151043",
|
|
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/core": "
|
|
22
|
-
"@mastra/deployer": "
|
|
29
|
+
"fs-extra": "^11.3.0",
|
|
30
|
+
"@mastra/core": "0.0.0-trigger-playground-ui-package-20250506151043",
|
|
31
|
+
"@mastra/deployer": "0.0.0-trigger-playground-ui-package-20250506151043"
|
|
23
32
|
},
|
|
24
33
|
"devDependencies": {
|
|
25
|
-
"@microsoft/api-extractor": "^7.
|
|
26
|
-
"@types/node": "^
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
34
|
+
"@microsoft/api-extractor": "^7.52.5",
|
|
35
|
+
"@types/node": "^20.17.27",
|
|
36
|
+
"eslint": "^9.23.0",
|
|
37
|
+
"tsup": "^8.4.0",
|
|
38
|
+
"typescript": "^5.8.2",
|
|
39
|
+
"vercel": "^39.4.2",
|
|
40
|
+
"vitest": "^3.1.2",
|
|
41
|
+
"@internal/lint": "0.0.0-trigger-playground-ui-package-20250506151043"
|
|
31
42
|
},
|
|
32
43
|
"scripts": {
|
|
33
|
-
"build": "tsup src/index.ts --format esm --experimental-dts --clean --treeshake",
|
|
44
|
+
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
|
34
45
|
"build:watch": "pnpm build --watch",
|
|
35
|
-
"test": "vitest run"
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"lint": "eslint ."
|
|
36
48
|
}
|
|
37
49
|
}
|
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
|