@mastra/deployer-vercel 0.0.1-alpha.3 → 0.0.1-alpha.31

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,228 @@
1
1
  # @mastra/deployer-vercel
2
2
 
3
+ ## 0.0.1-alpha.31
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [9fb3039]
8
+ - @mastra/core@0.1.27-alpha.81
9
+ - @mastra/deployer@0.0.1-alpha.26
10
+
11
+ ## 0.0.1-alpha.30
12
+
13
+ ### Patch Changes
14
+
15
+ - 327ece7: Updates for ts versions
16
+ - Updated dependencies [327ece7]
17
+ - @mastra/core@0.1.27-alpha.80
18
+ - @mastra/deployer@0.0.1-alpha.25
19
+
20
+ ## 0.0.1-alpha.29
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [21fe536]
25
+ - @mastra/core@0.1.27-alpha.79
26
+ - @mastra/deployer@0.0.1-alpha.24
27
+
28
+ ## 0.0.1-alpha.28
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [88f18d7]
33
+ - @mastra/deployer@0.0.1-alpha.23
34
+
35
+ ## 0.0.1-alpha.27
36
+
37
+ ### Patch Changes
38
+
39
+ - 44c7c26: Rebuild
40
+
41
+ ## 0.0.1-alpha.26
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies [685108a]
46
+ - Updated dependencies [685108a]
47
+ - @mastra/deployer@0.0.1-alpha.22
48
+ - @mastra/core@0.1.27-alpha.78
49
+
50
+ ## 0.0.1-alpha.25
51
+
52
+ ### Patch Changes
53
+
54
+ - 2b75edf: mastra deployers tsup bundling
55
+ - Updated dependencies [8105fae]
56
+ - Updated dependencies [cfb966f]
57
+ - @mastra/core@0.1.27-alpha.77
58
+ - @mastra/deployer@0.0.1-alpha.21
59
+
60
+ ## 0.0.1-alpha.24
61
+
62
+ ### Patch Changes
63
+
64
+ - Updated dependencies [ae7bf94]
65
+ - Updated dependencies [ae7bf94]
66
+ - @mastra/deployer@0.0.1-alpha.20
67
+ - @mastra/core@0.1.27-alpha.76
68
+
69
+ ## 0.0.1-alpha.23
70
+
71
+ ### Patch Changes
72
+
73
+ - Updated dependencies [23dcb23]
74
+ - Updated dependencies [7064554]
75
+ - @mastra/core@0.1.27-alpha.75
76
+ - @mastra/deployer@0.0.1-alpha.19
77
+
78
+ ## 0.0.1-alpha.22
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [7b87567]
83
+ - @mastra/core@0.1.27-alpha.74
84
+ - @mastra/deployer@0.0.1-alpha.18
85
+
86
+ ## 0.0.1-alpha.21
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies [3427b95]
91
+ - @mastra/core@0.1.27-alpha.73
92
+ - @mastra/deployer@0.0.1-alpha.17
93
+
94
+ ## 0.0.1-alpha.20
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [e4d4ede]
99
+ - Updated dependencies [06b2c0a]
100
+ - @mastra/core@0.1.27-alpha.72
101
+ - @mastra/deployer@0.0.1-alpha.16
102
+
103
+ ## 0.0.1-alpha.19
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [d9c8dd0]
108
+ - @mastra/deployer@0.0.1-alpha.15
109
+ - @mastra/core@0.1.27-alpha.71
110
+
111
+ ## 0.0.1-alpha.18
112
+
113
+ ### Patch Changes
114
+
115
+ - Updated dependencies [ad2cd74]
116
+ - @mastra/deployer@0.0.1-alpha.14
117
+
118
+ ## 0.0.1-alpha.17
119
+
120
+ ### Patch Changes
121
+
122
+ - Updated dependencies [a1774e7]
123
+ - @mastra/deployer@0.0.1-alpha.13
124
+
125
+ ## 0.0.1-alpha.16
126
+
127
+ ### Patch Changes
128
+
129
+ - Updated dependencies [28dceab]
130
+ - @mastra/deployer@0.0.1-alpha.12
131
+
132
+ ## 0.0.1-alpha.15
133
+
134
+ ### Patch Changes
135
+
136
+ - bdaf834: publish packages
137
+ - Updated dependencies [bdaf834]
138
+ - @mastra/deployer@0.0.1-alpha.11
139
+
140
+ ## 0.0.1-alpha.14
141
+
142
+ ### Patch Changes
143
+
144
+ - Updated dependencies [dd6d87f]
145
+ - Updated dependencies [04434b6]
146
+ - @mastra/core@0.1.27-alpha.70
147
+ - @mastra/deployer@0.0.1-alpha.10
148
+
149
+ ## 0.0.1-alpha.13
150
+
151
+ ### Patch Changes
152
+
153
+ - Updated dependencies [9066f95]
154
+ - @mastra/deployer@0.0.1-alpha.9
155
+
156
+ ## 0.0.1-alpha.12
157
+
158
+ ### Patch Changes
159
+
160
+ - 0d5a03d: Vector store modules
161
+
162
+ ## 0.0.1-alpha.11
163
+
164
+ ### Patch Changes
165
+
166
+ - Updated dependencies [b425845]
167
+ - @mastra/deployer@0.0.1-alpha.8
168
+
169
+ ## 0.0.1-alpha.10
170
+
171
+ ### Patch Changes
172
+
173
+ - Updated dependencies [1944807]
174
+ - Updated dependencies [9ade36e]
175
+ - @mastra/deployer@0.0.1-alpha.7
176
+ - @mastra/core@0.1.27-alpha.69
177
+
178
+ ## 0.0.1-alpha.9
179
+
180
+ ### Patch Changes
181
+
182
+ - Updated dependencies [291fe57]
183
+ - Updated dependencies [1a41fbf]
184
+ - @mastra/deployer@0.0.1-alpha.6
185
+
186
+ ## 0.0.1-alpha.8
187
+
188
+ ### Patch Changes
189
+
190
+ - Updated dependencies [0be7181]
191
+ - Updated dependencies [0be7181]
192
+ - @mastra/core@0.1.27-alpha.68
193
+ - @mastra/deployer@0.0.1-alpha.5
194
+
195
+ ## 0.0.1-alpha.7
196
+
197
+ ### Patch Changes
198
+
199
+ - Updated dependencies [7babd5c]
200
+ - @mastra/deployer@0.0.1-alpha.4
201
+
202
+ ## 0.0.1-alpha.6
203
+
204
+ ### Patch Changes
205
+
206
+ - Updated dependencies [c8ff2f5]
207
+ - Updated dependencies [a291824]
208
+ - @mastra/core@0.1.27-alpha.67
209
+ - @mastra/deployer@0.0.1-alpha.3
210
+
211
+ ## 0.0.1-alpha.5
212
+
213
+ ### Patch Changes
214
+
215
+ - 88600bc: Deployer fixes
216
+
217
+ ## 0.0.1-alpha.4
218
+
219
+ ### Patch Changes
220
+
221
+ - a9b5ddf: Publish new versions
222
+ - Updated dependencies [a9b5ddf]
223
+ - Updated dependencies [72c280b]
224
+ - @mastra/deployer@0.0.1-alpha.2
225
+
3
226
  ## 0.0.1-alpha.0
4
227
 
5
228
  ### 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,5 +1,6 @@
1
1
  import { MastraDeployer } from '@mastra/core';
2
- export declare class VercelDeployer extends MastraDeployer {
2
+
3
+ declare class VercelDeployer extends MastraDeployer {
3
4
  constructor({ scope, env, projectName }: {
4
5
  env?: Record<string, any>;
5
6
  scope: string;
@@ -22,4 +23,5 @@ export declare class VercelDeployer extends MastraDeployer {
22
23
  dir: string;
23
24
  }): void;
24
25
  }
25
- //# sourceMappingURL=index.d.ts.map
26
+
27
+ export { VercelDeployer };
package/dist/index.js CHANGED
@@ -1,8 +1,140 @@
1
+ import { MastraDeployer } from '@mastra/core';
2
+ import * as child_process from 'child_process';
3
+ import { writeFileSync, readFileSync } from 'fs';
4
+ import { join } from 'path';
1
5
 
2
- 'use strict'
6
+ // src/index.ts
7
+ var VercelDeployer = class extends MastraDeployer {
8
+ constructor({ scope, env, projectName }) {
9
+ super({ scope, env, projectName });
10
+ }
11
+ writeFiles({ dir }) {
12
+ this.writeIndex({ dir });
13
+ writeFileSync(
14
+ join(dir, "vercel.json"),
15
+ JSON.stringify(
16
+ {
17
+ version: 2,
18
+ installCommand: "npm install --omit=dev",
19
+ builds: [
20
+ {
21
+ src: "index.mjs",
22
+ use: "@vercel/node",
23
+ config: { includeFiles: ["**"] }
24
+ }
25
+ ],
26
+ routes: [
27
+ {
28
+ src: "/(.*)",
29
+ dest: "index.mjs"
30
+ }
31
+ ]
32
+ },
33
+ null,
34
+ 2
35
+ )
36
+ );
37
+ }
38
+ getProjectId({ dir }) {
39
+ const projectJsonPath = join(dir, ".vercel", "project.json");
40
+ try {
41
+ const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
42
+ return projectJson.projectId;
43
+ } catch (error) {
44
+ throw new Error("Could not find project ID. Make sure the project has been deployed first.");
45
+ }
46
+ }
47
+ async syncEnv({ scope, dir, token }) {
48
+ const envFiles = this.getEnvFiles();
49
+ const envVars = [];
50
+ for (const file of envFiles) {
51
+ const vars = this.parseEnvFile(file);
52
+ envVars.push(...vars);
53
+ }
54
+ console.log("Syncing environment variables...");
55
+ const vercelEnvVars = envVars.map((envVar) => {
56
+ const [key, value] = envVar.split("=");
57
+ if (!key || !value) {
58
+ throw new Error(`Invalid environment variable format: ${envVar}`);
59
+ }
60
+ return {
61
+ key,
62
+ value,
63
+ target: ["production", "preview", "development"],
64
+ type: "plain"
65
+ };
66
+ });
67
+ try {
68
+ const projectId = this.getProjectId({ dir });
69
+ const response = await fetch(`https://api.vercel.com/v10/projects/${projectId}/env?teamId=${scope}&upsert=true`, {
70
+ method: "POST",
71
+ headers: {
72
+ Authorization: `Bearer ${token}`,
73
+ "Content-Type": "application/json"
74
+ },
75
+ body: JSON.stringify(vercelEnvVars)
76
+ });
77
+ if (!response.ok) {
78
+ const error = await response.json();
79
+ throw new Error(`Failed to sync environment variables: ${error.message}`);
80
+ }
81
+ console.log("\u2713 Successfully synced environment variables");
82
+ } catch (error) {
83
+ if (error instanceof Error) {
84
+ console.error("Failed to sync environment variables:", error.message);
85
+ } else {
86
+ console.error("Failed to sync environment variables:", error);
87
+ }
88
+ throw error;
89
+ }
90
+ }
91
+ async deploy({ dir, token }) {
92
+ const envFiles = this.getEnvFiles();
93
+ const envVars = [];
94
+ for (const file of envFiles) {
95
+ const vars = this.parseEnvFile(file);
96
+ envVars.push(...vars);
97
+ }
98
+ const commandArgs = [
99
+ "--scope",
100
+ this.scope,
101
+ "--cwd",
102
+ dir,
103
+ "deploy",
104
+ "--token",
105
+ token,
106
+ "--yes",
107
+ ...this.projectName ? ["--name", this.projectName] : []
108
+ ];
109
+ for (const envVar of envVars) {
110
+ commandArgs.push("--env", envVar);
111
+ }
112
+ child_process.execSync(`vercel ${commandArgs.join(" ")}`, {
113
+ cwd: dir,
114
+ env: {
115
+ ...this.env,
116
+ PATH: process.env.PATH
117
+ },
118
+ stdio: "inherit"
119
+ });
120
+ console.log("Deployment started on Vercel. You can wait for it to finish or exit this command.");
121
+ if (envVars.length > 0) {
122
+ await this.syncEnv({ scope: this.scope, dir, token });
123
+ } else {
124
+ console.log("\nAdd your ENV vars to .env or your vercel dashboard.\n");
125
+ }
126
+ }
127
+ writeIndex({ dir }) {
128
+ writeFileSync(
129
+ join(dir, "index.mjs"),
130
+ `
131
+ import { handle } from 'hono/vercel'
132
+ import { app } from './hono.mjs';
133
+ export const GET = handle(app);
134
+ export const POST = handle(app);
135
+ `
136
+ );
137
+ }
138
+ };
3
139
 
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
- }
140
+ export { VercelDeployer };
package/package.json CHANGED
@@ -1,21 +1,14 @@
1
1
  {
2
2
  "name": "@mastra/deployer-vercel",
3
- "version": "0.0.1-alpha.3",
3
+ "version": "0.0.1-alpha.31",
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,22 @@
23
16
  "author": "",
24
17
  "license": "ISC",
25
18
  "dependencies": {
26
- "@mastra/core": "0.1.27-alpha.66",
27
- "@mastra/deployer": "0.0.1-alpha.1"
19
+ "@mastra/deployer": "0.0.1-alpha.26",
20
+ "@mastra/core": "0.1.27-alpha.81"
28
21
  },
29
22
  "devDependencies": {
30
23
  "@babel/preset-env": "^7.26.0",
31
24
  "@babel/preset-typescript": "^7.26.0",
32
25
  "@tsconfig/recommended": "^1.0.7",
33
- "@types/jsdom": "^21.1.7",
34
26
  "@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"
27
+ "tsup": "^8.0.1",
28
+ "typescript": "^5.3.3",
29
+ "vercel": "^39.3.0",
30
+ "vitest": "^3.0.4"
39
31
  },
40
32
  "scripts": {
41
- "build": "dts build",
42
- "build:dev": "dts watch",
33
+ "build": "tsup-node src/index.ts --format esm --dts --clean --treeshake",
34
+ "dev": "tsup-node src/index.ts --format esm --dts --clean --treeshake --watch",
43
35
  "test": "vitest run"
44
36
  }
45
37
  }
package/src/index.ts CHANGED
@@ -19,6 +19,7 @@ export class VercelDeployer extends MastraDeployer {
19
19
  constructor({ scope, env, projectName }: { env?: Record<string, any>; scope: string; projectName: string }) {
20
20
  super({ scope, env, projectName });
21
21
  }
22
+
22
23
  writeFiles({ dir }: { dir: string }): void {
23
24
  this.writeIndex({ dir });
24
25
 
@@ -123,7 +124,6 @@ export class VercelDeployer extends MastraDeployer {
123
124
 
124
125
  // Create the command array with base arguments
125
126
  const commandArgs = [
126
- '--debug',
127
127
  '--scope',
128
128
  this.scope as string,
129
129
  '--cwd',
@@ -141,9 +141,6 @@ export class VercelDeployer extends MastraDeployer {
141
141
  }
142
142
 
143
143
  // Run the Vercel deploy command
144
- // console.log('Running command:', 'vercel', commandArgs.join(' '));
145
- console.log(`vercel ${commandArgs.join(' ')}`);
146
-
147
144
  child_process.execSync(`vercel ${commandArgs.join(' ')}`, {
148
145
  cwd: dir,
149
146
  env: {
package/tsconfig.json CHANGED
@@ -1,10 +1,5 @@
1
1
  {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "moduleResolution": "bundler",
5
- "outDir": "./dist",
6
- "rootDir": "./src"
7
- },
2
+ "extends": "../../tsconfig.node.json",
8
3
  "include": ["src/**/*"],
9
4
  "exclude": ["node_modules", "**/*.test.ts"]
10
5
  }
package/vitest.config.ts CHANGED
@@ -2,7 +2,7 @@ import { defineConfig } from 'vitest/config';
2
2
 
3
3
  export default defineConfig({
4
4
  test: {
5
- globals: true,
5
+ environment: 'node',
6
6
  include: ['src/**/*.test.ts'],
7
7
  },
8
8
  });