@mastra/deployer-vercel 0.0.0-trigger-playground-ui-package-20250506151043 → 0.0.0-tsconfig-compile-20250703214351

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.
@@ -1,22 +1,12 @@
1
1
  import { Deployer } from '@mastra/deployer';
2
2
 
3
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;
4
+ constructor();
15
5
  prepare(outputDirectory: string): Promise<void>;
16
6
  private getEntry;
17
7
  private writeVercelJSON;
18
8
  bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
19
- deploy(outputDirectory: string): Promise<void>;
9
+ deploy(): Promise<void>;
20
10
  lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
21
11
  }
22
12
 
@@ -1,22 +1,12 @@
1
1
  import { Deployer } from '@mastra/deployer';
2
2
 
3
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;
4
+ constructor();
15
5
  prepare(outputDirectory: string): Promise<void>;
16
6
  private getEntry;
17
7
  private writeVercelJSON;
18
8
  bundle(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
19
- deploy(outputDirectory: string): Promise<void>;
9
+ deploy(): Promise<void>;
20
10
  lint(entryFile: string, outputDirectory: string, toolsPaths: string[]): Promise<void>;
21
11
  }
22
12
 
package/dist/index.cjs CHANGED
@@ -1,107 +1,24 @@
1
1
  'use strict';
2
2
 
3
- var child_process = require('child_process');
4
3
  var fs = require('fs');
5
4
  var path = require('path');
6
5
  var process = require('process');
7
6
  var deployer = require('@mastra/deployer');
7
+ var esm = require('fs-extra/esm');
8
8
 
9
9
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
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
11
  var process__default = /*#__PURE__*/_interopDefault(process);
31
12
 
32
13
  // src/index.ts
33
14
  var VercelDeployer = class extends deployer.Deployer {
34
- teamSlug;
35
- projectName;
36
- token;
37
- constructor({ teamSlug, projectName, token }) {
15
+ constructor() {
38
16
  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
- }
17
+ this.outputDir = path.join(".vercel", "output", "functions", "index.func");
102
18
  }
103
19
  async prepare(outputDirectory) {
104
20
  await super.prepare(outputDirectory);
21
+ this.writeVercelJSON(path.join(outputDirectory, this.outputDir, "..", ".."));
105
22
  }
106
23
  getEntry() {
107
24
  return `
@@ -125,11 +42,6 @@ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agen
125
42
  });
126
43
  });
127
44
 
128
- if (mastra.getStorage()) {
129
- // start storage init in the background
130
- mastra.getStorage().init();
131
- }
132
-
133
45
  registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
134
46
  const storage = mastra.getStorage();
135
47
  if (storage) {
@@ -160,74 +72,66 @@ const app = await createHonoServer(mastra);
160
72
 
161
73
  export const GET = handle(app);
162
74
  export const POST = handle(app);
75
+ export const PUT = handle(app);
76
+ export const DELETE = handle(app);
77
+ export const OPTIONS = handle(app);
78
+ export const HEAD = handle(app);
163
79
  `;
164
80
  }
165
- writeVercelJSON(outputDirectory, files = ["./*"]) {
81
+ writeVercelJSON(outputDirectory) {
166
82
  fs.writeFileSync(
167
- path.join(outputDirectory, this.outputDir, "vercel.json"),
83
+ path.join(outputDirectory, "config.json"),
84
+ JSON.stringify({
85
+ version: 3,
86
+ routes: [
87
+ {
88
+ src: "/(.*)",
89
+ dest: "/"
90
+ }
91
+ ]
92
+ })
93
+ );
94
+ }
95
+ async bundle(entryFile, outputDirectory, toolsPaths) {
96
+ const result = await this._bundle(
97
+ this.getEntry(),
98
+ entryFile,
99
+ outputDirectory,
100
+ toolsPaths,
101
+ path.join(outputDirectory, this.outputDir)
102
+ );
103
+ const nodeVersion = process__default.default.version?.split(".")?.[0]?.replace("v", "") ?? "22";
104
+ fs.writeFileSync(
105
+ path.join(outputDirectory, this.outputDir, ".vc-config.json"),
168
106
  JSON.stringify(
169
107
  {
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
- ]
108
+ handler: "index.mjs",
109
+ launcherType: "Nodejs",
110
+ runtime: `nodejs${nodeVersion}.x`,
111
+ shouldAddHelpers: true
185
112
  },
186
113
  null,
187
114
  2
188
115
  )
189
116
  );
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
117
+ await esm.move(path.join(outputDirectory, ".vercel", "output"), path.join(process__default.default.cwd(), ".vercel", "output"), {
118
+ overwrite: true
195
119
  });
196
- const filesWithoutNodeModules = files.filter(
197
- (file) => typeof file === "string" && !file.startsWith("node_modules")
198
- );
199
- this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
200
120
  return result;
201
121
  }
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
- }
122
+ async deploy() {
123
+ this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
228
124
  }
229
125
  async lint(entryFile, outputDirectory, toolsPaths) {
230
126
  await super.lint(entryFile, outputDirectory, toolsPaths);
127
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
128
+ if (hasLibsql) {
129
+ this.logger.error(
130
+ `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
131
+ Use other Mastra Storage options instead e.g @mastra/pg`
132
+ );
133
+ process__default.default.exit(1);
134
+ }
231
135
  }
232
136
  };
233
137
 
package/dist/index.js CHANGED
@@ -1,82 +1,18 @@
1
- import * as child_process from 'child_process';
2
- import { readFileSync, writeFileSync, readdirSync } from 'fs';
1
+ import { writeFileSync } from 'fs';
3
2
  import { join } from 'path';
4
3
  import process from 'process';
5
4
  import { Deployer } from '@mastra/deployer';
5
+ import { move } from 'fs-extra/esm';
6
6
 
7
7
  // src/index.ts
8
8
  var VercelDeployer = class extends Deployer {
9
- teamSlug;
10
- projectName;
11
- token;
12
- constructor({ teamSlug, projectName, token }) {
9
+ constructor() {
13
10
  super({ name: "VERCEL" });
14
- this.teamSlug = teamSlug;
15
- this.projectName = projectName;
16
- this.token = token;
17
- }
18
- getProjectId({ dir }) {
19
- const projectJsonPath = join(dir, "output", ".vercel", "project.json");
20
- try {
21
- const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
22
- return projectJson.projectId;
23
- } catch {
24
- throw new Error("Could not find project ID. Make sure the project has been deployed first.");
25
- }
26
- }
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 }) {
38
- console.log("Syncing environment variables...");
39
- const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
40
- if (!key || !value) {
41
- throw new Error(`Invalid environment variable format: ${key || value}`);
42
- }
43
- return {
44
- key,
45
- value,
46
- target: ["production", "preview", "development"],
47
- type: "plain"
48
- };
49
- });
50
- try {
51
- const projectId = this.getProjectId({ dir: outputDirectory });
52
- const teamId = await this.getTeamId();
53
- const response = await fetch(
54
- `https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
55
- {
56
- method: "POST",
57
- headers: {
58
- Authorization: `Bearer ${this.token}`,
59
- "Content-Type": "application/json"
60
- },
61
- body: JSON.stringify(vercelEnvVars)
62
- }
63
- );
64
- if (!response.ok) {
65
- const error = await response.json();
66
- throw new Error(`Failed to sync environment variables: ${error.message}`);
67
- }
68
- console.log("\u2713 Successfully synced environment variables");
69
- } catch (error) {
70
- if (error instanceof Error) {
71
- console.error("Failed to sync environment variables:", error.message);
72
- } else {
73
- console.error("Failed to sync environment variables:", error);
74
- }
75
- throw error;
76
- }
11
+ this.outputDir = join(".vercel", "output", "functions", "index.func");
77
12
  }
78
13
  async prepare(outputDirectory) {
79
14
  await super.prepare(outputDirectory);
15
+ this.writeVercelJSON(join(outputDirectory, this.outputDir, "..", ".."));
80
16
  }
81
17
  getEntry() {
82
18
  return `
@@ -100,11 +36,6 @@ registerHook(AvailableHooks.ON_GENERATION, ({ input, output, metric, runId, agen
100
36
  });
101
37
  });
102
38
 
103
- if (mastra.getStorage()) {
104
- // start storage init in the background
105
- mastra.getStorage().init();
106
- }
107
-
108
39
  registerHook(AvailableHooks.ON_EVALUATION, async traceObject => {
109
40
  const storage = mastra.getStorage();
110
41
  if (storage) {
@@ -135,74 +66,66 @@ const app = await createHonoServer(mastra);
135
66
 
136
67
  export const GET = handle(app);
137
68
  export const POST = handle(app);
69
+ export const PUT = handle(app);
70
+ export const DELETE = handle(app);
71
+ export const OPTIONS = handle(app);
72
+ export const HEAD = handle(app);
138
73
  `;
139
74
  }
140
- writeVercelJSON(outputDirectory, files = ["./*"]) {
75
+ writeVercelJSON(outputDirectory) {
141
76
  writeFileSync(
142
- join(outputDirectory, this.outputDir, "vercel.json"),
77
+ join(outputDirectory, "config.json"),
78
+ JSON.stringify({
79
+ version: 3,
80
+ routes: [
81
+ {
82
+ src: "/(.*)",
83
+ dest: "/"
84
+ }
85
+ ]
86
+ })
87
+ );
88
+ }
89
+ async bundle(entryFile, outputDirectory, toolsPaths) {
90
+ const result = await this._bundle(
91
+ this.getEntry(),
92
+ entryFile,
93
+ outputDirectory,
94
+ toolsPaths,
95
+ join(outputDirectory, this.outputDir)
96
+ );
97
+ const nodeVersion = process.version?.split(".")?.[0]?.replace("v", "") ?? "22";
98
+ writeFileSync(
99
+ join(outputDirectory, this.outputDir, ".vc-config.json"),
143
100
  JSON.stringify(
144
101
  {
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
- ]
102
+ handler: "index.mjs",
103
+ launcherType: "Nodejs",
104
+ runtime: `nodejs${nodeVersion}.x`,
105
+ shouldAddHelpers: true
160
106
  },
161
107
  null,
162
108
  2
163
109
  )
164
110
  );
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
111
+ await move(join(outputDirectory, ".vercel", "output"), join(process.cwd(), ".vercel", "output"), {
112
+ overwrite: true
170
113
  });
171
- const filesWithoutNodeModules = files.filter(
172
- (file) => typeof file === "string" && !file.startsWith("node_modules")
173
- );
174
- this.writeVercelJSON(outputDirectory, filesWithoutNodeModules);
175
114
  return result;
176
115
  }
177
- async deploy(outputDirectory) {
178
- const envVars = await this.loadEnvVars();
179
- const commandArgs = [
180
- "--scope",
181
- this.teamSlug,
182
- "--cwd",
183
- join(outputDirectory, this.outputDir),
184
- "--token",
185
- this.token,
186
- "deploy",
187
- "--yes",
188
- ...this.projectName ? ["--name", this.projectName] : []
189
- ];
190
- child_process.execSync(`npx vercel ${commandArgs.join(" ")}`, {
191
- cwd: join(outputDirectory, this.outputDir),
192
- env: {
193
- PATH: process.env.PATH
194
- },
195
- stdio: "inherit"
196
- });
197
- this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
198
- if (envVars.size > 0) {
199
- await this.syncEnv(envVars, { outputDirectory });
200
- } else {
201
- this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
202
- }
116
+ async deploy() {
117
+ this.logger?.info("Deploying to Vercel is deprecated. Please use the Vercel dashboard to deploy.");
203
118
  }
204
119
  async lint(entryFile, outputDirectory, toolsPaths) {
205
120
  await super.lint(entryFile, outputDirectory, toolsPaths);
121
+ const hasLibsql = await this.deps.checkDependencies(["@mastra/libsql"]) === `ok`;
122
+ if (hasLibsql) {
123
+ this.logger.error(
124
+ `Vercel Deployer does not support @libsql/client(which may have been installed by @mastra/libsql) as a dependency.
125
+ Use other Mastra Storage options instead e.g @mastra/pg`
126
+ );
127
+ process.exit(1);
128
+ }
206
129
  }
207
130
  };
208
131
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer-vercel",
3
- "version": "0.0.0-trigger-playground-ui-package-20250506151043",
3
+ "version": "0.0.0-tsconfig-compile-20250703214351",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -27,18 +27,21 @@
27
27
  "dependencies": {
28
28
  "@rollup/plugin-virtual": "^3.0.2",
29
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"
30
+ "@mastra/deployer": "0.0.0-tsconfig-compile-20250703214351"
32
31
  },
33
32
  "devDependencies": {
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"
33
+ "@microsoft/api-extractor": "^7.52.8",
34
+ "@types/fs-extra": "^11.0.4",
35
+ "@types/node": "^20.19.0",
36
+ "eslint": "^9.29.0",
37
+ "tsup": "^8.5.0",
38
+ "typescript": "^5.8.3",
39
+ "vitest": "^3.2.4",
40
+ "@internal/lint": "0.0.0-tsconfig-compile-20250703214351",
41
+ "@mastra/core": "0.0.0-tsconfig-compile-20250703214351"
42
+ },
43
+ "peerDependencies": {
44
+ "@mastra/core": "0.0.0-tsconfig-compile-20250703214351"
42
45
  },
43
46
  "scripts": {
44
47
  "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",