@mastra/deployer-vercel 0.0.0-storage-20250225005900 → 0.0.0-vnextWorkflows-20250416071310
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 +22 -0
- package/dist/_tsup-dts-rollup.d.ts +4 -3
- package/dist/index.cjs +177 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.js +22 -14
- 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,22 @@
|
|
|
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
|
+
writeFiles(outputDirectory: string): void;
|
|
13
|
+
private getProjectId;
|
|
14
|
+
private getTeamId;
|
|
15
|
+
private syncEnv;
|
|
16
|
+
prepare(outputDirectory: string): Promise<void>;
|
|
17
|
+
private getEntry;
|
|
18
|
+
bundle(entryFile: string, outputDirectory: string): Promise<void>;
|
|
19
|
+
deploy(outputDirectory: string): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export { }
|
|
@@ -1,16 +1,17 @@
|
|
|
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
12
|
writeFiles(outputDirectory: string): void;
|
|
13
13
|
private getProjectId;
|
|
14
|
+
private getTeamId;
|
|
14
15
|
private syncEnv;
|
|
15
16
|
prepare(outputDirectory: string): Promise<void>;
|
|
16
17
|
private getEntry;
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
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
|
+
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
|
+
}
|
|
128
|
+
}
|
|
129
|
+
async prepare(outputDirectory) {
|
|
130
|
+
await super.prepare(outputDirectory);
|
|
131
|
+
await this.writeFiles(outputDirectory);
|
|
132
|
+
}
|
|
133
|
+
getEntry() {
|
|
134
|
+
return `
|
|
135
|
+
import { handle } from 'hono/vercel'
|
|
136
|
+
import { mastra } from '#mastra';
|
|
137
|
+
import { createHonoServer } from '#server';
|
|
138
|
+
|
|
139
|
+
const app = await createHonoServer(mastra);
|
|
140
|
+
|
|
141
|
+
export const GET = handle(app);
|
|
142
|
+
export const POST = handle(app);
|
|
143
|
+
`;
|
|
144
|
+
}
|
|
145
|
+
async bundle(entryFile, outputDirectory) {
|
|
146
|
+
return this._bundle(this.getEntry(), entryFile, outputDirectory);
|
|
147
|
+
}
|
|
148
|
+
async deploy(outputDirectory) {
|
|
149
|
+
const envVars = await this.loadEnvVars();
|
|
150
|
+
const commandArgs = [
|
|
151
|
+
"--scope",
|
|
152
|
+
this.teamSlug,
|
|
153
|
+
"--cwd",
|
|
154
|
+
path.join(outputDirectory, this.outputDir),
|
|
155
|
+
"--token",
|
|
156
|
+
this.token,
|
|
157
|
+
"deploy",
|
|
158
|
+
"--yes",
|
|
159
|
+
...this.projectName ? ["--name", this.projectName] : []
|
|
160
|
+
];
|
|
161
|
+
child_process__namespace.execSync(`npx vercel ${commandArgs.join(" ")}`, {
|
|
162
|
+
cwd: path.join(outputDirectory, this.outputDir),
|
|
163
|
+
env: {
|
|
164
|
+
PATH: process__default.default.env.PATH
|
|
165
|
+
},
|
|
166
|
+
stdio: "inherit"
|
|
167
|
+
});
|
|
168
|
+
this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
|
|
169
|
+
if (envVars.size > 0) {
|
|
170
|
+
await this.syncEnv(envVars, { outputDirectory });
|
|
171
|
+
} else {
|
|
172
|
+
this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
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,19 +1,17 @@
|
|
|
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
2
|
import { writeFileSync, readFileSync } 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
|
}
|
|
@@ -44,15 +42,25 @@ var VercelDeployer = class extends Deployer {
|
|
|
44
42
|
);
|
|
45
43
|
}
|
|
46
44
|
getProjectId({ dir }) {
|
|
47
|
-
const projectJsonPath = join(dir, ".vercel", "project.json");
|
|
45
|
+
const projectJsonPath = join(dir, "output", ".vercel", "project.json");
|
|
48
46
|
try {
|
|
49
47
|
const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
|
|
50
48
|
return projectJson.projectId;
|
|
51
|
-
} catch
|
|
49
|
+
} catch {
|
|
52
50
|
throw new Error("Could not find project ID. Make sure the project has been deployed first.");
|
|
53
51
|
}
|
|
54
52
|
}
|
|
55
|
-
async
|
|
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 }) {
|
|
56
64
|
console.log("Syncing environment variables...");
|
|
57
65
|
const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
|
|
58
66
|
if (!key || !value) {
|
|
@@ -66,9 +74,10 @@ var VercelDeployer = class extends Deployer {
|
|
|
66
74
|
};
|
|
67
75
|
});
|
|
68
76
|
try {
|
|
69
|
-
const projectId = this.getProjectId({ dir:
|
|
77
|
+
const projectId = this.getProjectId({ dir: outputDirectory });
|
|
78
|
+
const teamId = await this.getTeamId();
|
|
70
79
|
const response = await fetch(
|
|
71
|
-
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${
|
|
80
|
+
`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
|
|
72
81
|
{
|
|
73
82
|
method: "POST",
|
|
74
83
|
headers: {
|
|
@@ -115,7 +124,7 @@ export const POST = handle(app);
|
|
|
115
124
|
const envVars = await this.loadEnvVars();
|
|
116
125
|
const commandArgs = [
|
|
117
126
|
"--scope",
|
|
118
|
-
this.
|
|
127
|
+
this.teamSlug,
|
|
119
128
|
"--cwd",
|
|
120
129
|
join(outputDirectory, this.outputDir),
|
|
121
130
|
"--token",
|
|
@@ -127,14 +136,13 @@ export const POST = handle(app);
|
|
|
127
136
|
child_process.execSync(`npx vercel ${commandArgs.join(" ")}`, {
|
|
128
137
|
cwd: join(outputDirectory, this.outputDir),
|
|
129
138
|
env: {
|
|
130
|
-
// ...this.env,
|
|
131
139
|
PATH: process.env.PATH
|
|
132
140
|
},
|
|
133
141
|
stdio: "inherit"
|
|
134
142
|
});
|
|
135
143
|
this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
|
|
136
144
|
if (envVars.size > 0) {
|
|
137
|
-
await this.syncEnv(envVars);
|
|
145
|
+
await this.syncEnv(envVars, { outputDirectory });
|
|
138
146
|
} else {
|
|
139
147
|
this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
|
|
140
148
|
}
|
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-vnextWorkflows-20250416071310",
|
|
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/
|
|
29
|
+
"fs-extra": "^11.3.0",
|
|
30
|
+
"@mastra/deployer": "0.0.0-vnextWorkflows-20250416071310",
|
|
31
|
+
"@mastra/core": "0.0.0-vnextWorkflows-20250416071310"
|
|
23
32
|
},
|
|
24
33
|
"devDependencies": {
|
|
25
|
-
"@microsoft/api-extractor": "^7.
|
|
26
|
-
"@types/node": "^
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
34
|
+
"@microsoft/api-extractor": "^7.52.1",
|
|
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.0.9",
|
|
41
|
+
"@internal/lint": "0.0.2"
|
|
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
|