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

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,220 @@
1
1
  # @mastra/deployer-vercel
2
2
 
3
+ ## 0.0.1-alpha.30
4
+
5
+ ### Patch Changes
6
+
7
+ - 327ece7: Updates for ts versions
8
+ - Updated dependencies [327ece7]
9
+ - @mastra/core@0.1.27-alpha.80
10
+ - @mastra/deployer@0.0.1-alpha.25
11
+
12
+ ## 0.0.1-alpha.29
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [21fe536]
17
+ - @mastra/core@0.1.27-alpha.79
18
+ - @mastra/deployer@0.0.1-alpha.24
19
+
20
+ ## 0.0.1-alpha.28
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [88f18d7]
25
+ - @mastra/deployer@0.0.1-alpha.23
26
+
27
+ ## 0.0.1-alpha.27
28
+
29
+ ### Patch Changes
30
+
31
+ - 44c7c26: Rebuild
32
+
33
+ ## 0.0.1-alpha.26
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [685108a]
38
+ - Updated dependencies [685108a]
39
+ - @mastra/deployer@0.0.1-alpha.22
40
+ - @mastra/core@0.1.27-alpha.78
41
+
42
+ ## 0.0.1-alpha.25
43
+
44
+ ### Patch Changes
45
+
46
+ - 2b75edf: mastra deployers tsup bundling
47
+ - Updated dependencies [8105fae]
48
+ - Updated dependencies [cfb966f]
49
+ - @mastra/core@0.1.27-alpha.77
50
+ - @mastra/deployer@0.0.1-alpha.21
51
+
52
+ ## 0.0.1-alpha.24
53
+
54
+ ### Patch Changes
55
+
56
+ - Updated dependencies [ae7bf94]
57
+ - Updated dependencies [ae7bf94]
58
+ - @mastra/deployer@0.0.1-alpha.20
59
+ - @mastra/core@0.1.27-alpha.76
60
+
61
+ ## 0.0.1-alpha.23
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies [23dcb23]
66
+ - Updated dependencies [7064554]
67
+ - @mastra/core@0.1.27-alpha.75
68
+ - @mastra/deployer@0.0.1-alpha.19
69
+
70
+ ## 0.0.1-alpha.22
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies [7b87567]
75
+ - @mastra/core@0.1.27-alpha.74
76
+ - @mastra/deployer@0.0.1-alpha.18
77
+
78
+ ## 0.0.1-alpha.21
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [3427b95]
83
+ - @mastra/core@0.1.27-alpha.73
84
+ - @mastra/deployer@0.0.1-alpha.17
85
+
86
+ ## 0.0.1-alpha.20
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies [e4d4ede]
91
+ - Updated dependencies [06b2c0a]
92
+ - @mastra/core@0.1.27-alpha.72
93
+ - @mastra/deployer@0.0.1-alpha.16
94
+
95
+ ## 0.0.1-alpha.19
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies [d9c8dd0]
100
+ - @mastra/deployer@0.0.1-alpha.15
101
+ - @mastra/core@0.1.27-alpha.71
102
+
103
+ ## 0.0.1-alpha.18
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [ad2cd74]
108
+ - @mastra/deployer@0.0.1-alpha.14
109
+
110
+ ## 0.0.1-alpha.17
111
+
112
+ ### Patch Changes
113
+
114
+ - Updated dependencies [a1774e7]
115
+ - @mastra/deployer@0.0.1-alpha.13
116
+
117
+ ## 0.0.1-alpha.16
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [28dceab]
122
+ - @mastra/deployer@0.0.1-alpha.12
123
+
124
+ ## 0.0.1-alpha.15
125
+
126
+ ### Patch Changes
127
+
128
+ - bdaf834: publish packages
129
+ - Updated dependencies [bdaf834]
130
+ - @mastra/deployer@0.0.1-alpha.11
131
+
132
+ ## 0.0.1-alpha.14
133
+
134
+ ### Patch Changes
135
+
136
+ - Updated dependencies [dd6d87f]
137
+ - Updated dependencies [04434b6]
138
+ - @mastra/core@0.1.27-alpha.70
139
+ - @mastra/deployer@0.0.1-alpha.10
140
+
141
+ ## 0.0.1-alpha.13
142
+
143
+ ### Patch Changes
144
+
145
+ - Updated dependencies [9066f95]
146
+ - @mastra/deployer@0.0.1-alpha.9
147
+
148
+ ## 0.0.1-alpha.12
149
+
150
+ ### Patch Changes
151
+
152
+ - 0d5a03d: Vector store modules
153
+
154
+ ## 0.0.1-alpha.11
155
+
156
+ ### Patch Changes
157
+
158
+ - Updated dependencies [b425845]
159
+ - @mastra/deployer@0.0.1-alpha.8
160
+
161
+ ## 0.0.1-alpha.10
162
+
163
+ ### Patch Changes
164
+
165
+ - Updated dependencies [1944807]
166
+ - Updated dependencies [9ade36e]
167
+ - @mastra/deployer@0.0.1-alpha.7
168
+ - @mastra/core@0.1.27-alpha.69
169
+
170
+ ## 0.0.1-alpha.9
171
+
172
+ ### Patch Changes
173
+
174
+ - Updated dependencies [291fe57]
175
+ - Updated dependencies [1a41fbf]
176
+ - @mastra/deployer@0.0.1-alpha.6
177
+
178
+ ## 0.0.1-alpha.8
179
+
180
+ ### Patch Changes
181
+
182
+ - Updated dependencies [0be7181]
183
+ - Updated dependencies [0be7181]
184
+ - @mastra/core@0.1.27-alpha.68
185
+ - @mastra/deployer@0.0.1-alpha.5
186
+
187
+ ## 0.0.1-alpha.7
188
+
189
+ ### Patch Changes
190
+
191
+ - Updated dependencies [7babd5c]
192
+ - @mastra/deployer@0.0.1-alpha.4
193
+
194
+ ## 0.0.1-alpha.6
195
+
196
+ ### Patch Changes
197
+
198
+ - Updated dependencies [c8ff2f5]
199
+ - Updated dependencies [a291824]
200
+ - @mastra/core@0.1.27-alpha.67
201
+ - @mastra/deployer@0.0.1-alpha.3
202
+
203
+ ## 0.0.1-alpha.5
204
+
205
+ ### Patch Changes
206
+
207
+ - 88600bc: Deployer fixes
208
+
209
+ ## 0.0.1-alpha.4
210
+
211
+ ### Patch Changes
212
+
213
+ - a9b5ddf: Publish new versions
214
+ - Updated dependencies [a9b5ddf]
215
+ - Updated dependencies [72c280b]
216
+ - @mastra/deployer@0.0.1-alpha.2
217
+
3
218
  ## 0.0.1-alpha.0
4
219
 
5
220
  ### Patch Changes
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.30",
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/core": "0.1.27-alpha.80",
20
+ "@mastra/deployer": "0.0.1-alpha.25"
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
  });