@mastra/deployer-vercel 0.0.1-alpha.9 → 0.1.0-alpha.38

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/CHANGELOG.md CHANGED
@@ -1,5 +1,256 @@
1
1
  # @mastra/deployer-vercel
2
2
 
3
+ ## 0.1.0-alpha.38
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [7365b6c]
8
+ - @mastra/core@0.2.0-alpha.87
9
+ - @mastra/deployer@0.1.0-alpha.33
10
+
11
+ ## 0.1.0-alpha.37
12
+
13
+ ### Minor Changes
14
+
15
+ - 5916f9d: Update deps from fixed to ^
16
+
17
+ ### Patch Changes
18
+
19
+ - Updated dependencies [6fa4bd2]
20
+ - Updated dependencies [5916f9d]
21
+ - Updated dependencies [e2e76de]
22
+ - Updated dependencies [7f24c29]
23
+ - Updated dependencies [67637ba]
24
+ - Updated dependencies [04f3171]
25
+ - @mastra/core@0.2.0-alpha.86
26
+ - @mastra/deployer@0.1.0-alpha.32
27
+
28
+ ## 0.0.1-alpha.36
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [e9d1b47]
33
+ - Updated dependencies [c5f2d50]
34
+ - @mastra/core@0.2.0-alpha.85
35
+ - @mastra/deployer@0.0.1-alpha.31
36
+
37
+ ## 0.0.1-alpha.35
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [e27fe69]
42
+ - @mastra/deployer@0.0.1-alpha.30
43
+
44
+ ## 0.0.1-alpha.34
45
+
46
+ ### Patch Changes
47
+
48
+ - 38b7f66: Update deployer logic
49
+ - Updated dependencies [2f17a5f]
50
+ - Updated dependencies [0696eeb]
51
+ - Updated dependencies [cb290ee]
52
+ - Updated dependencies [b4d7416]
53
+ - Updated dependencies [38b7f66]
54
+ - @mastra/core@0.2.0-alpha.84
55
+ - @mastra/deployer@0.0.1-alpha.29
56
+
57
+ ## 0.0.1-alpha.33
58
+
59
+ ### Patch Changes
60
+
61
+ - 9625602: Use mastra core splitted bundles in other packages
62
+ - Updated dependencies [2ab57d6]
63
+ - Updated dependencies [30322ce]
64
+ - Updated dependencies [78eec7c]
65
+ - Updated dependencies [9625602]
66
+ - Updated dependencies [8769a62]
67
+ - @mastra/deployer@0.0.1-alpha.28
68
+ - @mastra/core@0.2.0-alpha.83
69
+
70
+ ## 0.0.1-alpha.32
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies [73d112c]
75
+ - Updated dependencies [ac8c61a]
76
+ - @mastra/deployer@0.0.1-alpha.27
77
+ - @mastra/core@0.1.27-alpha.82
78
+
79
+ ## 0.0.1-alpha.31
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies [9fb3039]
84
+ - @mastra/core@0.1.27-alpha.81
85
+ - @mastra/deployer@0.0.1-alpha.26
86
+
87
+ ## 0.0.1-alpha.30
88
+
89
+ ### Patch Changes
90
+
91
+ - 327ece7: Updates for ts versions
92
+ - Updated dependencies [327ece7]
93
+ - @mastra/core@0.1.27-alpha.80
94
+ - @mastra/deployer@0.0.1-alpha.25
95
+
96
+ ## 0.0.1-alpha.29
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [21fe536]
101
+ - @mastra/core@0.1.27-alpha.79
102
+ - @mastra/deployer@0.0.1-alpha.24
103
+
104
+ ## 0.0.1-alpha.28
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies [88f18d7]
109
+ - @mastra/deployer@0.0.1-alpha.23
110
+
111
+ ## 0.0.1-alpha.27
112
+
113
+ ### Patch Changes
114
+
115
+ - 44c7c26: Rebuild
116
+
117
+ ## 0.0.1-alpha.26
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [685108a]
122
+ - Updated dependencies [685108a]
123
+ - @mastra/deployer@0.0.1-alpha.22
124
+ - @mastra/core@0.1.27-alpha.78
125
+
126
+ ## 0.0.1-alpha.25
127
+
128
+ ### Patch Changes
129
+
130
+ - 2b75edf: mastra deployers tsup bundling
131
+ - Updated dependencies [8105fae]
132
+ - Updated dependencies [cfb966f]
133
+ - @mastra/core@0.1.27-alpha.77
134
+ - @mastra/deployer@0.0.1-alpha.21
135
+
136
+ ## 0.0.1-alpha.24
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies [ae7bf94]
141
+ - Updated dependencies [ae7bf94]
142
+ - @mastra/deployer@0.0.1-alpha.20
143
+ - @mastra/core@0.1.27-alpha.76
144
+
145
+ ## 0.0.1-alpha.23
146
+
147
+ ### Patch Changes
148
+
149
+ - Updated dependencies [23dcb23]
150
+ - Updated dependencies [7064554]
151
+ - @mastra/core@0.1.27-alpha.75
152
+ - @mastra/deployer@0.0.1-alpha.19
153
+
154
+ ## 0.0.1-alpha.22
155
+
156
+ ### Patch Changes
157
+
158
+ - Updated dependencies [7b87567]
159
+ - @mastra/core@0.1.27-alpha.74
160
+ - @mastra/deployer@0.0.1-alpha.18
161
+
162
+ ## 0.0.1-alpha.21
163
+
164
+ ### Patch Changes
165
+
166
+ - Updated dependencies [3427b95]
167
+ - @mastra/core@0.1.27-alpha.73
168
+ - @mastra/deployer@0.0.1-alpha.17
169
+
170
+ ## 0.0.1-alpha.20
171
+
172
+ ### Patch Changes
173
+
174
+ - Updated dependencies [e4d4ede]
175
+ - Updated dependencies [06b2c0a]
176
+ - @mastra/core@0.1.27-alpha.72
177
+ - @mastra/deployer@0.0.1-alpha.16
178
+
179
+ ## 0.0.1-alpha.19
180
+
181
+ ### Patch Changes
182
+
183
+ - Updated dependencies [d9c8dd0]
184
+ - @mastra/deployer@0.0.1-alpha.15
185
+ - @mastra/core@0.1.27-alpha.71
186
+
187
+ ## 0.0.1-alpha.18
188
+
189
+ ### Patch Changes
190
+
191
+ - Updated dependencies [ad2cd74]
192
+ - @mastra/deployer@0.0.1-alpha.14
193
+
194
+ ## 0.0.1-alpha.17
195
+
196
+ ### Patch Changes
197
+
198
+ - Updated dependencies [a1774e7]
199
+ - @mastra/deployer@0.0.1-alpha.13
200
+
201
+ ## 0.0.1-alpha.16
202
+
203
+ ### Patch Changes
204
+
205
+ - Updated dependencies [28dceab]
206
+ - @mastra/deployer@0.0.1-alpha.12
207
+
208
+ ## 0.0.1-alpha.15
209
+
210
+ ### Patch Changes
211
+
212
+ - bdaf834: publish packages
213
+ - Updated dependencies [bdaf834]
214
+ - @mastra/deployer@0.0.1-alpha.11
215
+
216
+ ## 0.0.1-alpha.14
217
+
218
+ ### Patch Changes
219
+
220
+ - Updated dependencies [dd6d87f]
221
+ - Updated dependencies [04434b6]
222
+ - @mastra/core@0.1.27-alpha.70
223
+ - @mastra/deployer@0.0.1-alpha.10
224
+
225
+ ## 0.0.1-alpha.13
226
+
227
+ ### Patch Changes
228
+
229
+ - Updated dependencies [9066f95]
230
+ - @mastra/deployer@0.0.1-alpha.9
231
+
232
+ ## 0.0.1-alpha.12
233
+
234
+ ### Patch Changes
235
+
236
+ - 0d5a03d: Vector store modules
237
+
238
+ ## 0.0.1-alpha.11
239
+
240
+ ### Patch Changes
241
+
242
+ - Updated dependencies [b425845]
243
+ - @mastra/deployer@0.0.1-alpha.8
244
+
245
+ ## 0.0.1-alpha.10
246
+
247
+ ### Patch Changes
248
+
249
+ - Updated dependencies [1944807]
250
+ - Updated dependencies [9ade36e]
251
+ - @mastra/deployer@0.0.1-alpha.7
252
+ - @mastra/core@0.1.27-alpha.69
253
+
3
254
  ## 0.0.1-alpha.9
4
255
 
5
256
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # @mastra/deployer-vercel
2
+
3
+ A Vercel deployer for Mastra applications.
4
+
5
+ ## Features
6
+
7
+ - Deploy Mastra applications to Vercel
8
+ - Zero-configuration serverless deployments
9
+ - Automatic environment variable synchronization
10
+ - Support for production, preview, and development environments
11
+ - Instant global deployments with Edge Functions
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pnpm add @mastra/deployer-vercel
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ The Vercel deployer is used as part of the Mastra framework:
22
+
23
+ ```typescript
24
+ import { Mastra } from '@mastra/core';
25
+ import { VercelDeployer } from '@mastra/deployer-vercel';
26
+
27
+ const deployer = new VercelDeployer({
28
+ scope: 'your-team-id',
29
+ projectName: 'your-project-name',
30
+ });
31
+
32
+ const mastra = new Mastra({
33
+ deployer,
34
+ // ... other Mastra configuration options
35
+ });
36
+ ```
37
+
38
+ ## Configuration
39
+
40
+ ### Constructor Options
41
+
42
+ - `scope` (required): Your Vercel team ID or username
43
+ - `projectName`: Name of your Vercel project (will be created if it doesn't exist)
44
+
45
+ ## Project Structure
46
+
47
+ The deployer creates:
48
+
49
+ ```
50
+ your-project/
51
+ ├── vercel.json # Deployment configuration
52
+ └── index.mjs # Application entry point
53
+ ```
54
+
55
+ ### vercel.json Configuration
56
+
57
+ Default configuration:
58
+
59
+ ```json
60
+ {
61
+ "version": 2,
62
+ "installCommand": "npm install --omit=dev",
63
+ "builds": [
64
+ {
65
+ "src": "index.mjs",
66
+ "use": "@vercel/node",
67
+ "config": {
68
+ "includeFiles": ["**"]
69
+ }
70
+ }
71
+ ],
72
+ "routes": [
73
+ {
74
+ "src": "/(.*)",
75
+ "dest": "index.mjs"
76
+ }
77
+ ]
78
+ }
79
+ ```
80
+
81
+ ## Environment Variables
82
+
83
+ Environment variables are handled automatically through:
84
+
85
+ - `.env` files in your project
86
+ - Environment variables passed through the Mastra configuration
87
+ - Vercel's environment variable UI
88
+
89
+ ## Deployment Process
90
+
91
+ The deployer:
92
+
93
+ 1. Configures your project with the necessary files
94
+ 2. Deploys to Vercel using the CLI
95
+ 3. Synchronizes environment variables for future deployments
package/dist/index.d.ts CHANGED
@@ -1,25 +1,21 @@
1
- import { MastraDeployer } from '@mastra/core';
2
- export declare class VercelDeployer extends MastraDeployer {
3
- constructor({ scope, env, projectName }: {
4
- env?: Record<string, any>;
5
- scope: string;
1
+ import { Deployer } from '@mastra/deployer';
2
+
3
+ declare class VercelDeployer extends Deployer {
4
+ private teamId;
5
+ private projectName;
6
+ private token;
7
+ constructor({ teamId, projectName, token }: {
8
+ teamId: string;
6
9
  projectName: string;
10
+ token: string;
7
11
  });
8
- writeFiles({ dir }: {
9
- dir: string;
10
- }): void;
12
+ writeFiles(outputDirectory: string): void;
11
13
  private getProjectId;
12
- syncEnv({ scope, dir, token }: {
13
- token: string;
14
- dir: string;
15
- scope: string;
16
- }): Promise<void>;
17
- deploy({ dir, token }: {
18
- dir: string;
19
- token: string;
20
- }): Promise<void>;
21
- writeIndex({ dir }: {
22
- dir: string;
23
- }): void;
14
+ private syncEnv;
15
+ prepare(outputDirectory: string): Promise<void>;
16
+ private getEntry;
17
+ bundle(mastraDir: string, outputDirectory: string): Promise<void>;
18
+ deploy(outputDirectory: string): Promise<void>;
24
19
  }
25
- //# sourceMappingURL=index.d.ts.map
20
+
21
+ export { VercelDeployer };
package/dist/index.js CHANGED
@@ -1,8 +1,152 @@
1
+ import { Deployer } from '@mastra/deployer';
2
+ import { getBundler } from '@mastra/deployer/build';
3
+ import virtual from '@rollup/plugin-virtual';
4
+ import * as child_process from 'child_process';
5
+ import { writeFileSync, readFileSync } from 'fs';
6
+ import { join } from 'path';
7
+ import process from 'process';
1
8
 
2
- 'use strict'
9
+ // src/index.ts
10
+ var VercelDeployer = class extends Deployer {
11
+ teamId;
12
+ projectName;
13
+ token;
14
+ constructor({ teamId, projectName, token }) {
15
+ super({ name: "VERCEL" });
16
+ this.teamId = teamId;
17
+ this.projectName = projectName;
18
+ this.token = token;
19
+ }
20
+ writeFiles(outputDirectory) {
21
+ writeFileSync(
22
+ join(outputDirectory, "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
+ getProjectId({ dir }) {
47
+ const projectJsonPath = join(dir, ".vercel", "project.json");
48
+ try {
49
+ const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
50
+ return projectJson.projectId;
51
+ } catch (error) {
52
+ throw new Error("Could not find project ID. Make sure the project has been deployed first.");
53
+ }
54
+ }
55
+ async syncEnv(envVars) {
56
+ console.log("Syncing environment variables...");
57
+ const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
58
+ if (!key || !value) {
59
+ throw new Error(`Invalid environment variable format: ${key || value}`);
60
+ }
61
+ return {
62
+ key,
63
+ value,
64
+ target: ["production", "preview", "development"],
65
+ type: "plain"
66
+ };
67
+ });
68
+ try {
69
+ const projectId = this.getProjectId({ dir: process.cwd() });
70
+ const response = await fetch(
71
+ `https://api.vercel.com/v10/projects/${projectId}/env?teamId=${this.teamId}&upsert=true`,
72
+ {
73
+ method: "POST",
74
+ headers: {
75
+ Authorization: `Bearer ${this.token}`,
76
+ "Content-Type": "application/json"
77
+ },
78
+ body: JSON.stringify(vercelEnvVars)
79
+ }
80
+ );
81
+ if (!response.ok) {
82
+ const error = await response.json();
83
+ throw new Error(`Failed to sync environment variables: ${error.message}`);
84
+ }
85
+ console.log("\u2713 Successfully synced environment variables");
86
+ } catch (error) {
87
+ if (error instanceof Error) {
88
+ console.error("Failed to sync environment variables:", error.message);
89
+ } else {
90
+ console.error("Failed to sync environment variables:", error);
91
+ }
92
+ throw error;
93
+ }
94
+ }
95
+ async prepare(outputDirectory) {
96
+ await super.prepare(outputDirectory);
97
+ await this.writeFiles(outputDirectory);
98
+ }
99
+ getEntry() {
100
+ return `
101
+ import { handle } from 'hono/vercel'
102
+ import { mastra } from '#mastra';
103
+ import { createHonoServer } from '#server';
3
104
 
4
- if (process.env.NODE_ENV === 'production') {
5
- module.exports = require('./deployer-vercel.cjs.production.min.js')
6
- } else {
7
- module.exports = require('./deployer-vercel.cjs.development.js')
8
- }
105
+ const app = await createHonoServer(mastra);
106
+
107
+ export const GET = handle(app);
108
+ export const POST = handle(app);
109
+ `;
110
+ }
111
+ async bundle(mastraDir, outputDirectory) {
112
+ const bundler = await getBundler({
113
+ input: "#entry",
114
+ plugins: [virtual({ "#entry": this.getEntry() })]
115
+ });
116
+ await bundler.write({
117
+ inlineDynamicImports: true,
118
+ file: `${outputDirectory}/index.mjs`,
119
+ format: "es"
120
+ });
121
+ }
122
+ async deploy(outputDirectory) {
123
+ const envVars = await this.loadEnvVars();
124
+ const commandArgs = [
125
+ "--scope",
126
+ this.teamId,
127
+ "--cwd",
128
+ outputDirectory,
129
+ "--token",
130
+ this.token,
131
+ "deploy",
132
+ "--yes",
133
+ ...this.projectName ? ["--name", this.projectName] : []
134
+ ];
135
+ child_process.execSync(`npx vercel ${commandArgs.join(" ")}`, {
136
+ cwd: outputDirectory,
137
+ env: {
138
+ // ...this.env,
139
+ PATH: process.env.PATH
140
+ },
141
+ stdio: "inherit"
142
+ });
143
+ this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
144
+ if (envVars.size > 0) {
145
+ await this.syncEnv(envVars);
146
+ } else {
147
+ this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
148
+ }
149
+ }
150
+ };
151
+
152
+ export { VercelDeployer };
package/package.json CHANGED
@@ -1,21 +1,14 @@
1
1
  {
2
2
  "name": "@mastra/deployer-vercel",
3
- "version": "0.0.1-alpha.9",
3
+ "version": "0.1.0-alpha.38",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
- "module": "dist/deployer-vercel.esm.js",
8
7
  "types": "dist/index.d.ts",
9
8
  "exports": {
10
9
  ".": {
11
- "import": {
12
- "types": "./dist/index.d.ts",
13
- "default": "./dist/deployer-vercel.esm.js"
14
- },
15
- "require": {
16
- "types": "./dist/index.d.ts",
17
- "default": "./dist/index.js"
18
- }
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
19
12
  },
20
13
  "./package.json": "./package.json"
21
14
  },
@@ -23,23 +16,24 @@
23
16
  "author": "",
24
17
  "license": "ISC",
25
18
  "dependencies": {
26
- "@mastra/core": "0.1.27-alpha.68",
27
- "@mastra/deployer": "0.0.1-alpha.6"
19
+ "@rollup/plugin-virtual": "^3.0.2",
20
+ "fs-extra": "^11.2.0",
21
+ "@mastra/deployer": "^0.1.0-alpha.33",
22
+ "@mastra/core": "^0.2.0-alpha.87"
28
23
  },
29
24
  "devDependencies": {
30
25
  "@babel/preset-env": "^7.26.0",
31
26
  "@babel/preset-typescript": "^7.26.0",
32
27
  "@tsconfig/recommended": "^1.0.7",
33
- "@types/jsdom": "^21.1.7",
34
28
  "@types/node": "^22.9.0",
35
- "@types/pg": "^8.11.10",
36
- "dts-cli": "^2.0.5",
37
- "vitest": "^2.1.8",
38
- "vercel": "^39.3.0"
29
+ "tsup": "^8.0.1",
30
+ "typescript": "^5.3.3",
31
+ "vercel": "^39.3.0",
32
+ "vitest": "^3.0.4"
39
33
  },
40
34
  "scripts": {
41
- "build": "dts build",
42
- "build:dev": "dts watch",
35
+ "build": "tsup-node src/index.ts --format esm --dts --clean --treeshake",
36
+ "dev": "tsup-node src/index.ts --format esm --dts --clean --treeshake --watch",
43
37
  "test": "vitest run"
44
38
  }
45
39
  }