@mastra/deployer-vercel 0.1.14-alpha.0 → 0.1.14-alpha.1

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/README.md CHANGED
@@ -25,7 +25,7 @@ import { Mastra } from '@mastra/core';
25
25
  import { VercelDeployer } from '@mastra/deployer-vercel';
26
26
 
27
27
  const deployer = new VercelDeployer({
28
- teamId: 'your-team-id',
28
+ teamSlug: 'your-team-slug',
29
29
  projectName: 'your-project-name',
30
30
  token: 'your-vercel-token',
31
31
  });
@@ -40,7 +40,7 @@ const mastra = new Mastra({
40
40
 
41
41
  ### Constructor Options
42
42
 
43
- - `teamId` (required): Your Vercel team ID or username
43
+ - `teamSlug` (required): Your Vercel team slug
44
44
  - `projectName`: Name of your Vercel project (will be created if it doesn't exist)
45
45
  - `token`: Your Vercel API token (required for authentication)
46
46
 
@@ -1,16 +1,17 @@
1
1
  import { Deployer } from '@mastra/deployer';
2
2
 
3
3
  export declare class VercelDeployer extends Deployer {
4
- private teamId;
4
+ private teamSlug;
5
5
  private projectName;
6
6
  private token;
7
- constructor({ teamId, projectName, token }: {
8
- teamId: string;
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;
@@ -1,16 +1,17 @@
1
1
  import { Deployer } from '@mastra/deployer';
2
2
 
3
3
  export declare class VercelDeployer extends Deployer {
4
- private teamId;
4
+ private teamSlug;
5
5
  private projectName;
6
6
  private token;
7
- constructor({ teamId, projectName, token }: {
8
- teamId: string;
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 CHANGED
@@ -31,12 +31,12 @@ var process__default = /*#__PURE__*/_interopDefault(process);
31
31
 
32
32
  // src/index.ts
33
33
  var VercelDeployer = class extends deployer.Deployer {
34
- teamId;
34
+ teamSlug;
35
35
  projectName;
36
36
  token;
37
- constructor({ teamId, projectName, token }) {
37
+ constructor({ teamSlug, projectName, token }) {
38
38
  super({ name: "VERCEL" });
39
- this.teamId = teamId;
39
+ this.teamSlug = teamSlug;
40
40
  this.projectName = projectName;
41
41
  this.token = token;
42
42
  }
@@ -67,7 +67,7 @@ var VercelDeployer = class extends deployer.Deployer {
67
67
  );
68
68
  }
69
69
  getProjectId({ dir }) {
70
- const projectJsonPath = path.join(dir, ".vercel", "project.json");
70
+ const projectJsonPath = path.join(dir, "output", ".vercel", "project.json");
71
71
  try {
72
72
  const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, "utf-8"));
73
73
  return projectJson.projectId;
@@ -75,7 +75,17 @@ var VercelDeployer = class extends deployer.Deployer {
75
75
  throw new Error("Could not find project ID. Make sure the project has been deployed first.");
76
76
  }
77
77
  }
78
- async syncEnv(envVars) {
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 }) {
79
89
  console.log("Syncing environment variables...");
80
90
  const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
81
91
  if (!key || !value) {
@@ -89,9 +99,10 @@ var VercelDeployer = class extends deployer.Deployer {
89
99
  };
90
100
  });
91
101
  try {
92
- const projectId = this.getProjectId({ dir: process__default.default.cwd() });
102
+ const projectId = this.getProjectId({ dir: outputDirectory });
103
+ const teamId = await this.getTeamId();
93
104
  const response = await fetch(
94
- `https://api.vercel.com/v10/projects/${projectId}/env?teamId=${this.teamId}&upsert=true`,
105
+ `https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
95
106
  {
96
107
  method: "POST",
97
108
  headers: {
@@ -138,7 +149,7 @@ export const POST = handle(app);
138
149
  const envVars = await this.loadEnvVars();
139
150
  const commandArgs = [
140
151
  "--scope",
141
- this.teamId,
152
+ this.teamSlug,
142
153
  "--cwd",
143
154
  path.join(outputDirectory, this.outputDir),
144
155
  "--token",
@@ -150,14 +161,13 @@ export const POST = handle(app);
150
161
  child_process__namespace.execSync(`npx vercel ${commandArgs.join(" ")}`, {
151
162
  cwd: path.join(outputDirectory, this.outputDir),
152
163
  env: {
153
- // ...this.env,
154
164
  PATH: process__default.default.env.PATH
155
165
  },
156
166
  stdio: "inherit"
157
167
  });
158
168
  this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
159
169
  if (envVars.size > 0) {
160
- await this.syncEnv(envVars);
170
+ await this.syncEnv(envVars, { outputDirectory });
161
171
  } else {
162
172
  this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
163
173
  }
package/dist/index.js CHANGED
@@ -6,12 +6,12 @@ import { Deployer } from '@mastra/deployer';
6
6
 
7
7
  // src/index.ts
8
8
  var VercelDeployer = class extends Deployer {
9
- teamId;
9
+ teamSlug;
10
10
  projectName;
11
11
  token;
12
- constructor({ teamId, projectName, token }) {
12
+ constructor({ teamSlug, projectName, token }) {
13
13
  super({ name: "VERCEL" });
14
- this.teamId = teamId;
14
+ this.teamSlug = teamSlug;
15
15
  this.projectName = projectName;
16
16
  this.token = token;
17
17
  }
@@ -42,7 +42,7 @@ var VercelDeployer = class extends Deployer {
42
42
  );
43
43
  }
44
44
  getProjectId({ dir }) {
45
- const projectJsonPath = join(dir, ".vercel", "project.json");
45
+ const projectJsonPath = join(dir, "output", ".vercel", "project.json");
46
46
  try {
47
47
  const projectJson = JSON.parse(readFileSync(projectJsonPath, "utf-8"));
48
48
  return projectJson.projectId;
@@ -50,7 +50,17 @@ var VercelDeployer = class extends Deployer {
50
50
  throw new Error("Could not find project ID. Make sure the project has been deployed first.");
51
51
  }
52
52
  }
53
- async syncEnv(envVars) {
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 }) {
54
64
  console.log("Syncing environment variables...");
55
65
  const vercelEnvVars = Array.from(envVars.entries()).map(([key, value]) => {
56
66
  if (!key || !value) {
@@ -64,9 +74,10 @@ var VercelDeployer = class extends Deployer {
64
74
  };
65
75
  });
66
76
  try {
67
- const projectId = this.getProjectId({ dir: process.cwd() });
77
+ const projectId = this.getProjectId({ dir: outputDirectory });
78
+ const teamId = await this.getTeamId();
68
79
  const response = await fetch(
69
- `https://api.vercel.com/v10/projects/${projectId}/env?teamId=${this.teamId}&upsert=true`,
80
+ `https://api.vercel.com/v10/projects/${projectId}/env?teamId=${teamId}&upsert=true`,
70
81
  {
71
82
  method: "POST",
72
83
  headers: {
@@ -113,7 +124,7 @@ export const POST = handle(app);
113
124
  const envVars = await this.loadEnvVars();
114
125
  const commandArgs = [
115
126
  "--scope",
116
- this.teamId,
127
+ this.teamSlug,
117
128
  "--cwd",
118
129
  join(outputDirectory, this.outputDir),
119
130
  "--token",
@@ -125,14 +136,13 @@ export const POST = handle(app);
125
136
  child_process.execSync(`npx vercel ${commandArgs.join(" ")}`, {
126
137
  cwd: join(outputDirectory, this.outputDir),
127
138
  env: {
128
- // ...this.env,
129
139
  PATH: process.env.PATH
130
140
  },
131
141
  stdio: "inherit"
132
142
  });
133
143
  this.logger.info("Deployment started on Vercel. You can wait for it to finish or exit this command.");
134
144
  if (envVars.size > 0) {
135
- await this.syncEnv(envVars);
145
+ await this.syncEnv(envVars, { outputDirectory });
136
146
  } else {
137
147
  this.logger.info("\nAdd your ENV vars to .env or your vercel dashboard.\n");
138
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/deployer-vercel",
3
- "version": "0.1.14-alpha.0",
3
+ "version": "0.1.14-alpha.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -27,17 +27,17 @@
27
27
  "dependencies": {
28
28
  "@rollup/plugin-virtual": "^3.0.2",
29
29
  "fs-extra": "^11.3.0",
30
- "@mastra/core": "^0.6.5-alpha.0",
31
- "@mastra/deployer": "^0.2.5-alpha.0"
30
+ "@mastra/core": "^0.7.0-alpha.1",
31
+ "@mastra/deployer": "^0.2.5-alpha.1"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@microsoft/api-extractor": "^7.52.1",
35
- "@types/node": "^22.13.10",
36
- "eslint": "^9.22.0",
35
+ "@types/node": "^20.17.27",
36
+ "eslint": "^9.23.0",
37
37
  "tsup": "^8.4.0",
38
38
  "typescript": "^5.8.2",
39
39
  "vercel": "^39.4.2",
40
- "vitest": "^3.0.8",
40
+ "vitest": "^3.0.9",
41
41
  "@internal/lint": "0.0.1"
42
42
  },
43
43
  "scripts": {